legacy_test.sh revision 50471
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# 2950471Speter# $FreeBSD: head/bin/test/TEST.sh 50471 1999-08-27 23:15:48Z peter $ 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 4120970Swosch echo -n "$1: $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' 7816491Swoscht 1 '-f = h' 7916491Swoscht 1 '-h = f' 8016491Swoscht 1 '-o = f' 8116491Swoscht 1 'f = -o' 8216491Swoscht 0 '\( -h = -h \)' 8316491Swoscht 1 '\( a = -h \)' 8416491Swoscht 1 '\( -f = h \)' 8516491Swoscht 0 '-h = -h -o a' 8616491Swoscht 0 '\( -h = -h \) -o 1' 8716491Swoscht 0 '-h = -h -o -h = -h' 8816491Swoscht 0 '\( -h = -h \) -o \( -h = -h \)' 8920970Swoscht 0 'roedelheim = roedelheim' 9020970Swoscht 1 'potsdam = berlin-dahlem' 9116491Swosch 9216491Swoscht 0 '-d /' 9316491Swoscht 0 '-d / -a a != b' 9416491Swoscht 1 '-z "-z"' 9516491Swoscht 0 '-n -n' 9616491Swosch 9716491Swoscht 0 '0' 9816491Swoscht 0 '\( 0 \)' 9916491Swoscht 0 '-E' 10016491Swoscht 0 '-X -a -X' 10116491Swoscht 0 '-XXX' 10216491Swoscht 0 '\( -E \)' 10316491Swoscht 0 'true -o X' 10416491Swoscht 0 'true -o -X' 10516491Swoscht 0 '\( \( \( a = a \) -o 1 \) -a 1 \) -a true' 10616491Swoscht 1 '-h /' 10716491Swoscht 0 '-r /' 10816491Swoscht 1 '-w /' 10916491Swoscht 0 '-x /bin/sh' 11016491Swoscht 0 '-c /dev/null' 11116491Swoscht 0 '-b /dev/fd0a -o -b /dev/rfd0a -o true' 11216491Swoscht 0 '-f /etc/passwd' 11316491Swoscht 0 '-s /etc/passwd' 11420970Swosch 11516491Swoscht 1 '! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)' 11616491Swoscht 0 '100 -eq 100' 11716491Swoscht 0 '100 -lt 200' 11816491Swoscht 1 '1000 -lt 200' 11916491Swoscht 0 '1000 -gt 200' 12016491Swoscht 0 '1000 -ge 200' 12116491Swoscht 0 '1000 -ge 1000' 12216491Swoscht 1 '2 -ne 2' 12320970Swoscht 0 '0 -eq 0' 12420970Swoscht 1 '-5 -eq 5' 12520970Swoscht 0 '\( 0 -eq 0 \)' 12620970Swoscht 1 '1 -eq 0 -o a = a -a 1 -eq 0 -o a = aa' 12716491Swosch 12820970Swoscht 1 '"" -o ""' 12920970Swoscht 1 '"" -a ""' 13020970Swoscht 1 '"a" -a ""' 13120970Swoscht 0 '"a" -a ! ""' 13220970Swoscht 1 '""' 13320970Swoscht 0 '! ""' 13420970Swosch 13516491Swoschecho "" 13616491Swoschecho "Syntax errors: $ERROR Failed: $FAILED" 137