From d0ae258e963f9bafffc4ca43c87497d27e57c127 Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Wed, 24 Feb 2016 16:51:30 +1300 Subject: oe-selftest: devtool: rework devtool upgrade test * Use a more real-world test of a recipe pointing to a remote file * The cleanup tracking / teardown commands need to be added towards the top, or they won't have the desired effect of cleaning up if the test fails. * Check that a versioned subdirectory gets renamed to match the new version * Ensure the recipe contents gets changed as we expect it to * Check that the recipe directory is deleted by devtool reset at the end Signed-off-by: Paul Eggleton Signed-off-by: Ross Burton --- meta/lib/oeqa/selftest/devtool.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'meta/lib/oeqa/selftest/devtool.py') diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index 036146425b..4d280bb4af 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py @@ -1095,14 +1095,18 @@ class DevtoolTests(DevtoolBase): def test_devtool_upgrade(self): # Check preconditions self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory') + self.track_for_cleanup(self.workspacedir) + self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') # Check parameters result = runCmd('devtool upgrade -h') for param in 'recipename srctree --version -V --branch -b --keep-temp --no-patch'.split(): self.assertIn(param, result.output) # For the moment, we are using a real recipe. - recipe='devtool-upgrade' - version='0.2' + recipe = 'devtool-upgrade-test1' + version = '1.6.0' + oldrecipefile = get_bb_var('FILE', recipe) tempdir = tempfile.mkdtemp(prefix='devtoolqa') + self.track_for_cleanup(tempdir) # Check that recipe is not already under devtool control result = runCmd('devtool status') self.assertNotIn(recipe, result.output) @@ -1110,22 +1114,27 @@ class DevtoolTests(DevtoolBase): # we are downgrading instead of upgrading. result = runCmd('devtool upgrade %s %s -V %s' % (recipe, tempdir, version)) # Check if srctree at least is populated - self.assertTrue(len(os.listdir(tempdir)) > 0, 'scrtree (%s) should be populated with new (%s) source code' % (tempdir, version)) - # Check new recipe folder is present - self.assertTrue(os.path.exists(os.path.join(self.workspacedir,'recipes',recipe)), 'Recipe folder should exist') + self.assertTrue(len(os.listdir(tempdir)) > 0, 'srctree (%s) should be populated with new (%s) source code' % (tempdir, version)) + # Check new recipe subdirectory is present + self.assertTrue(os.path.exists(os.path.join(self.workspacedir, 'recipes', recipe, '%s-%s' % (recipe, version))), 'Recipe folder should exist') # Check new recipe file is present - self.assertTrue(os.path.exists(os.path.join(self.workspacedir,'recipes',recipe,"%s_%s.bb" % (recipe,version))), 'Recipe folder should exist') + newrecipefile = os.path.join(self.workspacedir, 'recipes', recipe, '%s_%s.bb' % (recipe, version)) + self.assertTrue(os.path.exists(newrecipefile), 'Recipe file should exist after upgrade') # Check devtool status and make sure recipe is present result = runCmd('devtool status') self.assertIn(recipe, result.output) self.assertIn(tempdir, result.output) + # Check recipe got changed as expected + with open(oldrecipefile + '.upgraded', 'r') as f: + desiredlines = f.readlines() + with open(newrecipefile, 'r') as f: + newlines = f.readlines() + self.assertEqual(desiredlines, newlines) # Check devtool reset recipe result = runCmd('devtool reset %s -n' % recipe) result = runCmd('devtool status') self.assertNotIn(recipe, result.output) - self.track_for_cleanup(tempdir) - self.track_for_cleanup(self.workspacedir) - self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') + self.assertFalse(os.path.exists(os.path.join(self.workspacedir, 'recipes', recipe)), 'Recipe directory should not exist after resetting') @testcase(1352) def test_devtool_layer_plugins(self): -- cgit 1.2.3-korg