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

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

Pull Kunit fixes from Shuah Khan:
"This Kselftest kunit update consists of fixes to documentation and
the run-time tool from Brendan Higgins and Heidi Fahim"

* tag 'linux-kselftest-kunit-5.6-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
kunit: run kunit_tool from any directory
kunit: test: Improve error messages for kunit_tool when kunitconfig is invalid
Documentation: kunit: fixed sphinx error in code block

+29 -12
+1
Documentation/dev-tools/kunit/usage.rst
··· 551 551 Once the kernel is built and installed, a simple 552 552 553 553 .. code-block:: bash 554 + 554 555 modprobe example-test 555 556 556 557 ...will run the tests.
+12
tools/testing/kunit/kunit.py
··· 24 24 25 25 KunitRequest = namedtuple('KunitRequest', ['raw_output','timeout', 'jobs', 'build_dir', 'defconfig']) 26 26 27 + KernelDirectoryPath = sys.argv[0].split('tools/testing/kunit/')[0] 28 + 27 29 class KunitStatus(Enum): 28 30 SUCCESS = auto() 29 31 CONFIG_FAILURE = auto() ··· 36 34 if not os.path.exists(kunit_kernel.kunitconfig_path): 37 35 shutil.copyfile('arch/um/configs/kunit_defconfig', 38 36 kunit_kernel.kunitconfig_path) 37 + 38 + def get_kernel_root_path(): 39 + parts = sys.argv[0] if not __file__ else __file__ 40 + parts = os.path.realpath(parts).split('tools/testing/kunit') 41 + if len(parts) != 2: 42 + sys.exit(1) 43 + return parts[0] 39 44 40 45 def run_tests(linux: kunit_kernel.LinuxSourceTree, 41 46 request: KunitRequest) -> KunitResult: ··· 123 114 cli_args = parser.parse_args(argv) 124 115 125 116 if cli_args.subcommand == 'run': 117 + if get_kernel_root_path(): 118 + os.chdir(get_kernel_root_path()) 119 + 126 120 if cli_args.build_dir: 127 121 if not os.path.exists(cli_args.build_dir): 128 122 os.mkdir(cli_args.build_dir)
+16 -12
tools/testing/kunit/kunit_kernel.py
··· 93 93 return False 94 94 return True 95 95 96 + def validate_config(self, build_dir): 97 + kconfig_path = get_kconfig_path(build_dir) 98 + validated_kconfig = kunit_config.Kconfig() 99 + validated_kconfig.read_from_file(kconfig_path) 100 + if not self._kconfig.is_subset_of(validated_kconfig): 101 + invalid = self._kconfig.entries() - validated_kconfig.entries() 102 + message = 'Provided Kconfig is not contained in validated .config. Following fields found in kunitconfig, ' \ 103 + 'but not in .config: %s' % ( 104 + ', '.join([str(e) for e in invalid]) 105 + ) 106 + logging.error(message) 107 + return False 108 + return True 109 + 96 110 def build_config(self, build_dir): 97 111 kconfig_path = get_kconfig_path(build_dir) 98 112 if build_dir and not os.path.exists(build_dir): ··· 117 103 except ConfigError as e: 118 104 logging.error(e) 119 105 return False 120 - validated_kconfig = kunit_config.Kconfig() 121 - validated_kconfig.read_from_file(kconfig_path) 122 - if not self._kconfig.is_subset_of(validated_kconfig): 123 - logging.error('Provided Kconfig is not contained in validated .config!') 124 - return False 125 - return True 106 + return self.validate_config(build_dir) 126 107 127 108 def build_reconfig(self, build_dir): 128 109 """Creates a new .config if it is not a subset of the .kunitconfig.""" ··· 142 133 except (ConfigError, BuildError) as e: 143 134 logging.error(e) 144 135 return False 145 - used_kconfig = kunit_config.Kconfig() 146 - used_kconfig.read_from_file(get_kconfig_path(build_dir)) 147 - if not self._kconfig.is_subset_of(used_kconfig): 148 - logging.error('Provided Kconfig is not contained in final config!') 149 - return False 150 - return True 136 + return self.validate_config(build_dir) 151 137 152 138 def run_kernel(self, args=[], timeout=None, build_dir=''): 153 139 args.extend(['mem=256M'])