legacy_test.sh revision 17849
116491Swosch#!/bin/sh 216491Swosch# 317849Swosch# Copyright (c) June 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. 417849Swosch# All rights reserved. 517849Swosch# 617849Swosch# Redistribution and use in source and binary forms, with or without 717849Swosch# modification, are permitted provided that the following conditions 817849Swosch# are met: 917849Swosch# 1. Redistributions of source code must retain the above copyright 1017849Swosch# notice, this list of conditions and the following disclaimer. 1117849Swosch# 2. Redistributions in binary form must reproduce the above copyright 1217849Swosch# notice, this list of conditions and the following disclaimer in the 1317849Swosch# documentation and/or other materials provided with the distribution. 1417849Swosch# 1517849Swosch# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1617849Swosch# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1717849Swosch# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1817849Swosch# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1917849Swosch# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2017849Swosch# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2117849Swosch# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2217849Swosch# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2317849Swosch# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2417849Swosch# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2517849Swosch# SUCH DAMAGE. 2617849Swosch# 2716491Swosch# TEST.sh - check if test(1) or builtin test works 2816491Swosch# 2917849Swosch# $Id: TEST.sh,v 1.1 1996/06/19 00:44:44 wosch Exp $ 3016491Swosch 3116491Swosch# force a specified test program, e.g. `env test=/bin/test sh TEST.sh' 3216491Swosch: ${test=test} 3316491Swosch 3416491SwoschERROR=0 FAILED=0 3516491Swosch 3616491Swoscht () 3716491Swosch{ 3816491Swosch # $1 -> exit code 3916491Swosch # $2 -> $test expression 4016491Swosch 4116491Swosch echo -n "$test $2 " 4216491Swosch 4316491Swosch # check for syntax errors 4416491Swosch syntax="`eval $test $2 2>&1`" 4516491Swosch if test -z "$syntax"; then 4616491Swosch 4716491Swosch case $1 in 4816491Swosch 0) if eval $test $2; then echo " OK"; else failed;fi;; 4916491Swosch 1) if eval $test $2; then failed; else echo " OK";fi;; 5016491Swosch esac 5116491Swosch 5216491Swosch else 5316491Swosch error 5416491Swosch fi 5516491Swosch} 5616491Swosch 5716491Swoscherror () 5816491Swosch{ 5916491Swosch echo ""; echo " $syntax" 6016491Swosch ERROR=`expr $ERROR + 1` 6116491Swosch} 6216491Swosch 6316491Swoschfailed () 6416491Swosch{ 6516491Swosch echo ""; echo " failed" 6616491Swosch FAILED=`expr $FAILED + 1` 6716491Swosch} 6816491Swosch 6916491Swosch 7016491Swoscht 0 'b = b' 7116491Swoscht 1 'b != b' 7216491Swoscht 0 '\( b = b \)' 7316491Swoscht 1 '! \( b = b \)' 7416491Swoscht 1 '! -f /etc/passwd' 7516491Swosch 7616491Swoscht 0 '-h = -h' 7716491Swoscht 0 '-o = -o' 7816491Swosch 7916491Swoscht 1 '-f = h' 8016491Swoscht 1 '-h = f' 8116491Swoscht 1 '-o = f' 8216491Swoscht 1 'f = -o' 8316491Swoscht 0 '\( -h = -h \)' 8416491Swoscht 1 '\( a = -h \)' 8516491Swoscht 1 '\( -f = h \)' 8616491Swosch 8716491Swosch 8816491Swoscht 1 '\( -f = h \)' 8916491Swosch 9016491Swoscht 0 '-h = -h -o a' 9116491Swoscht 0 '\( -h = -h \) -o 1' 9216491Swosch 9316491Swoscht 0 '-h = -h -o -h = -h' 9416491Swoscht 0 '\( -h = -h \) -o \( -h = -h \)' 9516491Swosch 9616491Swoscht 0 '-d /' 9716491Swoscht 0 '-d / -a a != b' 9816491Swoscht 1 '-z "-z"' 9916491Swoscht 0 '-n -n' 10016491Swoscht 0 '0 -eq 0' 10116491Swoscht 0 '\( 0 -eq 0 \)' 10216491Swoscht 1 '1 -eq 0 -o a = a -a 1 -eq 0 -o a = aa' 10316491Swosch 10416491Swoscht 0 '0' 10516491Swoscht 0 '\( 0 \)' 10616491Swoscht 0 '-E' 10716491Swoscht 0 '-X -a -X' 10816491Swoscht 0 '-XXX' 10916491Swoscht 0 '\( -E \)' 11016491Swoscht 0 'true -o X' 11116491Swoscht 0 'true -o -X' 11216491Swoscht 0 '\( \( \( a = a \) -o 1 \) -a 1 \) -a true' 11316491Swoscht 1 '-h /' 11416491Swoscht 0 '-r /' 11516491Swoscht 1 '-w /' 11616491Swoscht 0 '-x /bin/sh' 11716491Swoscht 0 '-c /dev/null' 11816491Swoscht 0 '-b /dev/fd0a -o -b /dev/rfd0a -o true' 11916491Swoscht 0 '-f /etc/passwd' 12016491Swoscht 0 '-s /etc/passwd' 12116491Swoscht 1 '! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)' 12216491Swoscht 0 '100 -eq 100' 12316491Swoscht 0 '100 -lt 200' 12416491Swoscht 1 '1000 -lt 200' 12516491Swoscht 0 '1000 -gt 200' 12616491Swoscht 0 '1000 -ge 200' 12716491Swoscht 0 '1000 -ge 1000' 12816491Swoscht 1 '2 -ne 2' 12916491Swosch 13016491Swoschecho "" 13116491Swoschecho "Syntax errors: $ERROR Failed: $FAILED" 13216491Swosch 133