1#							-*- Autotest -*-
2
3AT_BANNER([M4sh.])
4
5# Copyright (C) 2000-2012 Free Software Foundation, Inc.
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20## --------------------------- ##
21## Re-exec with CONFIG_SHELL.  ##
22## --------------------------- ##
23
24AT_SETUP([No extra re-exec with CONFIG_SHELL])
25AT_KEYWORDS([CONFIG_SHELL])
26AT_DATA_M4SH([script.as],
27[[
28dnl We have to muck with internal details to goad the script into
29dnl thinking that the default shell is always good enough.
30m4_define([_AS_DETECT_REQUIRED_BODY], [])dnl
31m4_define([_AS_DETECT_SUGGESTED_BODY], [])dnl
32AS_INIT
33echo foo > ok
34]])
35AT_CHECK_M4SH
36AT_CHECK([CONFIG_SHELL=/bin/false ./script], [0], [], [])
37AT_CHECK([test -f ok], [0])
38rm -f ok
39
40AT_CLEANUP
41
42AT_SETUP([Forced re-exec with CONFIG_SHELL])
43AT_KEYWORDS([CONFIG_SHELL])
44
45AT_DATA_M4SH([script.as],
46[[m4_define([_AS_FORCE_REEXEC_WITH_CONFIG_SHELL], [yes])
47AS_INIT
48echo foo > sentinel
49]])
50AT_CHECK_M4SH
51
52# Calling the script simply 'script' could cause problems with
53# Solaris /usr/xpg4/bin/sh in the invocation 'sh script' below.
54mv -f script script2
55
56AT_DATA([fake-shell],
57[[#!/bin/sh
58echo 'Fake shell executed.'
59shift # fake shell
60echo "nargs = @S|@#"
61for i
62do
63  printf ' :%s:\n' "$i"
64done
65]])
66chmod a+x fake-shell
67
68AT_CHECK([CONFIG_SHELL=./fake-shell ./script2 1 2 4 8], [0],
69[Fake shell executed.
70nargs = 4
71 :1:
72 :2:
73 :4:
74 :8:
75], [])
76AT_CHECK([test ! -f sentinel], [0])
77test ! -f sentinel || rm -f sentinel # Cleanup for next test.
78
79AT_CHECK(
80[CONFIG_SHELL=`pwd`/fake-shell sh script2 a 'b  c' '  d	   e '],
81[0],
82[Fake shell executed.
83nargs = 3
84 :a:
85 :b  c:
86 :  d	   e :
87], [])
88AT_CHECK([test ! -f sentinel], [0])
89test ! -f sentinel || rm -f sentinel # Cleanup for next test.
90
91AT_CHECK([(PATH=`pwd`:$PATH; export PATH;
92CONFIG_SHELL=fake-shell script2 '' '&' '!;*' '<($[]@%:@)>,' 'x
93y  z
941 2 3')], [0],
95[Fake shell executed.
96nargs = 5
97 ::
98 :&:
99 :!;*:
100 :<($[]@%:@)>,:
101 :x
102y  z
1031 2 3:
104], [])
105AT_CHECK([test ! -f sentinel], [0])
106test ! -f sentinel || rm -f sentinel # Cleanup for next test.
107
108AT_CLEANUP
109
110AT_SETUP([Configure re-execs self with CONFIG_SHELL])
111
112AT_DATA([configure.ac],
113[[AC_INIT
114echo foobar >> quux
115]])
116
117AT_CHECK_AUTOCONF
118
119AT_DATA([cfg-sh],
120[[#!/bin/sh
121: > cfg-sh-has-run
122exec sh "@S|@@"
123]])
124chmod a+x cfg-sh
125
126AT_CAPTURE_FILE([config.log])
127# Export CONFIG_SITE to /dev/null to avoid spurious diffs in expected
128# stdout/stderr.
129AT_CHECK([env CONFIG_SITE=/dev/null CONFIG_SHELL=./cfg-sh ./configure],
130         [0], [], [])
131# ./configure re-executed itself.
132AT_CHECK([test -f cfg-sh-has-run], [0])
133# And did that not to cause extra execution of later commands.
134AT_CHECK([cat quux], [0], [foobar
135], [])
136
137rm -f quux cfg-sh*
138AT_CLEANUP
139
140
141## ------------------- ##
142## AS_WARN, AS_ERROR.  ##
143## ------------------- ##
144
145AT_SETUP([AS@&t@_WARN and AS@&t@_ERROR])
146AT_KEYWORDS([m4sh])
147
148dnl without logging
149AT_DATA_M4SH([script.as],
150[[AS_INIT
151AS_WARN([*watch out*])dnl
152
153if test x"$die" != x; then
154  AS_ERROR([you're dead])dnl
155
156  AS_ERROR([really])dnl
157
158fi
159echo got here
160]])
161
162AT_CHECK_M4SH
163AT_CHECK([$CONFIG_SHELL ./script], [],
164[[got here
165]], [[script: WARNING: *watch out*
166]])
167AT_CHECK([die=: $CONFIG_SHELL ./script], [1],
168[], [[script: WARNING: *watch out*
169script: error: you're dead
170]])
171
172dnl with logging
173rm script
174AT_DATA_M4SH([script.as],
175[[AS_INIT
176m4_define([gone], [AS_ERROR([really])])
177m4_define([AS_MESSAGE_LOG_FD], [5])
178exec AS_MESSAGE_LOG_FD>log.txt
179AS_WARN([*watch out*])dnl
180
181if test x"$die" != x; then
182  AS_ERROR([you're dead])dnl
183
184  AS_ERROR([really])dnl
185
186fi
187echo got here
188exec AS_MESSAGE_LOG_FD>&-
189]])
190
191AT_CHECK_M4SH
192AT_CHECK([$CONFIG_SHELL ./script], [],
193[[got here
194]], [[script: WARNING: *watch out*
195]])
196AT_CHECK([[grep 'script:[0-9]*: WARNING: \*watch out\*' log.txt]], [], [ignore])
197AT_CHECK([die=: $CONFIG_SHELL ./script], [1],
198[], [[script: WARNING: *watch out*
199script: error: you're dead
200]])
201AT_CHECK([[grep 'script:[0-9]*: WARNING: \*watch out\*' log.txt]], [], [ignore])
202AT_CHECK([[grep 'script:[0-9]*: error: you'\''re dead' log.txt]], [], [ignore])
203
204AT_CLEANUP
205
206## ---------------- ##
207## LINENO support.  ##
208## ---------------- ##
209
210AT_SETUP([LINENO])
211AT_KEYWORDS([m4sh])
212
213# We cannot unset LINENO with Zsh, yet this test case relies on
214# unsetting LINENO to compare its result when (i) LINENO is supported
215# and when (ii) it is not.
216# So just skip if the shell is ZSH.
217AT_CHECK([test -n "${ZSH_VERSION+set}" && exit 77], ignore)
218
219# AT_DATA_LINENO(FILE-NAME,
220#                UNSET-LINENO = true | false, COUNTER, COUNTER-RE)
221# ----------------------------------------------------------------
222# Produce the FILE-NAME M4sh script which uses the COUNTER LINENO or
223# _oline_, which we can recognized via COUNTER-RE.  Unset LINENO is
224# UNSET-LINENO.
225#
226# Use COUNTER, COUNTER-RE = [__LINENO__], [LINENO]
227#  or                     = [__OLINE__],  [_oline__]
228#
229# instead of the obvious $LINENO and __oline__, because they would
230# be replaced in the test suite itself, even before creating these
231# scripts.  For the same reason, grep for LINENO and _oline__ (sic).
232#
233# UNSET-LINENO is a shell condition to make sure the scripts have the
234# same number of lines in the output, so that their outputs be identical.
235m4_define([AT_DATA_LINENO],
236[AT_DATA([$1.tas],
237[[AS@&t@_INIT
238m4@&t@_divert_text([], [
239if $2; then
240  AS@&t@_UNSET([LINENO])
241fi
242])
243AS@&t@_LINENO_PREPARE
244echo "Line: $3"
245grep 'Line: .*$4' "$[0]" >/dev/null ||
246  AS@&t@_ERROR([cannot find original script])
247exit 0
248]])
249# If occurrences of $LINENO or __@&t@oline__ were wanted, create them.
250sed 's/__LINENO__/$''LINENO/g;s/__OLINE__/__''oline__/g' $1.tas >$1.as
251AT_CHECK([autom4te -l m4sh $1.as -o $1])
252])# AT_DATA_LINENO
253
254# `_oline_', once processed and ran, produces our reference.
255# We check that we find ourselves by looking at a string which is
256# available only in the original script: `_oline_'.
257AT_DATA_LINENO([reference], [false], [__OLINE__], [_oline__])
258AT_CHECK([./reference], 0, [stdout])
259
260# The reference:
261mv stdout expout
262
263# Now using a maybe-functioning LINENO, with different call conventions.
264# Be sure to be out of the PATH.
265AT_CHECK([mkdir test || exit 77])
266
267AT_DATA_LINENO([test/test-1], [false], [__LINENO__], [LINENO])
268AT_CHECK([./test/test-1],                          0, [expout])
269AT_CHECK([(PATH=test$PATH_SEPARATOR$PATH; export PATH; exec test-1)],
270						   0, [expout])
271AT_CHECK([sh ./test/test-1],                       0, [expout])
272
273# Now using a disabled LINENO, with different call conventions.
274AT_DATA_LINENO([test/test-2], [true], [__LINENO__], [LINENO])
275AT_CHECK([./test/test-2],                          0, [expout])
276AT_CHECK([(PATH=test$PATH_SEPARATOR$PATH; export PATH; exec test-2)],
277						   0, [expout])
278AT_CHECK([sh ./test/test-2],                       0, [expout])
279
280AT_CLEANUP
281
282
283## ---------------------- ##
284## LINENO stack support.  ##
285## ---------------------- ##
286
287AT_SETUP([LINENO stack])
288AT_KEYWORDS([m4sh])
289
290AT_DATA_M4SH([script.as],
291[[AS_INIT
292
293AS_LINENO_PUSH([9999])
294test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 1])
295AS_LINENO_PUSH([8888])
296test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 2])
297AS_LINENO_POP
298test $as_lineno = 9999 || AS_ERROR([bad as_lineno at depth 1])
299AS_LINENO_POP
300test x${as_lineno+set} = xset && AS_ERROR([as_lineno set at depth 0])
301
302AS_EXIT([0])
303]])
304
305AT_CHECK_M4SH
306AT_CHECK([$CONFIG_SHELL ./script])
307
308AT_CLEANUP
309
310
311## -------- ##
312## AS_BOX.  ##
313## -------- ##
314
315# Output a framed one-line message.
316AT_SETUP([AS@&t@_BOX])
317AT_KEYWORDS([m4sh])
318
319AT_DATA_M4SH([script.as],
320[[AS_INIT
321echo
322AS_BOX([Send a simple message, to foobar@example.com])
323AS_BOX([Send a simple message, to foobar@example.com], [$])
324m4_define([msg], [$complex])
325complex='Not quite as simple |$[1]'
326AS_BOX([msg])
327AS_BOX([msg], [,])
328AS_EXIT(0)
329]])
330
331AT_CHECK_M4SH
332AT_CHECK([sed -n '/ -\{44\} /,/ -\{44\} /p' script ]dnl
333[| sed '1 s/.*## -/## -/; 3 s/- ##.*/- ##/'], [],
334[[## -------------------------------------------- ##
335## Send a simple message, to foobar@example.com ##
336## -------------------------------------------- ##
337]])
338
339AT_CHECK([$CONFIG_SHELL ./script], [], [[
340## -------------------------------------------- ##
341## Send a simple message, to foobar@example.com ##
342## -------------------------------------------- ##
343## $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ##
344## Send a simple message, to foobar@example.com ##
345## $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ##
346## ----------------------- ##
347## Not quite as simple |$1 ##
348## ----------------------- ##
349## ,,,,,,,,,,,,,,,,,,,,,,, ##
350## Not quite as simple |$1 ##
351## ,,,,,,,,,,,,,,,,,,,,,,, ##
352]])
353
354AT_CLEANUP
355
356
357# Strip path from file.
358AT_SETUP([AS@&t@_BASENAME])
359AT_KEYWORDS([m4sh])
360
361AT_DATA_M4SH([script.as],
362[[AS_INIT
363
364m4_define([BASENAME_TEST],
365[base=`AS_BASENAME([$1])`
366test "$base" = "$2" ||
367  echo "basename($1) = $base instead of $2" >&2
368
369base=`_AS_BASENAME_SED([$1])`
370test "$base" = "$2" ||
371  echo "basename_sed($1) = $base instead of $2" >&2])
372
373BASENAME_TEST([//1],             [1])
374BASENAME_TEST([/1],              [1])
375BASENAME_TEST([./1],             [1])
376BASENAME_TEST([../../2],         [2])
377BASENAME_TEST([//1/],            [1])
378BASENAME_TEST([/1/],             [1])
379BASENAME_TEST([./1/],            [1])
380BASENAME_TEST([../../2],         [2])
381BASENAME_TEST([//1/3],           [3])
382BASENAME_TEST([/1/3],            [3])
383BASENAME_TEST([./1/3],           [3])
384BASENAME_TEST([../../2/3],       [3])
385BASENAME_TEST([//1/3///],        [3])
386BASENAME_TEST([/1/3///],         [3])
387BASENAME_TEST([./1/3///],        [3])
388BASENAME_TEST([../../2/3///],    [3])
389BASENAME_TEST([//1//3/],         [3])
390BASENAME_TEST([/1//3/],          [3])
391BASENAME_TEST([./1//3/],         [3])
392BASENAME_TEST([a.c],             [a.c])
393BASENAME_TEST([a.c/],            [a.c])
394BASENAME_TEST([/a.c/],           [a.c])
395BASENAME_TEST([/1/a.c],          [a.c])
396BASENAME_TEST([/1/a.c/],         [a.c])
397BASENAME_TEST([/1/../a.c],       [a.c])
398BASENAME_TEST([/1/../a.c/],      [a.c])
399BASENAME_TEST([./1/a.c],         [a.c])
400BASENAME_TEST([./1/a.c/],        [a.c])
401AS_EXIT(0)
402]])
403
404AT_CHECK_M4SH
405AT_CHECK([$CONFIG_SHELL ./script])
406
407AT_CLEANUP
408
409
410## ------------ ##
411## AS_DIRNAME.  ##
412## ------------ ##
413
414# Strip filename component.
415AT_SETUP([AS@&t@_DIRNAME])
416AT_KEYWORDS([m4sh])
417
418AT_DATA_M4SH([script.as],
419[[AS_INIT
420
421# The EXPR variant is allowed to fail if `expr' was considered as too
422# weak for us, in which case `as_expr=false'.
423m4_define([DIRNAME_TEST],
424[dir=`AS_DIRNAME([$1])`
425test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
426  echo "dirname($1) = $dir instead of $2" >&2
427
428if test "$as_expr" != false; then
429  dir=`_AS_DIRNAME_EXPR([$1])`
430  test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
431    echo "dirname_expr($1) = $dir instead of $2" >&2
432fi
433
434dir=`_AS_DIRNAME_SED([$1])`
435test "$dir" = "$2" || (test -n "$3" && test "$dir" = "$3") ||
436  echo "dirname_sed($1) = $dir instead of $2" >&2])
437
438DIRNAME_TEST([/],		[/])
439DIRNAME_TEST([//],		[//],	[/])
440DIRNAME_TEST([///],		[/])
441DIRNAME_TEST([//1],		[//],	[/])
442DIRNAME_TEST([/1],		[/])
443DIRNAME_TEST([./1],		[.])
444DIRNAME_TEST([../../2],		[../..])
445DIRNAME_TEST([//1/],		[//],	[/])
446DIRNAME_TEST([/1/],		[/])
447DIRNAME_TEST([./1/],		[.])
448DIRNAME_TEST([../../2],		[../..])
449DIRNAME_TEST([//1/3],		[//1])
450DIRNAME_TEST([/1/3],		[/1])
451DIRNAME_TEST([./1/3],		[./1])
452DIRNAME_TEST([../../2/3],	[../../2])
453DIRNAME_TEST([//1/3///],	[//1])
454DIRNAME_TEST([/1/3///],		[/1])
455DIRNAME_TEST([./1/3///],	[./1])
456DIRNAME_TEST([../../2/3///],	[../../2])
457DIRNAME_TEST([//1//3/],		[//1])
458DIRNAME_TEST([/1//3/],		[/1])
459DIRNAME_TEST([./1//3/],		[./1])
460DIRNAME_TEST([../../2//3/],	[../../2])
461AS_EXIT(0)
462]])
463
464AT_CHECK_M4SH
465AT_CHECK([$CONFIG_SHELL ./script])
466
467AT_CLEANUP
468
469
470## ---------------- ##
471## AS_SET_CATFILE.  ##
472## ---------------- ##
473
474AT_SETUP([AS@&t@_SET_CATFILE])
475AT_KEYWORDS([m4sh])
476
477AT_DATA_M4SH([script.as],
478[[AS_INIT
479
480# CATFILE_TEST(DIR, FILE, EXPECTED)
481m4_define([CATFILE_TEST],
482[# AS_SET_CATFILE works and can be used in a compound list.
483if AS_SET_CATFILE([var], [$1], [$2]) \
484   && test "$var" = $3; then :; else
485  echo "catfile($1, $2) = $var != $3" >&2
486fi
487# AS_SET_CATFILE can use non-literals in its arguments.
488varname=var2
489dirpart=$1
490filepart=$2
491if AS_SET_CATFILE([$varname], [$dirpart], [$filepart]) \
492   && test "$var2" = $3; then :; else
493  echo "catfile($dirpart, $filepart) = $var2 != $3" >&2
494fi
495])
496
497CATFILE_TEST([dir], [file], [dir/file])
498CATFILE_TEST([.], [file], [file])
499CATFILE_TEST([dir], [.], [dir])
500CATFILE_TEST([dir], [/abs/file], [/abs/file])
501CATFILE_TEST([dir], [C:/abs/file], [C:/abs/file])
502CATFILE_TEST(["dir  name"], ['file  name'], ['dir  name/file  name'])
503
504AS_EXIT(0)
505]])
506
507AT_CHECK_M4SH
508AT_CHECK([$CONFIG_SHELL ./script])
509
510AT_CLEANUP
511
512
513## --------- ##
514## AS_ECHO.  ##
515## --------- ##
516
517# Print literal strings, with/without newline.
518AT_SETUP([AS@&t@_ECHO and AS@&t@_ECHO_N])
519AT_KEYWORDS([m4sh])
520
521AT_DATA_M4SH([script.as],
522[[AS_INIT
523
524m4_define([ECHO_TEST],
525[echo=`AS_ECHO(['$1'])`
526test "X$echo" = 'X$1' ||
527  echo "AS@&t@_ECHO('"'$1'"') outputs '$echo'" >&2
528
529echo=`AS_ECHO_N(['$1'])`
530test "X$echo" = 'X$1' ||
531  echo "AS@&t@_ECHO_N('"'$1'"') outputs '$echo'" >&2])
532
533ECHO_TEST([-])
534ECHO_TEST([--])
535ECHO_TEST([---...---])
536ECHO_TEST([	 ])
537ECHO_TEST([-e])
538ECHO_TEST([-E])
539ECHO_TEST([-n])
540ECHO_TEST([-n -n])
541ECHO_TEST([-e -n])
542ECHO_TEST([ab\ncd])
543ECHO_TEST([abcd\c])
544ECHO_TEST([\a\b\c\f\n\r\t\v\"\])
545ECHO_TEST([ab
546cd
547e])
548ECHO_TEST([
549 ])
550ECHO_TEST([
551\c])
552AS_EXIT(0)
553]])
554
555AT_CHECK_M4SH
556AT_CHECK([$CONFIG_SHELL ./script])
557
558AT_CLEANUP
559
560
561
562## ----------------- ##
563## AS_EXECUTABLE_P.  ##
564## ----------------- ##
565
566# Check for executable regular files.
567AT_SETUP([AS@&t@_EXECUTABLE_P])
568AT_KEYWORDS([m4sh])
569
570AT_DATA_M4SH([script.as],
571[[AS_INIT
572
573if AS_EXECUTABLE_P([/]); then
574  echo fail
575else
576  echo 1
577fi
578cat > foo.sh <<\EOF || AS_EXIT([1])
579#!/bin/sh
580exit 0
581EOF
582# File systems like FAT tend to fake executable permissions on all files.
583# At this point, foo.sh should be executable iff permissions are faked.
584AS_EXECUTABLE_P([foo.sh])
585st1=$?
586(./foo.sh) >/dev/null 2>&1
587st2=$?
588case $st1:$st2 in
589  *[[1-9]]*:*[[1-9]]* | 0:0 ) echo 2 ;;
590  *) echo "fail ($st1:$st2)" ;;
591esac
592# Now things better be executable
593chmod a+x foo.sh || AS_EXIT([2])
594mkdir 'two  spaces' || AS_EXIT([3])
595'two  spaces'/../foo.sh || AS_EXIT([4])
596if AS_EXECUTABLE_P(["two  spaces/../foo.sh"]); then
597  echo 3
598else
599  echo fail
600fi
601]])
602
603AT_CHECK_M4SH
604AT_CHECK([$CONFIG_SHELL ./script], [],
605[[1
6062
6073
608]])
609
610AT_CLEANUP
611
612
613
614## --------- ##
615## AS_EXIT.  ##
616## --------- ##
617
618# Exit scripts with given status.
619AT_SETUP([AS@&t@_EXIT])
620AT_KEYWORDS([m4sh AS@&t@_SET_STATUS])
621
622AT_DATA_M4SH([script.as],
623[[AS_INIT
624test x${1} = xa && AS_EXIT
625test x${1} = xb && AS_EXIT([${2}])
626test x${1} = xc && { AS_SET_STATUS([${2}]); AS_EXIT; }
627test x${1} = xd && trap 's=$?; echo $s; AS_EXIT([$s])' 0
628test x${2} = xe && set -e
629test $[#] -gt 0 || AS_EXIT
630AS_SET_STATUS([3])
631dnl Solaris /bin/sh 'set -e' doesn't react to failed function calls
632test x${2} = xe \
633  && { echo 'skipping rest of test: set -e support is lousy'; exit 77; }
634AS_SET_STATUS([4])
635]])
636
637AT_CHECK_M4SH
638AT_CHECK([$CONFIG_SHELL ./script], [1])
639AT_CHECK([$CONFIG_SHELL ./script ''], [4])
640AT_CHECK([$CONFIG_SHELL ./script a], [0])
641AT_CHECK([$CONFIG_SHELL ./script b], [0])
642AT_CHECK([$CONFIG_SHELL ./script b 0], [0])
643AT_CHECK([$CONFIG_SHELL ./script b 2], [2])
644AT_CHECK([$CONFIG_SHELL ./script c 0], [0])
645AT_CHECK([$CONFIG_SHELL ./script c 2], [2])
646AT_CHECK([$CONFIG_SHELL ./script d], [4], [[4
647]])
648dnl If we got to this point without a FAIL, then AS_EXIT at least works.
649dnl The rest of this test relies on semi-decent 'set -e' support, even
650dnl though m4sh in general should not try to rely on it because of
651dnl portability nightmares on what constructs are considered errors across
652dnl various shells; therefore, an overall SKIP result is desirable on
653dnl broken shells like Solaris /bin/sh.
654AT_CHECK([$CONFIG_SHELL ./script '' e], [3])
655AT_CHECK([$CONFIG_SHELL ./script d e], [3], [stdout])
656dnl NetBSD sh fails to output on stderr here.
657AT_CHECK([grep 3 stdout || exit 77], [], [ignore])
658
659AT_CLEANUP
660
661
662
663## ------------ ##
664## AS_MKDIR_P.  ##
665## ------------ ##
666
667# Build nested dirs.
668AT_SETUP([AS@&t@_MKDIR_P])
669AT_KEYWORDS([m4sh])
670
671AT_DATA_M4SH([script.as],
672[[AS_INIT
673
674pwd=`pwd`
675set -e
676# Absolute
677AS_MKDIR_P(["$pwd/1/2/3/4/5/6"])
678test -d "$pwd/1/2/3/4/5/6" ||
679  AS_ERROR([$pwd/1/2/3/4/5/6 has not been properly created])
680# Relative
681AS_MKDIR_P(["a/b/c/d/e/f"])
682test -d a/b/c/d/e/f ||
683  AS_ERROR([a/b/c/d/e/f has not been properly created])
684AS_EXIT(0)
685]])
686
687AT_CHECK_M4SH
688AT_CHECK([$CONFIG_SHELL ./script])
689
690AT_CLEANUP
691
692
693
694
695## -------------------- ##
696## AS_VERSION_COMPARE.  ##
697## -------------------- ##
698
699# Three-way version comparison.
700AT_SETUP([AS@&t@_VERSION_COMPARE])
701AT_KEYWORDS([m4sh])
702
703AT_DATA_M4SH([script.as],
704[[AS_INIT
705
706m4_define([VERSION_COMPARE_TEST],
707[AS_VERSION_COMPARE([$1], [$3], [result='<'], [result='='], [result='>'])
708test "X$result" = "X$2" ||
709  AS_ERROR([version $1 $result $3; should be $1 $2 $3])
710m4_if([$1], <,
711[AS_VERSION_COMPARE([$3], [$1], [result='<'], [result='='], [result='>'])
712test "X$result" = "X>" ||
713  AS_ERROR([version $3 $result $1; should be $3 > $1])])])
714
715VERSION_COMPARE_TEST([], =, [])
716VERSION_COMPARE_TEST([1.0], =, [1.0])
717VERSION_COMPARE_TEST([alpha-1.0], =, [alpha-1.0])
718
719# These tests are taken from libc/string/tst-svc.expect.
720tst_svc_expect='
721  000 001 00 00a 01 01a 0 0a 2.8 2.8-0.4 20 21 22 212 CP037 CP345 CP1257
722  foo foo-0.4 foo-0.4a foo-0.4b foo-0.5 foo-0.10.5 foo-3.01 foo-3.0
723  foo-3.0.0 foo-3.0.1 foo-3.2 foo-3.10 foo00 foo0
724'
725test1=''
726for test2 in $tst_svc_expect; do
727  VERSION_COMPARE_TEST([$test1], <, [$test2])
728  test1=$test2
729done
730
731AS_EXIT(0)
732]])
733
734AT_CHECK_M4SH
735AT_CHECK([$CONFIG_SHELL ./script])
736
737AT_CLEANUP
738
739
740
741
742## ------- ##
743## as_me.  ##
744## ------- ##
745
746AT_SETUP([as_me])
747AT_KEYWORDS([m4sh])
748
749AT_DATA_M4SH([script.as],
750[[AS_INIT
751AS_ME_PREPARE
752test "$as_me" = script || AS_ECHO([["incorrect value of \$as_me: $as_me"]])
753]])
754
755AT_CHECK_M4SH
756AT_CHECK([$CONFIG_SHELL ./script])
757
758AT_CLEANUP
759
760
761
762
763## ----------------------------- ##
764## Negated classes in globbing.  ##
765## ----------------------------- ##
766
767# According to http://www.in-ulm.de/~mascheck/bourne/, all shells with
768# functions also support `[!...]'.  But `[^...]' is not universally supported.
769
770AT_SETUP([Negated classes in globbing])
771AT_KEYWORDS([m4sh])
772
773AT_DATA_M4SH([script.as],
774[[AS_INIT
775
776case 'with!two!bangs' in
777  *[[!a-z]]*) ;;
778           *) AS_ERROR([[`*[!a-z]*' didn't match `with!two!bangs']]);;
779esac
780
781case without in
782  *[[!a-z]]*) AS_ERROR([[`*[!a-z]*' matched `without']]);;
783esac
784]])
785
786AT_CHECK_M4SH
787AT_CHECK([$CONFIG_SHELL ./script])
788
789AT_CLEANUP
790
791## ---------------------------- ##
792## Null variable substitution.  ##
793## ---------------------------- ##
794
795# According to http://www.in-ulm.de/~mascheck/bourne/, all shells with
796# functions also support `${a:-b}'.
797
798AT_SETUP([Null variable substitution])
799AT_KEYWORDS([m4sh])
800
801AT_DATA_M4SH([script.as],
802[[AS_INIT
803
804AS_UNSET([a])
805b=
806c=.
807case ${a:-x}${b:-y}${c:-z} in
808  xy.) ;;
809  *) exit 1 ;;
810esac
811case ${a-x}${b-y}${c-z} in
812  x.) ;;
813  *) exit 2 ;;
814esac
815
816case ${a+x}${b+y}${c+z} in
817  yz) ;;
818  *) exit 3 ;;
819esac
820case ${a:+x}${b:+y}${c:+z} in
821  z) ;;
822  *) exit 4 ;;
823esac
824
825case ${a=x}${b=y}${c=z} in
826  x.) ;;
827  *) exit 5 ;;
828esac
829AS_UNSET([a])
830case ${a:=x}${b:=y}${c:=z} in
831  xy.) ;;
832  *) exit 6 ;;
833esac
834case $a$b$c in
835  xy.) ;;
836  *) exit 7 ;;
837esac
838AS_UNSET([a])
839b=
840
841(: ${a?oops}; echo fail) 2>err && exit 8
842grep oops err >/dev/null || exit 9
843test "${b?oops}" = '' || exit 10
844test "${c?oops}" = . || exit 11
845(: ${a:?oops}; echo fail) 2>err && exit 12
846grep oops err >/dev/null || exit 13
847(: ${b:?oops}; echo fail) 2>err && exit 14
848grep oops err >/dev/null || exit 15
849test "${c:?oops}" = . || exit 16
850]])
851
852AT_CHECK_M4SH
853AT_CHECK([$CONFIG_SHELL ./script])
854
855AT_CLEANUP
856
857
858## ------------------- ##
859## Functions Support.  ##
860## ------------------- ##
861
862# All m4sh scripts require function support.
863
864AT_SETUP([Functions Support])
865AT_KEYWORDS([m4sh])
866
867AT_DATA_M4SH([script.as],
868[[AS_INIT
869AS_LINENO_PREPARE
870
871func_return () {
872  (exit $1)
873}
874
875func_success () {
876  func_return 0
877}
878
879func_failure () {
880  func_return 1
881}
882
883if func_success; then
884  if func_failure; then
885    AS_ERROR([func_failure passed])
886  fi
887else
888  AS_ERROR([func_success failed])
889fi
890]])
891
892AT_CHECK_M4SH
893AT_CHECK([$CONFIG_SHELL ./script])
894
895AT_CLEANUP
896
897
898
899
900## ------------------------------ ##
901## Functions and return Support.  ##
902## ------------------------------ ##
903
904# All m4sh scripts require working return within functions.
905
906AT_SETUP([Functions and return Support])
907AT_KEYWORDS([m4sh])
908
909AT_DATA_M4SH([script.as],
910[[AS_INIT
911AS_LINENO_PREPARE
912
913func_success () {
914  return 0
915}
916
917func_failure () {
918  return 1
919}
920
921if func_success; then
922  if func_failure; then
923    AS_ERROR([func_failure passed])
924  fi
925else
926  AS_ERROR([func_success failed])
927fi
928]])
929
930AT_CHECK_M4SH
931AT_CHECK([$CONFIG_SHELL ./script])
932
933AT_CLEANUP
934
935
936## --------------------------- ##
937## Nested AS_REQUIRE_SHELL_FN. ##
938## --------------------------- ##
939
940# Hypothesis: M4sh expands nested AS_REQUIRE_SHELL_FN
941# separately.
942
943AT_SETUP([Nested AS@&t@_REQUIRE_SHELL_FN])
944AT_KEYWORDS([m4sh])
945
946AT_DATA_M4SH([script.as], [[dnl
947m4_define([INIT], [oops])dnl
948AS_INIT
949
950m4_defun([TEST_FUNC2_BODY], [
951:
952])
953
954m4_defun([TEST_FUNC1_BODY], [
955AS_REQUIRE_SHELL_FN([test_func2], [], [TEST_FUNC2_BODY])
956:
957])
958
959AS_REQUIRE_SHELL_FN([test_func1], [], [TEST_FUNC1_BODY])
960test_func2
961]])
962
963AT_CHECK_M4SH
964AT_CHECK([$CONFIG_SHELL ./script])
965
966AT_CLEANUP
967
968
969## ------------------- ##
970## Nested AS_REQUIRE.  ##
971## ------------------- ##
972
973# Hypothesis: M4sh expands the requirements of AS_REQUIRE in the
974# requested diversion, even if other AS_REQUIREs are interleaved.
975
976AT_SETUP([Nested AS@&t@_REQUIRE])
977AT_KEYWORDS([m4sh])
978
979AT_DATA_M4SH([script.as], [[dnl
980AS_INIT
981
982m4_defun([in_fn_diversion], still_in_m4sh_init_fn=yes)
983m4_defun([not_in_fn_diversion], still_in_m4sh_init_fn=no)
984
985m4_defun([NESTED], [nested_require_in_fn_diversion=$still_in_m4sh_init_fn])
986
987m4_defun([OUTER], [AS_REQUIRE([NESTED])dnl
988outer_require_in_fn_diversion=$still_in_m4sh_init_fn])
989
990m4_defun([test_init], [
991AS_REQUIRE([in_fn_diversion], , [M4SH-INIT-FN])
992AS_REQUIRE([OUTER], , [M4SH-INIT-FN])
993AS_REQUIRE([not_in_fn_diversion], , [M4SH-INIT-FN])
994])
995
996test_init
997if test $outer_require_in_fn_diversion != yes; then AS_EXIT([1]); fi
998if test $nested_require_in_fn_diversion != no; then AS_EXIT([1]); fi
999]])
1000
1001AT_CHECK_M4SH
1002AT_CHECK([$CONFIG_SHELL ./script])
1003
1004AT_CLEANUP
1005
1006
1007## ------------------------------------ ##
1008## AS_REQUIRE_SHELL_FN and m4_require.  ##
1009## ------------------------------------ ##
1010
1011# Hypothesis: M4sh expands the requirements of AS_REQUIRE_SHELL_FN
1012# in M4SH-INIT-FN.  This changed after Autoconf 2.63.
1013
1014AT_SETUP([AS@&t@_REQUIRE_SHELL_FN and m4@&t@_require])
1015AT_KEYWORDS([m4sh])
1016
1017AT_DATA_M4SH([script.as], [[dnl
1018AS_INIT
1019
1020m4_defun([in_m4_sh_init], still_in_m4sh_init=yes)
1021m4_defun([not_in_m4_sh_init], still_in_m4sh_init=no)
1022
1023m4_defun([error_if_emitted_in_m4sh_init], [
1024  if test x$still_in_m4sh_init = xyes; then
1025    AS_ERROR([requirement emitted in M4SH-INIT])
1026  fi
1027])
1028
1029m4_defun([TEST_FUNC_BODY], [
1030m4_require([error_if_emitted_in_m4sh_init])
1031: echo in shell function, with parameter = [$]1
1032])
1033
1034
1035m4_defun([test_init], [
1036AS_REQUIRE([in_m4_sh_init], , [M4SH-INIT-FN])
1037AS_REQUIRE_SHELL_FN([test_func], [], [TEST_FUNC_BODY])
1038AS_REQUIRE([not_in_m4_sh_init])
1039])
1040
1041test_init
1042test_func parameter1
1043]])
1044
1045AT_CHECK_M4SH
1046AT_CHECK([$CONFIG_SHELL ./script])
1047
1048AT_CLEANUP
1049
1050
1051## -------------- ##
1052## AS_HELP_STRING ##
1053## -------------- ##
1054
1055AT_SETUP([AS@&t@_HELP_STRING])
1056AT_KEYWORDS([m4sh m4@&t@_text_wrap m4@&t@_expand])
1057
1058AT_DATA_M4SH([script.as],
1059[[AS_INIT
1060
1061echo "AS_HELP_STRING([--an-option],[some text])"
1062echo "AS_HELP_STRING([--another-much-longer-option],
1063[some other text which should wrap at our default of 80 characters.])"
1064echo "AS_HELP_STRING([--fooT=barT], [foo bar])"
1065echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@], [foo bar])"
1066echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789], [foo bar])"
1067echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890], [foo bar])"
1068echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901], [foo bar])"
1069echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012], [foo bar])"
1070echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123], [foo bar])"
1071echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@],
1072[some other text which should wrap at our default of 80 characters.])"
1073echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789],
1074[some other text which should wrap at our default of 80 characters.])"
1075echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890],
1076[some other text which should wrap at our default of 80 characters.])"
1077echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901],
1078[some other text which should wrap at our default of 80 characters.])"
1079echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012],
1080[some other text which should wrap at our default of 80 characters.])"
1081echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123],
1082[some other text which should wrap at our default of 80 characters.])"
1083echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@],
1084[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
1085echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789],
1086[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
1087echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890],
1088[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
1089echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@12345678901],
1090[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
1091echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@123456789012],
1092[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
1093echo "AS_HELP_STRING([--foo@<][:@=bar@:][>@1234567890123],
1094[some other @<][:@ex@:][>@ which should wrap at our default of 80 characters.])"
1095echo "AS_HELP_STRING([[--foo[=bar]]],
1096[some other t[]t which should wrap at our default of 80 characters.])"
1097echo "AS_HELP_STRING([[--foo[=bar]123456789]],
1098[some other t[]t which should wrap at our default of 80 characters.])"
1099echo "AS_HELP_STRING([[--foo[=bar]1234567890]],
1100[some other t[]t which should wrap at our default of 80 characters.])"
1101echo "AS_HELP_STRING([[--foo[=bar]12345678901]],
1102[some other t[]t which should wrap at our default of 80 characters.])"
1103echo "AS_HELP_STRING([[--foo[=bar]123456789012]],
1104[some other t[]t which should wrap at our default of 80 characters.])"
1105echo "AS_HELP_STRING([[--foo[=bar]1234567890123]],
1106[some other t[]t which should wrap at our default of 80 characters.])"
1107m4_define([mac], [MACRO])dnl
1108echo "AS_HELP_STRING([--mac], [mac])"
1109echo "AS_HELP_STRING([--o1, --o2], [two
1110options,	one  description])"
1111echo "AS_HELP_STRING([[[--o3, --o4]]], [comma inside literal quoting])"
1112echo "AS_HELP_STRING([--tune1], [check out the tuned formatting],
1113[            ])"
1114echo "AS_HELP_STRING([--tune2], [check out the tuned formatting],
1115[12])"
1116echo "AS_HELP_STRING([--tune3], [check out the tuned formatting],
1117[], [40])"
1118echo "AS_HELP_STRING([--tune4], [check out the tuned formatting],
1119[12], [40])"
1120]])
1121
1122AT_CHECK_M4SH
1123AT_CHECK([$CONFIG_SHELL ./script], [0],
1124[[  --an-option             some text
1125  --another-much-longer-option
1126                          some other text which should wrap at our default of
1127                          80 characters.
1128  --fooT=barT             foo bar
1129  --foo[=bar]             foo bar
1130  --foo[=bar]123456789    foo bar
1131  --foo[=bar]1234567890   foo bar
1132  --foo[=bar]12345678901  foo bar
1133  --foo[=bar]123456789012 foo bar
1134  --foo[=bar]1234567890123
1135                          foo bar
1136  --foo[=bar]             some other text which should wrap at our default of
1137                          80 characters.
1138  --foo[=bar]123456789    some other text which should wrap at our default of
1139                          80 characters.
1140  --foo[=bar]1234567890   some other text which should wrap at our default of
1141                          80 characters.
1142  --foo[=bar]12345678901  some other text which should wrap at our default of
1143                          80 characters.
1144  --foo[=bar]123456789012 some other text which should wrap at our default of
1145                          80 characters.
1146  --foo[=bar]1234567890123
1147                          some other text which should wrap at our default of
1148                          80 characters.
1149  --foo[=bar]             some other [ex] which should wrap at our default of
1150                          80 characters.
1151  --foo[=bar]123456789    some other [ex] which should wrap at our default of
1152                          80 characters.
1153  --foo[=bar]1234567890   some other [ex] which should wrap at our default of
1154                          80 characters.
1155  --foo[=bar]12345678901  some other [ex] which should wrap at our default of
1156                          80 characters.
1157  --foo[=bar]123456789012 some other [ex] which should wrap at our default of
1158                          80 characters.
1159  --foo[=bar]1234567890123
1160                          some other [ex] which should wrap at our default of
1161                          80 characters.
1162  --foo[=bar]             some other t[]t which should wrap at our default of
1163                          80 characters.
1164  --foo[=bar]123456789    some other t[]t which should wrap at our default of
1165                          80 characters.
1166  --foo[=bar]1234567890   some other t[]t which should wrap at our default of
1167                          80 characters.
1168  --foo[=bar]12345678901  some other t[]t which should wrap at our default of
1169                          80 characters.
1170  --foo[=bar]123456789012 some other t[]t which should wrap at our default of
1171                          80 characters.
1172  --foo[=bar]1234567890123
1173                          some other t[]t which should wrap at our default of
1174                          80 characters.
1175  --MACRO                 mac
1176  --o1, --o2              two options, one description
1177  [--o3, --o4]            comma inside literal quoting
1178  --tune1   check out the tuned formatting
1179  --tune2   check out the tuned formatting
1180  --tune3                 check out the
1181                          tuned
1182                          formatting
1183  --tune4   check out the tuned
1184            formatting
1185]])
1186
1187AT_CLEANUP
1188
1189
1190## ------------------- ##
1191## AS_IF and AS_CASE.  ##
1192## ------------------- ##
1193
1194AT_SETUP([AS@&t@_IF and AS@&t@_CASE])
1195AT_KEYWORDS([m4sh m4@&t@_map_args_pair])
1196
1197AT_DATA_M4SH([script.as], [[dnl
1198AS_INIT
1199# Syntax checks: cope with empty arguments.
1200AS_IF([:], [], [echo wrong])
1201AS_IF([:], [echo one], [echo wrong])
1202AS_IF([false], [echo wrong], [echo two])
1203AS_IF([false], [echo wrong])
1204# n-ary version
1205AS_IF([false], [echo wrong],
1206      [:], [echo three])
1207AS_IF([false], [echo wrong],
1208      [:], [echo four],
1209      [echo wrong])
1210AS_IF([false], [echo wrong],
1211      [false], [echo wrong])
1212AS_IF([false], [echo wrong],
1213      [false], [echo wrong],
1214      [echo five])
1215AS_IF([false], [echo wrong],
1216      [false], [echo wrong],
1217      [:], [echo six],
1218      [echo wrong])
1219AS_CASE([foo])
1220AS_CASE([foo], [echo seven])
1221AS_CASE([foo],
1222        [foo], [echo eight],
1223        [echo wrong])
1224AS_CASE([foo],
1225        [foo], [echo nine],
1226        [*],   [echo wrong])
1227AS_CASE([foo],
1228        [bar], [echo wrong],
1229        [foo], [echo ten],
1230        [*],   [echo wrong])
1231
1232# check for nesting, lists, and side effects, and quoting robustness
1233empty=
1234AS_IF([AS_IF([$empty], [echo eleven])]) && AS_CASE([foo]) && echo twelve
1235rm -f file
1236AS_IF([touch file; false]) && echo thirteen
1237test -f file && echo fourteen
1238rm -f file
1239AS_CASE([`touch file; false`]) && test -f file && echo fifteen
1240dnl The next line is badly underquoted; don't intentionally copy this style.
1241AS_CASE([foo], [foo], m4_do(AS_CASE([bar], [bar], [echo sixteen])))
1242dnl Handle blank arguments.
1243AS_IF([false], [:], [ ]) && AS_CASE([foo], [foo], []
1244) && echo seventeen
1245m4_define([empty])AS_IF([:], [empty]
1246) && AS_CASE([foo], [foo], [empty]) && echo eighteen
1247dnl We can't handle AS_IF([false], [:], [empty]) unless m4_expand is
1248dnl taught how to handle m4_require.  The user is responsible for
1249dnl avoiding the syntax error in that case.
1250
1251# check that require works correctly
1252m4_for([n], 1, 9, [],
1253[m4_defun([FOO]n, [foo]n[=]n)dnl
1254m4_defun([BAR]n,
1255	 [m4_require([FOO]]n[)dnl
1256bar]n[=]n)[]dnl
1257])
1258
1259AS_IF([:], [BAR1])
1260echo "foo1=$foo1 bar1=$bar1"
1261AS_IF([:], [], [BAR2])
1262echo "foo2=$foo2 bar2=$bar2"
1263AS_IF([false], [BAR3])
1264echo "foo3=$foo3 bar3=$bar3"
1265AS_IF([false], [], [BAR4])
1266echo "foo4=$foo4 bar4=$bar4"
1267AS_CASE([x], [x], [BAR5])
1268echo "foo5=$foo5 bar5=$bar5"
1269AS_CASE([x], [y], [BAR6])
1270echo "foo6=$foo6 bar6=$bar6"
1271AS_CASE([x],
1272	[x], [:],
1273	[BAR7])
1274echo "foo7=$foo7 bar7=$bar7"
1275AS_CASE([x],
1276	[y], [:],
1277	[BAR8])
1278echo "foo8=$foo8 bar8=$bar8"
1279AS_CASE([x],
1280	[y], [:],
1281	[x], [BAR9])
1282echo "foo9=$foo9 bar9=$bar9"
1283]])
1284
1285AT_CHECK_M4SH
1286AT_CHECK([$CONFIG_SHELL ./script], [0], [[one
1287two
1288three
1289four
1290five
1291six
1292seven
1293eight
1294nine
1295ten
1296eleven
1297twelve
1298thirteen
1299fourteen
1300fifteen
1301sixteen
1302seventeen
1303eighteen
1304foo1=1 bar1=1
1305foo2=2 bar2=
1306foo3=3 bar3=
1307foo4=4 bar4=4
1308foo5=5 bar5=5
1309foo6=6 bar6=
1310foo7=7 bar7=
1311foo8=8 bar8=8
1312foo9=9 bar9=9
1313]])
1314
1315dnl stress test for large number of conditionals
1316dnl too large, and we start tickling shell bugs
1317m4_pushdef([limit], [1000])dnl
1318AT_DATA_M4SH([script.as], [[dnl
1319AS_INIT
1320AS_IF(m4_shift(m4_for([i], [1], ]limit[, [], [, test $[1] = i, echo i])))
1321AS_IF(m4_shift(m4_for([i], [1], ]limit[, [], [, test $[1] = i, echo i])),
1322      [echo default])
1323AS_CASE([$[1]]m4_for([i], [1], ]limit[, [], [, i, echo i]))
1324AS_CASE([$[1]]m4_for([i], [1], ]limit[, [], [, i, echo i]), [echo default])
1325]])
1326
1327dnl Add --force so autom4te doesn't think `script' is still up to date.
1328AT_CHECK_M4SH([--force])
1329AT_CHECK([$CONFIG_SHELL ./script 1], [0], [[1
13301
13311
13321
1333]])
1334AT_CHECK([$CONFIG_SHELL ./script limit], [0], [limit
1335limit
1336limit
1337limit
1338])
1339AT_CHECK([$CONFIG_SHELL ./script default], [0], [[default
1340default
1341]])
1342m4_popdef([limit])
1343
1344AT_CLEANUP
1345
1346
1347## -------- ##
1348## AS_FOR.  ##
1349## -------- ##
1350
1351AT_SETUP([AS@&t@_FOR])
1352AT_KEYWORDS([m4sh])
1353
1354AT_DATA_M4SH([script.as], [[dnl
1355AS_INIT
1356
1357# Simple checks.
1358AS_FOR([m4var], [shvar], [a],
1359[echo "m4var $shvar"])
1360AS_FOR([m4var], [shvar], [b c],
1361[echo "m4var $shvar"])
1362list='d e'
1363AS_FOR([m4var], [shvar], [$list],
1364[echo "m4var $shvar"])
1365AS_FOR([m4var], [shvar], ["$list"],
1366[echo "m4var $shvar"])
1367AS_FOR([m4var], [shvar], ['$list'],
1368[echo "m4var $shvar"])
1369AS_FOR([m4var], [shvar], [\'],
1370[echo "m4var $shvar"])
1371
1372# Syntax checks: cope with empty/blank arguments.
1373set f g
1374AS_FOR([], [shvar], [],
1375[echo "m4_defn([]) $shvar"])
1376rm -f file
1377AS_FOR([], [shvar], [`touch file`])
1378test -f file || exit 1
1379AS_FOR([], [shvar], [], [ ])
1380m4_define([empty])AS_FOR([], [shvar], [], [empty])
1381
1382# Check that break works.
1383while :
1384do
1385  AS_FOR([m4var], [shvar], [h i],
1386    [echo "m4var"; break 2])
1387  exit 1
1388done
1389while :
1390do
1391  AS_FOR([m4var], [shvar], [j],
1392    [echo "m4var"; break 2])
1393  exit 1
1394done
1395]])
1396
1397AT_CHECK_M4SH
1398AT_CHECK([$CONFIG_SHELL ./script], [0], [[a a
1399b b
1400c c
1401d d
1402e e
1403d e d e
1404$list $list
1405' '
1406f f
1407g g
1408h
1409j
1410]])
1411
1412AT_CLEANUP
1413
1414
1415## --------------- ##
1416## AS_LITERAL_IF.  ##
1417## --------------- ##
1418
1419AT_SETUP([AS@&t@_LITERAL_IF])
1420AT_KEYWORDS([m4sh AS@&t@_LITERAL_WORD_IF AS@&t@_LITERAL_HEREDOC_IF])
1421
1422AT_DATA_M4SH([script.as], [[dnl
1423AS_INIT
1424echo AS_LITERAL_IF([lit], [ok], [ERR]) 1
1425echo AS_LITERAL_IF([l-/.it], [ok], [ERR]) 2
1426echo AS_LITERAL_IF([l''it], [ERR], [ok]) 3
1427echo AS_LITERAL_IF([l$it], [ERR], [ok]) 4
1428echo AS_LITERAL_IF([l$it], [ERR1], [ERR2], [ok]) 5
1429echo AS_LITERAL_IF([l${it}], [ERR1], [ERR2], [ok]) 6
1430echo AS_LITERAL_IF([l`case a in b) ;; esac`it], [ERR], [ok]) 7
1431echo AS_LITERAL_IF([l`case a in b) ;; esac`it], [ERR1], [ok], [ERR2]) 8
1432m4_define([mac], [l-/.it])
1433echo AS_LITERAL_IF([mac], [ok], [ERR]) 9
1434echo AS_LITERAL_IF([mac($, ``)], [ok], [ERR]) 10
1435m4_define([mac], [l$it])
1436echo AS_LITERAL_IF([mac], [ERR], [ok]) 11
1437echo AS_LITERAL_IF([mac], [ERR1], [ERR2], [ok]) 12
1438m4_define([mac], [l``it])
1439echo AS_LITERAL_IF([mac], [ERR], [ok]) 13
1440echo AS_LITERAL_IF([mac], [ERR1], [ok], [ERR2]) 14
1441echo AS_LITERAL_IF([	a ][
1442b], [ok], [ERR]) 15
1443echo AS_LITERAL_WORD_IF([	a ][
1444b], [ERR], [ok]) 16
1445echo AS_LITERAL_HEREDOC_IF([	a ][
1446b], [ok], [ERR]) 17
1447echo AS_LITERAL_IF([(a)], [ERR], [ok]) 18
1448echo AS_LITERAL_WORD_IF([(a)], [ERR], [ok]) 19
1449echo AS_LITERAL_HEREDOC_IF([(a)], [ok], [ERR]) 20
1450echo AS_LITERAL_IF([@S|@a], [ERR], [ok]) 21
1451echo AS_LITERAL_WORD_IF([@S|@a], [ERR], [ok]) 22
1452echo AS_LITERAL_HEREDOC_IF([@S|@a], [ERR], [ok]) 23
1453echo AS_LITERAL_IF([${a+b}], [ERR1], [ok], [ERR2]) 24
1454echo AS_LITERAL_IF([${a=b}], [ERR1], [ok], [ERR2]) 25
1455echo AS_LITERAL_IF([a+b], [ok], [ERR1], [ERR2]) 26
1456echo AS_LITERAL_IF([a=b], [ok], [ERR1], [ERR2]) 27
1457]])
1458
1459AT_CHECK_M4SH
1460AT_CHECK([$CONFIG_SHELL ./script], [],
1461[[ok 1
1462ok 2
1463ok 3
1464ok 4
1465ok 5
1466ok 6
1467ok 7
1468ok 8
1469ok 9
1470ok 10
1471ok 11
1472ok 12
1473ok 13
1474ok 14
1475ok 15
1476ok 16
1477ok 17
1478ok 18
1479ok 19
1480ok 20
1481ok 21
1482ok 22
1483ok 23
1484ok 24
1485ok 25
1486ok 26
1487ok 27
1488]])
1489
1490AT_CLEANUP
1491
1492
1493## --------------------- ##
1494## AS_TR_SH, AS_TR_CPP.  ##
1495## --------------------- ##
1496
1497AT_SETUP([AS@&t@_TR_SH and AS@&t@_TR_CPP])
1498
1499AT_DATA_M4SH([script.as], [[dnl
1500AS_INIT
1501m4_define([abc], [hI])m4_define([ABC], [Hi])
1502m4_define([hi], [oops])m4_define([HI], [OOPS])
1503echo AS_TR_SH(abc) AS_TR_SH(aBc) AS_TR_SH(ABC)
1504echo AS_TR_SH([abc]) AS_TR_SH([aBc]) AS_TR_SH([ABC])
1505echo AS_TR_SH([[abc]]) AS_TR_SH([[aBc]]) AS_TR_SH([[ABC]])
1506echo AS_TR_CPP(abc) AS_TR_CPP(aBc) AS_TR_CPP(ABC)
1507echo AS_TR_CPP([abc]) AS_TR_CPP([aBc]) AS_TR_CPP([ABC])
1508echo AS_TR_CPP([[abc]]) AS_TR_CPP([[aBc]]) AS_TR_CPP([[ABC]])
1509echo ===
1510[var=abc vAr=aBc VAR=ABC]
1511echo AS_TR_SH($var) AS_TR_SH($vAr) AS_TR_SH($VAR)
1512echo AS_TR_SH([$var]) AS_TR_SH([$vAr]) AS_TR_SH([$VAR])
1513echo AS_TR_SH([[$var]]) AS_TR_SH([[$vAr]]) AS_TR_SH([[$VAR]])
1514echo AS_TR_CPP($var) AS_TR_CPP($vAr) AS_TR_CPP($VAR)
1515echo AS_TR_CPP([$var]) AS_TR_CPP([$vAr]) AS_TR_CPP([$VAR])
1516echo AS_TR_CPP([[$var]]) AS_TR_CPP([[$vAr]]) AS_TR_CPP([[$VAR]])
1517echo ===
1518echo AS_TR_SH(`echo abc`) AS_TR_SH(`echo aBc`) AS_TR_SH(`echo ABC`)
1519echo AS_TR_SH([`echo abc`]) AS_TR_SH([`echo aBc`]) AS_TR_SH([`echo ABC`])
1520echo AS_TR_SH([[`echo abc`]]) AS_TR_SH([[`echo aBc`]]) AS_TR_SH([[`echo ABC`]])
1521echo AS_TR_CPP(`echo abc`) AS_TR_CPP(`echo aBc`) AS_TR_CPP(`echo ABC`)
1522echo AS_TR_CPP([`echo abc`]) AS_TR_CPP([`echo aBc`]) AS_TR_CPP([`echo ABC`])
1523echo AS_TR_CPP([[`echo abc`]]) AS_TR_CPP([[`echo aBc`]]) AS_TR_CPP([[`echo ABC`]])
1524echo ===
1525# start here
1526echo AS_TR_SH([a.b/c+*-=])
1527echo AS_TR_CPP([a.b/c+*-=])
1528var=a.b/c+*-=
1529echo AS_TR_SH([$var])
1530echo AS_TR_CPP([$var])
1531m4_define([macro], [a.b/c+*-=])
1532echo AS_TR_SH([macro])
1533echo AS_TR_CPP([macro])
1534]])
1535
1536AT_CHECK_M4SH
1537AT_CHECK([$CONFIG_SHELL ./script], [],
1538[[hI aBc Hi
1539hI aBc Hi
1540abc aBc ABC
1541HI ABC HI
1542HI ABC HI
1543ABC ABC ABC
1544===
1545abc aBc ABC
1546abc aBc ABC
1547abc aBc ABC
1548ABC ABC ABC
1549ABC ABC ABC
1550ABC ABC ABC
1551===
1552hI aBc Hi
1553hI aBc Hi
1554abc aBc ABC
1555HI ABC HI
1556HI ABC HI
1557ABC ABC ABC
1558===
1559a_b_cpp__
1560A_B_C_P__
1561a_b_cpp__
1562A_B_C_P__
1563a_b_cpp__
1564A_B_C_P__
1565]])
1566
1567dnl Check that of the last 6 macros, only 2 needed command substitution.
1568dnl This test abuses our knowledge of m4sh internals a bit; oh well.
1569AT_CHECK([tab='	' # a single ASCII tab character
1570sed -n '/start here/,$ {
1571/`.*`/p
1572}' script | wc -l | sed "s/[[ $tab]]//g" ], [], [[2
1573]])
1574
1575AT_CLEANUP
1576
1577
1578## ---------- ##
1579## AS_VAR_*.  ##
1580## ---------- ##
1581
1582AT_SETUP([AS@&t@_VAR basics])
1583AT_KEYWORDS([m4sh AS@&t@_VAR_COPY AS@&t@_VAR_SET AS@&t@_VAR_GET])
1584AT_KEYWORDS([AS@&t@_VAR_TEST_SET AS@&t@_VAR_SET_IF AS@&t@_VAR_IF])
1585AT_KEYWORDS([AS@&t@_VAR_PUSHDEF AS@&t@_VAR_POPDEF])
1586
1587AT_DATA_M4SH([script.as], [[dnl
1588AS_INIT
1589 m4_define([with], [WITH])
1590# Literals.
1591dnl AS_VAR_SET_IF also covers AS_VAR_TEST_SET
1592AS_VAR_SET_IF([foo], [echo oops]) && echo ok
1593AS_VAR_IF([foo], [], [echo ok], [echo oops])
1594foo=
1595AS_VAR_SET_IF([foo], [echo ok])
1596AS_VAR_SET([foo], ['\a  "weird" `value` with; $fun '\''characters
1597']) # 'font-lock
1598AS_VAR_COPY([bar], [foo])
1599AS_ECHO(["$bar-"])
1600AS_ECHO(["AS_VAR_GET([foo])-"])
1601AS_VAR_SET_IF([foo], [echo ok], [echo oops])
1602AS_VAR_IF([foo], [string], [echo oops]) && echo ok
1603AS_VAR_PUSHDEF([tmp], [foo])
1604AS_VAR_IF([tmp], ['\a  "weird" `value` with; $fun '\''characters
1605'], [echo ok], [echo oops]) # 'font-lock
1606AS_VAR_POPDEF([tmp])
1607m4_ifdef([tmp], [echo oops])
1608
1609# Indirects via shell vars.
1610echo '===='
1611num=1
1612AS_VAR_SET_IF([foo$num], [echo oops]) && echo ok
1613AS_VAR_IF([foo$num], [], [echo ok], [echo oops])
1614foo1=
1615AS_VAR_SET_IF([foo$num], [echo ok])
1616AS_VAR_SET([foo$num], ['\a  "weird" `value` with; $fun '\''characters
1617']) # 'font-lock
1618AS_VAR_COPY([bar], [foo$num])
1619num=2
1620AS_VAR_COPY([foo$num], [bar])
1621AS_ECHO(["$foo2-"])
1622AS_ECHO(["AS_VAR_GET([foo$num])-"])
1623AS_VAR_SET_IF([foo$num], [echo ok], [echo oops])
1624AS_VAR_IF([foo$num], [string], [echo oops]) && echo ok
1625AS_VAR_PUSHDEF([tmp], [foo$num])
1626AS_VAR_IF([tmp], ['\a  "weird" `value` with; $fun '\''characters
1627'], [echo ok], [echo oops]) # 'font-lock
1628AS_VAR_POPDEF([tmp])
1629m4_ifdef([tmp], [echo oops])
1630
1631# Indirects via command substitution.
1632echo '===='
1633AS_VAR_SET_IF([`echo foo3`], [echo oops]) && echo ok
1634AS_VAR_IF([`echo foo3`], [], [echo ok], [echo oops])
1635foo3=
1636AS_VAR_SET_IF([`echo foo3`], [echo ok])
1637AS_VAR_SET([`echo foo3`], ['\a  "weird" `value` with; $fun '\''characters
1638']) # 'font-lock
1639AS_VAR_COPY([bar], [`echo foo3`])
1640num=2
1641AS_VAR_COPY([`echo foo4`], [bar])
1642AS_ECHO(["$foo4-"])
1643AS_ECHO(["AS_VAR_GET([`echo foo4`])-"])
1644AS_VAR_SET_IF([`echo foo4`], [echo ok], [echo oops])
1645AS_VAR_IF([`echo foo4`], [string], [echo oops]) && echo ok
1646AS_VAR_PUSHDEF([tmp], [`echo foo4`])
1647AS_VAR_IF([tmp], ['\a  "weird" `value` with; $fun '\''characters
1648'], [echo ok], [echo oops]) # 'font-lock
1649AS_VAR_POPDEF([tmp])
1650m4_ifdef([tmp], [echo oops])
1651:
1652]])
1653
1654AT_CHECK_M4SH
1655AT_CHECK([$CONFIG_SHELL ./script], [], [[ok
1656ok
1657ok
1658\a  "weird" `value` WITH; $fun 'characters
1659-
1660\a  "weird" `value` WITH; $fun 'characters
1661-
1662ok
1663ok
1664ok
1665====
1666ok
1667ok
1668ok
1669\a  "weird" `value` WITH; $fun 'characters
1670-
1671\a  "weird" `value` WITH; $fun 'characters-
1672ok
1673ok
1674ok
1675====
1676ok
1677ok
1678ok
1679\a  "weird" `value` WITH; $fun 'characters
1680-
1681\a  "weird" `value` WITH; $fun 'characters-
1682ok
1683ok
1684ok
1685]])
1686
1687AT_CLEANUP
1688
1689
1690## --------------- ##
1691## AS_VAR_APPEND.  ##
1692## --------------- ##
1693
1694AT_SETUP([AS@&t@_VAR_APPEND])
1695AT_KEYWORDS([m4sh AS@&t@_VAR])
1696
1697AT_DATA_M4SH([script.as], [[dnl
1698AS_INIT
1699# Literals.
1700AS_VAR_APPEND([foo], ["hello,  "])
1701AS_VAR_APPEND([foo], [world])
1702echo "$foo"
1703# Indirects via shell vars.
1704num=1
1705AS_VAR_APPEND([foo$num], ['hello,  '])
1706AS_VAR_APPEND([foo$num], [`echo "world"`])
1707echo "$foo1"
1708# Indirects via command substitution.
1709h=hello w=',  world'
1710AS_VAR_APPEND([`echo foo2`], [${h}])
1711AS_VAR_APPEND([`echo foo2`], ["$w"])
1712echo "$foo2"
1713]])
1714
1715AT_CHECK_M4SH
1716AT_CHECK([$CONFIG_SHELL ./script], [],
1717[[hello,  world
1718hello,  world
1719hello,  world
1720]])
1721
1722AT_CLEANUP
1723
1724
1725## -------------- ##
1726## AS_VAR_ARITH.  ##
1727## -------------- ##
1728
1729AT_SETUP([AS@&t@_VAR_ARITH])
1730AT_KEYWORDS([m4sh AS@&t@_VAR])
1731
1732AT_DATA_M4SH([script.as], [[dnl
1733AS_INIT
1734# Literals.
1735AS_VAR_ARITH([foo], [1 + 1])
1736echo "$foo"
1737# Indirects via shell vars.
1738num=1
1739AS_VAR_ARITH([foo$num], [\( 2 + 3 \) \* 4])
1740echo "$foo1"
1741# Indirects via command substitution.
1742AS_VAR_ARITH([`echo foo2`], [0 + -2 + $foo1 / 2])
1743echo "$foo2"
1744]])
1745
1746AT_CHECK_M4SH
1747AT_CHECK([$CONFIG_SHELL ./script], [],
1748[[2
174920
17508
1751]])
1752
1753AT_CLEANUP
1754
1755
1756## ----------------- ##
1757## AS_INIT cleanup.  ##
1758## ----------------- ##
1759
1760AT_SETUP([AS@&t@_INIT cleanup])
1761AT_KEYWORDS([m4sh m4@&t@_wrap m4@&t@_wrap_lifo])
1762
1763AT_DATA_M4SH([script.as], [[dnl
1764dnl Registered before AS_INIT's cleanups
1765m4_wrap([echo cleanup 1
1766])
1767m4_pushdef([_AS_SHELL_FN_SPY])dnl neutralize the spy, we don't care about it
1768AS_INIT
1769dnl Registered after AS_INIT's cleanups, thus goes to KILL diversion
1770m4_wrap([echo cleanup 2
1771dnl However, nested wraps and diversions can still be used
1772dnl Also, test wrapping text that looks like parameter reference
1773m4_wrap([echo cleanup 3
1774m4_divert_text([M4SH-INIT], [m4_define([foo], [$1])dnl
1775echo prep foo([4])
1776])])])
1777dnl Registered before AS_INIT's cleanups
1778m4_wrap_lifo([echo cleanup 5
1779])
1780echo body
1781]])
1782
1783AT_CHECK_M4SH
1784AT_CHECK([$CONFIG_SHELL ./script], [], [[prep 4
1785body
1786cleanup 5
1787cleanup 1
1788]])
1789
1790AT_CLEANUP
1791
1792
1793## ------------------- ##
1794## AS_INIT_GENERATED.  ##
1795## ------------------- ##
1796
1797AT_SETUP([AS@&t@_INIT_GENERATED])
1798AT_KEYWORDS([AS@&t@_MESSAGE AS@&t@_MESSAGE_LOG_FD])
1799
1800dnl First run, no logging, tests shell selection
1801AT_DATA_M4SH([script.as], [[dnl
1802AS_INIT
1803AS_INIT_GENERATED([child], [echo hello from child])
1804cat >>child <<\EOF
1805AS_ECHO(["SHELL=$SHELL"])
1806EOF
1807echo hello from parent
1808AS_ECHO(["SHELL=$SHELL"])
1809]])
1810
1811AT_CHECK_M4SH
1812AT_CHECK([$CONFIG_SHELL ./script], [0], [stdout])
1813AT_CHECK([grep 'SHELL=.' stdout], [0], [ignore])
1814sed s/parent/child/ <stdout >expout
1815AT_CHECK([./child], [0], [expout])
1816SHELL=/bogus
1817export SHELL
1818cp stdout expout
1819mv child child.bak
1820AT_CHECK([$CONFIG_SHELL ./script], [0], [expout])
1821AT_CHECK([cmp child child.bak])
1822AT_CHECK([grep 'SHELL=.' stdout], [0], [ignore])
1823sed s/parent/child/ <stdout >expout
1824AT_CHECK([./child], [0], [expout])
1825
1826
1827dnl Second run, with logging from parent and child, tests fd handling
1828AT_DATA_M4SH([script.as], [[dnl
1829AS_INIT
1830child=${1-child}
1831m4_define([AS_MESSAGE_LOG_FD], [5])
1832exec AS_MESSAGE_LOG_FD>log
1833AS_INIT_GENERATED([$child], [echo hello1 from $child]) || AS_EXIT([1])
1834cat >>$child <<\EOF
1835m4_pushdef([AS_MESSAGE_LOG_FD])
1836AS_MESSAGE([hello2 from ${child}child])
1837m4_popdef([AS_MESSAGE_LOG_FD])
1838exec AS_MESSAGE_LOG_FD>>log
1839AS_MESSAGE([hello3 from child])
1840EOF
1841AS_MESSAGE([hello from parent])
1842dnl close log in parent before spawning child, for mingw
1843exec AS_MESSAGE_LOG_FD>&-
1844./$child
1845]])
1846
1847rm -f script
1848AT_CHECK_M4SH
1849AT_CHECK([$CONFIG_SHELL ./script], [0], [[script: hello from parent
1850hello1 from child
1851child: hello2 from child
1852child: hello3 from child
1853]])
1854AT_CHECK([[sed 's,:[0-9][0-9]*:,:0:,' log]], [0],
1855[[script:0: hello from parent
1856child:0: hello3 from child
1857]])
1858
1859# Force write error creating a file on stdout
1860if test -w /dev/full && test -c /dev/full; then
1861  AT_CHECK([$CONFIG_SHELL ./script /dev/full], [1], [ignore], [ignore])
1862fi
1863
1864AT_CLEANUP
1865
1866
1867## --------------- ##
1868## AS_MESSAGE_FD.  ##
1869## --------------- ##
1870
1871AT_SETUP([AS@&t@_MESSAGE_FD])
1872AT_KEYWORDS([AS@&t@_MESSAGE AS@&t@_MESSAGE_LOG_FD AS@&t_ORIGINAL_STDIN_FD])
1873AT_KEYWORDS([AS@&t@_LINENO_PUSH])
1874
1875AT_DATA_M4SH([script.as], [[dnl
1876AS_INIT
1877m4_define([AS_ORIGINAL_STDIN_FD], [5])
1878m4_define([AS_MESSAGE_LOG_FD], [6])
1879m4_define([AS_MESSAGE_FD], [7])
1880exec AS_ORIGINAL_STDIN_FD<&0 </dev/null AS_MESSAGE_LOG_FD>log
1881if test $[#] -gt 0; then
1882  exec AS_MESSAGE_FD>/dev/null
1883else
1884  exec AS_MESSAGE_FD>&1
1885fi
1886AS_LINENO_PUSH([100])
1887cat # tests that stdin is neutralized
1888AS_MESSAGE([hello world])
1889cat <&AS_ORIGINAL_STDIN_FD
1890]])
1891
1892AT_CHECK_M4SH
1893AT_CHECK([echo goodbye | $CONFIG_SHELL ./script], [0],
1894[[script: hello world
1895goodbye
1896]])
1897AT_CHECK([cat log], [0],
1898[[script:100: hello world
1899]])
1900rm log
1901AT_CHECK([echo goodbye | $CONFIG_SHELL ./script silent], [0],
1902[[goodbye
1903]])
1904AT_CHECK([cat log], [0],
1905[[script:100: hello world
1906]])
1907
1908AT_CLEANUP
1909
1910
1911## --------------- ##
1912## _AS_CLEAN_DIR.  ##
1913## --------------- ##
1914
1915AT_SETUP([_AS@&t@_CLEAN_DIR])
1916
1917dnl ensure that we can erase all files in a directory.  Note that
1918dnl _AS_CLEAN_DIR needs three globs to catch all these files.
1919AT_DATA_M4SH([script.as], [[dnl
1920AS_INIT
1921# Unwritable subdirectories are common during 'make distcheck'.
1922mkdir sub sub/unwritable || AS_ERROR([failed to mkdir])
1923touch sub/unwritable/file || AS_ERROR([failed to touch])
1924chmod a-wx sub/unwritable || AS_ERROR([failed to chmod])
1925# Cygwin 1.5 can't touch 'sub/...', so make that file optional.
1926touch sub/a sub/aa sub/aaa sub/.a sub/..a sub/.aa \
1927  || AS_ERROR([failed to touch])
1928touch sub/... 2>/dev/null
1929_AS_CLEAN_DIR([sub]) || AS_ERROR([failed to clean])
1930# rmdir instead of 'rm -fr' here proves that we emptied sub.
1931rmdir sub || AS_ERROR([failed to rmdir])
1932]])
1933
1934AT_CHECK_M4SH
1935AT_CHECK([$CONFIG_SHELL ./script])
1936
1937AT_CLEANUP
1938
1939
1940## -------- ##
1941## ECHO_C.  ##
1942## -------- ##
1943
1944AT_SETUP([ECHO_C])
1945
1946AT_DATA_M4SH([script.as], [[dnl
1947AS_INIT
1948_AS_PREPARE
1949foo=`echo foobar`
1950echo "$foo"
1951]])
1952
1953AT_CHECK_M4SH
1954AT_CHECK([$CONFIG_SHELL ./script], [], [foobar
1955])
1956
1957AT_CLEANUP
1958