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>
81 lines
3.3 KiB
Python
81 lines
3.3 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 re
|
|
from data import PatchTestInput, PatchTestDataStore
|
|
|
|
class LicFilesChkSum(base.Metadata):
|
|
metadata = 'LIC_FILES_CHKSUM'
|
|
license = 'LICENSE'
|
|
closed = 'CLOSED'
|
|
lictag = 'License-Update'
|
|
lictag_re = re.compile("^%s:" % lictag, re.MULTILINE)
|
|
|
|
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_lic_files_chksum_presence(self):
|
|
if not self.added:
|
|
self.skip('No added recipes, skipping test')
|
|
|
|
for pn in self.added:
|
|
rd = self.tinfoil.parse_recipe(pn)
|
|
pathname = rd.getVar('FILE')
|
|
# we are not interested in images
|
|
if '/images/' in pathname:
|
|
continue
|
|
lic_files_chksum = rd.getVar(self.metadata)
|
|
if rd.getVar(self.license) == self.closed:
|
|
continue
|
|
if not lic_files_chksum:
|
|
self.fail('%s is missing in newly added recipe' % self.metadata)
|
|
|
|
def pretest_lic_files_chksum_modified_not_mentioned(self):
|
|
if not self.modified:
|
|
self.skip('No modified recipes, skipping pretest')
|
|
# get the proper metadata values
|
|
for pn in self.modified:
|
|
rd = self.tinfoil.parse_recipe(pn)
|
|
pathname = rd.getVar('FILE')
|
|
# we are not interested in images
|
|
if '/images/' in pathname:
|
|
continue
|
|
PatchTestDataStore['%s-%s-%s' % (self.shortid(),self.metadata,pn)] = rd.getVar(self.metadata)
|
|
|
|
def test_lic_files_chksum_modified_not_mentioned(self):
|
|
if not self.modified:
|
|
self.skip('No modified recipes, skipping test')
|
|
|
|
# get the proper metadata values
|
|
for pn in self.modified:
|
|
rd = self.tinfoil.parse_recipe(pn)
|
|
pathname = rd.getVar('FILE')
|
|
# we are not interested in images
|
|
if '/images/' in pathname:
|
|
continue
|
|
PatchTestDataStore['%s-%s-%s' % (self.shortid(),self.metadata,pn)] = rd.getVar(self.metadata)
|
|
# compare if there were changes between pre-merge and merge
|
|
for pn in self.modified:
|
|
pretest = PatchTestDataStore['pre%s-%s-%s' % (self.shortid(),self.metadata, pn)]
|
|
test = PatchTestDataStore['%s-%s-%s' % (self.shortid(),self.metadata, pn)]
|
|
|
|
# TODO: this is workaround to avoid false-positives when pretest metadata is empty (not reason found yet)
|
|
# For more info, check bug 12284
|
|
if not pretest:
|
|
return
|
|
|
|
if pretest != test:
|
|
# if any patch on the series contain reference on the metadata, fail
|
|
for commit in self.commits:
|
|
if self.lictag_re.search(commit.commit_message):
|
|
break
|
|
else:
|
|
self.fail('LIC_FILES_CHKSUM changed on target %s but there is no "%s" tag in commit message. Include it with a brief description' % (pn, self.lictag),
|
|
data=[('Current checksum', pretest), ('New checksum', test)])
|