a8866524b585f0a914b9b9a4e30dddbbc78e2b82
[vpp.git] / extras / hs-test / test
1 #!/usr/bin/env bash
2
3 source vars
4
5 args=
6 single_test=0
7 persist_set=0
8 unconfigure_set=0
9 debug_set=0
10
11 for i in "$@"
12 do
13 case "${i}" in
14     --persist=*)
15         persist="${i#*=}"
16         if [ $persist = "true" ]; then
17             args="$args -persist"
18             persist_set=1
19         fi
20         ;;
21     --debug=*)
22         debug="${i#*=}"
23         if [ $debug = "true" ]; then
24             args="$args -debug"
25             debug_set=1
26         fi
27         ;;
28     --verbose=*)
29         verbose="${i#*=}"
30         if [ $verbose = "true" ]; then
31             args="$args -verbose"
32         fi
33         ;;
34     --unconfigure=*)
35         unconfigure="${i#*=}"
36         if [ $unconfigure = "true" ]; then
37             args="$args -unconfigure"
38             unconfigure_set=1
39         fi
40         ;;
41     --test=*)
42         tc_name="${i#*=}"
43         if [ $tc_name != "all" ]; then
44             single_test=1
45             args="$args -run $tc_name"
46         fi
47 esac
48 done
49
50 if [ $single_test -eq 0 ] && [ $persist_set -eq 1 ]; then
51     echo "persist flag is not supported while running all tests!"
52     exit 1
53 fi
54
55 if [ $unconfigure_set -eq 1 ] && [ $single_test -eq 0 ]; then
56     echo "a single test has to be specified when unconfigure is set"
57     exit 1
58 fi
59
60 if [ $persist_set -eq 1 ] && [ $unconfigure_set -eq 1 ]; then
61     echo "setting persist flag and unconfigure flag is not allowed"
62     exit 1
63 fi
64
65 if [ $single_test -eq 0 ] && [ $debug_set -eq 1 ]; then
66     echo "VPP debug flag is not supperted while running all tests!"
67     exit 1
68 fi
69
70 sudo -E go test -buildvcs=false -v $args