#! /bin/bash # This script has two different modes of operation: # if KOKKOS_NEXTSILICON_TEST_TELEMETRYLESS is anything, we run in a telemetry-less mode, where any projection error counts as a failure # else, we run the two-pass telemetry-based flow set -e # Skip nextsystemd entirely if no tests would run (respects --gtest_filter and similar args). # For GTest binaries, count test cases listed by --gtest_list_tests (indented two spaces). if ./"$1" --help 2>&1 | grep -q 'This program contains tests written using Google Test'; then _test_count=$(./"$1" "${@:2}" --gtest_list_tests 2>/dev/null | grep -c '^ ' || true) if [ "${_test_count}" -eq 0 ]; then echo "nextsilicon-test-wrapper.sh: no tests selected, skipping" exit 0 fi fi # make sure nextsystemd shuts down no matter what cleanup() { # code from last thing that ran local result=$? echo "cleanup..." nextcli system terminate || true wait ${NEXTSYSTEMD_PID} echo "exit with $result" exit $result } trap cleanup EXIT patch_dir=$(mktemp -d) # Kill any lingering NS processes left by a previously timed-out test pkill -x nextsystemd 2>/dev/null || true pkill -x nextoptd 2>/dev/null || true pkill -x nextruntimed 2>/dev/null || true pkill -f "webapps/collector/influxdb" 2>/dev/null || true rm -f "/run/user/$(id -u)/nextsystemd/observability"/*.sock 2>/dev/null || true sleep 2 if [[ -n "${KOKKOS_NEXTSILICON_TEST_TELEMETRYLESS:-}" ]]; then echo "nextsilicon-test-wrapper.sh: KOKKOS_NEXTSILICON_TEST_TELEMETRYLESS is set" # configure nextsystemd tee ${patch_dir}/kokkos.patch <&2 exit 127 fi