summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/selftest/cases/devtool.py113
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 99bfcd3d05..9eb9badf84 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -78,6 +78,58 @@ def tearDownModule():
78 78
79class DevtoolBase(OESelftestTestCase): 79class DevtoolBase(OESelftestTestCase):
80 80
81 @classmethod
82 def setUpClass(cls):
83 super(DevtoolBase, cls).setUpClass()
84 bb_vars = get_bb_vars(['TOPDIR', 'SSTATE_DIR'])
85 cls.original_sstate = bb_vars['SSTATE_DIR']
86 cls.devtool_sstate = os.path.join(bb_vars['TOPDIR'], 'sstate_devtool')
87 cls.sstate_conf = 'SSTATE_DIR = "%s"\n' % cls.devtool_sstate
88 cls.sstate_conf += ('SSTATE_MIRRORS += "file://.* file:///%s/PATH"\n'
89 % cls.original_sstate)
90
91 @classmethod
92 def tearDownClass(cls):
93 cls.logger.debug('Deleting devtool sstate cache on %s' % cls.devtool_sstate)
94 runCmd('rm -rf %s' % cls.devtool_sstate)
95 super(DevtoolBase, cls).tearDownClass()
96
97 def setUp(self):
98 """Test case setup function"""
99 super(DevtoolBase, self).setUp()
100 self.workspacedir = os.path.join(self.builddir, 'workspace')
101 self.assertTrue(not os.path.exists(self.workspacedir),
102 'This test cannot be run with a workspace directory '
103 'under the build directory')
104 self.append_config(self.sstate_conf)
105
106 def _check_src_repo(self, repo_dir):
107 """Check srctree git repository"""
108 self.assertTrue(os.path.isdir(os.path.join(repo_dir, '.git')),
109 'git repository for external source tree not found')
110 result = runCmd('git status --porcelain', cwd=repo_dir)
111 self.assertEqual(result.output.strip(), "",
112 'Created git repo is not clean')
113 result = runCmd('git symbolic-ref HEAD', cwd=repo_dir)
114 self.assertEqual(result.output.strip(), "refs/heads/devtool",
115 'Wrong branch in git repo')
116
117 def _check_repo_status(self, repo_dir, expected_status):
118 """Check the worktree status of a repository"""
119 result = runCmd('git status . --porcelain',
120 cwd=repo_dir)
121 for line in result.output.splitlines():
122 for ind, (f_status, fn_re) in enumerate(expected_status):
123 if re.match(fn_re, line[3:]):
124 if f_status != line[:2]:
125 self.fail('Unexpected status in line: %s' % line)
126 expected_status.pop(ind)
127 break
128 else:
129 self.fail('Unexpected modified file in line: %s' % line)
130 if expected_status:
131 self.fail('Missing file changes: %s' % expected_status)
132
81 def _test_recipe_contents(self, recipefile, checkvars, checkinherits): 133 def _test_recipe_contents(self, recipefile, checkvars, checkinherits):
82 with open(recipefile, 'r') as f: 134 with open(recipefile, 'r') as f:
83 invar = None 135 invar = None
@@ -181,58 +233,6 @@ class DevtoolBase(OESelftestTestCase):
181 233
182class DevtoolTests(DevtoolBase): 234class DevtoolTests(DevtoolBase):
183 235
184 @classmethod
185 def setUpClass(cls):
186 super(DevtoolTests, cls).setUpClass()
187 bb_vars = get_bb_vars(['TOPDIR', 'SSTATE_DIR'])
188 cls.original_sstate = bb_vars['SSTATE_DIR']
189 cls.devtool_sstate = os.path.join(bb_vars['TOPDIR'], 'sstate_devtool')
190 cls.sstate_conf = 'SSTATE_DIR = "%s"\n' % cls.devtool_sstate
191 cls.sstate_conf += ('SSTATE_MIRRORS += "file://.* file:///%s/PATH"\n'
192 % cls.original_sstate)
193
194 @classmethod
195 def tearDownClass(cls):
196 cls.logger.debug('Deleting devtool sstate cache on %s' % cls.devtool_sstate)
197 runCmd('rm -rf %s' % cls.devtool_sstate)
198 super(DevtoolTests, cls).tearDownClass()
199
200 def setUp(self):
201 """Test case setup function"""
202 super(DevtoolTests, self).setUp()
203 self.workspacedir = os.path.join(self.builddir, 'workspace')
204 self.assertTrue(not os.path.exists(self.workspacedir),
205 'This test cannot be run with a workspace directory '
206 'under the build directory')
207 self.append_config(self.sstate_conf)
208
209 def _check_src_repo(self, repo_dir):
210 """Check srctree git repository"""
211 self.assertTrue(os.path.isdir(os.path.join(repo_dir, '.git')),
212 'git repository for external source tree not found')
213 result = runCmd('git status --porcelain', cwd=repo_dir)
214 self.assertEqual(result.output.strip(), "",
215 'Created git repo is not clean')
216 result = runCmd('git symbolic-ref HEAD', cwd=repo_dir)
217 self.assertEqual(result.output.strip(), "refs/heads/devtool",
218 'Wrong branch in git repo')
219
220 def _check_repo_status(self, repo_dir, expected_status):
221 """Check the worktree status of a repository"""
222 result = runCmd('git status . --porcelain',
223 cwd=repo_dir)
224 for line in result.output.splitlines():
225 for ind, (f_status, fn_re) in enumerate(expected_status):
226 if re.match(fn_re, line[3:]):
227 if f_status != line[:2]:
228 self.fail('Unexpected status in line: %s' % line)
229 expected_status.pop(ind)
230 break
231 else:
232 self.fail('Unexpected modified file in line: %s' % line)
233 if expected_status:
234 self.fail('Missing file changes: %s' % expected_status)
235
236 @OETestID(1158) 236 @OETestID(1158)
237 def test_create_workspace(self): 237 def test_create_workspace(self):
238 # Check preconditions 238 # Check preconditions
@@ -254,6 +254,8 @@ class DevtoolTests(DevtoolBase):
254 self.assertNotIn(tempdir, result.output) 254 self.assertNotIn(tempdir, result.output)
255 self.assertIn(self.workspacedir, result.output) 255 self.assertIn(self.workspacedir, result.output)
256 256
257class DevtoolAddTests(DevtoolBase):
258
257 @OETestID(1159) 259 @OETestID(1159)
258 def test_devtool_add(self): 260 def test_devtool_add(self):
259 # Fetch source 261 # Fetch source
@@ -509,6 +511,8 @@ class DevtoolTests(DevtoolBase):
509 checkvars['SRC_URI'] = url.replace(testver, '${PV}') 511 checkvars['SRC_URI'] = url.replace(testver, '${PV}')
510 self._test_recipe_contents(recipefile, checkvars, []) 512 self._test_recipe_contents(recipefile, checkvars, [])
511 513
514class DevtoolModifyTests(DevtoolBase):
515
512 @OETestID(1164) 516 @OETestID(1164)
513 def test_devtool_modify(self): 517 def test_devtool_modify(self):
514 import oe.path 518 import oe.path
@@ -754,6 +758,7 @@ class DevtoolTests(DevtoolBase):
754 self._check_src_repo(tempdir) 758 self._check_src_repo(tempdir)
755 # This is probably sufficient 759 # This is probably sufficient
756 760
761class DevtoolUpdateTests(DevtoolBase):
757 762
758 @OETestID(1169) 763 @OETestID(1169)
759 def test_devtool_update_recipe(self): 764 def test_devtool_update_recipe(self):
@@ -1170,6 +1175,8 @@ class DevtoolTests(DevtoolBase):
1170 expected_status = [] 1175 expected_status = []
1171 self._check_repo_status(os.path.dirname(recipefile), expected_status) 1176 self._check_repo_status(os.path.dirname(recipefile), expected_status)
1172 1177
1178class DevtoolExtractTests(DevtoolBase):
1179
1173 @OETestID(1163) 1180 @OETestID(1163)
1174 def test_devtool_extract(self): 1181 def test_devtool_extract(self):
1175 tempdir = tempfile.mkdtemp(prefix='devtoolqa') 1182 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
@@ -1339,6 +1346,8 @@ class DevtoolTests(DevtoolBase):
1339 if reqpkgs: 1346 if reqpkgs:
1340 self.fail('The following packages were not present in the image as expected: %s' % ', '.join(reqpkgs)) 1347 self.fail('The following packages were not present in the image as expected: %s' % ', '.join(reqpkgs))
1341 1348
1349class DevtoolUpgradeTests(DevtoolBase):
1350
1342 @OETestID(1367) 1351 @OETestID(1367)
1343 def test_devtool_upgrade(self): 1352 def test_devtool_upgrade(self):
1344 # Check preconditions 1353 # Check preconditions