Skip to content

Commit

Permalink
Merge pull request #1245 from i12momal/rama2
Browse files Browse the repository at this point in the history
Replace bin in easy tests
  • Loading branch information
danigm authored Aug 8, 2024
2 parents 2241a48 + 8ca86ae commit b756e42
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 35 deletions.
13 changes: 3 additions & 10 deletions test/files/rpmlint-test.desktop
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
[Desktop Entry]
Name=rpmlint-test
Name[de]=rpmlint-test umlaut äöü
Name[x-test]=xxrpmlint-testxx
MimeType=application/x-rpm;
Name[de]=rpmlint-test umlaut äöü
Exec=rpmlint-test file.file
Icon=chameleon_v_balíku
Icon=chameleon_v_baliku
Type=Application
InitialPreference=5
NoDisplay=false
GenericName=rpmlint testcase
GenericName[x-test]=xxrpmlint testcasexx
Categories=System;PackageManager;
Keywords=software;package;
Keywords[x-test]=xxsoftwarexx;xxpackagexx;
Categories=Game;Amusement;
17 changes: 17 additions & 0 deletions test/mockdata/mock_LSB.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from Testing import get_tested_mock_package


LSB = get_tested_mock_package(
files={
'/usr/sbin/fping',
'/usr/share/doc/packages/fPing',
'/usr/share/doc/packages/fPing/CHANGELOG.md',
'/usr/share/licenses/fPing',
'/usr/share/licenses/fPing/COPYING',
'/usr/share/man/man8/fping.8.gz',
},
header={
'name': 'fPing@1',
'version': '1.0_beta',
'release': '1.0-beta'
})
7 changes: 7 additions & 0 deletions test/mockdata/mock_pam_modules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from Testing import get_tested_mock_package

PAMMODULES = get_tested_mock_package(
files={
'/usr/lib64/security/pam-module.so': {'content': ''}
}
)
51 changes: 51 additions & 0 deletions test/mockdata/mock_sysvinitonsystemd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from Testing import get_tested_mock_package


SYSVINITONSYSTEMD = get_tested_mock_package(
files={
'/etc/init.d/boot.script': {'content': ''},
'/etc/init.d/weekly.script': {'content': ''}
},
header={
'requires': ['insserv']
})


SYSVINITONSYSTEMD2 = get_tested_mock_package(
files={
'/etc/init.d/bar': {'content': """
#! /bin/bash
### BEGIN INIT INFO
# Provides: foo
# Required-Start: $local_fs $network
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: foo service
# Description: Run Foo service
### END INIT INFO
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting Foo..."
sudo -u foo-user bash -c 'cd /path/to/scripts/ && ./start-foo.sh'
;;
stop)
echo "Stopping Foo..."
sudo -u foo-user bash -c 'cd /path/to/scripts/ && ./stop-foo.sh'
sleep 2
;;
*)
echo "Usage: /etc/init.d/foo {start|stop}"
exit 1
;;
esac
exit 0
"""},
'/usr/lib/systemd/system/bar.service': {},
'/usr/lib/systemd/system/foo.service': {}},
header={
'requires': ['insserv']})
9 changes: 5 additions & 4 deletions test/test_LSB.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from mockdata.mock_LSB import LSB
import pytest
from rpmlint.checks.LSBCheck import LSBCheck
from rpmlint.filter import Filter

from Testing import CONFIG, get_tested_package
from Testing import CONFIG


@pytest.fixture(scope='function', autouse=True)
Expand All @@ -13,13 +14,13 @@ def lsbcheck():
return output, test


@pytest.mark.parametrize('package', ['binary/fPing'])
def test_LSB_compliance(tmp_path, package, lsbcheck):
@pytest.mark.parametrize('package', [LSB])
def test_LSB_compliance(package, lsbcheck):
"""
Check that the package name, version and release number are LSB compliant.
"""
output, test = lsbcheck
test.check(get_tested_package(package, tmp_path))
test.check(package)
out = output.print_results(output.results)

