summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/oelib
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/oelib')
-rw-r--r--meta/lib/oeqa/selftest/cases/oelib/buildhistory.py26
-rw-r--r--meta/lib/oeqa/selftest/cases/oelib/elf.py2
-rw-r--r--meta/lib/oeqa/selftest/cases/oelib/license.py24
-rw-r--r--meta/lib/oeqa/selftest/cases/oelib/path.py2
-rw-r--r--meta/lib/oeqa/selftest/cases/oelib/types.py2
-rw-r--r--meta/lib/oeqa/selftest/cases/oelib/utils.py5
6 files changed, 41 insertions, 20 deletions
diff --git a/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py b/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py
index 802a91a488..042ccdd2b4 100644
--- a/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py
+++ b/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py
@@ -1,8 +1,11 @@
1# 1#
2# Copyright OpenEmbedded Contributors
3#
2# SPDX-License-Identifier: MIT 4# SPDX-License-Identifier: MIT
3# 5#
4 6
5import os 7import os
8import sys
6from oeqa.selftest.case import OESelftestTestCase 9from oeqa.selftest.case import OESelftestTestCase
7import tempfile 10import tempfile
8import operator 11import operator
@@ -11,15 +14,14 @@ from oeqa.utils.commands import get_bb_var
11class TestBlobParsing(OESelftestTestCase): 14class TestBlobParsing(OESelftestTestCase):
12 15
13 def setUp(self): 16 def setUp(self):
14 import time
15 self.repo_path = tempfile.mkdtemp(prefix='selftest-buildhistory', 17 self.repo_path = tempfile.mkdtemp(prefix='selftest-buildhistory',
16 dir=get_bb_var('TOPDIR')) 18 dir=get_bb_var('TOPDIR'))
17 19
18 try: 20 try:
19 from git import Repo 21 from git import Repo
20 self.repo = Repo.init(self.repo_path) 22 self.repo = Repo.init(self.repo_path)
21 except ImportError: 23 except ImportError as e:
22 self.skipTest('Python module GitPython is not present') 24 self.skipTest('Python module GitPython is not present (%s) (%s)' % (e, sys.path))
23 25
24 self.test_file = "test" 26 self.test_file = "test"
25 self.var_map = {} 27 self.var_map = {}
@@ -28,6 +30,16 @@ class TestBlobParsing(OESelftestTestCase):
28 import shutil 30 import shutil
29 shutil.rmtree(self.repo_path) 31 shutil.rmtree(self.repo_path)
30 32
33 @property
34 def heads_default(self):
35 """
36 Support repos defaulting to master or to main branch
37 """
38 try:
39 return self.repo.heads.main
40 except AttributeError:
41 return self.repo.heads.master
42
31 def commit_vars(self, to_add={}, to_remove = [], msg="A commit message"): 43 def commit_vars(self, to_add={}, to_remove = [], msg="A commit message"):
32 if len(to_add) == 0 and len(to_remove) == 0: 44 if len(to_add) == 0 and len(to_remove) == 0:
33 return 45 return
@@ -65,10 +77,10 @@ class TestBlobParsing(OESelftestTestCase):
65 changesmap = { "foo-2" : ("2", "8"), "bar" : ("","4"), "bar-2" : ("","5")} 77 changesmap = { "foo-2" : ("2", "8"), "bar" : ("","4"), "bar-2" : ("","5")}
66 78
67 self.commit_vars(to_add = { "foo" : "1", "foo-2" : "2", "foo-3" : "3" }) 79 self.commit_vars(to_add = { "foo" : "1", "foo-2" : "2", "foo-3" : "3" })
68 blob1 = self.repo.heads.master.commit.tree.blobs[0] 80 blob1 = self.heads_default.commit.tree.blobs[0]
69 81
70 self.commit_vars(to_add = { "foo-2" : "8", "bar" : "4", "bar-2" : "5" }) 82 self.commit_vars(to_add = { "foo-2" : "8", "bar" : "4", "bar-2" : "5" })
71 blob2 = self.repo.heads.master.commit.tree.blobs[0] 83 blob2 = self.heads_default.commit.tree.blobs[0]
72 84
73 change_records = compare_dict_blobs(os.path.join(self.repo_path, self.test_file), 85 change_records = compare_dict_blobs(os.path.join(self.repo_path, self.test_file),
74 blob1, blob2, False, False) 86 blob1, blob2, False, False)
@@ -84,10 +96,10 @@ class TestBlobParsing(OESelftestTestCase):
84 defaultmap = { x : ("default", "1") for x in ["PKG", "PKGE", "PKGV", "PKGR"]} 96 defaultmap = { x : ("default", "1") for x in ["PKG", "PKGE", "PKGV", "PKGR"]}
85 97
86 self.commit_vars(to_add = { "foo" : "1" }) 98 self.commit_vars(to_add = { "foo" : "1" })
87 blob1 = self.repo.heads.master.commit.tree.blobs[0] 99 blob1 = self.heads_default.commit.tree.blobs[0]
88 100
89 self.commit_vars(to_add = { "PKG" : "1", "PKGE" : "1", "PKGV" : "1", "PKGR" : "1" }) 101 self.commit_vars(to_add = { "PKG" : "1", "PKGE" : "1", "PKGV" : "1", "PKGR" : "1" })
90 blob2 = self.repo.heads.master.commit.tree.blobs[0] 102 blob2 = self.heads_default.commit.tree.blobs[0]
91 103
92 change_records = compare_dict_blobs(os.path.join(self.repo_path, self.test_file), 104 change_records = compare_dict_blobs(os.path.join(self.repo_path, self.test_file),
93 blob1, blob2, False, False) 105 blob1, blob2, False, False)
diff --git a/meta/lib/oeqa/selftest/cases/oelib/elf.py b/meta/lib/oeqa/selftest/cases/oelib/elf.py
index 5a5f9b4fdf..7bf550b6fd 100644
--- a/meta/lib/oeqa/selftest/cases/oelib/elf.py
+++ b/meta/lib/oeqa/selftest/cases/oelib/elf.py
@@ -1,4 +1,6 @@
1# 1#
2# Copyright OpenEmbedded Contributors
3#
2# SPDX-License-Identifier: MIT 4# SPDX-License-Identifier: MIT
3# 5#
4 6
diff --git a/meta/lib/oeqa/selftest/cases/oelib/license.py b/meta/lib/oeqa/selftest/cases/oelib/license.py
index 6ebbee589f..5eea12e761 100644
--- a/meta/lib/oeqa/selftest/cases/oelib/license.py
+++ b/meta/lib/oeqa/selftest/cases/oelib/license.py
@@ -1,4 +1,6 @@
1# 1#
2# Copyright OpenEmbedded Contributors
3#
2# SPDX-License-Identifier: MIT 4# SPDX-License-Identifier: MIT
3# 5#
4 6
@@ -15,11 +17,11 @@ class SeenVisitor(oe.license.LicenseVisitor):
15 17
16class TestSingleLicense(TestCase): 18class TestSingleLicense(TestCase):
17 licenses = [ 19 licenses = [
18 "GPLv2", 20 "GPL-2.0-only",
19 "LGPL-2.0", 21 "LGPL-2.0-only",
20 "Artistic", 22 "Artistic-1.0",
21 "MIT", 23 "MIT",
22 "GPLv3+", 24 "GPL-3.0-or-later",
23 "FOO_BAR", 25 "FOO_BAR",
24 ] 26 ]
25 invalid_licenses = ["GPL/BSD"] 27 invalid_licenses = ["GPL/BSD"]
@@ -67,9 +69,9 @@ class TestComplexCombinations(TestSimpleCombinations):
67 "FOO & (BAR | BAZ)&MOO": ["FOO", "BAR", "MOO"], 69 "FOO & (BAR | BAZ)&MOO": ["FOO", "BAR", "MOO"],
68 "(ALPHA|(BETA&THETA)|OMEGA)&DELTA": ["OMEGA", "DELTA"], 70 "(ALPHA|(BETA&THETA)|OMEGA)&DELTA": ["OMEGA", "DELTA"],
69 "((ALPHA|BETA)&FOO)|BAZ": ["BETA", "FOO"], 71 "((ALPHA|BETA)&FOO)|BAZ": ["BETA", "FOO"],
70 "(GPL-2.0|Proprietary)&BSD-4-clause&MIT": ["GPL-2.0", "BSD-4-clause", "MIT"], 72 "(GPL-2.0-only|Proprietary)&BSD-4-clause&MIT": ["GPL-2.0-only", "BSD-4-clause", "MIT"],
71 } 73 }
72 preferred = ["BAR", "OMEGA", "BETA", "GPL-2.0"] 74 preferred = ["BAR", "OMEGA", "BETA", "GPL-2.0-only"]
73 75
74class TestIsIncluded(TestCase): 76class TestIsIncluded(TestCase):
75 tests = { 77 tests = {
@@ -87,12 +89,12 @@ class TestIsIncluded(TestCase):
87 [True, ["BAR", "FOOBAR"]], 89 [True, ["BAR", "FOOBAR"]],
88 ("(FOO | BAR) & FOOBAR | BAZ & MOO & BARFOO", None, "FOO"): 90 ("(FOO | BAR) & FOOBAR | BAZ & MOO & BARFOO", None, "FOO"):
89 [True, ["BAZ", "MOO", "BARFOO"]], 91 [True, ["BAZ", "MOO", "BARFOO"]],
90 ("GPL-3.0 & GPL-2.0 & LGPL-2.1 | Proprietary", None, None): 92 ("GPL-3.0-or-later & GPL-2.0-only & LGPL-2.1-only | Proprietary", None, None):
91 [True, ["GPL-3.0", "GPL-2.0", "LGPL-2.1"]], 93 [True, ["GPL-3.0-or-later", "GPL-2.0-only", "LGPL-2.1-only"]],
92 ("GPL-3.0 & GPL-2.0 & LGPL-2.1 | Proprietary", None, "GPL-3.0"): 94 ("GPL-3.0-or-later & GPL-2.0-only & LGPL-2.1-only | Proprietary", None, "GPL-3.0-or-later"):
93 [True, ["Proprietary"]], 95 [True, ["Proprietary"]],
94 ("GPL-3.0 & GPL-2.0 & LGPL-2.1 | Proprietary", None, "GPL-3.0 Proprietary"): 96 ("GPL-3.0-or-later & GPL-2.0-only & LGPL-2.1-only | Proprietary", None, "GPL-3.0-or-later Proprietary"):
95 [False, ["GPL-3.0"]] 97 [False, ["GPL-3.0-or-later"]]
96 } 98 }
97 99
98 def test_tests(self): 100 def test_tests(self):
diff --git a/meta/lib/oeqa/selftest/cases/oelib/path.py b/meta/lib/oeqa/selftest/cases/oelib/path.py
index a1cfa08c09..b963e447e3 100644
--- a/meta/lib/oeqa/selftest/cases/oelib/path.py
+++ b/meta/lib/oeqa/selftest/cases/oelib/path.py
@@ -1,4 +1,6 @@
1# 1#
2# Copyright OpenEmbedded Contributors
3#
2# SPDX-License-Identifier: MIT 4# SPDX-License-Identifier: MIT
3# 5#
4 6
diff --git a/meta/lib/oeqa/selftest/cases/oelib/types.py b/meta/lib/oeqa/selftest/cases/oelib/types.py
index 7eb49e6f95..58318b18b2 100644
--- a/meta/lib/oeqa/selftest/cases/oelib/types.py
+++ b/meta/lib/oeqa/selftest/cases/oelib/types.py
@@ -1,4 +1,6 @@
1# 1#
2# Copyright OpenEmbedded Contributors
3#
2# SPDX-License-Identifier: MIT 4# SPDX-License-Identifier: MIT
3# 5#
4 6
diff --git a/meta/lib/oeqa/selftest/cases/oelib/utils.py b/meta/lib/oeqa/selftest/cases/oelib/utils.py
index a7214beb4c..0cb46425a0 100644
--- a/meta/lib/oeqa/selftest/cases/oelib/utils.py
+++ b/meta/lib/oeqa/selftest/cases/oelib/utils.py
@@ -1,4 +1,6 @@
1# 1#
2# Copyright OpenEmbedded Contributors
3#
2# SPDX-License-Identifier: MIT 4# SPDX-License-Identifier: MIT
3# 5#
4 6
@@ -64,7 +66,7 @@ class TestMultiprocessLaunch(TestCase):
64 import bb 66 import bb
65 67
66 def testfunction(item, d): 68 def testfunction(item, d):
67 if item == "2" or item == "1": 69 if item == "2":
68 raise KeyError("Invalid number %s" % item) 70 raise KeyError("Invalid number %s" % item)
69 return "Found %s" % item 71 return "Found %s" % item
70 72
@@ -99,5 +101,4 @@ class TestMultiprocessLaunch(TestCase):
99 # Assert the function prints exceptions 101 # Assert the function prints exceptions
100 with captured_output() as (out, err): 102 with captured_output() as (out, err):
101 self.assertRaises(bb.BBHandledException, multiprocess_launch, testfunction, ["1", "2", "3", "4", "5", "6"], d, extraargs=(d,)) 103 self.assertRaises(bb.BBHandledException, multiprocess_launch, testfunction, ["1", "2", "3", "4", "5", "6"], d, extraargs=(d,))
102 self.assertIn("KeyError: 'Invalid number 1'", out.getvalue())
103 self.assertIn("KeyError: 'Invalid number 2'", out.getvalue()) 104 self.assertIn("KeyError: 'Invalid number 2'", out.getvalue())