xref: /minix/minix/commands/swifi/tests/run_t1 (revision fb9c64b2)
1#!/bin/sh
2
3LABEL=es1371
4EXEDIR=/service/es1371
5#LABEL=fxp
6#EXEDIR=/usr/build/drivers/fxp
7EXE=$EXEDIR/$LABEL
8DEV="-dev /dev/audio"
9
10:>log
11
12do_one()
13{
14	# $1 = test-nr, $2 = count, $3 = seed
15	pid=''
16	while [ X"$pid" = X ]
17	do
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
25		fi
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"
33}
34
35one_round()
36{
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
49}
50
51usage()
52{
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
57}
58
59select_from()
60{
61	# $1 = index, $2... = choices
62	index="$1"
63	index=`expr "$index" + 1`
64	shift
65	v=`eval echo '$'$index`
66	echo "$v"
67}
68
69random_type()
70{
71	# $1 = seed
72	seed="$1"
73	r=`./rnd -m 7 -s "$seed"`
74	select_from "$r" 6 5 8 14 12 0 4
75}
76
77if [ $# -ne 3 ]; then usage; fi
78count="$1"
79type="$2"
80seed="$3"
81
82case "$type" in
83source)		type_arg=6
84;;
85destination)	type_arg=5
86;;
87pointer)	type_arg=8
88;;
89interface)	type_arg=14
90;;
91loop)		type_arg=12
92;;
93text)		type_arg=0
94;;
95nop)		type_arg=4
96;;
97random)
98;;
99*)
100	usage
101esac
102
103# Start our own driver.
104minix-service down $LABEL
105sleep 2	# Allow driver to die
106minix-service up $EXE -script `pwd`/rs.restart_imm -period 3HZ $DEV
107
108i=0
109while [ $i -lt "$count" ]
110do
111	echo "Seed: $seed"
112	if [ "$type" = "random" ]
113	then
114		type_arg=`random_type $seed`
115	fi
116	do_one "$type_arg" 100 $seed
117	i=`expr $i + 1`
118	seed=`expr $seed + 1`
119done
120
121# Restart the driver
122minix-service refresh $LABEL
123