public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/openscap] main: Sanity/smoke-test: run C unit tests skipped under CUSTOM_OSCAP
@ 2026-11-02 11:31 Matus Marhefka
0 siblings, 0 replies; only message in thread
From: Matus Marhefka @ 2026-11-02 11:31 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : tests/openscap
Branch : main
Commit : 4256f349fb8a7cb1b0492bfaea84ec2389a566b7
Author : Matus Marhefka <mmarhefk@redhat.com>
Date : 2026-11-02T11:23:32+01:00
Stats : +26/-0 in 2 file(s)
URL : https://src.fedoraproject.org/tests/openscap/c/4256f349fb8a7cb1b0492bfaea84ec2389a566b7?branch=main
Log:
Sanity/smoke-test: run C unit tests skipped under CUSTOM_OSCAP
Upstream C unit tests guard their test binary with
`if [ -z ${CUSTOM_OSCAP+x} ]`, so when the suite runs against the
installed oscap (CUSTOM_OSCAP exported) the binary is skipped, all.sh
exits 0 and CTest reports Passed. As a result, tests such as
DS/ds_sds_path_traversal (SDS decomposition path traversal fix,
OpenSCAP/openscap#2459, PSIRTSUPT-15968) passed without running.
Add a second CTest pass that:
- finds the guarded tests by grepping tests/ in the source tree for
CUSTOM_OSCAP+x, so the selection follows each release and backport
- runs them with `env -u CUSTOM_OSCAP` (an empty value would still
count as set)
- submits its LastTest.log as unit_test_verbose_output.log, since the
first pass writes the same file
- asserts that the path traversal test actually ran (if present)
The unit tests run against the library rebuilt from the installed
package's SRPM, effectively the %check stage the RHEL spec does not
run. The second pass adds about 50 s.
Verified on RHEL 10.3 (openscap-1.4.6-1.el10_3): 26 tests passed and
58 inner checks ran, including path_traversal (it ran 0 before).
---
diff --git a/Sanity/smoke-test/main.fmf b/Sanity/smoke-test/main.fmf
index a35cee4..2d18a06 100644
--- a/Sanity/smoke-test/main.fmf
+++ b/Sanity/smoke-test/main.fmf
@@ -2,6 +2,8 @@ summary: Test runs upstream test suite.
description: |
Runs upstream test suite against installed openscap. Test suite is built from
the openscap source RPM by running %prep and %build stages from the spec file.
+ C unit tests which are skipped when CUSTOM_OSCAP is set are then run in
+ a second CTest pass with CUSTOM_OSCAP unset.
contact: Matus Marhefka <mmarhefk@redhat.com>
component:
- openscap
diff --git a/Sanity/smoke-test/runtest.sh b/Sanity/smoke-test/runtest.sh
index 13cf0d9..818559b 100755
--- a/Sanity/smoke-test/runtest.sh
+++ b/Sanity/smoke-test/runtest.sh
@@ -153,6 +153,30 @@ rlJournalStart
fi
rlPhaseEnd
+ if ! rlIsRHEL "<=7"; then
+ # C unit tests guarded by ${CUSTOM_OSCAP+x} skip their binary (and report
+ # Passed) when CUSTOM_OSCAP is set, so run them again with it unset.
+ rlPhaseStartTest "Run upstream C unit tests"
+ SRC_DIR=$(sed -n 's/^CMAKE_HOME_DIRECTORY:INTERNAL=//p' "$BUILD_DIR_PATH/CMakeCache.txt")
+ rlRun "test -d '$SRC_DIR/tests'" 0 "Source tests directory found: $SRC_DIR/tests"
+ UNIT_TESTS=$(cd "$SRC_DIR/tests" && grep -rlE 'CUSTOM_OSCAP\+x' --include='*.sh' . | sed 's|^\./||' | sort)
+ if [ -z "$UNIT_TESTS" ]; then
+ rlLogInfo "No CUSTOM_OSCAP-guarded unit tests found, skipping"
+ else
+ rlLogInfo "Guarded unit tests: $(echo "$UNIT_TESTS" | paste -sd' ')"
+ UNIT_TESTS_ESCAPED=${UNIT_TESTS//./\\.}
+ REGEX="^(${UNIT_TESTS_ESCAPED//$'\n'/|})\$"
+ rlRun -s "env -u CUSTOM_OSCAP ctest --test-dir $BUILD_DIR_PATH --output-on-failure -R '$REGEX'"
+ rv=$?
+ FILE="${BUILD_DIR_PATH}/Testing/Temporary/LastTest.log"
+ rlFileSubmit "$(readlink -f "$FILE")" unit_test_verbose_output.log
+ if [ $rv -ne 0 ]; then
+ rlBundleLogs unit_test_outputs_all "$(readlink -f "${BUILD_DIR_PATH}/tests")"
+ fi
+ fi
+ rlPhaseEnd
+ fi
+
rlPhaseStartCleanup
CleanupDo
rlPhaseEnd
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-02 11:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-02 11:31 [tests/openscap] main: Sanity/smoke-test: run C unit tests skipped under CUSTOM_OSCAP Matus Marhefka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox