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 |
Matus Fabian | e99d266 | 2024-07-19 16:04:09 +0200 | [diff] [blame] | 10 | leak_check_set=0 |
Adrian Villin | b4516bb | 2024-06-19 06:20:00 -0400 | [diff] [blame] | 11 | debug_build= |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 12 | ginkgo_args= |
Matus Fabian | e99d266 | 2024-07-19 16:04:09 +0200 | [diff] [blame] | 13 | tc_name= |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 14 | |
| 15 | for i in "$@" |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 16 | do |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 17 | case "${i}" in |
| 18 | --persist=*) |
| 19 | persist="${i#*=}" |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 20 | if [ "$persist" = "true" ]; then |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 21 | args="$args -persist" |
| 22 | persist_set=1 |
| 23 | fi |
| 24 | ;; |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 25 | --debug=*) |
| 26 | debug="${i#*=}" |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 27 | if [ "$debug" = "true" ]; then |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 28 | args="$args -debug" |
| 29 | debug_set=1 |
| 30 | fi |
| 31 | ;; |
Adrian Villin | b4516bb | 2024-06-19 06:20:00 -0400 | [diff] [blame] | 32 | --debug_build=*) |
| 33 | debug_build="${i#*=}" |
| 34 | if [ "$debug_build" = "true" ]; then |
| 35 | args="$args -debug_build" |
| 36 | fi |
| 37 | ;; |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 38 | --verbose=*) |
| 39 | verbose="${i#*=}" |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 40 | if [ "$verbose" = "true" ]; then |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 41 | args="$args -verbose" |
| 42 | fi |
| 43 | ;; |
Maros Ondrejicka | af004dd | 2023-02-27 16:52:57 +0100 | [diff] [blame] | 44 | --unconfigure=*) |
| 45 | unconfigure="${i#*=}" |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 46 | if [ "$unconfigure" = "true" ]; then |
Maros Ondrejicka | af004dd | 2023-02-27 16:52:57 +0100 | [diff] [blame] | 47 | args="$args -unconfigure" |
| 48 | unconfigure_set=1 |
| 49 | fi |
| 50 | ;; |
Filip Tehlar | 608d006 | 2023-04-28 10:29:47 +0200 | [diff] [blame] | 51 | --cpus=*) |
| 52 | args="$args -cpus ${i#*=}" |
| 53 | ;; |
Filip Tehlar | 109f3ce | 2023-09-05 15:36:28 +0200 | [diff] [blame] | 54 | --vppsrc=*) |
| 55 | args="$args -vppsrc ${i#*=}" |
| 56 | ;; |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 57 | --test=*) |
| 58 | tc_name="${i#*=}" |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 59 | if [ "$tc_name" != "all" ]; then |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 60 | single_test=1 |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 61 | ginkgo_args="$ginkgo_args --focus $tc_name -vv" |
| 62 | args="$args -verbose" |
| 63 | else |
| 64 | ginkgo_args="$ginkgo_args -v" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 65 | fi |
Adrian Villin | cee15aa | 2024-03-14 11:42:55 -0400 | [diff] [blame] | 66 | ;; |
| 67 | --parallel=*) |
| 68 | ginkgo_args="$ginkgo_args -procs=${i#*=}" |
Matus Fabian | bbee45c | 2024-04-22 19:47:27 +0200 | [diff] [blame] | 69 | ;; |
| 70 | --repeat=*) |
| 71 | ginkgo_args="$ginkgo_args --repeat=${i#*=}" |
| 72 | ;; |
Adrian Villin | 5d171eb | 2024-06-17 08:51:27 +0200 | [diff] [blame] | 73 | --cpu0=*) |
| 74 | cpu0="${i#*=}" |
| 75 | if [ "$cpu0" = "true" ]; then |
| 76 | args="$args -cpu0" |
| 77 | fi |
| 78 | ;; |
Matus Fabian | e99d266 | 2024-07-19 16:04:09 +0200 | [diff] [blame] | 79 | --leak_check=*) |
| 80 | leak_check="${i#*=}" |
| 81 | if [ "$leak_check" = "true" ]; then |
| 82 | args="$args -leak_check" |
| 83 | leak_check_set=1 |
| 84 | fi |
| 85 | ;; |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 86 | esac |
Maros Ondrejicka | 8753180 | 2022-12-19 20:35:27 +0100 | [diff] [blame] | 87 | done |
| 88 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 89 | if [ $single_test -eq 0 ] && [ $persist_set -eq 1 ]; then |
Maros Ondrejicka | af004dd | 2023-02-27 16:52:57 +0100 | [diff] [blame] | 90 | echo "persist flag is not supported while running all tests!" |
| 91 | exit 1 |
| 92 | fi |
| 93 | |
| 94 | if [ $unconfigure_set -eq 1 ] && [ $single_test -eq 0 ]; then |
| 95 | echo "a single test has to be specified when unconfigure is set" |
| 96 | exit 1 |
| 97 | fi |
| 98 | |
| 99 | if [ $persist_set -eq 1 ] && [ $unconfigure_set -eq 1 ]; then |
| 100 | echo "setting persist flag and unconfigure flag is not allowed" |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 101 | exit 1 |
| 102 | fi |
| 103 | |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 104 | if [ $single_test -eq 0 ] && [ $debug_set -eq 1 ]; then |
Adrian Villin | b4516bb | 2024-06-19 06:20:00 -0400 | [diff] [blame] | 105 | echo "VPP debug flag is not supported while running all tests!" |
Filip Tehlar | ec5c40b | 2023-02-28 18:59:15 +0100 | [diff] [blame] | 106 | exit 1 |
| 107 | fi |
| 108 | |
Matus Fabian | e99d266 | 2024-07-19 16:04:09 +0200 | [diff] [blame] | 109 | if [ $leak_check_set -eq 1 ]; then |
| 110 | if [ $single_test -eq 0 ]; then |
| 111 | echo "a single test has to be specified when leak_check is set" |
| 112 | exit 1 |
| 113 | fi |
| 114 | ginkgo_args="--focus $tc_name" |
| 115 | sudo -E go run github.com/onsi/ginkgo/v2/ginkgo $ginkgo_args -- $args |
| 116 | exit 0 |
| 117 | fi |
| 118 | |
Matus Fabian | a330856 | 2024-07-29 13:51:51 +0200 | [diff] [blame] | 119 | if [ -n "${BUILD_NUMBER}" ]; then |
| 120 | ginkgo_args="$ginkgo_args --no-color" |
| 121 | fi |
| 122 | |
Adrian Villin | 637edda | 2024-05-06 06:55:34 -0400 | [diff] [blame] | 123 | mkdir -p summary |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 124 | # shellcheck disable=SC2086 |
Adrian Villin | 58cb6ba | 2024-08-20 14:36:12 +0200 | [diff] [blame] | 125 | sudo -E go run github.com/onsi/ginkgo/v2/ginkgo --json-report=summary/report.json $ginkgo_args -- $args |
Adrian Villin | 688ac5a | 2024-05-10 04:19:35 -0400 | [diff] [blame] | 126 | |
Adrian Villin | 399d440 | 2024-08-22 10:35:19 +0200 | [diff] [blame^] | 127 | if [ $? != 0 ]; then |
| 128 | jq -r '.[0] | .SpecReports[] | select((.State == "failed") or (.State == "timedout") or (.State == "panicked")) | select(.Failure != null) | |
| 129 | "TestName: |
| 130 | \(.LeafNodeText) |
| 131 | Suite: |
| 132 | \(.Failure.FailureNodeLocation.FileName) |
| 133 | Message: |
| 134 | \(.Failure.Message)" |
| 135 | + (if .Failure.Message == "A spec timeout occurred" then "\n" else |
| 136 | "\nFull Stack Trace: |
| 137 | \(.Failure.Location.FullStackTrace)\n" end)' summary/report.json > summary/failed-summary.log \ |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 138 | && echo "Summary generated -> summary/failed-summary.log" |
Adrian Villin | 399d440 | 2024-08-22 10:35:19 +0200 | [diff] [blame^] | 139 | fi |