root/test/stress-gdb.sh

Revision 03be3fd1811b0b0f9348760cae484adacfc69998, 1.5 kB (checked in by Hans Petter Jansson <hpj@gong.(none)>, 2 years ago)

Allow commenting out tests from tests.list using '#'.

  • Property mode set to 100755
Line 
1 #!/bin/bash
2
3 # Runs battery of tests forever, with debug output. If
4 # a test fails, the log is enumerated and saved, and a
5 # diagnostic is printed to stdout.
6 #
7 # This variant runs tests under gdb, and tries to get
8 # a backtrace on failure.
9
10 export MALLOC_CHECK_=2
11 export MALLOC_PERTURB_=a
12
13 let n=0
14 let m=0
15
16 # Check prerequisites
17
18 for util in gdb expect dos2unix; do
19   if ! which $util >/dev/null 2>&1; then
20     echo "The '$util' utility was not found in your path. Aborting."
21     exit 1
22   fi
23 done
24
25 # Make sure binaries are created in .libs
26
27 echo -n "Preparing... "
28
29 for i in $(grep "^[ \t]*[^#]" tests.list); do
30   ./$i >/dev/null 2>&1;
31 done
32
33 echo "done"
34
35 while true; do
36   echo -n -e "\rIterations: $m"
37
38   for i in $(grep "^[ \t]*[^#]" tests.list); do
39     cat <<EOF >.expect-commands
40 proc send {ignore arg} {
41   sleep .1
42   exp_send -- \$arg
43 }
44
45 proc sendctrlc {} {
46   send -- ""
47 }
48
49 set timeout 120
50 spawn gdb -n -q .libs/lt-$i
51 match_max 100000
52 expect -exact "(gdb) "
53 send -- "set pagination off\r"
54 expect -exact "(gdb) "
55 send -- "run -n -v\r"
56 expect {
57   timeout {
58     sendctrlc
59     exp_continue
60   }
61   "(gdb) "
62 }
63 send -- "t a a bt\r"
64 expect -exact "(gdb) "
65 send -- "quit\r"
66 expect {
67   "(y or n) " {
68     send -- "y\r"
69     exp_continue
70   }
71   eof
72 }
73 EOF
74
75     # We need the dos2unix stage for grep's sake.
76     expect -f .expect-commands 2>&1 | dos2unix > out
77
78     if ! grep -L 'passed' out >/dev/null 2>&1; then
79       echo -e '\nFailure: ' $i
80       mv out stress-gdb-failure-$n.log
81       let n=$n+1
82     fi
83   done
84
85   let m=$m+1
86
87   sleep 1
88 done 2>&1
89
90 rm .expect-commands
Note: See TracBrowser for help on using the browser.