diff options
Diffstat (limited to 'bitbake')
-rwxr-xr-x | bitbake/bin/bitbake-selftest | 1 | ||||
-rw-r--r-- | bitbake/lib/bb/tests/siggen.py | 91 |
2 files changed, 92 insertions, 0 deletions
diff --git a/bitbake/bin/bitbake-selftest b/bitbake/bin/bitbake-selftest index e84d6a559f..6c0737416b 100755 --- a/bitbake/bin/bitbake-selftest +++ b/bitbake/bin/bitbake-selftest | |||
@@ -27,6 +27,7 @@ tests = ["bb.tests.codeparser", | |||
27 | "bb.tests.parse", | 27 | "bb.tests.parse", |
28 | "bb.tests.persist_data", | 28 | "bb.tests.persist_data", |
29 | "bb.tests.runqueue", | 29 | "bb.tests.runqueue", |
30 | "bb.tests.siggen", | ||
30 | "bb.tests.utils", | 31 | "bb.tests.utils", |
31 | "hashserv.tests", | 32 | "hashserv.tests", |
32 | "layerindexlib.tests.layerindexobj", | 33 | "layerindexlib.tests.layerindexobj", |
diff --git a/bitbake/lib/bb/tests/siggen.py b/bitbake/lib/bb/tests/siggen.py new file mode 100644 index 0000000000..c21ab4e4fb --- /dev/null +++ b/bitbake/lib/bb/tests/siggen.py | |||
@@ -0,0 +1,91 @@ | |||
1 | # | ||
2 | # BitBake Test for lib/bb/siggen.py | ||
3 | # | ||
4 | # Copyright (C) 2020 Jean-François Dagenais | ||
5 | # | ||
6 | # SPDX-License-Identifier: GPL-2.0-only | ||
7 | # | ||
8 | |||
9 | import unittest | ||
10 | import logging | ||
11 | import bb | ||
12 | import time | ||
13 | |||
14 | logger = logging.getLogger('BitBake.TestSiggen') | ||
15 | |||
16 | import bb.siggen | ||
17 | |||
18 | class SiggenTest(unittest.TestCase): | ||
19 | |||
20 | def test_clean_basepath_simple_target_basepath(self): | ||
21 | basepath = '/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask' | ||
22 | expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask' | ||
23 | |||
24 | actual_cleaned = bb.siggen.clean_basepath(basepath) | ||
25 | |||
26 | self.assertEqual(actual_cleaned, expected_cleaned) | ||
27 | |||
28 | def test_clean_basepath_basic_virtual_basepath(self): | ||
29 | basepath = 'virtual:something:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask' | ||
30 | expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask:virtual:something' | ||
31 | |||
32 | actual_cleaned = bb.siggen.clean_basepath(basepath) | ||
33 | |||
34 | self.assertEqual(actual_cleaned, expected_cleaned) | ||
35 | |||
36 | def test_clean_basepath_mc_basepath(self): | ||
37 | basepath = 'mc:somemachine:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask' | ||
38 | expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask:mc:somemachine' | ||
39 | |||
40 | actual_cleaned = bb.siggen.clean_basepath(basepath) | ||
41 | |||
42 | self.assertEqual(actual_cleaned, expected_cleaned) | ||
43 | |||
44 | def test_clean_basepath_virtual_long_prefix_basepath(self): | ||
45 | basepath = 'virtual:something:A:B:C:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask' | ||
46 | expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask:virtual:something:A:B:C' | ||
47 | |||
48 | actual_cleaned = bb.siggen.clean_basepath(basepath) | ||
49 | |||
50 | self.assertEqual(actual_cleaned, expected_cleaned) | ||
51 | |||
52 | def test_clean_basepath_mc_virtual_basepath(self): | ||
53 | basepath = 'mc:somemachine:virtual:something:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask' | ||
54 | expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask:virtual:something:mc:somemachine' | ||
55 | |||
56 | actual_cleaned = bb.siggen.clean_basepath(basepath) | ||
57 | |||
58 | self.assertEqual(actual_cleaned, expected_cleaned) | ||
59 | |||
60 | def test_clean_basepath_mc_virtual_long_prefix_basepath(self): | ||
61 | basepath = 'mc:X:virtual:something:C:B:A:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask' | ||
62 | expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask:virtual:something:C:B:A:mc:X' | ||
63 | |||
64 | actual_cleaned = bb.siggen.clean_basepath(basepath) | ||
65 | |||
66 | self.assertEqual(actual_cleaned, expected_cleaned) | ||
67 | |||
68 | |||
69 | # def test_clean_basepath_performance(self): | ||
70 | # input_basepaths = [ | ||
71 | # 'mc:X:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask', | ||
72 | # 'mc:X:virtual:something:C:B:A:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask', | ||
73 | # 'virtual:something:C:B:A:/different/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask', | ||
74 | # 'virtual:something:A:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask', | ||
75 | # '/this/is/most/common/input/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask', | ||
76 | # '/and/should/be/tested/with/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask', | ||
77 | # '/more/weight/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask', | ||
78 | # ] | ||
79 | |||
80 | # time_start = time.time() | ||
81 | |||
82 | # i = 2000000 | ||
83 | # while i >= 0: | ||
84 | # for basepath in input_basepaths: | ||
85 | # bb.siggen.clean_basepath(basepath) | ||
86 | # i -= 1 | ||
87 | |||
88 | # elapsed = time.time() - time_start | ||
89 | # print('{} ({}s)'.format(self.id(), round(elapsed, 3))) | ||
90 | |||
91 | # self.assertTrue(False) | ||