blob: 28df3e565fe27a52b20f1e4c3f06f71d38b8d877 [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 Villincee15aa2024-03-14 11:42:55 -040010ginkgo_args=
Filip Tehlar671cf512023-01-31 10:34:18 +010011
12for i in "$@"
Maros Ondrejicka87531802022-12-19 20:35:27 +010013do
Filip Tehlar671cf512023-01-31 10:34:18 +010014case "${i}" in
15 --persist=*)
16 persist="${i#*=}"
Dave Wallacebee28af2024-06-14 14:59:38 -040017 if [ "$persist" = "true" ]; then
Filip Tehlar671cf512023-01-31 10:34:18 +010018 args="$args -persist"
19 persist_set=1
20 fi
21 ;;
Filip Tehlarec5c40b2023-02-28 18:59:15 +010022 --debug=*)
23 debug="${i#*=}"
Dave Wallacebee28af2024-06-14 14:59:38 -040024 if [ "$debug" = "true" ]; then
Filip Tehlarec5c40b2023-02-28 18:59:15 +010025 args="$args -debug"
26 debug_set=1
27 fi
28 ;;
Filip Tehlar671cf512023-01-31 10:34:18 +010029 --verbose=*)
30 verbose="${i#*=}"
Dave Wallacebee28af2024-06-14 14:59:38 -040031 if [ "$verbose" = "true" ]; then
Filip Tehlar671cf512023-01-31 10:34:18 +010032 args="$args -verbose"
33 fi
34 ;;
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010035 --unconfigure=*)
36 unconfigure="${i#*=}"
Dave Wallacebee28af2024-06-14 14:59:38 -040037 if [ "$unconfigure" = "true" ]; then
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010038 args="$args -unconfigure"
39 unconfigure_set=1
40 fi
41 ;;
Filip Tehlar608d0062023-04-28 10:29:47 +020042 --cpus=*)
43 args="$args -cpus ${i#*=}"
44 ;;
Filip Tehlar109f3ce2023-09-05 15:36:28 +020045 --vppsrc=*)
46 args="$args -vppsrc ${i#*=}"
47 ;;
Filip Tehlar671cf512023-01-31 10:34:18 +010048 --test=*)
49 tc_name="${i#*=}"
Dave Wallacebee28af2024-06-14 14:59:38 -040050 if [ "$tc_name" != "all" ]; then
Filip Tehlar671cf512023-01-31 10:34:18 +010051 single_test=1
Adrian Villincee15aa2024-03-14 11:42:55 -040052 ginkgo_args="$ginkgo_args --focus $tc_name -vv"
53 args="$args -verbose"
54 else
55 ginkgo_args="$ginkgo_args -v"
Filip Tehlar671cf512023-01-31 10:34:18 +010056 fi
Adrian Villincee15aa2024-03-14 11:42:55 -040057 ;;
58 --parallel=*)
59 ginkgo_args="$ginkgo_args -procs=${i#*=}"
Matus Fabianbbee45c2024-04-22 19:47:27 +020060 ;;
61 --repeat=*)
62 ginkgo_args="$ginkgo_args --repeat=${i#*=}"
63 ;;
Filip Tehlar671cf512023-01-31 10:34:18 +010064esac
Maros Ondrejicka87531802022-12-19 20:35:27 +010065done
66
Filip Tehlar671cf512023-01-31 10:34:18 +010067if [ $single_test -eq 0 ] && [ $persist_set -eq 1 ]; then
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010068 echo "persist flag is not supported while running all tests!"
69 exit 1
70fi
71
72if [ $unconfigure_set -eq 1 ] && [ $single_test -eq 0 ]; then
73 echo "a single test has to be specified when unconfigure is set"
74 exit 1
75fi
76
77if [ $persist_set -eq 1 ] && [ $unconfigure_set -eq 1 ]; then
78 echo "setting persist flag and unconfigure flag is not allowed"
Filip Tehlar671cf512023-01-31 10:34:18 +010079 exit 1
80fi
81
Filip Tehlarec5c40b2023-02-28 18:59:15 +010082if [ $single_test -eq 0 ] && [ $debug_set -eq 1 ]; then
83 echo "VPP debug flag is not supperted while running all tests!"
84 exit 1
85fi
86
Adrian Villin637edda2024-05-06 06:55:34 -040087mkdir -p summary
Dave Wallacebee28af2024-06-14 14:59:38 -040088# shellcheck disable=SC2086
Adrian Villin637edda2024-05-06 06:55:34 -040089sudo -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 -040090
91jq -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 \
Dave Wallacebee28af2024-06-14 14:59:38 -040092 && echo "Summary generated -> summary/failed-summary.log"