Add a flag to update_version to request preserving srcdir.
Signed-off-by: Martin J. Bligh <mbligh@google.com>
Add a flag to update_version to request preserving srcdir,
and clean up the codeflow in there. Alter all callers to
pass the new flag (can't be optional param, due to the
var args).
Rationale is so that we can more easily use small tests
without a tarball, and diff submissions against the C
files become legible, etc.
Make aio_dio_bugs test use this new mechanism.
git-svn-id: http://test.kernel.org/svn/autotest/trunk@511 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/bin/autotest_utils.py b/client/bin/autotest_utils.py
index 1d480f6..4898c89 100755
--- a/client/bin/autotest_utils.py
+++ b/client/bin/autotest_utils.py
@@ -68,20 +68,27 @@
raise NameError, "extracting tarball produced no dir"
-def update_version(srcdir, new_version, install, *args, **dargs):
- """Make sure srcdir is version new_version
+def update_version(srcdir, preserve_srcdir, new_version, install, *args, **dargs):
+ """
+ Make sure srcdir is version new_version
- If not, delete it and install() the new version
+ If not, delete it and install() the new version.
+
+ In the preserve_srcdir case, we just check it's up to date,
+ and if not, we rerun install, without removing srcdir
"""
versionfile = srcdir + '/.version'
+ install_needed = True
+
if os.path.exists(srcdir):
if os.path.exists(versionfile):
old_version = pickle.load(open(versionfile, 'r'))
- if (old_version != new_version):
- system('rm -rf ' + srcdir)
- else:
+ if (old_version == new_version):
+ install_needed = False
+
+ if install_needed:
+ if not preserve_srcdir:
system('rm -rf ' + srcdir)
- if not os.path.exists(srcdir):
install(*args, **dargs)
if os.path.exists(srcdir):
pickle.dump(new_version, open(versionfile, 'w'))