summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Francois Dagenais <jeff.dagenais@gmail.com>2020-09-23 09:44:05 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-09-23 20:55:53 +0100
commit304d7a08611132ca292aea2484659ccc5b804178 (patch)
tree1f5154b1128078907e9899c80de8d8e8c5e7d35c
parent005f2951e2118c79d99665ce66d5bc9220f4a0b1 (diff)
downloadpoky-304d7a08611132ca292aea2484659ccc5b804178.tar.gz
bitbake: bitbake: tests/siggen: introduce clean_basepath testcases
While discussing with Richard we thought these might help document and safeguard the basic requirements of clean_basepath. A 'bonus' performance testcase is added but commented out since its runtime is long and test machine specific. It is intended for developers to test before and after their changes to the target function as a due diligence verification. (Bitbake rev: ee41549f26952d5f7af19a9b3d8a8b969866e2ef) Signed-off-by: Jean-Francois Dagenais <jeff.dagenais@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xbitbake/bin/bitbake-selftest1
-rw-r--r--bitbake/lib/bb/tests/siggen.py91
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
9import unittest
10import logging
11import bb
12import time
13
14logger = logging.getLogger('BitBake.TestSiggen')
15
16import bb.siggen
17
18class 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)