Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
| 2 | # SPDX-License-Identifier: MIT |
| 3 | # |
| 4 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 5 | import os |
| 6 | import tempfile |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame^] | 7 | import urllib |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 8 | |
| 9 | from oeqa.selftest.case import OESelftestTestCase |
| 10 | from oeqa.utils.commands import bitbake |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 11 | |
| 12 | class LicenseTests(OESelftestTestCase): |
| 13 | |
Patrick Williams | 03907ee | 2022-05-01 06:28:52 -0500 | [diff] [blame^] | 14 | 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', """ |
| 24 | INHIBIT_DEFAULT_DEPS = "1" |
| 25 | LIC_FILES_CHKSUM = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e" |
| 26 | SRC_URI = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e" |
| 27 | """ % (urllib.parse.quote(lic_path), urllib.parse.quote(lic_path))) |
| 28 | result = bitbake(bitbake_cmd) |
| 29 | |
| 30 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 31 | # Verify that changing a license file that has an absolute path causes |
| 32 | # the license qa to fail due to a mismatched md5sum. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 33 | 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 Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 41 | self.write_config("INHERIT:remove = \"report-error\"") |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 42 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 43 | self.write_recipeinc('emptytest', """ |
| 44 | INHIBIT_DEFAULT_DEPS = "1" |
| 45 | LIC_FILES_CHKSUM = "file://%s;md5=d41d8cd98f00b204e9800998ecf8427e" |
| 46 | SRC_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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 53 | result = bitbake(bitbake_cmd, ignore_status=True) |
| 54 | if error_msg not in result.output: |
| 55 | raise AssertionError(result.output) |