| |
@@ -0,0 +1,46 @@
|
| |
+ import pytest
|
| |
+ import subprocess
|
| |
+
|
| |
+ pkgs = ['389-ds-base', 'nss', 'nspr', 'openldap', 'cyrus-sasl']
|
| |
+
|
| |
+
|
| |
+ def get_rpm_version(pkg):
|
| |
+ try:
|
| |
+ result = subprocess.check_output(['rpm', '-q', '--queryformat',
|
| |
+ '%{VERSION}-%{RELEASE}', pkg])
|
| |
+ except:
|
| |
+ result = b"not installed"
|
| |
+
|
| |
+ return result.decode('utf-8')
|
| |
+
|
| |
+
|
| |
+ def is_fips():
|
| |
+ # Are we running in FIPS mode?
|
| |
+ with open('/proc/sys/crypto/fips_enabled', 'r') as f:
|
| |
+ return f.readline()
|
| |
+
|
| |
+
|
| |
+ @pytest.fixture(autouse=True)
|
| |
+ def _environment(request):
|
| |
+ if "_metadata" in dir(request.config):
|
| |
+ for pkg in pkgs:
|
| |
+ request.config._metadata[pkg] = get_rpm_version(pkg)
|
| |
+ request.config._metadata['FIPS'] = is_fips()
|
| |
+
|
| |
+
|
| |
+ def pytest_report_header(config):
|
| |
+ header = ""
|
| |
+ for pkg in pkgs:
|
| |
+ header += pkg + ": " + get_rpm_version(pkg) + "\n"
|
| |
+ header += "FIPS: " + is_fips()
|
| |
+ return header
|
| |
+
|
| |
+
|
| |
+ @pytest.mark.optionalhook
|
| |
+ def pytest_html_results_table_header(cells):
|
| |
+ cells.pop()
|
| |
+
|
| |
+
|
| |
+ @pytest.mark.optionalhook
|
| |
+ def pytest_html_results_table_row(report, cells):
|
| |
+ cells.pop()
|
| |
Bug Description:
From the test's output it's not possible to tell what version of
389-ds-base was used during the test, what are the versions of
libraries that we depend on, etc.
Fix Description:
We can use conftest.py to print this useful information. This also will
be reflected in a html report, if py.test was used with --html option.
https://pagure.io/389-ds-base/issue/49717
Reviewed by: ???