re-enable munmap().
[minix.git] / commands / swifi / run_t1
blobbea5420fbf38681073ffdd118b95e065920d989e
1 #!/bin/sh
3 LABEL=es1371
4 EXEDIR=/usr/build/drivers/es1371
5 #LABEL=fxp
6 #EXEDIR=/usr/build/drivers/fxp
7 EXE=$EXEDIR/$LABEL
8 DEV="-dev /dev/audio"
10 :>log
12 do_one()
14 # $1 = test-nr, $2 = count, $3 = seed
15 pid=''
16 while [ X"$pid" = X ]
18 ps ax | grep $LABEL | grep -v grep
19 pid=`ps ax | grep $LABEL | grep -v grep |
20 sort -n | tail -1 |
21 sed 's,^[ ]*,,;s,[ ].*,,`
22 if [ X"$pid" != X ]
23 then
24 break
26 sleep 10
27 done
28 echo pid = $pid
29 ./swifi -f $EXE $pid $1 $2 $3 >/tmp/out
30 sleep 1
31 kill -0 $pid &&
32 echo "driver failed to die, params: test $1, count $2, seed $3"
35 one_round()
37 # $1 = count, $2 = seed
38 count=$1
39 seed=$2
40 echo "Seed: $seed" >> log
41 sync
42 do_one 6 $count $seed # Source fault
43 do_one 5 $count $seed # Destination fault
44 do_one 8 $count $seed # Pointer fault
45 do_one 14 $count $seed # Interface fault
46 do_one 12 $count $seed # Loop fault
47 do_one 0 $count $seed # Text fault
48 do_one 4 $count $seed # Nop fault
51 usage()
53 echo "Usage: run_t1 <count> <type> <seed>" >&2
54 echo \
55 "Valid types are: source destination pointer interface loop text nop random" >&2
56 exit 1
59 select_from()
61 # $1 = index, $2... = choices
62 index="$1"
63 index=`expr "$index" + 1`
64 shift
65 v=`eval echo '$'$index`
66 echo "$v"
69 random_type()
71 # $1 = seed
72 seed="$1"
73 r=`./rnd -m 7 -s "$seed"`
74 select_from "$r" 6 5 8 14 12 0 4
77 if [ $# -ne 3 ]; then usage; fi
78 count="$1"
79 type="$2"
80 seed="$3"
82 case "$type" in
83 source) type_arg=6
85 destination) type_arg=5
87 pointer) type_arg=8
89 interface) type_arg=14
91 loop) type_arg=12
93 text) type_arg=0
95 nop) type_arg=4
97 random)
100 usage
101 esac
103 # Start our own driver.
104 service down $LABEL
105 sleep 2 # Allow driver to die
106 service up $EXE -script `pwd`/rs.restart_imm -config /etc/drivers.conf -period 3HZ $DEV
109 while [ $i -lt "$count" ]
111 echo "Seed: $seed"
112 if [ "$type" = "random" ]
113 then
114 type_arg=`random_type $seed`
116 do_one "$type_arg" 100 $seed
117 i=`expr $i + 1`
118 seed=`expr $seed + 1`
119 done
121 # Restart the driver
122 service refresh $LABEL