File: all.sh

package info (click to toggle)
openscap 1.4.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 125,040 kB
  • sloc: xml: 527,109; ansic: 91,390; sh: 19,789; python: 2,515; perl: 444; makefile: 49
file content (42 lines) | stat: -rwxr-xr-x 1,219 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash

# Copyright 2012 Red Hat Inc., Durham, North Carolina.
# All Rights Reserved.

set -e -o pipefail

. $builddir/tests/test_common.sh

function test_generate_fix {
    local INPUT=$srcdir/$1
    local TESTRESULT_ID=$2
    local EXPECTED_FIX=$3

    # grep to strip out whitespace and comments
    # `tail -n +2` to skip the first line with progress reporting
    local GENERATED_FIX RELEVANT_FIX_CONTENTS
    GENERATED_FIX=$($OSCAP xccdf generate fix --result-id "$TESTRESULT_ID" "$INPUT")
    RELEVANT_FIX_CONTENTS=$(grep -v -E "^([\t ]*|[\t ]*#.*|\) #.*)$" <<< "$GENERATED_FIX" | tail -n +2)
    if [ "$?" != "0" ]; then
        return 1
    fi
    echo "$GENERATED_FIX"

    if [ "$RELEVANT_FIX_CONTENTS" == "$EXPECTED_FIX" ]; then
        return 0
    fi

    echo "Generated fix doesn't match expected fix!"
    echo "'$RELEVANT_FIX_CONTENTS' != '$EXPECTED_FIX'"

    return 1
}

# Testing.

test_init "test_api_xccdf_fix.log"

test_run "test_api_xccdf_fix_xccdf11" test_generate_fix results-xccdf11.xml xccdf_org.open-scap_testresult_default-profile echo
test_run "test_api_xccdf_fix_xccdf12" test_generate_fix results-xccdf12.xml xccdf_org.open-scap_testresult_default-profile echo

test_exit