]> git.draconx.ca Git - dxcommon.git/blob - tests/scripts.at
41dfbb43760bcf95cd87792db5101e851cd1d882
[dxcommon.git] / tests / scripts.at
1 dnl Copyright © 2021-2022 Nick Bowler
2 dnl
3 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
4 dnl This is free software: you are free to do what the fuck you want to.
5 dnl There is NO WARRANTY, to the extent permitted by law.
6
7 AT_BANNER([Script tests])
8
9 AT_SETUP([gen-options.awk])
10 AT_KEYWORDS([gen-options awk script scripts])
11
12 AT_DATA([options.def],
13 [[--option-only
14 --option-with-val (5)
15 --option-with-flagval (&x, 5)
16 --option-with-arg=ARG
17 some "text" goes here
18 --option-with-optional-arg[=OPTIONAL]
19
20 hello
21 -a, --option-with-sopt
22
23 -b, --option-with-sopt-and-arg=SOPTARG
24 -c, --option-with-sopt-and-optional-arg[=SOPTOPTIONAL]
25 --option-with-arg-and-val=ARGVAL (42)
26 --option-with-arg-and-flagval=ARGFLAGVAL (&a[1], 'x')
27 --option-with-optional-arg-and-val[=OPTIONALARGVAL] (54)
28 --option-with-optional-arg-and-flagval[=OPTIONALFLAGVAL] (0, 0)
29 --with-sopt
30 Here is a help string
31     that has a line randomly indented
32 # with a comment
33     @&t@
34 and a blank line
35 --with-arg=ARG
36 do stuff with ARG
37 --flagval
38 ]])
39
40 AT_CHECK([$AWK -f "$builddir/scripts/gen-options.awk" <options.def >options.h])
41
42 AT_DATA([context.h],
43 [[struct option { const char *name; int has_arg; int *flag; int val; };
44 int x, a[5];
45 ]])
46
47 # test 0: sanity test
48 AT_DATA([test0.c],
49 [[#include "context.h"
50 #include "options.h"
51
52 static const char sopts[] = SOPT_STRING;
53 static const struct option opts[] = { LOPTS_INITIALIZER, {0} };
54
55 int main(void)
56 {
57   return 0;
58 }
59 ]])
60 AT_CHECK([$CC -o test0$EXEEXT test0.c && ./test0$EXEEXT], [0], [], [ignore])
61
62 # test 1: long option names and help text
63 AT_DATA([test1.c],
64 [[#include <stdio.h>
65 #include <stdlib.h>
66
67 #include "context.h"
68 #include "options.h"
69
70 static const struct option opts[] = { LOPTS_INITIALIZER };
71
72 int main(void)
73 {
74   unsigned i;
75
76   for (i = 0; i < sizeof opts / sizeof opts[0]; i++) {
77     struct lopt_help help = { "INVALID", "INVALID" };
78
79     if (!lopt_get_help(&opts[i], &help))
80       return EXIT_FAILURE;
81
82     printf("--%s", opts[i].name);
83     if (opts[i].has_arg)
84       printf("=%s", help.arg);
85     printf("\n%s", help.desc);
86     if (help.desc[0])
87       putchar('\n');
88   }
89
90   return 0;
91 }
92 ]])
93
94 # pick out interesting bits from the definitions file
95 sed -n '/^-/s/^.*--\([[^\= @<:@]]*\).*$/\1/p' options.def >options
96 sed -n '/^-/{
97   s/[[^=]]*\(=[[^@:>@ ]]*\).*$/\1/
98   s/^[[^=]].*//
99   s/^=//
100   p
101 }' options.def >argnames
102
103 AS_ECHO(["-"]) | sed -n '1s/^-.*//p
104 1,/^-/d
105 t clear
106 :clear
107 s/^-.*//p
108 t
109 s/^#.*//
110 s/^ *//
111 t next
112 :next
113 N
114 s/\n-.*//
115 t done
116 s/\n#.*//
117 s/\n */\n/g
118 t next
119 :done
120 s/"/\\\\"/g
121 s/[[^\n]][[^\n]]*/\\"&\\"/g
122 s/^\n*//
123 s/\n*$//
124 s/\n\n*/ /g
125 p
126 ' options.def - >helptext
127
128 exec 3<options 4<argnames 5<helptext 6>expout
129 while read opt <&3 && read arg <&4 && read help <&5; do
130   if test ${arg:+y}; then
131     AS_ECHO(["--$opt=$arg"]) >&6
132   else
133     AS_ECHO(["--$opt"]) >&6
134   fi
135   eval "set x $help"; shift
136   for arg
137   do
138     AS_ECHO(["$arg"]) >&6
139   done
140 done
141 exec 3<&- 4<&- 5<&- 6>&-
142
143 AT_CHECK([$CC -o test1$EXEEXT test1.c && ./test1$EXEEXT],
144   [0], [expout], [ignore])
145
146 # test 2: short option string
147 AT_DATA([test2.c],
148 [[#include <stdio.h>
149 #include <stdlib.h>
150
151 #include "context.h"
152 #include "options.h"
153
154 int main(void)
155 {
156   struct option lopts[] = {LOPTS_INITIALIZER};
157   unsigned i, j;
158
159   for (i = 0; i < sizeof SOPT_STRING - 1; i++) {
160     if (SOPT_STRING[i] != ':') {
161       for (j = 0; j < sizeof lopts / sizeof lopts[0]; j++) {
162         if (lopts[j].val == SOPT_STRING[i]) {
163           printf("--%s ", lopts[j].name);
164           break;
165         }
166       }
167     }
168     putchar(SOPT_STRING[i]);
169     if (SOPT_STRING[i+1] != ':')
170       putchar('\n');
171   }
172 }
173 ]])
174
175 sed -n '/^-/{
176   s/=.*/:/
177   s/[[@<:@]]/:/
178   s/^-\([[^-]]\)[[^:]]*/\1/p
179   s/^-.*//p
180 }' options.def >sopts
181
182 exec 3<options 4<sopts 5>expout
183 while read lopt <&3 && read sopt <&4; do
184   if test ${sopt:+y}; then
185     AS_ECHO(["--$lopt $sopt"]) >&5
186   fi
187 done
188 exec 3<&- 4<&- 5>&-
189
190 AT_CHECK([$CC -o test2$EXEEXT test2.c && ./test2$EXEEXT],
191   [0], [expout], [ignore])
192
193 # Check that all help strings are translatable
194 sed 's/\([[^\\]]\\\)" /\1\\n\\" /g' helptext >help-po
195 exec 3<options 4<argnames 5<help-po 6>expected.po
196 while read opt <&3 && read arg <&4 && read help <&5; do
197   if test ${arg:+y}; then
198     AS_ECHO(["msgctxt \"$opt\" msgid \"$arg\""]) >&6
199   fi
200   AS_ECHO(["msgctxt \"$opt\" msgid${help:+ }$help"]) >&6
201 done
202 exec 3<&- 4<&- 5<&- 6>&-
203
204 AT_CHECK([xgettext --keyword=PN_:1c,2 options.h
205   test -f messages.po || exit 77])
206
207 LC_ALL=C sort expected.po >expout
208 AT_CHECK([sed -n '/^msgctxt/{
209 t next
210 :next
211 N
212 s/\nmsgstr.*//
213 t done
214 s/\s*""//
215 s/\n/ /
216 t next
217 :done
218 p
219 }' messages.po | LC_ALL=C sort], [0], [expout])
220
221 AT_CLEANUP
222
223 AT_SETUP([gen-strtab.awk])
224 AT_KEYWORDS([gen-strtab awk script scripts])
225
226 AT_DATA([test.def],
227 [[
228 &a world
229 &b
230 hello world
231 &c
232 hello
233 world
234 &d world\n
235 &e
236 \\not a newline
237 &f
238 \not a newline
239 &g inline
240 continued
241 &h    no\
242 newline\
243 &i
244 \   leading whitespace
245 &j oneline
246 # with a comment
247 ]])
248
249 AT_CHECK([$AWK -f "$builddir/scripts/gen-strtab.awk" <test.def >test.h])
250
251 sed -n 's/^[[&]]\([[^ ]]*\).*/\1/p' test.def >identifiers
252
253 # test 0: sanity test
254 AT_DATA([test0.c],
255 [[#include "test.h"
256 #include <stdio.h>
257
258 int main(void)
259 {
260   printf("---\n");
261 ]])
262 exec 3<identifiers 4>>test0.c
263 while read ident <&3; do
264   AS_ECHO(['  printf("%s\n---\n", '"strtab+$ident);"]) >&4
265 done
266 AS_ECHO(['  return 0;']) >&4
267 AS_ECHO(['}']) >&4
268 exec 3<&- 4>&-
269
270 AT_CHECK([$CC -o test0$EXEEXT test0.c && ./test0$EXEEXT], [0], [---
271 world
272 ---
273 hello world
274
275 ---
276 hello
277 world
278
279 ---
280 world
281
282 ---
283 \not a newline
284
285 ---
286
287 ot a newline
288
289 ---
290 inline
291 continued
292
293 ---
294 nonewline
295 ---
296    leading whitespace
297
298 ---
299 oneline
300 ---
301 ], [ignore])
302
303 AT_CLEANUP
304
305 AT_SETUP([gen-tree.awk])
306 AT_KEYWORDS([gen-tree awk script scripts])
307
308 AT_DATA([tree.def],
309 [[# comment
310 ROOT0
311   r0a, r0a_OFFSET
312     r0b, r0b_OFFSET
313       r0c
314     r0d
315   r0e, r0e_OFFSET
316     r0f
317     r0g
318 # comment
319 ROOT1
320   r1a, r1a_OFFSET
321     r1b, r1b_OFFSET
322       r1b
323       r1e
324       r1b
325   r1c, r1c_OFFSET
326     r1d, r1d_OFFSET
327       r1e
328       r1b
329       r1e
330 # comment
331 ]])
332
333 AT_CHECK([$AWK -f "$builddir/scripts/gen-tree.awk" <tree.def >tree.h])
334
335 AT_DATA([test0.c],
336 [[#include "tree.h"
337 #include <stdio.h>
338
339 struct tree { unsigned id, subtree; };
340
341 static const struct tree tree0[] = {
342   ROOT0_INITIALIZER
343 };
344 static const struct tree tree1[] = {
345   ROOT1_INITIALIZER
346 };
347
348 void print_subtree(const struct tree *root, unsigned offset, int depth)
349 {
350   const struct tree *node;
351
352   for (node = &root[offset]; node->id; node++) {
353     printf("%*s%s", 2*depth, "", &tree_strtab[node->id]);
354     if (node->subtree) {
355       printf(", %s_OFFSET\n", &tree_strtab[node->id]);
356       print_subtree(root, node->subtree, depth+1);
357     } else {
358       putchar('\n');
359     }
360   }
361 }
362
363 int main(void)
364 {
365   printf("ROOT0\n");
366   print_subtree(tree0, 0, 1);
367   printf("ROOT1\n");
368   print_subtree(tree1, 0, 1);
369   return 0;
370 }
371 ]])
372 sed '/^#/d' tree.def >expout
373 AT_CHECK([$CC -o test0$EXEEXT test0.c && ./test0$EXEEXT], [0], [expout])
374
375 AT_CLEANUP
376
377 # Test the gen-tree features that avoid creating string labels for nodes.
378 AT_SETUP([gen-tree.awk @nostrtab option])
379 AT_KEYWORDS([gen-tree awk script scripts])
380
381 AT_DATA([tree.def],
382 [[@nostrtab
383 ROOT
384  a 1, a_OFFSET
385   b 1
386   c 2
387  d 2, d_OFFSET
388   e 1
389   f 2
390 ]])
391 AT_CHECK([$AWK -f "$builddir/scripts/gen-tree.awk" <tree.def >tree.h])
392
393 AT_DATA([test0.c],
394 [[float tree_strtab = 0;
395 #define a []
396 #define b []
397 #define c []
398 #define e []
399 #define f []
400 #include "tree.h"
401 #include <stdio.h>
402
403 static struct { int num, offset; } root[] = { ROOT_INITIALIZER };
404
405 int main(void)
406 {
407   unsigned i;
408   for (i = 0; i < sizeof root / sizeof root[0]; i++) {
409     printf("%d, %d\n", root[i].num, root[i].offset);
410   }
411 }
412 ]])
413
414 AT_CHECK([$CC -o test0$EXEEXT test0.c && ./test0$EXEEXT], [0],
415 [[1, 3
416 2, 6
417 0, 0
418 1, 0
419 2, 0
420 0, 0
421 1, 0
422 2, 0
423 0, 0
424 ]])
425
426 AT_DATA([flat.def],
427 [[FLAT
428  a 1
429  b 2
430  c 3
431 @nostrtab
432 ]])
433 AT_CHECK([$AWK -f "$builddir/scripts/gen-tree.awk" <flat.def >flat.h])
434
435 sed -e 's/tree\.h/flat.h/' -e 's/ROOT/FLAT/' test0.c >test1.c
436 AT_CHECK([$CC -o test1$EXEEXT test1.c && ./test1$EXEEXT], [0],
437 [[1, 0
438 2, 0
439 3, 0
440 0, 0
441 ]])
442
443 AT_CLEANUP
444
445 AT_SETUP([join.awk])
446 AT_KEYWORDS([join awk script scripts])
447
448 JOIN="$AWK -f $builddir/scripts/join.awk --"
449
450 AT_DATA([a],
451 [[1 a
452 3 a1 x
453 3 a2 x
454 5 a
455 6 a
456 8 a1 x
457 8 a2 x
458 9 a1
459 9 a2
460 9 a3
461 ]])
462
463 AT_DATA([b],
464 [[2 b
465 2 b
466 3 b y
467 4 b
468 6 b1 y
469 6 b2 y
470 7 b
471 8 b1 y
472 8 b2 y
473 ]])
474
475 AT_CHECK([$JOIN a b], [0],
476 [[3 a1 x b y
477 3 a2 x b y
478 6 a b1 y
479 6 a b2 y
480 8 a1 x b1 y
481 8 a1 x b2 y
482 8 a2 x b1 y
483 8 a2 x b2 y
484 ]])
485
486 AT_CHECK([$JOIN -v1 a b], [0],
487 [[1 a
488 5 a
489 9 a1
490 9 a2
491 9 a3
492 ]])
493
494 AT_CHECK([$JOIN -v2 a b], [0],
495 [[2 b
496 2 b
497 4 b
498 7 b
499 ]])
500
501 AT_CHECK([$JOIN -v1 -v2 a b], [0],
502 [[1 a
503 2 b
504 2 b
505 4 b
506 5 a
507 7 b
508 9 a1
509 9 a2
510 9 a3
511 ]])
512
513 AT_CHECK([$JOIN -a1 a b], [0],
514 [[1 a
515 3 a1 x b y
516 3 a2 x b y
517 5 a
518 6 a b1 y
519 6 a b2 y
520 8 a1 x b1 y
521 8 a1 x b2 y
522 8 a2 x b1 y
523 8 a2 x b2 y
524 9 a1
525 9 a2
526 9 a3
527 ]])
528
529 AT_CHECK([$JOIN -a2 a b], [0],
530 [[2 b
531 2 b
532 3 a1 x b y
533 3 a2 x b y
534 4 b
535 6 a b1 y
536 6 a b2 y
537 7 b
538 8 a1 x b1 y
539 8 a1 x b2 y
540 8 a2 x b1 y
541 8 a2 x b2 y
542 ]])
543
544 AT_CHECK([$JOIN -a1 -a2 a b], [0],
545 [[1 a
546 2 b
547 2 b
548 3 a1 x b y
549 3 a2 x b y
550 4 b
551 5 a
552 6 a b1 y
553 6 a b2 y
554 7 b
555 8 a1 x b1 y
556 8 a1 x b2 y
557 8 a2 x b1 y
558 8 a2 x b2 y
559 9 a1
560 9 a2
561 9 a3
562 ]])
563
564 AT_CHECK([$JOIN b a], [0],
565 [[3 b y a1 x
566 3 b y a2 x
567 6 b1 y a
568 6 b2 y a
569 8 b1 y a1 x
570 8 b1 y a2 x
571 8 b2 y a1 x
572 8 b2 y a2 x
573 ]])
574
575 AT_CHECK([$JOIN -v1 b a], [0],
576 [[2 b
577 2 b
578 4 b
579 7 b
580 ]])
581
582 AT_CHECK([$JOIN -v2 b a], [0],
583 [[1 a
584 5 a
585 9 a1
586 9 a2
587 9 a3
588 ]])
589
590 AT_CHECK([$JOIN -v1 -v2 b a], [0],
591 [[1 a
592 2 b
593 2 b
594 4 b
595 5 a
596 7 b
597 9 a1
598 9 a2
599 9 a3
600 ]])
601
602 AT_CHECK([$JOIN -a1 b a], [0],
603 [[2 b
604 2 b
605 3 b y a1 x
606 3 b y a2 x
607 4 b
608 6 b1 y a
609 6 b2 y a
610 7 b
611 8 b1 y a1 x
612 8 b1 y a2 x
613 8 b2 y a1 x
614 8 b2 y a2 x
615 ]])
616
617 AT_CHECK([$JOIN -a2 b a], [0],
618 [[1 a
619 3 b y a1 x
620 3 b y a2 x
621 5 a
622 6 b1 y a
623 6 b2 y a
624 8 b1 y a1 x
625 8 b1 y a2 x
626 8 b2 y a1 x
627 8 b2 y a2 x
628 9 a1
629 9 a2
630 9 a3
631 ]])
632
633 AT_CHECK([$JOIN -a1 -a2 b a], [0],
634 [[1 a
635 2 b
636 2 b
637 3 b y a1 x
638 3 b y a2 x
639 4 b
640 5 a
641 6 b1 y a
642 6 b2 y a
643 7 b
644 8 b1 y a1 x
645 8 b1 y a2 x
646 8 b2 y a1 x
647 8 b2 y a2 x
648 9 a1
649 9 a2
650 9 a3
651 ]])
652
653 AT_CHECK([echo wat | $JOIN -v1 - /dev/null], [0],
654 [[wat
655 ]])
656
657 AT_CLEANUP
658
659 m4_divert_push([PREPARE_TESTS])dnl
660 test_fix_ltdl () {
661   $PERL -e 'my $x = 42; exit $x;'; test $? = 42 || exit 77
662   $PERL -f "$srcdir/scripts/fix-ltdl.pl" "$@"
663 }
664 test_fix_gnulib () {
665   $PERL -e 'my $x = 42; exit $x;'; test $? = 42 || exit 77
666   $PERL -f "$srcdir/scripts/fix-gnulib.pl" "$@"
667 }
668 test_gnulib_mk () {
669   echo;
670   for arg
671   do
672     sed -n -f - "$srcdir/tests/data/gnulib.mk" <<EOF
673 /^## begin gnulib module $arg/,/^## end   gnulib module $arg/p
674 EOF
675   done
676 }
677 m4_divert_pop([PREPARE_TESTS])
678
679 AT_SETUP([fix-gnulib.pl SED_HEADER variables])
680
681 test_gnulib_mk gen-header >test.mk.in
682 AT_CHECK([grep SED_HEADER test.mk.in >expout || exit 99])
683 AT_CHECK([test_fix_gnulib -i test.mk.in -o test.mk || exit
684 grep SED_HEADER test.mk], [0], [expout])
685
686 AT_CLEANUP
687
688 AT_SETUP([fix-gnulib.pl %reldir% substitution])
689
690 test_gnulib_mk sys_types >test.mk.in
691 AT_CHECK([grep '%reldir%' test.mk.in >/dev/null || exit 99])
692
693 sed -n -f - test.mk.in >expout <<'EOF'
694 ${G;p;b}
695 /^## begin gnulib/,/^## end   gnulib/!b
696 /^#/{p;b}
697 s|(srcdir)|(top_srcdir)|
698 s|%reldir%|lib|
699 s|BUILT_SOURCES|gnulib_core_headers|
700 s|sys[[/_]]|lib/&|g
701 /^MOSTLYCLEANFILES/{h;b}
702 p
703 EOF
704
705 AT_CHECK([test_fix_gnulib -i test.mk.in -o test.mk || exit
706 sed -n -e '/^## begin gnulib/,/^## end   gnulib/p' \
707        -e '/CLEANFILES/p' test.mk],
708 [0], [expout])
709
710 AT_CLEANUP
711
712 AT_SETUP([fix-gnulib.pl warning removal])
713
714 AT_DATA([test.mk.in], [[
715 ## test begin
716 noinst_LTLIBRARIES += libgnu.la
717 libgnu_la_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS)
718 noinst_LIBRARIES += libgnu.a
719 libgnu_a_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS)
720 ## test end
721 ]])
722 AT_CHECK([test_fix_gnulib -i test.mk.in -o test.mk || exit
723 sed -n '/^## test begin/,/^## test end/p' test.mk], [0], [## test begin
724 EXTRA_LTLIBRARIES += libgnu.la
725 EXTRA_LIBRARIES += libgnu.a
726 ## test end
727 ])
728
729 AT_CLEANUP
730
731 AT_SETUP([fix-gnulib.pl header directory creation])
732
733 AT_DATA([extract.sed],
734 [[/AM_V_GEN/b ok
735 /gl_V_at/b ok
736 s/:.*/:/
737 h
738 b
739 :ok
740 s/'//g
741 x
742 G
743 p
744 n
745 s/[)].*/)/
746 p
747 ]])
748
749 test_gnulib_mk alloca-opt sys_types stddef >test.mk.in
750 AT_CHECK([test_fix_gnulib -i test.mk.in -o test.mk || exit
751 sed -n -f extract.sed test.mk], [0],
752 [[lib/alloca.h:
753         $(AM_V_GEN)$(MKDIR_P) lib
754         $(AM_V_at)
755 lib/sys/types.h:
756         $(AM_V_GEN)$(MKDIR_P) lib/sys
757         $(AM_V_at)
758 lib/stddef.h:
759         $(AM_V_GEN)$(MKDIR_P) lib
760         $(AM_V_at)
761 ]])
762
763 AT_CLEANUP
764
765 dnl TEST_FIND_AUTOMAKE_VER([to-check], [test-action])
766 dnl
767 dnl For each whitespace-separated version token in to-check, check if we can
768 dnl run the programs automake-VER and aclocal-VER.  The special token 'default'
769 dnl also checks the unversioned automake and aclocal (or, if set in the
770 dnl environment, $AUTOMAKE and $ACLOCAL).
771 dnl
772 dnl Then test-action is expanded such that shell variables $ac and $am refer to
773 dnl the aclocal and automake programs, and $amver is the actual version
774 dnl reported by --version.  The action should do nothing if the version is
775 dnl acceptable, or "continue" if the version is unacceptable.
776 dnl
777 dnl If an acceptable version is found, the AUTOMAKE and ACLOCAL environment
778 dnl variables are set accordingly.  Otherwise, the test group is skipped.
779 m4_define([TEST_FIND_AUTOMAKE],
780 [have_am=false
781 for am in $1; do
782   AS_CASE([$am],
783     [default], [ac=${ACLOCAL-aclocal} am=${AUTOMAKE-automake}],
784     [ac=aclocal-$am; am=automake-$am])
785   amver=`$am --version | sed -n '1s/.* //p'`
786   acver=`$ac --version | sed -n '1s/.* //p'`
787   set x $amver $acver; shift; test x"$[]#" = x"2" || continue
788   test x"$amver" = x"$acver" || continue
789   $2
790   have_am=:; break
791 done
792 AT_CHECK([$have_am || exit 77])
793 AUTOMAKE=$am; export AUTOMAKE
794 ACLOCAL=$ac; export ACLOCAL
795 AT_CHECK([$ACLOCAL --version && $AUTOMAKE --version], [0], [stdout])
796 ])
797
798 m4_define([TEST_LTDL_LIBOBJ_MANGLING],
799 [TEST_CONFIGURE_AC([[AM_INIT_AUTOMAKE([foreign subdir-objects])
800 AC_PROG_CC
801 LT_INIT
802 AC_SUBST([ltdl_LTLIBOBJS], [libltdl/test.lo])
803 AC_CONFIG_FILES([Makefile])
804 ]])
805
806 mkdir libltdl
807 AT_DATA([ltdl.mk.in], [[
808 AM_CPPFLAGS += -DSTRING=\"helloworld\"
809
810 noinst_LTLIBRARIES = libltdl/libltdl.la
811 libltdl_libltdl_la_SOURCES = libltdl/ltdl.c
812 libltdl_libltdl_la_LIBADD = $(ltdl_LTLIBOBJS)
813 libltdl_libltdl_la_DEPENDENCIES = $(ltdl_LTLIBOBJS)
814
815 EXTRA_DIST += libltdl/test.c
816 ]])
817 AT_DATA([Makefile.am], [[AM_CPPFLAGS =
818 include $(top_srcdir)/ltdl.mk
819 AM_LIBTOOLFLAGS = --quiet
820 bin_PROGRAMS = test
821 test_SOURCES =
822 test_LDADD = libltdl/libltdl.la
823 all-local: ; @printf '%s\n' $(AM_CPPFLAGS)
824 ]])
825 AT_DATA([libltdl/test.c], [[#include <stdio.h>
826 int foo(void) { printf("%s\n", STRING); return 0; }
827 ]])
828 AT_DATA([libltdl/ltdl.c], [[int foo(void); int main(void) { return foo(); }
829 ]])
830
831 AT_CHECK([test_fix_ltdl -i ltdl.mk.in -o ltdl.mk])
832 libtoolize; TEST_AUTORECONF
833 TEST_CONFIGURE([--disable-shared])
834 AT_CHECK([make -s && ./test], [0], [
835 helloworld
836 ])])
837
838 AT_SETUP([fix-ltdl.pl LIBOBJ mangling (<automake-1.16)])
839
840 TEST_FIND_AUTOMAKE([default 1.10 1.11 1.12 1.13 1.14 1.15],
841   [AS_VERSION_COMPARE(["$amver"], [1.16], [], [continue], [continue])])
842 TEST_LTDL_LIBOBJ_MANGLING
843
844 AT_CLEANUP
845
846 AT_SETUP([fix-ltdl.pl LIBOBJ mangling (>=automake-1.16)])
847
848 TEST_FIND_AUTOMAKE([default 1.16 1.17 1.18 1.19],
849   [AS_VERSION_COMPARE(["$amver"], [1.16], [continue])])
850 TEST_LTDL_LIBOBJ_MANGLING
851
852 AT_CLEANUP