blob: 8f1226e6a5fde058b70081fad4593c2a2ccb7a23 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
2# SPDX-License-Identifier: MIT
3#
4
Brad Bishopd7bf8c12018-02-25 22:55:05 -05005import os
6import tempfile
Patrick Williams03907ee2022-05-01 06:28:52 -05007import urllib
Brad Bishopd7bf8c12018-02-25 22:55:05 -05008
9from oeqa.selftest.case import OESelftestTestCase
10from oeqa.utils.commands import bitbake
Brad Bishopd7bf8c12018-02-25 22:55:05 -050011
12class LicenseTests(OESelftestTestCase):
13
Patrick Williams03907ee2022-05-01 06:28:52 -050014 def test_checksum_with_space(self):
15 bitbake_cmd = '-c populate_lic emptytest'
16
17 lic_file, lic_path = tempfile.mkstemp(" -afterspace")
18 os.close(lic_file)
19 #self.track_for_cleanup(lic_path)
20
21 self.write_config("INHERIT:remove = \"report-error\"")
22
23 self.write_recipeinc('emptytest', """
24INHIBIT_DEFAULT_DEPS = "1"
25LIC_FILES_CHKSUM = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e"
26SRC_URI = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e"
27""" % (urllib.parse.quote(lic_path), urllib.parse.quote(lic_path)))
28 result = bitbake(bitbake_cmd)
29
30
Brad Bishopd7bf8c12018-02-25 22:55:05 -050031 # Verify that changing a license file that has an absolute path causes
32 # the license qa to fail due to a mismatched md5sum.
Brad Bishopd7bf8c12018-02-25 22:55:05 -050033 def test_nonmatching_checksum(self):
34 bitbake_cmd = '-c populate_lic emptytest'
35 error_msg = 'emptytest: The new md5 checksum is 8d777f385d3dfec8815d20f7496026dc'
36
37 lic_file, lic_path = tempfile.mkstemp()
38 os.close(lic_file)
39 self.track_for_cleanup(lic_path)
40
Patrick Williams213cb262021-08-07 19:21:33 -050041 self.write_config("INHERIT:remove = \"report-error\"")
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080042
Brad Bishopd7bf8c12018-02-25 22:55:05 -050043 self.write_recipeinc('emptytest', """
44INHIBIT_DEFAULT_DEPS = "1"
45LIC_FILES_CHKSUM = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e"
46SRC_URI = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e"
47""" % (lic_path, lic_path))
48 result = bitbake(bitbake_cmd)
49
50 with open(lic_path, "w") as f:
51 f.write("data")
52
Brad Bishopd7bf8c12018-02-25 22:55:05 -050053 result = bitbake(bitbake_cmd, ignore_status=True)
54 if error_msg not in result.output:
55 raise AssertionError(result.output)