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