All of lore.kernel.org
 help / color / mirror / Atom feed
* [KVM-AUTOTEST PATCH v2 1/4] KVM test: support -kernel and -append command line options
@ 2010-06-08 21:50 Michael Goldish
  2010-06-08 21:50 ` [KVM-AUTOTEST PATCH v2 2/4] KVM test: add boolean 'testdev' VM parameter for RHEL-6 style unit tests Michael Goldish
  2010-06-09 12:03 ` [KVM-AUTOTEST PATCH v2 1/4] KVM test: support -kernel and -append command line options Avi Kivity
  0 siblings, 2 replies; 6+ messages in thread
From: Michael Goldish @ 2010-06-08 21:50 UTC (permalink / raw)
  To: autotest, kvm

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_vm.py |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 94bacdf..f3c05f3 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -268,6 +268,12 @@ class VM:
         def add_pcidevice(help, host):
             return " -pcidevice host=%s" % host
 
+        def add_kernel(help, filename):
+            return " -kernel %s" % filename
+
+        def add_kernel_cmdline(help, cmdline):
+            return " -append %s" % cmdline
+
         # End of command line option wrappers
 
         if name is None: name = self.name
@@ -360,6 +366,15 @@ class VM:
             tftp = kvm_utils.get_path(root_dir, tftp)
             qemu_cmd += add_tftp(help, tftp)
 
+        kernel = params.get("kernel")
+        if kernel:
+            kernel = kvm_utils.get_path(root_dir, kernel)
+            qemu_cmd += add_kernel(help, kernel)
+
+        kernel_cmdline = params.get("kernel_cmdline")
+        if kernel_cmdline:
+            qemu_cmd += add_kernel_cmdline(help, kernel_cmdline)
+
         for redir_name in kvm_utils.get_sub_dict_names(params, "redirs"):
             redir_params = kvm_utils.get_sub_dict(params, redir_name)
             guest_port = int(redir_params.get("guest_port"))
-- 
1.5.4.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [KVM-AUTOTEST PATCH v2 2/4] KVM test: add boolean 'testdev' VM parameter for RHEL-6 style unit tests
  2010-06-08 21:50 [KVM-AUTOTEST PATCH v2 1/4] KVM test: support -kernel and -append command line options Michael Goldish
@ 2010-06-08 21:50 ` Michael Goldish
  2010-06-08 21:50   ` [KVM-AUTOTEST PATCH v2 3/4] KVM test: add wrapper for RHEL-6 style unittests Michael Goldish
  2010-06-09 12:03 ` [KVM-AUTOTEST PATCH v2 1/4] KVM test: support -kernel and -append command line options Avi Kivity
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Goldish @ 2010-06-08 21:50 UTC (permalink / raw)
  To: autotest, kvm; +Cc: Michael Goldish

Should be set to "yes" to enable testdev.

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_vm.py |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index f3c05f3..af45a81 100755
--- a/client/tests/kvm/kvm_vm.py
+++ b/client/tests/kvm/kvm_vm.py
@@ -118,12 +118,16 @@ class VM:
 
         # Find available monitor filename
         while True:
-            # The monitor filename should be unique
+            # A unique identifier for this VM
             self.instance = (time.strftime("%Y%m%d-%H%M%S-") +
                              kvm_utils.generate_random_string(4))
-            self.monitor_file_name = os.path.join("/tmp",
-                                                  "monitor-" + self.instance)
-            if not os.path.exists(self.monitor_file_name):
+            # Monitor
+            self.monitor_file_name = "/tmp/monitor-" + self.instance
+            # Test log for unit tests
+            self.testlog_file_name = "/tmp/testlog-" + self.instance
+            # Verify uniqueness
+            if True not in map(os.path.exists, [self.monitor_file_name,
+                                                self.testlog_file_name]):
                 break
 
 
@@ -274,6 +278,10 @@ class VM:
         def add_kernel_cmdline(help, cmdline):
             return " -append %s" % cmdline
 
+        def add_testdev(help, filename):
+            return (" -chardev file,id=testlog,path=%s"
+                    " -device testdev,chardev=testlog" % filename)
+
         # End of command line option wrappers
 
         if name is None: name = self.name
@@ -393,6 +401,9 @@ class VM:
         elif params.get("uuid"):
             qemu_cmd += add_uuid(help, params.get("uuid"))
 
+        if params.get("testdev") == "yes":
+            qemu_cmd += add_testdev(help, self.testlog_file_name)
+
         # If the PCI assignment step went OK, add each one of the PCI assigned
         # devices to the qemu command line.
         if self.pci_assignable:
@@ -728,10 +739,11 @@ class VM:
                 self.pci_assignable.release_devs()
             if self.process:
                 self.process.close()
-            try:
-                os.unlink(self.monitor_file_name)
-            except OSError:
-                pass
+            for f in [self.monitor_file_name, self.testlog_file_name]:
+                try:
+                    os.unlink(f)
+                except OSError:
+                    pass
 
 
     def is_alive(self):
-- 
1.5.4.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [KVM-AUTOTEST PATCH v2 3/4] KVM test: add wrapper for RHEL-6 style unittests
  2010-06-08 21:50 ` [KVM-AUTOTEST PATCH v2 2/4] KVM test: add boolean 'testdev' VM parameter for RHEL-6 style unit tests Michael Goldish
