diff options
author | Christopher Larson <chris_larson@mentor.com> | 2015-07-16 16:22:22 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-07-27 23:29:13 +0100 |
commit | 3108e00d927fba20d433192a2af2bb275137372d (patch) | |
tree | db12f777788a95868cf211bb4c485eb8f519207f | |
parent | 7eb55b442b6ee7dd70d8a308887c2a0917aa9366 (diff) | |
download | poky-3108e00d927fba20d433192a2af2bb275137372d.tar.gz |
oeqa/recipetool: allow templayerdir override
This is provided for use by subclasses.
(From OE-Core rev: 95330664826e80c56360645ea90b59d265c2c50e)
Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oeqa/selftest/recipetool.py | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/meta/lib/oeqa/selftest/recipetool.py b/meta/lib/oeqa/selftest/recipetool.py index bebc1d6fad..689d41b740 100644 --- a/meta/lib/oeqa/selftest/recipetool.py +++ b/meta/lib/oeqa/selftest/recipetool.py | |||
@@ -8,7 +8,7 @@ from oeqa.utils.decorators import testcase | |||
8 | from oeqa.selftest import devtool | 8 | from oeqa.selftest import devtool |
9 | 9 | ||
10 | 10 | ||
11 | templayerdir = '' | 11 | templayerdir = None |
12 | 12 | ||
13 | 13 | ||
14 | def setUpModule(): | 14 | def setUpModule(): |
@@ -25,6 +25,7 @@ def tearDownModule(): | |||
25 | 25 | ||
26 | class RecipetoolBase(devtool.DevtoolBase): | 26 | class RecipetoolBase(devtool.DevtoolBase): |
27 | def setUpLocal(self): | 27 | def setUpLocal(self): |
28 | self.templayerdir = templayerdir | ||
28 | self.tempdir = tempfile.mkdtemp(prefix='recipetoolqa') | 29 | self.tempdir = tempfile.mkdtemp(prefix='recipetoolqa') |
29 | self.track_for_cleanup(self.tempdir) | 30 | self.track_for_cleanup(self.tempdir) |
30 | self.testfile = os.path.join(self.tempdir, 'testfile') | 31 | self.testfile = os.path.join(self.tempdir, 'testfile') |
@@ -32,7 +33,7 @@ class RecipetoolBase(devtool.DevtoolBase): | |||
32 | f.write('Test file\n') | 33 | f.write('Test file\n') |
33 | 34 | ||
34 | def tearDownLocal(self): | 35 | def tearDownLocal(self): |
35 | runCmd('rm -rf %s/recipes-*' % templayerdir) | 36 | runCmd('rm -rf %s/recipes-*' % self.templayerdir) |
36 | 37 | ||
37 | def _try_recipetool_appendcmd(self, cmd, testrecipe, expectedfiles, expectedlines=None): | 38 | def _try_recipetool_appendcmd(self, cmd, testrecipe, expectedfiles, expectedlines=None): |
38 | result = runCmd(cmd) | 39 | result = runCmd(cmd) |
@@ -40,7 +41,7 @@ class RecipetoolBase(devtool.DevtoolBase): | |||
40 | 41 | ||
41 | # Check the bbappend was created and applies properly | 42 | # Check the bbappend was created and applies properly |
42 | recipefile = get_bb_var('FILE', testrecipe) | 43 | recipefile = get_bb_var('FILE', testrecipe) |
43 | bbappendfile = self._check_bbappend(testrecipe, recipefile, templayerdir) | 44 | bbappendfile = self._check_bbappend(testrecipe, recipefile, self.templayerdir) |
44 | 45 | ||
45 | # Check the bbappend contents | 46 | # Check the bbappend contents |
46 | if expectedlines is not None: | 47 | if expectedlines is not None: |
@@ -76,11 +77,11 @@ class RecipetoolTests(RecipetoolBase): | |||
76 | bitbake('-c cleansstate selftest-recipetool-appendfile') | 77 | bitbake('-c cleansstate selftest-recipetool-appendfile') |
77 | 78 | ||
78 | def _try_recipetool_appendfile(self, testrecipe, destfile, newfile, options, expectedlines, expectedfiles): | 79 | def _try_recipetool_appendfile(self, testrecipe, destfile, newfile, options, expectedlines, expectedfiles): |
79 | cmd = 'recipetool appendfile %s %s %s %s' % (templayerdir, destfile, newfile, options) | 80 | cmd = 'recipetool appendfile %s %s %s %s' % (self.templayerdir, destfile, newfile, options) |
80 | return self._try_recipetool_appendcmd(cmd, testrecipe, expectedfiles, expectedlines) | 81 | return self._try_recipetool_appendcmd(cmd, testrecipe, expectedfiles, expectedlines) |
81 | 82 | ||
82 | def _try_recipetool_appendfile_fail(self, destfile, newfile, checkerror): | 83 | def _try_recipetool_appendfile_fail(self, destfile, newfile, checkerror): |
83 | cmd = 'recipetool appendfile %s %s %s' % (templayerdir, destfile, newfile) | 84 | cmd = 'recipetool appendfile %s %s %s' % (self.templayerdir, destfile, newfile) |
84 | result = runCmd(cmd, ignore_status=True) | 85 | result = runCmd(cmd, ignore_status=True) |
85 | self.assertNotEqual(result.status, 0, 'Command "%s" should have failed but didn\'t' % cmd) | 86 | self.assertNotEqual(result.status, 0, 'Command "%s" should have failed but didn\'t' % cmd) |
86 | self.assertNotIn('Traceback', result.output) | 87 | self.assertNotIn('Traceback', result.output) |
@@ -132,7 +133,7 @@ class RecipetoolTests(RecipetoolBase): | |||
132 | # Try appending a binary file | 133 | # Try appending a binary file |
133 | # /bin/ls can be a symlink to /usr/bin/ls | 134 | # /bin/ls can be a symlink to /usr/bin/ls |
134 | ls = os.path.realpath("/bin/ls") | 135 | ls = os.path.realpath("/bin/ls") |
135 | result = runCmd('recipetool appendfile %s /bin/ls %s -r coreutils' % (templayerdir, ls)) | 136 | result = runCmd('recipetool appendfile %s /bin/ls %s -r coreutils' % (self.templayerdir, ls)) |
136 | self.assertIn('WARNING: ', result.output) | 137 | self.assertIn('WARNING: ', result.output) |
137 | self.assertIn('is a binary', result.output) | 138 | self.assertIn('is a binary', result.output) |
138 | 139 | ||
@@ -341,17 +342,17 @@ class RecipetoolTests(RecipetoolBase): | |||
341 | def test_recipetool_appendfile_wildcard(self): | 342 | def test_recipetool_appendfile_wildcard(self): |
342 | 343 | ||
343 | def try_appendfile_wc(options): | 344 | def try_appendfile_wc(options): |
344 | result = runCmd('recipetool appendfile %s /etc/profile %s %s' % (templayerdir, self.testfile, options)) | 345 | result = runCmd('recipetool appendfile %s /etc/profile %s %s' % (self.templayerdir, self.testfile, options)) |
345 | self.assertNotIn('Traceback', result.output) | 346 | self.assertNotIn('Traceback', result.output) |
346 | bbappendfile = None | 347 | bbappendfile = None |
347 | for root, _, files in os.walk(templayerdir): | 348 | for root, _, files in os.walk(self.templayerdir): |
348 | for f in files: | 349 | for f in files: |
349 | if f.endswith('.bbappend'): | 350 | if f.endswith('.bbappend'): |
350 | bbappendfile = f | 351 | bbappendfile = f |
351 | break | 352 | break |
352 | if not bbappendfile: | 353 | if not bbappendfile: |
353 | self.assertTrue(False, 'No bbappend file created') | 354 | self.assertTrue(False, 'No bbappend file created') |
354 | runCmd('rm -rf %s/recipes-*' % templayerdir) | 355 | runCmd('rm -rf %s/recipes-*' % self.templayerdir) |
355 | return bbappendfile | 356 | return bbappendfile |
356 | 357 | ||
357 | # Check without wildcard option | 358 | # Check without wildcard option |
@@ -403,7 +404,7 @@ class RecipetoolTests(RecipetoolBase): | |||
403 | 404 | ||
404 | class RecipetoolAppendsrcBase(RecipetoolBase): | 405 | class RecipetoolAppendsrcBase(RecipetoolBase): |
405 | def _try_recipetool_appendsrcfile(self, testrecipe, newfile, destfile, options, expectedlines, expectedfiles): | 406 | def _try_recipetool_appendsrcfile(self, testrecipe, newfile, destfile, options, expectedlines, expectedfiles): |
406 | cmd = 'recipetool appendsrcfile %s %s %s %s %s' % (options, templayerdir, testrecipe, newfile, destfile) | 407 | cmd = 'recipetool appendsrcfile %s %s %s %s %s' % (options, self.templayerdir, testrecipe, newfile, destfile) |
407 | return self._try_recipetool_appendcmd(cmd, testrecipe, expectedfiles, expectedlines) | 408 | return self._try_recipetool_appendcmd(cmd, testrecipe, expectedfiles, expectedlines) |
408 | 409 | ||
409 | def _try_recipetool_appendsrcfiles(self, testrecipe, newfiles, expectedlines=None, expectedfiles=None, destdir=None, options=''): | 410 | def _try_recipetool_appendsrcfiles(self, testrecipe, newfiles, expectedlines=None, expectedfiles=None, destdir=None, options=''): |
@@ -414,11 +415,11 @@ class RecipetoolAppendsrcBase(RecipetoolBase): | |||
414 | if expectedfiles is None: | 415 | if expectedfiles is None: |
415 | expectedfiles = [os.path.basename(f) for f in newfiles] | 416 | expectedfiles = [os.path.basename(f) for f in newfiles] |
416 | 417 | ||
417 | cmd = 'recipetool appendsrcfiles %s %s %s %s' % (options, templayerdir, testrecipe, ' '.join(newfiles)) | 418 | cmd = 'recipetool appendsrcfiles %s %s %s %s' % (options, self.templayerdir, testrecipe, ' '.join(newfiles)) |
418 | return self._try_recipetool_appendcmd(cmd, testrecipe, expectedfiles, expectedlines) | 419 | return self._try_recipetool_appendcmd(cmd, testrecipe, expectedfiles, expectedlines) |
419 | 420 | ||
420 | def _try_recipetool_appendsrcfile_fail(self, testrecipe, newfile, destfile, checkerror): | 421 | def _try_recipetool_appendsrcfile_fail(self, testrecipe, newfile, destfile, checkerror): |
421 | cmd = 'recipetool appendsrcfile %s %s %s %s' % (templayerdir, testrecipe, newfile, destfile or '') | 422 | cmd = 'recipetool appendsrcfile %s %s %s %s' % (self.templayerdir, testrecipe, newfile, destfile or '') |
422 | result = runCmd(cmd, ignore_status=True) | 423 | result = runCmd(cmd, ignore_status=True) |
423 | self.assertNotEqual(result.status, 0, 'Command "%s" should have failed but didn\'t' % cmd) | 424 | self.assertNotEqual(result.status, 0, 'Command "%s" should have failed but didn\'t' % cmd) |
424 | self.assertNotIn('Traceback', result.output) | 425 | self.assertNotIn('Traceback', result.output) |
@@ -484,7 +485,7 @@ class RecipetoolAppendsrcBase(RecipetoolBase): | |||
484 | self.assertIn('file://%s' % f, src_uri) | 485 | self.assertIn('file://%s' % f, src_uri) |
485 | 486 | ||
486 | recipefile = get_bb_var('FILE', testrecipe) | 487 | recipefile = get_bb_var('FILE', testrecipe) |
487 | bbappendfile = self._check_bbappend(testrecipe, recipefile, templayerdir) | 488 | bbappendfile = self._check_bbappend(testrecipe, recipefile, self.templayerdir) |
488 | filesdir = os.path.join(os.path.dirname(bbappendfile), testrecipe) | 489 | filesdir = os.path.join(os.path.dirname(bbappendfile), testrecipe) |
489 | filesextrapaths = get_bb_var('FILESEXTRAPATHS', testrecipe).split(':') | 490 | filesextrapaths = get_bb_var('FILESEXTRAPATHS', testrecipe).split(':') |
490 | self.assertIn(filesdir, filesextrapaths) | 491 | self.assertIn(filesdir, filesextrapaths) |
@@ -498,7 +499,7 @@ class RecipetoolAppendsrcTests(RecipetoolAppendsrcBase): | |||
498 | testrecipe = 'base-files' | 499 | testrecipe = 'base-files' |
499 | self._test_appendsrcfile(testrecipe, 'a-file', options='-w') | 500 | self._test_appendsrcfile(testrecipe, 'a-file', options='-w') |
500 | recipefile = get_bb_var('FILE', testrecipe) | 501 | recipefile = get_bb_var('FILE', testrecipe) |
501 | bbappendfile = self._check_bbappend(testrecipe, recipefile, templayerdir) | 502 | bbappendfile = self._check_bbappend(testrecipe, recipefile, self.templayerdir) |
502 | self.assertEqual(os.path.basename(bbappendfile), '%s_%%.bbappend' % testrecipe) | 503 | self.assertEqual(os.path.basename(bbappendfile), '%s_%%.bbappend' % testrecipe) |
503 | 504 | ||
504 | def test_recipetool_appendsrcfile_subdir_basic(self): | 505 | def test_recipetool_appendsrcfile_subdir_basic(self): |