KVM test: Build and unittest fixes

* Make sure the unittest dir will be actually linked
* Be more lenient with test errors in unittest

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@4688 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/tests/kvm/tests/build.py b/client/tests/kvm/tests/build.py
index a46bbf2..5a8f3b0 100644
--- a/client/tests/kvm/tests/build.py
+++ b/client/tests/kvm/tests/build.py
@@ -154,10 +154,9 @@
         os.symlink(kvm_qemu, qemu_path)
         os.symlink(kvm_qemu_img, qemu_img_path)
 
-    elif unittest:
+    if unittest:
         logging.debug("Linking unittest dir")
-        unittest_dir = os.path.dirname(unittest)
-        os.symlink(unittest_dir, qemu_unittest_path)
+        os.symlink(unittest, qemu_unittest_path)
 
 
 def save_build(build_dir, dest_dir):
@@ -530,7 +529,7 @@
                                                    os.path.basename(patch)))
                 utils.system('patch -p1 %s' % os.path.basename(patch))
 
-        unittest_cfg = os.path.join(userspace_srcdir, 'kvm', 'test',
+        unittest_cfg = os.path.join(userspace_srcdir, 'kvm', 'test', 'x86',
                                     'unittests.cfg')
 
         self.unittest_cfg = None
@@ -609,18 +608,23 @@
         utils.system('make clean')
         utils.system('make -j %s' % make_jobs)
 
+        self.unittest_prefix = None
         if self.unittest_cfg:
-            os.chdir(os.path.dirname(self.unittest_cfg))
+            os.chdir(os.path.dirname(os.path.dirname(self.unittest_cfg)))
             utils.system('./configure --prefix=%s' % self.prefix)
             utils.system('make')
             utils.system('make install')
+            self.unittest_prefix = os.path.join(self.prefix, 'share', 'qemu',
+                                                'tests')
 
 
     def _install(self):
         os.chdir(self.userspace_srcdir)
         utils.system('make install')
         create_symlinks(test_bindir=self.test_bindir, prefix=self.prefix,
-                        bin_list=None, unittest=self.unittest_cfg)
+                        bin_list=None,
+                        unittest=self.unittest_prefix)
+
 
     def _load_modules(self):
         if self.kmod_srcdir and self.modules_build_succeed:
diff --git a/client/tests/kvm/tests/unittest.py b/client/tests/kvm/tests/unittest.py
index 143f584..8be1f27 100644
--- a/client/tests/kvm/tests/unittest.py
+++ b/client/tests/kvm/tests/unittest.py
@@ -47,19 +47,26 @@
     timeout = int(params.get('unittest_timeout', 600))
 
     for t in test_list:
+        logging.info('Running %s', t)
+
         file = None
         if parser.has_option(t, 'file'):
             file = parser.get(t, 'file')
 
         if file is None:
-            raise error.TestError('Unittest config file %s has section %s but '
-                                  'no mandatory option file.' %
-                                  (unittest_cfg, t))
+            nfail += 1
+            tests_failed.append(t)
+            logging.error('Unittest config file %s has section %s but no '
+                          'mandatory option file' % (unittest_cfg, t))
+            continue
 
         if file not in unittest_list:
-            raise error.TestError('Unittest file %s referenced in config file '
-                                  '%s but was not find under the unittest dir' %
-                                  (file, unittest_cfg))
+            nfail += 1
+            tests_failed.append(t)
+            logging.error('Unittest file %s referenced in config file %s but '
+                          'was not find under the unittest dir' %
+                          (file, unittest_cfg))
+            continue
 
         smp = None
         if parser.has_option(t, 'smp'):
@@ -70,11 +77,7 @@
             extra_params = parser.get(t, 'extra_params')
 
         vm_name = params.get("main_vm")
-        testlog_path = os.path.join(test.debugdir, "%s.log" % t)
-
         params['kernel'] = os.path.join(unittest_dir, file)
-        logging.info('Running %s', t)
-
         testlog_path = os.path.join(test.debugdir, "%s.log" % t)
 
         try:
@@ -97,6 +100,7 @@
                     logging.error("Unit test %s failed", t)
             except Exception, e:
                 nfail += 1
+                tests_failed.append(t)
                 logging.error('Exception happened during %s: %s', t, str(e))
         finally:
             try: