diff mbox

KVM test: Make it possible to configure preserve_srcdir

Message ID 1310957058-32095-1-git-send-email-lmr@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lucas Meneghel Rodrigues July 18, 2011, 2:44 a.m. UTC
The test base class attribute preserve_srcdir controls
whether the source directory is erased or not at the
beginning of a new test. It defaults to False for
several reasons. However, developers wanting to try
kvm_autotest on their machines might like to keep
the sources between tests, so it's not necessary to
re-fetch the code over and over.

So, make this attribute configurable by adding an
initialize() method to the kvm test, that will set
preserve_srcdir according to the test config value
of 'preserve_srcdir', not surprisingly. Also, defaults
this variable to 'yes'. People wanting to set up automated
testing environments (server) will probably want to change
this value to 'no', but at least the case 'developer
using autotest' scenario is covered with sensible
defaults.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
 client/tests/kvm/build.cfg.sample     |    2 ++
 client/tests/kvm/kvm.py               |    8 ++++++++
 client/tests/kvm/unittests.cfg.sample |    2 ++
 3 files changed, 12 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/client/tests/kvm/build.cfg.sample b/client/tests/kvm/build.cfg.sample
index 0bccd65..d4aea95 100644
--- a/client/tests/kvm/build.cfg.sample
+++ b/client/tests/kvm/build.cfg.sample
@@ -16,6 +16,8 @@  variants:
         load_modules = no
         # Save the results of this build on test.resultsdir?
         save_results = no
+        # Preserve the source code directory between tests?
+        preserve_srcdir = yes
         variants:
             - localtar:
                 install_mode = localtar
diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py
index c69ad46..5f9632f 100644
--- a/client/tests/kvm/kvm.py
+++ b/client/tests/kvm/kvm.py
@@ -23,6 +23,14 @@  class kvm(test.test):
     version = 1
     env_version = 1
 
+
+    def initialize(self, params):
+        # Change the value of the preserve_srcdir attribute according to
+        # the value present on the configuration file (defaults to yes)
+        if params.get("preserve_srcdir", "yes") == "yes":
+            self.preserve_srcdir = True
+
+
     def run_once(self, params):
         # Convert params to a Params object
         params = virt_utils.Params(params)
diff --git a/client/tests/kvm/unittests.cfg.sample b/client/tests/kvm/unittests.cfg.sample
index 16556b5..dfab508 100644
--- a/client/tests/kvm/unittests.cfg.sample
+++ b/client/tests/kvm/unittests.cfg.sample
@@ -46,6 +46,8 @@  variants:
         load_modules = no
         # Save the results of this build on test.resultsdir?
         save_results = no
+        # Preserve the source code directory between tests?
+        preserve_srcdir = yes
         variants:
             - git:
                 mode = git