diff options
Diffstat (limited to 'agen5/test')
44 files changed, 5346 insertions, 0 deletions
diff --git a/agen5/test/Makefile.am b/agen5/test/Makefile.am new file mode 100644 index 0000000..0915a4b --- /dev/null +++ b/agen5/test/Makefile.am @@ -0,0 +1,71 @@ +## -*- Mode: Makefile -*- +## +## Makefile.am -- process this file with automake to produce Makefile.in +## +## Time-stamp: "2012-04-07 09:22:01 bkorb" +## Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. + +SHELL_TESTS = define.test directives.test error.test expr.test extract.test \ + include.test opts.test output.test snarf.test suffix.test shell.test + +NOSHELL_TESTS = \ + alist.test case.test columns.test debug.test defref.test \ + dynref.test endmac.test for.test forfrom.test forin.test \ + format.test get.test gperf.test heredef.test html.test \ + in.test leave.test license.test line.test loop.test \ + make.test match.test pseudo.test reorder.test stack.test \ + stress.test string.test strtable.test strxform.test time.test + +UNREADY_TESTS = daemon.test +TESTS = @AGEN5_TESTS@ +EXTRA_DIST = $(TESTS) daemon.test +FUNCLIST = funcCase.c funcDef.c funcEval.c funcFor.c funcIf.c functions.c +EXPRLIST = expFormat.c expGuile.c expOutput.c expPrint.c expState.c \ + expString.c expGperf.c expExtract.c $(FUNCLIST) + +TESTS_ENVIRONMENT = TERM='' \ + CFLAGS='$(CFLAGS)' \ + COMPILE='$(COMPILE)' \ + EXPRLIST="$(EXPRLIST)" \ + LDFLAGS='$(LDFLAGS)' \ + SHELL="$(POSIX_SHELL)" \ + srcdir="$(srcdir)" \ + top_builddir="$(top_builddir)" \ + top_srcdir="$(top_srcdir)" + +distclean-local: + -rm -rf testdir FAILURES + +$(TESTS) : defs + +defs : ${top_builddir}/autoopts/test/defs + @set -x ; \ + $(SED) -e '/^ *srcdir=/s@".*"@"$(srcdir)"@' \ + -e '/^ *top_srcdir=/s@".*"@"$(top_srcdir)"@' \ + ${top_builddir}/autoopts/test/defs > $@ ; \ + cd $(srcdir) ; chmod +x *.test || : + +${top_builddir}/autoopts/test/defs : + cd ${top_builddir}/autoopts/test ; $(MAKE) defs + +verbose : defs + rm -rf FAILURES testdir ; \ + VERBOSE=true $(MAKE) check TESTS="$(TESTS)" + +# Makefile.am ends here diff --git a/agen5/test/Makefile.in b/agen5/test/Makefile.in new file mode 100644 index 0000000..61073be --- /dev/null +++ b/agen5/test/Makefile.in @@ -0,0 +1,581 @@ +# Makefile.in generated by automake 1.12.2 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2012 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = agen5/test +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/config/ag_macros.m4 \ + $(top_srcdir)/config/extensions.m4 \ + $(top_srcdir)/config/libopts.m4 \ + $(top_srcdir)/config/libtool.m4 \ + $(top_srcdir)/config/ltoptions.m4 \ + $(top_srcdir)/config/ltsugar.m4 \ + $(top_srcdir)/config/ltversion.m4 \ + $(top_srcdir)/config/lt~obsolete.m4 \ + $(top_srcdir)/config/onceonly.m4 \ + $(top_srcdir)/config/snprintfv.m4 \ + $(top_srcdir)/config/unlocked-io.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +am__tty_colors_dummy = \ + mgn= red= grn= lgn= blu= brg= std=; \ + am__color_tests=no +am__tty_colors = $(am__tty_colors_dummy) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AGEN5_TESTS = @AGEN5_TESTS@ +AG_GUILE = @AG_GUILE@ +AG_LDFLAGS = @AG_LDFLAGS@ +AG_MAJOR_VERSION = @AG_MAJOR_VERSION@ +AG_MINOR_VERSION = @AG_MINOR_VERSION@ +AG_TIMEOUT = @AG_TIMEOUT@ +AG_VERSION = @AG_VERSION@ +AG_XML2 = @AG_XML2@ +AGexe = @AGexe@ +AGnam = @AGnam@ +AMTAR = @AMTAR@ +AO_AGE = @AO_AGE@ +AO_CURRENT = @AO_CURRENT@ +AO_REVISION = @AO_REVISION@ +AO_TEMPLATE_VERSION = @AO_TEMPLATE_VERSION@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CLexe = @CLexe@ +CLnam = @CLnam@ +CONFIG_SHELL = @CONFIG_SHELL@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEBUG_ENABLED = @DEBUG_ENABLED@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +DYNAMIC_AG = @DYNAMIC_AG@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_STATIC = @ENABLE_STATIC@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GDexe = @GDexe@ +GDnam = @GDnam@ +GO_AGE = @GO_AGE@ +GO_CURRENT = @GO_CURRENT@ +GO_REVISION = @GO_REVISION@ +GREP = @GREP@ +GUILE_VERSION = @GUILE_VERSION@ +INCLIST = @INCLIST@ +INCSNPRINTFV = @INCSNPRINTFV@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBGUILE_CFLAGS = @LIBGUILE_CFLAGS@ +LIBGUILE_LIBS = @LIBGUILE_LIBS@ +LIBGUILE_PATH = @LIBGUILE_PATH@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBSNPRINTFV = @LIBSNPRINTFV@ +LIBTOOL = @LIBTOOL@ +LIBXML2_CFLAGS = @LIBXML2_CFLAGS@ +LIBXML2_LIBS = @LIBXML2_LIBS@ +LIBXML2_PATH = @LIBXML2_PATH@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +M4_SRC = @M4_SRC@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPTS_TESTDIR = @OPTS_TESTDIR@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSIX_SHELL = @POSIX_SHELL@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TEXI2HTML = @TEXI2HTML@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_aux_dir = @ac_aux_dir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +SHELL_TESTS = define.test directives.test error.test expr.test extract.test \ + include.test opts.test output.test snarf.test suffix.test shell.test + +NOSHELL_TESTS = \ + alist.test case.test columns.test debug.test defref.test \ + dynref.test endmac.test for.test forfrom.test forin.test \ + format.test get.test gperf.test heredef.test html.test \ + in.test leave.test license.test line.test loop.test \ + make.test match.test pseudo.test reorder.test stack.test \ + stress.test string.test strtable.test strxform.test time.test + +UNREADY_TESTS = daemon.test +TESTS = @AGEN5_TESTS@ +EXTRA_DIST = $(TESTS) daemon.test +FUNCLIST = funcCase.c funcDef.c funcEval.c funcFor.c funcIf.c functions.c +EXPRLIST = expFormat.c expGuile.c expOutput.c expPrint.c expState.c \ + expString.c expGperf.c expExtract.c $(FUNCLIST) + +TESTS_ENVIRONMENT = TERM='' \ + CFLAGS='$(CFLAGS)' \ + COMPILE='$(COMPILE)' \ + EXPRLIST="$(EXPRLIST)" \ + LDFLAGS='$(LDFLAGS)' \ + SHELL="$(POSIX_SHELL)" \ + srcdir="$(srcdir)" \ + top_builddir="$(top_builddir)" \ + top_srcdir="$(top_srcdir)" + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu agen5/test/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu agen5/test/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + +cscope cscopelist: + + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + $(am__tty_colors); \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + col=$$red; res=XPASS; \ + ;; \ + *) \ + col=$$grn; res=PASS; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xfail=`expr $$xfail + 1`; \ + col=$$lgn; res=XFAIL; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + col=$$red; res=FAIL; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + col=$$blu; res=SKIP; \ + fi; \ + echo "$${col}$$res$${std}: $$tst"; \ + done; \ + if test "$$all" -eq 1; then \ + tests="test"; \ + All=""; \ + else \ + tests="tests"; \ + All="All "; \ + fi; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="$$All$$all $$tests passed"; \ + else \ + if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ + banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all $$tests failed"; \ + else \ + if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ + banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + if test "$$skip" -eq 1; then \ + skipped="($$skip test was not run)"; \ + else \ + skipped="($$skip tests were not run)"; \ + fi; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + if test "$$failed" -eq 0; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + fi; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-local + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: all all-am check check-TESTS check-am clean clean-generic \ + clean-libtool distclean distclean-generic distclean-libtool \ + distclean-local distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + uninstall uninstall-am + + +distclean-local: + -rm -rf testdir FAILURES + +$(TESTS) : defs + +defs : ${top_builddir}/autoopts/test/defs + @set -x ; \ + $(SED) -e '/^ *srcdir=/s@".*"@"$(srcdir)"@' \ + -e '/^ *top_srcdir=/s@".*"@"$(top_srcdir)"@' \ + ${top_builddir}/autoopts/test/defs > $@ ; \ + cd $(srcdir) ; chmod +x *.test || : + +${top_builddir}/autoopts/test/defs : + cd ${top_builddir}/autoopts/test ; $(MAKE) defs + +verbose : defs + rm -rf FAILURES testdir ; \ + VERBOSE=true $(MAKE) check TESTS="$(TESTS)" + +# Makefile.am ends here + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/agen5/test/alist.test b/agen5/test/alist.test new file mode 100755 index 0000000..0f913fa --- /dev/null +++ b/agen5/test/alist.test @@ -0,0 +1,79 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# alist.test --- test evalstack functionality +# +# Time-stamp: "2010-06-26 16:06:53 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating $testname.tpl +cat > $testname.tpl <<'_EOF_' +[= AutoGen5 Template test =] +[= + +FOR value "\n" + +=] [= (for-index) =] name is [=name=][= +ENDFOR =] +_EOF_ + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo creating $testname.def +cat > $testname.def <<'_EOF_' +autogen definitions alist; + +\'( + (value ((name "first")) ) + (value ((name "second") (name "third")) ) + ) + +value = { name = last; }; +_EOF_ + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # + +echo creating $testname.out +# this is the output we should expect to see +cat > $testname.out <<_EOF_ + 0 name is first + 1 name is second + 2 name is last +_EOF_ + +AGCMD="-L ${srcdir}/.." +run_ag x ${AGCMD} $testname.def || failure ${AGCMD} failed +cmp -s $testname.test $testname.out || failure unexpected output + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of alist.test diff --git a/agen5/test/case.test b/agen5/test/case.test new file mode 100755 index 0000000..5ec29f9 --- /dev/null +++ b/agen5/test/case.test @@ -0,0 +1,136 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# case.test --- test CASE functionality +# +# Time-stamp: "2010-12-13 14:16:57 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +# +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. + +. ./defs + +# # # # # # # TEMPLATE FILE # # # # # # + +echo creating ${testname}.tpl +cat > ${testname}.tpl <<'EOF' +<= AutoGen5 template test => +<= +FOR grp "\n" =><= + CASE (get "nam") =><= + + == first =>first: <=(sprintf "%-6s" (get "val"))=> matches: <= + CASE (get "val") =><= + ~~ ^[a-z]*$ =>~~ ^[a-z]*$ OK<= + ~~ ^[A-Z]*$ =>~~ ^[A-Z]*$ *** BOGUS ***<= + ~~ .* =>~~ .* *** BOGUS ***<= + ESAC => and <= + CASE (get "val") =><= + ~ ^[a-z]*$ =>~ ^[a-z]*$ OK<= + * =>~ .* *** BOGUS ***<= + ESAC =><= + + == second =>second: <=(sprintf "%-6s" (get "val"))=> matches: <= + CASE (get "val") =><= + ~~ ^[a-z]*$ =>~~ ^[a-z]*$ *** BOGUS ***<= + ~~ ^[A-Z]*$ =>~~ ^[A-Z]*$ *** BOGUS ***<= + ~* . =>~* . OK<= + ESAC => and <= + CASE (get "val") =><= + ~ ^[a-z]*$ =>~ ^[a-z]*$ OK<= + * =>~ .* *** BOGUS ***<= + ESAC =><= + + == third =>third: <=(sprintf "%-6s" (get "val"))=> matches: <= + CASE (get "val") =><= + ~~ ^[a-z]*$ =>~~ ^[a-z]*$ *** BOGUS ***<= + ~~ ^[A-Z]*$ =>~~ ^[A-Z]*$ OK<= + ~~ .* =>~~ .* *** BOGUS ***<= + ESAC => and <= + CASE (get "val") =><= + ~ ^[a-z]*$ =>~ ^[a-z]*$ OK<= + * =>~ .* *** BOGUS ***<= + ESAC =><= + + ESAC =><= + +ENDFOR grp=> +empty: <= CASE empty-val =><= + ~* . =>WRONG<= + !E =>BOGUS<= + +E =>valid<= + * =>REAL-BOGUS<= + ESAC => +bogus: <= CASE bogus-val =><= + ~* . =>WRONG<= + +E =>BOGUS<= + !E =>valid<= + * =>REAL-BOGUS<= + ESAC => +EOF + +# # # # # # # SAMPLE OUTPUT FILE # # # # # # + +echo creating ${testname}.out in `pwd` +# this is the output we should expect to see +cat > ${testname}.out <<'EOF' +first: string matches: ~~ ^[a-z]*$ OK and ~ ^[a-z]*$ OK +second: String matches: ~* . OK and ~ ^[a-z]*$ OK +third: STRING matches: ~~ ^[A-Z]*$ OK and ~ ^[a-z]*$ OK +empty: valid +bogus: valid +EOF + +# # # # # # # DEFINITIONS FILE # # # # # # + +cat > ${testname}.def <<EOF +autogen definitions ${testname}; + +grp = { + nam = first; + val = string; +}; + +grp = { + nam = second; + val = String; +}; + +grp = { + nam = third; + val = STRING; +}; +empty-val; +EOF + +# # # # # # # RUN AUTOGEN # # # # # # + +run_ag x ${testname}.def || failure autogen failed + +# # # # # # # TEST RESULTS # # # # # # + +cmp -s ${testname}.test ${testname}.out || failure unexpected output + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of case.test diff --git a/agen5/test/columns.test b/agen5/test/columns.test new file mode 100755 index 0000000..6c02f09 --- /dev/null +++ b/agen5/test/columns.test @@ -0,0 +1,56 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# case.test --- test CASE functionality +# +# Time-stamp: "2010-12-13 14:24:49 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +# +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. + +. ./defs + +# # # # # # # # # # # # # TEST 1 # # # # # # # # # # # # + +${CLexe:-columns} --first '#define TABLE' --spread=1 --line=' \' \ + -I4 -c 3 -f '_Tbl_(%s)'> ${testname}.res <<_EOF_ +one +two +three +four +five +six +_EOF_ + +cat > ${testname}.base <<\_EOF_ +#define TABLE \ + _Tbl_(one) _Tbl_(two) _Tbl_(three) \ + _Tbl_(four) _Tbl_(five) _Tbl_(six) +_EOF_ + +cmp ${testname}.base ${testname}.res || \ + failure "malformed result:${nl}`diff ${testname}.base ${testname}.res`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of columns.test diff --git a/agen5/test/daemon.test b/agen5/test/daemon.test new file mode 100755 index 0000000..33114e7 --- /dev/null +++ b/agen5/test/daemon.test @@ -0,0 +1,127 @@ +#! /bin/ksh +# -*- Mode: Shell-script -*- +# daemon.test --- test functionality of `for' function +# +# Time-stamp: "2011-02-02 12:00:31 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +tdir=$( (mktemp -d $PWD/.daemon-XXXXXX.d) 2>/dev/null) +test -z "${tdir}" && { + tdir=$PWD/.daemon-$$.d + rm -rf ${tdir} + mkdir ${tdir} || exit 1 +} + +ag=`cd .. >/dev/null ; pwd`/autogen + +case $- in +*x* ) setcmd="set -ex" ;; +* ) setcmd='set -e' ;; +esac +cd ${tdir} + +exec 5> daemon-results + +cat > daemon.tpl <<_EOF_ +[= AutoGen5 Template =] +This is from the [= (shell "echo $$") =] server. +_EOF_ + +run_thrice() { + $setcmd + sleep 1 + for f in 1 2 3 + do ( + cat > ${1} <<_EOF_ +AutoGen Definitions daemon.tpl; +hello = yes; +_EOF_ + + sleep 1 + + cat >&5 < ${2} + ) & + done + sleep 1 +} + +do_run() { + $setcmd + $cmd & + pid=$! + + while test ! -S ${1} -a ! -p ${1} + do print -u2 No ${1}. Must delay. + ( ps -p ${pid} > /dev/null 2>&1 ) || { + print -u2 "autogen has gone away" + exit 1 + } + sleep 1 + done + + run_thrice "$@" + ps -fp $pid + + kill -HUP ${pid} || \ + kill -TERM ${pid} || \ + kill -KILL ${pid} +} + +( ${ag} --daemon daemon-io --help > /dev/null 2>&1 ) || exit 0 + +cmd="${ag} --daemon daemon-io -b dmn" +do_run daemon-io-in daemon-io-out + +tmp=$(echo ${tdir} | ${SED} 's,.*/\.,,;s/\.d$//') +pipe=$PWD/${tmp} + +cmd="${ag} --daemon unix:${pipe} -b dmn" +do_run ${tmp} ${tmp} + +sleep 2 +exec 5>&- +cat daemon-results +cd .. +rm -rf ${tdir} + +# No daemon-io-in. Must delay. +# UID PID PPID C STIME TTY TIME CMD +# bkorb 18431 18427 3 18:18 pts/1 00:00:00 /home/bkorb/ag/ag/agen5/.libs/lt +# AutoGen aborting on signal 1 (Hangup) in state OPTIONS +# No daemon-w0QjvL. Must delay. +# ./daemon.test[71]: cannot create daemon-w0QjvL: No such device or address +# ./daemon.test[71]: cannot create daemon-w0QjvL: No such device or address +# ./daemon.test[71]: cannot create daemon-w0QjvL: No such device or address +# UID PID PPID C STIME TTY TIME CMD +# bkorb 18466 18427 3 18:18 pts/1 00:00:00 /home/bkorb/ag/ag/agen5/.libs/lt +# AutoGen aborting on signal 1 (Hangup) in state OPTIONS + +# This is from the 18427 server. + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of daemon.test diff --git a/agen5/test/debug.test b/agen5/test/debug.test new file mode 100755 index 0000000..d83216f --- /dev/null +++ b/agen5/test/debug.test @@ -0,0 +1,175 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# debug.test --- definition reference testing +# +# Time-stamp: "2012-04-07 09:45:03 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +# +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +cat > ${testname}.tpl <<_EOF_ +<= AutoGen5 template test => +The last of each list:<= +FOR list =><= DEBUG slot 64 => + LAST -> <= val[$] => + + list -> <= + FOR val ", " =><= DEBUG bucket 128 => val[<=(for-index)=>]=<=val=><= + ENDFOR =><= +ENDFOR => +_EOF_ + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +# Create the files we need in the test environment +cat > ${testname}.def <<_EOF_ +AutoGen definitions "${testname}." "tpl"; +list = { val = L0.first, L0.last; }; +List[3] = { val = L3.third.all; }; +_EOF_ + +# # # # # # # # # # ANTICIPATED RESULTS # # # # # # # # # + +cat > ${testname}.base1 <<\_EOF_ + +eval from file agInit.c line XXX: +(debug-enable 'backtrace) +Definition Load: +list[0] (block) from debug.def/2 + val[0] (text) from debug.def/2 + val[1] (text) from debug.def/2 +list[3] (block) from debug.def/3 + val[0] (text) from debug.def/3 +marker ``<='' loaded +marker ``=>'' loaded +Starting test template +open_output_file 'debug.test' mode wb+ +Text (15) in debug.tpl at line 2 + The last of each list: +FOR ( F) in debug.tpl at line 3 +FOR list loop in debug.tpl on line 3 begins: +DEBUG ( 5) in debug.tpl at line 3 + slot 64 + -- DEBUG slot 64 -- FOR index 0 +Text (15) in debug.tpl at line 3 + +Unknown (16) in debug.tpl at line 4 +remapped to 'Expr' (16) in debug.tpl at line 4 + based on val[$] +Text (15) in debug.tpl at line 4 + +FOR ( F) in debug.tpl at line 7 + , +FOR val loop in debug.tpl on line 7 begins: +DEBUG ( 5) in debug.tpl at line 7 + bucket 128 + -- DEBUG bucket 128 -- FOR index 0 +Text (15) in debug.tpl at line 7 + val[ +EXPR ( E) in debug.tpl at line 7 + (for-index) +eval from file debug.tpl line 7: +(for-index) +Text (15) in debug.tpl at line 7 + ]= +Unknown (16) in debug.tpl at line 7 +remapped to 'Expr' (16) in debug.tpl at line 7 + based on val +DEBUG ( 5) in debug.tpl at line 7 + bucket 128 + -- DEBUG bucket 128 -- FOR index 1 +Text (15) in debug.tpl at line 7 + val[ +EXPR ( E) in debug.tpl at line 7 + (for-index) +eval from file debug.tpl line 7: +(for-index) +Text (15) in debug.tpl at line 7 + ]= +EXPR ( E) in debug.tpl at line 7 +FOR val repeated 2 times + from debug.tpl line 7 +DEBUG ( 5) in debug.tpl at line 3 + slot 64 + -- DEBUG slot 64 -- FOR index 3 +Text (15) in debug.tpl at line 3 + +EXPR ( E) in debug.tpl at line 4 +Text (15) in debug.tpl at line 4 + +FOR ( F) in debug.tpl at line 7 + , +FOR val loop in debug.tpl on line 7 begins: +DEBUG ( 5) in debug.tpl at line 7 + bucket 128 + -- DEBUG bucket 128 -- FOR index 0 +Text (15) in debug.tpl at line 7 + val[ +EXPR ( E) in debug.tpl at line 7 + (for-index) +eval from file debug.tpl line 7: +(for-index) +Text (15) in debug.tpl at line 7 + ]= +EXPR ( E) in debug.tpl at line 7 +FOR val repeated 1 times + from debug.tpl line 7 +FOR list repeated 2 times + from debug.tpl line 3 +Text (15) in debug.tpl at line 9 + +out_close 'debug.test' +_EOF_ + +traceout=${testname}-aglog-x1-$$.log + +if ${VERBOSE} +then trace_args='' +else trace_args=--trace=everything\ --trace-out=${traceout} +fi + +run_ag x1 ${trace_args} ${testname}.def || failure AutoGen failed +${SED} -e 's@from file .*agInit.*@from file agInit.c line XXX:@' \ + -e '/Called ag_scm_for_index/d' \ + -e '/^AutoGen [0-9]* starts:/d' \ + ${traceout} > ${testname}.trace1 +cmp -s ${testname}.base1 ${testname}.trace1 || \ + failure "`diff -c ${testname}.base1 ${testname}.trace1`" + +${VERBOSE} || { + traceout=${testname}-aglog-x2-$$.log + trace_args=--trace-out=${traceout} + run_ag x2 ${trace_args} ${testname}.def || failure AutoGen failed + test -f ${traceout} -a -s ${traceout} && \ + failure "autogen produced trace output" +} + +cleanup + +## +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of debug.test diff --git a/agen5/test/define.test b/agen5/test/define.test new file mode 100755 index 0000000..68008e4 --- /dev/null +++ b/agen5/test/define.test @@ -0,0 +1,160 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# define.test --- test evalstack functionality +# +# Time-stamp: "2012-04-07 09:40:07 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # TEMPLATE LIBRARY FILE # # # # # # + +echo creating $testname.tlib +cat > $testname.tlib <<'_EOF_' +[+ AutoGen5 Template Library +] +[+ + +# * * * * * * * * * * * * + + VISUAL SEPARATION ++][+ + +DEFINE first_macro ++][+(for-index)+] Argument list: + [+ + FOR arg "\n\t" + +]arg[ [+(for-index)+] ] = [+ arg +][+ + ENDFOR +][+ +ENDDEF +][+ + +# * * * * * * * * * * * * + + VISUAL SEPARATION ++][+ + +DEFINE last_macro + +]This is the last (number [+(for-index)+]) macro.[+ +ENDDEF +] +_EOF_ + + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating $testname.tpl +cat > $testname.tpl <<'_EOF_' +[= AutoGen5 Template test =] +[= + +DEFINE nest =][= + IF (exist? "name") =] +level [=level=] iteration [=(for-index)=] Nested Name: [=name=][= + ENDIF =][= + + FOR .nesting =][= + nest =][= + ENDFOR =][= + +ENDDEF nest =][= + +FOR value + +=][= + IF (or (first-for?) (last-for?)) =][= + INVOKE (string-append (get "value") "_macro") + arg = one arg = "the second arg = the second" + arg = (shell "date +'%A, %D'") arg = 'done.' =][= + ELSE =] + + non first/last value: [=value=] = [= (for-index) =] +[=ENDIF =][= +ENDFOR =] +[=invoke nest =] +Done. +_EOF_ + + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo creating $testname.def +cat > $testname.def <<_EOF_ +autogen definitions $testname; + +value = first; +value[2] = secondary; +value[4] = tertiary; +value[6] = last; + +level = 0; +nesting[1] = { + level = 1; + name = primary; + nesting[1] = { + level = 2; + name = secondary; + }, { + level = 2; + /* no name defined - default to primary level */ + nesting[1] = { + level = 3; + name = tertiary; + }; + }; +}; +_EOF_ + +# this is the output we should expect to see +cat > $testname.samp <<_EOF_ +0 Argument list: + arg[ 0 ] = one + arg[ 1 ] = the second arg = the second + arg[ 2 ] = `date +'%A, %D'` + arg[ 3 ] = done. + + non first/last value: secondary = 2 + + + non first/last value: tertiary = 4 +This is the last (number 6) macro. + +level 1 iteration 1 Nested Name: primary +level 2 iteration 1 Nested Name: secondary +level 2 iteration 2 Nested Name: primary +level 3 iteration 1 Nested Name: tertiary +Done. +_EOF_ + +run_ag x --lib=$testname.tlib $testname.def || \ + failure "autogen failed" +set -x +cmp -s $testname.samp $testname.test || \ + failure "`diff $testname.samp $testname.test`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of define.test diff --git a/agen5/test/defref.test b/agen5/test/defref.test new file mode 100755 index 0000000..cac27d5 --- /dev/null +++ b/agen5/test/defref.test @@ -0,0 +1,124 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# defref.test --- definition reference testing +# +# Time-stamp: "2011-02-02 12:09:02 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +${SED} 's/^ *[0-9]*://;s/^ //' > ${testname}.tpl <<_EOF_ + 1: <= AutoGen5 template test => + 2: The last of each list:<= + 3: FOR list => + 4: list[<= (for-index) =>] -> <= val[$] =><= + 5: ENDFOR => + 6: + 7: The first of each list:<= + 8: FOR list => + 9: list[<=(for-index)=>] -> <=val[]=><= +10: ENDFOR => +11: +12: The full list:<= +13: FOR list => +14: list[<=(for-index)=>] -> <= +15: FOR val ", " => val[<=(for-index)=>]=<=val=><= +16: ENDFOR =><= +17: ENDFOR => +18: +19: The local global list:<= +20: FOR list => +21: list[<=(for-index)=>] == "<= +22: (join ", " (stack ".param.name")) =>" +21: .. "<= +22: (join ", " (stack "param.name")) =>"<= +23: ENDFOR => +24: +25: The first value is: <= ?% list[].val[] "val = %s (first)" "Undefined??"=> +26: The last value is: <= ?% list[$].val[$] "val = %s (last)" "Undefined??"=> +_EOF_ + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +# Create the files we need in the test environment +cat > ${testname}.def <<_EOF_ +AutoGen definitions "${testname}." "tpl"; +param = { name = "global"; }; +list = { val = L0.first, L0.second, L0.last; + param = { name = "first-1", "first-2"; }; }, + { val[2] = L1.second-and-last; Val[0] = L1.first; + param = { name = "second-1", "second-2"; }; }; +List[3] = { val = L3.third.all; }, + { val[3] = L4.last; VAL[2] = L4.middle; VAL[1] = L4.first; }; +_EOF_ + +# # # # # # # # # # ANTICIPATED RESULT # # # # # # # # # + +cat > ${testname}.out <<_EOF_ +The last of each list: + list[0] -> L0.last + list[1] -> L1.second-and-last + list[3] -> L3.third.all + list[4] -> L4.last + +The first of each list: + list[0] -> L0.first + list[1] -> L1.first + list[3] -> L3.third.all + list[4] -> L4.first + +The full list: + list[0] -> val[0]=L0.first, val[1]=L0.second, val[2]=L0.last + list[1] -> val[0]=L1.first, val[2]=L1.second-and-last + list[3] -> val[0]=L3.third.all + list[4] -> val[1]=L4.first, val[2]=L4.middle, val[3]=L4.last + +The local global list: + list[0] == "first-1, first-2" + .. "first-1, first-2" + list[1] == "second-1, second-2" + .. "second-1, second-2" + list[3] == "" + .. "global" + list[4] == "" + .. "global" + +The first value is: val = L0.first (first) +The last value is: val = L4.last (last) +_EOF_ + +run_ag x ${testname}.def || failure AutoGen failed +cmp -s ${testname}.test ${testname}.out || \ + failure "`diff ${testname}.test ${testname}.out`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of defref.test diff --git a/agen5/test/directives.test b/agen5/test/directives.test new file mode 100755 index 0000000..aab6833 --- /dev/null +++ b/agen5/test/directives.test @@ -0,0 +1,148 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# directives.test --- test definition directives +# +# Time-stamp: "2011-02-02 12:09:10 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +mkdir ${testname}.dir +mkdir ${testname}.dir/subdir +LDIR=`pwd`/${testname}.dir +export LDIR + +echo creating ${testname}.dir/subdir/${testname}.tpl +cat > ${testname}.dir/subdir/${testname}.tpl <<'_EOF_' +[= AutoGen5 Template test =] +Irrelevant [=foo=]. +_EOF_ + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo creating ${testname}.inc +${SED} 's/^ *[0-9]*: //' > ${testname}.inc <<_EOF_ + 1: autogen definitions ${testname}; + 2: + 3: #option templ-dir \$LDIR/subdir + 4: + 5: /* + 6: #define COMMENT + 7: #ifdef COMMENT + 8: # error error in comment + 9: */ + 10: + 11: #ifdef MUMBLE + 12: # define MORE + 13: #else + 14: # define FUMBLE + 15: #endif +_EOF_ + +echo creating ${testname}.def +${SED} 's/^ *[0-9]*: //' > ${testname}.def <<_EOF_ + 1: autogen definitions ${testname}; + 2: + 3: #include ${testname}.inc + 4: + 5: #ifdef FUMBLE + 6: # error we fumbled mumble + 7: #endif + 8: + 9: #ifndef MORE + 10: # error we fumbled more + 11: #endif + 12: + 13: #if (FOO == 1) + 14: # error we got iffed + 15: #elif (FOO == 0) + 16: # error we got FOO zeroed + 17: #else + 18: # error we got lost + 19: #endif + 20: + 21: #shell + 22: + 23: echo "#line 1 shelltext" + 24: echo "foo = bar;" + 25: + 26: #endshell + 27: + 28: #define FUMBLE + 29: #undef MORE + 30: + 31: #ifndef FUMBLE + 32: # error we goofed fumble + 33: #endif + 34: + 35: #ifdef MORE + 36: # error we mumbled more + 37: #endif +_EOF_ + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # + +echo creating ${testname}.base +# this is the output we should expect to see +cat > ${testname}.base <<_EOF_ +Irrelevant bar. +_EOF_ + +agopts="-DMUMBLE -DFOO=1" +MORE=DOITWRONG + +run_ag x1 ${agopts} ${testname}.def +test $? -eq 0 || failure ${agopts}-1 failed +cmp -s ${testname}.base ${testname}.test || \ + failure "`diff ${testname}.base ${testname}.test`" + +echo '#assert `echo true`' >> ${testname}.inc +run_ag x2 ${agopts} ${testname}.def +test $? -eq 0 || failure ${agopts}-2 failed + +echo '#assert `echo false`' >> ${testname}.inc +run_ag x3 ${agopts} ${testname}.def +test $? -ne 0 || failure ${agopts}-3 failed + +${FGREP} -v '#assert' ${testname}.inc > ${testname}2.inc +mv -f ${testname}2.inc ${testname}.inc + +echo '#assert (version-compare > autogen-version "5.8.4")' >> ${testname}.inc +run_ag x4 ${agopts} ${testname}.def +test $? -eq 0 || failure ${agopts}-4 failed + +echo '#assert (version-compare < autogen-version "5.8.4.63")' >> ${testname}.inc +run_ag x5 ${agopts} ${testname}.def +test $? -ne 0 || failure ${agopts}-5 failed + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of directives.test diff --git a/agen5/test/dynref.test b/agen5/test/dynref.test new file mode 100755 index 0000000..1f62248 --- /dev/null +++ b/agen5/test/dynref.test @@ -0,0 +1,82 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# dynref.test --- test dynamic scoping of definition values +# +# Time-stamp: "2010-06-26 16:06:18 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating $testname.tpl +cat > $testname.tpl <<'_EOF_' +[= AutoGen5 Template test =] +[= + +DEFINE nest =][= + + FOR nesting =][= + IF (first-for?) +=]The un-nested value is: [=val_u=].[= + ENDIF =][= + ENDFOR =][= + +ENDDEF =][= + +nest Val-u = "hidden value" + +=] +_EOF_ + + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo creating $testname.def +cat > $testname.def <<_EOF_ +autogen definitions $testname; + +nesting = { name = one; }; +nesting = { name = two; }; +nesting = { name = three; }; +nesting = { name = four; }; +_EOF_ + +# this is the output we should expect to see +cat > $testname.out <<_EOF_ +The un-nested value is: hidden value. +_EOF_ + +run_ag x $testname.def || failure autogen failed +cmp -s $testname.test $testname.out || \ + failure "`diff $testname.test $testname.out`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of dynref.test diff --git a/agen5/test/endmac.test b/agen5/test/endmac.test new file mode 100755 index 0000000..c5ac062 --- /dev/null +++ b/agen5/test/endmac.test @@ -0,0 +1,73 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# endmac.test --- test variations on the end macro marker +# +# Time-stamp: "2011-02-24 10:53:51 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs +set -x +cat > ${testname}1.tpl <<EOF +<=AutoGen5 template test=>><<= +`echo ENDMAC 1` +=>> <=`pwd`=>> +<=# comment this test fails because the '=' is bound to 'test' >> +This is a test +EOF + +run_ag x1 -T${testname}1 --no-def 2> /dev/null && \ + failure $testname failure test was successful. Oops. +echo $testname failure test failed correctly + +cat > ${testname}2.tpl <<EOF +<=AutoGen5 template test =>> +ENDMAC 2 <=`echo print this message` =>> +<=# comment This test succeeds because the '=' is not part of 'test' =>> +This is a test +EOF + +run_ag x2 -T${testname}2 --no-def || \ + failure $testname success test was a failure +echo first successful $testname test succeeded + +cat > ${testname}3.tpl <<EOF +<+AutoGen5 template test+>> +ENDMAC 3 <+(define foo "print this message") foo +>> +<+# comment The '+' is not joined because it is neither '=' nor + a legal file name character +>> +This is a test +EOF + +run_ag x3 -T${testname}3 --no-def || \ + failure second $testname success test was a failure +echo second successful $testname test succeeded + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of endmac.test diff --git a/agen5/test/error.test b/agen5/test/error.test new file mode 100755 index 0000000..de9a896 --- /dev/null +++ b/agen5/test/error.test @@ -0,0 +1,250 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# +# error.test --- test error functionality +# +# Author: Bruce Korb <bkorb@gnu.org> +# Time-stamp: "2011-12-30 16:40:11 bkorb" +# +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. + +. ./defs + +verb_ok=true + +ag_err() +{ + ( + set +x + if ${VERBOSE} && ${verb_ok} + then + AUTOGEN_TRACE=everything + AUTOGEN_TRACE_OUT=${testname}-task${seq}-aglog.txt + VERBOSE=false + export AUTOGEN_TRACE AUTOGEN_TRACE_OUT + else + unset AUTOGEN_TRACE AUTOGEN_TRACE_OUT + fi + + seq=${1} ; shift + exec 2> ${testname}.err${seq} + touch ${testname}-task${seq}-running + run_ag x${seq} "$@" + res=$? + rm -f ${testname}-task${seq}-running + exit $res + ) && touch ${testname}-task${seq}-OK +} + +# # # # # # # # # # # # # TEST 1 # # # # # # # # # # # # + +echo creating ${testname}.tpl +${SED} 's/[ 0-9]*=//' > ${testname}.tpl <<'_EOF_' + 1 =<= AutoGen5 template fnord null => + 2 =THIS TEXT SHOULD BE DELETED!! + 3 =<= + 4 =CASE (suffix) =><= + 5 = + 6 = == fnord =><= + 7 = + 8 = ;; (out-push-new) + 9 = ;; (error (string-append "0 this is really okay" (out-pop #t)) + 10 = (error "0 this is really okay") + 11 = + 12 = =>this is never seen<= + 13 = + 14 = * =><= + 15 = + 16 = (error "This is a multi-line + 17 = error to show how to exit + 18 = your template") =><= + 19 = + 20 =ESAC => + 21 =this is never seen +_EOF_ + +echo creating ${testname}.def +cat > ${testname}.def <<'_EOF_' +autogen definitions alist; +#error The definitions file has a `#error' directive +_EOF_ + +echo creating ${testname}.base1 +# this is the output we should expect to see +cat > ${testname}.base1 <<'_EOF_' +#error directive -- in error.def on line 3 + The definitions file has a `#error' directive +_EOF_ + +ag_err 1 ${testname}.def +test -f ${testname}-task1-OK \ + && failure unexpected success for test-1 + +${SED} '/Giving up in/d;/Failing Guile command:/,$d' ${testname}.err1 \ + > ${testname}.err +cmp -s ${testname}.err ${testname}.base1 || \ + failure "expected->actual${nl}`diff -c ${testname}.base1 ${testname}.err`" + +# # # # # # # # # # # # # TEST 2 # # # # # # # # # # # # + +echo creating ${testname}.base2 +# this is the output we should expect to see +cat > ${testname}.base2 <<'_EOF_' +DEFINITIONS Warning in error.tpl line 8 for error2.fnord: + 0 this is really okay +Error in template error.tpl, line 16 + DEFINITIONS ERROR in error.tpl line 16 for /dev/null: + This is a multi-line + error to show how to exit + your template +Failing Guile command: = = = = = + +(error "This is a multi-line + error to show how to exit + your template") + +================================= +_EOF_ + +agopts="--no-def --base=${testname}" + +verb_ok=false +ag_err 2 -T${testname}.tpl ${agopts}2 +test -f ${testname}-task2-OK \ + && failure unexpected success for test-2 +verb_ok=true + +if test ${GUILE_VERSION} -gt 107000 +then + ${EGREP} -v 'Giving up in | is deprecated\.' ${testname}.err2 +else + ${EGREP} -v 'Giving up in ' ${testname}.err2 +fi > ${testname}.res2 + +cmp -s ${testname}.base2 ${testname}.res2 || \ + failure "expected->actual${nl}`diff -c ${testname}.base2 ${testname}.res2`" + +# # # # # # # # # # # # # TEST 3 # # # # # # # # # # # # + +# REMOVED: This test always worked, but the exact results +# vary all over the place. Too hard to test. + +# # # # # # # # # # # # # TEST 4 # # # # # # # # # # # # + +${SED} 's,^#error.*,this is broken;,' ${testname}.def > ${testname}2.def + +echo creating ${testname}.base4 +# this is the output we should expect to see +cat > ${testname}.base4 <<'_EOF_' +FSM Error: in state 5 (have_name), event 3 (var_name) is invalid +invalid transition: in error2.def on line 2 + token in error: var_name: ''is broken; +'' + + [[...<error-text>]] broken; + + +Likely causes: a mismatched quote, a value that needs quoting, + or a missing semi-colon +_EOF_ + +ag_err 4 ${testname}2.def +test -f ${testname}-task4-OK \ + && failure unexpected success for test-4 + +${GREP} -v 'Giving up in' ${testname}.err4 > ${testname}.res4 +cmp -s ${testname}.res4 ${testname}.base4 \ + || failure "expected->actual${nl}`diff -c ${testname}.base4 ${testname}.res4`" + +# # # # # # # # # # # # # TEST 5 # # # # # # # # # # # # + +echo creating ${testname}.tpl5 +cat > ${testname}.tpl5 <<'_EOF_' +<= AutoGen5 template fnord null => +THIS TEXT SHOULD BE DELETED!! +<= ENDIF => +_EOF_ + +ag_err 5 -T ${testname}.tpl5 ${agopts}5 > /dev/null +test -f ${testname}-task5-OK \ + && failure unexpected success for test-5 + +${EGREP} -v 'Giving up in .*functions\.c' ${testname}.err5 > ${testname}.res5 +cat > ${testname}.base5 <<'EOF' +Error in template error.tpl5, line 3 + Unknown macro or invalid context in error.tpl5 line 3: + ENDIF +EOF + +cmp -s ${testname}.base5 ${testname}.res5 || \ + failure "expected->actual${nl}`diff -c ${testname}.base5 ${testname}.res5`" + +# # # # # # # # # # # # # TEST 6 # # # # # # # # # # # # + +echo creating ${testname}.tpl6 +cat > ${testname}.tpl6 <<'_EOF_' +<= AutoGen5 template fnord null => +This is a broken template, "nothing" is not defined. +<= ( +if (exist? "nothing") + (error "it is broken + 'cuz it's okay") + (stumble-over-unbound-variable) +) => +End Of File +_EOF_ + +ag_err 6 -T ${testname}.tpl6 ${agopts}6 > /dev/null +test -f ${testname}-task6-OK \ + && failure unexpected success for test-6 + +cat > ${testname}.base6 <<EOF +Scheme evaluation error. AutoGen ABEND-ing in template + error.tpl6 on line 3 +Failing Guile command: = = = = = + +( +if (exist? "nothing") + (error "it is broken + 'cuz it's okay") + (stumble-over-unbound-variable) +) + +================================= +EOF + +# Guile keeps changing its mind about what it ought to print in the +# face of an unbound variable. So, the heck with it. We've tried to +# print file and line, but it was made just too hard. Strip out all +# the Guile library error messages. :( +# +${SED} -n '/^Scheme evaluation error./,$p' ${testname}.err6 | \ + ${SED} "/^${testname}\.tpl6:7:4:/d" > ${testname}.res6 + +cmp -s ${testname}.base6 ${testname}.res6 || \ + failure "expected->actual${nl}`diff -c ${testname}.base6 ${testname}.res6`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of error.test diff --git a/agen5/test/expr.test b/agen5/test/expr.test new file mode 100755 index 0000000..3e6eeda --- /dev/null +++ b/agen5/test/expr.test @@ -0,0 +1,107 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# expr.test --- [= % name (sprintf "%%-18s" "%s") =] expression +# +# Time-stamp: "2012-04-01 06:07:01 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # TEMPLATE & DEFINITIONS FILES # # # # # # # # # +# +# We construct this by pulling down the sources from the +# AutoGen source directory. We will also copy out the same +# commands as are used there. ${top_srcdir} is a full path. +# +cp ${top_srcdir}/agen5/snarf.tpl ${top_srcdir}/agen5/exp*.c \ + ${top_srcdir}/agen5/func*.c ${top_srcdir}/agen5/agShell.c ${TMPDIR}/. +f=`fgrep '#ifdef DEBUG_ENABLED' ${top_srcdir}/agen5/expr.ini` +test -n "$f" && { + DEBUG_ENABLED=true + export DEBUG_ENABLED +} + +exec 3> ${TMPDIR}/${testname}.sh +cat >&3 <<- _EOF_ + GDexe=${GDexe} + CLexe=${CLexe} + srcdir=`pwd` + export GDexe CLexe srcdir + cd ${TMPDIR} + set -e + _EOF_ + +if ${VERBOSE} +then + cat >&3 <<- _EOF_ + PS4='>${testname}-\${FUNCNAME-mkexp}> ' + set -x + run_ag() + { + tfile=ag-\${1}-$$.log + tag="-MF${testname}-stamp-\${1} --trace=every --trace-out=\${tfile}" + shift + ${AGexe} -L${top_srcdir}/autoopts/tpl \${tag} "\$@" + } + _EOF_ +else + cat >&3 <<- _EOF_ + run_ag() + { + tag="-MF${testname}-stamp-\${1}" + shift + echo ${AGexe} "\$@" + ${AGexe} -L${top_srcdir}/autoopts/tpl \${tag} "\$@" + } + _EOF_ +fi + +${SED} -n '/^make_exprini()/,/^[}]$/p' ${top_srcdir}/agen5/mk-stamps.sh | \ + ${SED} 's/rm -f /echo rm -f/' >&3 +cat >&3 <<- _EOF_ + make_exprini + ${SED} "${sed_omit_license}" expr.ini > \${srcdir}/expr.res + ${SED} "${sed_omit_license}" ${top_srcdir}/agen5/expr.ini \ + > \${srcdir}/expr.base + _EOF_ +exec 3>&- + +# Remove the lines that *will* be different, always... +# +${SHELLX} ${TMPDIR}/${testname}.sh || failure "${testname}.sh failed" + +test -s expr.res || \ + failure "${testname} test produced no output" + +cmp expr.base expr.res || \ + failure "`diff -c expr.base expr.res`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of expr.test diff --git a/agen5/test/extract.test b/agen5/test/extract.test new file mode 100755 index 0000000..1e3e4c0 --- /dev/null +++ b/agen5/test/extract.test @@ -0,0 +1,80 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# extract.test --- test extract functionality +# +# Time-stamp: "2010-06-26 16:05:58 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +mkdir ${testname}.dir +echo creating ${testname}.dir/${testname}.tpl +cat > ${testname}.dir/${testname}.tpl <<_EOF_ +[= AutoGen5 template out =] +This is the start of generated text[=\` echo ' working' \` =] +We will be extracting from [=(find-file "${testname}" "sample")=]: +[=(extract (find-file "${testname}" "sample") + "/* =-= %s =-= MARKER =-= %s =-= */")=] +[=(extract (find-file "${testname}" "sample") + "/* =-= %s =-= SECOND =-= %s =-= */" + "DNC Test" "DEFAULT-ed text.")=] +And this is the end.[= \` echo ' done' \` =] +_EOF_ + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # + +echo creating ${testname}.dir/${testname}.sample +# this is the output we should expect to see +cat > ${testname}.dir/${testname}.sample <<_EOF_ +This is the start of generated text working +We will be extracting from ${testname}.dir/${testname}.sample: +_EOF_ +cat >> ${testname}.dir/${testname}.sample <<\_EOF_ +/* =-= START =-= MARKER =-= DO NOT CHANGE THIS COMMENT =-= */ +This is inserted text +/* =-= END =-= MARKER =-= DO NOT CHANGE THIS COMMENT =-= */ +/* =-= START =-= SECOND =-= DNC Test =-= */ +This is an insertion +test. +/* =-= END =-= SECOND =-= DNC Test =-= */ +And this is the end. done +_EOF_ + +AGCMD="--no-def -L${testname}.dir -b${testname} -T${testname}.tpl" + +run_ag x ${AGCMD} || failure autogen ${AGCMD} failed + +cmp -s ${testname}.out ${testname}.dir/${testname}.sample || \ + failure "`diff -c ${testname}.out ${testname}.dir/${testname}.sample`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of extract.test diff --git a/agen5/test/for.test b/agen5/test/for.test new file mode 100755 index 0000000..45a2f55 --- /dev/null +++ b/agen5/test/for.test @@ -0,0 +1,112 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# for.test --- test functionality of `for' function +# +# Time-stamp: "2011-02-02 12:09:29 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating $testname.tpl +${SED} 's/^ *[0-9]*: //' > $testname.tpl <<_EOF_ + 1: <= AutoGen5 template test => + 2: <= + 3: FOR list ",\n" =><= + 4: IF (first-for?) + 5: =>FIRST: <= + 6: ELIF (last-for?) + 7: =>LAST: <= + 8: ELSE + 9: =>MIDDLE: <= +10: ENDIF =><=elt[0]=><= +11: ENDFOR => +12: <= +13: FOR list-2 \=> +14: <=FOR list ", "\=> +15: <=bumble \=> +16: <=ENDFOR \=> +17: <= +18: ENDFOR => +19: <= +20: FOR list ",\n" =><= +21: FOR list-2 \=> +22: <=(for-index "list")=>: <= +23: +24: IF (first-for? "list") +25: =>FIRST <= +26: ELIF (last-for? "list") +27: =>LAST <= +28: ELSE +29: =>MIDDLE <= +30: ENDIF =><= +31: +32: (tpl-file-line " on line %2\$d") =><= +33: +34: ENDFOR =><= +35: ENDFOR => +_EOF_ + + +# Create the files we need in the test environment +cat > $testname.def <<_EOF_ +AutoGen definitions $testname; +list = { elt = one; }, +{ elt = two.one, two.two, two.three; }; +list = { elt = three; }, {elt = four;}; + +list-2 = { bumble = mumble; }; +_EOF_ + +# this is the output we should expect to see +cat > $testname.sample <<_EOF_ +FIRST: one, +MIDDLE: two.one, +MIDDLE: three, +LAST: four +mumble, mumble, mumble, mumble +0: FIRST on line 32, +1: MIDDLE on line 32, +2: MIDDLE on line 32, +3: LAST on line 32 +_EOF_ + +run_ag x $testname.def || failure AutoGen failed +cmp -s $testname.test $testname.sample || \ + failure "`diff -c $testname.test $testname.sample`" + +echo '<= FOR =><= ENDFOR =>' >> $testname.tpl +f=`(run_ag x $testname.def 2>&1) | ${EGREP} 'requires iterator'` +test -z "$f" && \ + failure "failed to detect missing FOR iterator" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of for.test diff --git a/agen5/test/forfrom.test b/agen5/test/forfrom.test new file mode 100755 index 0000000..ea4a3a2 --- /dev/null +++ b/agen5/test/forfrom.test @@ -0,0 +1,79 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# +# forfrom.test --- test forfrom functionality +# +# Time-stamp: "2010-07-17 09:52:04 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +# +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating $testname.tpl +cat > $testname.tpl <<_EOF_ +<= AutoGen5 template test => +<= + +FOR list (for-by 3) (for-sep ",\n") + + =>list[<=(for-index)=>] = <= + ?% elt 'this is "%s"' EMPTY=><= + +ENDFOR + +=> +_EOF_ + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo creating $testname.def +cat > $testname.def <<EOF +AutoGen definitions $testname; +list[1] = { elt = one; }; +list[3] = { elt = three; }; +list[5] = { elt = five; }; +list[7] = { elt = seven; }; +list[9] = { elt = nine; }; +EOF + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # + +echo creating $testname.out +# this is the output we should expect to see +cat > $testname.out <<'_EOF_' +list[1] = this is "one", +list[4] = EMPTY, +list[7] = this is "seven" +_EOF_ + +run_ag x $testname.def || failure autogen failed +cmp -s $testname.test $testname.out || failure unexpected output + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of forfrom.test diff --git a/agen5/test/forin.test b/agen5/test/forin.test new file mode 100755 index 0000000..313d887 --- /dev/null +++ b/agen5/test/forin.test @@ -0,0 +1,86 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# +# forin.test --- test forin functionality +# +# Time-stamp: "2010-07-17 09:51:55 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +# +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # +set -x +echo creating ${testname}.tpl in `pwd` +cat > ${testname}.tpl <<_EOF_ +[+ AutoGen5 template out +] +[+ +FOR t IN build host target +][+ + FOR v IN alias cpu vendor os +] +[+t+]_[+v+]=@[+t+]_[+v+]@[+ + ENDFOR +] +[+t+]_canonical=@[+t+]_cpu@-@[+t+]_vendor@-@[+t+]_os@ +[+ + +ENDFOR + ++] +_EOF_ + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # + +echo creating ${testname}.ok +# this is the output we should expect to see +cat > ${testname}.ok <<'_EOF_' + +build_alias=@build_alias@ +build_cpu=@build_cpu@ +build_vendor=@build_vendor@ +build_os=@build_os@ +build_canonical=@build_cpu@-@build_vendor@-@build_os@ + +host_alias=@host_alias@ +host_cpu=@host_cpu@ +host_vendor=@host_vendor@ +host_os=@host_os@ +host_canonical=@host_cpu@-@host_vendor@-@host_os@ + +target_alias=@target_alias@ +target_cpu=@target_cpu@ +target_vendor=@target_vendor@ +target_os=@target_os@ +target_canonical=@target_cpu@-@target_vendor@-@target_os@ + +_EOF_ + +run_ag x --no-def -T${testname}.tpl -b ${testname} || \ + failure autogen failed +cmp -s ${testname}.ok ${testname}.out || \ + failure "`diff ${testname}.ok ${testname}.out`" +exit 0 +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of forin.test diff --git a/agen5/test/format.test b/agen5/test/format.test new file mode 100755 index 0000000..87d88c9 --- /dev/null +++ b/agen5/test/format.test @@ -0,0 +1,96 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# format.test --- Count format string arguments. +# +# Time-stamp: "2010-06-26 16:05:41 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating ${testname}.tpl +cat > ${testname}.tpl <<_EOF_ +[++ AutoGen5 template test ++] +[++ (dne "-d" "# ") ++] +[++ + +FOR fmt "\n" + +++]Fmt [++(+ 1 (for-index))++] has [++(format-arg-count (get "fmt")) +++] args: [++(c-string (get "fmt"))++][++ + +ENDFOR + +++] +[++(hide-email "Bruce Korb" "bkorb@gnu.org")++] +_EOF_ + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo creating ${testname}.def +cat > ${testname}.def <<_EOF_ +AutoGen definitions ${testname}; +fmt = "none"; +fmt = "one %s val"; +fmt = "two %s (%d%%) vals"; +_EOF_ + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # +set -x +echo creating ${testname}.base +# this is the output we should expect to see +cat > ${testname}.base <<'_EOF_' +# DO NOT EDIT THIS FILE (format.test) +# +# It has been AutoGen-ed +# From the definitions format.def +# and the template file format +Fmt 1 has 0 args: "none" +Fmt 2 has 1 args: "one %s val" +Fmt 3 has 2 args: "two %s (%d%%) vals" +<script language="JavaScript" type="text/javascript"> +<!-- +var one = 'ma'; +var two = 'ilt'; +document.write('<a href="' + one + two ); +document.write('o:bkorb@gnu.org'); +document.write('" >Bruce Korb</a>'); +//--> +</script> +_EOF_ + +run_ag x ${testname}.def || failure autogen failed +cmp -s ${testname}.base ${testname}.test || \ + failure "`diff ${testname}.base ${testname}.test`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of format.test diff --git a/agen5/test/get.test b/agen5/test/get.test new file mode 100755 index 0000000..7800a9a --- /dev/null +++ b/agen5/test/get.test @@ -0,0 +1,95 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# get.test --- test get functionality +# +# Time-stamp: "2011-03-06 15:26:30 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating $testname.tpl +cat > $testname.tpl <<_EOF_ +[= AutoGen5 template test =] +[= + +IF (not (exist? "foo.bar.baz")) =][= + (error "foo.bar.baz does, too, exist!") =][= + +ELIF (not (= "mumble" (get "foo.bar.baz"))) =][= + (error (sprintf "We got the wrong baz. We got: %s" + (get "foo.bar.baz"))) =][= +ELSE + =]A OK[= +ENDIF =][= + +- bogus "\nA OK2" =][= +- foo "\nBOGUS" =] +[= (get "fuz-zy") =] +[= (get "fuz_zy") =] +[= (get "fuz^zy") =] +[= (get-c-name "fuz-zy") =] +[= (get-up-name "fuz-zy") =] +[= (get-down-name "fuz-zy") =] +_EOF_ + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo creating $testname.def +cat > $testname.def <<_EOF_ +AutoGen definitions $testname; + +foo = { bar = { nada = nothing; }; }; +foo = { bar = { baz = mumble; }; }; /* this is the one */ +foo = { bar = { baz = grumble; }; }; +fuz-zy = Mum-Ble; +_EOF_ + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # +set -x +echo creating $testname.out +# this is the output we should expect to see +cat > $testname.out <<'_EOF_' +A OK +A OK2 +Mum-Ble +Mum-Ble +Mum-Ble +Mum_Ble +MUM_BLE +mum_ble +_EOF_ + +run_ag x $testname.def || failure autogen failed +cmp -s $testname.test $testname.out || failure unexpected output + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of get.test diff --git a/agen5/test/gperf.test b/agen5/test/gperf.test new file mode 100755 index 0000000..aa4746f --- /dev/null +++ b/agen5/test/gperf.test @@ -0,0 +1,95 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# gperf.test --- test functionality of `gperf' +# +# Time-stamp: "2010-12-06 13:08:36 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +# ---------------------------------------------------------------------- + +if gperf --version > /dev/null 2>&1 +then : +else + echo gperf functionality does not work without gperf >&2 + exit 0 +fi + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating ${testname}.tpl +cat > ${testname}.tpl <<_EOF_ +<= AutoGen5 template test => +<= + +(if (not (make-gperf "${testname}" (stack "foo.bar"))) + (error "cannot make gperf")) =><= + +FOR foo "\n" =><= + + FOR bar => +<=bar=> yields: <=(gperf "${testname}" (get "bar"))=><= + ENDFOR =><= + +ENDFOR =><= +\`tar cf - .${testname}.* > ${testname}-prog.tar || \ + die 'cannot save gperf files'\`=><= +(out-push-new "${testname}-code.c") +(emit (gperf-code "${testname}")) (emit "\n") +(out-pop) +=> +_EOF_ + + +# Create the files we need in the test environment +cat > ${testname}.def <<_EOF_ +AutoGen Definitions ${testname}; +foo = { bar = first; bar = second; }; +foo = { bar = third; bar = fourth; }; +_EOF_ + +# this is the output we should expect to see +cat > ${testname}.base <<_EOF_ + +first yields: 0x01 +second yields: 0x02 + +third yields: 0x03 +fourth yields: 0x04 +_EOF_ + +if ${VERBOSE:-false} +then opts="x --trace=server-shell ${testname}.def" +else opts="x ${testname}.def" +fi + +run_ag ${opts} || failure AutoGen failed +cmp -s ${testname}.base ${testname}.test || \ + failure "`diff ${testname}.base ${testname}.test`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of gperf.test diff --git a/agen5/test/heredef.test b/agen5/test/heredef.test new file mode 100755 index 0000000..959fb92 --- /dev/null +++ b/agen5/test/heredef.test @@ -0,0 +1,102 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# heredef.test --- definition reference testing +# +# Time-stamp: "2011-02-02 12:09:38 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +${SED} 's/^ *[0-9]*: //' > ${testname}.tpl <<\_EOF_ + 1: <= AutoGen5 template test => + 2: <= + 3: + 4: (if (not (= (get "string1") (get "string2"))) + 5: (error (sprintf "`%s' <> `%s'" + 6: (get "string1") (get "string2") )) ) + 7: + 8: =><= + 9: +10: (if (not (= (get "string2") (get "string3"))) +11: (error (sprintf "`%s' <> `%s'" +12: (get "string1") (get "string2") )) ) +13: =>OKAY: <= (c-string (get "string3")) => +14: FROM: string1 extracted <= (def-file-line "string1") => +15: string2 extracted +16: <= (def-file-line "string2" c-file-line-fmt) => +17: string3 extracted <= +18: (def-file-line "string3" "From %1$s on line %2$d") => +_EOF_ + +# # # # # # # # # # SAMPLE FILE # # # # # # # # # +cat > ${testname}.sample <<\_EOF_ +OKAY: "\"`Testing'" +FROM: string1 extracted from heredef.def line 11 + string2 extracted +#line 15 "heredef.def" + + string3 extracted From heredef.def on line 18 +_EOF_ + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +# Create the files we need in the test environment +echo "AutoGen definitions ${testname};" > ${testname}.def +${SED} 's/^ *[0-9]*: //' >> ${testname}.def <<\_EOF_ + 2: #ifdef BOGUS + 3: /* Line 3 */ + 4: #else + 5: #ifdef WRONG + 6: /* line 6 */ + 7: #endif + 8: #endif + 9: /* line 9 */ +10: string1 = <<- AG_EOF +11: "`Testing' +12: AG_EOF; /* " */ +13: /* line 13 */ +14: string2 = <<- AG_EOF +15: "`Testing' +16: AG_EOF; /* " */ +17: +18: string3 = "\"`Testing'"; /* line 18 */ +19: +_EOF_ + +run_ag x ${testname}.def || failure ${testname} AutoGen failed + +if cmp ${testname}.test ${testname}.sample +then cleanup +else failure "`diff ${testname}.sample ${testname}.test`" +fi + + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of heredef.test diff --git a/agen5/test/html.test b/agen5/test/html.test new file mode 100755 index 0000000..8ed4fb8 --- /dev/null +++ b/agen5/test/html.test @@ -0,0 +1,130 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# html.test --- test html generation +# +# Time-stamp: "2011-12-30 12:17:28 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILES # # # # # # # # # + +echo creating cgi.tpl +cat > cgi.tpl <<'_EOF_' +<? AutoGen5 Template ?> +<? DEFINE form-error +?>HTTP/1.0 500 AutoGen Forms Error +Content-Type: text/plain + +The submitted form does not contain a valid template<? + IF (exist? "template") ?> (<?template?>) <?ENDIF?>.<? +ENDDEF ?><? + (define foo "") + (if (exist? "break") (set! foo bogus)) ?><? +IF (not (exist? "template")) ?><? + form-error ?><? + +ELIF (access? (get "template") R_OK) ?><? + INCLUDE (get "template") ?><? + +ELIF (access? (string-append + (get "template") ".tpl") R_OK) ?><? + INCLUDE (string-append (get "template") ".tpl") ?><? + +ELSE ?><? + form-error ?><? +ENDIF ?> +_EOF_ + +echo creating ${testname}.tpl +cat > ${testname}.tpl <<'_EOF_' +<? AutoGen5 Template ?> +<head>Mumble: <? mumble ?></head> +<body>Foolish: <? foo ?></body> +_EOF_ + +# # # # # # # SAMPLE OUTPUT FILE # # # # # # + +echo creating ${testname}.out in `pwd` +# this is the output we should expect to see +cat > ${testname}.samp <<'_EOF_' +content-type: text/html + +<head>Mumble: fumble bumble</head> +<body>Foolish: bar</body> +_EOF_ + +# # # # # # # RUN AUTOGEN # # # # # # + +REQUEST_METHOD=GET +QUERY_STRING="mumble=fumble+bumble&foo=bar&template=${testname}" +CONTENT_LENGTH=`expr "${QUERY_STRING}" : ".*"` + +export CONTENT_LENGTH REQUEST_METHOD QUERY_STRING + +run_ag x1 | ${EGREP} -v '^in state' > ${testname}.test + +cmp -s ${testname}.samp ${testname}.test || \ + failure "`diff ${testname}.samp ${testname}.test`" + +# # # # # # # SECOND RUN # # # # # # + +QUERY_STRING="${QUERY_STRING}&break=true" +CONTENT_LENGTH=`expr "${QUERY_STRING}" : ".*"` + +run_ag x2 > ${testname}-2.test +fgrep 'AutoGen form processing error' ${testname}-2.test || \ + failure autogen unexpectedly succeeded + +cat > ${testname}-2.samp <<'_EOF_' +Content-type: text/plain + +AutoGen form processing error: +cgi.tpl:9:22: In expression (define foo bogus): +cgi.tpl:9:22: Unbound variable: bogus +Scheme evaluation error. AutoGen ABEND-ing in template + cgi.tpl on line 9 +Failing Guile command: = = = = = + +(define foo "") + (if (exist? "break") (set! foo bogus)) + +================================= +_EOF_ +${EGREP} -v '^in state' ${testname}-2.test > ${testname}-2.res +cmp -s ${testname}-2.samp ${testname}-2.res || { + exec >&2 + echo Your Guile library does not handle error traps correctly and causes + echo garbage to be emitted instead. Do not use this autogen as a CGI service. +} + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of html.test diff --git a/agen5/test/in.test b/agen5/test/in.test new file mode 100755 index 0000000..c3793a9 --- /dev/null +++ b/agen5/test/in.test @@ -0,0 +1,95 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# in.test --- Verify that the "in?" predicate works +# +# Time-stamp: "2010-06-26 16:05:12 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating ${testname}.tpl +cat > ${testname}.tpl <<_EOF_ +[++ AutoGen5 template out ++][++ + +(define stack-list (stack "foo.bar")) +(string-append + (if (in? (get "baz") stack-list) "success" "FAIL") + "\n" + (if (in? (get "oops") stack-list) "FAIL" "success") +) ++][++ + +IF .true ++] +success[++ +ELSE ++] +FAILURE[++ +ENDIF ++]-[++ .true ++][++ + +IF .false ++] +FAILURE[++ +ELSE ++] +success[++ +ENDIF ++]-[++ .false ++] +_EOF_ + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo creating ${testname}.def +cat > ${testname}.def <<_EOF_ +AutoGen definitions ${testname}; +foo = { bar = one; }; +foo = { bar = two; }; +foo = { bar = three; }; +foo = { bar = four; }; +baz = three; +oops = oops; +true = true; +false = false; +_EOF_ + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # +set -x +echo creating ${testname}.ok +# this is the output we should expect to see +cat > ${testname}.ok <<'_EOF_' +success +success +success-true +success-false +_EOF_ + +run_ag x ${testname}.def || failure autogen failed +cmp -s ${testname}.ok ${testname}.out || \ + failure "`diff ${testname}.ok ${testname}.test`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of in.test diff --git a/agen5/test/include.test b/agen5/test/include.test new file mode 100755 index 0000000..2b1ca88 --- /dev/null +++ b/agen5/test/include.test @@ -0,0 +1,80 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# include.test --- test include functionality +# +# Time-stamp: "2012-08-11 08:03:16 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating ${testname}.in +cat > ${testname}.in <<_EOF_ +<= AutoGen5 Template +# this is just a test +test => +<= v-name =>: <= \`echo This is an ${testname} test\` => +_EOF_ + +echo creating ${testname}.tpl +cat > ${testname}.tpl <<_EOF_ +[= AutoGen5 Template +# this is just a test + +test =] +[= Include "${testname}.in" =] +_EOF_ + +mkdir ${testname}.d ${testname}.d/good +cat > ${testname}.d/${testname}.def <<- _EOF_ + AutoGen Definitions ${testname}.tpl; + #include good/${testname}-aux.def + _EOF_ + +echo "v-name = Verify;" > ${testname}.d/good/${testname}-aux.def + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # + +echo creating ${testname}.ok +# this is the output we should expect to see +cat > ${testname}.ok <<_EOF_ +Verify: This is an ${testname} test +_EOF_ + +AGCMD="-L ${testname}.d/bad -L ${testname}.d/bad/good" + +run_ag x ${AGCMD} ${testname}.d/${testname}.def || \ + failure ${AGCMD} failed +cmp -s ${testname}.test ${testname}.ok || \ + failure "unexpected output + `diff -u ${testname}.test ${testname}.ok `" +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of include.test diff --git a/agen5/test/leave.test b/agen5/test/leave.test new file mode 100755 index 0000000..9476d49 --- /dev/null +++ b/agen5/test/leave.test @@ -0,0 +1,105 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# leave.test --- test return/next/break functionality +# +# Time-stamp: "2012-04-07 09:03:06 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. + +. ./defs + +# # # # # # # # # # TEMPLATE FILES # # # # # # # # # + +echo creating $testname.tlib +cat > $testname.tlib <<'_EOF_' +[= AutoGen5 Template test =] +[= RETURN =] +BOGUS +_EOF_ + +echo creating $testname.tpl +cat > $testname.tpl <<_EOF_ +[= AutoGen5 Template test =] +[= +INVOKE macro +=][= +DEFINE macro =][= + +FOR value =][= + IF (= 1 (for-index)) =][= BREAK =][= ENDIF =] +BOGUS +[= ENDFOR =][= + +FOR value =][= + CASE (for-index) =][= + == 4 =][= + * =][= CONTINUE =][= + ESAC =][= (for-index) =] Okay.[= + INCLUDE "$testname.tlib" =][= + + RETURN \=] + +BOGUS +[= ENDFOR =][= ENDDEF =] +_EOF_ + + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo creating $testname.def +cat > $testname.def <<_EOF_ +autogen definitions $testname; + +value[1] = first; +value[2] = secondary; +value[4] = tertiary; +value[6] = last; + +_EOF_ + +# this is the output we should expect to see +echo 4 Okay. > $testname.samp + +run_ag x $testname.def || \ + failure "autogen failed" +set -x +cmp -s $testname.samp $testname.test || \ + failure "`diff $testname.samp $testname.test`" + +# # # # # # # # # # TEMPLATE FILES # # # # # # # # # + +echo creating $testname.tlib +cat > $testname.tlib <<'_EOF_' +[= AutoGen5 Template test =] +[= BREAK =] +BOGUS +_EOF_ + +run_ag x -b $testname-bad $testname.def 2>/dev/null && \ + failure "processed broken template" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of leave.test diff --git a/agen5/test/license.test b/agen5/test/license.test new file mode 100755 index 0000000..5925acf --- /dev/null +++ b/agen5/test/license.test @@ -0,0 +1,114 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# license.test --- test license functionality +# +# Time-stamp: "2010-06-26 16:05:08 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating ${testname}.tpl +cat > ${testname}.tpl <<_EOF_ +[= AutoGen5 template test =] +/* +[= (license "${testname}" "${testname}" "Auto-Gen" " * " ) =] + */ +_EOF_ + +# # # # # # # # # # LICENSE FILE # # # # # # # # # + +echo creating ${testname}.lic +cat > ${testname}.lic <<'_EOF_' +This is a bogus license granted by %2$s for %1$s. +Use it in good health +_EOF_ + +# # # # # # # # # # EXTEND FILES TO PAGESIZE # # # # # # # # # + +cat > ${testname}-extend.c <<- _EOF_ + #define HAVE_CONFIG_H 1 + #include "config.h" + #include "compat/compat.h" + + int main( int argc, char** argv ) { + char z_tail[] = "=]\n */\n"; + long offset = 0L - (sizeof(z_tail) - 1); + struct stat sb; + char* file; + size_t sz; + FILE* fp; + + file = *++argv; + fp = fopen(file, "a"); + if (fp == NULL) return 1; + if (stat(file, &sb) != 0) return 1; + sz = 0x2000 - (sb.st_size & 0x1FFFUL); + while (sz > 0) { putc( '\n', fp ); sz--; } + fclose(fp); + + file = *++argv; + fp = fopen( file, "r+" ); + if (fp == NULL) return 1; + if (stat(file, &sb) != 0) return 1; + fseek(fp, offset, SEEK_END); + sz = 0x2000 - (sb.st_size & 0x1FFFUL); + while (sz > 0) { putc( '\n', fp ); sz--; } + fputs(z_tail, fp); + fclose(fp); + + return 0; } + _EOF_ + +Csrc=${testname}-extend +compile + +./${testname}-extend ${testname}.lic ${testname}.tpl || \ + failure "Could not extend license/template files to 8KB" +ls -l ${testname}.??? + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # +set -x +echo creating ${testname}.out +# this is the output we should expect to see +cat > ${testname}.out <<_EOF_ +/* + * This is a bogus license granted by Auto-Gen for ${testname}. + * Use it in good health + */ +_EOF_ + +run_ag x -b ${testname} --no-def -T ${testname}.tpl || \ + failure autogen failed +cmp -s ${testname}.test ${testname}.out || failure unexpected output + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of license.test diff --git a/agen5/test/line.test b/agen5/test/line.test new file mode 100755 index 0000000..c0462f0 --- /dev/null +++ b/agen5/test/line.test @@ -0,0 +1,68 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# line.test --- test (tpl-file-line) functionality +# +# Time-stamp: "2011-02-02 12:09:53 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating ${testname}.tpl +${SED} 's/^ *[0-9]*: //' > ${testname}.tpl << _EOTPL_ + 1: [= AutoGen5 Template txt =] + 2: ${testname} Test + 3: [= (define ix 0) (define ct 63) =] + 4: [=WHILE (< ix ct) \=] + 5: [= (set! ix (+ ix 1)) + 6: (sprintf "test %2d of %2d: %s\n" ix ct (tpl-file-line "%2\$d")) + 7: \=] + 8: [=ENDWHILE \=] + 9: End ${testname} Test +_EOTPL_ + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # +set -x +echo creating ${testname}.out +# this is the output we should expect to see +cat > ${testname}.out <<- \_EOF_ + line Test + + End line Test + _EOF_ + +run_ag x --base=${testname} --no-def --override=${testname}.tpl || \ + failure autogen failed +${EGREP} -v ' of 63: 5$' ${testname}.txt > ${testname}.test + +cmp -s ${testname}.test ${testname}.out || failure unexpected output + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of line.test diff --git a/agen5/test/loop.test b/agen5/test/loop.test new file mode 100755 index 0000000..ef92af5 --- /dev/null +++ b/agen5/test/loop.test @@ -0,0 +1,78 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# loop.test --- test FOR loop +# +# Time-stamp: "2010-06-26 16:04:59 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating ${testname}.tpl +limit=32 +cat > ${testname}.tpl <<- _EOTPL_ + [= AutoGen5 Template test =] + ${testname} Test + [= (define ix 0) (define ct ${limit}) =][= + + WHILE (< ix ct) =][= + (set! ix (+ ix 1)) =][= + (sprintf "test %2d of %2d: %s\n" + ix ct (tpl-file-line "%2\$d")) =][= + ENDWHILE + + =]End ${testname} Test + _EOTPL_ + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # +set -x +echo creating ${testname}.base + +# this is the output we should expect to see +# +exec 3> ${testname}.base +echo "${testname} Test" >&3 +ix=1 +while test $ix -le $limit +do printf "test %2d of ${limit}: 7\n" $ix + ix=`expr $ix + 1` +done >&3 +echo "End ${testname} Test" >&3 +exec 3>&- + +run_ag x --base=${testname} --no-def --override=${testname}.tpl || \ + failure autogen failed + +cmp -s ${testname}.base ${testname}.test || \ + failure "unexpected output: `diff ${testname}.base ${testname}.test`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of loop.test diff --git a/agen5/test/make.test b/agen5/test/make.test new file mode 100755 index 0000000..cfa55dd --- /dev/null +++ b/agen5/test/make.test @@ -0,0 +1,91 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# make.test --- test makefile script manufacture +# +# Time-stamp: "2010-06-26 16:04:55 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating ${testname}.tpl +cat > ${testname}.tpl <<'_EOF_' +[= AutoGen5 Template + +=] +== This source: +[= + + (out-push-new) + +=] +foo=`pwd` && ls -l $foo +bar=$foo continue=command \ +make macros: $(MAKE) $* $@ $< $% $? +shell vars: ${MAKE} $# $F ${?} ${*} $$ +[= +(define txt (out-pop #t)) +(string-append txt "\n== converts to:\n\n" (makefile-script txt)) +=] +_EOF_ + +# # # # # # # SAMPLE OUTPUT FILE # # # # # # + +echo creating ${testname}.out in `pwd` +# this is the output we should expect to see +cat > ${testname}.samp <<'_EOF_' +== This source: + +foo=`pwd` && ls -l $foo +bar=$foo continue=command \ +make macros: $(MAKE) $* $@ $< $% $? +shell vars: ${MAKE} $# $F ${?} ${*} $$ + +== converts to: + + foo=`pwd` && ls -l $$foo ; \ + bar=$$foo continue=command \ + make macros: $(MAKE) $* $@ $< $% $? ; \ + shell vars: $${MAKE} $$# $$F $${?} $${*} $$$$ +_EOF_ + +# # # # # # # RUN AUTOGEN # # # # # # + +run_ag x -T ${testname}.tpl --no-def > ${testname}.test || \ + failure autogen failed + +# # # # # # # TEST RESULTS # # # # # # + +cmp -s ${testname}.samp ${testname}.test || \ + failure "`diff ${testname}.samp ${testname}.test`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of make.test diff --git a/agen5/test/match.test b/agen5/test/match.test new file mode 100755 index 0000000..def13a3 --- /dev/null +++ b/agen5/test/match.test @@ -0,0 +1,72 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# match.test --- test the "match-value?" scheme +# +# Time-stamp: "2010-06-26 16:04:51 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating ${testname}.tpl +cat > ${testname}.tpl <<'_EOF_' +[= AutoGen5 Template test =] + ==* "sec" [= IF (match-value? ==* "foo.valu" "sec" ) + =]YES[=ELSE=]FAIL[=ENDIF=] + ==* "SEC" [= IF (match-value? ==* "foo.valu" "SEC" ) + =]FAIL[=ELSE=]YES[=ENDIF=] + *=* "rST" [= IF (match-value? *=* "foo.valu" "rST" ) + =]YES[=ELSE=]FAIL[=ENDIF=] + *==* "rST" [= IF (match-value? *==* "foo.valu" "rST" ) + =]FAIL[=ELSE=]YES[=ENDIF=] +_EOF_ + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo creating ${testname}.def +cat > ${testname}.def <<_EOF_ +autogen definitions ${testname}.tpl; + +foo = { valu = first.0; valu = primary.0; }; +foo = { valu = first.1; valu = secondary.1; }; +foo = { valu = first.2; }; +foo = { valu = first.3; valu = tertiery.3; }; +_EOF_ + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # + +run_ag x ${testname}.def || \ + failure could not generate output +${EGREP} FAIL ${testname}.test && \ + failure some ${testname} tests failed + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of match.test diff --git a/agen5/test/opts.test b/agen5/test/opts.test new file mode 100755 index 0000000..489e30f --- /dev/null +++ b/agen5/test/opts.test @@ -0,0 +1,91 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# opts.test --- Verify the handling of options +# +# Time-stamp: "2011-12-04 05:12:42 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. + +. ./defs + +# Fetch the options files +# +unstamp() +{ + # The "zDetail" and zCopyrightNotice text gets formatted with "fmt -w 75". + # The different "fmt" implementations behave differently. + # + ${SED} -e "${sed_omit_license}" \ + -e '/ extracted from.* line [1-9]/d' \ + -e '/static char const zDetail/,/";$/d' \ + -e '/static char const zCopyright/,/";$/d' \ + -e '/static char const zLicenseDescrip/,/";$/d' \ + -e '/ "autogen is free software: /,/www\.gnu\.org\/licenses/d' \ + $1 > $2 || + failure Cannot remove stamps from $1 +} + +workdir=`pwd` +rm -f ../VERSION ./opts.* || : + +cd ${top_srcdir}/agen5 +unstamp opts.c ${workdir}/opts.c.base +unstamp opts.h ${workdir}/opts.h.base +cp opts.def ${workdir}/. +cp -f ${top_srcdir}/VERSION ${workdir}/.. + +cd ${workdir} +set -x +ls -l * ../VERSION > $testname.log + +echo Checking for "'define DEBUG'" options +if ${GREP} 'define DEBUG' ${srcdir}/../opts.h +then + AGCMD="-DDEBUG=1" +else + AGCMD="" +fi + +run_ag x ${AGCMD} opts.def || { + rm -f ../VERSION + failure ${AGCMD} opts.def +} + +rm -f ../VERSION + +unstamp opts.c opts.c.res +echo diff opts.c.base opts.c.res +diff opts.c.base opts.c.res || \ + failure "`diff -c opts.c.base opts.c.res`" + +unstamp opts.h opts.h.res +echo diff opts.h.base opts.h.res +diff opts.h.base opts.h.res || \ + failure "`diff -c opts.h.base opts.h.res`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of opts.test diff --git a/agen5/test/output.test b/agen5/test/output.test new file mode 100755 index 0000000..06aeb72 --- /dev/null +++ b/agen5/test/output.test @@ -0,0 +1,120 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# include.test --- test include functionality +# +# Time-stamp: "2010-06-26 16:04:42 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating $testname.tpl +cat > $testname.tpl <<'EOF' +<= AutoGen5 template test => +<=(out-push-new) + +=>This is sample output +<= `echo echoed text.` =><= +(out-suspend "here") +(out-push-new) +=>This text is from another diversion. +<= +(out-suspend "there") +=>This is the first output text. +<=(out-resume "here") +=> +Final text<= + +(define text (out-pop #t)) =><= + +DEFINE wrapper + +=>BEGIN +<=(out-resume "there") (out-pop #t) +=><= +(. text)=> +END<= + +ENDDEF wrapper =><= + +wrapper => +Done. +EOF + +# # # # # # # SAMPLE OUTPUT FILE # # # # # # + +echo creating $testname.out in `pwd` +# this is the output we should expect to see +cat > $testname.samp <<'EOF' +This is the first output text. +BEGIN +This text is from another diversion. +This is sample output +echoed text. +Final text +END +Done. +EOF + +# # # # # # # RUN AUTOGEN # # # # # # + +run_ag nodef -b $testname -T $testname.tpl --no-def || \ + failure autogen failed + +# # # # # # # TEST RESULTS # # # # # # + +cmp -s $testname.samp $testname.test || \ + failure "`diff $testname.samp $testname.test`" + +# # # # # # # EMPTY DEFINITIONS FILE # # # # # # + +cat > $testname.def <<EOF +AutoGen Definitions $testname.tpl; +EOF + +# # # # # # # RUN AUTOGEN # # # # # # + +mv -f $testname.test $testname.tst1 || \ + failure moving output-1 failed + +run_ag def $testname.def || \ + failure autogen failed + +mv -f $testname.test $testname.tst2 || \ + failure moving output-2 failed + +# # # # # # # TEST RESULTS # # # # # # + +cmp -s $testname.tst1 $testname.tst2 || \ + failure "`diff $testname.tst1 $testname.tst2`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of output.test diff --git a/agen5/test/pseudo.test b/agen5/test/pseudo.test new file mode 100755 index 0000000..f5b87c7 --- /dev/null +++ b/agen5/test/pseudo.test @@ -0,0 +1,103 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# pseudo.test --- test the select pseudo option +# +# Time-stamp: "2010-06-26 16:04:38 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating ${testname}.tpl +cat > ${testname}.tpl <<- \_EOF_ + [= AutoGen5 Template + + (define f-name "") + + h=(begin + (set! f-name (getenv "incdir")) + (if (not (string? f-name)) (set! f-name ".")) + (set! f-name (string-append f-name "/%s-hdr.%s")) + (shellf + "d=`dirname %s` + test -d ${d} || mkdir -p $d || die cannot mkdir $d" + f-name) + f-name + ) + + c=(begin + (set! f-name (getenv "srcdir")) + (if (not (string? f-name)) (set! f-name ".")) + (set! f-name (string-append f-name "/%s-body.%s")) + (shellf + "d=`dirname %s` + test -d ${d} || mkdir -p $d || die cannot mkdir $d" + f-name) + f-name + ) + + # end of pseudo + =] + [= + + (sprintf "two file create %s: " (suffix)) =][= + + CASE (suffix) =][= + + == h =]HEADER FILE[= + == c =]BODY 4 FILE[= + * =][= (error "woops") =][= + + ESAC =] + _EOF_ + +# # # # # # # # # # RUN TESTS # # # # # # # + +incdir=${testname}-inc +srcdir=${testname}-src + +export incdir srcdir + +run_ag x --no-def -T${testname}.tpl -b${testname} || \ + failure autogen --no-def -T${testname}.tpl -b${testname} + +f=${incdir}/${testname}-hdr.h +test -f ${f} || \ + failure missing file: ${f} +${FGREP} 'two file create h: HEADER FILE' ${f} || failure bad contents for $f + +f=${srcdir}/${testname}-body.c +test -f ${f} || \ + failure missing file: ${f} +${FGREP} 'two file create c: BODY 4 FILE' ${f} || failure bad contents for $f + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of pseudo.test diff --git a/agen5/test/reorder.test b/agen5/test/reorder.test new file mode 100755 index 0000000..55cfb82 --- /dev/null +++ b/agen5/test/reorder.test @@ -0,0 +1,107 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# reorder.test --- test reorder functionality +# +# Time-stamp: "2010-06-26 16:04:32 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating $testname.tpl +cat > $testname.tpl <<'_EOF_' +<= AutoGen5 template test => +From zero:<= + +FOR a (for-from 0) (for-by 1) (for-sep ",")=> +<=(sprintf "%5d: " (for-index))=><= + ?% elt %s absent =><= + IF (first-for?) => first loop<= ENDIF =><= + IF (last-for? ) => last loop<= ENDIF =><= +ENDFOR => + +From start by two:<= + +FOR a (for-by 2) (for-sep ",")=> +<=(sprintf "%5d: " (for-index)) =><= + ?% elt %s absent =><= + IF (first-for?) => first loop<= ENDIF =><= + IF (last-for? ) => last loop<= ENDIF =><= +ENDFOR => +_EOF_ + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo creating $testname.def +cat > $testname.def <<_EOF_ +autogen definitions $testname; +a[ 3] = { elt = three; }; +a[ 5] = { elt = five; }; +a[12] = { elt = twelve; }; +a[ 8] = { elt = eight; }; +a[ 1] = { elt = one; }; +a[ 2] = { elt = two; }; +_EOF_ + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # + +echo creating $testname.out +# this is the output we should expect to see +cat > $testname.out <<_EOF_ +From zero: + 0: absent first loop, + 1: one, + 2: two, + 3: three, + 4: absent, + 5: five, + 6: absent, + 7: absent, + 8: eight, + 9: absent, + 10: absent, + 11: absent, + 12: twelve last loop + +From start by two: + 1: one first loop, + 3: three, + 5: five, + 7: absent, + 9: absent, + 11: absent last loop +_EOF_ + +run_ag x $testname.def || failure autogen failed +cmp -s $testname.test $testname.out || failure unexpected output + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of reorder.test diff --git a/agen5/test/shell.test b/agen5/test/shell.test new file mode 100755 index 0000000..269f46a --- /dev/null +++ b/agen5/test/shell.test @@ -0,0 +1,165 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# shell.test --- test functionality of switching shells +# +# Time-stamp: "2012-05-12 19:56:39 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# The test will verify that a real shell processes the declarations +# and our weirdo shell handles the template. +# +# ---------------------------------------------------------------------- + +exec 9>&2 + +. ./defs + +${FGREP} '#define SHELL_ENABLED ' ${top_builddir}/config.h > /dev/null 2>&1 +test $? -eq 0 || exit 0 + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +cat > ${testname}.c <<- \_EOF_ + #include <stdio.h> + #include <string.h> + #include <ctype.h> + #define NUL '\0' + char buf[ 4096 ]; + int + main( int argc, char** argv ) + { + char *pz; + for (;;) { + pz = fgets(buf, sizeof(buf),stdin); + if (pz == NULL) + return 1; /* must get something every time */ + while (isspace(*pz)) pz++; + if (*pz != NUL) break; /* ignore initial blank lines */ + } + + for (;;) { + if (*pz == '#') goto next_line; + if (strncmp( pz, "cd ", 3 ) == 0) goto next_line; + if ((strncmp( pz, "echo", 4 ) == 0) && isspace( pz[4] )) { + pz += 5; + while (isspace(*pz)) pz++; /* suppress the 'echo' */ + } + if (*pz == '\0') pz--; /* always force a newline */ + fputs( pz, stdout ); + fflush( stdout ); + + next_line: + pz = fgets(buf, sizeof(buf),stdin); + if (pz == NULL) + break; + while (isspace(*pz)) pz++; + } + return 0; + } + _EOF_ + +compile + +# The backslashes are stripped by the here-doc processing +# +echo creating ${testname}.tpl +cat > ${testname}.tpl <<- _EOF_ + <= AutoGen5 template test + (setenv "SHELL" "./${testname}") => + <=\` echo SHELL=\$SHELL \`=> + Some <=dummy=> text + <= FOR foo => + foo[<=(for-index)=>] = <=foo=> + raw-shell-str: <=(raw-shell-str (get "foo"))=> + shell-str: <=(shell-str (get "foo"))=> + sub-shell-str: <=(sub-shell-str (get "foo"))=> + <= ENDFOR => + <=\` : This is a final test \`=> + _EOF_ + +echo creating ${testname}.def +cat >${testname}.def <<- \_EOF_ + AutoGen Definitions shell.tpl; + + foo = "''foo'' 'foo' \"foo\" `foo` $foo"; + foo = '\\\'bar\\\' \\"bar\\" \`bar\` \$bar'; + foo = '\\\\\'BAZ\\\\\' \\\\"BAZ\\\\" \\\`BAZ\\\` \\\$BAZ'; + dummy = `echo "mumble"`; /* processed with regular shell */ + _EOF_ + +# this is the output we should expect to see +cat > ${testname}.sample <<- \_EOF_ + SHELL=$SHELL + Some "mumble" text + + foo[0] = ''foo'' 'foo' "foo" `foo` $foo + raw-shell-str: \'\''foo'\'\'' '\''foo'\'' "foo" `foo` $foo' + shell-str: "''foo'' 'foo' \"foo\" `foo` $foo" + sub-shell-str: `''foo'' 'foo' "foo" \`foo\` $foo` + + foo[1] = \'bar\' \"bar\" \`bar\` \$bar + raw-shell-str: '\'\''bar\'\'' \"bar\" \`bar\` \$bar' + shell-str: "\\'bar\\' \\\"bar\\\" \`bar\` \$bar" + sub-shell-str: `\\'bar\\' \"bar\" \\\`bar\\\` \$bar` + + foo[2] = \\'BAZ\\' \\"BAZ\\" \\`BAZ\\` \\$BAZ + raw-shell-str: '\\'\''BAZ\\'\'' \\"BAZ\\" \\`BAZ\\` \\$BAZ' + shell-str: "\\\\'BAZ\\\\' \\\\\"BAZ\\\\\" \\\`BAZ\\\` \\\$BAZ" + sub-shell-str: `\\\\'BAZ\\\\' \\\"BAZ\\\" \\\\\`BAZ\\\\\` \\\$BAZ` + + : This is a final test + _EOF_ + +run_ag x --shell=$PWD/shell ${testname}.def || \ + failure "autogen ${testname}.def" + +${GREP} -v '^AGexe=' ${testname}.test > ${testname}.XX +mv -f ${testname}.XX ${testname}.test +if cmp -s ${testname}.test ${testname}.sample +then cleanup + exit 0 +fi + +if ${FGREP} 'SHELL=' ${testname}.test > /dev/null 2>&1 +then + if ${FGREP} 'SHELL=$SHELL' ${testname}.test > /dev/null 2>&1 + then : ; else + cat >&9 <<- _EOF_ + The ${testname}.test output file does not start with "SHELL=\$SHELL" + This is because you have a Guile library that cannot modify + the environment. This is a known breakage on some platforms + (viz., BSD derivatives). Sorry. + _EOF_ + ${FGREP} 'SHELL=' ${testname}.test >&9 + cleanup + exit 0 + fi +fi + +failure "`set +x;diff -c ${testname}.sample ${testname}.test`" + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of shell.test diff --git a/agen5/test/snarf.test b/agen5/test/snarf.test new file mode 100755 index 0000000..c03e408 --- /dev/null +++ b/agen5/test/snarf.test @@ -0,0 +1,267 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# snarf.test --- test the extraction of scm-type definitions +# +# Time-stamp: "2012-03-04 19:48:23 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # SOURCE FILE # # # # # # # # # + +echo creating ${testname}.c +cat > ${testname}.c <<_EOF_ +#include "${testname}.h" +#include "${testname}.ini" +/*=gfunc test_to_example_x + * + * exparg: in, test input arg desc, optional, list + * +=*/ +SCM +test_scm_test_to_example_x(SCM in) +{ + return in; +} + +/*=symbol mumble_check + * + * init_val: SCM_BOOL_T +=*/ +/*=symbol bumble_it + * + * const_val: 100L + * global: +=*/ +/*=syntax guile_syntax_ele + * + * type: scm_makacro + * cfn: scm_m_undefine +=*/ +_EOF_ + +# # # # # # # # # # PROCESS SOURCE FILE # # # # # # # # # + +f=`echo ${AGexe} | ${SED} 's/ .*//'` + +agsrc=`cd $top_srcdir/agen5 && pwd` +tplsrc=`cd $top_srcdir/autoopts/tpl && pwd` + +cat > ${testname}.cfg <<- _EOF_ + subblock exparg=arg_name,arg_desc,arg_optional,arg_list + template snarf.tpl + srcfile + assign group = ${testname}_grp + assign init = Chosen_init + base-name ${testname} + agarg -L$agsrc + agarg -L$tplsrc + input ${testname}.c + autogen ${f} + _EOF_ +unset DEBUG_ENABLED + +echo "getdefs load=${testname}.cfg ${testname}.c" +${VERBOSE} && { + AUTOGEN_TRACE=everything + AUTOGEN_TRACE_OUT=">>${testname}-ag-log.txt" + export AUTOGEN_TRACE AUTOGEN_TRACE_OUT +} +${GDexe} load=${testname}.cfg || \ + failure getdefs load=${testname}.cfg + +${SED} -e "${sed_omit_license}" -e '/^#undef *NEW_PROC *$/,$d' \ + ${testname}.ini > ${testname}.ini.tst1 + +${SED} "${sed_omit_license}" ${testname}.h > ${testname}.h.tst1 + +# # # # # # # # # # EXPECTED INI FILE # # # # # # # # # + +echo creating ${testname}.ini.OK1 +cat > ${testname}.ini.OK1 <<'_EOF_' +#include "snarf.h" +typedef SCM (*scm_callback_t)(void); +void Chosen_init(void); + +extern SCM snarf_grp_scm_sym_bumble_it = SCM_BOOL_F; +static SCM snarf_grp_scm_sym_mumble_check = SCM_BOOL_F; +#if GUILE_VERSION >= 108000 +#define NEW_PROC(_As, _Ar, _Ao, _Ax, _An) \ + scm_c_define_gsubr((char*)(_As), \ + _Ar, _Ao, _Ax, (scm_callback_t)(void*)ag_scm_ ## _An) +#else +#define NEW_PROC(_As, _Ar, _Ao, _Ax, _An) \ + gh_new_procedure((char*)(_As), (scm_callback_t)(void*)ag_scm_ ## _An, \ + _Ar, _Ao, _Ax) +#endif + +/* + * snarf_grp Initialization procedure. + */ +void +Chosen_init(void) +{ +static char const g_nm[55] = +/* 0 */ "test->example!\0" +/* 15 */ "guile-syntax-ele\0" +/* 32 */ "bumble-it\0" +/* 42 */ "mumble-check"; + + NEW_PROC(g_nm + 0, 0, 0, 1, test_to_example_x); + scm_make_synt(g_nm+15, scm_makacro, scm_m_undefine); + snarf_grp_scm_sym_bumble_it = scm_permanent_object(SCM_CAR (scm_intern0 (g_nm+32))); + snarf_grp_scm_sym_mumble_check = scm_permanent_object(SCM_CAR (scm_intern0 (g_nm+42))); +} +_EOF_ + +cmp ${testname}.ini.tst1 ${testname}.ini.OK1 || \ + failure "`diff ${testname}.ini.tst1 ${testname}.ini.OK1`" + +# # # # # # # # # # EXPECTED HEADER FILE # # # # # # # + +echo creating ${testname}.h.OK +cat > ${testname}.h.OK <<_EOF_ +#ifndef GUILE_PROCS_SNARF_H_GUARD +#define GUILE_PROCS_SNARF_H_GUARD 1 +#if GUILE_VERSION >= 108000 +# include <libguile.h> +#else +# include <guile/gh.h> +#endif + +typedef enum { + GH_TYPE_UNDEFINED = 0, + GH_TYPE_BOOLEAN, + GH_TYPE_SYMBOL, + GH_TYPE_CHAR, + GH_TYPE_VECTOR, + GH_TYPE_PAIR, + GH_TYPE_NUMBER, + GH_TYPE_STRING, + GH_TYPE_PROCEDURE, + GH_TYPE_LIST, + GH_TYPE_INEXACT, + GH_TYPE_EXACT +} teGuileType; + +extern SCM snarf_grp_scm_test_to_example_x(SCM); +extern SCM snarf_grp_scm_sym_bumble_it; + +#endif /* GUILE_PROCS_SNARF_H_GUARD */ +_EOF_ + +cmp ${testname}.h.* || \ + failure "`diff ${testname}.h.*`" + +# # # # # # # # # # PROCESS SOURCE FILE AGAIN # # # # # # # # # + +cp ${testname}.cfg ${testname}.cfg1 + +echo 'assign debug-enabled = true' >> ${testname}.cfg +DEBUG_ENABLED=true +export DEBUG_ENABLED + +${GDexe} load=${testname}.cfg || \ + failure getdefs load=${testname}.cfg + +${SED} -e "${sed_omit_license}" \ + -e '/^#undef *NEW_PROC$/,$d' \ + ${testname}.ini > ${testname}.ini.tst2 + +${SED} "${sed_omit_license}" ${testname}.h > ${testname}.h.tst2 + +# # # # # # # # # # EXPECTED INI FILE # # # # # # # # # + +echo creating ${testname}.ini.OK2 +cat > ${testname}.ini.OK2 <<'_EOF_' +#include "snarf.h" +typedef SCM (*scm_callback_t)(void); +void Chosen_init(void); + +extern SCM snarf_grp_scm_sym_bumble_it = SCM_BOOL_F; +static SCM snarf_grp_scm_sym_mumble_check = SCM_BOOL_F; +#ifdef DEBUG_ENABLED +static SCM +agrelay_scm_test_to_example_x(SCM scm0) +{ + if (OPT_VALUE_TRACE >= TRACE_EVERYTHING) { + static char const proc_z[] = + "Called ag_scm_test_to_example_x()\n"; + fwrite(proc_z, sizeof(proc_z) - 1, 1, trace_fp); + } + return ag_scm_test_to_example_x(scm0); +} + +#if GUILE_VERSION >= 108000 +#define NEW_PROC(_As, _Ar, _Ao, _Ax, _An) \ + scm_c_define_gsubr((char*)(_As), \ + _Ar, _Ao, _Ax, (scm_callback_t)(void*)agrelay_scm_ ## _An) +#else +#define NEW_PROC(_As, _Ar, _Ao, _Ax, _An) \ + gh_new_procedure((char*)(_As), (scm_callback_t)(void*)agrelay_scm_ ## _An, \ + _Ar, _Ao, _Ax) +#endif + +#else /* DEBUG_ENABLED *not* */ +#if GUILE_VERSION >= 108000 +#define NEW_PROC(_As, _Ar, _Ao, _Ax, _An) \ + scm_c_define_gsubr((char*)(_As), \ + _Ar, _Ao, _Ax, (scm_callback_t)(void*)ag_scm_ ## _An) +#else +#define NEW_PROC(_As, _Ar, _Ao, _Ax, _An) \ + gh_new_procedure((char*)(_As), (scm_callback_t)(void*)ag_scm_ ## _An, \ + _Ar, _Ao, _Ax) +#endif +#endif /* DEBUG_ENABLED */ + +/* + * snarf_grp Initialization procedure. + */ +void +Chosen_init(void) +{ +static char const g_nm[55] = +/* 0 */ "test->example!\0" +/* 15 */ "guile-syntax-ele\0" +/* 32 */ "bumble-it\0" +/* 42 */ "mumble-check"; + + NEW_PROC(g_nm + 0, 0, 0, 1, test_to_example_x); + scm_make_synt(g_nm+15, scm_makacro, scm_m_undefine); + snarf_grp_scm_sym_bumble_it = scm_permanent_object(SCM_CAR (scm_intern0 (g_nm+32))); + snarf_grp_scm_sym_mumble_check = scm_permanent_object(SCM_CAR (scm_intern0 (g_nm+42))); +} +_EOF_ + +cmp ${testname}.ini.tst2 ${testname}.ini.OK2 || \ + failure "`diff ${testname}.ini.tst2 ${testname}.ini.OK2`" + +cleanup + +## +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of snarf.test diff --git a/agen5/test/stack.test b/agen5/test/stack.test new file mode 100755 index 0000000..32317af --- /dev/null +++ b/agen5/test/stack.test @@ -0,0 +1,93 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# stack.test --- test stack and join functionality +# +## Time-stamp: "2010-02-24 08:41:38 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating ${testname}.tpl +cat > ${testname}.tpl <<_EOF_ +[= AutoGen5 template test =] +[= + + (join ", " (stack "foo.bar.baz")) + +=] +[= + + (join ",\n" "one" "two" "three" "four" ) + +=] +[= + + (join ", " "foo" (stack "foo.bar.baz") "bar" "baz") + +=] +[= (string-substitute (join "\n" (stack "foo.bar.baz")) + '("umb" "le") '("_UMB_" "<=") ) =] +_EOF_ + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo creating ${testname}.def +cat > ${testname}.def <<_EOF_ +AutoGen definitions ${testname}; + +foo = { bar = { baz = fumble; }; }; +foo = { bar = { baz = mumble; }; }; +foo = { bar = { baz = grumble; }; }; +_EOF_ + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # +set -x +echo creating ${testname}.out +# this is the output we should expect to see +cat > ${testname}.out <<'_EOF_' +fumble, mumble, grumble +one, +two, +three, +four +foo, fumble, mumble, grumble, bar, baz +f_UMB_<= +m_UMB_<= +gr_UMB_<= +_EOF_ + +run_ag x ${testname}.def || failure autogen failed +cmp -s ${testname}.test ${testname}.out || \ + failure "`diff ${testname}.*t`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of stack.test diff --git a/agen5/test/stress.test b/agen5/test/stress.test new file mode 100755 index 0000000..05dc399 --- /dev/null +++ b/agen5/test/stress.test @@ -0,0 +1,68 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# stress.test --- stress test +# +## Time-stamp: "2011-03-06 15:26:25 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating ${testname}.tpl +cat > ${testname}.tpl <<_EOF_ +[= AutoGen5 template test =] +Entry Count = [= (count "entry") =]. +_EOF_ + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # +set -x +echo creating ${testname}.samp +ecount=${STRESS_COUNT:-1000} +# this is the output we should expect to see +echo "Entry Count = ${ecount}." > ${testname}.samp + +( + set +x + echo "AutoGen Definitions ${testname};" + idx=1 + while test $idx -le ${ecount} + do + echo "entry = { value = 'val-${idx}'; depth = '${idx}'; const = xx; };" + idx=`expr $idx + 1` + done +) | run_ag x -b ${testname} - +test $? -eq 0 || failure autogen failed + +cmp -s ${testname}.test ${testname}.samp || \ + failure "`diff ${testname}.test ${testname}.samp`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of stress.test diff --git a/agen5/test/string.test b/agen5/test/string.test new file mode 100755 index 0000000..dfcabb3 --- /dev/null +++ b/agen5/test/string.test @@ -0,0 +1,247 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# string.test --- test string formation rules +# +# Time-stamp: "2012-05-12 19:56:52 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# ---------------------------------------------------------------------- + +. ./defs + +# There are five different things we need to examine: +# +# 1. That the autogen internal string. +# 2. What we expect that string to contain. +# 3. What is generated as the "C" representation +# 4. What is generated for raw shell strings +# 5. What is generated for "cooked" shell strings +# +# We will compare all these things by generating a C program that +# will test the various strings and a shell script to invoke the +# program with the two shell string formats for arguments. +# The program will also write out the expected string value. +# That value will be compared with what autogen wrote out +# as its internal value. +# +# All this stuff must be generated carefully. +# Specifically, the '${testname}' expressions need to +# be expanded in certain parts of the output file. +# In those areas, the eof marker must *not* be quoted. +# In other places (e.g., where defining the strings), +# rather than hassle with understanding shell quoting rules, +# instead we *will* quote the EOF marker to avoid +# any shell interpretation at all!! +# +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating $testname.tpl +exec 4> $testname.tpl +cat >&4 <<_EOF_ +[= AutoGen5 Template c sh =] +[= + +CASE (suffix) =][= + + == c + +=]#include <stdio.h> +#include <string.h> +#include <unistd.h> + +#ifndef STDOUT_FILENO +# define STDOUT_FILENO 1 +#endif[= + + + ;; Create a file containing nothing but the + ;; autogen internal contents of the string + ;; + (out-push-new "${testname}.raw") + + =][=string=][= + + (out-pop) + +=] +_EOF_ + +test -z "$LINENO" && LINENO=` + ${GREP} -n FIND-THIS-LINE-NUMBER $0 | sed 's/:.*//'` # close enough +printf '\nchar zTestFile[] = "%s";\n#line %s\n' \ + ${testname}.raw `expr $LINENO + 4` >&4 + +cat >&4 <<'_EOF_' +char zGened[] = [=(c-string (get "string"))=]; +char zKrGen[] = [=(kr-string (get "string"))=]; +char zExpect[] = "'\f\r\b\v\t\a\n\n" + "\\f\\r\\b\\v\\t\\a\\n\n" + "\"Wow!\" This'll be \\hard\\'\n" + "#endif /* .\n" + "and it'll be a \"hassle\"." + "\001\002\003\n'"; +#define expectSize ((int)(sizeof(zExpect) - 1)) +int checkStr( char* pz, char const* pzWhat ); +int checkStr( char* pz, char const* pzWhat ) +{ + static char const zNotMatch[] = + "%s generated string mismatches at offset %d of %d\n" + "Expected char: 0x%02X saw char: 0x%02X\n" + "Expected string:\n==>%s<==\n\n" + "Generated string:\n-->%s<--\n\n"; + + char* pzE = zExpect; + char* pzR = pz; + int ix = strlen( pz ); + int res = 0; + + if (ix != expectSize) { + fprintf( stderr, "%s is %d bytes, not %d\n", pzWhat, ix, expectSize ); + res = 1; + } + + for (ix = 0; ix < expectSize; ix++) { + if (*(pzE++) != *(pzR++)) { + fprintf(stderr, zNotMatch, pzWhat, ix, expectSize, + (unsigned)pzE[-1], (unsigned)pzR[-1], zExpect, pz); + return 1; + } + } + if (*pzE != '\0') { + fputs( "compile error: expected string too long\n", stderr); + res = 1; + } else if (*pzR != '\0') { + fprintf(stderr, "%s has %d residual characters:\n==>%s<==\n", + pzWhat, (int)strlen(pzR), pzR); + res = 1; + } + return res; +} + + +int main( int argc, char** argv ) +{ + int resCode = 0; + + /* + * Write out the expected value to a file. + * The "cmp" program will compare it with the + * internal version autogen wrote out itself. + */ + write( STDOUT_FILENO, zExpect, sizeof( zExpect )-1); + close( STDOUT_FILENO ); + + if (sizeof( zGened ) != sizeof( zExpect )) { + fputs( "Expected and generated string sizes do not match.\n", + stderr ); + resCode = 1; + } + + if (strlen( zGened ) != sizeof( zGened )-1) { + fputs( "The generated string contains a NUL.\n", stderr ); + resCode++; + } + + if (checkStr( zGened, "'C' program" )) + resCode++; + + if (checkStr( zKrGen, "K&R 'C' program" )) + resCode++; + + if (checkStr( argv[1], "Raw shell" )) + resCode++; + + if (checkStr( argv[2], "Cooked shell" )) + resCode++; + + return resCode; +}[= + + == sh + +=]#! /bin/sh +set -x +_EOF_ + +cat 1>&4 <<_EOF_ +./${testname} [=(raw-shell-str (get "string")) + =] [=(shell-str (get "string"))=] > ${testname}.out +res=\$? +cmp ${testname}.out ${testname}.raw > /dev/null 2>&1 + +if [ \$? -ne 0 ] +then + echo the AutoGen internal content did not match expectations + res=\`expr \$res + 1\` +fi +if [ \$res -eq 0 ] +then + echo All string comparisons pass +else + echo There were \$res string test failures + exit \$res +fi[= + +ESAC + +=] +_EOF_ +exec 4>&- + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo creating $testname.def +echo "autogen definitions $testname.tpl;" > $testname.def +cat >> $testname.def <<'_EOF_' + +string = + "'\f\r\b\v\t\a\n +" + '\f\r\b\v\t\a\n +' + '"Wow!" This\'ll be \\hard\\\' +\#endif /* . +' + "and it'll be a \"hassle\"." + "\001\x02\X03\n'"; + +_EOF_ + +# # # # # # # # # # RUN THE TESTS # # # # # # # # # # # + +SHELL=${SHELL-/bin/sh} + +run_ag x $testname.def || failure autogen failed + +compile + +chmod +x *.sh + +./${testname}.sh || failure strings do not match + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of string.test diff --git a/agen5/test/strtable.test b/agen5/test/strtable.test new file mode 100755 index 0000000..8c06e44 --- /dev/null +++ b/agen5/test/strtable.test @@ -0,0 +1,97 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# strtable.test --- test string-table functionality +# +# Time-stamp: "2012-01-07 09:02:42 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating ${testname}.tpl +cat > ${testname}.tpl <<_EOF_ +[= AutoGen5 template test =] +[= + +(string-table-new "scribble") +(out-push-new) ;; redirect output to temporary +(define ct 1) + +=][= + +FOR str IN that was the week that was + +=][= (set! ct (+ ct 1)) =] + [= (string-table-add-ref "scribble" (get "str")) =],[= + +ENDFOR + +=][= + (out-suspend "main") + (emit-string-table "scribble") + (emit (sprintf "\n#define STRING_CT %d\n" (- ct 1))) + (ag-fprintf 0 "\nchar const * const ap[%d] = {" ct) + (out-resume "main") + (out-pop #t) ;; now dump out the redirected output + ;; and finish: =] + NULL }; +_EOF_ + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # +set -x +echo creating ${testname}.base +# this is the output we should expect to see +cat > ${testname}.base <<'_EOF_' + +static char const scribble[18] = +/* 0 */ "that\0" +/* 5 */ "was\0" +/* 9 */ "the\0" +/* 13 */ "week"; + +#define STRING_CT 6 + +char const * const ap[7] = { + scribble+0, + scribble+5, + scribble+9, + scribble+13, + scribble+0, + scribble+5, + NULL }; +_EOF_ + +run_ag x -b ${testname} -T ${testname}.tpl --no-defin || \ + failure autogen failed +cmp -s ${testname}.base ${testname}.test || \ + failure "bad output: `diff -c ${testname}.base ${testname}.test`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of strtable.test diff --git a/agen5/test/strxform.test b/agen5/test/strxform.test new file mode 100755 index 0000000..cdf043a --- /dev/null +++ b/agen5/test/strxform.test @@ -0,0 +1,87 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# strxform.test --- test string transformation functionality +# +# Time-stamp: "2011-02-02 12:02:13 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating ${testname}.tpl +${SED} 's/^ *[0-9]*: //' > ${testname}.tpl <<- _EOTPL_ + 1: [= AutoGen5 Template test =] + 2: string input: [= in-str =] + 3: + 4: string->c-name! [= (string->c-name! (get "in-str")) =] + 5: string-upcase! [= (string-upcase! (get "in-str")) =] + 6: string-capitalize! [= (string-capitalize! (get "in-str")) =] + 7: string-capitalize [= (string-capitalize (get "in-str")) =] + 8: string-downcase! [= (string-downcase! (get "in-str")) =] + 9: string-downcase [= (string-downcase (get "in-str")) =] +10: string->camelcase [= (string->camelcase (get "in-str")) =] +_EOTPL_ + +cat > ${testname}.def <<- _EOF_ + AutoGen Definitions ${testname}.tpl; + in-str = "The 10quick\tfoxes-jumped/very=\n=high9indeed!"; + _EOF_ + +# # # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # +set -x +echo creating ${testname}.out +# this is the output we should expect to see +cat > ${testname}.out <<- \_EOF_ + string input: The 10quick foxes-jumped/very= + =high9indeed! + + string->c-name! The 10quick foxes_jumped_very_ + _high9indeed_ + string-upcase! THE 10QUICK FOXES-JUMPED/VERY= + =HIGH9INDEED! + string-capitalize! The 10quick Foxes-Jumped/Very= + =High9indeed! + string-capitalize The 10quick Foxes-Jumped/Very= + =High9indeed! + string-downcase! the 10quick foxes-jumped/very= + =high9indeed! + string-downcase the 10quick foxes-jumped/very= + =high9indeed! + string->camelcase The10QuickFoxesJumpedVeryHigh9Indeed + _EOF_ + +run_ag x ${testname}.def || failure autogen failed + +cmp -s ${testname}.test ${testname}.out || \ + failure "unexpected output:${nl}`diff ${testname}.out ${testname}.test`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of strxform.test diff --git a/agen5/test/suffix.test b/agen5/test/suffix.test new file mode 100755 index 0000000..55997f5 --- /dev/null +++ b/agen5/test/suffix.test @@ -0,0 +1,90 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# suffix.test --- test the select suffix option +# +# Time-stamp: "2013-03-10 07:10:42 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating ${testname}.tpl +cat > ${testname}.tpl <<'_EOF_' +[= AutoGen5 Template test =] +[= + +CASE (suffix) =][= + +== test =]BOGUS[= +== "* NONE *" =]No Suffix[= +== Example =]Example[= +* =]Bogon ``[=(suffix)=]''[= + +ESAC =] +_EOF_ + +# # # # # # # # # # EXPECTED OUTPUT FILE # # # # # # # + +echo "Example" > ${testname}.Example.test +echo "No Suffix" > ${testname}.stdout.test + +# # # # # # # # # # RUN TESTS # # # # # # # +nodefopt="--no-def -T${testname}.tpl" +run_ag ex ${nodefopt} -oExample -b${testname} || \ + failure autogen ${nodefopt} -oExample -b${testname} + +cmp ${testname}.Example* || \ + failure `diff -c cmp ${testname}.Example*` + +# # # # # # # # # # STDOUT TEMPLATE # # # # # # # # # + +echo creating ${testname}.tpl +cat > ${testname}.tpl <<'_EOF_' +[= AutoGen5 Template =] +[= +text =] +_EOF_ + +cat > ${testname}.samp <<- EOF + This is some text. + This should appear in the output. +EOF + +cat > ${testname}.def <<\EOF +AutoGen Definitions suffix; +text = `cat suffix.samp`; +EOF + +run_ag sfx ${testname}.def | ${EGREP} -v '^in state ' > ${testname}.out +cmp ${testname}.out ${testname}.samp || \ + failure "`diff ${testname}.out ${testname}.samp`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of suffix.test diff --git a/agen5/test/time.test b/agen5/test/time.test new file mode 100755 index 0000000..ad46a38 --- /dev/null +++ b/agen5/test/time.test @@ -0,0 +1,64 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# time.test --- test modification time settings +# +## Time-stamp: "2010-02-24 08:41:34 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoGen. +## AutoGen Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoGen 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 3 of the License, or +## (at your option) any later version. +## +## AutoGen 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, see <http://www.gnu.org/licenses/>. +## +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # + +echo creating ${testname}.tpl +cat > ${testname}.tpl <<_EOF_ +[= AutoGen5 template test =] +Plain text template. +_EOF_ + +touch -t 200109110846.00 ${testname}.tpl + +run_ag time --source-time -b ${testname} -T ${testname}.tpl --no-definitions || \ + failure autogen failed + +touch -t 200109110846.02 ${testname}.taaa + +set -- `ls -t ${testname}.t*` + +while : +do + test "${3}" = ${testname}.tpl || break + test "${2}" = ${testname}.test || break + test "${1}" = ${testname}.taaa || break + cleanup + exit 0 +done + +failure "wrong file time ordering: $*" + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of time.test |