Debian Codegraph @

tests/probes/textfilecontent54/test_filecontent_non_utf.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2 set -o pipefail
3
4 . $builddir/tests/test_common.sh
5
6 function test_filecontent_non_utf {
7 RESULT=$1
8 FILE_SUFFIX=${2}
9
10 result=`mktemp`
11 output=`mktemp`
12 test_dir=$(mktemp -d)
13 exit_code=0
14 cp ${srcdir}/test_filecontent_non_utf.${FILE_SUFFIX} ${test_dir}/${FILE_SUFFIX}
15
16 cp ${srcdir}/test_filecontent_non_utf.oval.xml ${test_dir}/oval.xml
17
18 xsed -i "s:TEST_FILE:${test_dir}/${FILE_SUFFIX}:" ${test_dir}/oval.xml
19
20 $OSCAP oval eval --results $result ${test_dir}/oval.xml &> $output || exit_code=1
21 if ! grep ${RESULT} $output; then
22 echo "Failed to output \"${RESULT}\", something is wrong"
23 cat $output
24 exit_code=1
25 fi
26 rm -f $result $output
27 rm -rf ${test_dir}
28 return ${exit_code}
29 }
30
31 test_init
32
33 test_run "filecontent regex of utf8 file" test_filecontent_non_utf "false" "utf8"
34 test_run "filecontent regex of iso8859 file" test_filecontent_non_utf "error" "iso8859"
35
36 test_exit
37