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.zip
poky-304d7a08611132ca292aea2484659ccc5b804178.tar.gz
poky-304d7a08611132ca292aea2484659ccc5b804178.tar.bz2
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 e84d6a5..6c07374 100755
--- a/bitbake/bin/bitbake-selftest
+++ b/bitbake/bin/bitbake-selftest
@@ -27,6 +27,7 @@ tests = ["bb.tests.codeparser",
"bb.tests.parse",
"bb.tests.persist_data",
"bb.tests.runqueue",
+ "bb.tests.siggen",
"bb.tests.utils",
"hashserv.tests",
"layerindexlib.tests.layerindexobj",
diff --git a/bitbake/lib/bb/tests/siggen.py b/bitbake/lib/bb/tests/siggen.py
new file mode 100644
index 0000000..c21ab4e
--- /dev/null
+++ b/bitbake/lib/bb/tests/siggen.py
@@ -0,0 +1,91 @@
+#
+# BitBake Test for lib/bb/siggen.py
+#
+# Copyright (C) 2020 Jean-Fran├žois Dagenais
+#
+# SPDX-License-Identifier: GPL-2.0-only
+#
+
+import unittest
+import logging
+import bb
+import time
+
+logger = logging.getLogger('BitBake.TestSiggen')
+
+import bb.siggen
+
+class SiggenTest(unittest.TestCase):
+
+ def test_clean_basepath_simple_target_basepath(self):
+ basepath = '/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask'
+ expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask'
+
+ actual_cleaned = bb.siggen.clean_basepath(basepath)
+
+ self.assertEqual(actual_cleaned, expected_cleaned)
+
+ def test_clean_basepath_basic_virtual_basepath(self):
+ basepath = 'virtual:something:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask'
+ expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask:virtual:something'
+
+ actual_cleaned = bb.siggen.clean_basepath(basepath)
+
+ self.assertEqual(actual_cleaned, expected_cleaned)
+
+ def test_clean_basepath_mc_basepath(self):
+ basepath = 'mc:somemachine:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask'
+ expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask:mc:somemachine'
+
+ actual_cleaned = bb.siggen.clean_basepath(basepath)
+
+ self.assertEqual(actual_cleaned, expected_cleaned)
+
+ def test_clean_basepath_virtual_long_prefix_basepath(self):
+ basepath = 'virtual:something:A:B:C:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask'
+ expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask:virtual:something:A:B:C'
+
+ actual_cleaned = bb.siggen.clean_basepath(basepath)
+
+ self.assertEqual(actual_cleaned, expected_cleaned)
+
+ def test_clean_basepath_mc_virtual_basepath(self):
+ basepath = 'mc:somemachine:virtual:something:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask'
+ expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask:virtual:something:mc:somemachine'
+
+ actual_cleaned = bb.siggen.clean_basepath(basepath)
+
+ self.assertEqual(actual_cleaned, expected_cleaned)
+
+ def test_clean_basepath_mc_virtual_long_prefix_basepath(self):
+ basepath = 'mc:X:virtual:something:C:B:A:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask'
+ expected_cleaned = 'helloworld/helloworld_1.2.3.bb:do_sometask:virtual:something:C:B:A:mc:X'
+
+ actual_cleaned = bb.siggen.clean_basepath(basepath)
+
+ self.assertEqual(actual_cleaned, expected_cleaned)
+
+
+ # def test_clean_basepath_performance(self):
+ # input_basepaths = [
+ # 'mc:X:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask',
+ # 'mc:X:virtual:something:C:B:A:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask',
+ # 'virtual:something:C:B:A:/different/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask',
+ # 'virtual:something:A:/full/path/to/poky/meta/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask',
+ # '/this/is/most/common/input/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask',
+ # '/and/should/be/tested/with/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask',
+ # '/more/weight/recipes-whatever/helloworld/helloworld_1.2.3.bb:do_sometask',
+ # ]
+
+ # time_start = time.time()
+
+ # i = 2000000
+ # while i >= 0:
+ # for basepath in input_basepaths:
+ # bb.siggen.clean_basepath(basepath)
+ # i -= 1
+
+ # elapsed = time.time() - time_start
+ # print('{} ({}s)'.format(self.id(), round(elapsed, 3)))
+
+ # self.assertTrue(False)