Debian Codegraph @

tests/probes/textfilecontent54/test_symlinks.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2 . $builddir/tests/test_common.sh
3
4 set -e -o pipefail
5
6 name=$(basename $0 .sh)
7 tmpdir=$(make_temp_dir /tmp ${name})
8 tpl=${srcdir}/${name}.xml.tpl
9 input=${tmpdir}/${name}.xml
10 result=${tmpdir}/${name}.results.xml
11 echo "Temp dir: $tmpdir"
12
13 # prepare the environment
14 sed "s@%PATH%@${tmpdir}@" $tpl > $input
15 ln -s /etc/hosts ${tmpdir}/sl1
16 ln -s /nonexistent ${tmpdir}/sl2
17 ln -s ${tmpdir} ${tmpdir}/sl3
18
19 echo "Evaluating content."
20 $OSCAP oval eval --results $result $input || [ $? == 2 ]
21 echo "Validating results."
22 $OSCAP oval validate --results $result
23 echo "Testing syschar values."
24 [ "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/@result)')" == "true" ]
25 [ "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/@result)')" == "false" ]
26 [ "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/@result)')" == "false" ]
27 [ "$($XPATH $result 'string(/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/@result)')" == "true" ]
28 echo "Testing syschar values."
29 [ "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:1"]/@flag)')" == "complete" ]
30 [ "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:2"]/@flag)')" == "does not exist" ]
31 [ "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:3"]/@flag)')" == "does not exist" ]
32 [ "$($XPATH $result 'string(/oval_results/results/system/oval_system_characteristics/collected_objects/object[@id="oval:x:obj:4"]/@flag)')" == "complete" ]
33
34 rm -rf $tmpdir