#!/bin/sh
#
####################################################
#     This software released to the public domain  #
#     without restrictions of any kind.            #
####################################################
#
#	@(#)obench	3.3 10/25/89

def_baud="9600 exta extb"
def_mode="opost -opost"

tty=
baud=
mode=
len=
min=0

while [ "$1" ]
do
	case "$1" in

	50|75|110|1200|2400|4800|9600|19200|38400|exta|extb)
		def_baud=
		baud="$baud $1"
		;;
	
	[1-9]|1[0-6])
		min=$1
		;;

	opost|-opost)
		def_mode=
		mode="$mode $1"
		;;
	
	/dev/*)
		tty="$tty $1"
		;;

	tty*|cu*)
		tty="$tty /dev/$1"
		;;
	
	*)
		tty="$tty /dev/tty$1"
		;;
	esac

	shift
done

baud="$def_baud $baud"
mode="$def_mode $mode"

(perf -s 999999 >/dev/null) 2>&1

for b in $baud
do
	case $b in
	50) vol=574000 ;;
	75) vol=768000 ;;
	110) vol=1152000 ;;
	1200) vol=12000 ;;
	2400) vol=24000 ;;
	4800) vol=48000 ;;
	9600) vol=96000 ;;
	exta|19200) vol=192000 ;;
	extb|38400) vol=384000 ;;
	esac

	for m in $mode
	do
		t=
		n=0

		for i in $tty
		do
			t="$t $i"
			n=`expr $n + 1`

			[ $n -ge $min ] || continue

			echo "TEST tty=$n, baud=$b, mode=$m"

			for j in $t
			do
				(
				stty $b $m -ixon -ixoff
				sleep 10
				perf $vol
				) >$j <&1 &
			done

			sleep 30
			cpu -t 50

			wait
		done
	done
done 2>&1
