kunit: Fix kunit.py run --build_dir='<foo>' fails on "unclean" trees
PATCH RESEND v3 1/1 kunit: Fix kunit.py run --build_dir='<foo>' fails on "unclean" trees
Fix this bug: https://bugzilla.kernel.org/show_bug.cgi?id=205219
For some reason, the environment variable ARCH is used instead of ARCH passed as an argument, this patch uses a copy of the env, but using ARCH=um and CROSS_COMPILER='' to avoid this problem.
This patch doesn't change the user's environment variables, avoiding side effects.
---
v2:
- Use the correct next branch
v3:
- Use torvalds/master branch
- Use base parameter on git send-email
--- tools/testing/kunit/kunit_kernel.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
tools/testing/kunit/kunit_kernel.py +12 -7
@@ -20,6 +20,7 @@ import kunit_parser KCONFIG_PATH = '.config' kunitconfig_path = '.kunitconfig' BROKEN_ALLCONFIG_PATH = 'tools/testing/kunit/configs/broken_on_uml.config' +env = dict(os.environ.copy(), ARCH='um', CROSS_COMPILE='') class ConfigError(Exception): """Represents an error trying to configure the Linux kernel."""
@@ -41,13 +42,15 @@ class LinuxSourceTreeOperations(object): raise ConfigError(e.output) def make_olddefconfig(self, build_dir, make_options): - command = ['make', 'ARCH=um', 'olddefconfig'] + command = ['make', 'olddefconfig'] if make_options: command.extend(make_options) if build_dir: command += ['O=' + build_dir] try: - subprocess.check_output(command, stderr=subprocess.PIPE) + subprocess.check_output(command, + stderr=subprocess.PIPE, + env=env) except OSError as e: raise ConfigError('Could not call make command: ' + e) except subprocess.CalledProcessError as e:
@@ -57,9 +60,10 @@ class LinuxSourceTreeOperations(object): kunit_parser.print_with_timestamp( 'Enabling all CONFIGs for UML...') process = subprocess.Popen( - ['make', 'ARCH=um', 'allyesconfig'], + ['make', 'allyesconfig'], stdout=subprocess.DEVNULL, - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, + env=env) process.wait() kunit_parser.print_with_timestamp( 'Disabling broken configs to run KUnit tests...')
@@ -71,13 +75,13 @@ class LinuxSourceTreeOperations(object): 'Starting Kernel with all configs takes a few minutes...') def make(self, jobs, build_dir, make_options): - command = ['make', 'ARCH=um', '--jobs=' + str(jobs)] + command = ['make', '--jobs=' + str(jobs)] if make_options: command.extend(make_options) if build_dir: command += ['O=' + build_dir] try: - subprocess.check_output(command) + subprocess.check_output(command, env=env) except OSError as e: raise BuildError('Could not call execute make: ' + e) except subprocess.CalledProcessError as e:
@@ -91,7 +95,8 @@ class LinuxSourceTreeOperations(object): with open(outfile, 'w') as output: process = subprocess.Popen([linux_bin] + params, stdout=output, - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, + env=env) process.wait(timeout)
base-commit: 7e63420847ae5f1036e4f7c42f0b3282e73efbc2
Signature · 6 lines
2.25.1 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 2 lines · Vitor Massaru Iha
Fix this bug: https://bugzilla.kernel.org/show_bug.cgi?id=205219
I am still seeing the error described in the bug.
Steps to reproduce:
1. tools/testing/kunit/kunit.py run --timeout=60 --jobs=8 --defconfig
2. make ARCH=um mrproper
3. tools/testing/kunit/kunit.py run --timeout=60 --jobs=8 --defconfig --build_dir=.kunit
One other note: It should probably be done in another patch, but it would be nice if kunit.py would tell you that you need to run mrproper when the olddefconfig fails.
Quoted 93 lines
For some reason, the environment variable ARCH is used instead of ARCH passed as an argument, this patch uses a copy of the env, but using ARCH=um and CROSS_COMPILER='' to avoid this problem.
This patch doesn't change the user's environment variables, avoiding side effects.
Signed-off-by Vitor Massaru Iha <[email protected]>---
v2:
- Use the correct next branchv3:
- Use torvalds/master branch
- Use base parameter on git send-email--- tools/testing/kunit/kunit_kernel.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)tools/testing/kunit/kunit_kernel.py +12
-7@@ -20,6 +20,7 @@ import kunit_parser KCONFIG_PATH = '.config' kunitconfig_path = '.kunitconfig' BROKEN_ALLCONFIG_PATH = 'tools/testing/kunit/configs/broken_on_uml.config' +env = dict(os.environ.copy(), ARCH='um', CROSS_COMPILE='') class ConfigError(Exception): """Represents an error trying to configure the Linux kernel."""@@ -41,13 +42,15 @@ class LinuxSourceTreeOperations(object): raise ConfigError(e.output) def make_olddefconfig(self, build_dir, make_options): - command = ['make', 'ARCH=um', 'olddefconfig'] + command = ['make', 'olddefconfig'] if make_options: command.extend(make_options) if build_dir: command += ['O=' + build_dir] try: - subprocess.check_output(command, stderr=subprocess.PIPE) + subprocess.check_output(command, + stderr=subprocess.PIPE, + env=env) except OSError as e: raise ConfigError('Could not call make command: ' + e) except subprocess.CalledProcessError as e:@@ -57,9 +60,10 @@ class LinuxSourceTreeOperations(object): kunit_parser.print_with_timestamp( 'Enabling all CONFIGs for UML...') process = subprocess.Popen( - ['make', 'ARCH=um', 'allyesconfig'], + ['make', 'allyesconfig'], stdout=subprocess.DEVNULL, - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, + env=env) process.wait() kunit_parser.print_with_timestamp( 'Disabling broken configs to run KUnit tests...')@@ -71,13 +75,13 @@ class LinuxSourceTreeOperations(object): 'Starting Kernel with all configs takes a few minutes...') def make(self, jobs, build_dir, make_options): - command = ['make', 'ARCH=um', '--jobs=' + str(jobs)] + command = ['make', '--jobs=' + str(jobs)] if make_options: command.extend(make_options) if build_dir: command += ['O=' + build_dir] try: - subprocess.check_output(command) + subprocess.check_output(command, env=env) except OSError as e: raise BuildError('Could not call execute make: ' + e) except subprocess.CalledProcessError as e:@@ -91,7 +95,8 @@ class LinuxSourceTreeOperations(object): with open(outfile, 'w') as output: process = subprocess.Popen([linux_bin] + params, stdout=output, - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, + env=env) process.wait(timeout)base-commit:
7e63420847ae5f1036e4f7c42f0b3282e73efbc2--
2.25.1
Hi Brendan,
Quoted 6 lines · Brendan Higgins
Quoted 1 line · Vitor Massaru Iha
Fix this bug: https://bugzilla.kernel.org/show_bug.cgi?id=205219
I am still seeing the error described in the bug.
Quoted 8 lines
Steps to reproduce:
1.
tools/testing/kunit/kunit.pyrun --timeout=60 --jobs=8 --defconfig2. make ARCH=um mrproper
3.
tools/testing/kunit/kunit.pyrun --timeout=60 --jobs=8 --defconfig --build_dir=.kunit
Thanks. I managed to reproduce the bug. I'm working on it.
Quoted 4 lines
One other note: It should probably be done in another patch, but it would be nice if
kunit.pywould tell you that you need to run mrproper
when the olddefconfig fails.
Sure, I can work on it.
Quoted 109 lines
Quoted 109 lines
For some reason, the environment variable ARCH is used instead of ARCH
passed as an argument, this patch uses a copy of the env, but using ARCH=um and CROSS_COMPILER='' to avoid this problem.This patch doesn't change the user's environment variables, avoiding
side effects.Signed-off-by Vitor Massaru Iha <[email protected]>---
v2:
- Use the correct next branchv3:
- Use torvalds/master branch
- Use base parameter on git send-email--- tools/testing/kunit/kunit_kernel.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)tools/testing/kunit/kunit_kernel.py +0
-0@@ -20,6 +20,7 @@ import kunit_parser KCONFIG_PATH = '.config' kunitconfig_path = '.kunitconfig' BROKEN_ALLCONFIG_PATH ='
tools/testing/kunit/configs/broken_on_uml.config' +env =dict(os.environ.copy(), ARCH='um', CROSS_COMPILE='')class ConfigError(Exception):
"""Represents an error trying to configure the Linux
kernel."""tools/testing/kunit/kunit_kernel.py +4
-2@@ -41,13 +42,15 @@ class LinuxSourceTreeOperations(object): raise ConfigError(e.output) def make_olddefconfig(self, build_dir, make_options): - command = ['make', 'ARCH=um', 'olddefconfig'] + command = ['make', 'olddefconfig'] if make_options: command.extend(make_options) if build_dir: command += ['O=' + build_dir] try: - subprocess.check_output(command, stderr=subprocess.PIPE) + subprocess.check_output(command, + stderr=subprocess.P IPE, + env=env) except OSError as e:raise ConfigError('Could not call make
command: ' + e)
except subprocess.CalledProcessError as e:tools/testing/kunit/kunit_kernel.py +3
-2@@ -57,9 +60,10 @@ class LinuxSourceTreeOperations(object): kunit_parser.print_with_timestamp( 'Enabling all CONFIGs for UML...') process = subprocess.Popen( - ['make', 'ARCH=um', 'allyesconfig'], + ['make', 'allyesconfig'], stdout=subprocess.DEVNULL, - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, + env=env) process.wait() kunit_parser.print_with_timestamp( 'Disabling broken configs to run KUnittests...')
tools/testing/kunit/kunit_kernel.py +0
-1@@ -71,13 +75,13 @@ class LinuxSourceTreeOperations(object): 'Starting Kernel with all configs takes a few minutes...') def make(self, jobs, build_dir, make_options): - command = ['make', 'ARCH=um', '--jobs=' +str(jobs)]
tools/testing/kunit/kunit_kernel.py +2
-1+ command = ['make', '--jobs=' + str(jobs)] if make_options: command.extend(make_options) if build_dir: command += ['O=' + build_dir] try: - subprocess.check_output(command) + subprocess.check_output(command, env=env) except OSError as e: raise BuildError('Could not call executemake: ' + e)
except subprocess.CalledProcessError as e:tools/testing/kunit/kunit_kernel.py +2
-1@@ -91,7 +95,8 @@ class LinuxSourceTreeOperations(object): with open(outfile, 'w') as output: process = subprocess.Popen([linux_bin] + params, stdout=output, - stderr=subproces s.STDOUT) + stderr=subproces s.STDOUT, + env=env)
process.wait(timeout)base-commit:
7e63420847ae5f1036e4f7c42f0b3282e73efbc2--
2.25.1