source: zzuf/trunk/test/check-memory @ 2545

Last change on this file since 2545 was 2545, checked in by Sam Hocevar, 12 years ago
  • Add a bunch of unit tests to check for zzuf basic capabilities: SIGSEGV and SIGFPE detection, memory exhaustion detection.
  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/bin/sh
2
3set -e
4
5DIR="$(dirname "$0")"
6ZZUF="$DIR/../src/zzuf"
7PROGRAM="$DIR/bug-memory"
8if [ ! -f "$PROGRAM" ]; then
9  echo "error: test/bug-memory is missing"
10  exit 1
11fi
12FAILED=0
13TESTED=0
14
15if [ -z "$1" ]; then
16  seed=$(date | $ZZUF -m 2>/dev/null | cut -f2 -d' ' | tr -d abcdef | cut -b1-8)
17else
18  seed="$1"
19fi
20
21echo "*** running zzuf buffer memory test with seed $seed ***"
22
23echo "*** bug-memory < /file-00"
24if ! $PROGRAM < "$DIR/file-00"; then
25    echo "unexpected exit status $?"
26    FAILED="$(($FAILED + 1))"
27else
28    echo "*** test OK ***"
29fi
30TESTED="$(($TESTED + 1))"
31
32echo "*** zzuf -qi -r0 bug-memory < /file-00"
33if ! "$ZZUF" -r0 -qi "$PROGRAM" < "$DIR/file-00"; then
34    echo "unexpected exit status $?"
35    FAILED="$(($FAILED + 1))"
36else
37    echo "*** test OK ***"
38fi
39TESTED="$(($TESTED + 1))"
40
41echo "*** zzuf -qi bug-memory < file-00"
42if "$ZZUF" -M 256 -qi "$PROGRAM" < "$DIR/file-00"; then
43    echo "unexpected exit status $?"
44    FAILED="$(($FAILED + 1))"
45else
46    echo "*** test OK ***"
47fi
48TESTED="$(($TESTED + 1))"
49
50echo ""
51if [ "$FAILED" != 0 ]; then
52    echo "*** $FAILED tests failed out of $TESTED ***"
53    exit 1
54fi
55echo "*** all $TESTED tests OK ***"
56
57exit 0
58
Note: See TracBrowser for help on using the repository browser.