1#!/bin/bash 2 3# A helper script to use multidelta to reduce to a minimal set of tests to 4# reproduce a failure. 5# Sometimes the tests interact in unexpected ways, so you need to run two 6# or three tests in order to cause the failure to occur. It's tiresome to 7# determine a minimal subset of tests by hand; this script automates it. 8 9# I think https://github.com/DRMacIver/structureshrink would be better than 10# multidelta for this; multidelta requires strange workarounds. But 11# multidelta is readily available in most distributions' packages, so using 12# that. 13 14set -ue 15 16if ! which multidelta &>/dev/null 17then 18 echo "multidelta not found. Please install it to use this script" >&2 19 exit 1 20fi 21 22if [ $# -lt 1 ] 23then 24 printf "Usage: %s RNG_SEED [OPTIONS...]\n" "$0" >&2 25 exit 1 26fi 27 28if [ ! -x tests/cata_test ] 29then 30 printf "Please build cata_test and run this script from the top-level directory" >&2 31 exit 1 32fi 33 34export rng_seed=$1 35 36shift 37 38export REDUCE_TESTS_EXTRA_OPTS="$*" 39 40# Figure out which test executable to use 41test_exe= 42 43for potential_test_exe in ./tests/cata_test ./cata_test ./cata_test-tiles 44do 45 if [ -x "$potential_test_exe" ] 46 then 47 if [ -z "$test_exe" -o "$potential_test_exe" -nt "$test_exe" ] 48 then 49 test_exe=$potential_test_exe 50 fi 51 fi 52done 53 54if [ -z "$test_exe" ] 55then 56 echo "You don't seem to have compiled any test executable" >&2 57 exit 1 58else 59 printf "Using test executable '%s'\n" "$test_exe" 60fi 61 62export REDUCE_TESTS_TEST_EXE=$test_exe 63 64# For some reason the following cata_test command returns 140, rather than 0 (success). 65# Not sure why. 66 67# We have to add braces around the lines to avoid topformflat messing up the file. 68# The braces are removed again inside our helper script. 69"$test_exe" --list-test-names-only '~[.]' | \ 70 grep '[^ ]' | sed 's/.*/{&}/' > list_of_tests || true 71multidelta tools/reduce_tests_helper.sh list_of_tests 72 73# vim:tw=0 74