diff options
Diffstat (limited to 'meta/lib/patchtest/tests/test_metadata_license.py')
-rw-r--r-- | meta/lib/patchtest/tests/test_metadata_license.py | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/meta/lib/patchtest/tests/test_metadata_license.py b/meta/lib/patchtest/tests/test_metadata_license.py deleted file mode 100644 index 1a7f09b747..0000000000 --- a/meta/lib/patchtest/tests/test_metadata_license.py +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
1 | # Checks related to the patch's LIC_FILES_CHKSUM metadata variable | ||
2 | # | ||
3 | # Copyright (C) 2016 Intel Corporation | ||
4 | # | ||
5 | # SPDX-License-Identifier: GPL-2.0-only | ||
6 | |||
7 | import base | ||
8 | import os | ||
9 | from data import PatchTestInput | ||
10 | |||
11 | class License(base.Metadata): | ||
12 | metadata = 'LICENSE' | ||
13 | invalid_license = 'PATCHTESTINVALID' | ||
14 | |||
15 | def test_license_presence(self): | ||
16 | if not self.added: | ||
17 | self.skip('No added recipes, skipping test') | ||
18 | |||
19 | # TODO: this is a workaround so we can parse the recipe not | ||
20 | # containing the LICENSE var: add some default license instead | ||
21 | # of INVALID into auto.conf, then remove this line at the end | ||
22 | auto_conf = os.path.join(os.environ.get('BUILDDIR'), 'conf', 'auto.conf') | ||
23 | open_flag = 'w' | ||
24 | if os.path.exists(auto_conf): | ||
25 | open_flag = 'a' | ||
26 | with open(auto_conf, open_flag) as fd: | ||
27 | for pn in self.added: | ||
28 | fd.write('LICENSE ??= "%s"\n' % self.invalid_license) | ||
29 | |||
30 | no_license = False | ||
31 | for pn in self.added: | ||
32 | rd = self.tinfoil.parse_recipe(pn) | ||
33 | license = rd.getVar(self.metadata) | ||
34 | if license == self.invalid_license: | ||
35 | no_license = True | ||
36 | break | ||
37 | |||
38 | # remove auto.conf line or the file itself | ||
39 | if open_flag == 'w': | ||
40 | os.remove(auto_conf) | ||
41 | else: | ||
42 | fd = open(auto_conf, 'r') | ||
43 | lines = fd.readlines() | ||
44 | fd.close() | ||
45 | with open(auto_conf, 'w') as fd: | ||
46 | fd.write(''.join(lines[:-1])) | ||
47 | |||
48 | if no_license: | ||
49 | self.fail('Recipe does not have the LICENSE field set.') | ||
50 | |||