rpmlint/test
Daniel Garcia Moreno 27ee58aceb AlternativesCheck: Fix .conf files regex
The previous regex matches any path in /usr/share/libalternatives/ that ends
with "conf" so it was crashing when trying to parse an rpm file that contains a
binary "ldaptor-ldap2dhcpconf" with a libalternatives configuration.

This patch fixes this issue making the regex more specific so it doesn't catch
any folder, just ".conf" files.
2025-06-09 15:37:25 +02:00
..
binary test: Mocking TagsCheck binaries 2024-10-10 14:30:07 +02:00
configs Allow multiple spaces between paren 2021-11-16 18:59:50 -05:00
files FilesCheck: Update FSF address check 2025-01-07 11:29:11 +01:00
ldd Add ldd checks also for executables (#5). 2019-08-25 15:28:13 +08:00
mockdata AlternativesCheck: Fix .conf files regex 2025-06-09 15:37:25 +02:00
pyc Fix getting pyc mtime on Python 3.7 2018-03-02 10:41:56 +01:00
readelf Remove shared-library-without-dependency and library-not-linked-against-libc 2022-12-01 11:28:34 +01:00
rpmlintrc Add logic for rpmlint loading wrt issue #125 2020-02-10 13:02:44 +01:00
source TagsCheck: handle license exception in first item of a grouping 2023-03-20 03:20:44 -04:00
spec SpecCheck: warn also for py3_install macro usage 2025-05-08 10:35:44 +02:00
README.md test: Remove real_files opotional parameter 2023-09-13 09:09:22 +02:00
Testing.py test: Mocking TagsCheck binaries 2024-10-10 14:30:07 +02:00
dump_stats.py dump_stats.py: add one more category for filtering 2022-11-10 14:43:39 +01:00
test_FHS.py test: Normalize mock_FHS 2024-10-03 12:39:05 +02:00
test_LSB.py test: Normalize mock_LSB 2024-10-03 12:39:05 +02:00
test_alternatives.py AlternativesCheck: Fix .conf files regex 2025-06-09 15:37:25 +02:00
test_appdata.py test: Normalize mock_appdata 2024-10-03 12:39:05 +02:00
test_bashisms.py test: Normalize mock_bashisms 2024-10-03 12:39:05 +02:00
test_binaries.py test: Fix flake8 issues 2024-10-03 12:39:05 +02:00
test_build_date.py test: Fix flake8 issues 2024-10-03 12:39:05 +02:00
test_build_root.py test: Normalize mock_build_root 2024-10-03 12:39:05 +02:00
test_cli.py lint: Reset all checks for each package 2024-01-03 15:08:05 +01:00
test_config.py Test: Fix test_config error raised by new ruff 2024-07-03 09:53:45 +02:00
test_config_files.py test: Normalize mock_config_files 2024-10-03 12:39:05 +02:00
test_dbus_policy.py test: Normalize mock_dbus_policy.py 2024-10-03 12:39:05 +02:00
test_diff.py tests: use get_tested_path rather than testpath 2023-04-24 10:42:30 +02:00
test_doc.py test: Fix flake8 issues 2024-10-03 12:39:05 +02:00
test_duplicates.py test: add mocks folder and mocks for duplicates check 2024-03-14 06:33:49 +00:00
test_erlang.py test: Normalize mock_erlang.py 2024-10-03 12:39:05 +02:00
test_files.py FilesCheck: Update FSF address check 2025-01-07 11:29:11 +01:00
test_filter.py tests: use get_tested_path rather than testpath 2023-04-24 10:42:30 +02:00
test_helpers.py Fixes for new flake8 2020-06-23 11:51:57 +02:00
test_i18n.py test: Fix flake8 issues 2024-10-03 12:39:05 +02:00
test_icon_sizes.py test: Normalize mock_icon_sizes 2024-10-03 12:39:05 +02:00
test_ldd_parser.py Remove duplicite argument for run_elf_checks and use PkgFile. 2022-01-21 14:38:26 +01:00
test_lib_dependency.py test: Remove not needed mock_lib_dependency.py 2024-10-03 12:39:05 +02:00
test_lint.py test: Fix test_extract_fail when running as root 2024-09-04 10:30:33 +02:00
test_logrotate.py test: Fix flake8 issues 2024-10-03 12:39:05 +02:00
test_menuxdg.py test: Fix flake8 issues 2024-10-03 12:39:05 +02:00
test_mixed_ownership.py test: Normalize mock_mixed_ownership 2024-10-03 12:39:05 +02:00
test_objdump_parser.py test: Skip test_executable_stack when ldd-failed 2023-08-03 10:56:27 +02:00
test_pam_modules.py test: Normalize mock_pam_modules 2024-10-03 12:39:05 +02:00
test_pkg.py test: Use skipif instead of early return in test_extract_fail 2024-10-03 12:39:05 +02:00
test_pkgconfig.py test: Fix flake8 issues 2024-10-03 12:39:05 +02:00
test_python.py PythonCheck: simplify requirement check using metadata 2024-05-03 12:38:49 +02:00
test_readelf_parser.py test: Skip test_executable_stack when ldd-failed 2023-08-03 10:56:27 +02:00
test_shlib_policy.py test: Fix flake8 issues 2024-10-03 12:39:05 +02:00
test_signature.py Tests: Accept long GPG key ids (for RPM 6) 2025-04-23 10:52:49 +02:00
test_sources.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_speccheck.py SpecCheck: warn also for py3_install macro usage 2025-05-08 10:35:44 +02:00
test_spellchecking.py SpecCheck: Add new warning for setup.py install usage 2025-05-08 10:05:37 +02:00
test_sysvinitonsystemd.py test: Normalize mock_sysvinitonsystemd 2024-10-03 12:39:05 +02:00
test_tags.py test: Mocking TagsCheck binaries 2024-10-10 14:30:07 +02:00
test_tmp_files.py test: Fix flake8 issues 2024-10-03 12:39:05 +02:00
test_xinetd.py test: mocked package in test_xinetd.py 2024-03-20 23:49:33 +05:30
test_zip.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_zypp_syntax.py test: Fix flake8 issues 2024-10-03 12:39:05 +02:00

README.md

Testing

The RPMLint test suite has undergone some changes as part of the Google Summer of Code program. These changes can be seen in the links openSUSE/mentoring#189 and rpm-software-management/rpmlint#1101. The new test suite uses a mocking strategy to address the issue of relying on binary RPM files. Binary RPM files take a lot of time to unpack and consume real resources like storage in the repository. They also require significant computation when unpacked as individual files.

In this new test suite, we will utilize a FakePkg class, which acts as a mock representation of a Pkg. This Pkg resembles a real RPM file, allowing any test function to use it. Although FakePkg is still in its early stages, it can already mock many tests compared to the current implementation.

get_tested_mock_package Function

The get_tested_mock_package function's interface is as follows:

def get_tested_mock_package(files=None, header=None)

For each new test, we employ the get_tested_mock_package function, a helper from test/Testing.py. This function leverages the FakePkg class to create a mock package named mockPkg.

The current implementation of the get_tested_mock_package function is as follows:

def get_tested_mock_package(files=None, header=None):
    mockPkg = FakePkg('mockPkg')
    if files is not None:
        mockPkg.create_files(files)
    if header is not None:
        mockPkg.add_header(header)
    mockPkg.initiate_files_base_data()
    return mockPkg

The get_tested_mock_package function can accept arguments

  • files
  • header

See the example test function below to get basic idea

@pytest.mark.parametrize('package', [get_tested_mock_package(
    files={
        '/usr/lib/python2.7/site-packages/doc': {},
        '/usr/lib/python2.7/site-packages/docs': {},
        '/usr/lib/python3.10/site-packages/doc': {},
        '/usr/lib/python3.10/site-packages/docs': {},
        '/usr/lib64/python2.7/site-packages/doc': {},
        '/usr/lib64/python2.7/site-packages/docs': {},
        '/usr/lib64/python3.10/site-packages/doc': {},
        '/usr/lib64/python3.10/site-packages/docs': {}
    }
)])
def test_python_doc_in_site_packages(package, pythoncheck):
    output, test = pythoncheck
    test.check(package)
    out = output.print_results(output.results)
    assert 'E: python-doc-in-site-packages /usr/lib/python2.7/site-packages/doc' in out
    # ... (similar assertions for other paths)

files: files argument takes each file's path and a dictionary as shown above '/usr/lib/python2.7/site-packages/doc': {} the value part is again a dictionary with file related data such as create_dirs, metadata and include_dirs. metadata is yet versatile it can assign any rpm related options or simply rpm file meta data unique to file.

If the content or metadata of the files in the package is not important, it's possible to use just a list of paths and the files will be created with default empty content and default flags.

header: Header is dictionary object that is specific to rpm file. We can pass specific rpm file header information with this parameter. See test_python.py tests for more info