1# 2# Copyright OpenEmbedded Contributors 3# 4# SPDX-License-Identifier: MIT 5# 6 7import os 8import tempfile 9import urllib 10 11from oeqa.selftest.case import OESelftestTestCase 12from oeqa.utils.commands import bitbake 13 14class LicenseTests(OESelftestTestCase): 15 16 def test_checksum_with_space(self): 17 bitbake_cmd = '-c populate_lic emptytest' 18 19 lic_file, lic_path = tempfile.mkstemp(" -afterspace") 20 os.close(lic_file) 21 #self.track_for_cleanup(lic_path) 22 23 self.write_config("INHERIT:remove = \"report-error\"") 24 25 self.write_recipeinc('emptytest', """ 26INHIBIT_DEFAULT_DEPS = "1" 27LIC_FILES_CHKSUM = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e" 28SRC_URI = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e" 29""" % (urllib.parse.quote(lic_path), urllib.parse.quote(lic_path))) 30 result = bitbake(bitbake_cmd) 31 self.delete_recipeinc('emptytest') 32 33 34 # Verify that changing a license file that has an absolute path causes 35 # the license qa to fail due to a mismatched md5sum. 36 def test_nonmatching_checksum(self): 37 bitbake_cmd = '-c populate_lic emptytest' 38 error_msg = 'emptytest: The new md5 checksum is 8d777f385d3dfec8815d20f7496026dc' 39 40 lic_file, lic_path = tempfile.mkstemp() 41 os.close(lic_file) 42 self.track_for_cleanup(lic_path) 43 44 self.write_config("INHERIT:remove = \"report-error\"") 45 46 self.write_recipeinc('emptytest', """ 47INHIBIT_DEFAULT_DEPS = "1" 48LIC_FILES_CHKSUM = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e" 49SRC_URI = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e" 50""" % (lic_path, lic_path)) 51 result = bitbake(bitbake_cmd) 52 53 with open(lic_path, "w") as f: 54 f.write("data") 55 56 result = bitbake(bitbake_cmd, ignore_status=True) 57 self.delete_recipeinc('emptytest') 58 if error_msg not in result.output: 59 raise AssertionError(result.output) 60