Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helper script for test reduction #30033

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions tools/reduce_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# A helper script to use multidelta to reduce to a minimal set of tests to
# reproduce a failure.
# Sometimes the tests interact in unexpected ways, so you need to run two
# or three tests in order to cause the failure to occur. It's tiresome to
# determine a minimal subset of tests by hand; this script automates it.

# I think https://github.com/DRMacIver/structureshrink would be better than
# multidelta for this; multidelta requires strange workarounds. But
# multidelta is readily available in most distributions' packages, so using
# that.

set -ue

if ! which multidelta &>/dev/null
then
echo "multidelta not found. Please install it to use this script" >&2
exit 1
fi

if [ $# != 1 ]
then
printf "Usage: %s RNG_SEED\n" "$0" >&2
exit 1
fi

if [ ! -x tests/cata_test ]
then
printf "Please build cata_test and run this script from the top-level directory" >&2
exit 1
fi

export rng_seed=$1

# For some reason the following cata_test command returns 140, rather than 0 (success).
# Not sure why.

# We have to add braces around the lines to avoid topformflat messing up the file.
# The braces are removed again inside our helper script.
./tests/cata_test --list-test-names-only '~[.]' | \
grep '[^ ]' | sed 's/.*/{&}/' > list_of_tests || true
multidelta tools/reduce_tests_helper.sh list_of_tests

# vim:tw=0
19 changes: 19 additions & 0 deletions tools/reduce_tests_helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Helper script for reduce_tests.sh

set -uex

# Disallow empty test list
if [ ! -s "$multidelta_all_files" ]
then
exit 1
fi

if ./tests/cata_test -d yes --abort --rng-seed "$rng_seed" \
-f <(tr -d '{}' < "$multidelta_all_files")
then
exit 1
fi

exit 0