summaryrefslogtreecommitdiff
path: root/Tests/LibC
AgeCommit message (Collapse)Author
2023-04-09Tests: Use `FileSystem` instead of `DeprecatedFile`Cameron Youell
2023-04-03AK+Everywhere: Change AK::fill_with_random to accept a Bytes objectTimothy Flynn
Rather than the very C-like API we currently have, accepting a void* and a length, let's take a Bytes object instead. In almost all existing cases, the compiler figures out the length.
2023-02-13LibCore: Rename `File` to `DeprecatedFile`Tim Schumacher
As usual, this removes many unused includes and moves used includes further down the chain.
2023-01-27AK: Remove StringBuilder::build() in favor of to_deprecated_string()Linus Groh
Having an alias function that only wraps another one is silly, and keeping the more obvious name should flush out more uses of deprecated strings. No behavior change.
2023-01-20Tests: Use AK::shuffle() for shufflingSam Atkins
2023-01-19AK: Don't write trailing zeros with %gPeter Elliott
2023-01-07Everywhere: Remove "LibC/" includes, add lint-rule against itBen Wiederhake
2023-01-07Tests: Remove already-completed fixmeBen Wiederhake
2023-01-02Everywhere: Remove unused includes of LibC/stdlib.hBen Wiederhake
These instances were detected by searching for files that include stdlib.h, but don't match the regex: \\b(_abort|abort|abs|aligned_alloc|arc4random|arc4random_buf|arc4random_ uniform|atexit|atof|atoi|atol|atoll|bsearch|calloc|clearenv|div|div_t|ex it|_Exit|EXIT_FAILURE|EXIT_SUCCESS|free|getenv|getprogname|grantpt|labs| ldiv|ldiv_t|llabs|lldiv|lldiv_t|malloc|malloc_good_size|malloc_size|mble n|mbstowcs|mbtowc|mkdtemp|mkstemp|mkstemps|mktemp|posix_memalign|posix_o penpt|ptsname|ptsname_r|putenv|qsort|qsort_r|rand|RAND_MAX|random|reallo c|realpath|secure_getenv|serenity_dump_malloc_stats|serenity_setenv|sete nv|setprogname|srand|srandom|strtod|strtof|strtol|strtold|strtoll|strtou l|strtoull|system|unlockpt|unsetenv|wcstombs|wctomb)\\b (Without the linebreaks.) This regex is pessimistic, so there might be more files that don't actually use anything from the stdlib. In theory, one might use LibCPP to detect things like this automatically, but let's do this one step after another.
2023-01-02Everywhere: Remove unused includes of AK/Format.hBen Wiederhake
These instances were detected by searching for files that include AK/Format.h, but don't match the regex: \\b(CheckedFormatString|critical_dmesgln|dbgln|dbgln_if|dmesgln|FormatBu ilder|__FormatIfSupported|FormatIfSupported|FormatParser|FormatString|Fo rmattable|Formatter|__format_value|HasFormatter|max_format_arguments|out |outln|set_debug_enabled|StandardFormatter|TypeErasedFormatParams|TypeEr asedParameter|VariadicFormatParams|v_critical_dmesgln|vdbgln|vdmesgln|vf ormat|vout|warn|warnln|warnln_if)\\b (Without the linebreaks.) This regex is pessimistic, so there might be more files that don't actually use any formatting functions. Observe that this revealed that Userland/Libraries/LibC/signal.cpp is missing an include. In theory, one might use LibCPP to detect things like this automatically, but let's do this one step after another.
2023-01-01Kernel+Tests: Allow deleting someone else's file in my sticky directoryAndreas Kling
This should be allowed according to Dr. POSIX. :^)
2023-01-01Kernel+Tests: Remove inaccurate FIXME in sys$rmdir()Andreas Kling
We were already handling the rmdir("..") case by refusing to remove directories that were not empty. This patch removes a FIXME from January 2019 and adds a test. :^)
2023-01-01Kernel+Tests: Make sys$rmdir() fail with EINVAL if basename is "."Andreas Kling
Dr. POSIX says that we should reject attempts to rmdir() the file named "." so this patch does exactly that. We also add a test. This solves a FIXME from January 2019. :^)
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-11-19LibC+Tests: Simplify getpwuid_r() and getpwnam_r() and add testsAndreas Kling
These functions are now implemented in terms of getpwent_r() which allows us to remove two FIXMEs about global variable shenanigans. I'm also adding tests for both APIs. :^)
2022-10-27Tests: Add pthread scheduler priority testskleines Filmröllchen
2022-10-25Tests: Use new global variables at /sys/kernel/ directoryLiav A
2022-10-23LibC+Tests: Add extra tests for special values for strtoddavidot
2022-10-16Kernel: Use more fine-grained content data block granularity in TmpFSLiav A
Instead of just having a giant KBuffer that is not resizeable easily, we use multiple AnonymousVMObjects in one Vector to store them. The idea is to not have to do giant memcpy or memset each time we need to allocate or de-allocate memory for TmpFS inodes, but instead, we can allocate only the desired block range when trying to write to it. Therefore, it is also possible to have data holes in the inode content in case of skipping an entire set of one data block or more when writing to the inode content, thus, making memory usage much more efficient. To ensure we don't run out of virtual memory range, don't allocate a Region in advance to each TmpFSInode, but instead try to allocate a Region on IO operation, and then use that Region to map the VMObjects in IO loop.
2022-10-14AK+Toolchain: Make char and wchar_t behave on AARCH64Gunnar Beutner
By default char and wchar_t are unsigned on AARCH64. This fixes a bunch of related compiler errors.
2022-10-06LibC: Implement `mkstemps()` in stdlib and add a testEWouters
`mkstemps` generates a unique temporary file name from a pattern like `prefixXXXXXXsuffix` where `prefix` and `suffix` can be any string with only characters that are valid in a filename. The second parameter is the length of the suffix. `mkstemp` is `mkstemps` with suffix length 0, so to avoid code duplication it calls `mkstemps`. It is unlikely this has any significant performance impact on SerenityOS. `generate_unique_filename` now takes the suffix length as a `size_t`. The original behavior of this function is preserved when specifying a suffix length of 0. All original uses of this function have been adapted. `mkstemps()` was added because it is required by version 4.6.3 of the ccache port.
2022-10-04AK+Everywhere: Add AK_COMPILER_{GCC,CLANG} and use them most placesNico Weber
Doesn't use them in libc headers so that those don't have to pull in AK/Platform.h. AK_COMPILER_GCC is set _only_ for gcc, not for clang too. (__GNUC__ is defined in clang builds as well.) Using AK_COMPILER_GCC simplifies things some. AK_COMPILER_CLANG isn't as much of a win, other than that it's consistent with AK_COMPILER_GCC.
2022-09-16Tests: Move the former LibM test into the LibC namespaceTim Schumacher
2022-09-14Everywhere: Fix a variety of typosBrian Gianforcaro
Spelling fixes found by `codespell`.
2022-09-09LibC: Consume all whitespace in `scanf` if present in formatJelle Raaijmakers
We were consuming all whitespace from the format, but not the input lexer - that was left to the actual format parsing code. It so happened that we did not account for whitespace with the conversion specifier '[', causing whitespace to end up in the output variables. Fix this by always consuming all whitespace and removing the whitespace logic from the conversion code.
2022-07-22Tests: Add a test for `pthread_cancel`Tim Schumacher
2022-07-22Tests: Add tests for `pthread_setcancel{state,type}`Tim Schumacher
We likely won't be able to test `pthread_cancel` itself, but this at least makes sure that we use the correct values by default and that we correctly reject invalid values.
2022-07-19Tests: Move the LibPthread tests to the correct namespaceTim Schumacher
2022-07-12Everywhere: Explicitly specify the size in StringView constructorssin-ack
This commit moves the length calculations out to be directly on the StringView users. This is an important step towards the goal of removing StringView(char const*), as it moves the responsibility of calculating the size of the string to the user of the StringView (which will prevent naive uses causing OOB access).
2022-07-04Tests: Move sprintf test from AK/ to LibC/Daniel Bertalan
This test doesn't test AK::String, but LibC's sprintf instead, so it does not belong in `Tests/AK`. This also means this test won't be ran on Lagom using the host OS's printf implementation. Fixes a deprecated declaration warning when compiling with macOS SDK 13.
2022-06-30Tests: Add tests for <ctype.h> functions declared in the C StandardAndrew Kaster
2022-06-23Tests: Add tests for `wcsftime`Tim Schumacher
2022-06-13AK/ByteBuffer+Everywhere: Handle errors in ByteBuffer::slice()Matthias Zimmerman
2022-05-20Tests: Add tests for posix_memalign(3) and aligned_alloc(3)Peter Elliott
2022-04-14Tests: Add a test for printf truncationTim Schumacher
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-24Userland+Tests: Convert File::read_link() from String to ErrorOr<String>Kenneth Myhra
This converts the return value of File::read_link() from String to ErrorOr<String>. The rest of the change is to support the potential of an Error being returned and subsequent release of the value when no Error is returned. Unfortunately at this stage none of the places affected can utililize our TRY() macro.
2022-03-08LibC: Set `saved_str` to null in strtok_r if no tokens were foundDaniel Bertalan
If we do not do this, the next call to strtok_r will start tokenizing (and possibly modifying!) the memory pointed to by `saved_ptr`.
2022-03-08Tests: Include limits.h for PATH_MAX in realpath testsTim Schumacher
2022-03-08Tests: Include limits.h for MB_LEN_MAX in wchar testsTim Schumacher
2022-03-02AK: Print NaN and infinite numbers in PrintfImplementationPeter Ross
2022-03-02LibC: Set PRI[xX]8/PRI[xX]16 macros to `x` and `X`Peter Ross
Described in: <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/ inttypes.h.html> The macros were first added in a7a456002e91d9f13793e23aab4c24519c4e87c7, but it is not clear why the PRIx16/32 macros were defined as 'b' & 'w'. PrintfImplementation was never able to parse these values.
2022-02-28AK: Add tests for integer values formatting in printfTimur Sultanov
2022-02-20LibC: Do not write value when scanf assignment value is suppressedPeter Ross
This change has the positive side-effect of causing scanf to *segfault* when a NULL pointer argument is passed to scanf. e.g. sscanf(str, "%d", NULL);
2022-02-20LibC: Do not include suppressed assignments in scanf return valuePeter Ross
2022-02-13Tests: Add test for LibC mkdir()Max Wipfli
2022-01-25LibC: Ensure most time tests run under UTCTimothy Flynn
This ensures these tests pass even if the user has changed the system time zone away from UTC.
2022-01-25LibC: Implement tzset with time zone awareness in accordance with POSIXTimothy Flynn
2022-01-16Tests: Test whether stdio streams are flushed correctly on exitDaniel Bertalan
2022-01-16LibC: Make `*alloc` return `NULL` in case of failure (POSIX)Michel Hermier