Skip to content

Commit bd69cce

Browse files
committed
test: removal of binaries for tests in test_tags.py
See #1105
1 parent 412b43b commit bd69cce

File tree

7 files changed

+81
-19
lines changed

7 files changed

+81
-19
lines changed

rpmlint/checks/TagsCheck.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -708,14 +708,16 @@ def _check_forbidden_controlchar(self, pkg):
708708
Output info to STDOUT
709709
"""
710710

711+
# Check if a package contains forbidden-controlchar in Requires: tag.
711712
for tagname, items in (
712713
('Provides', pkg.provides),
713714
('Conflicts', pkg.conflicts),
714715
('Obsoletes', pkg.obsoletes),
715716
('Supplements', pkg.supplements),
716717
('Suggests', pkg.suggests),
717718
('Enhances', pkg.enhances),
718-
('Recommends', pkg.recommends)):
719+
('Recommends', pkg.recommends),
720+
('Requires', pkg.requires)):
719721
for item in items:
720722
dep = Pkg.has_forbidden_controlchars(item)
721723
if dep:
@@ -726,15 +728,6 @@ def _check_forbidden_controlchar(self, pkg):
726728
value = Pkg.formatRequire(*item)
727729
self._unexpanded_macros(pkg, f'{tagname} {value}', value)
728730

729-
# Check if a package contains forbidden-controlchar in Requires: tag.
730-
for pkg_token in (pkg.requires):
731-
dep = Pkg.has_forbidden_controlchars(pkg_token)
732-
if dep:
733-
self.output.add_info('E',
734-
pkg,
735-
'forbidden-controlchar-found',
736-
f'Requires: {dep}')
737-
738731
def _check_self_obsoletion(self, pkg):
739732
"""Trigger check self-obsoletion
740733

rpmlint/pkg.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,9 @@ def __init__(self, name, is_source=False):
843843
self.header[getattr(rpm, f'RPMTAG_{tagname}FLAGS')] = []
844844
self.header[getattr(rpm, f'RPMTAG_{tagname}VERSION')] = []
845845
self.header[rpm.RPMTAG_FILENAMES] = []
846+
self.header[rpm.RPMTAG_CHANGELOGNAME] = []
847+
self.header[rpm.RPMTAG_CHANGELOGTEXT] = []
848+
self.header[rpm.RPMTAG_CHANGELOGTIME] = []
846849

847850
def add_file(self, path, name):
848851
pkgfile = PkgFile(name)
@@ -968,6 +971,13 @@ def add_header(self, header):
968971
self.header[getattr(rpm, f'RPMTAG_{tagname}VERSION')].append(version)
969972
continue
970973

974+
if k == 'changelog':
975+
for name, text, time_ in v:
976+
self.header[rpm.RPMTAG_CHANGELOGNAME].append(name)
977+
self.header[rpm.RPMTAG_CHANGELOGTEXT].append(text)
978+
self.header[rpm.RPMTAG_CHANGELOGTIME].append(time_)
979+
continue
980+
971981
key = getattr(rpm, f'RPMTAG_{k}'.upper())
972982
self.header[key] = v
973983

-7.21 KB
Binary file not shown.
-61 KB
Binary file not shown.
Binary file not shown.

