1#!/bin/sh 2 3#- 4# Copyright (c) June 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin. 5# All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 10# 1. Redistributions of source code must retain the above copyright 11# notice, this list of conditions and the following disclaimer. 12# 2. Redistributions in binary form must reproduce the above copyright 13# notice, this list of conditions and the following disclaimer in the 14# documentation and/or other materials provided with the distribution. 15# 16# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26# SUCH DAMAGE. 27 28# 29# TEST.sh - check if test(1) or builtin test works 30# 31# $FreeBSD: src/tools/regression/bin/test/regress.sh,v 1.1 2010/11/08 23:15:10 jilles Exp $ 32 33# force a specified test program, e.g. `env test=/bin/test sh regress.sh' 34: ${test=test} 35 36t () 37{ 38 # $1 -> exit code 39 # $2 -> $test expression 40 41 count=$((count+1)) 42 # check for syntax errors 43 syntax="`eval $test $2 2>&1`" 44 ret=$? 45 if test -n "$syntax"; then 46 printf "not ok %s - (syntax error)\n" "$count $2" 47 elif [ "$ret" != "$1" ]; then 48 printf "not ok %s - (got $ret, expected $1)\n" "$count $2" 49 else 50 printf "ok %s\n" "$count $2" 51 fi 52} 53 54count=0 55echo "1..94" 56 57t 0 'b = b' 58t 1 'b != b' 59t 0 '\( b = b \)' 60t 1 '! \( b = b \)' 61t 1 '! -f /etc/passwd' 62 63t 0 '-h = -h' 64t 0 '-o = -o' 65t 1 '-f = h' 66t 1 '-h = f' 67t 1 '-o = f' 68t 1 'f = -o' 69t 0 '\( -h = -h \)' 70t 1 '\( a = -h \)' 71t 1 '\( -f = h \)' 72t 0 '-h = -h -o a' 73t 0 '\( -h = -h \) -o 1' 74t 0 '-h = -h -o -h = -h' 75t 0 '\( -h = -h \) -o \( -h = -h \)' 76t 0 'roedelheim = roedelheim' 77t 1 'potsdam = berlin-dahlem' 78 79t 0 '-d /' 80t 0 '-d / -a a != b' 81t 1 '-z "-z"' 82t 0 '-n -n' 83 84t 0 '0' 85t 0 '\( 0 \)' 86t 0 '-E' 87t 0 '-X -a -X' 88t 0 '-XXX' 89t 0 '\( -E \)' 90t 0 'true -o X' 91t 0 'true -o -X' 92t 0 '\( \( \( a = a \) -o 1 \) -a 1 \) -a true' 93t 1 '-h /' 94t 0 '-r /' 95t 1 '-w /' 96t 0 '-x /bin/sh' 97t 0 '-c /dev/null' 98t 0 '-f /etc/passwd' 99t 0 '-s /etc/passwd' 100 101t 1 '! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)' 102t 0 '100 -eq 100' 103t 0 '100 -lt 200' 104t 1 '1000 -lt 200' 105t 0 '1000 -gt 200' 106t 0 '1000 -ge 200' 107t 0 '1000 -ge 1000' 108t 1 '2 -ne 2' 109t 0 '0 -eq 0' 110t 1 '-5 -eq 5' 111t 0 '\( 0 -eq 0 \)' 112t 1 '1 -eq 0 -o a = a -a 1 -eq 0 -o a = aa' 113 114t 1 '"" -o ""' 115t 1 '"" -a ""' 116t 1 '"a" -a ""' 117t 0 '"a" -a ! ""' 118t 1 '""' 119t 0 '! ""' 120 121t 0 '!' 122t 0 '\(' 123t 0 '\)' 124 125t 1 '\( = \)' 126t 0 '\( != \)' 127t 0 '\( ! \)' 128t 0 '\( \( \)' 129t 0 '\( \) \)' 130t 0 '! = !' 131t 1 '! != !' 132t 1 '-n = \)' 133t 0 '! != \)' 134t 1 '! = a' 135t 0 '! != -n' 136t 0 '! -c /etc/passwd' 137 138t 0 '! \( = \)' 139t 1 '! \( != \)' 140t 1 '! = = =' 141t 0 '! = = \)' 142t 0 '! "" -o ""' 143t 1 '! "x" -o ""' 144t 1 '! "" -o "x"' 145t 1 '! "x" -o "x"' 146t 0 '\( -f /etc/passwd \)' 147t 1 '\( ! = \)' 148t 0 '\( ! "" \)' 149t 1 '\( ! -e \)' 150 151t 0 '0 -eq 0 -a -d /' 152t 0 '-s = "" -o "" = ""' 153t 0 '"" = "" -o -s = ""' 154t 1 '-s = "" -o -s = ""' 155t 0 '-z x -o x = "#" -o x = x' 156t 1 '-z y -o y = "#" -o y = x' 157t 0 '0 -ne 0 -o ! -f /' 158t 0 '1 -ne 0 -o ! -f /etc/passwd' 159t 1 '0 -ne 0 -o ! -f /etc/passwd' 160