File: all.sh

package info (click to toggle)
openscap 1.4.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 125,116 kB
  • sloc: xml: 527,136; ansic: 91,867; sh: 19,831; python: 2,531; perl: 444; makefile: 49
file content (42 lines) | stat: -rwxr-xr-x 1,151 bytes parent folder | download | duplicates (3)
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 -o pipefail

. $builddir/tests/test_common.sh

function test_progress {
    local PROGRESS=$1
    local INPUT="$srcdir/$2"
    local EXPECTED_CONTENT="$3"

    local GENERATED_CONTENT=$($OSCAP xccdf eval $PROGRESS "$INPUT")
    if [ "$?" != "0" ]; then
        echo "Unable to generate content, oscap result: $?"
        return 1
    fi

    echo "$GENERATED_CONTENT" | grep "$EXPECTED_CONTENT"
    if [ "$?" == "0" ]; then
        return 0
    fi

    echo "Generated content does not contain '$EXPECTED_CONTENT'!"
    echo "Generated content:"
    echo "$GENERATED_CONTENT"

    return 1
}

# Testing.

test_init "test_api_xccdf_progress.log"

test_run "test_api_xccdf_progress_xccdf11" test_progress --progress content-xccdf11.xml xccdf_moc.elpmaxe.www_rule_1:pass
test_run "test_api_xccdf_progress_xccdf12" test_progress --progress content-xccdf12.xml xccdf_moc.elpmaxe.www_rule_1:pass

test_run "test_api_xccdf_progress_full_xccdf11" test_progress --progress-full content-xccdf11.xml "xccdf_moc.elpmaxe.www_rule_1\\|Rule 1\\|pass"

test_exit