Debian Codegraph @

tests/API/CPE/inbuilt/all.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 #
3 # Copyright 2013 Red Hat Inc., Durham, North Carolina.
4 # All Rights Reserved.
5 #
6 # This script is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
10 #
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20 set -e -o pipefail
21
22 . $builddir/tests/test_common.sh
23
24 function ensure_oscap_versionscip-shell shell shell-project 0.0.0 ensure_oscap_version().(){
25 local name=$FUNCNAME
26 local stdout=$(mktempscip-shell system . . mktemp. -t ${name}.out.XXXXXX)
27 local stderr=$(mktempscip-shell system . . mktemp. -t ${name}.err.XXXXXX)
28 $OSCAP --version 2> $stderr > $stdout
29 [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]; rmscip-shell system . . rm. $stderr
30 grepscip-shell system . . grep. "^Default CPE files: .*/cpe$" $stdout
31 grepscip-shell system . . grep. " Inbuilt CPE names " $stdout
32 rmscip-shell system . . rm. $stdout
33 }
34
35 function _get_inbuilt_cpe_dirscip-shell shell shell-project 0.0.0 _get_inbuilt_cpe_dir().(){
36 $OSCAP --version | awkscip-shell system . . awk. -F: '/^Default CPE files: / {$1=""; print}scip-shell filesystem . . `/^Default CPE files: / {$1=""; print}`.'
37 }
38
39 function _get_inbuilt_cpe_pathscip-shell shell shell-project 0.0.0 _get_inbuilt_cpe_path().(){
40 echoscip-shell system . . echo. "$(_get_inbuilt_cpe_dirscip-shell shell shell-project 0.0.0 _get_inbuilt_cpe_dir().)/openscap-cpe-dict.xml"
41 }
42
43 function validate_inbuilt_dictscip-shell shell shell-project 0.0.0 validate_inbuilt_dict().(){
44 local name=$FUNCNAME
45 local path=$(_get_inbuilt_cpe_pathscip-shell shell shell-project 0.0.0 _get_inbuilt_cpe_path().)
46 local output=$(mktempscip-shell system . . mktemp. -t ${name}.out.XXXXXX)
47 [scip-shell system . . `[`. -f $path ]
48 $OSCAP cpe validate $path 2>&1 > $output
49 [scip-shell system . . `[`. -f $output ]; [scip-shell system . . `[`. ! -s $output ]
50 $OSCAP cpe validate $path 2>&1 > $output
51 [scip-shell system . . `[`. -f $output ]; [scip-shell system . . `[`. ! -s $output ]
52 rmscip-shell system . . rm. $output
53 }
54
55 function info_inbuilt_dictscip-shell shell shell-project 0.0.0 info_inbuilt_dict().(){
56 local name=$FUNCNAME
57 local path=$(_get_inbuilt_cpe_pathscip-shell shell shell-project 0.0.0 _get_inbuilt_cpe_path().)
58 local stderr=$(mktempscip-shell system . . mktemp. -t ${name}.err.XXXXXX)
59 [scip-shell system . . `[`. -f $path ]
60 $OSCAP info $path 2> $stderr
61 [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ];
62 rmscip-shell system . . rm. $stderr
63 }
64
65 test_init test_api_cpe_inbuilt.log
66
67 test_run "ensure_oscap_version" ensure_oscap_version
68 test_run "validate_inbuilt_dict" validate_inbuilt_dict
69 test_run "info_inbuilt_dict" info_inbuilt_dict
70
71 test_exit