fixing stuff
[dyninst.git] / dyninstAPI / tests / src / test11.sh
1 #!/bin/sh
2
3 GREP="grep -q"
4 GZIP=gzip
5 PS=ps
6 EXPR=expr
7
8 FAIL_COUNT=0
9 SUCCESS_STR='information: the execution of mutatee terminates...'
10
11 if [ x$PLATFORM = x ]; then
12     echo Environment variable PLATFORM must be set prior to running this test.
13     exit
14 fi
15
16 # Find our way to core/codeCoverge
17 case `basename $PWD` in
18     testprog)
19         cd ../../..
20         BASEDIR=`pwd`/core
21         SCRIPTDIR=`pwd`/scripts
22         ;;
23     $PLATFORM)
24         cd ../../../..
25         BASEDIR=`pwd`/core
26         SCRIPTDIR=`pwd`/scripts
27         ;;
28     *)
29         if [ x$PARADYN_BASE = x ]; then
30             BASEDIR=$DYNINST_ROOT/core
31             SCRIPTDIR=$DYNINST_ROOT/scripts
32         else
33             BASEDIR=$PARADYN_BASE/core
34             SCRIPTDIR=$PARADYN_BASE/scripts
35         fi
36         ;;
37 esac
38
39 if [ ! -d $BASEDIR ]; then
40     echo "I cannot find the codeCoverage directory."
41     exit
42 fi
43
44 runTest() {
45     TESTNUM=$1
46     TESTSTR=$2
47     shift 2
48
49     ($SCRIPTDIR/timer.pl -t 1200 -r '^\S*ijpeg' -r '^\S*cc1' -r '\S*dyncov' $@ 2>&1) | $GREP "$SUCCESS_STR"
50     RETVAL=$?
51
52     if [ -f core ]; then
53         echo "**Failed** test #$TESTNUM ($TESTSTR)"
54         echo "    - Core file produced."
55         FAIL_COUNT=`$EXPR $FAIL_COUNT + 1`
56         rm -f core
57
58     elif [ $RETVAL != 0 ]; then
59         echo "**Failed** test #$TESTNUM ($TESTSTR)"
60         echo "    - Success string not found in output."
61         FAIL_COUNT=`$EXPR $FAIL_COUNT + 1`
62
63     else
64         echo "Passed test #$TESTNUM ($TESTSTR)"
65     fi
66 }
67
68 cd $BASEDIR/codeCoverage/$PLATFORM/tests/ijpeg
69 DYNCOV_IJPEG_ARGS="--run ./ijpeg
70                    -image_file specmun.ppm
71                    -compression.quality 90
72                    -compression.optimize_coding 0
73                    -compression.smoothing_factor 90
74                    -difference.image 1
75                    -difference.x_stride 10
76                    -difference.y_stride 10
77                    -verbose 1 -GO.findoptcomp"
78
79 # Fake output to simulate standard test
80 echo "*** dyninstAPI test11..."
81 echo 
82 echo "[Tests with ijpeg]"
83 $GZIP -df ijpeg.gz
84 echo
85 echo '"test11 -mutatee test11.mutatee_ijpeg"'
86 echo
87 runTest 1 'IJPEG Pre-Instrumentation, All Blocks'                       \
88         ../../dyncov $DYNCOV_IJPEG_ARGS
89 runTest 2 'IJPEG Pre-Instrumentation, All Blocks, Deletion'             \
90         ../../dyncov --del 10 $DYNCOV_IJPEG_ARGS
91 runTest 3 'IJPEG Pre-Instrumentation, Dominator'                        \
92         ../../dyncov --dom $DYNCOV_IJPEG_ARGS
93 runTest 4 'IJPEG Pre-Instrumentation, Dominator, Deletion'              \
94         ../../dyncov --dom --del 10 $DYNCOV_IJPEG_ARGS
95 runTest 5 'IJPEG On-Demand Instrumentation, All Blocks'                 \
96         ../../dyncov --ond $DYNCOV_IJPEG_ARGS
97 runTest 6 'IJPEG On-Demand Instrumentation, All Blocks, Deletion'       \
98         ../../dyncov --ond --del 10 $DYNCOV_IJPEG_ARGS
99 runTest 7 'IJPEG On-Demand Instrumentation, Dominator'                  \
100         ../../dyncov --ond --dom $DYNCOV_IJPEG_ARGS
101 runTest 8 'IJPEG On-Demand Instrumentation, Dominator, Deletion'        \
102         ../../dyncov --ond --dom --del 10 $DYNCOV_IJPEG_ARGS
103
104 echo
105 if [ $FAIL_COUNT = 0 ]; then
106     echo "All tests passed"
107
108 elif [ $FAIL_COUNT = 1 ]; then
109     echo "**Failed** $FAIL_COUNT test"
110
111 else
112     echo "**Failed** $FAIL_COUNT tests"
113 fi
114
115 FAIL_COUNT=0
116
117 cd $BASEDIR/codeCoverage/$PLATFORM/tests/cc1
118 DYNCOV_CC1_ARGS="--run ./cc1 `/bin/ls *.i`"
119
120 # Fake output to simulate standard test
121 echo
122 echo "[Tests with cc1]"
123 $GZIP -df cc1.gz
124 echo
125 echo '"test11 -mutatee test11.mutatee_cc1"'
126 echo
127 runTest 1 'cc1 Pre-Instrumentation, All Blocks'                         \
128         ../../dyncov $DYNCOV_CC1_ARGS
129 runTest 2 'cc1 Pre-Instrumentation, All Blocks, Deletion'               \
130         ../../dyncov --del 10 $DYNCOV_CC1_ARGS
131 runTest 3 'cc1 Pre-Instrumentation, Dominator'                          \
132         ../../dyncov --dom $DYNCOV_CC1_ARGS
133 runTest 4 'cc1 Pre-Instrumentation, Dominator, Deletion'                \
134         ../../dyncov --dom --del 10 $DYNCOV_CC1_ARGS
135 runTest 5 'cc1 On-Demand Instrumentation, All Blocks'                   \
136         ../../dyncov --ond $DYNCOV_CC1_ARGS
137 runTest 6 'cc1 On-Demand Instrumentation, All Blocks, Deletion'         \
138         ../../dyncov --ond --del 10 $DYNCOV_CC1_ARGS
139 runTest 7 'cc1 On-Demand Instrumentation, Dominator'                    \
140         ../../dyncov --ond --dom $DYNCOV_CC1_ARGS
141 runTest 8 'cc1 On-Demand Instrumentation, Dominator, Deletion'          \
142         ../../dyncov --ond --dom --del 10 $DYNCOV_CC1_ARGS
143
144 echo
145 if [ $FAIL_COUNT = 0 ]; then
146     echo "All tests passed"
147
148 elif [ $FAIL_COUNT = 1 ]; then
149     echo "**Failed** $FAIL_COUNT test"
150
151 else
152     echo "**Failed** $FAIL_COUNT tests"
153 fi