blob: 398e2b39edb5d33322df1830f5c5a9ee7a8bce6f [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
Filip Tehlar109f3ce2023-09-05 15:36:28 +020010vppsrc=
Adrian Villincee15aa2024-03-14 11:42:55 -040011ginkgo_args=
12parallel=
Filip Tehlar671cf512023-01-31 10:34:18 +010013
14for i in "$@"
Maros Ondrejicka87531802022-12-19 20:35:27 +010015do
Filip Tehlar671cf512023-01-31 10:34:18 +010016case "${i}" in
17 --persist=*)
18 persist="${i#*=}"
19 if [ $persist = "true" ]; then
20 args="$args -persist"
21 persist_set=1
22 fi
23 ;;
Filip Tehlarec5c40b2023-02-28 18:59:15 +010024 --debug=*)
25 debug="${i#*=}"
26 if [ $debug = "true" ]; then
27 args="$args -debug"
28 debug_set=1
29 fi
30 ;;
Filip Tehlar671cf512023-01-31 10:34:18 +010031 --verbose=*)
32 verbose="${i#*=}"
33 if [ $verbose = "true" ]; then
34 args="$args -verbose"
35 fi
36 ;;
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010037 --unconfigure=*)
38 unconfigure="${i#*=}"
39 if [ $unconfigure = "true" ]; then
40 args="$args -unconfigure"
41 unconfigure_set=1
42 fi
43 ;;
Filip Tehlar608d0062023-04-28 10:29:47 +020044 --cpus=*)
45 args="$args -cpus ${i#*=}"
46 ;;
Filip Tehlar109f3ce2023-09-05 15:36:28 +020047 --vppsrc=*)
48 args="$args -vppsrc ${i#*=}"
49 ;;
Filip Tehlar671cf512023-01-31 10:34:18 +010050 --test=*)
51 tc_name="${i#*=}"
52 if [ $tc_name != "all" ]; then
53 single_test=1
Adrian Villincee15aa2024-03-14 11:42:55 -040054 ginkgo_args="$ginkgo_args --focus $tc_name -vv"
55 args="$args -verbose"
56 else
57 ginkgo_args="$ginkgo_args -v"
Filip Tehlar671cf512023-01-31 10:34:18 +010058 fi
Adrian Villincee15aa2024-03-14 11:42:55 -040059 ;;
60 --parallel=*)
61 ginkgo_args="$ginkgo_args -procs=${i#*=}"
Matus Fabianbbee45c2024-04-22 19:47:27 +020062 ;;
63 --repeat=*)
64 ginkgo_args="$ginkgo_args --repeat=${i#*=}"
65 ;;
Filip Tehlar671cf512023-01-31 10:34:18 +010066esac
Maros Ondrejicka87531802022-12-19 20:35:27 +010067done
68
Filip Tehlar671cf512023-01-31 10:34:18 +010069if [ $single_test -eq 0 ] && [ $persist_set -eq 1 ]; then
Maros Ondrejickaaf004dd2023-02-27 16:52:57 +010070 echo "persist flag is not supported while running all tests!"
71 exit 1
72fi
73
74if [ $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
77fi
78
79if [ $persist_set -eq 1 ] && [ $unconfigure_set -eq 1 ]; then
80 echo "setting persist flag and unconfigure flag is not allowed"
Filip Tehlar671cf512023-01-31 10:34:18 +010081 exit 1
82fi
83
Filip Tehlarec5c40b2023-02-28 18:59:15 +010084if [ $single_test -eq 0 ] && [ $debug_set -eq 1 ]; then
85 echo "VPP debug flag is not supperted while running all tests!"
86 exit 1
87fi
88
Adrian Villin637edda2024-05-06 06:55:34 -040089mkdir -p summary
90
91sudo -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 -040092
93jq -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"