Allow site_utils to override utils, for version control
Signed-off-by: Martin Bligh <[email protected]>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@2665 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/bin/job.py b/client/bin/job.py
index 45581ef..b1fda55 100755
--- a/client/bin/job.py
+++ b/client/bin/job.py
@@ -689,7 +689,8 @@
self.record("END ABORT", subdir, 'reboot', optional_fields=kernel)
raise error.JobError("reboot returned with the wrong kernel")
- self.record('GOOD', subdir, 'reboot.verify', expected_id)
+ self.record('GOOD', subdir, 'reboot.verify',
+ utils.running_os_full_version())
self.end_reboot(subdir, expected_id, patches)
diff --git a/client/bin/job_unittest.py b/client/bin/job_unittest.py
index 1f99548..69c96e7 100644
--- a/client/bin/job_unittest.py
+++ b/client/bin/job_unittest.py
@@ -279,6 +279,7 @@
self.job.setup_dirs.expect_call(results,
tmp).and_return((results, tmp))
kernel.preprocess_path.expect_call(path).and_return(path)
+ os.path.exists.expect_call(path).and_return(False)
self.job.pkgmgr.fetch_pkg.expect_call(path, packages_dir, repo_url='')
mykernel = kernel.rpm_kernel.expect_new(self.job, packages_dir,
results)
@@ -518,6 +519,9 @@
utils.read_one_line.expect_call("/proc/cmdline").and_return(
"blah more-blah root=lala IDENT=81234567 blah-again")
+ self.god.stub_function(utils, "running_os_full_version")
+ utils.running_os_full_version.expect_call().and_return("2.6.15-smp")
+
self.job.record.expect_call("GOOD", "sub", "reboot.verify",
"2.6.15-smp")
self.job._decrement_group_level.expect_call()
diff --git a/client/bin/net/net_utils.py b/client/bin/net/net_utils.py
index 4a7a566..c9343cf 100755
--- a/client/bin/net/net_utils.py
+++ b/client/bin/net/net_utils.py
@@ -5,7 +5,7 @@
import commands, os, re, socket, sys, time, struct
from autotest_lib.client.common_lib import error
-from autotest_lib.client.bin import utils
+import utils
TIMEOUT = 10 # Used for socket timeout and barrier timeout
diff --git a/client/bin/net/net_utils_unittest.py b/client/bin/net/net_utils_unittest.py
index 37d2eff..32a8cef 100755
--- a/client/bin/net/net_utils_unittest.py
+++ b/client/bin/net/net_utils_unittest.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
import unittest, os, socket, time, sys, struct
import common
-from autotest_lib.client.bin import utils
+import utils
from autotest_lib.client.bin.net import net_utils, net_utils_mock
from autotest_lib.client.common_lib.test_utils import mock
from autotest_lib.client.common_lib import error
diff --git a/client/bin/partition.py b/client/bin/partition.py
index 34b55e9..de14e2d 100755
--- a/client/bin/partition.py
+++ b/client/bin/partition.py
@@ -1,7 +1,7 @@
# Copyright Martin J. Bligh, Google, 2006-2008
import os, re, string, sys, fcntl
-from autotest_lib.client.bin import utils
+import utils
from autotest_lib.client.common_lib import error
diff --git a/client/bin/utils.py b/client/bin/utils.py
index 68a38c3..591273a 100755
--- a/client/bin/utils.py
+++ b/client/bin/utils.py
@@ -3,6 +3,12 @@
NOTE: this is a mixin library that pulls in functions from both here and
client/common_lib/utils.py (which are functions shared with the server code)
+
+It also pulls in site_utils.py, where you can override functions in here.
+(note the "from site_utils import *" at the END of this file)
+
+There's no really good way to do this, as this isn't a class we can do
+inheritance with, just a collection of static methods.
"""
import os, shutil, sys, signal, commands, pickle, glob, statvfs
import math, re, string, fnmatch
@@ -512,6 +518,11 @@
return version + '::' + timestamp
+def running_os_full_version():
+ (version, timestamp) = running_os_release()
+ return version
+
+
# much like find . -name 'pattern'
def locate(pattern, root=os.getcwd()):
for path, dirs, files in os.walk(root):
@@ -634,3 +645,4 @@
system("echo 3 > /proc/sys/vm/drop_caches", ignore_status=True)
+from autotest_lib.client.bin.site_utils import *