Skip to contentSkip to conversation

kunit: tool: fix --alltests flag

PATCH In review Brendan Higgins 2 participants 2 messages Sep 23, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kunit: tool: fix --alltests flag

Alltests flag evidently stopped working when run from outside of the root of the source tree, so fix that. Also add an additional broken config to the broken_on_uml config.

---
 tools/testing/kunit/configs/broken_on_uml.config |  1 +
 tools/testing/kunit/kunit_kernel.py              | 15 ++++++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)
tools/testing/kunit/configs/broken_on_uml.config +1 -0
index 239b9f03da2c..a7f0603d33f6 100644
@@ -39,3 +39,4 @@
 # CONFIG_QCOM_CPR is not set
 # CONFIG_RESET_BRCMSTB_RESCAL is not set
 # CONFIG_RESET_INTEL_GW is not set
+# CONFIG_ADI_AXI_ADC is not set
tools/testing/kunit/kunit_kernel.py +10 -5
index e20e2056cb38..1b1826500f61 100644
@@ -53,18 +53,23 @@ class LinuxSourceTreeOperations(object):
 		except subprocess.CalledProcessError as e:
 			raise ConfigError(e.output)
 
-	def make_allyesconfig(self):
+	def make_allyesconfig(self, build_dir, make_options):
 		kunit_parser.print_with_timestamp(
 			'Enabling all CONFIGs for UML...')
+		command = ['make', 'ARCH=um', 'allyesconfig']
+		if make_options:
+			command.extend(make_options)
+		if build_dir:
+			command += ['O=' + build_dir]
 		process = subprocess.Popen(
-			['make', 'ARCH=um', 'allyesconfig'],
+			command,
 			stdout=subprocess.DEVNULL,
 			stderr=subprocess.STDOUT)
 		process.wait()
 		kunit_parser.print_with_timestamp(
 			'Disabling broken configs to run KUnit tests...')
 		with ExitStack() as es:
-			config = open(KCONFIG_PATH, 'a')
+			config = open(get_kconfig_path(build_dir), 'a')
 			disable = open(BROKEN_ALLCONFIG_PATH, 'r').read()
 			config.write(disable)
 		kunit_parser.print_with_timestamp(
@@ -161,9 +166,9 @@ class LinuxSourceTree(object):
 			return self.build_config(build_dir, make_options)
 
 	def build_um_kernel(self, alltests, jobs, build_dir, make_options):
-		if alltests:
-			self._ops.make_allyesconfig()
 		try:
+			if alltests:
+				self._ops.make_allyesconfig(build_dir, make_options)
 			self._ops.make_olddefconfig(build_dir, make_options)
 			self._ops.make(jobs, build_dir, make_options)
 		except (ConfigError, BuildError) as e:

base-commit: 92a2b470086f68bf35eb9f94b6cb5ebdfac41b25

Signature · 1 line
2.28.0.681.g6f77f65b4e-goog
maintainer
#1 lore raw
Quoted 63 lines · Brendan Higgins

Alltests flag evidently stopped working when run from outside of the root of the source tree, so fix that. Also add an additional broken config to the broken_on_uml config.

---
  tools/testing/kunit/configs/broken_on_uml.config |  1 +
  tools/testing/kunit/kunit_kernel.py              | 15 ++++++++++-----
  2 files changed, 11 insertions(+), 5 deletions(-)
tools/testing/kunit/configs/broken_on_uml.config +1 -0
index 239b9f03da2c..a7f0603d33f6 100644
@@ -39,3 +39,4 @@
  # CONFIG_QCOM_CPR is not set
  # CONFIG_RESET_BRCMSTB_RESCAL is not set
  # CONFIG_RESET_INTEL_GW is not set
+# CONFIG_ADI_AXI_ADC is not set
tools/testing/kunit/kunit_kernel.py +10 -5
index e20e2056cb38..1b1826500f61 100644
@@ -53,18 +53,23 @@ class LinuxSourceTreeOperations(object):
  		except subprocess.CalledProcessError as e:
  			raise ConfigError(e.output)
 
-	def make_allyesconfig(self):
+	def make_allyesconfig(self, build_dir, make_options):
  		kunit_parser.print_with_timestamp(
  			'Enabling all CONFIGs for UML...')
+		command = ['make', 'ARCH=um', 'allyesconfig']
+		if make_options:
+			command.extend(make_options)
+		if build_dir:
+			command += ['O=' + build_dir]
  		process = subprocess.Popen(
-			['make', 'ARCH=um', 'allyesconfig'],
+			command,
  			stdout=subprocess.DEVNULL,
  			stderr=subprocess.STDOUT)
  		process.wait()
  		kunit_parser.print_with_timestamp(
  			'Disabling broken configs to run KUnit tests...')
  		with ExitStack() as es:
-			config = open(KCONFIG_PATH, 'a')
+			config = open(get_kconfig_path(build_dir), 'a')
  			disable = open(BROKEN_ALLCONFIG_PATH, 'r').read()
  			config.write(disable)
  		kunit_parser.print_with_timestamp(
@@ -161,9 +166,9 @@ class LinuxSourceTree(object):
  			return self.build_config(build_dir, make_options)
 
  	def build_um_kernel(self, alltests, jobs, build_dir, make_options):
-		if alltests:
-			self._ops.make_allyesconfig()
  		try:
+			if alltests:
+				self._ops.make_allyesconfig(build_dir, make_options)
  			self._ops.make_olddefconfig(build_dir, make_options)
  			self._ops.make(jobs, build_dir, make_options)
  		except (ConfigError, BuildError) as e:
Quoted 2 lines

base-commit: 92a2b470086f68bf35eb9f94b6cb5ebdfac41b25

Thanks. Applied to linux-kselftest kunit-fiex for 5.10-rc1

thanks,
-- Shuah