blob: 2d0b805b90fffda781823ccbce55b28e7a0eae7b [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)
Patrick Williams7784c422022-11-17 07:29:11 -060031 self.delete_recipeinc('emptytest')
Patrick Williams03907ee2022-05-01 06:28:52 -050032
33
Brad Bishopd7bf8c12018-02-25 22:55:05 -050034 # Verify that changing a license file that has an absolute path causes
35 # the license qa to fail due to a mismatched md5sum.
Brad Bishopd7bf8c12018-02-25 22:55:05 -050036 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
Patrick Williams213cb262021-08-07 19:21:33 -050044 self.write_config("INHERIT:remove = \"report-error\"")
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080045
Brad Bishopd7bf8c12018-02-25 22:55:05 -050046 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
Brad Bishopd7bf8c12018-02-25 22:55:05 -050056 result = bitbake(bitbake_cmd, ignore_status=True)
Patrick Williams7784c422022-11-17 07:29:11 -060057 self.delete_recipeinc('emptytest')
Brad Bishopd7bf8c12018-02-25 22:55:05 -050058 if error_msg not in result.output:
59 raise AssertionError(result.output)