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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
#!/bin/sh
LABEL=dp8390
EXEDIR=/service/dp8390
EXE=$EXEDIR/$LABEL
DAYTIME_HOST=jetsam.cs.vu.nl
FAULTS_PER_BLOCK=1
:>log
fault_blocks=0
connect_blocks=0
dont_connect=0
do_one()
{
# $1 = test-nr, $2 = count, $3 = seed
pid=''
while [ X"$pid" = X ]
do
pid=`ps ax | grep $LABEL | grep -v grep |
sed 's,^[ ]*,,;s,[ ].*,,'`
if [ X"$pid" != X ]
then
break
fi
sleep 10
done
echo pid = $pid
swifi -f $EXE $pid $1 $2 $3 >/tmp/out
sleep 1
fault_blocks=`expr $fault_blocks + 1`
if kill -0 $pid
then
if [ $dont_connect -eq 0 ]
then
if ./socket -t 10 $DAYTIME_HOST daytime < /dev/null
then
connect_blocks=`expr $connect_blocks + 1`
else
dont_connect=1
fi
fi
echo "driver failed to die, params: test $1, count $2, seed $3"
else
connect_blocks=`expr $connect_blocks + 1`
echo "driver crashed after $fault_blocks blocks"
echo "driver failed to connect after $connect_blocks blocks"
fault_blocks=0
connect_blocks=0
dont_connect=0
fi
}
one_round()
{
# $1 = count, $2 = seed
count=$1
seed=$2
echo "Seed: $seed" >> log
sync
do_one 6 $count $seed # Source fault
do_one 5 $count $seed # Destination fault
do_one 8 $count $seed # Pointer fault
do_one 14 $count $seed # Interface fault
do_one 12 $count $seed # Loop fault
do_one 0 $count $seed # Text fault
do_one 4 $count $seed # Nop fault
}
usage()
{
echo "Usage: run_t2 <count> <type> <seed>" >&2
echo \
"Valid types are: source destination pointer interface loop text nop random" >&2
exit 1
}
select_from()
{
# $1 = index, $2... = choices
index="$1"
index=`expr "$index" + 1`
shift
v=`eval echo '$'$index`
echo "$v"
}
random_type()
{
# $1 = seed
seed="$1"
r=`./rnd -m 7 -s "$seed"`
select_from "$r" 6 5 8 14 12 0 4
}
if [ $# -ne 3 ]; then usage; fi
count="$1"
type="$2"
seed="$3"
case "$type" in
source) type_arg=6
;;
destination) type_arg=5
;;
pointer) type_arg=8
;;
interface) type_arg=14
;;
loop) type_arg=12
;;
text) type_arg=0
;;
nop) type_arg=4
;;
random)
;;
*)
usage
esac
# Start our own driver.
minix-service down $LABEL
sleep 10 # Allow driver to die
minix-service up $EXE -script `pwd`/rs.restart_imm -period 3HZ
i=0
while [ $i -lt "$count" ]
do
echo "Seed: $seed"
if [ "$type" = "random" ]
then
type_arg=`random_type $seed`
fi
do_one "$type_arg" $FAULTS_PER_BLOCK $seed
i=`expr $i + 1`
seed=`expr $seed + 1`
done
connect_blocks=`expr $connect_blocks + 1`
echo "driver crashed after $fault_blocks blocks"
echo "driver failed to connect after $connect_blocks blocks"
# Restart the driver
minix-service refresh $LABEL
|