From df293db349a71a42976b66355ebc9d8e940139ec Mon Sep 17 00:00:00 2001 From: ehouse Date: Sun, 12 Jul 2009 01:18:09 +0000 Subject: [PATCH] script to run lots of games with events at more natural intervals against relay. --- xwords4/linux/scripts/sim_real.sh | 136 ++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100755 xwords4/linux/scripts/sim_real.sh diff --git a/xwords4/linux/scripts/sim_real.sh b/xwords4/linux/scripts/sim_real.sh new file mode 100755 index 000000000..0f8eed811 --- /dev/null +++ b/xwords4/linux/scripts/sim_real.sh @@ -0,0 +1,136 @@ +#!/bin/bash + +NRUNS=${NRUNS:-4} +XWORDS=${XWORDS:-"./obj_linux_memdbg/xwords"} +DICT=${DICT:-dict.xwd} +HOST=${HOST:-localhost} +PORT=${PORT:-10999} +QUIT=${QUIT:-"-q 2"} +USE_CURSES=${USE_CURSES:="yes"} + +usage() { + echo "usage: $0 " + cat </dev/null | cksum | cut -f1 -d" ") +# echo $RAND + echo $RANDOM +} + +do_one() { + COOKIE=${1:-$(exec sh -c 'echo $PPID')} + + while :; do # loop forever (eventually) + + TODO=$(($COOKIE % 3)) + TODO=$((TODO+2)) + COUNT=0 + for NAME in Bbbbb Aaaaa Kkkkk Eeeee; do + [ $COUNT = $TODO ] && break + while :; do + RAND=$(random) + INDEX=$(( $RAND % $TODO )) + WAIT=$(( $RAND % 60 )) + case $INDEX in + 0) + if [ -z "$ZERO_DONE" ]; then + REMOTES="" + for JJ in $(seq $(($TODO-1))); do + REMOTES="$REMOTES -N"; + done + ZERO_DONE=1 + echo $COOKIE:ZERO + if [ "$USE_CURSES" = "yes" ]; then + $XWORDS -d $DICT -r $NAME -s $REMOTES \ + -a $HOST -p $PORT -C $COOKIE $QUIT -u \ + -z 0:$WAIT >/dev/null \ + 2>/tmp/log_${COOKIE}_${INDEX}.txt & + + else + $XWORDS -d $DICT -r $NAME -s $REMOTES \ + -a $HOST -p $PORT -C $COOKIE $QUIT & + fi + break + fi + ;; + 1) + if [ -z "$ONE_DONE" ]; then + ONE_DONE=1 + echo $COOKIE:ONE + if [ "$USE_CURSES" = "yes" ]; then + $XWORDS -d $DICT -r $NAME -a $HOST -p $PORT \ + -C $COOKIE $QUIT -u \ + -z 0:$WAIT >/dev/null \ + 2>/tmp/log_$COOKIE_${INDEX}.txt & + else + $XWORDS -d $DICT -r $NAME -a $HOST -p $PORT \ + -C $COOKIE $QUIT & + fi + break + fi + ;; + 2) + if [ -z "$TWO_DONE" ]; then + TWO_DONE=1 + echo $COOKIE:TWO + if [ "$USE_CURSES" = "yes" ]; then + $XWORDS -d $DICT -r $NAME -a $HOST -p $PORT \ + -C $COOKIE $QUIT -u \ + -z 0:$WAIT >/dev/null \ + 2>/tmp/log_$COOKIE_${INDEX}.txt & + + else + $XWORDS -d $DICT -r $NAME -a $HOST -p $PORT \ + -C $COOKIE $QUIT & + fi + break + fi + ;; + 3) + if [ -z "$THREE_DONE" ]; then + THREE_DONE=1 + echo $COOKIE:THREE + if [ "$USE_CURSES" = "yes" ]; then + $XWORDS -d $DICT -r $NAME -a $HOST -p $PORT \ + -C $COOKIE $QUIT -u \ + -z 0:$WAIT >/dev/null \ + 2>/tmp/log_$COOKIE_${INDEX}.txt & + else + $XWORDS -d $DICT -r $NAME -a $HOST -p $PORT \ + -C $COOKIE $QUIT & + fi + break + fi + ;; + esac + done + COUNT=$((COUNT+1)) + done + wait + break + done +} + +############################################################################ +# main + +[ -n "$1" ] && usage + +for II in $(seq $NRUNS); do + do_one $II & +done + +wait