rpmlint/test
Daniel Garcia Moreno 511fe0ea4f Add new warning about the usage of %suse_update_desktop_file
https://lists.opensuse.org/archives/list/packaging@lists.opensuse.org/message/TF4QO7ECOSEDHBFI5YDEA3OF4RNSI7D7/
2024-09-11 13:04:50 +02:00
..
binary Merge branch 'main' into opensuse 2024-04-09 21:00:01 +02:00
configs test_file_digest: cover new glob features in package and path names 2024-01-29 14:55:45 +01:00
data FileDigestCheck: Filter minor versions in shebangs. 2023-12-05 11:11:13 +01:00
files PythonCheck: simplify requirement check using metadata 2024-05-03 12:38:49 +02:00
ldd Add ldd checks also for executables (#5). 2019-08-25 15:28:13 +08:00
mockdata Create Mock packages for tests in config_files, i18n, tmp_file and zypp_syntax (#1235) 2024-06-26 17:32:38 +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 FileDigestCheck: remove -digest- from error names where unnecessary 2021-09-15 10:00:30 +02:00
source TagsCheck: handle license exception in first item of a grouping 2023-03-20 03:20:44 -04:00
spec Add new warning about the usage of %suse_update_desktop_file 2024-09-11 13:04:50 +02:00
README.md test: Remove real_files opotional parameter 2023-09-13 09:09:22 +02:00
Testing.py Merge branch 'main' into opensuse 2024-02-22 13:47:13 +01:00
dump_stats.py dump_stats.py: add one more category for filtering 2022-11-10 14:43:39 +01:00
test_FHS.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_LSB.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_alternatives.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_appdata.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_bashisms.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_binaries.py BinariesCheck: do not mark as binary eBPF ELF files 2024-02-19 18:43:14 +01:00
test_branding.py pytest: use tmp_path mock instead of tmpdir 2023-03-27 09:58:29 +02:00
test_build_date.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_build_root.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_cli.py Merge branch 'main' into opensuse 2024-01-23 12:02:46 +01:00
test_config.py Merge branch 'main' into opensuse 2024-07-03 10:06:38 +02:00
test_config_files.py Create Mock packages for tests in config_files, i18n, tmp_file and zypp_syntax (#1235) 2024-06-26 17:32:38 +02:00
test_dbus_policy.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_device_files.py Add 2 FileMetadataCheck checks. 2021-06-24 10:20:06 +02:00
test_diff.py tests: use get_tested_path rather than testpath 2023-04-24 10:42:30 +02:00
test_doc.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_duplicates.py test: add mocks folder and mocks for duplicates check 2024-03-14 06:33:49 +00:00
test_erlang.py pkg_resource is deprecated, importlib and packaging are standard now 2023-07-11 07:58:02 +00:00
test_file_digest.py test_file_digest: cover new glob features in package and path names 2024-01-29 14:55:45 +01:00
test_filelist.py pytest: use tmp_path mock instead of tmpdir 2023-03-27 09:58:29 +02:00
test_files.py FilesCheck: Fix zero perm check with binaries 2024-08-02 08:00:35 +02:00
test_filter.py Merge branch 'main' into opensuse 2023-04-24 10:54:35 +02:00
test_helpers.py Fixes for new flake8 2020-06-23 11:51:57 +02:00
test_i18n.py Create Mock packages for tests in config_files, i18n, tmp_file and zypp_syntax (#1235) 2024-06-26 17:32:38 +02:00
test_icon_sizes.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_kmp.py pytest: use tmp_path mock instead of tmpdir 2023-03-27 09:58:29 +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 stringToVersion: make epoch always an integer 2023-03-27 16:56:00 +02:00
test_lint.py Merge branch 'main' into opensuse 2023-10-20 09:12:26 +02:00
test_logrotate.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_menuxdg.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_mixed_ownership.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_objdump_parser.py test: Skip test_executable_stack when ldd-failed 2023-08-03 10:56:27 +02:00
test_pam_modules.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_pkg.py Move rpm2cpio to one line 2024-01-30 12:23:25 +01:00
test_pkgconfig.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_polkit.py port to get_tested_path instead of testpath 2023-04-24 10:57:45 +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 Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_signature.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_sources.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_speccheck.py Add new warning about the usage of %suse_update_desktop_file 2024-09-11 13:04:50 +02:00
test_spellchecking.py Do not expect precise order of suggestions in spellchecking. 2021-12-16 13:50:03 +01:00
test_suid_permissions.py port to get_tested_path instead of testpath 2023-04-24 10:57:45 +02:00
test_systemd_install.py SystemIstallCheck: Allow %service_del_postun_without_restart macro usage 2024-02-07 14:16:04 +01:00
test_systemd_tmpfiles.py port to get_tested_path instead of testpath 2023-04-24 10:57:45 +02:00
test_sysvinitonsystemd.py Pytest documentation recommends refactoring "tmpdir" to "tmp_path" 2023-03-26 06:04:58 +05:30
test_tags.py test: Extend tag tests to check 'W: missing-dependency-on' 2023-12-14 10:13:35 +01:00
test_tmp_files.py Create Mock packages for tests in config_files, i18n, tmp_file and zypp_syntax (#1235) 2024-06-26 17:32:38 +02:00
test_whitelist_syntax.py Port 2 usages of toml library to tomli. 2022-07-24 22:29:51 +02:00
test_world_writable.py Correct filter in WorldWritableCheck. 2021-06-24 10:20:06 +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 Create Mock packages for tests in config_files, i18n, tmp_file and zypp_syntax (#1235) 2024-06-26 17:32:38 +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