[OE-core] [PATCH 10/20] oeqa.selftest.lic-checksum: Split configuration from code

Jose Lamego jose.a.lamego at linux.intel.com
Mon Aug 8 16:22:58 UTC 2016


Improve oeqa-selftest capabilities and UX by placing
test configuration features and variables into a separate
configuration file.

[Yocto 9389]

Signed-off-by: Jose Lamego <jose.a.lamego at linux.intel.com>
---
 meta/lib/oeqa/selftest/conf/lic-checksum.conf |  4 ++++
 meta/lib/oeqa/selftest/lic-checksum.py        | 22 ++++++++++++++++------
 2 files changed, 20 insertions(+), 6 deletions(-)
 create mode 100644 meta/lib/oeqa/selftest/conf/lic-checksum.conf

diff --git a/meta/lib/oeqa/selftest/conf/lic-checksum.conf b/meta/lib/oeqa/selftest/conf/lic-checksum.conf
new file mode 100644
index 0000000..262b8b1
--- /dev/null
+++ b/meta/lib/oeqa/selftest/conf/lic-checksum.conf
@@ -0,0 +1,4 @@
+[LicenseTests]
+nonmatching_checksum_bitbake_cmd = -c populate_lic emptytest
+nonmatching_checksum_error_msg = emptytest: The new md5 checksum is 8d777f385d3dfec8815d20f7496026dc
+nonmatching_checksum_lic_path_md5 = d41d8cd98f00b204e9800998ecf8427e
diff --git a/meta/lib/oeqa/selftest/lic-checksum.py b/meta/lib/oeqa/selftest/lic-checksum.py
index df44c97..78590fc 100644
--- a/meta/lib/oeqa/selftest/lic-checksum.py
+++ b/meta/lib/oeqa/selftest/lic-checksum.py
@@ -5,25 +5,35 @@ from oeqa.selftest.base import oeSelfTest
 from oeqa.utils.commands import bitbake
 from oeqa.utils import CommandError
 from oeqa.utils.decorators import testcase
+from oeqa.utils.readconfig import conffile
+
 
 class LicenseTests(oeSelfTest):
 
+    @classmethod
+    def setUpClass(cls):
+        # Get test configurations from configuration file
+        cls.config = conffile(__file__)
+
     # Verify that changing a license file that has an absolute path causes
     # the license qa to fail due to a mismatched md5sum.
     @testcase(1197)
     def test_nonmatching_checksum(self):
-        bitbake_cmd = '-c populate_lic emptytest'
-        error_msg = 'emptytest: The new md5 checksum is 8d777f385d3dfec8815d20f7496026dc'
-
+        bitbake_cmd = self.config.get(
+                    'LicenseTests', 'nonmatching_checksum_bitbake_cmd')
+        error_msg = self.config.get(
+                  'LicenseTests', 'nonmatching_checksum_error_msg')
+        lic_path_md5 = self.config.get(
+                     'LicenseTests', 'nonmatching_checksum_lic_path_md5')
         lic_file, lic_path = tempfile.mkstemp()
         os.close(lic_file)
         self.track_for_cleanup(lic_path)
 
         self.write_recipeinc('emptytest', """
 INHIBIT_DEFAULT_DEPS = "1"
-LIC_FILES_CHKSUM = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e"
-SRC_URI = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e"
-""" % (lic_path, lic_path))
+LIC_FILES_CHKSUM = "file://%s;md5=%s"
+SRC_URI = "file://%s;md5=%s"
+""" % (lic_path, lic_path_md5, lic_path, lic_path_md5))
         result = bitbake(bitbake_cmd)
 
         with open(lic_path, "w") as f:
-- 
1.8.3.1




More information about the Openembedded-core mailing list