-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-cnf-suites.sh
executable file
·131 lines (113 loc) · 2.9 KB
/
run-cnf-suites.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env bash
# [debug] uncomment line below to print out the statements as they are being
# executed.
set -x
# defaults
export OUTPUT_LOC="$PWD/cnf-certification-test"
usage() {
echo "$0 [-o OUTPUT_LOC] [-l LABEL...]"
echo "Call the script and list the test suites to run"
echo " e.g."
echo " $0 [ARGS] -l \"access-control,lifecycle\""
echo " will run the access-control and lifecycle suites"
echo " $0 [ARGS] -l all will run all the tests"
echo ""
echo "Allowed suites are listed in the README."
echo ""
echo "The specs can be listed with $0 -L|--list [-l LABEL...]"
}
usage_error() {
usage
exit 1
}
TIMEOUT=24h0m0s
LABEL=''
LIST=false
BASEDIR=$(dirname "$(realpath "$0")")
# Parse args beginning with "-".
while [[ $1 == -* ]]; do
case "$1" in
-h | --help | -\?)
usage
exit 0
;;
-L | --list)
LIST=true
;;
-o)
if (($# > 1)); then
OUTPUT_LOC=$2
shift
else
echo >&2 '-o requires an argument'
exit 1
fi
;;
-l | --label)
while (("$#" >= 2)) && ! [[ $2 = --* ]] && ! [[ $2 = -* ]]; do
LABEL="$LABEL $2"
shift
done
;;
-*)
echo >&2 "invalid option: $1"
usage_error
;;
esac
shift
done
# Strips the leading whitespace.
LABEL="$(echo -e "${LABEL}" | sed -e 's/^[[:space:]]*//')"
if [[ $LABEL == "all" ]]; then
LABEL='common,extended,faredge,telco'
fi
# List the specs (filtering by suite).
if [ "$LIST" = true ]; then
cd "$BASEDIR"/cnf-certification-test || exit 1
./cnf-certification-test.test \
--ginkgo.dry-run \
--ginkgo.timeout=$TIMEOUT \
--ginkgo.v \
--ginkgo.label-filter="$LABEL"
cd ..
exit 0
fi
# Specify Junit report file name.
GINKGO_ARGS="\
--ginkgo.timeout=$TIMEOUT \
-junit $OUTPUT_LOC \
-claimloc $OUTPUT_LOC \
--ginkgo.junit-report $OUTPUT_LOC/cnf-certification-tests_junit.xml \
-ginkgo.v \
-test.v\
"
if [[ $LABEL == "all" ]]; then
LABEL='common,extended,faredge,telco'
fi
echo "Running with label filter '$LABEL'"
echo "Report will be output to '$OUTPUT_LOC'"
echo "ginkgo arguments '${GINKGO_ARGS}'"
LABEL_STRING=''
if [ -z "$LABEL" ]; then
echo "No test label (-l) was set, so only diagnostic functions will run."
else
LABEL_STRING="-ginkgo.label-filter=${LABEL}"
fi
cd "$BASEDIR"/cnf-certification-test || exit 1
# configuring special pipeline mode
# The exit status of a pipeline is the exit status of the last command in the pipeline, unless the pipefail option
# is enabled (see The Set Builtin). If pipefail is enabled, the pipeline's return status is the value of the last (rightmost)
# command to exit with a non-zero status, or zero if all commands exit successfully.
set -o pipefail
# Do not double quote.
# SC2086: Double quote to prevent globbing and word splitting.
# shellcheck disable=SC2086
./cnf-certification-test.test \
"${LABEL_STRING}" \
${GINKGO_ARGS} |& tee $OUTPUT_LOC/tnf-execution.log
# preserving the exit status
RESULT=$?
# revert to normal mode
set +o pipefail
# exit with retrieved exit status
exit $RESULT