#!/bin/sh12#3# Copyright (c) 2008 Peter Holm <[email protected]>4# All rights reserved.5#6# Redistribution and use in source and binary forms, with or without7# modification, are permitted provided that the following conditions8# are met:9# 1. Redistributions of source code must retain the above copyright10# notice, this list of conditions and the following disclaimer.11# 2. Redistributions in binary form must reproduce the above copyright12# notice, this list of conditions and the following disclaimer in the13# documentation and/or other materials provided with the distribution.14#15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25# SUCH DAMAGE.26#2728# Run 1) with no argument: the default test cases29# 2) with the "-a" arguments all the *.cfg test variations30# 3) with one argument: that specific test case3132while getopts a name; do33case $name in34a) aflag=1;;35?) printf "Usage: %s: [-a] [arg]\n" $036exit 2;;37esac38done39shift $(($OPTIND - 1))4041[ -x ./testcases/run/run ] ||42{ echo "Please run \"make\" first." && exit 1; }43[ `basename ${stress2origin:-X}` != misc ] &&44echo "Note: all.sh in stress2/misc is the preferred test to run." \451>&246find ./testcases -perm -1 \( -name "*.debug" -o -name "*.full" \) -delete \472>/dev/null48if [ ! -z "$aflag" ]; then49. ./default.cfg50export runRUNTIME=5m51t1=`date '+%s'`52while true;do53for i in `ls *.cfg | grep -v default`; do54t2=`date '+%s'`55e=` date -u -j -f '%s' '+%T' $((t2 - t1))`56echo "`date '+%Y%m%d %T'` $i, elapsed $e"57echo "`date '+%Y%m%d %T'` $i, elapsed $e" >> /tmp/all.log58logger "Starting test $i"59[ -w /dev/console ] &&60printf "`date '+%Y%m%d %T'` run $i\r\n" > /dev/console61$0 $i62done63done64else65CONFIG=./default.cfg66if [ $# -eq 1 ]; then67[ ! -r $1 ] && echo "$0: $1 not found!" && exit 168CONFIG=$169fi70. $CONFIG7172[ -z "$RUNDIR" ] && echo "$0: RUNDIR is unset!" && exit 173[ `basename $RUNDIR` != stressX ] && \74echo "$0: Basename of RUNDIR must be stressX!" && exit 275[ -d "$RUNDIR" ] && (cd $RUNDIR && find . -delete)7677[ -z "$EXCLUDETESTS" ] && EXCLUDETESTS=DuMmY7879[ -z "$TESTPROGS" ] && \80TESTPROGS=`find testcases/ -perm -1 -type f | \81egrep -v "/run/|$EXCLUDETESTS|\.full|\.debug"`82./testcases/run/run $TESTPROGS83fi848586