echo Building...
cargo build --example leak-test
echo Running...
cargo run --example leak-test -- ${1:-keychain} &
sleep 2
rm -f /tmp/leak-test.modified.dmp /tmp/lldb-output.log
echo Dumping...
command="process save-core -s modified-memory /tmp/leak-test.modified.dmp"
lldb --attach-name leak-test --batch --one-line "$command" > /tmp/lldb-output.log
if [ $? != 0 ]; then
echo TEST ABORT - lldb failure
echo Waiting for leak test to clean up...
wait %1
exit 1
fi
echo Grepping...
strings - /tmp/leak-test.modified.dmp | grep "super-duper-password"
if [ $? == 0 ]; then
exitcode=1
echo TEST FAILED
else
exitcode=0
echo TEST SUCCEEDED.
fi
echo Waiting for leak test to clean up...
wait %1
exit $exitcode