blob: 5897a396d93cc557f48cc9774fcc5234d7dcacad [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Brad Bishopc342db32019-05-15 21:57:59 -04004# SPDX-License-Identifier: MIT
5#
6
Brad Bishopd7bf8c12018-02-25 22:55:05 -05007import os
8import tempfile
Patrick Williams03907ee2022-05-01 06:28:52 -05009import urllib
Brad Bishopd7bf8c12018-02-25 22:55:05 -050010
11from oeqa.selftest.case import OESelftestTestCase
12from oeqa.utils.commands import bitbake
Brad Bishopd7bf8c12018-02-25 22:55:05 -050013
14class LicenseTests(OESelftestTestCase):
15
Patrick Williams03907ee2022-05-01 06:28:52 -050016 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
32
Brad Bishopd7bf8c12018-02-25 22:55:05 -050033 # Verify that changing a license file that has an absolute path causes
34 # the license qa to fail due to a mismatched md5sum.
Brad Bishopd7bf8c12018-02-25 22:55:05 -050035 def test_nonmatching_checksum(self):
36 bitbake_cmd = '-c populate_lic emptytest'
37 error_msg = 'emptytest: The new md5 checksum is 8d777f385d3dfec8815d20f7496026dc'
38
39 lic_file, lic_path = tempfile.mkstemp()
40 os.close(lic_file)
41 self.track_for_cleanup(lic_path)
42
Patrick Williams213cb262021-08-07 19:21:33 -050043 self.write_config("INHERIT:remove = \"report-error\"")
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080044
Brad Bishopd7bf8c12018-02-25 22:55:05 -050045 self.write_recipeinc('emptytest', """
46INHIBIT_DEFAULT_DEPS = "1"
47LIC_FILES_CHKSUM = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e"
48SRC_URI = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e"
49""" % (lic_path, lic_path))
50 result = bitbake(bitbake_cmd)
51
52 with open(lic_path, "w") as f:
53 f.write("data")
54
Brad Bishopd7bf8c12018-02-25 22:55:05 -050055 result = bitbake(bitbake_cmd, ignore_status=True)
56 if error_msg not in result.output:
57 raise AssertionError(result.output)