diff options
author | Jeff Bailey <jbailey@raspberryginger.com> | 2000-02-17 03:03:19 +0000 |
---|---|---|
committer | Jeff Bailey <jbailey@raspberryginger.com> | 2000-02-17 03:03:19 +0000 |
commit | bd11691d6520f7539e7ed2efdf75f266719e27e9 (patch) | |
tree | 13d3a4e534f6df846a128af52438769b9f51f09e /tests/other-tests | |
download | m4-bd11691d6520f7539e7ed2efdf75f266719e27e9.tar.gz |
Initial revision
Diffstat (limited to 'tests/other-tests')
-rw-r--r-- | tests/other-tests/discard-comments.m4 | 7 | ||||
-rwxr-xr-x | tests/other-tests/discard-comments.test | 17 | ||||
-rw-r--r-- | tests/other-tests/gmp.m4 | 10 | ||||
-rwxr-xr-x | tests/other-tests/gmp.test | 120 | ||||
-rw-r--r-- | tests/other-tests/import-environment.m4 | 4 | ||||
-rwxr-xr-x | tests/other-tests/import-environment.test | 28 | ||||
-rw-r--r-- | tests/other-tests/iso8859.m4 | bin | 0 -> 1146 bytes | |||
-rwxr-xr-x | tests/other-tests/iso8859.test | 31 | ||||
-rwxr-xr-x | tests/other-tests/stackovf.test | 86 | ||||
-rw-r--r-- | tests/other-tests/sync-lines.m4 | 12 | ||||
-rwxr-xr-x | tests/other-tests/sync-lines.test | 35 |
11 files changed, 350 insertions, 0 deletions
diff --git a/tests/other-tests/discard-comments.m4 b/tests/other-tests/discard-comments.m4 new file mode 100644 index 00000000..95aebd27 --- /dev/null +++ b/tests/other-tests/discard-comments.m4 @@ -0,0 +1,7 @@ +This is not a comment # but this is. +# This line should dissappear completely. +This should not disappear. +changecom(`<!--', `-->') +html <!-- +comment + --> ends. diff --git a/tests/other-tests/discard-comments.test b/tests/other-tests/discard-comments.test new file mode 100755 index 00000000..2f6a4599 --- /dev/null +++ b/tests/other-tests/discard-comments.test @@ -0,0 +1,17 @@ +#!/bin/sh + +# discard-comments.test is part of the GNU m4 testsuite + +. ${srcdir}/defs + +cat ${srcdir}/other-tests/discard-comments.m4 >in + +cat <<\EOF >ok +This is not a comment This should not disappear. + +html ends. +EOF + +M4PATH=$srcdir:$srcdir/other-tests $M4 -c -d in >out 2>err +sed -e "s, ../../src/m4:, m4:," err >sederr && mv sederr err +$CMP -s out ok diff --git a/tests/other-tests/gmp.m4 b/tests/other-tests/gmp.m4 new file mode 100644 index 00000000..b916ff69 --- /dev/null +++ b/tests/other-tests/gmp.m4 @@ -0,0 +1,10 @@ +divert(-1) +# forloop(i, from, to, stmt) + +define(`forloop', `pushdef(`$1', `$2')_forloop(`$1', `$2', `$3', `$4')popdef(`$1')') +define(`_forloop', + `$4`'ifelse($1, `$3', , + `define(`$1', incr($1))_forloop(`$1', `$2', `$3', `$4')')') +divert +forloop(`x', 1, 100, `2**x = eval(2**x) +') diff --git a/tests/other-tests/gmp.test b/tests/other-tests/gmp.test new file mode 100755 index 00000000..9382832a --- /dev/null +++ b/tests/other-tests/gmp.test @@ -0,0 +1,120 @@ +#!/bin/sh + +# gmp.test is part of the GNU m4 testsuite + +. ${srcdir}/defs +. ${srcdir}/config.sh + +# cannot perform test without --with-gmp +test -z "$WITH_GMP" && exit 77 + +cat ${srcdir}/other-tests/gmp.m4 >in + +cat <<\EOF >ok + +2**1 = 2 +2**2 = 4 +2**3 = 8 +2**4 = 16 +2**5 = 32 +2**6 = 64 +2**7 = 128 +2**8 = 256 +2**9 = 512 +2**10 = 1024 +2**11 = 2048 +2**12 = 4096 +2**13 = 8192 +2**14 = 16384 +2**15 = 32768 +2**16 = 65536 +2**17 = 131072 +2**18 = 262144 +2**19 = 524288 +2**20 = 1048576 +2**21 = 2097152 +2**22 = 4194304 +2**23 = 8388608 +2**24 = 16777216 +2**25 = 33554432 +2**26 = 67108864 +2**27 = 134217728 +2**28 = 268435456 +2**29 = 536870912 +2**30 = 1073741824 +2**31 = 2147483648 +2**32 = 4294967296 +2**33 = 8589934592 +2**34 = 17179869184 +2**35 = 34359738368 +2**36 = 68719476736 +2**37 = 137438953472 +2**38 = 274877906944 +2**39 = 549755813888 +2**40 = 1099511627776 +2**41 = 2199023255552 +2**42 = 4398046511104 +2**43 = 8796093022208 +2**44 = 17592186044416 +2**45 = 35184372088832 +2**46 = 70368744177664 +2**47 = 140737488355328 +2**48 = 281474976710656 +2**49 = 562949953421312 +2**50 = 1125899906842624 +2**51 = 2251799813685248 +2**52 = 4503599627370496 +2**53 = 9007199254740992 +2**54 = 18014398509481984 +2**55 = 36028797018963968 +2**56 = 72057594037927936 +2**57 = 144115188075855872 +2**58 = 288230376151711744 +2**59 = 576460752303423488 +2**60 = 1152921504606846976 +2**61 = 2305843009213693952 +2**62 = 4611686018427387904 +2**63 = 9223372036854775808 +2**64 = 18446744073709551616 +2**65 = 36893488147419103232 +2**66 = 73786976294838206464 +2**67 = 147573952589676412928 +2**68 = 295147905179352825856 +2**69 = 590295810358705651712 +2**70 = 1180591620717411303424 +2**71 = 2361183241434822606848 +2**72 = 4722366482869645213696 +2**73 = 9444732965739290427392 +2**74 = 18889465931478580854784 +2**75 = 37778931862957161709568 +2**76 = 75557863725914323419136 +2**77 = 151115727451828646838272 +2**78 = 302231454903657293676544 +2**79 = 604462909807314587353088 +2**80 = 1208925819614629174706176 +2**81 = 2417851639229258349412352 +2**82 = 4835703278458516698824704 +2**83 = 9671406556917033397649408 +2**84 = 19342813113834066795298816 +2**85 = 38685626227668133590597632 +2**86 = 77371252455336267181195264 +2**87 = 154742504910672534362390528 +2**88 = 309485009821345068724781056 +2**89 = 618970019642690137449562112 +2**90 = 1237940039285380274899124224 +2**91 = 2475880078570760549798248448 +2**92 = 4951760157141521099596496896 +2**93 = 9903520314283042199192993792 +2**94 = 19807040628566084398385987584 +2**95 = 39614081257132168796771975168 +2**96 = 79228162514264337593543950336 +2**97 = 158456325028528675187087900672 +2**98 = 316912650057057350374175801344 +2**99 = 633825300114114700748351602688 +2**100 = 1267650600228229401496703205376 + +EOF + +M4PATH=$srcdir:$srcdir/../tests $M4 -d in >out 2>err +sed -e "s, ../../src/m4:, m4:," err >sederr && mv sederr err +$CMP -s out ok diff --git a/tests/other-tests/import-environment.m4 b/tests/other-tests/import-environment.m4 new file mode 100644 index 00000000..f537df66 --- /dev/null +++ b/tests/other-tests/import-environment.m4 @@ -0,0 +1,4 @@ +`TEST'=TEST +`LANGUAGE'=LANGUAGE +`ZAPPED'=ZAPPED +`OVERRIDE'=OVERRIDE diff --git a/tests/other-tests/import-environment.test b/tests/other-tests/import-environment.test new file mode 100755 index 00000000..195434b5 --- /dev/null +++ b/tests/other-tests/import-environment.test @@ -0,0 +1,28 @@ +#!/bin/sh + +# import-environment.test is part of the GNU m4 testsuite + +. ${srcdir}/defs + +TEST='This is an environment variable' +export TEST + +ZAPPED='This is an environment variable which we will delete' +export ZAPPED + +OVERRIDE='This is an environment variable which we will change' +export OVERRIDE + +cat ${srcdir}/other-tests/import-environment.m4 >in + +cat <<\EOF >ok +TEST=This is an environment variable +LANGUAGE=C +ZAPPED=ZAPPED +OVERRIDE=It is changed. +EOF + +M4PATH=$srcdir:$srcdir/other-tests \ +$M4 --import-environment -UZAPPED -DOVERRIDE='It is changed.' -d in >out 2>err +sed -e "s, ../../src/m4:, m4:," err >sederr && mv sederr err +$CMP -s out ok diff --git a/tests/other-tests/iso8859.m4 b/tests/other-tests/iso8859.m4 Binary files differnew file mode 100644 index 00000000..4ac1d196 --- /dev/null +++ b/tests/other-tests/iso8859.m4 diff --git a/tests/other-tests/iso8859.test b/tests/other-tests/iso8859.test new file mode 100755 index 00000000..f77dbb27 --- /dev/null +++ b/tests/other-tests/iso8859.test @@ -0,0 +1,31 @@ +#!/bin/sh + +# iso8859.test is part of the GNU m4 testsuite + +. ${srcdir}/defs + +cat ${srcdir}/other-tests/iso8859.m4 > in + +cat <<\EOF >ok +# Texting quotes +DEFINE +CHANGEQUOTE(«,») +0 TEST # TEST +1 test # test +2 «test» # «test» +3 ««test»» # ««test»» +CHANGEQUOTE(«««,»»») +0 TEST # TEST +1 «TEST» # «TEST» +2 ««TEST»» # ««TEST»» +3 test # test +# Test use of all iso8859 characters except NUL ` ' +Length of string is: 253 +Comparing strings: MATCH +# NUL does not pass through +This will be seen. +EOF + +M4PATH=$srcdir:$srcdir/other-tests $M4 -d in >out 2>err +sed -e "s, ../../src/m4:, m4:," err >sederr && mv sederr err +$CMP -s out ok diff --git a/tests/other-tests/stackovf.test b/tests/other-tests/stackovf.test new file mode 100755 index 00000000..699c5bef --- /dev/null +++ b/tests/other-tests/stackovf.test @@ -0,0 +1,86 @@ +#!/bin/sh + +exit 77 + +# Script to verify that stack overflow is diagnosed properly when +# there is infinite macro call nesting. +# (causes coredump in m4-1.0.3) + +# On some systems the ulimit command is available in ksh or bash but not sh +(exec 2>/dev/null; ulimit -HSs 300) || { + for altshell in bash bsh ksh ; do + if (exec >/dev/null 2>&1; $altshell -c 'ulimit -HSs 300') && + test -z "$1" + then + echo "Using $altshell because it supports ulimit" + exec $altshell $0 running-with-$altshell + exit 9 + fi + done +} + +PATH=.:..:$PATH; export PATH; +: ${M4=../../src/m4} +type $M4 + +tmpfile=/tmp/t.$$ +trap 'rm -f $tmpfile; exit 1' 1 2 3 15 + +rm -f core +perl -e ' +# Generate nested define sequence +$max=1000000; +for ($i=0; $i<$max; $i++) { + print "define(X$i,\n"; +} +for ($i=$max-1; $i>=0; $i--) { + print "body with substance no. $i)dnl\n" +} +' | \ +( +# Limit the stack size if the shell we are running permits it +if (exec 2>/dev/null; ulimit -HSs 50) +then + (exec >/dev/null 2>&1; ulimit -v) && ulimitdashv=ok + ulimit -HSs 50 + #ulimit -HSd 8000 + #test -n "$ulimitdashv" && ulimit -HSv 8000 + echo "Stack limit is `ulimit -s`K"; + echo "Heap limit is `ulimit -d`K"; + test -n "$ulimitdashv" && + echo "VMem limit is `ulimit -v`K"; +else + echo "Can't reset stack limit - this may take a while..." +fi +strace -o /tmp/aaa $M4 -L999999999 > $tmpfile 2>&1 +) +result=$? +{ echo "Output from $M4:"; cat $tmpfile; } + +exitcode=1 +if test $result -eq 0 ; then + echo "TEST DID NOT WORK - m4 did not abort. Output:" +else + # See if stack overflow was diagnosed + case "`cat $tmpfile`" in + *overflow*) + echo "Test succeeded."; + exitcode=0 + ;; + *ut*of*emory*|*emory*xhausted) + echo "*** Test is INCONCLUSIVE (ran out of heap before stack overflow)"; + ;; + *) echo "*** Test FAILED. $M4 aborted unexpectedly. Output:"; + ;; + esac +fi + +if test -f core ; then + ls -l core + exitcode=1 +fi + +#(test $exitcode -ne 0) && + { echo "Output from $M4:"; cat $tmpfile; } + +exit $exitcode diff --git a/tests/other-tests/sync-lines.m4 b/tests/other-tests/sync-lines.m4 new file mode 100644 index 00000000..7cad389d --- /dev/null +++ b/tests/other-tests/sync-lines.m4 @@ -0,0 +1,12 @@ +syncoutput(on)dnl +# Several input lines, expanding to one +define(`foo', ``foo' line one. +`foo' line two. +`foo' line three.') xyz +foo +# Several input lines, expanding to none +define(`foo', ``foo' line one. +`foo' line two. +`foo' line three.')dnl +# one input line, expanding to several output lines +foo foo diff --git a/tests/other-tests/sync-lines.test b/tests/other-tests/sync-lines.test new file mode 100755 index 00000000..c151f669 --- /dev/null +++ b/tests/other-tests/sync-lines.test @@ -0,0 +1,35 @@ +#!/bin/sh + +# sync-lines.test is part of the GNU m4 testsuite + +. ${srcdir}/defs + +cat ${srcdir}/other-tests/sync-lines.m4 >in + +cat <<\EOF >ok +#line 2 "in" +# Several input lines, expanding to one +#line 5 + xyz +foo line one. +#line 6 +foo line two. +#line 6 +foo line three. +# Several input lines, expanding to none +#line 11 +# one input line, expanding to several output lines +foo line one. +#line 12 +foo line two. +#line 12 +foo line three. foo line one. +#line 12 +foo line two. +#line 12 +foo line three. +EOF + +M4PATH=$srcdir:$srcdir/other-tests $M4 -d in >out 2>err +sed -e "s, ../../src/m4:, m4:," err >sederr && mv sederr err +$CMP -s out ok |