# Check invalid package name
Expand Down
18 changes: 8 additions & 10 deletions test/test_menuxdg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# TODO: Add MXDG4 when the test is corrected
from mockdata.mock_menuxdg import MENUXDG, MENUXDG1, MENUXDG2, MENUXDG3, MENUXDG5
from mockdata.mock_menuxdg import MENUXDG, MENUXDG1, MENUXDG2, MENUXDG3, MENUXDG4, MENUXDG5
import pytest
from rpmlint.checks.MenuXDGCheck import MenuXDGCheck
from rpmlint.filter import Filter
Expand Down Expand Up @@ -56,14 +55,13 @@ def test_missing_header(package, menuxdgcheck):
assert 'invalid-desktopfile' in out


# TODO: Correct this test.
# @pytest.mark.skipif(not HAS_DESKTOP_FILE_UTILS, reason='Optional dependency desktop-file-utils not installed')
# @pytest.mark.parametrize('package', [MENUXDG4])
# def test_bad_unicode(package, menuxdgcheck):
# output, test = menuxdgcheck
# test.check(package)
# out = output.print_results(output.results)
# assert 'non-utf8-desktopfile' in out
@pytest.mark.skipif(not HAS_DESKTOP_FILE_UTILS, reason='Optional dependency desktop-file-utils not installed')
@pytest.mark.parametrize('package', [MENUXDG4])
def test_bad_unicode(package, menuxdgcheck):
output, test = menuxdgcheck
test.check(package)
out = output.print_results(output.results)
assert 'non-utf8-desktopfile' in out


@pytest.mark.skipif(not HAS_DESKTOP_FILE_UTILS, reason='Optional dependency desktop-file-utils not installed')
Expand Down
9 changes: 5 additions & 4 deletions test/test_pam_modules.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from mockdata.mock_pam_modules import PAMMODULES
import pytest
from rpmlint.checks.PAMModulesCheck import PAMModulesCheck
from rpmlint.filter import Filter

from Testing import CONFIG, get_tested_package
from Testing import CONFIG


@pytest.fixture(scope='function', autouse=True)
Expand All @@ -13,9 +14,9 @@ def pammodulecheck():
return output, test


@pytest.mark.parametrize('package', ['binary/pam-module'])
def test_pam_modules(tmp_path, package, pammodulecheck):
@pytest.mark.parametrize('package', [PAMMODULES])
def test_pam_modules(package, pammodulecheck):
output, test = pammodulecheck
test.check(get_tested_package(package, tmp_path))
test.check(package)
out = output.print_results(output.results)
assert 'E: pam-unauthorized-module pam-module.so' in out
15 changes: 8 additions & 7 deletions test/test_sysvinitonsystemd.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from mockdata.mock_sysvinitonsystemd import SYSVINITONSYSTEMD, SYSVINITONSYSTEMD2
import pytest
from rpmlint.checks.SysVInitOnSystemdCheck import SysVInitOnSystemdCheck
from rpmlint.filter import Filter

from Testing import CONFIG, get_tested_package
from Testing import CONFIG


@pytest.fixture(scope='function', autouse=True)
Expand All @@ -13,19 +14,19 @@ def sysvcheck():
return output, test


@pytest.mark.parametrize('package', ['binary/init'])
def test_sysv_init_on_systemd_check(tmp_path, package, sysvcheck):
@pytest.mark.parametrize('package', [SYSVINITONSYSTEMD])
def test_sysv_init_on_systemd_check(package, sysvcheck):
output, test = sysvcheck
test.check(get_tested_package(package, tmp_path))
test.check(package)
out = output.print_results(output.results)
assert 'E: obsolete-insserv-requirement' in out
assert 'E: deprecated-init-script weekly.script' in out
assert 'E: deprecated-boot-script boot.script' in out


@pytest.mark.parametrize('package', ['binary/rc-links'])
def test_overshadowing_of_initscript(tmp_path, package, sysvcheck):
@pytest.mark.parametrize('package', [SYSVINITONSYSTEMD2])
def test_overshadowing_of_initscript(package, sysvcheck):
output, test = sysvcheck
test.check(get_tested_package(package, tmp_path))
test.check(package)
out = output.print_results(output.results)
assert 'E: systemd-shadowed-initscript bar' in out

0 comments on commit b756e42

Please sign in to comment.