Merge tag 'linux-kselftest-next-6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 23 Feb 2023 17:37:29 +0000 (09:37 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 23 Feb 2023 17:37:29 +0000 (09:37 -0800)
Pull Kselftest update from Shuah Khan:

 - several patches to fix incorrect kernel headers search path from
   Mathieu Desnoyers

 - a few follow-on fixes found during testing the above change

 - miscellaneous fixes

 - support for filtering and enumerating tests

* tag 'linux-kselftest-next-6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (40 commits)
  selftests/user_events: add a note about user_events.h dependency
  selftests/mount_setattr: fix to make run_tests failure
  selftests/mount_setattr: fix redefine struct mount_attr build error
  selftests/sched: fix warn_unused_result build warns
  selftests/ptp: Remove clean target from Makefile
  selftests: use printf instead of echo -ne
  selftests/ftrace: Fix bash specific "==" operator
  selftests: tpm2: remove redundant ord()
  selftests: find echo binary to use -ne options
  selftests: Fix spelling mistake "allright" -> "all right"
  selftests: tdx: Use installed kernel headers search path
  selftests: ptrace: Use installed kernel headers search path
  selftests: memfd: Use installed kernel headers search path
  selftests: iommu: Use installed kernel headers search path
  selftests: x86: Fix incorrect kernel headers search path
  selftests: vm: Fix incorrect kernel headers search path
  selftests: user_events: Fix incorrect kernel headers search path
  selftests: sync: Fix incorrect kernel headers search path
  selftests: seccomp: Fix incorrect kernel headers search path
  selftests: sched: Fix incorrect kernel headers search path
  ...

43 files changed:
tools/testing/selftests/Makefile
tools/testing/selftests/arm64/fp/Makefile
tools/testing/selftests/arm64/tags/Makefile
tools/testing/selftests/clone3/Makefile
tools/testing/selftests/core/Makefile
tools/testing/selftests/dmabuf-heaps/Makefile
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c
tools/testing/selftests/drivers/dma-buf/Makefile
tools/testing/selftests/drivers/s390x/uvdevice/Makefile
tools/testing/selftests/filesystems/Makefile
tools/testing/selftests/filesystems/binderfs/Makefile
tools/testing/selftests/filesystems/epoll/Makefile
tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc
tools/testing/selftests/futex/functional/Makefile
tools/testing/selftests/gpio/Makefile
tools/testing/selftests/iommu/Makefile
tools/testing/selftests/ipc/Makefile
tools/testing/selftests/kcmp/Makefile
tools/testing/selftests/kselftest_harness.h
tools/testing/selftests/media_tests/Makefile
tools/testing/selftests/membarrier/Makefile
tools/testing/selftests/memfd/Makefile
tools/testing/selftests/mount_setattr/Makefile
tools/testing/selftests/mount_setattr/mount_setattr_test.c
tools/testing/selftests/move_mount_set_group/Makefile
tools/testing/selftests/perf_events/Makefile
tools/testing/selftests/pid_namespace/Makefile
tools/testing/selftests/pidfd/Makefile
tools/testing/selftests/prctl/disable-tsc-ctxt-sw-stress-test.c
tools/testing/selftests/prctl/disable-tsc-on-off-stress-test.c
tools/testing/selftests/ptp/Makefile
tools/testing/selftests/ptrace/Makefile
tools/testing/selftests/rseq/Makefile
tools/testing/selftests/sched/Makefile
tools/testing/selftests/sched/cs_prctl_test.c
tools/testing/selftests/seccomp/Makefile
tools/testing/selftests/sync/Makefile
tools/testing/selftests/tdx/Makefile
tools/testing/selftests/tdx/tdx_guest_test.c
tools/testing/selftests/tpm2/tpm2.py
tools/testing/selftests/user_events/Makefile
tools/testing/selftests/vm/Makefile
tools/testing/selftests/x86/Makefile

