Debian Codegraph @

tests/schemas/all.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 # Author:
4 # Martin Preisler <[email protected]>
5
6 . $builddir/tests/test_common.sh
7
8 # Test Cases.
9
10 function test_no_external_importsscip-shell shell shell-project 0.0.0 test_no_external_imports(). {
11 # openscap XSD schemas shall NOT import other XSDs from external
12 # locations!
13
14 # We have to do this pathetic double grep because grep doesn't support
15 # multiline matching. Normally pcregrep could be used but since it's not
16 # installed very often we use this hack instead. It assumes that xsd:import
17 # declarations don't take more than 2 lines in total.
18 case $(unamescip-shell system . . uname.) in
19 FreeBSD)
20 EXTERNAL_IMPORTS=$(grepscip-shell system . . grep. -R -E 'schemaLocation=\"http*://' "${srcdir}/../../schemas/" -C 1 | grepscip-shell system . . grep. -R -E '<xs.*:import')
21 ;;
22 *)
23 EXTERNAL_IMPORTS=$(grepscip-shell system . . grep. -n -P "schemaLocation=\"http[s]?://[^\"]+\"" -C 1 -r "${srcdir}/../../schemas/" | grepscip-shell system . . grep. -P "<[^:]+:import")
24 ;;
25 esac
26
27 if [scip-shell system . . `[`. "$?x" != "1x" ]; then
28 echoscip-shell system . . echo. "XSD schemas using external xsd:import found!:"
29 echoscip-shell system . . echo.
30 echoscip-shell system . . echo. "$EXTERNAL_IMPORTS"
31 echoscip-shell system . . echo.
32
33 return 1
34 fi
35
36 return 0
37 }
38
39 # Testing.
40 test_init "test_schemas.log"
41
42 if [scip-shell system . . `[`. -z ${CUSTOM_OSCAP+x} ] ; then
43 test_run "no_external_imports" test_no_external_imports
44 fi
45
46 test_exit