Debian Codegraph @

tests/API/OVAL/unittests/test_ipv4_comparison.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 result=$(mktemp ${name}.out.XXXXXX)
8 echo "result file: $result"
9 stderr=$(mktemp ${name}.err.XXXXXX)
10 echo "stderr file: $stderr"
11
12 echo "Analysing syschar content."
13 $OSCAP oval analyse --results $result $srcdir/$name.oval.xml $srcdir/$name.syschar.xml 2> $stderr
14 [ -f $stderr ]; [ ! -s $stderr ]; rm $stderr
15 [ -f $result ]
16
17 assert_exists 1 '/oval_results'
18 assert_exists 1 '/oval_results/generator'
19 assert_exists 1 '/oval_results/generator/oval:product_name'
20 assert_exists 1 '/oval_results/generator/oval:product_name[text()="cpe:/a:open-scap:oscap"]'
21 assert_exists 1 '/oval_results/generator/oval:schema_version'
22 assert_exists 1 '/oval_results/generator/oval:schema_version[text()="5.8"]'
23 assert_exists 1 '/oval_results/generator/oval:timestamp'
24 assert_exists 1 '/oval_results/directives'
25 assert_exists 1 '/oval_results/oval_definitions'
26 assert_exists 1 '/oval_results/results'
27 assert_exists 1 '/oval_results/results/system'
28 assert_exists 1 '/oval_results/results/system/definitions'
29 assert_exists 6 '/oval_results/results/system/definitions/definition'
30 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:1"]'
31 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:1"][@result="true"]'
32 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:1"]/criteria'
33 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:1"]/criteria/criterion'
34 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:1"]/criteria/criterion[@result="true"]'
35 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:2"]'
36 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:2"][@result="true"]'
37 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:2"]/criteria'
38 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:2"]/criteria/criterion'
39 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:2"]/criteria/criterion[@result="true"]'
40 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:3"]'
41 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:3"][@result="error"]'
42 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:3"]/criteria'
43 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:3"]/criteria/criterion'
44 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:3"]/criteria/criterion[@result="error"]'
45 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:4"]'
46 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:4"][@result="error"]'
47 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:4"]/criteria'
48 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:4"]/criteria/criterion'
49 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:4"]/criteria/criterion[@result="error"]'
50 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:5"]'
51 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:5"][@result="error"]'
52 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:5"]/criteria'
53 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:5"]/criteria/criterion'
54 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:5"]/criteria/criterion[@result="error"]'
55 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:6"]'
56 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:6"][@result="error"]'
57 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:6"]/criteria'
58 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:6"]/criteria/criterion'
59 assert_exists 1 '/oval_results/results/system/definitions/definition[@definition_id="oval:x:def:6"]/criteria/criterion[@result="error"]'
60 assert_exists 1 '/oval_results/results/system/tests'
61 assert_exists 6 '/oval_results/results/system/tests/test'
62 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]'
63 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"][@result="true"]'
64 assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/*'
65 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/tested_item'
66 assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/tested_item/@*'
67 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/tested_item/@item_id'
68 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/tested_item[@result="true"]'
69 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/tested_variable'
70 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/tested_variable/@*'
71 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/tested_variable[@variable_id="oval:x:var:1"]'
72 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/tested_variable[text()="192.192.1.1"]'
73 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]'
74 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"][@result="true"]'
75 assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/*'
76 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/tested_item'
77 assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/tested_item/@*'
78 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/tested_item/@item_id'
79 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/tested_item[@result="true"]'
80 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/tested_variable'
81 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/tested_variable/@*'
82 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/tested_variable[@variable_id="oval:x:var:2"]'
83 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/tested_variable[text()="42.42.42.42"]'
84
85 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]'
86 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"][@result="error"]'
87 assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/*'
88 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_item'
89 assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_item/@*'
90 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_item/@item_id'
91 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_item[@result="error"]'
92 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_variable'
93 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_variable/@*'
94 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_variable[@variable_id="oval:x:var:3"]'
95 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_variable[text()="192.168.120.80/24"]'
96
97 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]'
98 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"][@result="error"]'
99 assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/*'
100 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_item'
101 assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_item/@*'
102 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_item/@item_id'
103 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_item[@result="error"]'
104 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_variable'
105 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_variable/@*'
106 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_variable[@variable_id="oval:x:var:3"]'
107 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_variable[text()="192.168.120.80/24"]'
108
109 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]'
110 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"][@result="error"]'
111 assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/*'
112 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_item'
113 assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_item/@*'
114 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_item/@item_id'
115 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_item[@result="error"]'
116 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_variable'
117 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_variable/@*'
118 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_variable[@variable_id="oval:x:var:3"]'
119 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_variable[text()="192.168.120.80/24"]'
120
121 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]'
122 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"][@result="error"]'
123 assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/*'
124 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_item'
125 assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_item/@*'
126 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_item/@item_id'
127 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_item[@result="error"]'
128 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_variable'
129 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_variable/@*'
130 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_variable[@variable_id="oval:x:var:3"]'
131 assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_variable[text()="192.168.120.80/24"]'
132
133 rm $result