Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Pavel-Durov/d194c0e7192c56f059e8d3667aba8c06 to your computer and use it in GitHub Desktop.
Save Pavel-Durov/d194c0e7192c56f059e8d3667aba8c06 to your computer and use it in GitHub Desktop.
Shrinkray script for redusing the richards benchmark in awfe via shrinkray
#!/bin/bash
export YKD_SERIALISE_COMPILATION=1
export RUST_BACKTRACE=full
# Get the test file from shrinkray (it passes it as an argument)
TEST_FILE="$1"
if [ -z "$TEST_FILE" ]; then
echo "Error: No test file provided"
exit 1
fi
cd /home/pd/yk-benchmarks/suites/awfy/Lua
# Copy the test file to richards.lua since that's what the harness expects
cp "$TEST_FILE" richards.lua
# First, check if the file has substantial content
if [ ! -s richards.lua ] || [ $(wc -l < richards.lua) -lt 10 ]; then
echo "Error not found - test case is not interesting (file too small)"
exit 1
fi
# Run the benchmark and capture both stdout and stderr
~/yklua-fork/src/lua ./harness.lua richards 1 100 > /tmp/output.txt 2> /tmp/stderr.txt
cd -
# Check if the benchmark actually started and ran
if ! grep -q "Starting richards benchmark" /tmp/output.txt; then
echo "Error not found - test case is not interesting (benchmark didn't start)"
exit 1
fi
# Check if we got the specific error we're looking for
# Look for either "no entry found for key" OR "attempt to index a nil value"
if (grep -q "no entry found for key" /tmp/stderr.txt || grep -q "attempt to index a nil value" /tmp/stderr.txt) && [ -s /tmp/stderr.txt ]; then
# Make sure the error output is substantial (not just a trivial crash)
if [ $(wc -l < /tmp/stderr.txt) -gt 3 ]; then
echo "Found the error - test case is interesting"
exit 0
fi
fi
# The error did not occur or context was insufficient - this is not "interesting"
echo "Error not found - test case is not interesting"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment