Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'linux-kselftest-next-5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull Kselftest updates from Shuah Khan:
"Several build and cleanup fixes:

- removing obsolete config options

- removing dependency on internal kernel macros

- adding config options

- several build fixes related to headers and install paths"

* tag 'linux-kselftest-next-5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (22 commits)
selftests: Fix build when $(O) points to a relative path
selftests: netfilter: fix a build error on openSUSE
selftests: kvm: add generated file to the .gitignore
selftests/exec: add generated files to .gitignore
selftests: add kselftest_install to .gitignore
selftests/rtc: continuously read RTC in a loop for 30s
selftests/lkdtm: Add UBSAN config
selftests/lkdtm: Remove dead config option
selftests/exec: Rename file binfmt_script to binfmt_script.py
selftests: Use -isystem instead of -I to include headers
selftests: vm: remove dependecy from internal kernel macros
selftests: vm: Add the uapi headers include variable
selftests: mptcp: Add the uapi headers include variable
selftests: net: Add the uapi headers include variable
selftests: landlock: Add the uapi headers include variable
selftests: kvm: Add the uapi headers include variable
selftests: futex: Add the uapi headers include variable
selftests: Correct the headers install path
selftests: Add and export a kernel uapi headers path
selftests: set the BUILD variable to absolute path
...

