Merge tag 'linux-kselftest-5.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull Kselftest fixes from Shuah Khan:

- rseq build failures fixes related to glibc 2.30 compatibility from
Mathieu Desnoyers

- Kunit fixes and cleanups from SeongJae Park

- Fixes to filesystems/epoll, firmware, and livepatch build failures
and skip handling.

* tag 'linux-kselftest-5.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
rseq/selftests: Clarify rseq_prepare_unload() helper requirements
rseq/selftests: Fix: Namespace gettid() for compatibility with glibc 2.30
rseq/selftests: Turn off timeout setting
kunit/kunit_tool_test: Test '--build_dir' option run
kunit: Rename 'kunitconfig' to '.kunitconfig'
kunit: Place 'test.log' under the 'build_dir'
kunit: Create default config in '--build_dir'
kunit: Remove duplicated defconfig creation
docs/kunit/start: Use in-tree 'kunit_defconfig'
selftests: livepatch: Fix it to do root uid check and skip
selftests: firmware: Fix it to do root uid check and skip
selftests: filesystems/epoll: fix build error

+70 -38
+5 -8
Documentation/dev-tools/kunit/start.rst
··· 24 For more information on this wrapper (also called kunit_tool) checkout the 25 :doc:`kunit-tool` page. 26 27 - Creating a kunitconfig 28 - ====================== 29 The Python script is a thin wrapper around Kbuild. As such, it needs to be 30 - configured with a ``kunitconfig`` file. This file essentially contains the 31 regular Kernel config, with the specific test targets as well. 32 33 .. code-block:: bash 34 35 - git clone -b master https://kunit.googlesource.com/kunitconfig $PATH_TO_KUNITCONFIG_REPO 36 cd $PATH_TO_LINUX_REPO 37 - ln -s $PATH_TO_KUNIT_CONFIG_REPO/kunitconfig kunitconfig 38 - 39 - You may want to add kunitconfig to your local gitignore. 40 41 Verifying KUnit Works 42 --------------------- ··· 148 149 obj-$(CONFIG_MISC_EXAMPLE_TEST) += example-test.o 150 151 - Now add it to your ``kunitconfig``: 152 153 .. code-block:: none 154
··· 24 For more information on this wrapper (also called kunit_tool) checkout the 25 :doc:`kunit-tool` page. 26 27 + Creating a .kunitconfig 28 + ======================= 29 The Python script is a thin wrapper around Kbuild. As such, it needs to be 30 + configured with a ``.kunitconfig`` file. This file essentially contains the 31 regular Kernel config, with the specific test targets as well. 32 33 .. code-block:: bash 34 35 cd $PATH_TO_LINUX_REPO 36 + cp arch/um/configs/kunit_defconfig .kunitconfig 37 38 Verifying KUnit Works 39 --------------------- ··· 151 152 obj-$(CONFIG_MISC_EXAMPLE_TEST) += example-test.o 153 154 + Now add it to your ``.kunitconfig``: 155 156 .. code-block:: none 157
+11 -7
tools/testing/kunit/kunit.py
··· 31 TEST_FAILURE = auto() 32 33 def create_default_kunitconfig(): 34 - if not os.path.exists(kunit_kernel.KUNITCONFIG_PATH): 35 shutil.copyfile('arch/um/configs/kunit_defconfig', 36 - kunit_kernel.KUNITCONFIG_PATH) 37 38 def run_tests(linux: kunit_kernel.LinuxSourceTree, 39 request: KunitRequest) -> KunitResult: 40 - if request.defconfig: 41 - create_default_kunitconfig() 42 - 43 config_start = time.time() 44 success = linux.build_reconfig(request.build_dir) 45 config_end = time.time() ··· 105 run_parser.add_argument('--build_dir', 106 help='As in the make command, it specifies the build ' 107 'directory.', 108 - type=str, default=None, metavar='build_dir') 109 110 run_parser.add_argument('--defconfig', 111 - help='Uses a default kunitconfig.', 112 action='store_true') 113 114 cli_args = parser.parse_args(argv) 115 116 if cli_args.subcommand == 'run': 117 if cli_args.defconfig: 118 create_default_kunitconfig() 119
··· 31 TEST_FAILURE = auto() 32 33 def create_default_kunitconfig(): 34 + if not os.path.exists(kunit_kernel.kunitconfig_path): 35 shutil.copyfile('arch/um/configs/kunit_defconfig', 36 + kunit_kernel.kunitconfig_path) 37 38 def run_tests(linux: kunit_kernel.LinuxSourceTree, 39 request: KunitRequest) -> KunitResult: 40 config_start = time.time() 41 success = linux.build_reconfig(request.build_dir) 42 config_end = time.time() ··· 108 run_parser.add_argument('--build_dir', 109 help='As in the make command, it specifies the build ' 110 'directory.', 111 + type=str, default='', metavar='build_dir') 112 113 run_parser.add_argument('--defconfig', 114 + help='Uses a default .kunitconfig.', 115 action='store_true') 116 117 cli_args = parser.parse_args(argv) 118 119 if cli_args.subcommand == 'run': 120 + if cli_args.build_dir: 121 + if not os.path.exists(cli_args.build_dir): 122 + os.mkdir(cli_args.build_dir) 123 + kunit_kernel.kunitconfig_path = os.path.join( 124 + cli_args.build_dir, 125 + kunit_kernel.kunitconfig_path) 126 + 127 if cli_args.defconfig: 128 create_default_kunitconfig() 129
+5 -5
tools/testing/kunit/kunit_kernel.py
··· 14 import kunit_config 15 16 KCONFIG_PATH = '.config' 17 - KUNITCONFIG_PATH = 'kunitconfig' 18 19 class ConfigError(Exception): 20 """Represents an error trying to configure the Linux kernel.""" ··· 82 83 def __init__(self): 84 self._kconfig = kunit_config.Kconfig() 85 - self._kconfig.read_from_file(KUNITCONFIG_PATH) 86 self._ops = LinuxSourceTreeOperations() 87 88 def clean(self): ··· 111 return True 112 113 def build_reconfig(self, build_dir): 114 - """Creates a new .config if it is not a subset of the kunitconfig.""" 115 kconfig_path = get_kconfig_path(build_dir) 116 if os.path.exists(kconfig_path): 117 existing_kconfig = kunit_config.Kconfig() ··· 140 return False 141 return True 142 143 - def run_kernel(self, args=[], timeout=None, build_dir=None): 144 args.extend(['mem=256M']) 145 process = self._ops.linux_bin(args, timeout, build_dir) 146 - with open('test.log', 'w') as f: 147 for line in process.stdout: 148 f.write(line.rstrip().decode('ascii') + '\n') 149 yield line.rstrip().decode('ascii')
··· 14 import kunit_config 15 16 KCONFIG_PATH = '.config' 17 + kunitconfig_path = '.kunitconfig' 18 19 class ConfigError(Exception): 20 """Represents an error trying to configure the Linux kernel.""" ··· 82 83 def __init__(self): 84 self._kconfig = kunit_config.Kconfig() 85 + self._kconfig.read_from_file(kunitconfig_path) 86 self._ops = LinuxSourceTreeOperations() 87 88 def clean(self): ··· 111 return True 112 113 def build_reconfig(self, build_dir): 114 + """Creates a new .config if it is not a subset of the .kunitconfig.""" 115 kconfig_path = get_kconfig_path(build_dir) 116 if os.path.exists(kconfig_path): 117 existing_kconfig = kunit_config.Kconfig() ··· 140 return False 141 return True 142 143 + def run_kernel(self, args=[], timeout=None, build_dir=''): 144 args.extend(['mem=256M']) 145 process = self._ops.linux_bin(args, timeout, build_dir) 146 + with open(os.path.join(build_dir, 'test.log'), 'w') as f: 147 for line in process.stdout: 148 f.write(line.rstrip().decode('ascii') + '\n') 149 yield line.rstrip().decode('ascii')
+9 -1
tools/testing/kunit/kunit_tool_test.py
··· 174 kunit.main(['run'], self.linux_source_mock) 175 assert self.linux_source_mock.build_reconfig.call_count == 1 176 assert self.linux_source_mock.run_kernel.call_count == 1 177 self.print_mock.assert_any_call(StrContains('Testing complete.')) 178 179 def test_run_passes_args_fail(self): ··· 200 timeout = 3453 201 kunit.main(['run', '--timeout', str(timeout)], self.linux_source_mock) 202 assert self.linux_source_mock.build_reconfig.call_count == 1 203 - self.linux_source_mock.run_kernel.assert_called_once_with(build_dir=None, timeout=timeout) 204 self.print_mock.assert_any_call(StrContains('Testing complete.')) 205 206 if __name__ == '__main__':
··· 174 kunit.main(['run'], self.linux_source_mock) 175 assert self.linux_source_mock.build_reconfig.call_count == 1 176 assert self.linux_source_mock.run_kernel.call_count == 1 177 + self.linux_source_mock.run_kernel.assert_called_once_with(build_dir='', timeout=300) 178 self.print_mock.assert_any_call(StrContains('Testing complete.')) 179 180 def test_run_passes_args_fail(self): ··· 199 timeout = 3453 200 kunit.main(['run', '--timeout', str(timeout)], self.linux_source_mock) 201 assert self.linux_source_mock.build_reconfig.call_count == 1 202 + self.linux_source_mock.run_kernel.assert_called_once_with(build_dir='', timeout=timeout) 203 + self.print_mock.assert_any_call(StrContains('Testing complete.')) 204 + 205 + def test_run_builddir(self): 206 + build_dir = '.kunit' 207 + kunit.main(['run', '--build_dir', build_dir], self.linux_source_mock) 208 + assert self.linux_source_mock.build_reconfig.call_count == 1 209 + self.linux_source_mock.run_kernel.assert_called_once_with(build_dir=build_dir, timeout=300) 210 self.print_mock.assert_any_call(StrContains('Testing complete.')) 211 212 if __name__ == '__main__':
+1 -1
tools/testing/selftests/filesystems/epoll/Makefile
··· 1 # SPDX-License-Identifier: GPL-2.0 2 3 CFLAGS += -I../../../../../usr/include/ 4 - LDFLAGS += -lpthread 5 TEST_GEN_PROGS := epoll_wakeup_test 6 7 include ../../lib.mk
··· 1 # SPDX-License-Identifier: GPL-2.0 2 3 CFLAGS += -I../../../../../usr/include/ 4 + LDLIBS += -lpthread 5 TEST_GEN_PROGS := epoll_wakeup_test 6 7 include ../../lib.mk
+6
tools/testing/selftests/firmware/fw_lib.sh
··· 34 35 check_mods() 36 { 37 trap "test_modprobe" EXIT 38 if [ ! -d $DIR ]; then 39 modprobe test_firmware
··· 34 35 check_mods() 36 { 37 + local uid=$(id -u) 38 + if [ $uid -ne 0 ]; then 39 + echo "skip all tests: must be run as root" >&2 40 + exit $ksft_skip 41 + fi 42 + 43 trap "test_modprobe" EXIT 44 if [ ! -d $DIR ]; then 45 modprobe test_firmware
+14 -1
tools/testing/selftests/livepatch/functions.sh
··· 7 MAX_RETRIES=600 8 RETRY_INTERVAL=".1" # seconds 9 10 # log(msg) - write message to kernel log 11 # msg - insightful words 12 function log() { ··· 21 function skip() { 22 log "SKIP: $1" 23 echo "SKIP: $1" >&2 24 - exit 4 25 } 26 27 # die(msg) - game over, man ··· 74 # for verbose livepatching output and turn on 75 # the ftrace_enabled sysctl. 76 function setup_config() { 77 push_config 78 set_dynamic_debug 79 set_ftrace_enabled 1
··· 7 MAX_RETRIES=600 8 RETRY_INTERVAL=".1" # seconds 9 10 + # Kselftest framework requirement - SKIP code is 4 11 + ksft_skip=4 12 + 13 # log(msg) - write message to kernel log 14 # msg - insightful words 15 function log() { ··· 18 function skip() { 19 log "SKIP: $1" 20 echo "SKIP: $1" >&2 21 + exit $ksft_skip 22 + } 23 + 24 + # root test 25 + function is_root() { 26 + uid=$(id -u) 27 + if [ $uid -ne 0 ]; then 28 + echo "skip all tests: must be run as root" >&2 29 + exit $ksft_skip 30 + fi 31 } 32 33 # die(msg) - game over, man ··· 62 # for verbose livepatching output and turn on 63 # the ftrace_enabled sysctl. 64 function setup_config() { 65 + is_root 66 push_config 67 set_dynamic_debug 68 set_ftrace_enabled 1
+1 -2
tools/testing/selftests/livepatch/test-state.sh
··· 8 MOD_LIVEPATCH2=test_klp_state2 9 MOD_LIVEPATCH3=test_klp_state3 10 11 - set_dynamic_debug 12 - 13 14 # TEST: Loading and removing a module that modifies the system state 15
··· 8 MOD_LIVEPATCH2=test_klp_state2 9 MOD_LIVEPATCH3=test_klp_state3 10 11 + setup_config 12 13 # TEST: Loading and removing a module that modifies the system state 14
+10 -8
tools/testing/selftests/rseq/param_test.c
··· 15 #include <errno.h> 16 #include <stddef.h> 17 18 - static inline pid_t gettid(void) 19 { 20 return syscall(__NR_gettid); 21 } ··· 373 rseq_percpu_unlock(&data->lock, cpu); 374 #ifndef BENCHMARK 375 if (i != 0 && !(i % (reps / 10))) 376 - printf_verbose("tid %d: count %lld\n", (int) gettid(), i); 377 #endif 378 } 379 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n", 380 - (int) gettid(), nr_abort, signals_delivered); 381 if (!opt_disable_rseq && thread_data->reg && 382 rseq_unregister_current_thread()) 383 abort(); ··· 455 } while (rseq_unlikely(ret)); 456 #ifndef BENCHMARK 457 if (i != 0 && !(i % (reps / 10))) 458 - printf_verbose("tid %d: count %lld\n", (int) gettid(), i); 459 #endif 460 } 461 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n", 462 - (int) gettid(), nr_abort, signals_delivered); 463 if (!opt_disable_rseq && thread_data->reg && 464 rseq_unregister_current_thread()) 465 abort(); ··· 607 } 608 609 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n", 610 - (int) gettid(), nr_abort, signals_delivered); 611 if (!opt_disable_rseq && rseq_unregister_current_thread()) 612 abort(); 613 ··· 798 } 799 800 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n", 801 - (int) gettid(), nr_abort, signals_delivered); 802 if (!opt_disable_rseq && rseq_unregister_current_thread()) 803 abort(); 804 ··· 1013 } 1014 1015 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n", 1016 - (int) gettid(), nr_abort, signals_delivered); 1017 if (!opt_disable_rseq && rseq_unregister_current_thread()) 1018 abort(); 1019
··· 15 #include <errno.h> 16 #include <stddef.h> 17 18 + static inline pid_t rseq_gettid(void) 19 { 20 return syscall(__NR_gettid); 21 } ··· 373 rseq_percpu_unlock(&data->lock, cpu); 374 #ifndef BENCHMARK 375 if (i != 0 && !(i % (reps / 10))) 376 + printf_verbose("tid %d: count %lld\n", 377 + (int) rseq_gettid(), i); 378 #endif 379 } 380 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n", 381 + (int) rseq_gettid(), nr_abort, signals_delivered); 382 if (!opt_disable_rseq && thread_data->reg && 383 rseq_unregister_current_thread()) 384 abort(); ··· 454 } while (rseq_unlikely(ret)); 455 #ifndef BENCHMARK 456 if (i != 0 && !(i % (reps / 10))) 457 + printf_verbose("tid %d: count %lld\n", 458 + (int) rseq_gettid(), i); 459 #endif 460 } 461 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n", 462 + (int) rseq_gettid(), nr_abort, signals_delivered); 463 if (!opt_disable_rseq && thread_data->reg && 464 rseq_unregister_current_thread()) 465 abort(); ··· 605 } 606 607 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n", 608 + (int) rseq_gettid(), nr_abort, signals_delivered); 609 if (!opt_disable_rseq && rseq_unregister_current_thread()) 610 abort(); 611 ··· 796 } 797 798 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n", 799 + (int) rseq_gettid(), nr_abort, signals_delivered); 800 if (!opt_disable_rseq && rseq_unregister_current_thread()) 801 abort(); 802 ··· 1011 } 1012 1013 printf_verbose("tid %d: number of rseq abort: %d, signals delivered: %u\n", 1014 + (int) rseq_gettid(), nr_abort, signals_delivered); 1015 if (!opt_disable_rseq && rseq_unregister_current_thread()) 1016 abort(); 1017
+7 -5
tools/testing/selftests/rseq/rseq.h
··· 149 /* 150 * rseq_prepare_unload() should be invoked by each thread executing a rseq 151 * critical section at least once between their last critical section and 152 - * library unload of the library defining the rseq critical section 153 - * (struct rseq_cs). This also applies to use of rseq in code generated by 154 - * JIT: rseq_prepare_unload() should be invoked at least once by each 155 - * thread executing a rseq critical section before reclaim of the memory 156 - * holding the struct rseq_cs. 157 */ 158 static inline void rseq_prepare_unload(void) 159 {
··· 149 /* 150 * rseq_prepare_unload() should be invoked by each thread executing a rseq 151 * critical section at least once between their last critical section and 152 + * library unload of the library defining the rseq critical section (struct 153 + * rseq_cs) or the code referred to by the struct rseq_cs start_ip and 154 + * post_commit_offset fields. This also applies to use of rseq in code 155 + * generated by JIT: rseq_prepare_unload() should be invoked at least once by 156 + * each thread executing a rseq critical section before reclaim of the memory 157 + * holding the struct rseq_cs or reclaim of the code pointed to by struct 158 + * rseq_cs start_ip and post_commit_offset fields. 159 */ 160 static inline void rseq_prepare_unload(void) 161 {
+1
tools/testing/selftests/rseq/settings
···
··· 1 + timeout=0