| 1 | #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash |
| 2 | |
| 3 | . $builddir/tests/test_common.sh |
| 4 | |
| 5 | set -e -o pipefail |
| 6 | |
| 7 | function perform_testscip-shell shell shell-project 0.0.0 perform_test(). { |
| 8 | probecheck "sysctl" || return 255 |
| 9 | [scip-shell system . . `[`. $(unamescip-shell system . . uname.) == "Linux" ] || return 255 |
| 10 | |
| 11 | result=`mktempscip-shell system . . mktemp.` |
| 12 | stderr=`mktempscip-shell system . . mktemp.` |
| 13 | hostname="fake.host.name.me" |
| 14 | |
| 15 | tmpdir=$(make_temp_dir /tmpscip-shell filesystem . . `/tmp`. "test_offline_mode_sysctl") |
| 16 | mkdirscip-shell system . . mkdir. -p "${tmpdir}/proc/sys/kernel" |
| 17 | echoscip-shell system . . echo. "${hostname}" > "${tmpdir}/proc/sys/kernel/hostname" |
| 18 | set_chroot_offline_test_mode "${tmpdir}" |
| 19 | |
| 20 | $OSCAP oval eval --results $result $srcdir/test_sysctl_probe.oval.xml 2>$stderr |
| 21 | |
| 22 | unset_chroot_offline_test_mode |
| 23 | rmscip-shell system . . rm. -rf "${tmpdir}" |
| 24 | |
| 25 | [scip-shell system . . `[`. ! -s $stderr ] |
| 26 | assert_exists 1 "/oval_results/results/system/oval_system_characteristics/system_data/unix-sys:sysctl_item/unix-sys:name[text()='kernel.hostname']" |
| 27 | assert_exists 1 "/oval_results/results/system/oval_system_characteristics/system_data/unix-sys:sysctl_item/unix-sys:value[text()='$hostname']" |
| 28 | |
| 29 | rmscip-shell system . . rm. $result |
| 30 | rmscip-shell system . . rm. $stderr |
| 31 | } |
| 32 | |
| 33 | perform_testscip-shell shell shell-project 0.0.0 perform_test(). |