legacy_test.sh revision 215022
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/tools/regression/bin/test/regress.sh 215022 2010-11-08 23:15:10Z jilles $ 3216491Swosch 33215022Sjilles# force a specified test program, e.g. `env test=/bin/test sh regress.sh' 3416491Swosch: ${test=test} 3516491Swosch 3616491Swoscht () 3716491Swosch{ 3816491Swosch # $1 -> exit code 3916491Swosch # $2 -> $test expression 4016491Swosch 41215022Sjilles count=$((count+1)) 4216491Swosch # check for syntax errors 4316491Swosch syntax="`eval $test $2 2>&1`" 44215022Sjilles ret=$? 45215022Sjilles if test -n "$syntax"; then 46215022Sjilles printf "not ok %s - (syntax error)\n" "$count $2" 47215022Sjilles elif [ "$ret" != "$1" ]; then 48215022Sjilles printf "not ok %s - (got $ret, expected $1)\n" "$count $2" 4916491Swosch else 50215022Sjilles printf "ok %s\n" "$count $2" 5116491Swosch fi 5216491Swosch} 5316491Swosch 54215022Sjillescount=0 55215022Sjillesecho "1..94" 5616491Swosch 5716491Swoscht 0 'b = b' 5816491Swoscht 1 'b != b' 5916491Swoscht 0 '\( b = b \)' 6016491Swoscht 1 '! \( b = b \)' 6116491Swoscht 1 '! -f /etc/passwd' 6216491Swosch 6316491Swoscht 0 '-h = -h' 6416491Swoscht 0 '-o = -o' 6516491Swoscht 1 '-f = h' 6616491Swoscht 1 '-h = f' 6716491Swoscht 1 '-o = f' 6816491Swoscht 1 'f = -o' 6916491Swoscht 0 '\( -h = -h \)' 7016491Swoscht 1 '\( a = -h \)' 7116491Swoscht 1 '\( -f = h \)' 7216491Swoscht 0 '-h = -h -o a' 7316491Swoscht 0 '\( -h = -h \) -o 1' 7416491Swoscht 0 '-h = -h -o -h = -h' 7516491Swoscht 0 '\( -h = -h \) -o \( -h = -h \)' 7620970Swoscht 0 'roedelheim = roedelheim' 7720970Swoscht 1 'potsdam = berlin-dahlem' 7816491Swosch 7916491Swoscht 0 '-d /' 8016491Swoscht 0 '-d / -a a != b' 8116491Swoscht 1 '-z "-z"' 8216491Swoscht 0 '-n -n' 8316491Swosch 8416491Swoscht 0 '0' 8516491Swoscht 0 '\( 0 \)' 8616491Swoscht 0 '-E' 8716491Swoscht 0 '-X -a -X' 8816491Swoscht 0 '-XXX' 8916491Swoscht 0 '\( -E \)' 9016491Swoscht 0 'true -o X' 9116491Swoscht 0 'true -o -X' 9216491Swoscht 0 '\( \( \( a = a \) -o 1 \) -a 1 \) -a true' 9316491Swoscht 1 '-h /' 9416491Swoscht 0 '-r /' 9516491Swoscht 1 '-w /' 9616491Swoscht 0 '-x /bin/sh' 9716491Swoscht 0 '-c /dev/null' 9816491Swoscht 0 '-f /etc/passwd' 9916491Swoscht 0 '-s /etc/passwd' 10020970Swosch 10116491Swoscht 1 '! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)' 10216491Swoscht 0 '100 -eq 100' 10316491Swoscht 0 '100 -lt 200' 10416491Swoscht 1 '1000 -lt 200' 10516491Swoscht 0 '1000 -gt 200' 10616491Swoscht 0 '1000 -ge 200' 10716491Swoscht 0 '1000 -ge 1000' 10816491Swoscht 1 '2 -ne 2' 10920970Swoscht 0 '0 -eq 0' 11020970Swoscht 1 '-5 -eq 5' 11120970Swoscht 0 '\( 0 -eq 0 \)' 11220970Swoscht 1 '1 -eq 0 -o a = a -a 1 -eq 0 -o a = aa' 11316491Swosch 11420970Swoscht 1 '"" -o ""' 11520970Swoscht 1 '"" -a ""' 11620970Swoscht 1 '"a" -a ""' 11720970Swoscht 0 '"a" -a ! ""' 11820970Swoscht 1 '""' 11920970Swoscht 0 '! ""' 12020970Swosch 121192862Sjillest 0 '!' 122192862Sjillest 0 '\(' 123192862Sjillest 0 '\)' 124192862Sjilles 125192862Sjillest 1 '\( = \)' 126192862Sjillest 0 '\( != \)' 127192862Sjillest 0 '\( ! \)' 128192862Sjillest 0 '\( \( \)' 129192862Sjillest 0 '\( \) \)' 130192862Sjillest 0 '! = !' 131192862Sjillest 1 '! != !' 132192862Sjillest 1 '-n = \)' 133192862Sjillest 0 '! != \)' 134192862Sjillest 1 '! = a' 135192862Sjillest 0 '! != -n' 136192862Sjillest 0 '! -c /etc/passwd' 137192862Sjilles 138192862Sjillest 0 '! \( = \)' 139192862Sjillest 1 '! \( != \)' 140192862Sjillest 1 '! = = =' 141192862Sjillest 0 '! = = \)' 142192862Sjillest 0 '! "" -o ""' 143192862Sjillest 1 '! "x" -o ""' 144192862Sjillest 1 '! "" -o "x"' 145192862Sjillest 1 '! "x" -o "x"' 146192862Sjillest 0 '\( -f /etc/passwd \)' 147192862Sjillest 1 '\( ! = \)' 148192862Sjillest 0 '\( ! "" \)' 149192862Sjillest 1 '\( ! -e \)' 150192862Sjilles 151192862Sjillest 0 '0 -eq 0 -a -d /' 152192862Sjillest 0 '-s = "" -o "" = ""' 153192862Sjillest 0 '"" = "" -o -s = ""' 154192862Sjillest 1 '-s = "" -o -s = ""' 155192862Sjillest 0 '-z x -o x = "#" -o x = x' 156192862Sjillest 1 '-z y -o y = "#" -o y = x' 157192862Sjillest 0 '0 -ne 0 -o ! -f /' 158192862Sjillest 0 '1 -ne 0 -o ! -f /etc/passwd' 159192862Sjillest 1 '0 -ne 0 -o ! -f /etc/passwd' 160