blob: 064e4ae51db47cf3e1ef38a862cca4a6546fa27c [file] [log] [blame]
#!/bin/bash -u
#
# This script is one of the required scripts that get passed to
# binary_search_state.py. It's job is to test the executable that
# was generated by mixing/matching good & bad object files, and determine
# whether the resulting binary is good or bad.
#
# In this particular case, the generated binary is 'bin-trees'. This
# script runs the binary, captures its output, and compares the output
# to a file containg the correct (good) output, and three files containing
# what the bad output might look like, depending on if one of the two
# possile bad .o files was used, or if both bad .o files were used.
#
# If the output matches the known good output, this returns 0.
# If the output matches any known bad output, this returns 1.
# If the output does not match the good or bad outputs, this returns 125.
#
source full_bisect_test/common.sh
full_bisect_test/bin-trees > full_bisect_test/temp_output.txt
diff full_bisect_test/temp_output.txt full_bisect_test/good-output.txt &> /dev/null
retval=$?
if [[ ${retval} -eq 0 ]]; then
rm -f full_bisect_test/temp_output.txt
exit 0
fi
diff full_bisect_test/temp_output.txt full_bisect_test/bad-output-1.txt &> /dev/null
retval=$?
if [[ ${retval} -eq 0 ]]; then
rm -f full_bisect_test/temp_output.txt
exit 1
else
diff full_bisect_test/temp_output.txt full_bisect_test/bad-output-2.txt &> /dev/null
retval=$?
if [[ ${retval} -eq 0 ]]; then
rm -f full_bisect_test/temp_output.txt
exit 1
else
diff full_bisect_test/temp_output.txt full_bisect_test/bad-output-3.txt &> /dev/null
retval=$?
if [[ ${retval} -eq 0 ]]; then
rm -f full_bisect_test/temp_output.txt
exit 1
fi
fi
fi
rm -f full_bisect_test/temp_output.txt
exit 125