Skip to content

Commit

Permalink
Update test for example 1 to start testing other snapchange utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
corydu committed Nov 6, 2023
1 parent 528d476 commit 45ab232
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions examples/01_getpid/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Reset the snapshot from a previous run
pushd snapshot > /dev/null
./reset.sh
# ./reset.sh
popd > /dev/null

# Rebuild the fuzzer
Expand Down Expand Up @@ -35,9 +35,43 @@ ls snapshot/crashes/SIGSEGV* >/dev/null
STATUS=$?
if [ "$STATUS" -gt 0 ]; then
echo "Example 1 did not find crash"
ls snapchange-example-01/snapshot/crashes >/dev/null
exit 1
else
echo -e "\e[32mExample 01 SUCCESS!\e[0m"
fi

echo -e "\e[32mExample 01 fuzz SUCCESS!\e[0m"

CRASH_FILE=$(find ./snapshot/crashes/SIGSEGV* -type f | head -n 1)

### Test trace ###

## trace -- basic
cargo run -r -- trace $CRASH_FILE 2>/dev/null >/dev/null

grep unhandled_signal snapshot/traces/* >/dev/null
STATUS=$?
if [ "$STATUS" -gt 0 ]; then
echo "Example 1 failed trace test -- basic"
exit 1
fi

## trace -- no-single-step
cargo run -r -- trace $CRASH_FILE --no-single-step 2>/dev/null >/dev/null
grep INSTR snapshot/traces/*no_single_step >/dev/null
STATUS=$?
if [ "$STATUS" -gt 0 ]; then
echo "Example 1 failed trace test -- --no-single-step"
exit 1
fi

echo -e "\e[32mExample 01 trace SUCCESS!\e[0m"

### Test coverage ###

## coverage
cargo run -r -- coverage $CRASH_FILE 2>/dev/null >/dev/null
ls coverages >/dev/null
if [ "$STATUS" -gt 0 ]; then
echo "Example 1 failed coverage test"
exit 1
fi
echo -e "\e[32mExample 01 coverage SUCCESS!\e[0m"

0 comments on commit 45ab232

Please sign in to comment.