Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Unified Diff: prebuilt_unittest.py

Issue 6348010: Update prebuilt to use cros_overlay_list as the definitive answer for which overlay to modify. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/crosutils@master
Patch Set: Updated unittests with respect to feedback provided Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « prebuilt.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: prebuilt_unittest.py
diff --git a/prebuilt_unittest.py b/prebuilt_unittest.py
index d3291333f083b4d4e50d9c82f07a64413d6a7b52..d41ba5693eff338b1dcf9e6176f2559b6198e2a8 100755
--- a/prebuilt_unittest.py
+++ b/prebuilt_unittest.py
@@ -195,42 +195,73 @@ class TestPrebuilt(unittest.TestCase):
files = {'test': '/uasd'}
self.assertEqual(prebuilt.RemoteUpload(files), set([('test', '/uasd')]))
+ def testDeterminePrebuiltConfHost(self):
+ """Test that the host prebuilt path comes back properly."""
+ expected_path = os.path.join(prebuilt._PREBUILT_MAKE_CONF['amd64'])
+ self.assertEqual(prebuilt.DeterminePrebuiltConfFile('fake_path', 'amd64'),
+ expected_path)
+
def testDeterminePrebuiltConf(self):
"""Test the different known variants of boards for proper path discovery."""
- targets = {'amd64': os.path.join(prebuilt._PREBUILT_MAKE_CONF['amd64']),
- 'x86-generic': os.path.join(prebuilt._BINHOST_BASE_DIR,
- 'overlay-x86-generic', 'prebuilt.conf'),
- 'arm-tegra2_vogue': os.path.join(
- prebuilt._BINHOST_BASE_DIR,
- 'overlay-variant-arm-tegra2-vogue', 'prebuilt.conf'),}
- for target in targets:
- self.assertEqual(prebuilt.DeterminePrebuiltConfFile(target),
- targets[target])
-
- def testPrivatePrebuiltConf(self):
- """Test that we get a different path for private prebuilts"""
- targets = {'amd64': os.path.join(prebuilt._PREBUILT_MAKE_CONF['amd64']),
- 'x86-generic': os.path.join(
- prebuilt._PRIVATE_OVERLAY_DIR, 'overlay-x86-generic',
- 'prebuilt.conf'),
- 'arm-tegra2_vogue': os.path.join(
- prebuilt._PRIVATE_OVERLAY_DIR,
- 'overlay-variant-arm-tegra2-vogue', 'prebuilt.conf'),}
-
- self.mox.StubOutWithMock(prebuilt.os.path, 'exists')
- # Add mocks for every target we check
- for mock_count in range(len(targets)):
- prebuilt.os.path.exists(prebuilt._PRIVATE_OVERLAY_DIR).AndReturn(True)
+ fake_path = '/b/cbuild'
+ script_path = os.path.join(fake_path, 'src/scripts/bin')
+ public_overlay_path = os.path.join(fake_path, 'src/overlays')
+ private_overlay_path = os.path.join(fake_path,
+ prebuilt._PRIVATE_OVERLAY_DIR)
+ path_dict = {'private_overlay_path': private_overlay_path,
+ 'public_overlay_path': public_overlay_path}
+ # format for targets
+ # board target key in dictionar
+ # Tuple containing cmd run, expected results as cmd obj, and expected output
+
+ # Mock output from cros_overlay_list
+ x86_out = ('%(private_overlay_path)s//chromeos-overlay\n'
sosa 2011/01/19 22:16:52 Dbl slash?
scottz 2011/01/19 22:21:24 Oh snap :) thanks On 2011/01/19 22:16:52, sosa wr
+ '%(public_overlay_path)s/overlay-x86-generic\n' % path_dict)
+
+ x86_cmd = './cros_overlay_list --board x86-generic'
+ x86_expected_path = os.path.join(public_overlay_path, 'overlay-x86-generic',
+ 'prebuilt.conf')
+ # Mock output from cros_overlay_list
+ tegra2_out = ('%(private_overlay_path)s/chromeos-overlay\n'
+ '%(public_overlay_path)s/overlay-tegra2\n'
+ '%(public_overlay_path)s/overlay-variant-tegra2-seaboard\n'
+ '%(private_overlay_path)s/overlay-tegra2-private\n'
+ '%(private_overlay_path)s/'
+ 'overlay-variant-tegra2-seaboard-private\n' % path_dict)
+ tegra2_cmd = './cros_overlay_list --board tegra2 --variant seaboard'
+ tegra2_expected_path = os.path.join(
+ private_overlay_path, 'overlay-variant-tegra2-seaboard-private',
+ 'prebuilt.conf')
+
+
+ targets = {'x86-generic': {'cmd': x86_cmd,
+ 'output': x86_out,
+ 'result': x86_expected_path},
+ 'tegra2_seaboard': {'cmd': tegra2_cmd,
+ 'output': tegra2_out,
+ 'result': tegra2_expected_path}
+ }
+
+ self.mox.StubOutWithMock(prebuilt.cros_build_lib, 'RunCommand')
+ for target, expected_results in targets.iteritems():
+ # create command object for output
+ cmd_result_obj = cros_build_lib.CommandResult()
+ cmd_result_obj.output = expected_results['output']
+ prebuilt.cros_build_lib.RunCommand(
+ expected_results['cmd'].split(), redirect_stdout=True,
+ cwd=script_path).AndReturn(cmd_result_obj)
+
self.mox.ReplayAll()
-
- for target in targets:
- self.assertEqual(prebuilt.DeterminePrebuiltConfFile(target),
- targets[target])
+ for target, expected_results in targets.iteritems():
+ self.assertEqual(
+ prebuilt.DeterminePrebuiltConfFile(fake_path, target),
+ expected_results['result'])
def testDeterminePrebuiltConfGarbage(self):
"""Ensure an exception is raised on bad input."""
self.assertRaises(prebuilt.UnknownBoardFormat,
- prebuilt.DeterminePrebuiltConfFile, 'asdfasdf')
+ prebuilt.DeterminePrebuiltConfFile,
+ 'fake_path', 'asdfasdf')
class TestPackagesFileFiltering(unittest.TestCase):
« no previous file with comments | « prebuilt.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698