blob: 107fc686176192614731fb76eaeffec2b1e76916 [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 ;;
Filip Tehlar671cf512023-01-31 10:34:18 +010071esac
Maros Ondrejicka87531802022-12-19 20:35:27 +010072done
73
Filip Tehlar671cf512023-01-31 10:34:18 +010074if [ $single_test -eq 0 ] && [ $persist_set -eq 1 ]; then
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010075 echo "persist flag is not supported while running all tests!"
76 exit 1
77fi
78
79if [ $unconfigure_set -eq 1 ] && [ $single_test -eq 0 ]; then
80 echo "a single test has to be specified when unconfigure is set"
81 exit 1
82fi
83
84if [ $persist_set -eq 1 ] && [ $unconfigure_set -eq 1 ]; then
85 echo "setting persist flag and unconfigure flag is not allowed"
Filip Tehlar671cf512023-01-31 10:34:18 +010086 exit 1
87fi
88
Filip Tehlarec5c40b2023-02-28 18:59:15 +010089if [ $single_test -eq 0 ] && [ $debug_set -eq 1 ]; then
Adrian Villinb4516bb2024-06-19 06:20:00 -040090 echo "VPP debug flag is not supported while running all tests!"
Filip Tehlarec5c40b2023-02-28 18:59:15 +010091 exit 1
92fi
93
Adrian Villin637edda2024-05-06 06:55:34 -040094mkdir -p summary
Dave Wallacebee28af2024-06-14 14:59:38 -040095# shellcheck disable=SC2086
Adrian Villin637edda2024-05-06 06:55:34 -040096sudo -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 -040097
Adrian Villin6d44aab2024-06-26 10:08:47 +020098jq -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 -040099 && echo "Summary generated -> summary/failed-summary.log"