[go: up one dir, main page]

File: t0097a.sh

package info (click to toggle)
cook 2.19-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 7,316 kB
  • ctags: 3,969
  • sloc: ansic: 50,331; sh: 13,190; makefile: 4,542; yacc: 3,174; perl: 224; awk: 154
file content (302 lines) | stat: -rw-r--r-- 5,771 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#!/bin/sh
#
#	cook - file construction tool
#	Copyright (C) 1997, 1998 Peter Miller;
#	All rights reserved.
#
#	This program is free software; you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by
#	the Free Software Foundation; either version 2 of the License, or
#	(at your option) any later version.
#
#	This program is distributed in the hope that it will be useful,
#	but WITHOUT ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#	GNU General Public License for more details.
#
#	You should have received a copy of the GNU General Public License
#	along with this program; if not, write to the Free Software
#	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
#
# MANIFEST: Test the make2cook functionality
#
work=${COOK_TMP:-/tmp}/$$
PAGER=cat
export PAGER
umask 022
unset COOK
here=`pwd`
if test $? -ne 0 ; then exit 1; fi

bin="$here/${1-.}/bin"

fail()
{
	set +x
	echo 'FAILED test of the make2cook functionality' 1>&2
	cd $here
	rm -rf $work
	exit 1
}
pass()
{
	set +x
	cd $here
	rm -rf $work
	exit 0
}
trap \"fail\" 1 2 3 15

mkdir $work $work/lib
if test $? -ne 0 ; then exit 1; fi
cd $work
if test $? -ne 0 ; then fail; fi

#
# Use the default error messages.  There is no other way to get
# predictable test behaviour on the unknown systems we will be tested on.
#
COOK_MESSAGE_LIBRARY=$work/no-such-dir
export COOK_MESSAGE_LIBRARY
unset LANG

#
# test the make2cook functionality
#
cat > test.in << 'fubar'
.SUFFIXES:

libs_for_gcc = -lgnu
normal_libs =

ifeq ($(CC),gcc)
foo: $(objects)
	$(CC) -o foo $(objects) $(libs_for_gcc)
else
foo: $(objects)
	$(CC) -o foo $(objects) $(normals_libs)
endif
fubar
if test $? -ne 0 ; then fail; fi
cat > test.ok << 'fubar'
if [not [defined normals_libs]] then
	normals_libs = [getenv normals_libs];
if [not [defined objects]] then
	objects = [getenv objects];
if [not [defined CC]] then
{
	CC = [getenv CC];
	if [not [CC]] then
		CC = cc;
}

if [not [defined libs_for_gcc]] then
#line 3 "test.in"
	libs_for_gcc = -lgnu;
if [not [defined normal_libs]] then
#line 4 "test.in"
	normal_libs = ;

#if [in [CC] gcc ]
foo: [objects]
{
#line 8 "test.in"
	[CC] -o foo [objects] [libs_for_gcc];
}
#else
#line 10 "test.in"
foo: [objects]
{
#line 11 "test.in"
	[CC] -o foo [objects] [normals_libs];
}
#endif
fubar
if test $? -ne 0 ; then fail; fi

$bin/make2cook -e -ln test.in test.out
if test $? -ne 0 ; then fail; fi

diff test.ok test.out
if test $? -ne 0 ; then fail; fi

#
# test the make2cook functionality
#
cat > test.in << 'fubar'
.SUFFIXES:

libs_for_gcc = -lgnu
normal_libs =

ifneq "$(CC)" "gcc"
libs = $(normal_libs)
else
libs = $(libs_for_gcc)
endif

foo: $(objects)
	$(CC) -o foo $(objects) $(libs)
fubar
if test $? -ne 0 ; then fail; fi
cat > test.ok << 'fubar'
if [not [defined objects]] then
	objects = [getenv objects];
if [not [defined CC]] then
{
	CC = [getenv CC];
	if [not [CC]] then
		CC = cc;
}

if [not [defined libs_for_gcc]] then
#line 3 "test.in"
	libs_for_gcc = -lgnu;
if [not [defined normal_libs]] then
#line 4 "test.in"
	normal_libs = ;

#if [not [in [CC] gcc ] ]
if [not [defined libs]] then
#line 7 "test.in"
	libs = [normal_libs];
#else
if [not [defined libs]] then
#line 9 "test.in"
	libs = [libs_for_gcc];
#endif

foo: [objects]
{
#line 13 "test.in"
	[CC] -o foo [objects] [libs];
}
fubar
if test $? -ne 0 ; then fail; fi

$bin/make2cook -e -ln test.in test.out
if test $? -ne 0 ; then fail; fi

diff test.ok test.out
if test $? -ne 0 ; then fail; fi

#
# test the make2cook functionality
#
cat > test.in << 'fubar'
.SUFFIXES:

ifndef slartibartfast

ifneq "$(CC)" "gcc"
libs = $(normal_libs)
else
libs = $(libs_for_gcc)
endif

foo: $(objects)
	$(CC) -o foo $(objects) $(libs)
endif
fubar
if test $? -ne 0 ; then fail; fi
cat > test.ok << 'fubar'
if [not [defined objects]] then
	objects = [getenv objects];
if [not [defined libs_for_gcc]] then
	libs_for_gcc = [getenv libs_for_gcc];
if [not [defined normal_libs]] then
	normal_libs = [getenv normal_libs];
if [not [defined CC]] then
{
	CC = [getenv CC];
	if [not [CC]] then
		CC = cc;
}
#line 3 "test.in"
#if [not [defined slartibartfast ] ]

#if [not [in [CC] gcc ] ]
if [not [defined libs]] then
#line 6 "test.in"
	libs = [normal_libs];
#else
if [not [defined libs]] then
#line 8 "test.in"
	libs = [libs_for_gcc];
#endif

foo: [objects]
{
#line 12 "test.in"
	[CC] -o foo [objects] [libs];
}
#endif
fubar
if test $? -ne 0 ; then fail; fi

$bin/make2cook -e -ln test.in test.out
if test $? -ne 0 ; then fail; fi

diff test.ok test.out
if test $? -ne 0 ; then fail; fi

#
# test the make2cook functionality
#
cat > test.in << 'fubar'
.SUFFIXES:

libs_for_gcc = -lgnu
normal_libs =

foo: $(objects)
ifeq ($(CC),gcc)
	$(CC) -o foo $(objects) $(libs_for_gcc)
else
	$(CC) -o foo $(objects) $(normals_libs)
endif
fubar
if test $? -ne 0 ; then fail; fi
cat > test.ok << 'fubar'
if [not [defined normals_libs]] then
	normals_libs = [getenv normals_libs];
if [not [defined CC]] then
{
	CC = [getenv CC];
	if [not [CC]] then
		CC = cc;
}
if [not [defined objects]] then
	objects = [getenv objects];

if [not [defined libs_for_gcc]] then
#line 3 "test.in"
	libs_for_gcc = -lgnu;
if [not [defined normal_libs]] then
#line 4 "test.in"
	normal_libs = ;

foo: [objects]
{
#line 7 "test.in"
	#if [in [CC] gcc ]
	[CC] -o foo [objects] [libs_for_gcc];
	#else
	[CC] -o foo [objects] [normals_libs];
	#endif
}
fubar
if test $? -ne 0 ; then fail; fi

$bin/make2cook -e -ln test.in test.out
if test $? -ne 0 ; then fail; fi

diff test.ok test.out
if test $? -ne 0 ; then fail; fi

#
# Only definite negatives are possible.
# The functionality exercised by this test appears to work,
# no other guarantees are made.
#
pass