1198090Srdivacky#!/bin/sh 2198090Srdivacky 3198090Srdivacky#- 4198090Srdivacky# Copyright (c) June 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. 5198090Srdivacky# All rights reserved. 6198090Srdivacky# 7198090Srdivacky# Redistribution and use in source and binary forms, with or without 8198090Srdivacky# modification, are permitted provided that the following conditions 9198090Srdivacky# are met: 10249423Sdim# 1. Redistributions of source code must retain the above copyright 11198090Srdivacky# notice, this list of conditions and the following disclaimer. 12249423Sdim# 2. Redistributions in binary form must reproduce the above copyright 13198090Srdivacky# notice, this list of conditions and the following disclaimer in the 14249423Sdim# documentation and/or other materials provided with the distribution. 15198090Srdivacky# 16198090Srdivacky# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17249423Sdim# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18210299Sed# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19198090Srdivacky# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20249423Sdim# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21198090Srdivacky# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22218893Sdim# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23198090Srdivacky# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24198090Srdivacky# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25206083Srdivacky# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26198090Srdivacky# SUCH DAMAGE. 27198090Srdivacky 28198090Srdivacky# 29198090Srdivacky# TEST.sh - check if test(1) or builtin test works 30210299Sed# 31198090Srdivacky 32218893Sdim# force a specified test program, e.g. `env test=/bin/test sh regress.sh' 33208599Srdivacky: ${test=test} 34239462Sdim 35239462Sdimt () 36198090Srdivacky{ 37249423Sdim # $1 -> exit code 38249423Sdim # $2 -> $test expression 39249423Sdim 40198090Srdivacky count=$((count+1)) 41198090Srdivacky # check for syntax errors 42198090Srdivacky syntax="`eval $test $2 2>&1`" 43198090Srdivacky ret=$? 44218893Sdim if test -n "$syntax"; then 45249423Sdim printf "not ok %s - (syntax error)\n" "$count $2" 46198090Srdivacky elif [ "$ret" != "$1" ]; then 47249423Sdim printf "not ok %s - (got $ret, expected $1)\n" "$count $2" 48221345Sdim else 49221345Sdim printf "ok %s\n" "$count $2" 50202878Srdivacky fi 51249423Sdim} 52239462Sdim 53218893Sdimcount=0 54202878Srdivackyecho "1..130" 55198090Srdivacky 56202878Srdivackyt 0 'b = b' 57198090Srdivackyt 0 'b == b' 58208599Srdivackyt 1 'b != b' 59234353Sdimt 0 '\( b = b \)' 60208599Srdivackyt 0 '\( b == b \)' 61208599Srdivackyt 1 '! \( b = b \)' 62234353Sdimt 1 '! \( b == b \)' 63208599Srdivackyt 1 '! -f /etc/passwd' 64208599Srdivacky 65234353Sdimt 0 '-h = -h' 66208599Srdivackyt 0 '-o = -o' 67208599Srdivackyt 1 '-f = h' 68234353Sdimt 1 '-h = f' 69208599Srdivackyt 1 '-o = f' 70203954Srdivackyt 1 'f = -o' 71234353Sdimt 0 '\( -h = -h \)' 72203954Srdivackyt 1 '\( a = -h \)' 73226633Sdimt 1 '\( -f = h \)' 74243830Sdimt 0 '-h = -h -o a' 75198090Srdivackyt 0 '\( -h = -h \) -o 1' 76239462Sdimt 0 '-h = -h -o -h = -h' 77208599Srdivackyt 0 '\( -h = -h \) -o \( -h = -h \)' 78208599Srdivackyt 0 'roedelheim = roedelheim' 79208599Srdivackyt 1 'potsdam = berlin-dahlem' 80203954Srdivacky 81212904Sdimt 0 '-d /' 82212904Sdimt 0 '-d / -a a != b' 83212904Sdimt 1 '-z "-z"' 84212904Sdimt 0 '-n -n' 85203954Srdivacky 86212904Sdimt 0 '0' 87234353Sdimt 0 '\( 0 \)' 88198090Srdivackyt 0 '-E' 89198090Srdivackyt 0 '-X -a -X' 90249423Sdimt 0 '-XXX' 91249423Sdimt 0 '\( -E \)' 92249423Sdimt 0 'true -o X' 93249423Sdimt 0 'true -o -X' 94198090Srdivackyt 0 '\( \( \( a = a \) -o 1 \) -a 1 \) -a true' 95198090Srdivackyt 1 '-h /' 96198090Srdivackyt 0 '-r /' 97198090Srdivackyt 1 '-w /' 98218893Sdimt 0 '-x /bin/sh' 99249423Sdimt 0 '-c /dev/null' 100249423Sdimt 0 '-f /etc/passwd' 101218893Sdimt 0 '-s /etc/passwd' 102249423Sdim 103249423Sdimt 1 '! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)' 104249423Sdimt 0 '100 -eq 100' 105249423Sdimt 0 '100 -lt 200' 106249423Sdimt 1 '1000 -lt 200' 107218893Sdimt 0 '1000 -gt 200' 108218893Sdimt 0 '1000 -ge 200' 109221345Sdimt 0 '1000 -ge 1000' 110221345Sdimt 1 '2 -ne 2' 111221345Sdimt 0 '0 -eq 0' 112221345Sdimt 1 '-5 -eq 5' 113221345Sdimt 0 '\( 0 -eq 0 \)' 114221345Sdimt 1 '1 -eq 0 -o a = a -a 1 -eq 0 -o a = aa' 115221345Sdim 116221345Sdimt 1 '"" -o ""' 117221345Sdimt 1 '"" -a ""' 118221345Sdimt 1 '"a" -a ""' 119221345Sdimt 0 '"a" -a ! ""' 120221345Sdimt 1 '""' 121198090Srdivackyt 0 '! ""' 122198090Srdivacky 123198090Srdivackyt 0 '!' 124218893Sdimt 0 '\(' 125251662Sdimt 0 '\)' 126210299Sed 127210299Sedt 1 '\( = \)' 128218893Sdimt 0 '\( != \)' 129251662Sdimt 0 '\( ! \)' 130208599Srdivackyt 0 '\( \( \)' 131218893Sdimt 0 '\( \) \)' 132198090Srdivackyt 0 '! = !' 133218893Sdimt 1 '! != !' 134208599Srdivackyt 1 '-n = \)' 135208599Srdivackyt 0 '! != \)' 136208599Srdivackyt 1 '! = a' 137208599Srdivackyt 0 '! != -n' 138208599Srdivackyt 0 '! -c /etc/passwd' 139208599Srdivacky 140208599Srdivackyt 1 '! = = =' 141208599Srdivackyt 0 '! = = \)' 142198090Srdivackyt 0 '! "" -o ""' 143198090Srdivackyt 1 '! "x" -o ""' 144249423Sdimt 1 '! "" -o "x"' 145249423Sdimt 1 '! "x" -o "x"' 146249423Sdimt 0 '\( -f /etc/passwd \)' 147239462Sdimt 0 '\( ! "" \)' 148243830Sdimt 1 '\( ! -e \)' 149243830Sdim 150239462Sdimt 0 '0 -eq 0 -a -d /' 151239462Sdimt 0 '-s = "" -o "" = ""' 152239462Sdimt 0 '"" = "" -o -s = ""' 153239462Sdimt 1 '-s = "" -o -s = ""' 154239462Sdimt 0 '-z x -o x = "#" -o x = x' 155239462Sdimt 1 '-z y -o y = "#" -o y = x' 156239462Sdimt 0 '0 -ne 0 -o ! -f /' 157239462Sdimt 0 '1 -ne 0 -o ! -f /etc/passwd' 158239462Sdimt 1 '0 -ne 0 -o ! -f /etc/passwd' 159239462Sdim 160243830Sdimt 0 '-n =' 161243830Sdimt 1 '-z =' 162239462Sdimt 1 '! =' 163239462Sdimt 0 '-n -eq' 164239462Sdimt 1 '-z -eq' 165239462Sdimt 1 '! -eq' 166239462Sdimt 0 '-n -a' 167239462Sdimt 1 '-z -a' 168239462Sdimt 1 '! -a' 169239462Sdimt 0 '-n -o' 170239462Sdimt 1 '-z -o' 171202878Srdivackyt 1 '! -o' 172218893Sdimt 1 '! -n =' 173234353Sdimt 0 '! -z =' 174218893Sdimt 0 '! ! =' 175198090Srdivackyt 1 '! -n -eq' 176218893Sdimt 0 '! -z -eq' 177226633Sdimt 0 '! ! -eq' 178226633Sdimt 1 '! -n -a' 179226633Sdimt 0 '! -z -a' 180202878Srdivackyt 0 '! ! -a' 181210299Sedt 1 '! -n -o' 182198090Srdivackyt 0 '! -z -o' 183198090Srdivackyt 0 '! ! -o' 184218893Sdimt 0 '\( -n = \)' 185198090Srdivackyt 1 '\( -z = \)' 186249423Sdimt 1 '\( ! = \)' 187249423Sdimt 0 '\( -n -eq \)' 188249423Sdimt 1 '\( -z -eq \)' 189249423Sdimt 1 '\( ! -eq \)' 190239462Sdimt 0 '\( -n -a \)' 191239462Sdimt 1 '\( -z -a \)' 192239462Sdimt 1 '\( ! -a \)' 193239462Sdimt 0 '\( -n -o \)' 194239462Sdimt 1 '\( -z -o \)' 195239462Sdimt 1 '\( ! -o \)' 196239462Sdim