diff options
author | Samantha Jalabert <samantha.jalabert@syslinbit.com> | 2023-09-22 14:46:28 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-09-27 11:47:42 +0100 |
commit | aa8b9d601a8a165f214334350e9a14fb4a2d6421 (patch) | |
tree | 7e24659ac06f133088611d7d58950af5aac4fb51 /meta | |
parent | 1be0c80ab7003c0ff76738d70e5870c886ea3182 (diff) | |
download | poky-aa8b9d601a8a165f214334350e9a14fb4a2d6421.tar.gz |
qa: Add selftest for python3-spdx-tools
(From OE-Core rev: e766fe7a9391cc9348d92ab704ec58c4806e38c6)
Signed-off-by: Marta Rybczynska <mrybczynska@syslinbit.com>
Signed-off-by: Samantha Jalabert <samantha.jalabert@syslinbit.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oeqa/selftest/cases/spdx.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/spdx.py b/meta/lib/oeqa/selftest/cases/spdx.py new file mode 100644 index 0000000000..05fc4e390b --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/spdx.py | |||
@@ -0,0 +1,54 @@ | |||
1 | # | ||
2 | # Copyright OpenEmbedded Contributors | ||
3 | # | ||
4 | # SPDX-License-Identifier: MIT | ||
5 | # | ||
6 | |||
7 | import json | ||
8 | import os | ||
9 | from oeqa.selftest.case import OESelftestTestCase | ||
10 | from oeqa.utils.commands import bitbake, get_bb_var, runCmd | ||
11 | |||
12 | class SPDXCheck(OESelftestTestCase): | ||
13 | |||
14 | @classmethod | ||
15 | def setUpClass(cls): | ||
16 | super(SPDXCheck, cls).setUpClass() | ||
17 | bitbake("python3-spdx-tools-native") | ||
18 | bitbake("-c addto_recipe_sysroot python3-spdx-tools-native") | ||
19 | |||
20 | def check_recipe_spdx(self, high_level_dir, spdx_file, target_name): | ||
21 | config = """ | ||
22 | INHERIT += "create-spdx" | ||
23 | """ | ||
24 | self.write_config(config) | ||
25 | |||
26 | deploy_dir = get_bb_var("DEPLOY_DIR") | ||
27 | machine_var = get_bb_var("MACHINE") | ||
28 | # qemux86-64 creates the directory qemux86_64 | ||
29 | machine_dir = machine_var.replace("-", "_") | ||
30 | |||
31 | full_file_path = os.path.join(deploy_dir, "spdx", machine_dir, high_level_dir, spdx_file) | ||
32 | |||
33 | try: | ||
34 | os.remove(full_file_path) | ||
35 | except FileNotFoundError: | ||
36 | pass | ||
37 | |||
38 | bitbake("%s -c create_spdx" % target_name) | ||
39 | |||
40 | def check_spdx_json(filename): | ||
41 | with open(filename) as f: | ||
42 | report = json.load(f) | ||
43 | self.assertNotEqual(report, None) | ||
44 | self.assertNotEqual(report["SPDXID"], None) | ||
45 | |||
46 | python = os.path.join(get_bb_var('STAGING_BINDIR', 'python3-spdx-tools-native'), 'nativepython3') | ||
47 | validator = os.path.join(get_bb_var('STAGING_BINDIR', 'python3-spdx-tools-native'), 'pyspdxtools') | ||
48 | result = runCmd("{} {} -i {}".format(python, validator, filename)) | ||
49 | |||
50 | self.assertExists(full_file_path) | ||
51 | result = check_spdx_json(full_file_path) | ||
52 | |||
53 | def test_spdx_base_files(self): | ||
54 | self.check_recipe_spdx("packages", "base-files.spdx.json", "base-files") | ||