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