Created
June 21, 2018 19:19
-
-
Save vedantk/746215fadf1e191084ac82a6a4202c59 to your computer and use it in GitHub Desktop.
Script to check whether an opt invocation is debug info invariant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
OPT=$1 | |
shift 1 | |
TEST_FILE=$1 | |
shift 1 | |
strip_cmd() { | |
$OPT -disable-verify -strip -strip-dead-prototypes -strip-named-metadata -o - $* | |
} | |
unstripped_log=$(mktemp) | |
strip_cmd $TEST_FILE | $OPT $* > $unstripped_log | |
result="$?" | |
if [[ $result != "0" ]]; then | |
rm $unstripped_log | |
echo ":: The baseline had errors ($result), skipping" | |
exit 0 | |
fi | |
baseline_log=$(mktemp) | |
cat $unstripped_log | strip_cmd -S > $baseline_log | |
rm $unstripped_log | |
with_di_log=$(mktemp) | |
strip_cmd $TEST_FILE | $OPT $* -disable-verify -debugify-quiet -debugify-each | strip_cmd -S > $with_di_log | |
echo "Comparing: $* $TEST_FILE" | |
echo " Baseline: $baseline_log" | |
echo " With DI : $with_di_log" | |
diff $baseline_log $with_di_log | |
result="$?" | |
if [[ $result == "0" ]]; then | |
rm $baseline_log $with_di_log | |
exit 0 | |
else | |
echo ":: Found a test case ^" | |
exit $result | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment