legacy_test.sh revision 219084
1264790Sbapt#!/bin/sh
2264790Sbapt
3264790Sbapt#-
4264790Sbapt# Copyright (c) June 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
5264790Sbapt# All rights reserved. 
6264790Sbapt#
7264790Sbapt# Redistribution and use in source and binary forms, with or without
8264790Sbapt# modification, are permitted provided that the following conditions
9264790Sbapt# are met:
10264790Sbapt# 1. Redistributions of source code must retain the above copyright
11264790Sbapt#    notice, this list of conditions and the following disclaimer.
12264790Sbapt# 2. Redistributions in binary form must reproduce the above copyright
13264790Sbapt#    notice, this list of conditions and the following disclaimer in the
14264790Sbapt#    documentation and/or other materials provided with the distribution.
15264790Sbapt#
16264790Sbapt# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17264790Sbapt# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18264790Sbapt# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19264790Sbapt# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20264790Sbapt# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21264790Sbapt# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22264790Sbapt# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23264790Sbapt# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24264790Sbapt# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25264790Sbapt# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26264790Sbapt# SUCH DAMAGE.
27264790Sbapt
28264790Sbapt#
29264790Sbapt# TEST.sh - check if test(1) or builtin test works
30264790Sbapt#
31264790Sbapt# $FreeBSD: head/tools/regression/bin/test/regress.sh 219084 2011-02-27 12:28:06Z delphij $
32264790Sbapt
33264790Sbapt# force a specified test program, e.g. `env test=/bin/test sh regress.sh'
34264790Sbapt: ${test=test}		
35264790Sbapt
36264790Sbaptt ()
37264790Sbapt{
38264790Sbapt	# $1 -> exit code
39264790Sbapt	# $2 -> $test expression
40264790Sbapt
41264790Sbapt	count=$((count+1))
42264790Sbapt	# check for syntax errors
43264790Sbapt	syntax="`eval $test $2 2>&1`"
44264790Sbapt	ret=$?
45264790Sbapt	if test -n "$syntax"; then
46264790Sbapt		printf "not ok %s - (syntax error)\n" "$count $2"
47264790Sbapt	elif [ "$ret" != "$1" ]; then
48264790Sbapt		printf "not ok %s - (got $ret, expected $1)\n" "$count $2"
49264790Sbapt	else
50264790Sbapt		printf "ok %s\n" "$count $2"
51264790Sbapt	fi
52264790Sbapt}
53264790Sbapt
54264790Sbaptcount=0
55264790Sbaptecho "1..97"
56264790Sbapt
57264790Sbaptt 0 'b = b' 
58264790Sbaptt 0 'b == b' 
59264790Sbaptt 1 'b != b' 
60264790Sbaptt 0 '\( b = b \)' 
61264790Sbaptt 0 '\( b == b \)' 
62264790Sbaptt 1 '! \( b = b \)' 
63264790Sbaptt 1 '! \( b == b \)' 
64264790Sbaptt 1 '! -f /etc/passwd'
65264790Sbapt
66264790Sbaptt 0 '-h = -h'
67264790Sbaptt 0 '-o = -o'
68264790Sbaptt 1 '-f = h'
69264790Sbaptt 1 '-h = f'
70264790Sbaptt 1 '-o = f'
71264790Sbaptt 1 'f = -o'
72264790Sbaptt 0 '\( -h = -h \)'
73264790Sbaptt 1 '\( a = -h \)'
74264790Sbaptt 1 '\( -f = h \)'
75264790Sbaptt 0 '-h = -h -o a'
76264790Sbaptt 0 '\( -h = -h \) -o 1'
77264790Sbaptt 0 '-h = -h -o -h = -h'
78264790Sbaptt 0 '\( -h = -h \) -o \( -h = -h \)'
79264790Sbaptt 0 'roedelheim = roedelheim'
80264790Sbaptt 1 'potsdam = berlin-dahlem'
81264790Sbapt
82264790Sbaptt 0 '-d /'
83264790Sbaptt 0 '-d / -a a != b'
84264790Sbaptt 1 '-z "-z"'
85264790Sbaptt 0 '-n -n'
86264790Sbapt
87264790Sbaptt 0 '0'
88264790Sbaptt 0 '\( 0 \)'
89264790Sbaptt 0 '-E'
90264790Sbaptt 0 '-X -a -X'
91264790Sbaptt 0 '-XXX'
92264790Sbaptt 0 '\( -E \)'
93264790Sbaptt 0 'true -o X'
94264790Sbaptt 0 'true -o -X'
95264790Sbaptt 0 '\( \( \( a = a \) -o 1 \) -a 1 \) -a true'
96264790Sbaptt 1 '-h /'
97264790Sbaptt 0 '-r /'
98264790Sbaptt 1 '-w /'
99264790Sbaptt 0 '-x /bin/sh'
100264790Sbaptt 0 '-c /dev/null'
101264790Sbaptt 0 '-f /etc/passwd'
102264790Sbaptt 0 '-s /etc/passwd'
103264790Sbapt
104264790Sbaptt 1 '! \( 700 -le 1000 -a -n "1" -a "20" = "20" \)'
105264790Sbaptt 0 '100 -eq 100'
106264790Sbaptt 0 '100 -lt 200'
107264790Sbaptt 1 '1000 -lt 200'
108264790Sbaptt 0 '1000 -gt 200'
109264790Sbaptt 0 '1000 -ge 200'
110264790Sbaptt 0 '1000 -ge 1000'
111264790Sbaptt 1 '2 -ne 2'
112264790Sbaptt 0 '0 -eq 0'
113264790Sbaptt 1 '-5 -eq 5'
114264790Sbaptt 0 '\( 0 -eq 0 \)'
115264790Sbaptt 1 '1 -eq 0 -o a = a -a 1 -eq 0 -o a = aa'
116264790Sbapt
117264790Sbaptt 1 '"" -o ""'
118264790Sbaptt 1 '"" -a ""'
119264790Sbaptt 1 '"a" -a ""'
120264790Sbaptt 0 '"a" -a ! ""'
121264790Sbaptt 1 '""'
122264790Sbaptt 0 '! ""'
123264790Sbapt
124264790Sbaptt 0 '!'
125264790Sbaptt 0 '\('
126264790Sbaptt 0 '\)'
127264790Sbapt
128264790Sbaptt 1 '\( = \)'
129264790Sbaptt 0 '\( != \)'
130264790Sbaptt 0 '\( ! \)'
131264790Sbaptt 0 '\( \( \)'
132264790Sbaptt 0 '\( \) \)'
133264790Sbaptt 0 '! = !'
134264790Sbaptt 1 '! != !'
135264790Sbaptt 1 '-n = \)'
136264790Sbaptt 0 '! != \)'
137264790Sbaptt 1 '! = a'
138264790Sbaptt 0 '! != -n'
139264790Sbaptt 0 '! -c /etc/passwd'
140264790Sbapt
141264790Sbaptt 0 '! \( = \)'
142264790Sbaptt 1 '! \( != \)'
143264790Sbaptt 1 '! = = ='
144264790Sbaptt 0 '! = = \)'
145264790Sbaptt 0 '! "" -o ""'
146264790Sbaptt 1 '! "x" -o ""'
147264790Sbaptt 1 '! "" -o "x"'
148264790Sbaptt 1 '! "x" -o "x"'
149264790Sbaptt 0 '\( -f /etc/passwd \)'
150264790Sbaptt 1 '\( ! = \)'
151264790Sbaptt 0 '\( ! "" \)'
152264790Sbaptt 1 '\( ! -e \)'
153264790Sbapt
154264790Sbaptt 0 '0 -eq 0 -a -d /'
155264790Sbaptt 0 '-s = "" -o "" = ""'
156264790Sbaptt 0 '"" = "" -o -s = ""'
157264790Sbaptt 1 '-s = "" -o -s = ""'
158264790Sbaptt 0 '-z x -o x = "#" -o x = x'
159264790Sbaptt 1 '-z y -o y = "#" -o y = x'
160264790Sbaptt 0 '0 -ne 0 -o ! -f /'
161264790Sbaptt 0 '1 -ne 0 -o ! -f /etc/passwd'
162264790Sbaptt 1 '0 -ne 0 -o ! -f /etc/passwd'
163264790Sbapt