blob: 803b8f717dab81b1a69eaf4a37ee260873993eec [file] [log] [blame]
Filip Tehlar229f5fc2022-08-09 14:44:47 +00001#!/usr/bin/env bash
2
3source vars
Maros Ondrejicka87531802022-12-19 20:35:27 +01004
Filip Tehlar671cf512023-01-31 10:34:18 +01005args=
6single_test=0
7persist_set=0
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +01008unconfigure_set=0
Filip Tehlarec5c40b2023-02-28 18:59:15 +01009debug_set=0
Adrian Villinb4516bb2024-06-19 06:20:00 -040010debug_build=
Adrian Villincee15aa2024-03-14 11:42:55 -040011ginkgo_args=
Filip Tehlar671cf512023-01-31 10:34:18 +010012
13for i in "$@"
Maros Ondrejicka87531802022-12-19 20:35:27 +010014do
Filip Tehlar671cf512023-01-31 10:34:18 +010015case "${i}" in
16 --persist=*)
17 persist="${i#*=}"
Dave Wallacebee28af2024-06-14 14:59:38 -040018 if [ "$persist" = "true" ]; then
Filip Tehlar671cf512023-01-31 10:34:18 +010019 args="$args -persist"
20 persist_set=1
21 fi
22 ;;
Filip Tehlarec5c40b2023-02-28 18:59:15 +010023 --debug=*)
24 debug="${i#*=}"
Dave Wallacebee28af2024-06-14 14:59:38 -040025 if [ "$debug" = "true" ]; then
Filip Tehlarec5c40b2023-02-28 18:59:15 +010026 args="$args -debug"
27 debug_set=1
28 fi
29 ;;
Adrian Villinb4516bb2024-06-19 06:20:00 -040030 --debug_build=*)
31 debug_build="${i#*=}"
32 if [ "$debug_build" = "true" ]; then
33 args="$args -debug_build"
34 fi
35 ;;
Filip Tehlar671cf512023-01-31 10:34:18 +010036 --verbose=*)
37 verbose="${i#*=}"
Dave Wallacebee28af2024-06-14 14:59:38 -040038 if [ "$verbose" = "true" ]; then
Filip Tehlar671cf512023-01-31 10:34:18 +010039 args="$args -verbose"
40 fi
41 ;;
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010042 --unconfigure=*)
43 unconfigure="${i#*=}"
Dave Wallacebee28af2024-06-14 14:59:38 -040044 if [ "$unconfigure" = "true" ]; then
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010045 args="$args -unconfigure"
46 unconfigure_set=1
47 fi
48 ;;
Filip Tehlar608d0062023-04-28 10:29:47 +020049 --cpus=*)
50 args="$args -cpus ${i#*=}"
51 ;;
Filip Tehlar109f3ce2023-09-05 15:36:28 +020052 --vppsrc=*)
53 args="$args -vppsrc ${i#*=}"
54 ;;
Filip Tehlar671cf512023-01-31 10:34:18 +010055 --test=*)
56 tc_name="${i#*=}"
Dave Wallacebee28af2024-06-14 14:59:38 -040057 if [ "$tc_name" != "all" ]; then
Filip Tehlar671cf512023-01-31 10:34:18 +010058 single_test=1
Adrian Villincee15aa2024-03-14 11:42:55 -040059 ginkgo_args="$ginkgo_args --focus $tc_name -vv"
60 args="$args -verbose"
61 else
62 ginkgo_args="$ginkgo_args -v"
Filip Tehlar671cf512023-01-31 10:34:18 +010063 fi
Adrian Villincee15aa2024-03-14 11:42:55 -040064 ;;
65 --parallel=*)
66 ginkgo_args="$ginkgo_args -procs=${i#*=}"
Matus Fabianbbee45c2024-04-22 19:47:27 +020067 ;;
68 --repeat=*)
69 ginkgo_args="$ginkgo_args --repeat=${i#*=}"
70 ;;
Adrian Villin5d171eb2024-06-17 08:51:27 +020071 --cpu0=*)
72 cpu0="${i#*=}"
73 if [ "$cpu0" = "true" ]; then
74 args="$args -cpu0"
75 fi
76 ;;
Filip Tehlar671cf512023-01-31 10:34:18 +010077esac
Maros Ondrejicka87531802022-12-19 20:35:27 +010078done
79
Filip Tehlar671cf512023-01-31 10:34:18 +010080if [ $single_test -eq 0 ] && [ $persist_set -eq 1 ]; then
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010081 echo "persist flag is not supported while running all tests!"
82 exit 1
83fi
84
85if [ $unconfigure_set -eq 1 ] && [ $single_test -eq 0 ]; then
86 echo "a single test has to be specified when unconfigure is set"
87 exit 1
88fi
89
90if [ $persist_set -eq 1 ] && [ $unconfigure_set -eq 1 ]; then
91 echo "setting persist flag and unconfigure flag is not allowed"
Filip Tehlar671cf512023-01-31 10:34:18 +010092 exit 1
93fi
94
Filip Tehlarec5c40b2023-02-28 18:59:15 +010095if [ $single_test -eq 0 ] && [ $debug_set -eq 1 ]; then
Adrian Villinb4516bb2024-06-19 06:20:00 -040096 echo "VPP debug flag is not supported while running all tests!"
Filip Tehlarec5c40b2023-02-28 18:59:15 +010097 exit 1
98fi
99
Adrian Villin637edda2024-05-06 06:55:34 -0400100mkdir -p summary
Dave Wallacebee28af2024-06-14 14:59:38 -0400101# shellcheck disable=SC2086
Adrian Villin637edda2024-05-06 06:55:34 -0400102sudo -E go run github.com/onsi/ginkgo/v2/ginkgo --no-color --trace --json-report=summary/report.json $ginkgo_args -- $args
Adrian Villin688ac5a2024-05-10 04:19:35 -0400103
Adrian Villin6d44aab2024-06-26 10:08:47 +0200104jq -r '.[0] | .SpecReports[] | select((.State == "failed") or (.State == "timedout") or (.State == "panicked")) | select(.Failure != null) | "TestName: \(.LeafNodeText)\nSuite:\n\(.Failure.FailureNodeLocation.FileName)\nMessage:\n\(.Failure.Message)\n Full Stack Trace:\n\(.Failure.Location.FullStackTrace)\n"' summary/report.json > summary/failed-summary.log \
Dave Wallacebee28af2024-06-14 14:59:38 -0400105 && echo "Summary generated -> summary/failed-summary.log"