Have Custom install chdir to test.bindir
PATCH 1/1 Have Custom install chdir to test.bindir
If you are using custom install and load_modules=yes, then autotest needs to change to the test.bindir so that it looks for kernel modules in the right place.
--- client/tests/kvm_runtest_2/kvm_install.py | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
client/tests/kvm_runtest_2/kvm_install.py +1 -0
@@ -79,6 +79,7 @@ def run_kvm_install(test, params, env): # install from custom script elif install_mode == "custom": + os.chdir(test.bindir) install_script = params.get("install_script") script = os.path.join(test.bindir,install_script) if not install_script:
Signature · 1 line
1.5.5.6
PATCH 1/1 Check exit status of custom install script and fail if script failed.
--- client/tests/kvm_runtest_2/kvm_install.py | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
client/tests/kvm_runtest_2/kvm_install.py +6 -1
@@ -90,7 +90,12 @@ def run_kvm_install(test, params, env): kvm_log.info("Adding KVM_INSTALL_%s to Environment" % (k)) os.putenv("KVM_INSTALL_%s" % (k), str(params[k])) kvm_log.info("Running " + script + " to install kvm") - os.system("cd %s; %s" % (test.bindir, script)) + install_result = os.system("cd %s; %s" % (test.bindir, script)) + if os.WEXITSTATUS(install_result) != 0: + message = "Custom Script encountered an error" + kvm_log.error(message) + raise error.TestError, message + kvm_log.info("Completed %s" % (script)) # invalid installation mode
Signature · 1 line
1.5.5.6
Re: [PATCH][KVM-AUTOTEST] Check exit status of custom install script and fail if script failed.
Quoted 11 lines · Mike Burns
Signed-off-by Mike Burns <[email protected]>--- client/tests/kvm_runtest_2/kvm_install.py | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)client/tests/kvm_runtest_2/kvm_install.py +0
-0@@ -90,7 +90,12 @@ def run_kvm_install(test, params, env): kvm_log.info("Adding KVM_INSTALL_%s to Environment" % (k))
client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env): · line 99
Quoted 10 lines
client/tests/kvm_runtest_2/kvm_install.py +6
-1os.putenv("KVM_INSTALL_%s" % (k), str(params[k])) kvm_log.info("Running " + script + " to install kvm") - os.system("cd %s; %s" % (test.bindir, script)) + install_result = os.system("cd %s; %s" % (test.bindir, script)) + if os.WEXITSTATUS(install_result) != 0: + message = "Custom Script encountered an error" + kvm_log.error(message) + raise error.TestError, message +
How about a helper that does os.system() (or rather, commands.getstatusoutput()) and throws an exception on failure? I imagine it could be used in many places.
Oh and "Custom script encountered an error" is unfriendly. Mention the command line and the actual output.
Signature · 1 line
error compiling committee.c: too many arguments to function
Re: [PATCH][KVM-AUTOTEST] Check exit status of custom install script and fail if script failed.
Quoted 18 lines · Avi Kivity
Quoted 17 lines · Mike Burns
Signed-off-by Mike Burns <[email protected]>--- client/tests/kvm_runtest_2/kvm_install.py | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)client/tests/kvm_runtest_2/kvm_install.py +3
-1@@ -90,7 +90,12 @@ def run_kvm_install(test, params, env): kvm_log.info("Adding KVM_INSTALL_%s to Environment" % (k)) os.putenv("KVM_INSTALL_%s" % (k), str(params[k])) kvm_log.info("Running " + script + " to install kvm") - os.system("cd %s; %s" % (test.bindir, script)) + install_result = os.system("cd %s; %s" % (test.bindir, script)) + if os.WEXITSTATUS(install_result) != 0: + message = "Custom Script encountered an error"
Quoted 8 lines
client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env): · line 100
Quoted 4 lines
client/tests/kvm_runtest_2/kvm_install.py +3
-0+ kvm_log.error(message) + raise error.TestError, message +How about a helper that does
os.system()(or rather,commands.getstatusoutput()) and throws an exception on failure? I imagine it could be used in many places.
utils.system() does that. If we have exit code != 0, it throws an error.CmdError exception.
Signature · 3 lines
Lucas Meneghel Rodrigues Software Engineer (QE) Red Hat - Emerging Technologies
Re: [PATCH][KVM-AUTOTEST] Check exit status of custom install script and fail if script failed.
Quoted 29 lines · Lucas Meneghel Rodrigues
Quoted 17 lines · Avi Kivity
Quoted 15 lines · Mike Burns
Signed-off-by Mike Burns <[email protected]>--- client/tests/kvm_runtest_2/kvm_install.py | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)client/tests/kvm_runtest_2/kvm_install.py +1
-1@@ -90,7 +90,12 @@ def run_kvm_install(test, params, env): kvm_log.info("Adding KVM_INSTALL_%s to Environment" % (k)) os.putenv("KVM_INSTALL_%s" % (k), str(params[k])) kvm_log.info("Running " + script + " to install kvm") - os.system("cd %s; %s" % (test.bindir, script)) + install_result = os.system("cd %s; %s" % (test.bindir, script))Quoted 9 lines
client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env):
Quoted 7 lines
client/tests/kvm_runtest_2/kvm_install.py +5
-0+ if os.WEXITSTATUS(install_result) != 0: + message = "Custom Script encountered an error" + kvm_log.error(message) + raise error.TestError, message +How about a helper that does
os.system()(or rather,commands.getstatusoutput()) and throws an exception on failure? I imagine it could be used in many places.
Quoted 3 lines
utils.system()does that. If we have exit code != 0, it throws an error.CmdError exception.
Well let's use it then. Every time I see 'raise' used I'm going to complain, so it will be a lot more efficient as well as smaller code.
Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
Re: [PATCH][KVM-AUTOTEST] Check exit status of custom install script and fail if script failed.
Quoted 33 lines · Avi Kivity
Quoted 32 lines · Lucas Meneghel Rodrigues
Quoted 29 lines · Avi Kivity
Quoted 13 lines · Mike Burns
Signed-off-by Mike Burns <[email protected]>--- client/tests/kvm_runtest_2/kvm_install.py | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)client/tests/kvm_runtest_2/kvm_install.py +0
-0@@ -90,7 +90,12 @@ def run_kvm_install(test, params, env): kvm_log.info("Adding KVM_INSTALL_%s to Environment" % (k)) os.putenv("KVM_INSTALL_%s" % (k), str(params[k]))client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env): · line 100
Quoted 10 lines
client/tests/kvm_runtest_2/kvm_install.py +6
-1kvm_log.info("Running " + script + " to install kvm") - os.system("cd %s; %s" % (test.bindir, script)) + install_result = os.system("cd %s; %s" % (test.bindir, script)) + if os.WEXITSTATUS(install_result) != 0: + message = "Custom Script encountered an error" + kvm_log.error(message) + raise error.TestError, message +How about a helper that does
os.system()(or rather,commands.getstatusoutput()) and throws an exception on failure? I imagine it could be used in many places.
Quoted 7 lines
Quoted 3 lines
utils.system()does that. If we have exit code != 0, it throws an error.CmdError exception.Well let's use it then. Every time I see 'raise' used I'm going to complain, so it will be a lot more efficient as well as smaller code.
Agreed. I'll rework this and my other patches and get them re-posted in the next day or two.
Mike
Quoted 15 lines · Mike Burns
If you are using custom install and load_modules=yes, then autotest needs to change to the test.bindir so that it looks for kernel modules in the right place.
Signed-off-by Mike Burns <[email protected]>--- client/tests/kvm_runtest_2/kvm_install.py | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)client/tests/kvm_runtest_2/kvm_install.py +0
-0
client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env): · line 85
Quoted 7 lines
client/tests/kvm_runtest_2/kvm_install.py +1
-0@@ -79,6 +79,7 @@ def run_kvm_install(test, params, env): # install from custom script elif install_mode == "custom": + os.chdir(test.bindir) install_script = params.get("install_script") script = os.path.join(test.bindir,install_script) if not install_script:
Don't you need to chdir back afterwards?
Opportunity for a with statement.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 29 lines · Avi Kivity
Quoted 18 lines · Mike Burns
If you are using custom install and load_modules=yes, then autotest needs to
change to the test.bindir so that it looks for kernel modules in the right
place.Signed-off-by Mike Burns <[email protected]>--- client/tests/kvm_runtest_2/kvm_install.py | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)client/tests/kvm_runtest_2/kvm_install.py +0
-0client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env): · line 85
Quoted 7 lines
client/tests/kvm_runtest_2/kvm_install.py +1
-0@@ -79,6 +79,7 @@ def run_kvm_install(test, params, env): # install from custom script elif install_mode == "custom": + os.chdir(test.bindir) install_script = params.get("install_script") script = os.path.join(test.bindir,install_script) if not install_script:Don't you need to chdir back afterwards?
Quoted 2 lines
Opportunity for a with statement.
No, the custom install option essentially is replacing the call to __install_kvm which does a chdir and doesn't ever revert back to the original directory. Either this is handled somewhere outside of the kvm_install.py script or it is not necessary.
Mike