diff options
author | Dan Albert <danalbert@google.com> | 2015-11-17 13:47:16 -0800 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2015-11-17 13:47:16 -0800 |
commit | a14a4add9d8e72c10f68f50adde4d73c299f186f (patch) | |
tree | c19277787d3fdf604f54d73b571c0fc848ced12c /cbuildbot/run_tests_unittest.py | |
parent | f9a912f6cfbc0c8e9419cafb0c7b1698926dce5f (diff) | |
parent | 691026242b81aceac4805322e2a51cb5ccbb6766 (diff) | |
download | chromite-a14a4add9d8e72c10f68f50adde4d73c299f186f.tar.gz |
Merge to upstream 691026242b81aceac4805322e2a51cb5ccbb6766HEADndk-r11cndk-r11bndk-r11ndk-r11-releasemastermainbrillo-m10-releasebrillo-m10-dev
Diffstat (limited to 'cbuildbot/run_tests_unittest.py')
-rw-r--r-- | cbuildbot/run_tests_unittest.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cbuildbot/run_tests_unittest.py b/cbuildbot/run_tests_unittest.py index 443299946..1323909ea 100644 --- a/cbuildbot/run_tests_unittest.py +++ b/cbuildbot/run_tests_unittest.py @@ -56,6 +56,38 @@ class FindTestsTest(cros_test_lib.TempDirTestCase): self.assertEqual(list(found), []) +class SortTest(cros_test_lib.TempDirTestCase): + """Tests for the SortTests() func""" + + def SortTests(self, tests, **kwargs): + """Helper to set cache file to a local temp one""" + kwargs['timing_cache_file'] = os.path.join(self.tempdir, 'cache.json') + return run_tests.SortTests(tests, **kwargs) + + def testEmpty(self): + """Verify handling of empty test lists""" + self.SortTests([]) + self.SortTests([], jobs=100) + + def testSmallSet(self): + """Do nothing when number of tests is lower than number of jobs.""" + tests = ['small', 'test', 'list', 'is', 'ignored'] + ret = self.SortTests(tests, jobs=100) + self.assertEqual(tests, ret) + + def testOddSet(self): + """Verify we can sort odd number of tests.""" + tests = ['1', '2', '3'] + ret = self.SortTests(tests, jobs=1) + self.assertEqual(set(tests), set(ret)) + + def testEvenSet(self): + """Verify we can sort even number of tests.""" + tests = ['1', '2', '3', '4'] + ret = self.SortTests(tests, jobs=1) + self.assertEqual(set(tests), set(ret)) + + class MainTest(cros_test_lib.MockOutputTestCase): """Tests for the main() func""" |