index 0bc9592b5e62a432faba17e06430637f2f20a0ed..0ebd9cce49b9661c5d9127a915a6b9fcfad91a56 100644 (file)
@@ -237,8 +237,8 @@ ifdef INSTALL_PATH
        @# included in the generated runlist.
        for TARGET in $(TARGETS); do \
                BUILD_TARGET=$$BUILD/$$TARGET;  \
-               [ ! -d $(INSTALL_PATH)/$$TARGET ] && echo "Skipping non-existent dir: $$TARGET" && continue; \
-               echo -ne "Emit Tests for $$TARGET\n"; \
+               [ ! -d $(INSTALL_PATH)/$$TARGET ] && printf "Skipping non-existent dir: $$TARGET\n" && continue; \
+               printf "Emit Tests for $$TARGET\n"; \
                $(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET COLLECTION=$$TARGET \
                        -C $$TARGET emit_tests >> $(TEST_LIST); \
        done;
index 50a70220ba6c79a68d96f169c657b892777806a2..48f56c86ad4579970300940813c94340712b9ac0 100644 (file)
@@ -3,7 +3,7 @@
 # A proper top_srcdir is needed by KSFT(lib.mk)
 top_srcdir = $(realpath ../../../../../)
 
-CFLAGS += -I$(top_srcdir)/usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := fp-stress \
        sve-ptrace sve-probe-vls \
index 41cb7507051171ac0ccc488384521d5396684213..6d29cfde43a212569173c0f0240f4cf77fd924d8 100644 (file)
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS += -I../../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 TEST_GEN_PROGS := tags_test
 TEST_PROGS := run_tags_test.sh
 
index 79b19a2863a0b3eeb6603e32e2af727b7cb81e23..84832c369a2ea33ac63b69d5812ebd7ba330b009 100644 (file)
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -g -std=gnu99 -I../../../../usr/include/
+CFLAGS += -g -std=gnu99 $(KHDR_INCLUDES)
 LDLIBS += -lcap
 
 TEST_GEN_PROGS := clone3 clone3_clear_sighand clone3_set_tid \
index f6f2d6f473c6a868d48a8b3002f60408a41f8130..ce262d09726990e85a943c26d7e5eebbe5d7cfc5 100644 (file)
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-CFLAGS += -g -I../../../../usr/include/
+CFLAGS += -g $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := close_range_test
 
index 604b43ece15f5cff7861ac3a6670c5f856323e5b..9e7e158d5fa3207da5f7e9b886021c518fae771b 100644 (file)
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -static -O3 -Wl,-no-as-needed -Wall
+CFLAGS += -static -O3 -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS = dmabuf-heap
 
index 29af27acd40ea08fdf787e63a52cd285980c5cfc..890a8236a8ba73008aea8354b9bfeba712cfef28 100644 (file)
 #include <sys/types.h>
 
 #include <linux/dma-buf.h>
+#include <linux/dma-heap.h>
 #include <drm/drm.h>
 
-#include "../../../../include/uapi/linux/dma-heap.h"
-
 #define DEVPATH "/dev/dma_heap"
 
 static int check_vgem(int fd)
index 79cb16b4e01a9454ca64a9ed22af80d59ea58f1f..441407bb0e801ffba916664c3a682817d42d863c 100644 (file)
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-CFLAGS += -I../../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := udmabuf
 
index 891215a7dc8a19474068e961c22a6903fef95a77..755d164384c46f79da1fefe8a978ae20188b5884 100644 (file)
@@ -11,10 +11,9 @@ else
 TEST_GEN_PROGS := test_uvdevice
 
 top_srcdir ?= ../../../../../..
-khdr_dir = $(top_srcdir)/usr/include
 LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include
 
-CFLAGS += -Wall -Werror -static -I$(khdr_dir) -I$(LINUX_TOOL_ARCH_INCLUDE)
+CFLAGS += -Wall -Werror -static $(KHDR_INCLUDES) -I$(LINUX_TOOL_ARCH_INCLUDE)
 
 include ../../../lib.mk
 
index 129880fb42d34c04c343dc88875515dbbb27df91..c647fd6a0446ab9aae58fdab770743e35bab8099 100644 (file)
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS += -I../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 TEST_GEN_PROGS := devpts_pts
 TEST_GEN_PROGS_EXTENDED := dnotify_test
 
index 8af25ae9604982ec3be1a68a33da77ba8f3b524a..c2f7cef919c04566037582e017cb2d7b55b7a33f 100644 (file)
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS += -I../../../../../usr/include/ -pthread
+CFLAGS += $(KHDR_INCLUDES) -pthread
 TEST_GEN_PROGS := binderfs_test
 
 binderfs_test: binderfs_test.c ../../kselftest.h ../../kselftest_harness.h
index 78ae4aaf7141ad285847b94adf52c87229208520..0788a7dc80042df765efd0b216f6994f445f405d 100644 (file)
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS += -I../../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 LDLIBS += -lpthread
 TEST_GEN_PROGS := epoll_wakeup_test
 
index 3eea2abf68f9ee0e5dc26c6220398f3a0db3bd5e..2ad7d4b501cc140616d6f5eb07a979a39e5aa048 100644 (file)
@@ -42,7 +42,7 @@ test_event_enabled() {
 
     while [ $check_times -ne 0 ]; do
        e=`cat $EVENT_ENABLE`
-       if [ "$e" == $val ]; then
+       if [ "$e" = $val ]; then
            return 0
        fi
        sleep $SLEEP_TIME
index 5a0e0df8de9b3df37acbee263d4c90bd99f84593..a392d0917b4e55c145b293e1e60674bc904e74c0 100644 (file)
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-INCLUDES := -I../include -I../../ -I../../../../../usr/include/
+INCLUDES := -I../include -I../../ $(KHDR_INCLUDES)
 CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES) $(KHDR_INCLUDES)
 LDLIBS := -lpthread -lrt
 
index 616ed40196554eda9fa746b4d536ab220a0f6c52..e0884390447dcfffe4ca0b4fa0f1669463bb669c 100644 (file)
@@ -3,6 +3,6 @@
 TEST_PROGS := gpio-mockup.sh gpio-sim.sh
 TEST_FILES := gpio-mockup-sysfs.sh
 TEST_GEN_PROGS_EXTENDED := gpio-mockup-cdev gpio-chip-info gpio-line-name
-CFLAGS += -O2 -g -Wall -I../../../../usr/include/ $(KHDR_INCLUDES)
+CFLAGS += -O2 -g -Wall $(KHDR_INCLUDES)
 
 include ../lib.mk
index 7cb74d26f14171d67d297dcd8e5907e16bcb2ea9..32c5fdfd0eefc2d1b1d530ecca106dc2b84db189 100644 (file)
@@ -1,7 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 CFLAGS += -Wall -O2 -Wno-unused-function
-CFLAGS += -I../../../../include/uapi/
-CFLAGS += -I../../../../include/
+CFLAGS += $(KHDR_INCLUDES)
 
 CFLAGS += -D_GNU_SOURCE
 
index 1c4448a843a41e38d55b7260bd8807896898e15e..50e9c299fc4aea875a1b9b2402414c9b1ebd281f 100644 (file)
@@ -10,7 +10,7 @@ ifeq ($(ARCH),x86_64)
        CFLAGS := -DCONFIG_X86_64 -D__x86_64__
 endif
 
-CFLAGS += -I../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := msgque
 
index b4d39f6b5124dc750dc10c756ffe7d42b43c08a4..59a1e537901817e8b04ec3ddfa4a2f6c43ef8a99 100644 (file)
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-CFLAGS += -I../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := kcmp_test
 
index 25f4d54067c0ee243114bdf6733390a761d26b5b..d8bff2005dfc962f5119708261b1d499750758a5 100644 (file)
@@ -54,6 +54,7 @@
 #define _GNU_SOURCE
 #endif
 #include <asm/types.h>
+#include <ctype.h>
 #include <errno.h>
 #include <stdbool.h>
 #include <stdint.h>
@@ -985,6 +986,127 @@ void __wait_for_test(struct __test_metadata *t)
        }
 }
 
