diff options
author | craigdh@chromium.org <craigdh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-05 21:54:32 +0000 |
---|---|---|
committer | craigdh@chromium.org <craigdh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-05 21:54:32 +0000 |
commit | a8a3802628d4328a5d618a5376f408197c775a93 (patch) | |
tree | bb3b7962c98ea2894f84fddc4cce47cc864eea39 /build/android/pylib/base/shard_unittest.py | |
parent | a4c3a2dd814d6ced40d0d28392020df3bd3f2c1d (diff) | |
download | chromium_src-a8a3802628d4328a5d618a5376f408197c775a93.zip chromium_src-a8a3802628d4328a5d618a5376f408197c775a93.tar.gz chromium_src-a8a3802628d4328a5d618a5376f408197c775a93.tar.bz2 |
[Android] Switch instrumentation tests to the new shard/runner paradigm.
BUG=176325, 168889
TEST=build/android/run_instrumentation_tests.py
Review URL: https://codereview.chromium.org/12378048
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186266 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/android/pylib/base/shard_unittest.py')
-rw-r--r-- | build/android/pylib/base/shard_unittest.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/build/android/pylib/base/shard_unittest.py b/build/android/pylib/base/shard_unittest.py index 79aa5b2..e06d98d 100644 --- a/build/android/pylib/base/shard_unittest.py +++ b/build/android/pylib/base/shard_unittest.py @@ -25,8 +25,9 @@ class TestException(Exception): class MockRunner(object): """A mock TestRunner.""" - def __init__(self, device='0'): + def __init__(self, device='0', shard_index=0): self.device = device + self.shard_index = shard_index self.setups = 0 self.teardowns = 0 @@ -50,8 +51,8 @@ class MockRunnerFail(MockRunner): class MockRunnerFailTwice(MockRunner): - def __init__(self, device='0'): - super(MockRunnerFailTwice, self).__init__(device) + def __init__(self, device='0', shard_index=0): + super(MockRunnerFailTwice, self).__init__(device, shard_index) self._fails = 0 def RunTest(self, test): @@ -97,10 +98,16 @@ class TestFunctions(unittest.TestCase): def testSetUp(self): runners = [] - shard._SetUp(MockRunner, '0', runners) + counter = shard._ThreadSafeCounter() + shard._SetUp(MockRunner, '0', runners, counter) self.assertEqual(len(runners), 1) self.assertEqual(runners[0].setups, 1) + def testThreadSafeCounter(self): + counter = shard._ThreadSafeCounter() + for i in xrange(5): + self.assertEqual(counter.GetAndIncrement(), i) + class TestThreadGroupFunctions(unittest.TestCase): """Tests for shard._RunAllTests and shard._CreateRunners.""" @@ -111,6 +118,10 @@ class TestThreadGroupFunctions(unittest.TestCase): runners = shard._CreateRunners(MockRunner, ['0', '1']) for runner in runners: self.assertEqual(runner.setups, 1) + self.assertEqual(set([r.device for r in runners]), + set(['0', '1'])) + self.assertEqual(set([r.shard_index for r in runners]), + set([0, 1])) def testRun(self): runners = [MockRunner('0'), MockRunner('1')] |