* [KVM-AUTOTEST PATCH 1/2] KVM-test: autoit: Generalize the variables in autoit.py
2010-06-18 9:27 [KVM-AUTOTEST PATCH 0/2] Make autoit wrapper support more guest scripts than just AutoIt Chen Cao
@ 2010-06-18 9:28 ` Chen Cao
2010-06-18 9:28 ` [KVM-AUTOTEST PATCH 2/2] KVM-test: rename autoit to guest_test and update the sample config file Chen Cao
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Chen Cao @ 2010-06-18 9:28 UTC (permalink / raw)
To: lmr, autotest; +Cc: kvm
The autoit.py wrapper can actually support guest scripts more than
AutoIt, so generalize the variables in it.
Signed-off-by: Chen Cao <kcao@redhat.com>
---
client/tests/kvm/tests/autoit.py | 27 +++++++++++++++------------
client/tests/kvm/tests_base.cfg.sample | 10 +++++-----
2 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/client/tests/kvm/tests/autoit.py b/client/tests/kvm/tests/autoit.py
index e3fa6f6..0373f38 100644
--- a/client/tests/kvm/tests/autoit.py
+++ b/client/tests/kvm/tests/autoit.py
@@ -5,10 +5,10 @@ import kvm_utils, kvm_test_utils
def run_autoit(test, params, env):
"""
- A wrapper for AutoIt scripts.
+ A wrapper for running customized tests in guests.
1) Log into a guest.
- 2) Run AutoIt script.
+ 2) Run script.
3) Wait for script execution to complete.
4) Pass/fail according to exit status of script.
@@ -30,12 +30,13 @@ def run_autoit(test, params, env):
logging.info("Starting script...")
# Collect test parameters
- binary = params.get("autoit_binary")
- script = params.get("autoit_script")
- autoit_entry = params.get("autoit_entry", "script.au3")
- script_params = params.get("autoit_script_params", "")
- timeout = float(params.get("autoit_script_timeout", 600))
+ interpreter = params.get("interpreter")
+ script = params.get("guest_script")
+ dst_rsc_path = params.get("dst_rsc_path", "script.au3")
+ script_params = params.get("script_params", "")
+ test_timeout = float(params.get("test_timeout", 600))
+ logging.debug("Starting preparing resouce files...")
# Download the script resource from a remote server, or
# prepare the script using rss?
if params.get("download") == "yes":
@@ -44,16 +45,16 @@ def run_autoit(test, params, env):
rsc_dir = os.path.basename(rsc_server)
dst_rsc_dir = params.get("dst_rsc_dir")
- # Change dir to dst_rsc_dir, and remove 'autoit' there,
+ # Change dir to dst_rsc_dir, and remove the guest script dir there
rm_cmd = "cd %s && (rmdir /s /q %s || del /s /q %s)" % \
(dst_rsc_dir, rsc_dir, rsc_dir)
- if session.get_command_status(rm_cmd, timeout=timeout) != 0:
+ if session.get_command_status(rm_cmd, timeout=test_timeout) != 0:
raise error.TestFail("Remove %s failed." % rsc_dir)
logging.debug("Clean directory succeeded.")
# then download the resource.
rsc_cmd = "cd %s && %s %s" %(dst_rsc_dir, download_cmd, rsc_server)
- if session.get_command_status(rsc_cmd, timeout=timeout) != 0:
+ if session.get_command_status(rsc_cmd, timeout=test_timeout) != 0:
raise error.TestFail("Download test resource failed.")
logging.info("Download resource finished.")
else:
@@ -70,12 +71,12 @@ def run_autoit(test, params, env):
internal_timeout=0)
file.close()
- command = "cmd /c %s %s %s" % (binary, autoit_entry, script_params)
+ command = "cmd /c %s %s %s" %(interpreter, dst_rsc_path, script_params)
logging.info("---------------- Script output ----------------")
status = session.get_command_status(command,
print_func=logging.info,
- timeout=timeout)
+ timeout=test_timeout)
logging.info("---------------- End of script output ----------------")
if status is None:
@@ -87,5 +88,7 @@ def run_autoit(test, params, env):
if reboot == "yes":
logging.debug("Rebooting guest after test ...")
session = kvm_test_utils.reboot(vm, session, timeout=login_timeout)
+
+ logging.debug("guest test PASSED.")
finally:
session.close()
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index fc4fb0b..5b0da6a 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -251,19 +251,19 @@ variants:
- autoit: install setup unattended_install.cdrom
type = autoit
login_timeout = 360
- autoit_binary = D:\AutoIt3.exe
- autoit_script_timeout = 600
- autoit_script_params =
+ interpreter = D:\AutoIt3.exe
+ test_timeout = 600
+ script_params =
reboot = yes
variants:
- notepad:
- autoit_script = autoit/notepad1.au3
+ guest_script = autoit/notepad1.au3
- stub:
download = yes
download_cmd = "git clone"
rsc_server = "git://the.resource.server/autoit"
dst_rsc_dir = "C:\"
- autoit_entry = "C:\autoit\stub\stub.au3"
+ dst_rsc_path = "C:\autoit\stub\stub.au3"
- iozone_windows: unattended_install.cdrom
type = iozone_windows
^ permalink raw reply related [flat|nested] 5+ messages in thread* [KVM-AUTOTEST PATCH 2/2] KVM-test: rename autoit to guest_test and update the sample config file
2010-06-18 9:27 [KVM-AUTOTEST PATCH 0/2] Make autoit wrapper support more guest scripts than just AutoIt Chen Cao
2010-06-18 9:28 ` [KVM-AUTOTEST PATCH 1/2] KVM-test: autoit: Generalize the variables in autoit.py Chen Cao
@ 2010-06-18 9:28 ` Chen Cao
2010-06-18 9:33 ` [KVM-AUTOTEST PATCH 2/2 diff-rename mode] " Chen Cao
2010-06-18 14:46 ` [KVM-AUTOTEST PATCH 0/2] Make autoit wrapper support more guest scripts than just AutoIt Lucas Meneghel Rodrigues
3 siblings, 0 replies; 5+ messages in thread
From: Chen Cao @ 2010-06-18 9:28 UTC (permalink / raw)
To: lmr, autotest; +Cc: kvm
Rename the autoit.py to guest_test.py.
Update the related tests structure in the sample config file
and add powershell script test demo.
Signed-off-by: Chen Cao <kcao@redhat.com>
---
client/tests/kvm/tests/autoit.py | 94 --------------------------------
client/tests/kvm/tests/guest_test.py | 94 ++++++++++++++++++++++++++++++++
client/tests/kvm/tests_base.cfg.sample | 33 +++++++----
3 files changed, 116 insertions(+), 105 deletions(-)
delete mode 100644 client/tests/kvm/tests/autoit.py
create mode 100644 client/tests/kvm/tests/guest_test.py
diff --git a/client/tests/kvm/tests/autoit.py b/client/tests/kvm/tests/autoit.py
deleted file mode 100644
index 0373f38..0000000
--- a/client/tests/kvm/tests/autoit.py
+++ /dev/null
@@ -1,94 +0,0 @@
-import os, logging
-from autotest_lib.client.common_lib import error
-import kvm_utils, kvm_test_utils
-
-
-def run_autoit(test, params, env):
- """
- A wrapper for running customized tests in guests.
-
- 1) Log into a guest.
- 2) Run script.
- 3) Wait for script execution to complete.
- 4) Pass/fail according to exit status of script.
-
- @param test: KVM test object.
- @param params: Dictionary with test parameters.
- @param env: Dictionary with the test environment.
- """
- login_timeout = int(params.get("login_timeout", 360))
- reboot = params.get("reboot", "no")
-
- vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
- session = kvm_test_utils.wait_for_login(vm, timeout=login_timeout)
-
- if reboot == "yes":
- logging.debug("Rebooting guest before test ...")
- session = kvm_test_utils.reboot(vm, session, timeout=login_timeout)
-
- try:
- logging.info("Starting script...")
-
- # Collect test parameters
- interpreter = params.get("interpreter")
- script = params.get("guest_script")
- dst_rsc_path = params.get("dst_rsc_path", "script.au3")
- script_params = params.get("script_params", "")
- test_timeout = float(params.get("test_timeout", 600))
-
- logging.debug("Starting preparing resouce files...")
- # Download the script resource from a remote server, or
- # prepare the script using rss?
- if params.get("download") == "yes":
- download_cmd = params.get("download_cmd")
- rsc_server = params.get("rsc_server")
- rsc_dir = os.path.basename(rsc_server)
- dst_rsc_dir = params.get("dst_rsc_dir")
-
- # Change dir to dst_rsc_dir, and remove the guest script dir there
- rm_cmd = "cd %s && (rmdir /s /q %s || del /s /q %s)" % \
- (dst_rsc_dir, rsc_dir, rsc_dir)
- if session.get_command_status(rm_cmd, timeout=test_timeout) != 0:
- raise error.TestFail("Remove %s failed." % rsc_dir)
- logging.debug("Clean directory succeeded.")
-
- # then download the resource.
- rsc_cmd = "cd %s && %s %s" %(dst_rsc_dir, download_cmd, rsc_server)
- if session.get_command_status(rsc_cmd, timeout=test_timeout) != 0:
- raise error.TestFail("Download test resource failed.")
- logging.info("Download resource finished.")
- else:
- # Send AutoIt script to guest (this code will be replaced once we
- # support sending files to Windows guests)
- session.get_command_output("del script.au3", internal_timeout=0)
- file = open(kvm_utils.get_path(test.bindir, script))
- for line in file.readlines():
- # Insert a '^' before each character
- line = "".join("^" + c for c in line.rstrip())
- if line:
- # Append line to the file
- session.get_command_output("echo %s>>script.au3" % line,
- internal_timeout=0)
- file.close()
-
- command = "cmd /c %s %s %s" %(interpreter, dst_rsc_path, script_params)
-
- logging.info("---------------- Script output ----------------")
- status = session.get_command_status(command,
- print_func=logging.info,
- timeout=test_timeout)
- logging.info("---------------- End of script output ----------------")
-
- if status is None:
- raise error.TestFail("Timeout expired before script execution "
- "completed (or something weird happened)")
- if status != 0:
- raise error.TestFail("Script execution failed")
-
- if reboot == "yes":
- logging.debug("Rebooting guest after test ...")
- session = kvm_test_utils.reboot(vm, session, timeout=login_timeout)
-
- logging.debug("guest test PASSED.")
- finally:
- session.close()
diff --git a/client/tests/kvm/tests/guest_test.py b/client/tests/kvm/tests/guest_test.py
new file mode 100644
index 0000000..2ba3d02
--- /dev/null
+++ b/client/tests/kvm/tests/guest_test.py
@@ -0,0 +1,94 @@
+import os, logging
+from autotest_lib.client.common_lib import error
+import kvm_utils, kvm_test_utils
+
+
+def run_guest_test(test, params, env):
+ """
+ A wrapper for running customized tests in guests.
+
+ 1) Log into a guest.
+ 2) Run script.
+ 3) Wait for script execution to complete.
+ 4) Pass/fail according to exit status of script.
+
+ @param test: KVM test object.
+ @param params: Dictionary with test parameters.
+ @param env: Dictionary with the test environment.
+ """
+ login_timeout = int(params.get("login_timeout", 360))
+ reboot = params.get("reboot", "no")
+
+ vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
+ session = kvm_test_utils.wait_for_login(vm, timeout=login_timeout)
+
+ if reboot == "yes":
+ logging.debug("Rebooting guest before test ...")
+ session = kvm_test_utils.reboot(vm, session, timeout=login_timeout)
+
+ try:
+ logging.info("Starting script...")
+
+ # Collect test parameters
+ interpreter = params.get("interpreter")
+ script = params.get("guest_script")
+ dst_rsc_path = params.get("dst_rsc_path", "script.au3")
+ script_params = params.get("script_params", "")
+ test_timeout = float(params.get("test_timeout", 600))
+
+ logging.debug("Starting preparing resouce files...")
+ # Download the script resource from a remote server, or
+ # prepare the script using rss?
+ if params.get("download") == "yes":
+ download_cmd = params.get("download_cmd")
+ rsc_server = params.get("rsc_server")
+ rsc_dir = os.path.basename(rsc_server)
+ dst_rsc_dir = params.get("dst_rsc_dir")
+
+ # Change dir to dst_rsc_dir, and remove the guest script dir there
+ rm_cmd = "cd %s && (rmdir /s /q %s || del /s /q %s)" % \
+ (dst_rsc_dir, rsc_dir, rsc_dir)
+ if session.get_command_status(rm_cmd, timeout=test_timeout) != 0:
+ raise error.TestFail("Remove %s failed." % rsc_dir)
+ logging.debug("Clean directory succeeded.")
+
+ # then download the resource.
+ rsc_cmd = "cd %s && %s %s" %(dst_rsc_dir, download_cmd, rsc_server)
+ if session.get_command_status(rsc_cmd, timeout=test_timeout) != 0:
+ raise error.TestFail("Download test resource failed.")
+ logging.info("Download resource finished.")
+ else:
+ # Send AutoIt script to guest (this code will be replaced once we
+ # support sending files to Windows guests)
+ session.get_command_output("del script.au3", internal_timeout=0)
+ file = open(kvm_utils.get_path(test.bindir, script))
+ for line in file.readlines():
+ # Insert a '^' before each character
+ line = "".join("^" + c for c in line.rstrip())
+ if line:
+ # Append line to the file
+ session.get_command_output("echo %s>>script.au3" % line,
+ internal_timeout=0)
+ file.close()
+
+ command = "cmd /c %s %s %s" %(interpreter, dst_rsc_path, script_params)
+
+ logging.info("---------------- Script output ----------------")
+ status = session.get_command_status(command,
+ print_func=logging.info,
+ timeout=test_timeout)
+ logging.info("---------------- End of script output ----------------")
+
+ if status is None:
+ raise error.TestFail("Timeout expired before script execution "
+ "completed (or something weird happened)")
+ if status != 0:
+ raise error.TestFail("Script execution failed")
+
+ if reboot == "yes":
+ logging.debug("Rebooting guest after test ...")
+ session = kvm_test_utils.reboot(vm, session, timeout=login_timeout)
+
+ logging.debug("guest test PASSED.")
+ finally:
+ session.close()
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index 5b0da6a..105c67a 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -248,22 +248,33 @@ variants:
used_cpus = 5
used_mem = 2560
- - autoit: install setup unattended_install.cdrom
- type = autoit
+ - guest_test: install setup unattended_install.cdrom
+ type = guest_test
login_timeout = 360
- interpreter = D:\AutoIt3.exe
test_timeout = 600
script_params =
reboot = yes
variants:
- - notepad:
- guest_script = autoit/notepad1.au3
- - stub:
- download = yes
- download_cmd = "git clone"
- rsc_server = "git://the.resource.server/autoit"
- dst_rsc_dir = "C:\"
- dst_rsc_path = "C:\autoit\stub\stub.au3"
+ - autoit:
+ interpreter = D:\AutoIt3.exe
+ variants:
+ - notepad:
+ guest_script = autoit/notepad1.au3
+ - stub:
+ download = yes
+ download_cmd = "git clone"
+ rsc_server = "git://the.resource.server/autoit"
+ dst_rsc_dir = "C:\"
+ dst_rsc_path = "C:\autoit\stub\stub.au3"
+ - powershell:
+ interpreter = "powershell.exe -File"
+ variants:
+ - stub:
+ download = yes
+ download_cmd = "git clone"
+ rsc_server = "git://the.resource.server/powershell"
+ dst_rsc_dir = "C:\"
+ dst_rsc_path = "C:\powershell\stub\stub.ps1"
- iozone_windows: unattended_install.cdrom
type = iozone_windows
^ permalink raw reply related [flat|nested] 5+ messages in thread* [KVM-AUTOTEST PATCH 2/2 diff-rename mode] KVM-test: rename autoit to guest_test and update the sample config file
2010-06-18 9:27 [KVM-AUTOTEST PATCH 0/2] Make autoit wrapper support more guest scripts than just AutoIt Chen Cao
2010-06-18 9:28 ` [KVM-AUTOTEST PATCH 1/2] KVM-test: autoit: Generalize the variables in autoit.py Chen Cao
2010-06-18 9:28 ` [KVM-AUTOTEST PATCH 2/2] KVM-test: rename autoit to guest_test and update the sample config file Chen Cao
@ 2010-06-18 9:33 ` Chen Cao
2010-06-18 14:46 ` [KVM-AUTOTEST PATCH 0/2] Make autoit wrapper support more guest scripts than just AutoIt Lucas Meneghel Rodrigues
3 siblings, 0 replies; 5+ messages in thread
From: Chen Cao @ 2010-06-18 9:33 UTC (permalink / raw)
To: lmr, autotest; +Cc: kvm
Rename the autoit.py to guest_test.py.
Update the related tests structure in the sample config file
and add powershell script test demo.
Signed-off-by: Chen Cao <kcao@redhat.com>
---
.../tests/kvm/tests/{autoit.py => guest_test.py} | 2 +-
client/tests/kvm/tests_base.cfg.sample | 33 +++++++++++++------
2 files changed, 23 insertions(+), 12 deletions(-)
rename client/tests/kvm/tests/{autoit.py => guest_test.py} (99%)
diff --git a/client/tests/kvm/tests/autoit.py b/client/tests/kvm/tests/guest_test.py
similarity index 99%
rename from client/tests/kvm/tests/autoit.py
rename to client/tests/kvm/tests/guest_test.py
index 0373f38..2ba3d02 100644
--- a/client/tests/kvm/tests/autoit.py
+++ b/client/tests/kvm/tests/guest_test.py
@@ -3,7 +3,7 @@ from autotest_lib.client.common_lib import error
import kvm_utils, kvm_test_utils
-def run_autoit(test, params, env):
+def run_guest_test(test, params, env):
"""
A wrapper for running customized tests in guests.
diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample
index 5b0da6a..105c67a 100644
--- a/client/tests/kvm/tests_base.cfg.sample
+++ b/client/tests/kvm/tests_base.cfg.sample
@@ -248,22 +248,33 @@ variants:
used_cpus = 5
used_mem = 2560
- - autoit: install setup unattended_install.cdrom
- type = autoit
+ - guest_test: install setup unattended_install.cdrom
+ type = guest_test
login_timeout = 360
- interpreter = D:\AutoIt3.exe
test_timeout = 600
script_params =
reboot = yes
variants:
- - notepad:
- guest_script = autoit/notepad1.au3
- - stub:
- download = yes
- download_cmd = "git clone"
- rsc_server = "git://the.resource.server/autoit"
- dst_rsc_dir = "C:\"
- dst_rsc_path = "C:\autoit\stub\stub.au3"
+ - autoit:
+ interpreter = D:\AutoIt3.exe
+ variants:
+ - notepad:
+ guest_script = autoit/notepad1.au3
+ - stub:
+ download = yes
+ download_cmd = "git clone"
+ rsc_server = "git://the.resource.server/autoit"
+ dst_rsc_dir = "C:\"
+ dst_rsc_path = "C:\autoit\stub\stub.au3"
+ - powershell:
+ interpreter = "powershell.exe -File"
+ variants:
+ - stub:
+ download = yes
+ download_cmd = "git clone"
+ rsc_server = "git://the.resource.server/powershell"
+ dst_rsc_dir = "C:\"
+ dst_rsc_path = "C:\powershell\stub\stub.ps1"
- iozone_windows: unattended_install.cdrom
type = iozone_windows
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [KVM-AUTOTEST PATCH 0/2] Make autoit wrapper support more guest scripts than just AutoIt
2010-06-18 9:27 [KVM-AUTOTEST PATCH 0/2] Make autoit wrapper support more guest scripts than just AutoIt Chen Cao
` (2 preceding siblings ...)
2010-06-18 9:33 ` [KVM-AUTOTEST PATCH 2/2 diff-rename mode] " Chen Cao
@ 2010-06-18 14:46 ` Lucas Meneghel Rodrigues
3 siblings, 0 replies; 5+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-06-18 14:46 UTC (permalink / raw)
To: Chen Cao; +Cc: autotest, kvm
On Fri, 2010-06-18 at 17:27 +0800, Chen Cao wrote:
> Just rename variables and the file, the wrapper itself can support other
> scripts already.
Ok Chen, looks good to me, patchset applied!
> ---
>
> Chen Cao (2):
> KVM-test: autoit: Generalize the variables in autoit.py
> KVM-test: rename autoit to guest_test and update the sample config file
>
>
> client/tests/kvm/tests/autoit.py | 91 -------------------------------
> client/tests/kvm/tests/guest_test.py | 94 ++++++++++++++++++++++++++++++++
> client/tests/kvm/tests_base.cfg.sample | 37 ++++++++-----
> 3 files changed, 118 insertions(+), 104 deletions(-)
> delete mode 100644 client/tests/kvm/tests/autoit.py
> create mode 100644 client/tests/kvm/tests/guest_test.py
>
^ permalink raw reply [flat|nested] 5+ messages in thread