@ 2010-06-08 21:50   ` Michael Goldish
  2010-06-08 21:50     ` [KVM-AUTOTEST PATCH v2 4/4] KVM test: add sample RHEL-6 style unittest config file Michael Goldish
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Goldish @ 2010-06-08 21:50 UTC (permalink / raw)
  To: autotest, kvm; +Cc: Michael Goldish

Based on Naphtali Sprei's patches.

Changes from v1:
- Determine success/failure by exit status instead of output
- Restructure loop so that vm.is_dead() is called less often
- Copy test log to debugdir/unittest.log
- Change parameters passed to wait_for()

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/tests/unittest.py |   65 ++++++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/tests/unittest.py

diff --git a/client/tests/kvm/tests/unittest.py b/client/tests/kvm/tests/unittest.py
new file mode 100644
index 0000000..4570096
--- /dev/null
+++ b/client/tests/kvm/tests/unittest.py
@@ -0,0 +1,65 @@
+import logging, time, os, shutil
+from autotest_lib.client.common_lib import error
+import kvm_subprocess, kvm_test_utils, kvm_utils
+
+
+def run_unittest(test, params, env):
+    """
+    KVM RHEL-6 style unit test:
+    1) Resume a stopped VM
+    2) Wait for VM to terminate
+    3) Make sure qemu's exit status is 0
+
+    @param test: kvm test object
+    @param params: Dictionary with the test parameters
+    @param env: Dictionary with test environment
+    """
+    # Get VM
+    vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
+    # Resume VM if stopped
+    vm.send_monitor_cmd("cont")
+
+    timeout = float(params.get("unittest_timeout", 60))
+
+    try:
+        if params.get("log_output") == "yes":
+            # Log test output
+            f = open(vm.testlog_file_name)
+            logging.info("-------- Test output --------")
+            try:
+                end_time = time.time() + timeout
+                while time.time() < end_time:
+                    line = f.readline()
+                    if line:
+                        logging.info(line.rstrip())
+                    elif vm.is_dead():
+                        break
+                    else:
+                        time.sleep(1)
+                else:
+                    raise error.TestFail("Timeout elapsed (%ss)" % timeout)
+                # Make sure everything has been read and logged
+                while True:
+                    line = f.readline()
+                    if line:
+                        logging.info(line.rstrip())
+                    else:
+                        break
+            finally:
+                logging.info("-------- End of test output --------")
+                f.close()
+        else:
+            # Just wait for the VM to terminate
+            logging.info("Waiting for VM to terminate...")
+            if not kvm_utils.wait_for(vm.is_dead, timeout):
+                raise error.TestFail("Timeout elapsed (%ss)" % timeout)
+    finally:
+        # Copy test log to debugdir/unittest.log
+        testlog_path = os.path.join(test.debugdir, "unittest.log")
+        shutil.copy(vm.testlog_file_name, testlog_path)
+
+    # Check qemu's exit status
+    status = vm.process.get_status()
+    if status != 0:
+        raise error.TestFail("qemu exited with status %s (see unittest "
+                             "output at %s)" % (status, testlog_path))
-- 
1.5.4.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [KVM-AUTOTEST PATCH v2 4/4] KVM test: add sample RHEL-6 style unittest config file
  2010-06-08 21:50   ` [KVM-AUTOTEST PATCH v2 3/4] KVM test: add wrapper for RHEL-6 style unittests Michael Goldish
@ 2010-06-08 21:50     ` Michael Goldish
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Goldish @ 2010-06-08 21:50 UTC (permalink / raw)
  To: autotest, kvm

