File: test.sh

package info (click to toggle)
hyphen 2.5-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,292 kB
  • ctags: 216
  • sloc: sh: 10,067; ansic: 4,829; makefile: 224; perl: 148; sed: 116; awk: 26
file content (57 lines) | stat: -rwxr-xr-x 1,426 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash

function check_valgrind_log () {
if [ "$VALGRIND" != "" ]; then
  if [ -f $TEMPDIR/test.pid* ]; then
    log=`ls $TEMPDIR/test.pid*`
    if ! grep -q 'ERROR SUMMARY: 0 error' $log; then
        echo "Fail in $NAME $1 checking detected by Valgrind"
        echo "$log Valgrind log file moved to $TEMPDIR/badlogs"
        mv $log $TEMPDIR/badlogs
        exit 1
    fi
    if grep -q 'LEAK SUMMARY' $log; then
        echo "Memory leak in $NAME $1 checking detected by Valgrind"
        echo "$log Valgrind log file moved to $TEMPDIR/badlogs"
        mv $log $TEMPDIR/badlogs
        exit 1
    fi    
    rm -f $log
  fi
fi
}

if [ -d ../../_build/../tests ]; then
  TESTDIR="../../tests"
else
  TESTDIR="."
fi

TEMPDIR="./testSubDir"
NAME="$1"

if [ ! -d $TEMPDIR ]; then
  mkdir $TEMPDIR
fi

shopt -s expand_aliases

alias example='../example'

if [ "$VALGRIND" != "" ]; then
  rm -f $TEMPDIR/test.pid*
  if [ ! -d $TEMPDIR/badlogs ]; then
    mkdir $TEMPDIR/badlogs
  fi
  if [ ! -f ../.libs/lt-example ]; then
    echo "Use make check before Valgrind tests"
  else
  alias example='valgrind --tool=$VALGRIND --leak-check=yes --show-reachable=yes --log-file=$TEMPDIR/test.pid ../.libs/lt-example'
  fi
fi

example $TESTDIR/$1 $TESTDIR/$2 >$TEMPDIR/test.out$$
diff $TEMPDIR/test.out$$ $TESTDIR/$3 || exit 1
#diff $TEMPDIR/test.out$$ $TESTDIR/$3 && rm -f $TEMPDIR/*$$ || exit 1

check_valgrind_log "VALGRIND LOG"