Drop main() prototype. Syncs with NetBSD-8
[minix.git] / minix / commands / swifi / tests / run_t2
blob88be6dd9d5042950e1786d1b45b54c8d6b2bf1db
1 #!/bin/sh
3 LABEL=dp8390
4 EXEDIR=/service/dp8390
5 EXE=$EXEDIR/$LABEL
6 DAYTIME_HOST=jetsam.cs.vu.nl
7 FAULTS_PER_BLOCK=1
9 :>log
11 fault_blocks=0
12 connect_blocks=0
13 dont_connect=0
15 do_one()
17 # $1 = test-nr, $2 = count, $3 = seed
18 pid=''
19 while [ X"$pid" = X ]
21 pid=`ps ax | grep $LABEL | grep -v grep |
22 sed 's,^[ ]*,,;s,[ ].*,,'`
23 if [ X"$pid" != X ]
24 then
25 break
27 sleep 10
28 done
29 echo pid = $pid
30 swifi -f $EXE $pid $1 $2 $3 >/tmp/out
31 sleep 1
32 fault_blocks=`expr $fault_blocks + 1`
33 if kill -0 $pid
34 then
35 if [ $dont_connect -eq 0 ]
36 then
37 if ./socket -t 10 $DAYTIME_HOST daytime < /dev/null
38 then
39 connect_blocks=`expr $connect_blocks + 1`
40 else
41 dont_connect=1
44 echo "driver failed to die, params: test $1, count $2, seed $3"
45 else
46 connect_blocks=`expr $connect_blocks + 1`
47 echo "driver crashed after $fault_blocks blocks"
48 echo "driver failed to connect after $connect_blocks blocks"
49 fault_blocks=0
50 connect_blocks=0
51 dont_connect=0
55 one_round()
57 # $1 = count, $2 = seed
58 count=$1
59 seed=$2
60 echo "Seed: $seed" >> log
61 sync
62 do_one 6 $count $seed # Source fault
63 do_one 5 $count $seed # Destination fault
64 do_one 8 $count $seed # Pointer fault
65 do_one 14 $count $seed # Interface fault
66 do_one 12 $count $seed # Loop fault
67 do_one 0 $count $seed # Text fault
68 do_one 4 $count $seed # Nop fault
71 usage()
73 echo "Usage: run_t2 <count> <type> <seed>" >&2
74 echo \
75 "Valid types are: source destination pointer interface loop text nop random" >&2
76 exit 1
79 select_from()
81 # $1 = index, $2... = choices
82 index="$1"
83 index=`expr "$index" + 1`
84 shift
85 v=`eval echo '$'$index`
86 echo "$v"
89 random_type()
91 # $1 = seed
92 seed="$1"
93 r=`./rnd -m 7 -s "$seed"`
94 select_from "$r" 6 5 8 14 12 0 4
97 if [ $# -ne 3 ]; then usage; fi
98 count="$1"
99 type="$2"
100 seed="$3"
102 case "$type" in
103 source) type_arg=6
105 destination) type_arg=5
107 pointer) type_arg=8
109 interface) type_arg=14
111 loop) type_arg=12
113 text) type_arg=0
115 nop) type_arg=4
117 random)
120 usage
121 esac
123 # Start our own driver.
124 minix-service down $LABEL
125 sleep 10 # Allow driver to die
126 minix-service up $EXE -script `pwd`/rs.restart_imm -period 3HZ
129 while [ $i -lt "$count" ]
131 echo "Seed: $seed"
132 if [ "$type" = "random" ]
133 then
134 type_arg=`random_type $seed`
136 do_one "$type_arg" $FAULTS_PER_BLOCK $seed
137 i=`expr $i + 1`
138 seed=`expr $seed + 1`
139 done
141 connect_blocks=`expr $connect_blocks + 1`
142 echo "driver crashed after $fault_blocks blocks"
143 echo "driver failed to connect after $connect_blocks blocks"
145 # Restart the driver
146 minix-service refresh $LABEL