test/mockdata/mock_tags.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,59 @@
143143
'license': 'GPL-2.0+ WITH 389-exception',
144144
},
145145
)
146+
147+
148+
ForbiddenControlCharPackage = get_tested_mock_package(
149+
lazyload=True,
150+
name='xtables-addons-kmp-default',
151+
files=[],
152+
header={
153+
'requires': [
154+
'ksym(default:',
155+
'ksym(default:\b)',
156+
'ksym(default:HX_memmem) = 55bffe85',
157+
'ksym(default:PDE_DATA) = e515007f',
158+
'ksym(default:__alloc_skb) = a57f3289'
159+
],
160+
'provides': [],
161+
'arch': 'x86_64',
162+
'name': 'xtables-addons-kmp-default',
163+
'version': '0',
164+
'release': '0',
165+
},
166+
)
167+
168+
169+
ForbiddenControlCharChangelogPackage = get_tested_mock_package(
170+
lazyload=True,
171+
name='ruby2.6-rubygem-fast_gettext',
172+
files=[],
173+
header={
174+
'requires': [],
175+
'provides': [],
176+
'arch': 'x86_64',
177+
'name': 'ruby2.6-rubygem-fast_gettext',
178+
'version': '0',
179+
'release': '0',
180+
'changelog': [
181+
['[email protected]', 'Text', 1557057600],
182+
['[email protected]', 'Forbiddeen character \x04 in changelog', 1557057600],
183+
],
184+
},
185+
)
186+
187+
188+
ForbiddenControlCharAllPackage = ForbiddenControlCharPackage.clone(
189+
extend=True,
190+
name='SpecCheck4',
191+
files=[],
192+
header={
193+
'requires': ['/bin/sh', 'require\x06', 'rpmlib(CompressedFileNames) <= 3.0.4-1'],
194+
'provides': ['SpecCheck4 = 0.0.1-0', 'SpecCheck4(x86-64) = 0.0.1-0', 'provide\x06'],
195+
'obsoletes': ['obsoletes\x06'],
196+
'conflicts': ['conflicts\x06'],
197+
'changelog': [
198+
['[email protected]', 'changelog entry .... \x06', 1557057600],
199+
],
200+
},
201+
)

test/test_tags.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from mockdata.mock_tags import (
22
FooDevelPackage,
3+
ForbiddenControlCharAllPackage,
4+
ForbiddenControlCharChangelogPackage,
5+
ForbiddenControlCharPackage,
36
FuseCommonPackage,
47
InvalidExceptionPackage,
58
MissingProvidesPackage,
@@ -125,26 +128,26 @@ def test_valid_license_exception_begin_grouping(tmp_path, package, tagscheck):
125128
assert 'W: invalid-license-exception' not in out
126129

127130

128-
@pytest.mark.parametrize('package', ['binary/xtables-addons-kmp-default'])
129-
def test_forbidden_controlchar_found_requires(tmp_path, package, tagscheck):
131+
@pytest.mark.parametrize('package', [ForbiddenControlCharPackage])
132+
def test_forbidden_controlchar_found_requires(package, tagscheck):
130133
output, test = tagscheck
131-
test.check(get_tested_package(package, tmp_path))
134+
test.check(package)
132135
out = output.print_results(output.results)
133136
assert 'E: forbidden-controlchar-found Requires:' in out
134137

135138

136-
@pytest.mark.parametrize('package', ['binary/ruby2.6-rubygem-fast_gettext'])
137-
def test_forbidden_controlchar_found_changelog(tmp_path, package, tagscheck):
139+
@pytest.mark.parametrize('package', [ForbiddenControlCharChangelogPackage])
140+
def test_forbidden_controlchar_found_changelog(package, tagscheck):
138141
output, test = tagscheck
139-
test.check(get_tested_package(package, tmp_path))
142+
test.check(package)
140143
out = output.print_results(output.results)
141144
assert 'E: forbidden-controlchar-found %changelog' in out
142145

143146

144-
@pytest.mark.parametrize('package', ['binary/SpecCheck4'])
145-
def test_forbidden_controlchar_found(tmp_path, package, tagscheck):
147+
@pytest.mark.parametrize('package', [ForbiddenControlCharAllPackage])
148+
def test_forbidden_controlchar_found(package, tagscheck):
146149
output, test = tagscheck
147-
test.check(get_tested_package(package, tmp_path))
150+
test.check(package)
148151
out = output.print_results(output.results)
149152
assert 'E: forbidden-controlchar-found Requires:' in out
150153
assert 'E: forbidden-controlchar-found Provides:' in out

0 commit comments

Comments
 (0)