File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ add_oscap_test_executable(test_xccdf_shall_pass
1717)
1818target_link_libraries (test_xccdf_shall_pass openscap ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${LIBXSLT_EXSLT_LIBRARIES} ${PCRE2_LIBRARIES} ${CURL_LIBRARIES} ${RPM_LIBRARIES} )
1919
20+ add_oscap_test_executable (test_xccdf_result_sysinfo_platform
21+ "test_xccdf_result_sysinfo_platform.c"
22+ )
23+
2024if (PYTHONINTERP_FOUND)
2125 add_oscap_test ("all_python.sh" )
2226endif ()
@@ -109,6 +113,7 @@ add_oscap_test("test_fix_resultid_by_suffix.sh")
109113add_oscap_test ("test_generate_fix_ansible_vars.sh" )
110114add_oscap_test ("test_xccdf_requires_conflicts.sh" )
111115add_oscap_test ("test_results_hostname.sh" )
116+ add_oscap_test ("test_xccdf_result_sysinfo_platform.sh" LABELS macos )
112117add_oscap_test ("test_skip_rule.sh" )
113118add_oscap_test ("test_no_newline_between_select_elements.sh" )
114119add_oscap_test ("test_single_line_tailoring.sh" )
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: LGPL-2.1-or-later
2+
3+ #ifdef HAVE_CONFIG_H
4+ #include <config.h>
5+ #endif
6+
7+ #include <stdbool.h>
8+ #include <stdio.h>
9+ #include <string.h>
10+
11+ #include "xccdf_benchmark.h"
12+
13+ int main (void )
14+ {
15+ struct xccdf_result * result = xccdf_result_new ();
16+ struct xccdf_target_fact_iterator * facts = NULL ;
17+ bool saw_mac = false;
18+ bool saw_asset_mac = false;
19+
20+ xccdf_result_fill_sysinfo (result );
21+ facts = xccdf_result_get_target_facts (result );
22+
23+ while (xccdf_target_fact_iterator_has_more (facts )) {
24+ struct xccdf_target_fact * fact = xccdf_target_fact_iterator_next (facts );
25+ const char * name = xccdf_target_fact_get_name (fact );
26+
27+ if (name == NULL )
28+ continue ;
29+
30+ if (strcmp (name , "urn:xccdf:fact:ethernet:MAC" ) == 0 )
31+ saw_mac = true;
32+ if (strcmp (name , "urn:xccdf:fact:asset:identifier:mac" ) == 0 )
33+ saw_asset_mac = true;
34+ }
35+
36+ xccdf_target_fact_iterator_free (facts );
37+ xccdf_result_free (result );
38+
39+ #if defined(OS_APPLE )
40+ if (!saw_mac ) {
41+ fprintf (stderr , "Expected at least one urn:xccdf:fact:ethernet:MAC fact on macOS.\n" );
42+ return 1 ;
43+ }
44+ if (!saw_asset_mac ) {
45+ fprintf (stderr , "Expected at least one urn:xccdf:fact:asset:identifier:mac fact on macOS.\n" );
46+ return 1 ;
47+ }
48+ #endif
49+
50+ return 0 ;
51+ }
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ . $builddir /tests/test_common.sh
4+
5+ if [ -n " ${CUSTOM_OSCAP+x} " ] ; then
6+ exit 255
7+ fi
8+
9+ case " $( uname) " in
10+ Darwin) ;;
11+ * ) exit 255 ;;
12+ esac
13+
14+ ./test_xccdf_result_sysinfo_platform
Original file line number Diff line number Diff line change 11if (ENABLE_PROBES_UNIX)
22 add_oscap_test ("test_probes_password.sh" LABELS unix freebsd macos )
3- add_oscap_test ("test_probes_password_offline.sh" LABELS unix )
3+ add_oscap_test ("test_probes_password_offline.sh" LABELS unix macos )
44 add_oscap_test ("test_probes_password_offline_fallback.sh" LABELS unix macos )
55endif ()
Original file line number Diff line number Diff line change @@ -32,12 +32,12 @@ function test_probes_password {
3232 tmpdir=$( mktemp -t -d " test_password.XXXXXX" )
3333 mkdir -p " $tmpdir /etc"
3434 echo " root:x:0:0:root:/root:/bin/bash" > " $tmpdir /etc/passwd"
35- set_chroot_offline_test_mode " $tmpdir "
35+ set_offline_chroot_dir " $tmpdir "
3636
3737 $OSCAP oval eval --results $RF $DF
3838
39- unset_chroot_offline_test_mode
40- rm -rf $tempdir
39+ set_offline_chroot_dir " "
40+ rm -rf " $tmpdir "
4141
4242 if [ -f $RF ]; then
4343 result=$RF
Original file line number Diff line number Diff line change @@ -26,9 +26,9 @@ invalid_line_without_separators
2626root:x:0:0:root:/root:/bin/bash
2727EOF
2828
29- set_chroot_offline_test_mode " $tmpdir "
29+ set_offline_chroot_dir " $tmpdir "
3030 $OSCAP oval eval --results " $RF " " $DF "
31- unset_chroot_offline_test_mode
31+ set_offline_chroot_dir " "
3232 rm -rf " $tmpdir "
3333
3434 if [ -f " $RF " ]; then
Original file line number Diff line number Diff line change 11if (ENABLE_PROBES_UNIX)
22 add_oscap_test ("test_probes_runlevel.sh" LABELS unix linux_only )
3+ add_oscap_test ("test_probes_runlevel_unsupported.sh" LABELS unix macos freebsd )
34endif ()
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ . $builddir /tests/test_common.sh
4+
5+ set -e -o pipefail
6+
7+ function test_probes_runlevel_unsupported {
8+ probecheck " runlevel" || return 255
9+
10+ case " $( uname) " in
11+ Darwin|FreeBSD) ;;
12+ * ) return 255 ;;
13+ esac
14+
15+ local definition=" ${top_srcdir} /tests/oval_details/runlevel.oval.xml"
16+ local results=" results_unsupported.xml"
17+ [ -f " $results " ] && rm -f " $results "
18+
19+ $OSCAP oval eval --results " $results " " $definition "
20+
21+ result=" $results "
22+ assert_exists 1 ' oval_results/results/system/definitions/definition[@definition_id="oval:x:def:1"][@result="error"]'
23+ assert_exists 1 ' oval_results/results/system/tests/test[@test_id="oval:x:tst:1"][@result="error"]'
24+ assert_exists 1 ' oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:ssg:obj:1313"][@flag="error"]'
25+ assert_exists 1 ' oval_results/results/system/oval_system_characteristics/collected_objects/object/message[text()="get_runlevel failed."]'
26+ }
27+
28+ test_init
29+
30+ test_run " test_probes_runlevel_unsupported" test_probes_runlevel_unsupported
31+
32+ test_exit
You can’t perform that action at this time.
0 commit comments