Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | source vars |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 4 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 5 | args= |
| 6 | single_test=0 |
| 7 | persist_set=0 |
Maros Ondrejicka | af004dd | 2023-02-27 16:52:57 +0100 | [diff] [blame] | 8 | unconfigure_set=0 |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 9 | debug_set=0 |
Filip Tehlar | 109f3ce | 2023-09-05 15:36:28 +0200 | [diff] [blame] | 10 | vppsrc= |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 11 | ginkgo_args= |
| 12 | parallel= |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 13 | |
| 14 | for i in "$@" |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 15 | do |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 16 | case "${i}" in |
| 17 | --persist=*) |
| 18 | persist="${i#*=}" |
| 19 | if [ $persist = "true" ]; then |
| 20 | args="$args -persist" |
| 21 | persist_set=1 |
| 22 | fi |
| 23 | ;; |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 24 | --debug=*) |
| 25 | debug="${i#*=}" |
| 26 | if [ $debug = "true" ]; then |
| 27 | args="$args -debug" |
| 28 | debug_set=1 |
| 29 | fi |
| 30 | ;; |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 31 | --verbose=*) |
| 32 | verbose="${i#*=}" |
| 33 | if [ $verbose = "true" ]; then |
| 34 | args="$args -verbose" |
| 35 | fi |
| 36 | ;; |
Maros Ondrejicka | af004dd | 2023-02-27 16:52:57 +0100 | [diff] [blame] | 37 | --unconfigure=*) |
| 38 | unconfigure="${i#*=}" |
| 39 | if [ $unconfigure = "true" ]; then |
| 40 | args="$args -unconfigure" |
| 41 | unconfigure_set=1 |
| 42 | fi |
| 43 | ;; |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 44 | --cpus=*) |
| 45 | args="$args -cpus ${i#*=}" |
| 46 | ;; |
Filip Tehlar | 109f3ce | 2023-09-05 15:36:28 +0200 | [diff] [blame] | 47 | --vppsrc=*) |
| 48 | args="$args -vppsrc ${i#*=}" |
| 49 | ;; |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 50 | --test=*) |
| 51 | tc_name="${i#*=}" |
| 52 | if [ $tc_name != "all" ]; then |
| 53 | single_test=1 |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 54 | ginkgo_args="$ginkgo_args --focus $tc_name -vv" |
| 55 | args="$args -verbose" |
| 56 | else |
| 57 | ginkgo_args="$ginkgo_args -v" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 58 | fi |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 59 | ;; |
| 60 | --parallel=*) |
| 61 | ginkgo_args="$ginkgo_args -procs=${i#*=}" |
Matus Fabian | bbee45c | 2024-04-22 19:47:27 +0200 | [diff] [blame] | 62 | ;; |
| 63 | --repeat=*) |
| 64 | ginkgo_args="$ginkgo_args --repeat=${i#*=}" |
| 65 | ;; |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 66 | esac |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 67 | done |
| 68 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 69 | if [ $single_test -eq 0 ] && [ $persist_set -eq 1 ]; then |
Maros Ondrejicka | af004dd | 2023-02-27 16:52:57 +0100 | [diff] [blame] | 70 | echo "persist flag is not supported while running all tests!" |
| 71 | exit 1 |
| 72 | fi |
| 73 | |
| 74 | if [ $unconfigure_set -eq 1 ] && [ $single_test -eq 0 ]; then |
| 75 | echo "a single test has to be specified when unconfigure is set" |
| 76 | exit 1 |
| 77 | fi |
| 78 | |
| 79 | if [ $persist_set -eq 1 ] && [ $unconfigure_set -eq 1 ]; then |
| 80 | echo "setting persist flag and unconfigure flag is not allowed" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 81 | exit 1 |
| 82 | fi |
| 83 | |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 84 | if [ $single_test -eq 0 ] && [ $debug_set -eq 1 ]; then |
| 85 | echo "VPP debug flag is not supperted while running all tests!" |
| 86 | exit 1 |
| 87 | fi |
| 88 | |
Adrian Villin | 637edda | 2024-05-06 06:55:34 -0400 | [diff] [blame] | 89 | mkdir -p summary |
| 90 | |
| 91 | sudo -E go run github.com/onsi/ginkgo/v2/ginkgo --no-color --trace --json-report=summary/report.json $ginkgo_args -- $args |
Adrian Villin | 688ac5a | 2024-05-10 04:19:35 -0400 | [diff] [blame] | 92 | |
| 93 | jq -r '.[0] | .SpecReports[] | select((.State == "failed") or (.State == "timedout") or (.State == "panicked")) | select(.Failure != null) | "TestName: \(.LeafNodeText)\nSuite:\n\(.Failure.Location.FileName)\nMessage:\n\(.Failure.Message)\n Full Stack Trace:\n\(.Failure.Location.FullStackTrace)\n"' summary/report.json > summary/failed-summary.log \ |
| 94 | && echo "Summary generated -> summary/failed-summary.log" |