+140 -23
+1
tools/testing/selftests/.gitignore
··· 3 3 gpiogpio-hammer 4 4 gpioinclude/ 5 5 gpiolsgpio 6 + kselftest_install/ 6 7 tpm2/SpaceTest.log 7 8 8 9 # Python bytecode and cache
+26 -11
tools/testing/selftests/Makefile
··· 114 114 override LDFLAGS = 115 115 endif 116 116 117 - ifneq ($(O),) 118 - BUILD := $(O)/kselftest 117 + top_srcdir ?= ../../.. 118 + 119 + ifeq ("$(origin O)", "command line") 120 + KBUILD_OUTPUT := $(O) 121 + endif 122 + 123 + ifneq ($(KBUILD_OUTPUT),) 124 + # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot 125 + # expand a shell special character '~'. We use a somewhat tedious way here. 126 + abs_objtree := $(shell cd $(top_srcdir) && mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd) 127 + $(if $(abs_objtree),, \ 128 + $(error failed to create output directory "$(KBUILD_OUTPUT)")) 129 + # $(realpath ...) resolves symlinks 130 + abs_objtree := $(realpath $(abs_objtree)) 131 + BUILD := $(abs_objtree)/kselftest 132 + KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include 119 133 else 120 - ifneq ($(KBUILD_OUTPUT),) 121 - BUILD := $(KBUILD_OUTPUT)/kselftest 122 - else 123 - BUILD := $(shell pwd) 124 - DEFAULT_INSTALL_HDR_PATH := 1 125 - endif 134 + BUILD := $(CURDIR) 135 + abs_srctree := $(shell cd $(top_srcdir) && pwd) 136 + KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include 137 + DEFAULT_INSTALL_HDR_PATH := 1 126 138 endif 127 139 128 140 # Prepare for headers install 129 - top_srcdir ?= ../../.. 130 141 include $(top_srcdir)/scripts/subarch.include 131 142 ARCH ?= $(SUBARCH) 132 143 export KSFT_KHDR_INSTALL_DONE := 1 133 144 export BUILD 145 + export KHDR_INCLUDES 134 146 135 147 # set default goal to all, so make without a target runs all, even when 136 148 # all isn't the first target in the file. ··· 167 155 ifeq (1,$(DEFAULT_INSTALL_HDR_PATH)) 168 156 $(MAKE) --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install 169 157 else 170 - $(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$$BUILD/usr \ 158 + $(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$(abs_objtree)/usr \ 171 159 ARCH=$(ARCH) -C $(top_srcdir) headers_install 172 160 endif 173 161 ··· 177 165 BUILD_TARGET=$$BUILD/$$TARGET; \ 178 166 mkdir $$BUILD_TARGET -p; \ 179 167 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET \ 168 + O=$(abs_objtree) \ 180 169 $(if $(FORCE_TARGETS),|| exit); \ 181 170 ret=$$((ret * $$?)); \ 182 171 done; exit $$ret; ··· 185 172 run_tests: all 186 173 @for TARGET in $(TARGETS); do \ 187 174 BUILD_TARGET=$$BUILD/$$TARGET; \ 188 - $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\ 175 + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests \ 176 + O=$(abs_objtree); \ 189 177 done; 190 178 191 179 hotplug: ··· 237 223 for TARGET in $(TARGETS); do \ 238 224 BUILD_TARGET=$$BUILD/$$TARGET; \ 239 225 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install \ 226 + O=$(abs_objtree) \ 240 227 $(if $(FORCE_TARGETS),|| exit); \ 241 228 ret=$$((ret * $$?)); \ 242 229 done; exit $$ret;
+2
tools/testing/selftests/exec/.gitignore
··· 7 7 execveat.path.ephemeral 8 8 execveat.ephemeral 9 9 execveat.denatured 10 + non-regular 11 + null-argv 10 12 /load_address_* 11 13 /recursion-depth 12 14 xxxxxxxx*
+1 -1
tools/testing/selftests/exec/Makefile
··· 3 3 CFLAGS += -Wno-nonnull 4 4 CFLAGS += -D_GNU_SOURCE 5 5 6 - TEST_PROGS := binfmt_script 6 + TEST_PROGS := binfmt_script.py 7 7 TEST_GEN_PROGS := execveat load_address_4096 load_address_2097152 load_address_16777216 non-regular 8 8 TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir 9 9 # Makefile is a run-time dependency, since it's accessed by the execveat test
tools/testing/selftests/exec/binfmt_script tools/testing/selftests/exec/binfmt_script.py
+3 -3
tools/testing/selftests/futex/functional/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 - INCLUDES := -I../include -I../../ -I../../../../../usr/include/ \ 3 - -I$(KBUILD_OUTPUT)/kselftest/usr/include 4 - CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES) 2 + INCLUDES := -I../include -I../../ -I../../../../../usr/include/ 3 + CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES) $(KHDR_INCLUDES) 5 4 LDLIBS := -lpthread -lrt 6 5 7 6 HEADERS := \ ··· 23 24 24 25 top_srcdir = ../../../../.. 25 26 KSFT_KHDR_INSTALL := 1 27 + DEFAULT_INSTALL_HDR_PATH := 1 26 28 include ../../lib.mk 27 29 28 30 $(TEST_GEN_FILES): $(HEADERS)
+29 -1
tools/testing/selftests/kselftest/runner.sh
··· 18 18 exit 1 19 19 fi 20 20 21 + TR_CMD=$(command -v tr) 22 + 21 23 # If Perl is unavailable, we must fall back to line-at-a-time prefixing 22 24 # with sed instead of unbuffered output. 23 25 tap_prefix() ··· 51 49 52 50 # Reset any "settings"-file variables. 53 51 export kselftest_timeout="$kselftest_default_timeout" 52 + 53 + # Safe default if tr not available 54 + kselftest_cmd_args_ref="KSELFTEST_ARGS" 55 + 56 + # Optional arguments for this command, possibly defined as an 57 + # environment variable built using the test executable in all 58 + # uppercase and sanitized substituting non acceptable shell 59 + # variable name characters with "_" as in: 60 + # 61 + # KSELFTEST_<UPPERCASE_SANITIZED_TESTNAME>_ARGS="<options>" 62 + # 63 + # e.g. 64 + # 65 + # rtctest --> KSELFTEST_RTCTEST_ARGS="/dev/rtc1" 66 + # 67 + # cpu-on-off-test.sh --> KSELFTEST_CPU_ON_OFF_TEST_SH_ARGS="-a -p 10" 68 + # 69 + if [ -n "$TR_CMD" ]; then 70 + BASENAME_SANITIZED=$(echo "$BASENAME_TEST" | \ 71 + $TR_CMD -d "[:blank:][:cntrl:]" | \ 72 + $TR_CMD -c "[:alnum:]_" "_" | \ 73 + $TR_CMD [:lower:] [:upper:]) 74 + kselftest_cmd_args_ref="KSELFTEST_${BASENAME_SANITIZED}_ARGS" 75 + fi 76 + 54 77 # Load per-test-directory kselftest "settings" file. 55 78 settings="$BASE_DIR/$DIR/settings" 56 79 if [ -r "$settings" ] ; then ··· 96 69 echo "# Warning: file $TEST is missing!" 97 70 echo "not ok $test_num $TEST_HDR_MSG" 98 71 else 99 - cmd="./$BASENAME_TEST" 72 + eval kselftest_cmd_args="\$${kselftest_cmd_args_ref:-}" 73 + cmd="./$BASENAME_TEST $kselftest_cmd_args" 100 74 if [ ! -x "$TEST" ]; then 101 75 echo "# Warning: file $TEST is not executable" 102 76
+1
tools/testing/selftests/kvm/.gitignore
··· 20 20 /x86_64/hyperv_clock 21 21 /x86_64/hyperv_cpuid 22 22 /x86_64/hyperv_features 23 + /x86_64/hyperv_svm_test 23 24 /x86_64/mmio_warning_test 24 25 /x86_64/mmu_role_test 25 26 /x86_64/platform_info_test
+1 -1
tools/testing/selftests/kvm/Makefile
··· 149 149 CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \ 150 150 -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \ 151 151 -I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \ 152 - -I$(<D) -Iinclude/$(UNAME_M) -I.. $(EXTRA_CFLAGS) 152 + -I$(<D) -Iinclude/$(UNAME_M) -I.. $(EXTRA_CFLAGS) $(KHDR_INCLUDES) 153 153 154 154 no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ 155 155 $(CC) -Werror -no-pie -x c - -o "$$TMP", -no-pie)
+1 -1
tools/testing/selftests/landlock/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 - CFLAGS += -Wall -O2 3 + CFLAGS += -Wall -O2 $(KHDR_INCLUDES) 4 4 5 5 src_test := $(wildcard *_test.c) 6 6
+1 -1
tools/testing/selftests/lkdtm/config
··· 3 3 CONFIG_SLAB_FREELIST_HARDENED=y 4 4 CONFIG_FORTIFY_SOURCE=y 5 5 CONFIG_HARDENED_USERCOPY=y 6 - # CONFIG_HARDENED_USERCOPY_FALLBACK is not set 7 6 CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT=y 8 7 CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y 8 + CONFIG_UBSAN=y 9 9 CONFIG_UBSAN_BOUNDS=y 10 10 CONFIG_UBSAN_TRAP=y 11 11 CONFIG_STACKPROTECTOR_STRONG=y
+1 -1
tools/testing/selftests/net/Makefile
··· 2 2 # Makefile for net selftests 3 3 4 4 CFLAGS = -Wall -Wl,--no-as-needed -O2 -g 5 - CFLAGS += -I../../../../usr/include/ 5 + CFLAGS += -I../../../../usr/include/ $(KHDR_INCLUDES) 6 6 7 7 TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh \ 8 8 rtnetlink.sh xfrm_policy.sh test_blackhole_dev.sh
+1 -1
tools/testing/selftests/net/mptcp/Makefile
··· 3 3 top_srcdir = ../../../../.. 4 4 KSFT_KHDR_INSTALL := 1 5 5 6 - CFLAGS = -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include 6 + CFLAGS = -Wall -Wl,--no-as-needed -O2 -g -I$(top_srcdir)/usr/include $(KHDR_INCLUDES) 7 7 8 8 TEST_PROGS := mptcp_connect.sh pm_netlink.sh mptcp_join.sh diag.sh \ 9 9 simult_flows.sh mptcp_sockopt.sh
+1
tools/testing/selftests/netfilter/Makefile
··· 8 8 ipip-conntrack-mtu.sh conntrack_tcp_unreplied.sh \ 9 9 conntrack_vrf.sh nft_synproxy.sh 10 10 11 + CFLAGS += $(shell pkg-config --cflags libmnl 2>/dev/null || echo "-I/usr/include/libmnl") 11 12 LDLIBS = -lmnl 12 13 TEST_GEN_FILES = nf-queue connect_close 13 14
+66
tools/testing/selftests/rtc/rtctest.c
··· 20 20 21 21 #define NUM_UIE 3 22 22 #define ALARM_DELTA 3 23 + #define READ_LOOP_DURATION_SEC 30 24 + #define READ_LOOP_SLEEP_MS 11 23 25 24 26 static char *rtc_file = "/dev/rtc0"; 25 27 ··· 49 47 TH_LOG("Current RTC date/time is %02d/%02d/%02d %02d:%02d:%02d.", 50 48 rtc_tm.tm_mday, rtc_tm.tm_mon + 1, rtc_tm.tm_year + 1900, 51 49 rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec); 50 + } 51 + 52 + static time_t rtc_time_to_timestamp(struct rtc_time *rtc_time) 53 + { 54 + struct tm tm_time = { 55 + .tm_sec = rtc_time->tm_sec, 56 + .tm_min = rtc_time->tm_min, 57 + .tm_hour = rtc_time->tm_hour, 58 + .tm_mday = rtc_time->tm_mday, 59 + .tm_mon = rtc_time->tm_mon, 60 + .tm_year = rtc_time->tm_year, 61 + }; 62 + 63 + return mktime(&tm_time); 64 + } 65 + 66 + static void nanosleep_with_retries(long ns) 67 + { 68 + struct timespec req = { 69 + .tv_sec = 0, 70 + .tv_nsec = ns, 71 + }; 72 + struct timespec rem; 73 + 74 + while (nanosleep(&req, &rem) != 0) { 75 + req.tv_sec = rem.tv_sec; 76 + req.tv_nsec = rem.tv_nsec; 77 + } 78 + } 79 + 80 + TEST_F_TIMEOUT(rtc, date_read_loop, READ_LOOP_DURATION_SEC + 2) { 81 + int rc; 82 + long iter_count = 0; 83 + struct rtc_time rtc_tm; 84 + time_t start_rtc_read, prev_rtc_read; 85 + 86 + TH_LOG("Continuously reading RTC time for %ds (with %dms breaks after every read).", 87 + READ_LOOP_DURATION_SEC, READ_LOOP_SLEEP_MS); 88 + 89 + rc = ioctl(self->fd, RTC_RD_TIME, &rtc_tm); 90 + ASSERT_NE(-1, rc); 91 + start_rtc_read = rtc_time_to_timestamp(&rtc_tm); 92 + prev_rtc_read = start_rtc_read; 93 + 94 + do { 95 + time_t rtc_read; 96 + 97 + rc = ioctl(self->fd, RTC_RD_TIME, &rtc_tm); 98 + ASSERT_NE(-1, rc); 99 + 100 + rtc_read = rtc_time_to_timestamp(&rtc_tm); 101 + /* Time should not go backwards */ 102 + ASSERT_LE(prev_rtc_read, rtc_read); 103 + /* Time should not increase more then 1s at a time */ 104 + ASSERT_GE(prev_rtc_read + 1, rtc_read); 105 + 106 + /* Sleep 11ms to avoid killing / overheating the RTC */ 107 + nanosleep_with_retries(READ_LOOP_SLEEP_MS * 1000000); 108 + 109 + prev_rtc_read = rtc_read; 110 + iter_count++; 111 + } while (prev_rtc_read <= start_rtc_read + READ_LOOP_DURATION_SEC); 112 + 113 + TH_LOG("Performed %ld RTC time reads.", iter_count); 52 114 } 53 115 54 116 TEST_F_TIMEOUT(rtc, uie_read, NUM_UIE + 2) {
+1 -1
tools/testing/selftests/rtc/settings
··· 1 - timeout=180 1 + timeout=210
+1 -1
tools/testing/selftests/vm/Makefile
··· 25 25 # LDLIBS. 26 26 MAKEFLAGS += --no-builtin-rules 27 27 28 - CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) 28 + CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) $(KHDR_INCLUDES) 29 29 LDLIBS = -lrt -lpthread 30 30 TEST_GEN_FILES = compaction_test 31 31 TEST_GEN_FILES += gup_test
+3
tools/testing/selftests/vm/userfaultfd.c
··· 120 120 ~(unsigned long)(sizeof(unsigned long long) \ 121 121 - 1))) 122 122 123 + #define swap(a, b) \ 124 + do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) 125 + 123 126 const char *examples = 124 127 "# Run anonymous memory test on 100MiB region with 99999 bounces:\n" 125 128 "./userfaultfd anon 100 99999\n\n"