Gaurav Shah | 298aa37 | 2014-01-31 09:27:24 -0800 | [diff] [blame] | 1 | # Copyright (c) 2014 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | """Unit tests for the cbuildbot program""" |
| 6 | |
Aviv Keshet | b7519e1 | 2016-10-04 00:50:00 -0700 | [diff] [blame] | 7 | from chromite.lib import constants |
Gaurav Shah | 298aa37 | 2014-01-31 09:27:24 -0800 | [diff] [blame] | 8 | from chromite.lib import cros_test_lib |
| 9 | from chromite.scripts import cbuildbot |
| 10 | |
| 11 | |
Don Garrett | b85658c | 2015-06-30 19:07:22 -0700 | [diff] [blame] | 12 | # pylint: disable=protected-access |
| 13 | |
| 14 | |
Gaurav Shah | 298aa37 | 2014-01-31 09:27:24 -0800 | [diff] [blame] | 15 | class IsDistributedBuilderTest(cros_test_lib.TestCase): |
| 16 | """Test for cbuildbot._IsDistributedBuilder.""" |
| 17 | |
Mike Frysinger | 27e21b7 | 2018-07-12 14:20:21 -0400 | [diff] [blame] | 18 | # pylint: disable=protected-access |
Gaurav Shah | 298aa37 | 2014-01-31 09:27:24 -0800 | [diff] [blame] | 19 | def testIsDistributedBuilder(self): |
| 20 | """Tests for _IsDistributedBuilder() under various configurations.""" |
| 21 | parser = cbuildbot._CreateParser() |
Don Garrett | 211df8c | 2017-09-06 13:33:02 -0700 | [diff] [blame] | 22 | argv = ['--buildroot', '/foo', 'amd64-generic-paladin'] |
Mike Frysinger | 80bba8a | 2017-08-18 15:28:36 -0400 | [diff] [blame] | 23 | options = cbuildbot.ParseCommandLine(parser, argv) |
Gaurav Shah | 298aa37 | 2014-01-31 09:27:24 -0800 | [diff] [blame] | 24 | options.buildbot = False |
Gaurav Shah | 298aa37 | 2014-01-31 09:27:24 -0800 | [diff] [blame] | 25 | |
Mike Frysinger | c3e88fa | 2020-03-26 02:49:02 -0400 | [diff] [blame] | 26 | build_config = dict(manifest_version=False) |
Gaurav Shah | 298aa37 | 2014-01-31 09:27:24 -0800 | [diff] [blame] | 27 | chrome_rev = None |
| 28 | |
| 29 | def _TestConfig(expected): |
Mike Frysinger | 2d589a1 | 2019-08-25 14:15:12 -0400 | [diff] [blame] | 30 | self.assertEqual(expected, |
| 31 | cbuildbot._IsDistributedBuilder( |
| 32 | options=options, |
| 33 | chrome_rev=chrome_rev, |
| 34 | build_config=build_config)) |
Gaurav Shah | 298aa37 | 2014-01-31 09:27:24 -0800 | [diff] [blame] | 35 | |
| 36 | # Default options. |
| 37 | _TestConfig(False) |
| 38 | |
Gaurav Shah | 298aa37 | 2014-01-31 09:27:24 -0800 | [diff] [blame] | 39 | build_config['manifest_version'] = True |
| 40 | # Not running in buildbot mode even though manifest_version=True. |
| 41 | _TestConfig(False) |
| 42 | options.buildbot = True |
| 43 | _TestConfig(True) |
| 44 | |
| 45 | for chrome_rev in (constants.CHROME_REV_TOT, |
| 46 | constants.CHROME_REV_LOCAL, |
| 47 | constants.CHROME_REV_SPEC): |
| 48 | _TestConfig(False) |
Gregory Meinke | 5a25ac7 | 2019-01-31 13:20:51 -0700 | [diff] [blame] | 49 | |
| 50 | |
| 51 | class PostsubmitBuilderTest(cros_test_lib.TestCase): |
| 52 | """Test for special parameters for ChromeOS Findit Integration.""" |
| 53 | |
| 54 | def testBuildPackages(self): |
| 55 | parser = cbuildbot.CreateParser() |
| 56 | argv = ['--buildroot', '/foo', '--buildbot', |
Gregory Meinke | ad6d567 | 2019-02-19 08:41:12 -0700 | [diff] [blame] | 57 | '--cbb_snapshot_revision', 'hash1234', |
Gregory Meinke | 5a25ac7 | 2019-01-31 13:20:51 -0700 | [diff] [blame] | 58 | '--cbb_build_packages', 'pkgA pkgB', 'caroline-postsubmit'] |
| 59 | options = cbuildbot.ParseCommandLine(parser, argv) |
| 60 | expected = ['pkgA', 'pkgB'] |
Mike Frysinger | 2d589a1 | 2019-08-25 14:15:12 -0400 | [diff] [blame] | 61 | self.assertEqual(expected, options.cbb_build_packages) |
| 62 | self.assertEqual('hash1234', options.cbb_snapshot_revision) |