511fe0ea4f
https://lists.opensuse.org/archives/list/packaging@lists.opensuse.org/message/TF4QO7ECOSEDHBFI5YDEA3OF4RNSI7D7/ |
||
---|---|---|
.. | ||
binary | ||
configs | ||
data | ||
files | ||
ldd | ||
mockdata | ||
pyc | ||
readelf | ||
rpmlintrc | ||
source | ||
spec | ||
README.md | ||
Testing.py | ||
dump_stats.py | ||
test_FHS.py | ||
test_LSB.py | ||
test_alternatives.py | ||
test_appdata.py | ||
test_bashisms.py | ||
test_binaries.py | ||
test_branding.py | ||
test_build_date.py | ||
test_build_root.py | ||
test_cli.py | ||
test_config.py | ||
test_config_files.py | ||
test_dbus_policy.py | ||
test_device_files.py | ||
test_diff.py | ||
test_doc.py | ||
test_duplicates.py | ||
test_erlang.py | ||
test_file_digest.py | ||
test_filelist.py | ||
test_files.py | ||
test_filter.py | ||
test_helpers.py | ||
test_i18n.py | ||
test_icon_sizes.py | ||
test_kmp.py | ||
test_ldd_parser.py | ||
test_lib_dependency.py | ||
test_lint.py | ||
test_logrotate.py | ||
test_menuxdg.py | ||
test_mixed_ownership.py | ||
test_objdump_parser.py | ||
test_pam_modules.py | ||
test_pkg.py | ||
test_pkgconfig.py | ||
test_polkit.py | ||
test_python.py | ||
test_readelf_parser.py | ||
test_shlib_policy.py | ||
test_signature.py | ||
test_sources.py | ||
test_speccheck.py | ||
test_spellchecking.py | ||
test_suid_permissions.py | ||
test_systemd_install.py | ||
test_systemd_tmpfiles.py | ||
test_sysvinitonsystemd.py | ||
test_tags.py | ||
test_tmp_files.py | ||
test_whitelist_syntax.py | ||
test_world_writable.py | ||
test_xinetd.py | ||
test_zip.py | ||
test_zypp_syntax.py |
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