tools/nolibc: add libc-test binary
authorThomas Weißschuh <linux@weissschuh.net>
Sun, 2 Apr 2023 18:48:03 +0000 (20:48 +0200)
committerPaul E. McKenney <paulmck@kernel.org>
Fri, 9 Jun 2023 18:33:05 +0000 (11:33 -0700)
This can be used to easily compare the behavior of nolibc to the system
libc.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
tools/testing/selftests/nolibc/.gitignore
tools/testing/selftests/nolibc/Makefile

index 4696df589d68e54e3bed875566a7d0598a0b3a34..52f613cdad5477ae4597657b1772a4ef452b5359 100644 (file)
@@ -1,4 +1,5 @@
 /initramfs/
+/libc-test
 /nolibc-test
 /run.out
 /sysroot/
index bbce57420465cd81e94c61e478eb914ea29685ec..0cbe13809b37a909c375f5b9f3d9f6a01f52d5eb 100644 (file)
@@ -94,6 +94,7 @@ help:
        @echo "  help         this help"
        @echo "  sysroot      create the nolibc sysroot here (uses \$$ARCH)"
        @echo "  nolibc-test  build the executable (uses \$$CC and \$$CROSS_COMPILE)"
+       @echo "  libc-test    build an executable using the compiler's default libc instead"
        @echo "  run-user     runs the executable under QEMU (uses \$$ARCH, \$$TEST)"
        @echo "  initramfs    prepare the initramfs with nolibc-test"
        @echo "  defconfig    create a fresh new default config (uses \$$ARCH)"
@@ -128,6 +129,9 @@ nolibc-test: nolibc-test.c sysroot/$(ARCH)/include
        $(QUIET_CC)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \
          -nostdlib -static -Isysroot/$(ARCH)/include $< -lgcc
 
+libc-test: nolibc-test.c
+       $(QUIET_CC)$(CC) -o $@ $<
+
 # qemu user-land test
 run-user: nolibc-test
        $(Q)qemu-$(QEMU_ARCH) ./nolibc-test > "$(CURDIR)/run.out" || :
@@ -159,6 +163,8 @@ clean:
        $(Q)rm -rf sysroot
        $(call QUIET_CLEAN, nolibc-test)
        $(Q)rm -f nolibc-test
+       $(call QUIET_CLEAN, libc-test)
+       $(Q)rm -f libc-test
        $(call QUIET_CLEAN, initramfs)
        $(Q)rm -rf initramfs
        $(call QUIET_CLEAN, run.out)