Debian Codegraph @

tests/DS/test_ds_common.sh

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 function assert_correct_xlinks()
4 {
5 local DS=$1
6 local stderr=$(mktemp)
7 $OSCAP info $DS 2> $stderr
8 diff $stderr /dev/null
9 rm $stderr
10
11 # First of all make sure that there is at least one ds:component-ref.
12 [ "$($XPATH $DS 'count(//*[local-name()="component-ref"])')" != "0" ]
13 # We want to catch cases when this element has different namespace.
14 local ns=$($XPATH $DS 'name(//*[local-name()="component-ref"][1])' | sed 's/:.*$/:/')
15 [ "$ns" != "component-ref" ] || ns=""
16 # Ensure there is at least some xlink.
17 [ "`$XPATH $DS \"count(//${ns}component-ref/@xlink:href)\"`" != "0" ]
18 # This asserts that there is none component-ref/xlink:href broken.
19 # Previously, we have seen datastreams with broken xlinks (see trac#286).
20 [ "`$XPATH $DS \"count(//${ns}component-ref[substring(@xlink:href, 2, 10000) != (//${ns}component/@${ns}id | //${ns}extended-component/@${ns}id)])\"`" == "0" ]
21 }