Chromium Code Reviews| Index: prebuilt_unittest.py |
| diff --git a/prebuilt_unittest.py b/prebuilt_unittest.py |
| index d3291333f083b4d4e50d9c82f07a64413d6a7b52..ef5943da6bc102ae0b61fc0f64b9f968475d6dbf 100755 |
| --- a/prebuilt_unittest.py |
| +++ b/prebuilt_unittest.py |
| @@ -195,42 +195,67 @@ 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') |
| + _BINHOST_BASE_DIR = 'src/overlays' |
| + # 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 = ('%(fake_path)s/private-overlays/chromeos-overlay\n' |
| + '%(fake_path)s/src/overlays/overlay-x86-generic\n' |
|
sosa
2011/01/19 21:51:15
You shouldn't need to indent here
scottz
2011/01/19 22:11:06
I renamed the variable and forgot to re-align :) t
|
| + % {'fake_path': fake_path}) |
| + x86_cmd = './cros_overlay_list --board x86-generic' |
| + x86_expected_path = os.path.join(fake_path, _BINHOST_BASE_DIR, |
|
sosa
2011/01/19 21:51:15
Could have better reuse of paths from before here
scottz
2011/01/19 22:11:06
I knew that was coming :)
Done.
|
| + 'overlay-x86-generic', 'prebuilt.conf') |
| + # Mock output from cros_overlay_list |
| + tegra2_out = ('%(fake_path)s/src/private-overlays/chromeos-overlay\n' |
| + '%(fake_path)s/src/overlays/overlay-tegra2\n' |
| + '%(fake_path)s/src/overlays/overlay-variant-tegra2-seaboard\n' |
| + '%(fake_path)s/src/private-overlays/overlay-tegra2-private\n' |
| + '%(fake_path)s/src/private-overlays/' |
| + 'overlay-variant-tegra2-seaboard-private\n' |
| + % {'fake_path': fake_path}) |
| + tegra2_cmd = './cros_overlay_list --board tegra2 --variant seaboard' |
| + tegra2_expected_path = os.path.join( |
| + fake_path, prebuilt._PRIVATE_OVERLAY_DIR, |
| + 'overlay-variant-tegra2-seaboard-private', 'prebuilt.conf') |
| + |
| + |
| + targets = {'x86-generic': (x86_cmd, x86_out, x86_expected_path), |
|
sosa
2011/01/19 21:51:15
May wanna consider using a dict of dicts to make i
scottz
2011/01/19 22:11:06
I like it
|
| + 'tegra2_seaboard': (tegra2_cmd, tegra2_out, 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[1] |
| + prebuilt.cros_build_lib.RunCommand(expected_results[0].split(), |
| + redirect_stdout=True, |
| + cwd=script_path).AndReturn( |
|
sosa
2011/01/19 21:51:15
fix indentation
scottz
2011/01/19 22:11:06
Done.
|
| + cmd_result_obj) |
| + |
| self.mox.ReplayAll() |
| - |
| for target in targets: |
| - self.assertEqual(prebuilt.DeterminePrebuiltConfFile(target), |
| - targets[target]) |
| + self.assertEqual( |
| + prebuilt.DeterminePrebuiltConfFile(fake_path, target), |
| + targets[target][2]) |
| 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): |