diff options
| -rw-r--r-- | meta/lib/oeqa/selftest/cases/recipetool.py | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py index 95e4753976..1c73b2c5e0 100644 --- a/meta/lib/oeqa/selftest/cases/recipetool.py +++ b/meta/lib/oeqa/selftest/cases/recipetool.py | |||
| @@ -541,9 +541,13 @@ class RecipetoolTests(RecipetoolBase): | |||
| 541 | 541 | ||
| 542 | @classmethod | 542 | @classmethod |
| 543 | def setUpClass(cls): | 543 | def setUpClass(cls): |
| 544 | import sys | ||
| 545 | |||
| 544 | super(RecipetoolTests, cls).setUpClass() | 546 | super(RecipetoolTests, cls).setUpClass() |
| 545 | bb_vars = get_bb_vars(['BBPATH']) | 547 | bb_vars = get_bb_vars(['BBPATH']) |
| 546 | cls.bbpath = bb_vars['BBPATH'] | 548 | cls.bbpath = bb_vars['BBPATH'] |
| 549 | libpath = os.path.join(get_bb_var('COREBASE'), 'scripts', 'lib', 'recipetool') | ||
| 550 | sys.path.insert(0, libpath) | ||
| 547 | 551 | ||
| 548 | def _copy_file_with_cleanup(self, srcfile, basedstdir, *paths): | 552 | def _copy_file_with_cleanup(self, srcfile, basedstdir, *paths): |
| 549 | dstdir = basedstdir | 553 | dstdir = basedstdir |
| @@ -588,6 +592,66 @@ class RecipetoolTests(RecipetoolBase): | |||
| 588 | with open(srcfile, 'w') as fh: | 592 | with open(srcfile, 'w') as fh: |
| 589 | fh.writelines(plugincontent) | 593 | fh.writelines(plugincontent) |
| 590 | 594 | ||
| 595 | def test_recipetool_split_pkg_licenses(self): | ||
| 596 | from create import split_pkg_licenses | ||
| 597 | licvalues = [ | ||
| 598 | # Duplicate licenses | ||
| 599 | ('BSD-2-Clause', 'x/COPYING', None), | ||
| 600 | ('BSD-2-Clause', 'x/LICENSE', None), | ||
| 601 | # Multiple licenses | ||
| 602 | ('MIT', 'x/a/LICENSE.MIT', None), | ||
| 603 | ('ISC', 'x/a/LICENSE.ISC', None), | ||
| 604 | # Alternative licenses | ||
| 605 | ('(MIT | ISC)', 'x/b/LICENSE', None), | ||
| 606 | # Alternative licenses without brackets | ||
| 607 | ('MIT | BSD-2-Clause', 'x/c/LICENSE', None), | ||
| 608 | # Multi licenses with alternatives | ||
| 609 | ('MIT', 'x/d/COPYING', None), | ||
| 610 | ('MIT | BSD-2-Clause', 'x/d/LICENSE', None), | ||
| 611 | # Multi licenses with alternatives and brackets | ||
| 612 | ('Apache-2.0 & ((MIT | ISC) & BSD-3-Clause)', 'x/e/LICENSE', None) | ||
| 613 | ] | ||
| 614 | packages = { | ||
| 615 | '${PN}': '', | ||
| 616 | 'a': 'x/a', | ||
| 617 | 'b': 'x/b', | ||
| 618 | 'c': 'x/c', | ||
| 619 | 'd': 'x/d', | ||
| 620 | 'e': 'x/e', | ||
| 621 | 'f': 'x/f', | ||
| 622 | 'g': 'x/g', | ||
| 623 | } | ||
| 624 | fallback_licenses = { | ||
| 625 | # Ignored | ||
| 626 | 'a': 'BSD-3-Clause', | ||
| 627 | # Used | ||
| 628 | 'f': 'BSD-3-Clause' | ||
| 629 | } | ||
| 630 | outlines = [] | ||
| 631 | outlicenses = split_pkg_licenses(licvalues, packages, outlines, fallback_licenses) | ||
| 632 | expected_outlicenses = { | ||
| 633 | '${PN}': ['BSD-2-Clause'], | ||
| 634 | 'a': ['ISC', 'MIT'], | ||
| 635 | 'b': ['(ISC | MIT)'], | ||
| 636 | 'c': ['(BSD-2-Clause | MIT)'], | ||
| 637 | 'd': ['(BSD-2-Clause | MIT)', 'MIT'], | ||
| 638 | 'e': ['(ISC | MIT)', 'Apache-2.0', 'BSD-3-Clause'], | ||
| 639 | 'f': ['BSD-3-Clause'], | ||
| 640 | 'g': ['Unknown'] | ||
| 641 | } | ||
| 642 | self.assertEqual(outlicenses, expected_outlicenses) | ||
| 643 | expected_outlines = [ | ||
| 644 | 'LICENSE:${PN} = "BSD-2-Clause"', | ||
| 645 | 'LICENSE:a = "ISC & MIT"', | ||
| 646 | 'LICENSE:b = "(ISC | MIT)"', | ||
| 647 | 'LICENSE:c = "(BSD-2-Clause | MIT)"', | ||
| 648 | 'LICENSE:d = "(BSD-2-Clause | MIT) & MIT"', | ||
| 649 | 'LICENSE:e = "(ISC | MIT) & Apache-2.0 & BSD-3-Clause"', | ||
| 650 | 'LICENSE:f = "BSD-3-Clause"', | ||
| 651 | 'LICENSE:g = "Unknown"' | ||
| 652 | ] | ||
| 653 | self.assertEqual(outlines, expected_outlines) | ||
| 654 | |||
| 591 | 655 | ||
| 592 | class RecipetoolAppendsrcBase(RecipetoolBase): | 656 | class RecipetoolAppendsrcBase(RecipetoolBase): |
| 593 | def _try_recipetool_appendsrcfile(self, testrecipe, newfile, destfile, options, expectedlines, expectedfiles): | 657 | def _try_recipetool_appendsrcfile(self, testrecipe, newfile, destfile, options, expectedlines, expectedfiles): |