+static void test_harness_list_tests(void)
+{
+       struct __fixture_variant_metadata *v;
+       struct __fixture_metadata *f;
+       struct __test_metadata *t;
+
+       for (f = __fixture_list; f; f = f->next) {
+               v = f->variant;
+               t = f->tests;
+
+               if (f == __fixture_list)
+                       fprintf(stderr, "%-20s %-25s %s\n",
+                               "# FIXTURE", "VARIANT", "TEST");
+               else
+                       fprintf(stderr, "--------------------------------------------------------------------------------\n");
+
+               do {
+                       fprintf(stderr, "%-20s %-25s %s\n",
+                               t == f->tests ? f->name : "",
+                               v ? v->name : "",
+                               t ? t->name : "");
+
+                       v = v ? v->next : NULL;
+                       t = t ? t->next : NULL;
+               } while (v || t);
+       }
+}
+
+static int test_harness_argv_check(int argc, char **argv)
+{
+       int opt;
+
+       while ((opt = getopt(argc, argv, "hlF:f:V:v:t:T:r:")) != -1) {
+               switch (opt) {
+               case 'f':
+               case 'F':
+               case 'v':
+               case 'V':
+               case 't':
+               case 'T':
+               case 'r':
+                       break;
+               case 'l':
+                       test_harness_list_tests();
+                       return KSFT_SKIP;
+               case 'h':
+               default:
+                       fprintf(stderr,
+                               "Usage: %s [-h|-l] [-t|-T|-v|-V|-f|-F|-r name]\n"
+                               "\t-h       print help\n"
+                               "\t-l       list all tests\n"
+                               "\n"
+                               "\t-t name  include test\n"
+                               "\t-T name  exclude test\n"
+                               "\t-v name  include variant\n"
+                               "\t-V name  exclude variant\n"
+                               "\t-f name  include fixture\n"
+                               "\t-F name  exclude fixture\n"
+                               "\t-r name  run specified test\n"
+                               "\n"
+                               "Test filter options can be specified "
+                               "multiple times. The filtering stops\n"
+                               "at the first match. For example to "
+                               "include all tests from variant 'bla'\n"
+                               "but not test 'foo' specify '-T foo -v bla'.\n"
+                               "", argv[0]);
+                       return opt == 'h' ? KSFT_SKIP : KSFT_FAIL;
+               }
+       }
+
+       return KSFT_PASS;
+}
+
+static bool test_enabled(int argc, char **argv,
+                        struct __fixture_metadata *f,
+                        struct __fixture_variant_metadata *v,
+                        struct __test_metadata *t)
+{
+       unsigned int flen = 0, vlen = 0, tlen = 0;
+       bool has_positive = false;
+       int opt;
+
+       optind = 1;
+       while ((opt = getopt(argc, argv, "F:f:V:v:t:T:r:")) != -1) {
+               has_positive |= islower(opt);
+
+               switch (tolower(opt)) {
+               case 't':
+                       if (!strcmp(t->name, optarg))
+                               return islower(opt);
+                       break;
+               case 'f':
+                       if (!strcmp(f->name, optarg))
+                               return islower(opt);
+                       break;
+               case 'v':
+                       if (!strcmp(v->name, optarg))
+                               return islower(opt);
+                       break;
+               case 'r':
+                       if (!tlen) {
+                               flen = strlen(f->name);
+                               vlen = strlen(v->name);
+                               tlen = strlen(t->name);
+                       }
+                       if (strlen(optarg) == flen + 1 + vlen + !!vlen + tlen &&
+                           !strncmp(f->name, &optarg[0], flen) &&
+                           !strncmp(v->name, &optarg[flen + 1], vlen) &&
+                           !strncmp(t->name, &optarg[flen + 1 + vlen + !!vlen], tlen))
+                               return true;
+                       break;
+               }
+       }
+
+       /*
+        * If there are no positive tests then we assume user just wants
+        * exclusions and everything else is a pass.
+        */
+       return !has_positive;
+}
+
 void __run_test(struct __fixture_metadata *f,
                struct __fixture_variant_metadata *variant,
                struct __test_metadata *t)
