Skip to content

Instantly share code, notes, and snippets.

@vedantk
Created June 21, 2018 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vedantk/746215fadf1e191084ac82a6a4202c59 to your computer and use it in GitHub Desktop.
Save vedantk/746215fadf1e191084ac82a6a4202c59 to your computer and use it in GitHub Desktop.
Script to check whether an opt invocation is debug info invariant
#!/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