summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/selftest/devtool.py70
1 files changed, 69 insertions, 1 deletions
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py
index 8caf07aaec..f147f248b3 100644
--- a/meta/lib/oeqa/selftest/devtool.py
+++ b/meta/lib/oeqa/selftest/devtool.py
@@ -233,6 +233,8 @@ class DevtoolTests(oeSelfTest):
233 self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory') 233 self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory')
234 testrecipe = 'minicom' 234 testrecipe = 'minicom'
235 recipefile = get_bb_var('FILE', testrecipe) 235 recipefile = get_bb_var('FILE', testrecipe)
236 src_uri = get_bb_var('SRC_URI', testrecipe)
237 self.assertNotIn('git://', src_uri, 'This test expects the %s recipe to NOT be a git recipe' % testrecipe)
236 result = runCmd('git status . --porcelain', cwd=os.path.dirname(recipefile)) 238 result = runCmd('git status . --porcelain', cwd=os.path.dirname(recipefile))
237 self.assertEqual(result.output.strip(), "", '%s recipe is not clean' % testrecipe) 239 self.assertEqual(result.output.strip(), "", '%s recipe is not clean' % testrecipe)
238 # First, modify a recipe 240 # First, modify a recipe
@@ -266,11 +268,77 @@ class DevtoolTests(oeSelfTest):
266 self.assertEqual(line[:3], '?? ', 'Unexpected status in line: %s' % line) 268 self.assertEqual(line[:3], '?? ', 'Unexpected status in line: %s' % line)
267 elif line.endswith('0002-Add-a-new-file.patch'): 269 elif line.endswith('0002-Add-a-new-file.patch'):
268 self.assertEqual(line[:3], '?? ', 'Unexpected status in line: %s' % line) 270 self.assertEqual(line[:3], '?? ', 'Unexpected status in line: %s' % line)
269 elif re.search('minicom_[^_]*.bb$', line): 271 elif re.search('%s_[^_]*.bb$' % testrecipe, line):
270 self.assertEqual(line[:3], ' M ', 'Unexpected status in line: %s' % line) 272 self.assertEqual(line[:3], ' M ', 'Unexpected status in line: %s' % line)
271 else: 273 else:
272 raise AssertionError('Unexpected modified file in status: %s' % line) 274 raise AssertionError('Unexpected modified file in status: %s' % line)
273 275
276 def test_devtool_update_recipe_git(self):
277 # Check preconditions
278 workspacedir = os.path.join(self.builddir, 'workspace')
279 self.assertTrue(not os.path.exists(workspacedir), 'This test cannot be run with a workspace directory under the build directory')
280 testrecipe = 'mtd-utils'
281 recipefile = get_bb_var('FILE', testrecipe)
282 src_uri = get_bb_var('SRC_URI', testrecipe)
283 self.assertIn('git://', src_uri, 'This test expects the %s recipe to be a git recipe' % testrecipe)
284 result = runCmd('git status . --porcelain', cwd=os.path.dirname(recipefile))
285 self.assertEqual(result.output.strip(), "", '%s recipe is not clean' % testrecipe)
286 # First, modify a recipe
287 tempdir = tempfile.mkdtemp(prefix='devtoolqa')
288 self.track_for_cleanup(tempdir)
289 self.track_for_cleanup(workspacedir)
290 self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
291 # (don't bother with cleaning the recipe on teardown, we won't be building it)
292 result = runCmd('devtool modify %s -x %s' % (testrecipe, tempdir))
293 # Check git repo
294 self.assertTrue(os.path.isdir(os.path.join(tempdir, '.git')), 'git repository for external source tree not found')
295 result = runCmd('git status --porcelain', cwd=tempdir)
296 self.assertEqual(result.output.strip(), "", 'Created git repo is not clean')
297 result = runCmd('git symbolic-ref HEAD', cwd=tempdir)
298 self.assertEqual(result.output.strip(), "refs/heads/devtool", 'Wrong branch in git repo')
299 # Add a couple of commits
300 # FIXME: this only tests adding, need to also test update and remove
301 result = runCmd('echo "# Additional line" >> Makefile', cwd=tempdir)
302 result = runCmd('git commit -a -m "Change the Makefile"', cwd=tempdir)
303 result = runCmd('echo "A new file" > devtool-new-file', cwd=tempdir)
304 result = runCmd('git add devtool-new-file', cwd=tempdir)
305 result = runCmd('git commit -m "Add a new file"', cwd=tempdir)
306 self.add_command_to_tearDown('cd %s; git checkout %s %s' % (os.path.dirname(recipefile), testrecipe, os.path.basename(recipefile)))
307 result = runCmd('devtool update-recipe %s' % testrecipe)
308 result = runCmd('git status . --porcelain', cwd=os.path.dirname(recipefile))
309 self.assertNotEqual(result.output.strip(), "", '%s recipe should be modified' % testrecipe)
310 status = result.output.splitlines()
311 self.assertEqual(len(status), 3, 'Less/more files modified than expected. Entire status:\n%s' % result.output)
312 for line in status:
313 if line.endswith('add-exclusion-to-mkfs-jffs2-git-2.patch'):
314 self.assertEqual(line[:3], ' D ', 'Unexpected status in line: %s' % line)
315 elif line.endswith('fix-armv7-neon-alignment.patch'):
316 self.assertEqual(line[:3], ' D ', 'Unexpected status in line: %s' % line)
317 elif re.search('%s_[^_]*.bb$' % testrecipe, line):
318 self.assertEqual(line[:3], ' M ', 'Unexpected status in line: %s' % line)
319 else:
320 raise AssertionError('Unexpected modified file in status: %s' % line)
321 result = runCmd('git diff %s' % os.path.basename(recipefile), cwd=os.path.dirname(recipefile))
322 addlines = ['SRCREV = ".*"', 'SRC_URI = "git://git.infradead.org/mtd-utils.git"']
323 removelines = ['SRCREV = ".*"', 'SRC_URI = "git://git.infradead.org/mtd-utils.git \\\\', 'file://add-exclusion-to-mkfs-jffs2-git-2.patch \\\\', 'file://fix-armv7-neon-alignment.patch \\\\', '"']
324 for line in result.output.splitlines():
325 if line.startswith('+++') or line.startswith('---'):
326 continue
327 elif line.startswith('+'):
328 matched = False
329 for item in addlines:
330 if re.match(item, line[1:].strip()):
331 matched = True
332 break
333 self.assertTrue(matched, 'Unexpected diff add line: %s' % line)
334 elif line.startswith('-'):
335 matched = False
336 for item in removelines:
337 if re.match(item, line[1:].strip()):
338 matched = True
339 break
340 self.assertTrue(matched, 'Unexpected diff remove line: %s' % line)
341
274 def test_devtool_extract(self): 342 def test_devtool_extract(self):
275 # Check preconditions 343 # Check preconditions
276 workspacedir = os.path.join(self.builddir, 'workspace') 344 workspacedir = os.path.join(self.builddir, 'workspace')