Based on Naphtali Sprei's patches.

Changes from v1:
- Remove reference_output parameter

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/unittests.cfg.sample |   83 +++++++++++++++++++++++++++++++++
 1 files changed, 83 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/unittests.cfg.sample

diff --git a/client/tests/kvm/unittests.cfg.sample b/client/tests/kvm/unittests.cfg.sample
new file mode 100644
index 0000000..f3b7fcd
--- /dev/null
+++ b/client/tests/kvm/unittests.cfg.sample
@@ -0,0 +1,83 @@
+# Copy this file to tests_base.cfg and edit it.
+#
+# Define the objects we'll be using
+vms = vm1
+
+# Choose the main VM
+main_vm = vm1
+
+# Some preprocessor/postprocessor params
+start_vm = yes
+kill_vm = yes
+kill_vm_gracefully = no
+
+# Screendump specific stuff
+convert_ppm_files_to_png_on_error = yes
+#keep_ppm_files = yes
+#keep_ppm_files_on_error = yes
+take_regular_screendumps = yes
+keep_screendumps_on_error = yes
+screendump_delay = 5
+screendump_quality = 30
+screendump_temp_dir = /dev/shm
+
+# Some default VM params
+qemu_binary = qemu
+qemu_img_binary = qemu-img
+smp = 1
+mem = 512
+display = vnc
+
+# Default scheduler params
+used_cpus = 1
+used_mem = 512
+
+# NIC parameters
+run_tcpdump = no
+
+# Misc
+run_kvm_stat = yes
+
+
+# Tests
+variants:
+    # (This variant is defined only in order make all test names begin with 'unittest.')
+    - unittest:
+        type = unittest
+        unittest_timeout = 600
+        log_output = yes
+        testdev = yes
+        extra_params += " -S"
+
+        # All kernels are expected under unittests/
+        kernel = unittests/
+
+        variants:
+            - access:
+                kernel += access.flat
+            - apic:
+                kernel += apic.flat
+            - emulator:
+                kernel += emulator.flat
+            - hypercall:
+                kernel += hypercall.flat
+            - memtest1:
+                kernel += memtest1.flat
+            - msr:
+                kernel += msr.flat
+            - port80:
+                kernel += port80.flat
+            - realmode:
+                kernel += realmode.flat
+            - sieve:
+                kernel += sieve.flat
+            - simple:
+                kernel += simple.flat
+            - smptest:
+                kernel += smptest.flat
+            - stringio:
+                kernel += stringio.flat
+            - tsc:
+                kernel += tsc.flat
+            - vmexit:
+                kernel += vmexit.flat
-- 
1.5.4.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [KVM-AUTOTEST PATCH v2 1/4] KVM test: support -kernel and -append command line options
  2010-06-08 21:50 [KVM-AUTOTEST PATCH v2 1/4] KVM test: support -kernel and -append command line options Michael Goldish
  2010-06-08 21:50 ` [KVM-AUTOTEST PATCH v2 2/4] KVM test: add boolean 'testdev' VM parameter for RHEL-6 style unit tests Michael Goldish
@ 2010-06-09 12:03 ` Avi Kivity
  2010-06-09 15:25   ` Michael Goldish
  1 sibling, 1 reply; 6+ messages in thread
From: Avi Kivity @ 2010-06-09 12:03 UTC (permalink / raw)
  To: Michael Goldish; +Cc: autotest, kvm

On 06/09/2010 12:50 AM, Michael Goldish wrote:
> Signed-off-by: Michael Goldish<mgoldish@redhat.com>
> ---
>   client/tests/kvm/kvm_vm.py |   15 +++++++++++++++
>   1 files changed, 15 insertions(+), 0 deletions(-)
>
> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
> index 94bacdf..f3c05f3 100755
> --- a/client/tests/kvm/kvm_vm.py
> +++ b/client/tests/kvm/kvm_vm.py
> @@ -268,6 +268,12 @@ class VM:
>           def add_pcidevice(help, host):
>               return " -pcidevice host=%s" % host
>
> +        def add_kernel(help, filename):
> +            return " -kernel %s" % filename
> +
> +        def add_kernel_cmdline(help, cmdline):
> +            return " -append %s" % cmdline
> +
>    

Shell quoting is a good idea here.  Everywhere else too, in fact, but 
-append is very likely to contain spaces.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [KVM-AUTOTEST PATCH v2 1/4] KVM test: support -kernel and -append command line options
  2010-06-09 12:03 ` [KVM-AUTOTEST PATCH v2 1/4] KVM test: support -kernel and -append command line options Avi Kivity
