diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/recipetool.py')
-rw-r--r-- | meta/lib/oeqa/selftest/recipetool.py | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/meta/lib/oeqa/selftest/recipetool.py b/meta/lib/oeqa/selftest/recipetool.py index e8348233ec..d62c8bb603 100644 --- a/meta/lib/oeqa/selftest/recipetool.py +++ b/meta/lib/oeqa/selftest/recipetool.py | |||
@@ -4,7 +4,8 @@ import shutil | |||
4 | import tempfile | 4 | import tempfile |
5 | import urllib.parse | 5 | import urllib.parse |
6 | 6 | ||
7 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, create_temp_layer | 7 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var |
8 | from oeqa.utils.commands import get_bb_vars, create_temp_layer | ||
8 | from oeqa.utils.decorators import testcase | 9 | from oeqa.utils.decorators import testcase |
9 | from oeqa.selftest import devtool | 10 | from oeqa.selftest import devtool |
10 | 11 | ||
@@ -25,6 +26,7 @@ def tearDownModule(): | |||
25 | 26 | ||
26 | 27 | ||
27 | class RecipetoolBase(devtool.DevtoolBase): | 28 | class RecipetoolBase(devtool.DevtoolBase): |
29 | |||
28 | def setUpLocal(self): | 30 | def setUpLocal(self): |
29 | self.templayerdir = templayerdir | 31 | self.templayerdir = templayerdir |
30 | self.tempdir = tempfile.mkdtemp(prefix='recipetoolqa') | 32 | self.tempdir = tempfile.mkdtemp(prefix='recipetoolqa') |
@@ -65,12 +67,16 @@ class RecipetoolBase(devtool.DevtoolBase): | |||
65 | 67 | ||
66 | 68 | ||
67 | class RecipetoolTests(RecipetoolBase): | 69 | class RecipetoolTests(RecipetoolBase): |
70 | |||
68 | @classmethod | 71 | @classmethod |
69 | def setUpClass(cls): | 72 | def setUpClass(cls): |
70 | # Ensure we have the right data in shlibs/pkgdata | 73 | # Ensure we have the right data in shlibs/pkgdata |
71 | logger = logging.getLogger("selftest") | 74 | logger = logging.getLogger("selftest") |
72 | logger.info('Running bitbake to generate pkgdata') | 75 | logger.info('Running bitbake to generate pkgdata') |
73 | bitbake('-c packagedata base-files coreutils busybox selftest-recipetool-appendfile') | 76 | bitbake('-c packagedata base-files coreutils busybox selftest-recipetool-appendfile') |
77 | bb_vars = get_bb_vars(['COREBASE', 'BBPATH']) | ||
78 | cls.corebase = bb_vars['COREBASE'] | ||
79 | cls.bbpath = bb_vars['BBPATH'] | ||
74 | 80 | ||
75 | def _try_recipetool_appendfile(self, testrecipe, destfile, newfile, options, expectedlines, expectedfiles): | 81 | def _try_recipetool_appendfile(self, testrecipe, destfile, newfile, options, expectedlines, expectedfiles): |
76 | cmd = 'recipetool appendfile %s %s %s %s' % (self.templayerdir, destfile, newfile, options) | 82 | cmd = 'recipetool appendfile %s %s %s %s' % (self.templayerdir, destfile, newfile, options) |
@@ -104,9 +110,8 @@ class RecipetoolTests(RecipetoolBase): | |||
104 | # Now try with a file we know should be an alternative | 110 | # Now try with a file we know should be an alternative |
105 | # (this is very much a fake example, but one we know is reliably an alternative) | 111 | # (this is very much a fake example, but one we know is reliably an alternative) |
106 | self._try_recipetool_appendfile_fail('/bin/ls', self.testfile, ['ERROR: File /bin/ls is an alternative possibly provided by the following recipes:', 'coreutils', 'busybox']) | 112 | self._try_recipetool_appendfile_fail('/bin/ls', self.testfile, ['ERROR: File /bin/ls is an alternative possibly provided by the following recipes:', 'coreutils', 'busybox']) |
107 | corebase = get_bb_var('COREBASE') | ||
108 | # Need a test file - should be executable | 113 | # Need a test file - should be executable |
109 | testfile2 = os.path.join(corebase, 'oe-init-build-env') | 114 | testfile2 = os.path.join(self.corebase, 'oe-init-build-env') |
110 | testfile2name = os.path.basename(testfile2) | 115 | testfile2name = os.path.basename(testfile2) |
111 | expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', | 116 | expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', |
112 | '\n', | 117 | '\n', |
@@ -135,7 +140,6 @@ class RecipetoolTests(RecipetoolBase): | |||
135 | 140 | ||
136 | @testcase(1173) | 141 | @testcase(1173) |
137 | def test_recipetool_appendfile_add(self): | 142 | def test_recipetool_appendfile_add(self): |
138 | corebase = get_bb_var('COREBASE') | ||
139 | # Try arbitrary file add to a recipe | 143 | # Try arbitrary file add to a recipe |
140 | expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', | 144 | expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', |
141 | '\n', | 145 | '\n', |
@@ -148,7 +152,7 @@ class RecipetoolTests(RecipetoolBase): | |||
148 | self._try_recipetool_appendfile('netbase', '/usr/share/something', self.testfile, '-r netbase', expectedlines, ['testfile']) | 152 | self._try_recipetool_appendfile('netbase', '/usr/share/something', self.testfile, '-r netbase', expectedlines, ['testfile']) |
149 | # Try adding another file, this time where the source file is executable | 153 | # Try adding another file, this time where the source file is executable |
150 | # (so we're testing that, plus modifying an existing bbappend) | 154 | # (so we're testing that, plus modifying an existing bbappend) |
151 | testfile2 = os.path.join(corebase, 'oe-init-build-env') | 155 | testfile2 = os.path.join(self.corebase, 'oe-init-build-env') |
152 | testfile2name = os.path.basename(testfile2) | 156 | testfile2name = os.path.basename(testfile2) |
153 | expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', | 157 | expectedlines = ['FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"\n', |
154 | '\n', | 158 | '\n', |
@@ -500,8 +504,7 @@ class RecipetoolTests(RecipetoolBase): | |||
500 | recipetool = runCmd("which recipetool") | 504 | recipetool = runCmd("which recipetool") |
501 | fromname = runCmd("recipetool --quiet pluginfile") | 505 | fromname = runCmd("recipetool --quiet pluginfile") |
502 | srcfile = fromname.output | 506 | srcfile = fromname.output |
503 | bbpath = get_bb_var('BBPATH') | 507 | searchpath = self.bbpath.split(':') + [os.path.dirname(recipetool.output)] |
504 | searchpath = bbpath.split(':') + [os.path.dirname(recipetool.output)] | ||
505 | plugincontent = [] | 508 | plugincontent = [] |
506 | with open(srcfile) as fh: | 509 | with open(srcfile) as fh: |
507 | plugincontent = fh.readlines() | 510 | plugincontent = fh.readlines() |
@@ -597,17 +600,18 @@ class RecipetoolAppendsrcBase(RecipetoolBase): | |||
597 | 600 | ||
598 | self._try_recipetool_appendsrcfiles(testrecipe, newfiles, expectedfiles=expectedfiles, destdir=destdir, options=options) | 601 | self._try_recipetool_appendsrcfiles(testrecipe, newfiles, expectedfiles=expectedfiles, destdir=destdir, options=options) |
599 | 602 | ||
600 | src_uri = get_bb_var('SRC_URI', testrecipe).split() | 603 | bb_vars = get_bb_vars(['SRC_URI', 'FILE', 'FILESEXTRAPATHS'], testrecipe) |
604 | src_uri = bb_vars['SRC_URI'].split() | ||
601 | for f in expectedfiles: | 605 | for f in expectedfiles: |
602 | if destdir: | 606 | if destdir: |
603 | self.assertIn('file://%s;subdir=%s' % (f, destdir), src_uri) | 607 | self.assertIn('file://%s;subdir=%s' % (f, destdir), src_uri) |
604 | else: | 608 | else: |
605 | self.assertIn('file://%s' % f, src_uri) | 609 | self.assertIn('file://%s' % f, src_uri) |
606 | 610 | ||
607 | recipefile = get_bb_var('FILE', testrecipe) | 611 | recipefile = bb_vars['FILE'] |
608 | bbappendfile = self._check_bbappend(testrecipe, recipefile, self.templayerdir) | 612 | bbappendfile = self._check_bbappend(testrecipe, recipefile, self.templayerdir) |
609 | filesdir = os.path.join(os.path.dirname(bbappendfile), testrecipe) | 613 | filesdir = os.path.join(os.path.dirname(bbappendfile), testrecipe) |
610 | filesextrapaths = get_bb_var('FILESEXTRAPATHS', testrecipe).split(':') | 614 | filesextrapaths = bb_vars['FILESEXTRAPATHS'].split(':') |
611 | self.assertIn(filesdir, filesextrapaths) | 615 | self.assertIn(filesdir, filesextrapaths) |
612 | 616 | ||
613 | 617 | ||
@@ -638,8 +642,9 @@ class RecipetoolAppendsrcTests(RecipetoolAppendsrcBase): | |||
638 | @testcase(1280) | 642 | @testcase(1280) |
639 | def test_recipetool_appendsrcfile_srcdir_basic(self): | 643 | def test_recipetool_appendsrcfile_srcdir_basic(self): |
640 | testrecipe = 'bash' | 644 | testrecipe = 'bash' |
641 | srcdir = get_bb_var('S', testrecipe) | 645 | bb_vars = get_bb_vars(['S', 'WORKDIR'], testrecipe) |
642 | workdir = get_bb_var('WORKDIR', testrecipe) | 646 | srcdir = bb_vars['S'] |
647 | workdir = bb_vars['WORKDIR'] | ||
643 | subdir = os.path.relpath(srcdir, workdir) | 648 | subdir = os.path.relpath(srcdir, workdir) |
644 | self._test_appendsrcfile(testrecipe, 'a-file', srcdir=subdir) | 649 | self._test_appendsrcfile(testrecipe, 'a-file', srcdir=subdir) |
645 | 650 | ||
@@ -664,8 +669,9 @@ class RecipetoolAppendsrcTests(RecipetoolAppendsrcBase): | |||
664 | def test_recipetool_appendsrcfile_replace_file_srcdir(self): | 669 | def test_recipetool_appendsrcfile_replace_file_srcdir(self): |
665 | testrecipe = 'bash' | 670 | testrecipe = 'bash' |
666 | filepath = 'Makefile.in' | 671 | filepath = 'Makefile.in' |
667 | srcdir = get_bb_var('S', testrecipe) | 672 | bb_vars = get_bb_vars(['S', 'WORKDIR'], testrecipe) |
668 | workdir = get_bb_var('WORKDIR', testrecipe) | 673 | srcdir = bb_vars['S'] |
674 | workdir = bb_vars['WORKDIR'] | ||
669 | subdir = os.path.relpath(srcdir, workdir) | 675 | subdir = os.path.relpath(srcdir, workdir) |
670 | 676 | ||
671 | self._test_appendsrcfile(testrecipe, filepath, srcdir=subdir) | 677 | self._test_appendsrcfile(testrecipe, filepath, srcdir=subdir) |