diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/cases')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/devtool.py | 113 |
1 files changed, 61 insertions, 52 deletions
diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py index f2b0f59677..43a66c8e28 100644 --- a/meta/lib/oeqa/selftest/cases/devtool.py +++ b/meta/lib/oeqa/selftest/cases/devtool.py | |||
@@ -13,6 +13,58 @@ from oeqa.core.decorator.oeid import OETestID | |||
13 | 13 | ||
14 | class DevtoolBase(OESelftestTestCase): | 14 | class DevtoolBase(OESelftestTestCase): |
15 | 15 | ||
16 | @classmethod | ||
17 | def setUpClass(cls): | ||
18 | super(DevtoolBase, cls).setUpClass() | ||
19 | bb_vars = get_bb_vars(['TOPDIR', 'SSTATE_DIR']) | ||
20 | cls.original_sstate = bb_vars['SSTATE_DIR'] | ||
21 | cls.devtool_sstate = os.path.join(bb_vars['TOPDIR'], 'sstate_devtool') | ||
22 | cls.sstate_conf = 'SSTATE_DIR = "%s"\n' % cls.devtool_sstate | ||
23 | cls.sstate_conf += ('SSTATE_MIRRORS += "file://.* file:///%s/PATH"\n' | ||
24 | % cls.original_sstate) | ||
25 | |||
26 | @classmethod | ||
27 | def tearDownClass(cls): | ||
28 | cls.logger.debug('Deleting devtool sstate cache on %s' % cls.devtool_sstate) | ||
29 | runCmd('rm -rf %s' % cls.devtool_sstate) | ||
30 | super(DevtoolBase, cls).tearDownClass() | ||
31 | |||
32 | def setUp(self): | ||
33 | """Test case setup function""" | ||
34 | super(DevtoolBase, self).setUp() | ||
35 | self.workspacedir = os.path.join(self.builddir, 'workspace') | ||
36 | self.assertTrue(not os.path.exists(self.workspacedir), | ||
37 | 'This test cannot be run with a workspace directory ' | ||
38 | 'under the build directory') | ||
39 | self.append_config(self.sstate_conf) | ||
40 | |||
41 | def _check_src_repo(self, repo_dir): | ||
42 | """Check srctree git repository""" | ||
43 | self.assertTrue(os.path.isdir(os.path.join(repo_dir, '.git')), | ||
44 | 'git repository for external source tree not found') | ||
45 | result = runCmd('git status --porcelain', cwd=repo_dir) | ||
46 | self.assertEqual(result.output.strip(), "", | ||
47 | 'Created git repo is not clean') | ||
48 | result = runCmd('git symbolic-ref HEAD', cwd=repo_dir) | ||
49 | self.assertEqual(result.output.strip(), "refs/heads/devtool", | ||
50 | 'Wrong branch in git repo') | ||
51 | |||
52 | def _check_repo_status(self, repo_dir, expected_status): | ||
53 | """Check the worktree status of a repository""" | ||
54 | result = runCmd('git status . --porcelain', | ||
55 | cwd=repo_dir) | ||
56 | for line in result.output.splitlines(): | ||
57 | for ind, (f_status, fn_re) in enumerate(expected_status): | ||
58 | if re.match(fn_re, line[3:]): | ||
59 | if f_status != line[:2]: | ||
60 | self.fail('Unexpected status in line: %s' % line) | ||
61 | expected_status.pop(ind) | ||
62 | break | ||
63 | else: | ||
64 | self.fail('Unexpected modified file in line: %s' % line) | ||
65 | if expected_status: | ||
66 | self.fail('Missing file changes: %s' % expected_status) | ||
67 | |||
16 | def _test_recipe_contents(self, recipefile, checkvars, checkinherits): | 68 | def _test_recipe_contents(self, recipefile, checkvars, checkinherits): |
17 | with open(recipefile, 'r') as f: | 69 | with open(recipefile, 'r') as f: |
18 | invar = None | 70 | invar = None |
@@ -116,58 +168,6 @@ class DevtoolBase(OESelftestTestCase): | |||
116 | 168 | ||
117 | class DevtoolTests(DevtoolBase): | 169 | class DevtoolTests(DevtoolBase): |
118 | 170 | ||
119 | @classmethod | ||
120 | def setUpClass(cls): | ||
121 | super(DevtoolTests, cls).setUpClass() | ||
122 | bb_vars = get_bb_vars(['TOPDIR', 'SSTATE_DIR']) | ||
123 | cls.original_sstate = bb_vars['SSTATE_DIR'] | ||
124 | cls.devtool_sstate = os.path.join(bb_vars['TOPDIR'], 'sstate_devtool') | ||
125 | cls.sstate_conf = 'SSTATE_DIR = "%s"\n' % cls.devtool_sstate | ||
126 | cls.sstate_conf += ('SSTATE_MIRRORS += "file://.* file:///%s/PATH"\n' | ||
127 | % cls.original_sstate) | ||
128 | |||
129 | @classmethod | ||
130 | def tearDownClass(cls): | ||
131 | cls.logger.debug('Deleting devtool sstate cache on %s' % cls.devtool_sstate) | ||
132 | runCmd('rm -rf %s' % cls.devtool_sstate) | ||
133 | super(DevtoolTests, cls).tearDownClass() | ||
134 | |||
135 | def setUp(self): | ||
136 | """Test case setup function""" | ||
137 | super(DevtoolTests, self).setUp() | ||
138 | self.workspacedir = os.path.join(self.builddir, 'workspace') | ||
139 | self.assertTrue(not os.path.exists(self.workspacedir), | ||
140 | 'This test cannot be run with a workspace directory ' | ||
141 | 'under the build directory') | ||
142 | self.append_config(self.sstate_conf) | ||
143 | |||
144 | def _check_src_repo(self, repo_dir): | ||
145 | """Check srctree git repository""" | ||
146 | self.assertTrue(os.path.isdir(os.path.join(repo_dir, '.git')), | ||
147 | 'git repository for external source tree not found') | ||
148 | result = runCmd('git status --porcelain', cwd=repo_dir) | ||
149 | self.assertEqual(result.output.strip(), "", | ||
150 | 'Created git repo is not clean') | ||
151 | result = runCmd('git symbolic-ref HEAD', cwd=repo_dir) | ||
152 | self.assertEqual(result.output.strip(), "refs/heads/devtool", | ||
153 | 'Wrong branch in git repo') | ||
154 | |||
155 | def _check_repo_status(self, repo_dir, expected_status): | ||
156 | """Check the worktree status of a repository""" | ||
157 | result = runCmd('git status . --porcelain', | ||
158 | cwd=repo_dir) | ||
159 | for line in result.output.splitlines(): | ||
160 | for ind, (f_status, fn_re) in enumerate(expected_status): | ||
161 | if re.match(fn_re, line[3:]): | ||
162 | if f_status != line[:2]: | ||
163 | self.fail('Unexpected status in line: %s' % line) | ||
164 | expected_status.pop(ind) | ||
165 | break | ||
166 | else: | ||
167 | self.fail('Unexpected modified file in line: %s' % line) | ||
168 | if expected_status: | ||
169 | self.fail('Missing file changes: %s' % expected_status) | ||
170 | |||
171 | @OETestID(1158) | 171 | @OETestID(1158) |
172 | def test_create_workspace(self): | 172 | def test_create_workspace(self): |
173 | # Check preconditions | 173 | # Check preconditions |
@@ -189,6 +189,8 @@ class DevtoolTests(DevtoolBase): | |||
189 | self.assertNotIn(tempdir, result.output) | 189 | self.assertNotIn(tempdir, result.output) |
190 | self.assertIn(self.workspacedir, result.output) | 190 | self.assertIn(self.workspacedir, result.output) |
191 | 191 | ||
192 | class DevtoolAddTests(DevtoolBase): | ||
193 | |||
192 | @OETestID(1159) | 194 | @OETestID(1159) |
193 | def test_devtool_add(self): | 195 | def test_devtool_add(self): |
194 | # Fetch source | 196 | # Fetch source |
@@ -444,6 +446,8 @@ class DevtoolTests(DevtoolBase): | |||
444 | checkvars['SRC_URI'] = url.replace(testver, '${PV}') | 446 | checkvars['SRC_URI'] = url.replace(testver, '${PV}') |
445 | self._test_recipe_contents(recipefile, checkvars, []) | 447 | self._test_recipe_contents(recipefile, checkvars, []) |
446 | 448 | ||
449 | class DevtoolModifyTests(DevtoolBase): | ||
450 | |||
447 | @OETestID(1164) | 451 | @OETestID(1164) |
448 | def test_devtool_modify(self): | 452 | def test_devtool_modify(self): |
449 | import oe.path | 453 | import oe.path |
@@ -689,6 +693,7 @@ class DevtoolTests(DevtoolBase): | |||
689 | self._check_src_repo(tempdir) | 693 | self._check_src_repo(tempdir) |
690 | # This is probably sufficient | 694 | # This is probably sufficient |
691 | 695 | ||
696 | class DevtoolUpdateTests(DevtoolBase): | ||
692 | 697 | ||
693 | @OETestID(1169) | 698 | @OETestID(1169) |
694 | def test_devtool_update_recipe(self): | 699 | def test_devtool_update_recipe(self): |
@@ -1105,6 +1110,8 @@ class DevtoolTests(DevtoolBase): | |||
1105 | expected_status = [] | 1110 | expected_status = [] |
1106 | self._check_repo_status(os.path.dirname(recipefile), expected_status) | 1111 | self._check_repo_status(os.path.dirname(recipefile), expected_status) |
1107 | 1112 | ||
1113 | class DevtoolExtractTests(DevtoolBase): | ||
1114 | |||
1108 | @OETestID(1163) | 1115 | @OETestID(1163) |
1109 | def test_devtool_extract(self): | 1116 | def test_devtool_extract(self): |
1110 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') | 1117 | tempdir = tempfile.mkdtemp(prefix='devtoolqa') |
@@ -1274,6 +1281,8 @@ class DevtoolTests(DevtoolBase): | |||
1274 | if reqpkgs: | 1281 | if reqpkgs: |
1275 | self.fail('The following packages were not present in the image as expected: %s' % ', '.join(reqpkgs)) | 1282 | self.fail('The following packages were not present in the image as expected: %s' % ', '.join(reqpkgs)) |
1276 | 1283 | ||
1284 | class DevtoolUpgradeTests(DevtoolBase): | ||
1285 | |||
1277 | @OETestID(1367) | 1286 | @OETestID(1367) |
1278 | def test_devtool_upgrade(self): | 1287 | def test_devtool_upgrade(self): |
1279 | # Check preconditions | 1288 | # Check preconditions |