@@ -1032,24 +1154,32 @@ void __run_test(struct __fixture_metadata *f,
                        f->name, variant->name[0] ? "." : "", variant->name, t->name);
 }
 
-static int test_harness_run(int __attribute__((unused)) argc,
-                           char __attribute__((unused)) **argv)
+static int test_harness_run(int argc, char **argv)
 {
        struct __fixture_variant_metadata no_variant = { .name = "", };
        struct __fixture_variant_metadata *v;
        struct __fixture_metadata *f;
        struct __test_results *results;
        struct __test_metadata *t;
-       int ret = 0;
+       int ret;
        unsigned int case_count = 0, test_count = 0;
        unsigned int count = 0;
        unsigned int pass_count = 0;
 
+       ret = test_harness_argv_check(argc, argv);
+       if (ret != KSFT_PASS)
+               return ret;
+
        for (f = __fixture_list; f; f = f->next) {
                for (v = f->variant ?: &no_variant; v; v = v->next) {
-                       case_count++;
+                       unsigned int old_tests = test_count;
+
                        for (t = f->tests; t; t = t->next)
-                               test_count++;
+                               if (test_enabled(argc, argv, f, v, t))
+                                       test_count++;
+
+                       if (old_tests != test_count)
+                               case_count++;
                }
        }
 
@@ -1063,6 +1193,8 @@ static int test_harness_run(int __attribute__((unused)) argc,
        for (f = __fixture_list; f; f = f->next) {
                for (v = f->variant ?: &no_variant; v; v = v->next) {
                        for (t = f->tests; t; t = t->next) {
+                               if (!test_enabled(argc, argv, f, v, t))
+                                       continue;
                                count++;
                                t->results = results;
                                __run_test(f, v, t);
index 60826d7d37d49d3f2aaed26068085ffc2a59246a..471d83e61d95edb2bf42aaa43617c442e1f7adee 100644 (file)
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 #
-CFLAGS += -I../ -I../../../../usr/include/
+CFLAGS += -I../ $(KHDR_INCLUDES)
 TEST_GEN_PROGS := media_device_test media_device_open video_device_test
 
 include ../lib.mk
index 34d1c81a2324a692193e5b16f9ec09f86a1a0c46..fc840e06ff565f3f95fad75296bd2ebf52800a20 100644 (file)
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-CFLAGS += -g -I../../../../usr/include/
+CFLAGS += -g $(KHDR_INCLUDES)
 LDLIBS += -lpthread
 
 TEST_GEN_PROGS := membarrier_test_single_thread \
index 4da8b565fa326e54720eb6b8041b997ef98f3b91..163b6f68631c499916469b5e2f3252d38e0c6581 100644 (file)
@@ -1,8 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 CFLAGS += -D_FILE_OFFSET_BITS=64
-CFLAGS += -I../../../../include/uapi/
-CFLAGS += -I../../../../include/
-CFLAGS += -I../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := memfd_test
 TEST_PROGS := run_fuse_test.sh run_hugetlbfs_test.sh
index 2250f7dcb81e3974723371b71c2f5fc17e8836ec..0c0d7b1234c1930d9c369a864d4efa8d3c56167a 100644 (file)
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for mount selftests.
-CFLAGS = -g -I../../../../usr/include/ -Wall -O2 -pthread
+CFLAGS = -g $(KHDR_INCLUDES) -Wall -O2 -pthread
 
-TEST_GEN_FILES += mount_setattr_test
+TEST_GEN_PROGS := mount_setattr_test
 
 include ../lib.mk
index 8c5fea68ae677b6d9e4cca4acf9a1b7e0d637b14..582669ca38e9dd98ea2236577e5a4313ea887742 100644 (file)
        #else
                #define __NR_mount_setattr 442
        #endif
-
-struct mount_attr {
-       __u64 attr_set;
-       __u64 attr_clr;
-       __u64 propagation;
-       __u64 userns_fd;
-};
 #endif
 
 #ifndef __NR_open_tree
index 80c2d86812b068c772ffb9d4105cb373c2f2b545..94235846b6f9b8b2c6985b976ac7d892d124ffba 100644 (file)
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 # Makefile for mount selftests.
-CFLAGS = -g -I../../../../usr/include/ -Wall -O2
+CFLAGS = -g $(KHDR_INCLUDES) -Wall -O2
 
 TEST_GEN_FILES += move_mount_set_group_test
 
index fcafa5f0d34c04b2a2fab27d12288449ce4719b1..db93c4ff081a45d52ae50023a9be18be6b4ca298 100644 (file)
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -Wl,-no-as-needed -Wall -I../../../../usr/include
+CFLAGS += -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
 LDFLAGS += -lpthread
 
 TEST_GEN_PROGS := sigtrap_threads remove_on_exec
index edafaca1aeb39a8ac19aeca05040d1c6ebae3c95..9286a1d22cd3acd95da26203086c7324887e9ce8 100644 (file)
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -g -I../../../../usr/include/
+CFLAGS += -g $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS = regression_enomem
 
index 778b6cdc8aed8b5a6bdba13e605f2f7231d1c4dc..d731e3e76d5bf50270adf6405c471bcd804fc9dd 100644 (file)
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-CFLAGS += -g -I../../../../usr/include/ -pthread -Wall
+CFLAGS += -g $(KHDR_INCLUDES) -pthread -Wall
 
 TEST_GEN_PROGS := pidfd_test pidfd_fdinfo_test pidfd_open_test \
        pidfd_poll_test pidfd_wait pidfd_getfd_test pidfd_setns_test
index 62a93cc61b7cc377be7eb749e2509d9939f09838..6d1a5ee8eb28b73fad5af3817cd34d824c5c653c 100644 (file)
@@ -79,7 +79,7 @@ int main(void)
 {
        int n_tasks = 100, i;
 
-       fprintf(stderr, "[No further output means we're allright]\n");
+       fprintf(stderr, "[No further output means we're all right]\n");
 
        for (i=0; i<n_tasks; i++)
                if (fork() == 0)
index 79950f9a26fd660fa49ef4f75e614a620e378e81..d39511eb9b01db9c4013144988b73cb08afdc938 100644 (file)
@@ -83,7 +83,7 @@ int main(void)
 {
        int n_tasks = 100, i;
 
-       fprintf(stderr, "[No further output means we're allright]\n");
+       fprintf(stderr, "[No further output means we're all right]\n");
 
        for (i=0; i<n_tasks; i++)
                if (fork() == 0)
index ef06de0898b73980d4af4a1992c20f62b465cedf..8f57f88ecadd632746d47365b62ac2896149f8fc 100644 (file)
@@ -1,10 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -I../../../../usr/include/
-TEST_PROGS := testptp
+CFLAGS += $(KHDR_INCLUDES)
+TEST_GEN_PROGS := testptp
 LDLIBS += -lrt
-all: $(TEST_PROGS)
+TEST_PROGS = phc.sh
 
 include ../lib.mk
-
-clean:
-       rm -fr $(TEST_PROGS)
index 2f1f532c39dbcc6867d314753664f47535b9ed01..96ffa94afb9136237649b019a20a44a628b4654a 100644 (file)
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-CFLAGS += -std=c99 -pthread -iquote../../../../include/uapi -Wall
+CFLAGS += -std=c99 -pthread -Wall $(KHDR_INCLUDES)
 
 TEST_GEN_PROGS := get_syscall_info peeksiginfo vmaccess
 
index 82a52810a649ce40e8635da4c781a4fdcd3f3afc..b357ba24af06f69cc03872ad5b6bb8b21273835e 100644 (file)
@@ -4,7 +4,7 @@ ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
 CLANG_FLAGS += -no-integrated-as
 endif
 
-CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L$(OUTPUT) -Wl,-rpath=./ \
+CFLAGS += -O2 -Wall -g -I./ $(KHDR_INCLUDES) -L$(OUTPUT) -Wl,-rpath=./ \
          $(CLANG_FLAGS)
 LDLIBS += -lpthread -ldl
 
index 10c72f14fea9d06d56022d858ad93c76b39f1e4c..099ee9213557aded17823672f750668db942adf1 100644 (file)
@@ -4,7 +4,7 @@ ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),)
 CLANG_FLAGS += -no-integrated-as
 endif
 
-CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/  -Wl,-rpath=./ \
+CFLAGS += -O2 -Wall -g -I./ $(KHDR_INCLUDES) -Wl,-rpath=./ \
          $(CLANG_FLAGS)
 LDLIBS += -lpthread
 
index 8109b17dc764ceaf4f7b3410d4f06ad3b8421202..25e0d95d37133177fe52e2cce64f01ba73f2712c 100644 (file)
@@ -27,6 +27,7 @@
 #include <sys/prctl.h>
 #include <unistd.h>
 #include <time.h>
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -151,12 +152,17 @@ static void create_threads(int num_threads, int thr_tids[])
 static int child_func_process(void *arg)
 {
        struct child_args *ca = (struct child_args *)arg;
+       int ret;
 
        close(ca->pfd[0]);
 
        create_threads(ca->num_threads, ca->thr_tids);
 
-       write(ca->pfd[1], &ca->thr_tids, sizeof(int) * ca->num_threads);
+       ret = write(ca->pfd[1], &ca->thr_tids, sizeof(int) * ca->num_threads);
+       if (ret == -1)
+               printf("write failed on pfd[%d] - error (%s)\n",
+                       ca->pfd[1], strerror(errno));
+
        close(ca->pfd[1]);
 
        while (1)
@@ -169,7 +175,7 @@ static unsigned char child_func_process_stack[STACK_SIZE];
 void create_processes(int num_processes, int num_threads, struct child_args proc[])
 {
        pid_t cpid;
-       int i;
+       int i, ret;
 
        for (i = 0; i < num_processes; ++i) {
                proc[i].num_threads = num_threads;
@@ -184,7 +190,10 @@ void create_processes(int num_processes, int num_threads, struct child_args proc
        }
 
        for (i = 0; i < num_processes; ++i) {
-               read(proc[i].pfd[0], &proc[i].thr_tids, sizeof(int) * proc[i].num_threads);
+               ret = read(proc[i].pfd[0], &proc[i].thr_tids, sizeof(int) * proc[i].num_threads);
+               if (ret == -1)
+                       printf("read failed on proc[%d].pfd[0] error (%s)\n",
+                               i, strerror(errno));
                close(proc[i].pfd[0]);
        }
 }
index f017c382c0369c898881cdbac78648e07240f734..584fba487037292e12ffa7cd036d02a5d0cf4730 100644 (file)
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -Wl,-no-as-needed -Wall -isystem ../../../../usr/include/
+CFLAGS += -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
 LDFLAGS += -lpthread
 LDLIBS += -lcap
 
index d0121a8a3523a948af699e52b6adbf1cde37b030..df0f91bf6890db8024cac02d020089d6616bf26b 100644 (file)
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 CFLAGS += -O2 -g -std=gnu89 -pthread -Wall -Wextra
-CFLAGS += -I../../../../usr/include/
+CFLAGS += $(KHDR_INCLUDES)
 LDFLAGS += -pthread
 
 .PHONY: all clean
index 8dd43517cd55d31c353cf2929727d99789c8e05a..306e9c4d5ef7ca519260c164e49eb93f972fb830 100644 (file)
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-CFLAGS += -O3 -Wl,-no-as-needed -Wall -static
+CFLAGS += -O3 -Wl,-no-as-needed -Wall $(KHDR_INCLUDES) -static
 
 TEST_GEN_PROGS := tdx_guest_test
 
index 2a2afd856798b4bcf74820709796c1b5f0187579..81d8cb88ea1ad9bd358523beb68d32b73b28e0f3 100644 (file)
@@ -12,8 +12,8 @@
 #include <errno.h>
 #include <fcntl.h>
 
+#include <linux/tdx-guest.h>
 #include "../kselftest_harness.h"
-#include "../../../../include/uapi/linux/tdx-guest.h"
 
 #define TDX_GUEST_DEVNAME "/dev/tdx_guest"
 #define HEX_DUMP_SIZE 8
index c7363c6764fc63fbcf8284cda88591b25f0010d1..bba8cb54548ec9022af79d9eb6286a5ef0704fe4 100644 (file)
@@ -344,7 +344,7 @@ def get_algorithm(name):
 
 
 def hex_dump(d):
-    d = [format(ord(x), '02x') for x in d]
+    d = [format(x, '02x') for x in d]
     d = [d[i: i + 16] for i in range(0, len(d), 16)]
     d = [' '.join(x) for x in d]
     d = os.linesep.join(d)
index c765d8635d9afedc508d2372848be4d9caf655e5..6b512b86aec3495a5a94fc27d661088b44430648 100644 (file)
@@ -1,7 +1,15 @@
 # SPDX-License-Identifier: GPL-2.0
-CFLAGS += -Wl,-no-as-needed -Wall -I../../../../usr/include
+CFLAGS += -Wl,-no-as-needed -Wall $(KHDR_INCLUDES)
 LDLIBS += -lrt -lpthread -lm
 
+# Note:
+# This test depends on <linux/user_events.h> exported in uapi
+# The following commit removed user_events.h out of uapi:
+# commit 5cfff569cab8bf544bab62c911c5d6efd5af5e05
+# tracing: Move user_events.h temporarily out of include/uapi
+# This test will not compile until user_events.h is added
+# back to uapi.
+
 TEST_GEN_PROGS = ftrace_test dyn_test perf_test
 
 TEST_FILES := settings
index 89c14e41bd437e6b9899b6193d92217c3f539647..ac9366065fd26e715faabea9c3a8976b94674b60 100644 (file)
@@ -25,7 +25,7 @@ MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/p
 # LDLIBS.
 MAKEFLAGS += --no-builtin-rules
 
-CFLAGS = -Wall -I $(top_srcdir) -I $(top_srcdir)/usr/include $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
+CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES)
 LDLIBS = -lrt -lpthread
 TEST_GEN_FILES = cow
 TEST_GEN_FILES += compaction_test
index 0388c4d60af0e34f192b8869e21cf76cb61aa8a5..ca9374b56ead12dee7b5e85d2a5215649fd729d7 100644 (file)
@@ -34,7 +34,7 @@ BINARIES_64 := $(TARGETS_C_64BIT_ALL:%=%_64)
 BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32))
 BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64))
 
-CFLAGS := -O2 -g -std=gnu99 -pthread -Wall
+CFLAGS := -O2 -g -std=gnu99 -pthread -Wall $(KHDR_INCLUDES)
 
 # call32_from_64 in thunks.S uses absolute addresses.
 ifeq ($(CAN_BUILD_WITH_NOPIE),1)