mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 12:59:02 +02:00

The patchtest tests provide vague feedback to the user, and many of them also provide redundant 'fix' strings that could easily be incorporated into the issue messages themselves. Simplify them so that it is more clear what the errors are and how they can be addressed. No recommendation is given when the issue string adequately conveys the issue, e.g. with a missing "LICENSE" entry in a newly-created recipe. (From OE-Core rev: 0bfb3614244ec7aa79b6424bc63f9f2bccdabe98) Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
# Checks related to the patch's LIC_FILES_CHKSUM metadata variable
|
|
#
|
|
# Copyright (C) 2016 Intel Corporation
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
import base
|
|
import os
|
|
from data import PatchTestInput
|
|
|
|
class License(base.Metadata):
|
|
metadata = 'LICENSE'
|
|
invalid_license = 'PATCHTESTINVALID'
|
|
|
|
def setUp(self):
|
|
# these tests just make sense on patches that can be merged
|
|
if not PatchTestInput.repo.canbemerged:
|
|
self.skip('Patch cannot be merged')
|
|
|
|
def test_license_presence(self):
|
|
if not self.added:
|
|
self.skip('No added recipes, skipping test')
|
|
|
|
# TODO: this is a workaround so we can parse the recipe not
|
|
# containing the LICENSE var: add some default license instead
|
|
# of INVALID into auto.conf, then remove this line at the end
|
|
auto_conf = os.path.join(os.environ.get('BUILDDIR'), 'conf', 'auto.conf')
|
|
open_flag = 'w'
|
|
if os.path.exists(auto_conf):
|
|
open_flag = 'a'
|
|
with open(auto_conf, open_flag) as fd:
|
|
for pn in self.added:
|
|
fd.write('LICENSE ??= "%s"\n' % self.invalid_license)
|
|
|
|
no_license = False
|
|
for pn in self.added:
|
|
rd = self.tinfoil.parse_recipe(pn)
|
|
license = rd.getVar(self.metadata)
|
|
if license == self.invalid_license:
|
|
no_license = True
|
|
break
|
|
|
|
# remove auto.conf line or the file itself
|
|
if open_flag == 'w':
|
|
os.remove(auto_conf)
|
|
else:
|
|
fd = open(auto_conf, 'r')
|
|
lines = fd.readlines()
|
|
fd.close()
|
|
with open(auto_conf, 'w') as fd:
|
|
fd.write(''.join(lines[:-1]))
|
|
|
|
if no_license:
|
|
self.fail('Recipe does not have the LICENSE field set.')
|
|
|