legacy_test.sh revision 192862
116491Swosch#!/bin/sh 2139969Simp 3139969Simp#- 417849Swosch# Copyright (c) June 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. 517849Swosch# All rights reserved. 617849Swosch# 717849Swosch# Redistribution and use in source and binary forms, with or without 817849Swosch# modification, are permitted provided that the following conditions 917849Swosch# are met: 1017849Swosch# 1. Redistributions of source code must retain the above copyright 1117849Swosch# notice, this list of conditions and the following disclaimer. 1217849Swosch# 2. Redistributions in binary form must reproduce the above copyright 1317849Swosch# notice, this list of conditions and the following disclaimer in the 1417849Swosch# documentation and/or other materials provided with the distribution. 1517849Swosch# 1617849Swosch# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1717849Swosch# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1817849Swosch# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1917849Swosch# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2017849Swosch# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2117849Swosch# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2217849Swosch# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2317849Swosch# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2417849Swosch# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2517849Swosch# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2617849Swosch# SUCH DAMAGE. 27139969Simp 2817849Swosch# 2916491Swosch# TEST.sh - check if test(1) or builtin test works 3016491Swosch# 3150471Speter# $FreeBSD: head/bin/test/TEST.sh 192862 2009-05-26 22:33:10Z jilles $ 3216491Swosch 3316491Swosch# force a specified test program, e.g. `env test=/bin/test sh TEST.sh' 3416491Swosch: ${test=test} 3516491Swosch 3616491SwoschERROR=0 FAILED=0 3716491Swosch 3816491Swoscht () 3916491Swosch{ 4016491Swosch # $1 -> exit code 4116491Swosch # $2 -> $test expression 4216491Swosch 4320970Swosch echo -n "$1: $test $2 " 4416491Swosch 4516491Swosch # check for syntax errors 4616491Swosch syntax="`eval $test $2 2>&1`" 4716491Swosch if test -z "$syntax"; then 4816491Swosch 4916491Swosch case $1 in 5016491Swosch 0) if eval $test $2; then echo " OK"; else failed;fi;; 5116491Swosch 1) if eval $test $2; then failed; else echo " OK";fi;; 5216491Swosch esac 5316491Swosch 5416491Swosch else 5516491Swosch error 5616491Swosch fi 5716491Swosch} 5816491Swosch 5916491Swoscherror () 6016491Swosch{ 6116491Swosch echo ""; echo " $syntax" 6216491Swosch ERROR=`expr $ERROR + 1` 6316491Swosch} 6416491Swosch 6516491Swoschfailed () 6616491Swosch{ 6716491Swosch echo ""; echo " failed" 6816491Swosch FAILED=`expr $FAILED + 1` 6916491Swosch} 7016491Swosch 7116491Swosch 7216491Swoscht 0 'b = b' 7316491Swoscht 1 'b != b' 7416491Swoscht 0 '\( b = b \)' 7516491Swoscht 1 '! \( b = b \)' 7616491Swoscht 1 '! -f /etc/passwd' 7716491Swosch 7816491Swoscht 0 '-h = -h' 7916491Swoscht 0 '-o = -o' 8016491Swoscht 1 '-f = h' 8116491Swoscht 1 '-h = f' 8216491Swoscht 1 '-o = f' 8316491Swoscht 1 'f = -o' 8416491Swoscht 0 '\( -h = -h \)' 8516491Swoscht 1 '\( a = -h \)' 8616491Swoscht 1 '\( -f = h \)' 8716491Swoscht 0 '-h = -h -o a' 8816491Swoscht 0 '\( -h = -h \) -o 1' 8916491Swoscht 0 '-h = -h -o -h = -h' 9016491Swoscht 0 '\( -h = -h \) -o \( -h = -h \)' 9120970Swoscht 0 'roedelheim = roedelheim' 9220970Swoscht 1 'potsdam = berlin-dahlem' 9316491Swosch 9416491Swoscht 0 '-d /' 9516491Swoscht 0 '-d / -a a != b' 9616491Swoscht 1 '-z "-z"' 9716491Swoscht 0 '-n -n' 9816491Swosch 9916491Swoscht 0 '0' 10016491Swoscht 0 '\( 0 \)' 10116491Swoscht 0 '-E' 10216491Swoscht 0 '-X -a -X' 10316491Swoscht 0 '-XXX' 10416491Swoscht 0 '\( -E \)' 10516491Swoscht 0 'true -o X' 10616491Swoscht 0 'true -o -X' 10716491Swoscht 0 '\( \( \( a = a \) -o 1 \) -a 1 \) -a true' 10816491Swoscht 1 '-h /' 10916491Swoscht 0 '-r /' 11016491Swoscht 1 '-w /' 11116491Swoscht 0 '-x /bin/sh' 11216491Swoscht 0 '-c /dev/null' 11316491Swoscht 0 '-f /etc/passwd' 11416491Swoscht 0 '-s /etc/passwd' 11520970Swosch 11616491Swoscht 1 '! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)' 11716491Swoscht 0 '100 -eq 100' 11816491Swoscht 0 '100 -lt 200' 11916491Swoscht 1 '1000 -lt 200' 12016491Swoscht 0 '1000 -gt 200' 12116491Swoscht 0 '1000 -ge 200' 12216491Swoscht 0 '1000 -ge 1000' 12316491Swoscht 1 '2 -ne 2' 12420970Swoscht 0 '0 -eq 0' 12520970Swoscht 1 '-5 -eq 5' 12620970Swoscht 0 '\( 0 -eq 0 \)' 12720970Swoscht 1 '1 -eq 0 -o a = a -a 1 -eq 0 -o a = aa' 12816491Swosch 12920970Swoscht 1 '"" -o ""' 13020970Swoscht 1 '"" -a ""' 13120970Swoscht 1 '"a" -a ""' 13220970Swoscht 0 '"a" -a ! ""' 13320970Swoscht 1 '""' 13420970Swoscht 0 '! ""' 13520970Swosch 136192862Sjillest 0 '!' 137192862Sjillest 0 '\(' 138192862Sjillest 0 '\)' 139192862Sjilles 140192862Sjillest 1 '\( = \)' 141192862Sjillest 0 '\( != \)' 142192862Sjillest 0 '\( ! \)' 143192862Sjillest 0 '\( \( \)' 144192862Sjillest 0 '\( \) \)' 145192862Sjillest 0 '! = !' 146192862Sjillest 1 '! != !' 147192862Sjillest 1 '-n = \)' 148192862Sjillest 0 '! != \)' 149192862Sjillest 1 '! = a' 150192862Sjillest 0 '! != -n' 151192862Sjillest 0 '! -c /etc/passwd' 152192862Sjilles 153192862Sjillest 0 '! \( = \)' 154192862Sjillest 1 '! \( != \)' 155192862Sjillest 1 '! = = =' 156192862Sjillest 0 '! = = \)' 157192862Sjillest 0 '! "" -o ""' 158192862Sjillest 1 '! "x" -o ""' 159192862Sjillest 1 '! "" -o "x"' 160192862Sjillest 1 '! "x" -o "x"' 161192862Sjillest 0 '\( -f /etc/passwd \)' 162192862Sjillest 1 '\( ! = \)' 163192862Sjillest 0 '\( ! "" \)' 164192862Sjillest 1 '\( ! -e \)' 165192862Sjilles 166192862Sjillest 0 '0 -eq 0 -a -d /' 167192862Sjillest 0 '-s = "" -o "" = ""' 168192862Sjillest 0 '"" = "" -o -s = ""' 169192862Sjillest 1 '-s = "" -o -s = ""' 170192862Sjillest 0 '-z x -o x = "#" -o x = x' 171192862Sjillest 1 '-z y -o y = "#" -o y = x' 172192862Sjillest 0 '0 -ne 0 -o ! -f /' 173192862Sjillest 0 '1 -ne 0 -o ! -f /etc/passwd' 174192862Sjillest 1 '0 -ne 0 -o ! -f /etc/passwd' 175192862Sjilles 17616491Swoschecho "" 17716491Swoschecho "Syntax errors: $ERROR Failed: $FAILED" 178