Skip to contentSkip to conversation

Have Custom install chdir to test.bindir

PATCH In review Mike Burns 3 participants 8 messages May 20, 2009 – Jun 1, 2009 KVM

lore
Share & tools
lore

Mike Burns

author
#0 lore raw

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
index d1aceb2..ebd8b7d 100755
@@ -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
author
#1 lore raw

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
index ebd8b7d..392ef0c 100755
@@ -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
#2 lore raw

Re: [PATCH][KVM-AUTOTEST] Check exit status of custom install script and fail if script failed.

Quoted 11 lines · Mike Burns
---
 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
index ebd8b7d..392ef0c 100755
@@ -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 -1
           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
+
 

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
#3 lore raw

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
---
 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
index ebd8b7d..392ef0c 100755
@@ -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
#4 lore raw

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
---
 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
index ebd8b7d..392ef0c 100755
@@ -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.
author
#5 lore raw

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
---
 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
index ebd8b7d..392ef0c 100755
@@ -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 -1
     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.

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

#6 lore raw
In reply to Mike Burns
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.

---
 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
index d1aceb2..ebd8b7d 100755

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
author
#7 lore raw
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.

---
 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
index d1aceb2..ebd8b7d 100755

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?

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