Age | Commit message (Collapse) | Author |
|
The execution order of constructors in undefined and depends on the
toolchain. While recent toolchains seems to have a stable order, it
doesn't work for older ones and may also change at any time.
Stop validating the order and instead only validate that all
constructors are executed.
Reported-by: Willy Tarreau <w@1wt.eu>
Closes: https://lore.kernel.org/lkml/20250301110735.GA18621@1wt.eu/
Link: https://lore.kernel.org/r/20250306-nolibc-constructor-order-v1-1-68fd161cc5ec@weissschuh.net
Acked-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
This doesn't matter much, but is what the standard says.
Signed-off-by: Louis Taylor <louis@kragniz.eu>
Link: https://lore.kernel.org/r/20250306184147.208723-5-louis@kragniz.eu
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
openat is useful to avoid needing to construct relative paths, so expose
a wrapper for using it directly.
Signed-off-by: Louis Taylor <louis@kragniz.eu>
Link: https://lore.kernel.org/r/20250306184147.208723-1-louis@kragniz.eu
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
While nolibc does support ARM Thumb instructions,
that support was not tested specifically.
Add a new test configuration for it.
Tested-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250301-nolibc-armthumb-v1-2-d1f04abb5f6d@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
The default could also be -mthumb.
Explicitly use -marm to keep everything predictable.
Tested-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250301-nolibc-armthumb-v1-1-d1f04abb5f6d@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
These functions are used often, also in selftests.
sscanf() itself is also used by kselftest.h itself.
The implementation is limited and only supports numeric arguments.
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250209-nolibc-scanf-v2-1-c29dea32f1cd@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
32-bit s390 is very close to the existing 64-bit implementation.
Some special handling is necessary as there is neither LLVM nor
QEMU support. Also the kernel itself can not build natively for 32-bit
s390, so instead the test program is executed with a 64-bit kernel.
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250206-nolibc-s390-v2-2-991ad97e3d58@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
Support for 32-bit s390 is about to be added.
As "s39032" would look horrible, use the another naming scheme.
32-bit s390 is "s390" and 64-bit s390 is "s390x",
similar to how it is handled in various toolchain components.
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250206-nolibc-s390-v2-1-991ad97e3d58@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
The nolibc testsuite can be run against other libcs to test for
interoperability. Some aspects of the constructor execution are not
standardized and musl does not provide all tested feature, for one it
does not provide arguments to the constructors, anymore?
Skip the constructor tests on non-nolibc configurations.
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250212-nolibc-test-constructor-v1-1-c963875b3da4@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
The list is getting overly long and any modifications introduce a lot of
noise and are prone to conflicts. Split the string into a bash array
and break that into multiple lines.
Link: https://lore.kernel.org/r/20250211-nolibc-test-archs-v1-1-8e55aa3369cf@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
Add an implementation for directory access operations.
To keep nolibc itself allocation-free, a "DIR *" does not point to any
data, but directly encodes a filedescriptor number, equivalent to "FILE *".
Without any per-directory storage it is not possible to implement
readdir() POSIX confirming. Instead only readdir_r() is provided.
While readdir_r() is deprecated in glibc, the reasons for that are
not applicable to nolibc.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Link: https://lore.kernel.org/r/20250209-nolibc-dir-v2-2-57cc1da8558b@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
Avoid using a stale test kernel configuration by always synchronizing
it to the current source tree.
kbuild is smart enough to avoid spurious rebuilds.
Shuffle the code around a bit to keep all the commands with side-effects
together.
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250123-nolibc-config-v2-5-5701c35995d6@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
Some targets use the test kernel configuration.
Executing defconfig in the same make invocation as those targets results
in errors as the configuration may be in an inconsistent state during
reconfiguration.
Avoid this by introducing ordering dependencies between the defconfig
and some other targets.
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250123-nolibc-config-v2-4-5701c35995d6@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
"mrproper" unnecessarily cleans a lot of files.
kbuild is smart enough to handle changed configurations,
so the cleanup is not necessary and only leads to excessive rebuilds.
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250123-nolibc-config-v2-3-5701c35995d6@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
The "prepare" target does not need to be run manually.
kbuild knows when to use it on its own and the target is not even
documented.
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250123-nolibc-config-v2-2-5701c35995d6@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
kbuild already contains logic to merge predefines snippets into a
defconfig file. For MIPS a snippet for big-endian is already provided.
Link: https://lore.kernel.org/r/20250123-nolibc-config-v2-1-5701c35995d6@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
User code may want to use this compiler flag.
Make sure it is supported by nolibc.
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250123-nolibc-prototype-v1-3-e1afc5c1999a@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
To make sure nolibc itself is compatible with -Wmissing-prototypes the
compiler flag should be enabled when building nolibc-test.
However some of its functions are non-static to ease debugging [0],
triggering the compiler warning.
Disable the warning inside nolibc-test while still enabling it for
nolibc itself.
[0] https://lore.kernel.org/lkml/ZMjM0UPRAqoC+goY@1wt.eu/
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250123-nolibc-prototype-v1-2-e1afc5c1999a@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
nolibc already supports riscv32. Wire it up in the testsuite.
Link: https://lore.kernel.org/r/20241221-nolibc-rv32-v1-6-d9ef6dab7c63@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
riscv32 support is about the be added. To keep the naming clear and
consistent with other architectures rename riscv to riscv64, as that is
what it actually represents.
Link: https://lore.kernel.org/r/20241221-nolibc-rv32-v1-5-d9ef6dab7c63@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
The riscv32 architecture is missing many of the older syscalls.
Instead of providing wrappers for everything at once, introducing a lot
of complexity, skip the tests for those syscalls for now.
Link: https://lore.kernel.org/r/20241221-nolibc-rv32-v1-4-d9ef6dab7c63@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
Not all architectures implement lseek(), for example riscv32 only
implements llseek() which is not equivalent to normal lseek().
Remove the need for lseek() by using a pipe instead.
Link: https://lore.kernel.org/r/20241221-nolibc-rv32-v1-3-d9ef6dab7c63@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
Newer archs like riscv32 don't provide waitpid() anymore.
Switch to waitid() which is available everywhere.
Link: https://lore.kernel.org/r/20241221-nolibc-rv32-v1-2-d9ef6dab7c63@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
The script tries to resolve the path to the current toolchain using
realpath, which fails in case it's not installed, and since it's run
under -e, it doesn't have the opportunity to display a help message.
Let's detect the absence of the required toolchain before running that
command and provide a friendlier message when this happens.
Link: https://lore.kernel.org/all/ZtlQbpgpn9OQOPyI@1wt.eu/
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
Recently the loongarch defconfig stopped working with the default 128 MiB
of memory. The VM just spins infinitively.
Increasing the available memory to 1 GiB, similar to s390, fixes the
issue. To avoid having to do this for each architecture on its own,
proactively apply to all architectures.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Link: https://lore.kernel.org/r/20241007-nolibc-qemu-mem-v1-1-c1c2f9acd0f8@linutronix.de
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
The nolibc tests can now be properly built with LLVM.
Expose this through run-tests.sh.
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-15-c20f2f5fc7c2@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
The target names between GCC and clang differ for s390.
While GCC uses "s390", clang uses "systemz".
This mapping is not handled by tools/scripts/Makefile.include,
so do it in the nolibc-test Makefile.
Acked-by: Willy Tarreau <w@1wt.eu>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-14-c20f2f5fc7c2@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
The logic in clang to find the libgcc.a from a GCC toolchain for a
specific ABI does not work reliably and can lead to errors.
Instead disable libgcc when building with clang, as it's not needed
anyways.
Acked-by: Willy Tarreau <w@1wt.eu>
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-13-c20f2f5fc7c2@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
If the user specified their own CFLAGS_EXTRA these should not be
overwritten by `-e`.
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-12-c20f2f5fc7c2@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
The cc-option macro from Build.include is not compatible with clang
cross builds, as it does not respect the "--target" and similar flags,
set up by Mekfile.include.
Provide a custom variant which works correctly.
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-11-c20f2f5fc7c2@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
Makefile.include can modify CC and CFLAGS for usage with clang.
Make use of it.
Makefile.include is currently used to handle the O= variable.
This is incompatible with the LLVM= handling as for O= it has to be
included as early as possible, while for LLVM= it needs to be included
after CFLAGS are set up.
To avoid this incompatibility, switch the O= handling to custom logic.
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-10-c20f2f5fc7c2@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
The nolibc-test Makefile includes various other Makefiles from the tree.
At first these are included with relative paths like
"../../../build/Build.include" but as soon as $(srctree) is set up,
the inclusions use that instead to build full paths.
To keep the style of inclusions consistent, perform the setup
$(srctree) as early as possible and use it for all inclusions.
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-9-c20f2f5fc7c2@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
Clang on higher optimization levels detects that NULL is passed to
printf("%s") and warns about it.
While printf() from nolibc gracefully handles that NULL,
it is undefined behavior as per POSIX, so the warning is reasonable.
Avoid the warning by transforming NULL into a non-NULL placeholder.
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-8-c20f2f5fc7c2@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
When nolibc-test is so broken, it doesn't even start,
don't report success.
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-7-c20f2f5fc7c2@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
Since 2005 glibc has passed argc, argv, and envp to all constructors.
As it is cheap and easy to do so, mirror that behaviour in nolibc.
This makes it easier to migrate applications to nolibc.
Link: https://lore.kernel.org/r/20240728-nolibc-constructor-args-v1-1-36d0bf5cd4c0@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
strerror() is commonly used.
For example in kselftest which currently needs to do an #ifdef NOLIBC to
handle the lack of strerror().
Keep it simple and reuse the output format of perror() for strerror().
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
Some tests only make sense on nolibc. To avoid gaps in the test numbers
do to inline "#ifdef NOLIBC", add a condition to formally skip these
tests.
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
The implementation always works on uintmax_t values.
This is inefficient when only 32bit are needed.
However for all functions this only happens for strtol() on 32bit
platforms.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20240425-nolibc-strtol-v1-2-bfeef7846902@weissschuh.net
|
|
run-tests.sh hides the output from the compiler unless the compilation
fails. To recognize newly introduced warnings use -Werror by default.
Also add a switch to disable -Werror in case the warnings are expected.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20240423-nolibc-werror-v1-1-e6f0bd66eb45@weissschuh.net
|
|
On musl calls to brk() and sbrk() always fail with ENOMEM.
Detect this and skip the tests on musl.
Tested on glibc 2.39 and musl 1.2.5 in addition to nolibc.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20240424-nolibc-musl-brk-v1-1-b49882dd9a93@weissschuh.net
|
|
Fix the following compiler warning on 32bit:
i386-linux-gcc -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wextra -fno-stack-protector -m32 -mstack-protector-guard=global -fstack-protector-all -o nolibc-test \
-nostdlib -nostdinc -static -Isysroot/i386/include nolibc-test.c nolibc-test-linkage.c -lgcc
nolibc-test.c: In function 'expect_str_buf_eq':
nolibc-test.c:610:30: error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
610 | llen += printf(" = %lu <%s> ", expr, buf);
| ~~^ ~~~~
| | |
| | size_t {aka unsigned int}
| long unsigned int
| %u
Fixes: 1063649cf531 ("selftests/nolibc: Add tests for strlcat() and strlcpy()")
Cc: stable@vger.kernel.org
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
All supported kernels are assumed to use struct new_utsname.
This is validated in test_uname().
uname(2) can for example be used in ksft_min_kernel_version() from the
kernels selftest framework.
Link: https://lore.kernel.org/lkml/20240412123536.GA32444@redhat.com/
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Acked-by: Willy Tarreau <w@1wt.eu>
|
|
I've verified that the tests matches libbsd's strlcat()/strlcpy()
implementation.
Please note that as strlcat()/strlcpy() are not part of the libc, the
tests are only compiled when using nolibc.
Signed-off-by: Rodrigo Campos <rodrigo@sdfg.com.ar>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
qemu-user does has its own implementation of coredumping.
That implementation does not respect the call to
prctl(PR_SET_DUMPABLE, 0) in run_protection().
This leads to a coredump for every test run under qemu-user.
Use also setrlimit() to inhibit coredump creation which is respected by
qemu-user.
Link: https://lore.kernel.org/qemu-devel/20231115-qemu-user-dumpable-v1-2-edbe7f0fbb02@t-8ch.de/
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/lkml/20231123-nolibc-rlimit-v1-3-a428b131de2a@weissschuh.net/
Acked-by: Willy Tarreau <w@1wt.eu>
|
|
The implementation uses the prlimit64 systemcall as that is available on
all architectures.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/lkml/20231123-nolibc-rlimit-v1-2-a428b131de2a@weissschuh.net/
Acked-by: Willy Tarreau <w@1wt.eu>
|
|
The same testcase is present on the line above.
Fixes: b4844fa0bdb4 ("selftests/nolibc: implement a few tests for various syscalls")
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
Move the check of the existing length into the function so it can't be
forgotten by the caller.
Also hardcode the padding character as only spaces are ever used.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
MIPS requires some extra instructions to set up the $gp register for the
with a pointer to the global data area.
This isn't needed for non-PIC builds, but this patch enables the code
unconditionally to prevent bitrot.
Also enable PIC in one of the test configurations for ongoing
validation.
Link: https://lore.kernel.org/r/20231108-nolibc-pic-v2-1-4fb0d6284757@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
qemu-user is faster than a full system test.
Link: https://lore.kernel.org/r/20770915-nolibc-run-user-v1-2-3caec61726dc@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|
|
While ppc64le shares the same executable with regular ppc64 the user
variant needs has a dedicated executable.
Introduce a new QEMU_ARCH_USER Makefile variable to accommodate that.
Fixes: 17362f3d0bd3 ("selftests/nolibc: use qemu-system-ppc64 for ppc64le")
Link: https://lore.kernel.org/r/20770915-nolibc-run-user-v1-1-3caec61726dc@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
|