@ 2010-06-09 15:25   ` Michael Goldish
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Goldish @ 2010-06-09 15:25 UTC (permalink / raw)
  To: Avi Kivity; +Cc: autotest, kvm

On 06/09/2010 03:03 PM, Avi Kivity wrote:
> On 06/09/2010 12:50 AM, Michael Goldish wrote:
>> Signed-off-by: Michael Goldish<mgoldish@redhat.com>
>> ---
>>   client/tests/kvm/kvm_vm.py |   15 +++++++++++++++
>>   1 files changed, 15 insertions(+), 0 deletions(-)
>>
>> diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
>> index 94bacdf..f3c05f3 100755
>> --- a/client/tests/kvm/kvm_vm.py
>> +++ b/client/tests/kvm/kvm_vm.py
>> @@ -268,6 +268,12 @@ class VM:
>>           def add_pcidevice(help, host):
>>               return " -pcidevice host=%s" % host
>>
>> +        def add_kernel(help, filename):
>> +            return " -kernel %s" % filename
>> +
>> +        def add_kernel_cmdline(help, cmdline):
>> +            return " -append %s" % cmdline
>> +
>>    
> 
> Shell quoting is a good idea here.  Everywhere else too, in fact, but
> -append is very likely to contain spaces.
> 

Thanks.  I'll fix that for all parameters in a new patch.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-06-09 15:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-08 21:50 [KVM-AUTOTEST PATCH v2 1/4] KVM test: support -kernel and -append command line options Michael Goldish
2010-06-08 21:50 ` [KVM-AUTOTEST PATCH v2 2/4] KVM test: add boolean 'testdev' VM parameter for RHEL-6 style unit tests Michael Goldish
2010-06-08 21:50   ` [KVM-AUTOTEST PATCH v2 3/4] KVM test: add wrapper for RHEL-6 style unittests Michael Goldish
2010-06-08 21:50     ` [KVM-AUTOTEST PATCH v2 4/4] KVM test: add sample RHEL-6 style unittest config file Michael Goldish
2010-06-09 12:03 ` [KVM-AUTOTEST PATCH v2 1/4] KVM test: support -kernel and -append command line options Avi Kivity
2010-06-09 15:25   ` Michael Goldish

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.