Debian Codegraph @

tests/bz2/test_bz2_datastream.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 #
3 # Copyright 2014 Red Hat Inc., Durham, North Carolina.
4 # All Rights Reserved.
5
6 set -e -o pipefail
7
8 . $builddir/tests/test_common.sh
9
10 name=$(basenamescip-shell system . . basename. $0 .sh)
11 dir=$(mktempscip-shell system . . mktemp. -d -t ${name}.XXXXXX)
12 stderr=$(mktempscip-shell system . . mktemp. -t ${name}.err.XXXXXX)
13 echoscip-shell system . . echo. "Stderr file = $stderr"
14 sds=$dir/sds.xml
15 xccdf=$dir/xccdf.xml
16 cpscip-shell system . . cp. $srcdir/../DS/sds_multiple_oval/*.xml $dir/
17 cpscip-shell system . . cp. $srcdir/../bz2/sds.xml $sds
18 mvscip-shell system . . mv. $dir/multiple-oval-xccdf.xml $xccdf
19
20 #
21 # Checks before DataStream compose
22 #
23 bzip2scip-shell system . . bzip2. $xccdf
24 [scip-shell system . . `[`. -f "${xccdf}.bz2" ]
25 $OSCAP info "${xccdf}.bz2" 2> $stderr
26 [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]
27
28 $OSCAP xccdf validate --skip-schematron "${xccdf}.bz2" > $stderr
29 [scip-shell system . . `[`. ! -s $stderr ]
30 bashscip-shell system . . bash. $builddir/run ./test_bz2_memory_source "${xccdf}.bz2" | grepscip-shell system . . grep. 'XCCDF Checklist'
31
32 #
33 # Compose DataStream
34 #
35 bzip2scip-shell system . . bzip2. $sds
36 [scip-shell system . . `[`. -f "${sds}.bz2" ]
37 $OSCAP info "${sds}.bz2" 2> $stderr
38 [scip-shell system . . `[`. ! -s $stderr ]
39
40 $OSCAP ds sds-validate "${sds}.bz2" > $stderr
41 [scip-shell system . . `[`. ! -s $stderr ]
42 bashscip-shell system . . bash. $builddir/run ./test_bz2_memory_source "${sds}.bz2" | grepscip-shell system . . grep. 'SCAP Source Datastream'
43
44 #
45 # Evaluate
46 #
47 ret=0
48 $OSCAP xccdf eval "${xccdf}.bz2" 2> $stderr || ret=$?
49 [scip-shell system . . `[`. $ret -eq 2 -o $ret -eq 0 ]
50 [scip-shell system . . `[`. ! -s $stderr ]
51
52 ret=0
53 arf=$dir/arf.xml
54 $OSCAP xccdf eval --results-arf $arf "${sds}.bz2" 2> $stderr || ret=$?
55 [scip-shell system . . `[`. $ret -eq 2 -o $ret -eq 0 ]
56 [scip-shell system . . `[`. ! -s $stderr ]
57
58 #
59 # Generate report from ARF
60 #
61 bzip2scip-shell system . . bzip2. $arf
62 [scip-shell system . . `[`. -f "${arf}.bz2" ]
63 report=$dir/report.html
64 $OSCAP xccdf generate report --output $report "${arf}.bz2" 2> $stderr
65 [scip-shell system . . `[`. ! -s $stderr ]
66 [scip-shell system . . `[`. -f $report ]
67 bashscip-shell system . . bash. $builddir/run ./test_bz2_memory_source "${arf}.bz2" | grepscip-shell system . . grep. 'ARF Result Datastream'
68
69 grepscip-shell system . . grep. -q 'OVAL test results details' $report
70 rmscip-shell system . . rm. $stderr
71 rmscip-shell system . . rm. -rf $dir