cros_build_lib: new MachineDetails helper
The pushimage & gslock & signer files write out some details about the
system they're running on for the purpose of debugging. Unify all of
that in a new helper so as to standardize on the details we collect.
BUG=chromium:417035
TEST=`./cbuildbot/run_tests` passes
TEST=`./lib/paygen/gslock_unittest.py --network` passes
Change-Id: Id1a8373e813647788830431cca6ca6dce9d92872
Reviewed-on: https://chromium-review.googlesource.com/225645
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/pushimage_unittest.py b/scripts/pushimage_unittest.py
index 8a8cfe7..2927078 100755
--- a/scripts/pushimage_unittest.py
+++ b/scripts/pushimage_unittest.py
@@ -16,7 +16,6 @@
'..', '..'))
from chromite.lib import cros_build_lib
from chromite.lib import cros_test_lib
-from chromite.lib import git
from chromite.lib import gs
from chromite.lib import gs_unittest
from chromite.lib import osutils
@@ -122,8 +121,7 @@
def setUp(self):
# Minor optimization -- we call this for logging purposes in the main
# code, but don't really care about it for testing. It just slows us.
- self.PatchObject(git, 'RunGit',
- return_value=cros_build_lib.CommandResult(output='1234\n'))
+ self.PatchObject(cros_build_lib, 'MachineDetails', return_value='1234\n')
def testBasic(self):
"""Simple smoke test"""
@@ -145,24 +143,6 @@
self.assertRaises(ValueError, pushimage.MarkImageToBeSigned, self.ctx,
'', '', prio)
- def testTbsFile(self):
- """Make sure the tbs file we write has useful data"""
- WriteFile = osutils.WriteFile
- def _write_check(*args, **kwargs):
- # We can't mock every call, so do the actual write for most.
- WriteFile(*args, **kwargs)
-
- m = self.PatchObject(osutils, 'WriteFile')
- m.side_effect = _write_check
- pushimage.MarkImageToBeSigned(self.ctx, '', '', 50)
- # We assume the first call is the one we care about.
- self.assertTrue(m.called)
- content = m.call_args_list[0][0][1]
- self.assertIn('USER=', content)
- self.assertIn('HOSTNAME=', content)
- self.assertIn('GIT_REV=1234', content)
- self.assertIn('\n', content)
-
def testTbsUpload(self):
"""Make sure we actually try to upload the file"""
pushimage.MarkImageToBeSigned(self.ctx, '', '', 50)