Debian Codegraph @

tests/API/XCCDF/unittests/test_results_hostname.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 . $builddir/tests/test_common.sh
3
4 set -e
5 set -o pipefail
6
7 result=$(mktempscip-shell system . . mktemp.)
8 tmpdir=$(mktempscip-shell system . . mktemp. -d)
9
10 export OSCAP_PROBE_ROOT="$tmpdir"
11
12 mkdirscip-shell system . . mkdir. -p "$tmpdir/etc"
13 echoscip-shell system . . echo. "hostname_defined_in_etc_hostname" > "$tmpdir/etc/hostname"
14 $OSCAP xccdf eval --results "$result" "$srcdir/test_single_rule.ds.xml" || ret=$?
15 assert_exists 1 '/Benchmark/TestResult/target[text()="hostname_defined_in_etc_hostname"]scip-shell filesystem . . `/Benchmark/TestResult/target[text()="hostname_defined_in_etc_hostname"]`.'
16 assert_exists 0 '/Benchmark/TestResult/target[text()="hostname_defined_in_proc_sys_kernel"]scip-shell filesystem . . `/Benchmark/TestResult/target[text()="hostname_defined_in_proc_sys_kernel"]`.'
17
18 rmscip-shell system . . rm. -rf "$tmpdir/etc/hostname"
19 mkdirscip-shell system . . mkdir. -p "$tmpdir/proc/sys/kernel/"
20 echoscip-shell system . . echo. "hostname_defined_in_proc_sys_kernel" > "$tmpdir/proc/sys/kernel/hostname"
21 $OSCAP xccdf eval --results "$result" "$srcdir/test_single_rule.ds.xml" || ret=$?
22 assert_exists 0 '/Benchmark/TestResult/target[text()="hostname_defined_in_etc_hostname"]scip-shell filesystem . . `/Benchmark/TestResult/target[text()="hostname_defined_in_etc_hostname"]`.'
23 assert_exists 1 '/Benchmark/TestResult/target[text()="hostname_defined_in_proc_sys_kernel"]scip-shell filesystem . . `/Benchmark/TestResult/target[text()="hostname_defined_in_proc_sys_kernel"]`.'
24
25 rmscip-shell system . . rm. -f "$result"
26 rmscip-shell system . . rm. -rf "$tmpdir"