diff options
Diffstat (limited to 'autoopts/test')
28 files changed, 7897 insertions, 0 deletions
diff --git a/autoopts/test/Makefile.am b/autoopts/test/Makefile.am new file mode 100644 index 0000000..ce8ea2d --- /dev/null +++ b/autoopts/test/Makefile.am @@ -0,0 +1,53 @@ +## -*- Mode: Makefile -*- +## +## Makefile.am +## +## Time-stamp: "2012-05-13 16:02:42 bkorb" +## Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + +EXTRA_DIST = defs.in stdopts.def $(TESTS) +TESTS = \ + alias.test argument.test cfg-edit.test cond.test \ + config.test doc.test enums.test equiv.test \ + errors.test getopt.test handler.test immediate.test \ + keyword.test library.test main.test nested.test \ + nls.test rc.test shell.test stdopts.test \ + time.test usage.test vendor.test vers.test + +testsubdir = ./testdir + +TESTS_ENVIRONMENT = TERM='' top_builddir="$(top_builddir)" + +distclean-local: + -rm -rf $(testsubdir) FAILURES + +check : perm-stamp + +perm-stamp : + @-cd $(srcdir) ; chmod +x *.test 2>/dev/null + +verbose : + rm -rf FAILURES testdir ; VERBOSE=true ; export VERBOSE ; \ + $(MAKE) check TESTS="$(TESTS)" + +# Makefile.am ends here diff --git a/autoopts/test/Makefile.in b/autoopts/test/Makefile.in new file mode 100644 index 0000000..a5a0d5b --- /dev/null +++ b/autoopts/test/Makefile.in @@ -0,0 +1,560 @@ +# 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 = autoopts/test +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/defs.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 = defs +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@ +EXTRA_DIST = defs.in stdopts.def $(TESTS) +TESTS = \ + alias.test argument.test cfg-edit.test cond.test \ + config.test doc.test enums.test equiv.test \ + errors.test getopt.test handler.test immediate.test \ + keyword.test library.test main.test nested.test \ + nls.test rc.test shell.test stdopts.test \ + time.test usage.test vendor.test vers.test + +testsubdir = ./testdir +TESTS_ENVIRONMENT = TERM='' top_builddir="$(top_builddir)" +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 autoopts/test/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu autoopts/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): +defs: $(top_builddir)/config.status $(srcdir)/defs.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ + +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 $(testsubdir) FAILURES + +check : perm-stamp + +perm-stamp : + @-cd $(srcdir) ; chmod +x *.test 2>/dev/null + +verbose : + rm -rf FAILURES testdir ; VERBOSE=true ; export VERBOSE ; \ + $(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/autoopts/test/alias.test b/autoopts/test/alias.test new file mode 100755 index 0000000..1cde083 --- /dev/null +++ b/autoopts/test/alias.test @@ -0,0 +1,120 @@ +#! /bin/sh +# +# alias.test --- test option aliasing +# +# Time-stamp: "2012-05-12 19:56:13 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + +. ./defs +failure() { exit 1 ; } +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo "creating ${testname}.def in `pwd`" +testname="${testname}" test_main="YES" \ +argument="arg [...]" long_opts="YES" use_flags=true \ +${SHELLX} ${stdopts} option:'opt init' second=020 || \ + failure "Could not run stdopts.def" +: add defs +cat >> ${testname}.def <<- \_EOF_ + + flag = { + name = a-opt; + value = a; + aliases = option; + }; + + flag = { + name = b-second; + value = b; + aliases = second; + }; + _EOF_ + +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +compile "-?" + +# # # # # # # # # # FIRST TEST # # # # # # # # # + +echo creating ${testname}-1.help +clean_help > ${testname}-1.help <<'_EOF_' +test_alias - Test AutoOpts for alias +USAGE: alias [ -<flag> [<val>] | --<name>[{=| }<val>] ]... arg [...] + Flg Arg Option-Name Description + -o Str option The option option descrip + -s Num second The second option descrip + -a Str a-opt This is an alias for 'option' + -b Num b-second This is an alias for 'second' + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +Options are specified by doubled hyphens and their name or by a single +hyphen and the flag character. +_EOF_ + +cmp -s ${testname}-1.help ${testname}.help || \ + failure "`diff ${testname}-1.help ${testname}.help`" + +./${testname} -o foo -a bar && \ + failure "both -o and -a were accepted" + +./${testname} -a bar fumble > ${testname}.out +cat > ${testname}.base <<- \_EOF_ + OPTION_CT=2 + export OPTION_CT + TEST_ALIAS_OPTION='bar' + export TEST_ALIAS_OPTION + _EOF_ + +cmp -s ${testname}.out ${testname}.base || \ + failure "`diff ${testname}.out ${testname}.base`" + +run_ag als -T agtexi-cmd.tpl ${testname}.def +test -f invoke-test_${testname}.menu || \ + failure "no menu entry output" +rm -f invoke-test_${testname}.menu +test -f invoke-test_${testname}.texi || \ + failure "no texi output" +mv -f invoke-test_${testname}.texi ${testname}.texi + +run_ag als -T agmdoc-cmd.tpl ${testname}.def +test -f test_${testname}.1 || failure "no man page output" +mv test_${testname}.1 ${testname}.1 +lnct=` + ${EGREP} '^This is an alias for the (option|second) option[,.]$' \ + ${testname}.texi ${testname}.1 | \ + wc -l` +test $lnct -eq 4 || \ + failure "bad documentation output" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of cond.test diff --git a/autoopts/test/argument.test b/autoopts/test/argument.test new file mode 100755 index 0000000..ee7fa0d --- /dev/null +++ b/autoopts/test/argument.test @@ -0,0 +1,209 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# argument.test --- test argument program attribute +# make sure that when it is not specified +# then option processing consumes all args. +# +# Time-stamp: "2012-08-11 08:12:41 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo "creating ${testname}.def in `pwd`" +export testname test_main argument long_opts +${SHELLX} ${stdopts} option:'opt init' second=020 || \ + failure "Could not run stdopts.def" + +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +compile "-?" + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +basehlp=${testname}.hlp +echo creating ${basehlp} +clean_help > ${basehlp} <<'_EOF_' +test_argument - Test AutoOpts for argument +USAGE: argument [ -<flag> [<val>] ]... + Flg Arg Option-Name Description + -o Str option The option option descrip + -s Num second The second option descrip + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +_EOF_ + +cmp -s ${testname}.h*lp || \ + failure "`diff ${basehlp} ${testname}.help`" + +./${testname} mumble 2> /dev/null && \ + failure ${testname} should not accept non-options + +./${testname} -s mumble 2> /dev/null && \ + failure ${testname} should not accept bad options + +./${testname} -o string -s 99 > /dev/null || \ + failure ${testname} did not handle its options + +# # # # # # # # # # T E S T 2 # # # # # # # # # # # + +exec 3> ${testname}2.def +${SED} '/arg-type = number/q' ${testname}.def >&3 +cat >&3 <<- _EOF_ + arg-range = "-1"; + arg-range = "3->021"; + arg-range = "040->0x1FFF"; + scaled; + flag-code[0] = ' /* no-op zero */;'; + flag-code[1] = ' /* no-op one */;'; + }; + include = '#include <stdlib.h>'; + _EOF_ +exec 3>&- + +${AG_L} ${testname}2.def || \ + failure AutoGen could not process +{ + ${SED} '/^#if.*TEST MAIN PROCEDURE:/,/#endif.*defined TEST_/d + /^#/s/_ARGUMENT_/_ARGUMENT2_/' \ + ${testname}2.c + cat <<EOF +int main( int argc, char** argv ) { + optionProcess( &test_argumentOptions, argc, argv ); + return 0; } +EOF +} > XX +mv ${testname}2.c ${testname}2.c.save +mv -f XX ${testname}2.c + +Csrc=${testname}2 +compile "-?" + +clean_help > ${testname}2.hlp <<'_EOF_' +test_argument - Test AutoOpts for argument +USAGE: argument2 [ -<flag> [<val>] ]... + Flg Arg Option-Name Description + -o Str option The option option descrip + -s Num second The second option descrip + - is scalable with a suffix: k/K/m/M/g/G/t/T + - It must lie in one of the ranges: + -1 exactly, or + 3 to 17, or + 32 to 8191 + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +_EOF_ + +cmp -s ${testname}2.hlp ${testname}2.help || \ + failure "`diff ${testname}2.hlp ${testname}2.help`" + +./${testname}2 -o string -s 037 > /dev/null && \ + failure ${testname} handled wrong sized option + +./${testname}2 -o string -s 0x37 > /dev/null || \ + failure ${testname} did not handle its options + +./${testname}2 -o string -s 8k > /dev/null || \ + failure ${testname} could not handle 8k + +./${testname}2 -o string -s 8K > ${testname}2-bad.out 2>&1 && \ + failure ${testname} did handle 8K + +${GREP} 'error:.* value .* is out of range\.$' ${testname}2-bad.out || \ + failure "missing 'is out of range' message" + +# # # # # # # # # # T E S T 3 # # # # # # # # # # # + +exec 3> ${testname}3.def +${SED} '/value = .s.;/q' ${testname}.def >&3 +cat >&3 <<- _EOF_ + arg-type = file; + file-exists = yes; + open-file = fopen; + file-mode = "r"; + }; + _EOF_ +exec 3>&- + +${AG_L} ${testname}3.def || \ + failure AutoGen could not process +{ + ${SED} '/^#if.*TEST MAIN PROCEDURE:/,/#endif.*defined TEST_/d + /^#/s/_ARGUMENT_/_ARGUMENT3_/' \ + ${testname}3.c + cat <<EOF +int main( int argc, char** argv ) { + optionProcess( &test_argumentOptions, argc, argv ); + for (;;) { int ch = getc(OPT_VALUE_SECOND); + if (ch == EOF) break; + putc(ch, stdout); } + return fclose(OPT_VALUE_SECOND); } +EOF +} > XX +mv ${testname}3.c ${testname}3.c.save +mv -f XX ${testname}3.c + +Csrc=${testname}3 +compile "-?" + +clean_help > ${testname}3.hlp <<'_EOF_' +test_argument - Test AutoOpts for argument +USAGE: argument3 [ -<flag> [<val>] ]... + Flg Arg Option-Name Description + -o Str option The option option descrip + -s Fil second The second option descrip + - file must pre-exist + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +_EOF_ + +cmp -s ${testname}3.hlp ${testname}3.help || \ + failure "`diff ${testname}3.hlp ${testname}3.help`" + +./${testname}3 -o string -s `pwd`/bogusfilename.c > /dev/null && \ + failure ${testname} handled non-existent file + +./${testname}3 -o string -s `pwd`/${testname}3.hlp > ${testname}3-a.hlp || \ + failure ${testname} could not handle existing file + +cmp -s ${testname}3.hlp ${testname}3-a.hlp || \ + failure "`diff ${testname}3.hlp ${testname}3-a.hlp`" +# # # # # # # # # # T E S T E N D # # # # # # # # # # + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of argument.test diff --git a/autoopts/test/cfg-edit.test b/autoopts/test/cfg-edit.test new file mode 100755 index 0000000..506ca10 --- /dev/null +++ b/autoopts/test/cfg-edit.test @@ -0,0 +1,330 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# rc.test --- test loading and saving of rc files +# +# Time-stamp: "2012-03-31 13:10:38 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +test_name=`echo ${testname} | ${SED} 's/-/_/g'` +cfg_file=`basename ${TMPDIR}`/${testname}.cfg + +exec 5> ${testname}.def +cat >&5 <<- _EOF_ + + AutoGen definitions options; + + config-header = 'config.h'; + prog-name = "test_${testname}"; + prog-title = "Test AutoOpts for ${testname}"; + homerc = ${cfg_file}; + resettable; + argument = '[ <output-config-file> ]'; + + flag = { + name = struct; + value = s; + max = NOLIMIT; + descrip = 'structured argument val'; + arg-type = nested; + }; + + flag = { + name = members; + value = m; + descrip = 'membership set'; + keyword = one, two, three, four, five, six, seven, eight, nine, ten; + arg-default = five; + arg-type = set; + }; + + flag = { + name = enumerate; + value = e; + descrip = 'a test enumeration'; + keyword = uno, dos, tres, quatro, cinco, seis, siete, ocho; + arg-default = cinco; + arg-type = keyword; + }; + + flag = { + name = stacking; + value = k; + descrip = 'stack up a list'; + arg-default = initialized; + arg-type = string; + stack-arg; max = NOLIMIT; + }; + + flag = { + name = number; + value = n; + descrip = 'a range constrained int'; + arg-default = 32; + arg-type = number; + arg-range = '->-1', '1->31', '33', '64->'; + }; + + flag = { + name = boolean; + value = b; + descrip = 'a boolean value'; + arg-default = true; + arg-type = boolean; + }; + + flag = { + name = in-file; + value = I; + descrip = 'an input file'; + arg-type = file; + open-file = descriptor; + file-mode = O_RDONLY; + file-exists = yes; + }; + + flag = { + name = out-file; + value = O; + descrip = 'an output file'; + arg-type = file; + open-file = fopen; + file-mode = w; + file-exists = no; + }; + + flag = { + name = test-file; + value = T; + descrip = 'a test file'; + arg-type = file; + }; + + main = { + main-type = main; + _EOF_ + +asl='<''<' +cat >&5 <<- _EOF_ + main-text = ${asl}- _EOCode_ + { + tOptions * const pOpts = &test_${test_name}Options; + int svix = pOpts->specOptIdx.save_opts; + char const * pzFile = "${cfg_file}-default"; + + if (argc > 0) + pzFile = *argv; + if (svix == 0) exit(1); + SET_OPT_SAVE_OPTS(pzFile); + optionSaveFile(pOpts); + } + _EOF_ + +echo "_EOCode_; };" >&5 + +exec 5>&- + +# # # # # # # # # # CREATE PROGRAM # # # # # # # # # + +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +compile "-?" + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +basehelp=${testname}-base.help +echo creating ${basehelp} +clean_help > ${basehelp} <<_EOF_ +test_${testname} - Test AutoOpts for ${testname} +USAGE: ${testname} [ -<flag> [<val>] ]... [ <output-config-file> ] + Flg Arg Option-Name Description + -s Cpx struct structured argument val + - may appear multiple times + -m Mbr members membership set + - is a set membership option + -e KWd enumerate a test enumeration + -k Str stacking stack up a list + - may appear multiple times + -n Num number a range constrained int + - It must lie in one of the ranges: + less than or equal to -1, or + 1 to 31, or + 33 exactly, or + greater than or equal to 64 + -b T/F boolean a boolean value + -I Fil in-file an input file + - file must pre-exist + -O Fil out-file an output file + - file must not pre-exist + -T Fil test-file a test file + -R Str reset-option Reset an option's state + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + -> opt save-opts Save the option state to a config file + -< Str load-opts Load options from a config file + - disabled as --no-load-opts + - may appear multiple times + + +The following option preset mechanisms are supported: + - reading file ${testname}.cfg + +The valid "members" option keywords are: + one two three four five six seven eight nine ten + or an integer mask with any of the lower 10 bits set +or you may use a numeric representation. Preceding these with a '!' will +clear the bits, specifying 'none' will clear all bits, and 'all' will set them +all. Multiple entries may be passed as an option argument list. +The valid "enumerate" option keywords are: + uno dos tres quatro cinco seis siete ocho + or an integer from 0 through 7 +_EOF_ + +${SED} "/ - reading file/s/ file .*/ file ${testname}.cfg/" \ + ${testname}.help > X$$ +mv -f X$$ ${testname}.help +cmp -s ${basehelp} ${testname}.help || \ + failure "`diff ${basehelp} ${testname}.help`" + +./${testname} -m 'one + three + seven' '->' +members=`${SED} -n 's/^members *//p' ${cfg_file}` +case "${members}" in +'none + one + three + five + seven' ) : ;; +* ) failure "members not set to one, three, five and seven" ;; +esac + +./${testname} -R '*' '->' +members=`${SED} -n 's/^members *//p' ${cfg_file}` 2>/dev/null +case "${members}" in +'' ) : ;; +* ) failure "members entry not removed" +esac + +arg1="stumble, <foo>foo${ht}lish</foo>, <bar type=integer>1234</bar>, able" +arg2='foo, <bar type=integer>4321</bar> <gr type=nested>one, two=2, three</gr>' +dir=`echo ${TMPDIR} | ${SED} "s@^\`pwd\`//*@@"` +out_file=${dir}/${testname}-out-file +rm -f ${out_file} +./${testname} -m 'one + three' -b true -m 'seven' \ + -s "${arg1}" -n -200 -s "${arg2}" -e ocho \ + -I ${srcdir}/${testname}.test \ + -O ${out_file} \ + -T ${dir}/${testname}-test-file \ + '->' +${SED} '/^#/d' ${cfg_file} > ${testname}-X +mv -f ${testname}-X ${cfg_file} +cat > ${testname}.sample-cfg <<- \_EOF_ + <struct type=nested> + <able/> + <bar type=integer>0x4D2</bar> + <foo>foo	lish</foo> + <stumble/> + </struct> + <struct type=nested> + <bar type=integer>0x10E1</bar> + <foo/> + <gr type=nested> + <one/> + <three/> + <two>2</two> + </gr> + </struct> + members none + one + three + five + seven + enumerate ocho + number -200 + boolean true + _EOF_ + +cat >> ${testname}.sample-cfg <<- _EOF_ + in-file ${srcdir}/${testname}.test + out-file ${out_file} + test-file ${dir}/${testname}-test-file + _EOF_ +pair=${testname}.sample-cfg\ ${cfg_file} +cmp ${pair} || \ + failure "improperly saved state:${nl}`diff ${pair}`" + +rm -f ${out_file} +./${testname} ${cfg_file}-2 +${SED} '/^#/d' ${cfg_file}-2 > ${testname}-X +mv -f ${testname}-X ${cfg_file}-2 +cmp ${cfg_file} ${cfg_file}-2 || \ + failure "mismatched: re-saved config${nl}`diff ${cfg_file} ${cfg_file}-2`" + +rm -f ${cfg_file}-2 +rm -f ${out_file} +./${testname} -R struct ${cfg_file}-2 +test "X`egrep -v '^#' ${cfg_file}-2`" = "X`egrep '^[a-z]' ${cfg_file}`" || \ + failure "structure not erased${nl}`cat ${cfg_file}-2`" + +opt_ct=7 +mv -f ${cfg_file}-2 ${cfg_file} +ct=`egrep '^[a-z]' ${cfg_file} | wc -l` +test ${ct} -eq ${opt_ct} || failure "wrong line count${nl}`cat ${cfg_file}`" + +rm -f ${out_file} + +remove_opt() { + opt_ct=`expr $opt_ct - 1` + ./${testname} -R ${1} '->' + ct=`egrep '^[a-z]' ${cfg_file} | wc -l` + test ${ct} -eq ${opt_ct} || \ + failure "${1} is still there${nl}`cat ${cfg_file}`" +} + +for f in out-file in-file test-file boolean members enumerate number +do + remove_opt $f +done + +./${testname} -k alpha -k beta -k omega ${cfg_file}-XX +${SED} '/^#/d' ${cfg_file}-XX > ${cfg_file}-2 +cat > ${cfg_file}-3 <<- _EOF_ + stacking alpha + stacking beta + stacking omega + _EOF_ +cmp ${cfg_file}-[23] || \ + failure "missing stacking args:${nl}`diff -c ${cfg_file}-[23]`" +./${testname} -R k ${cfg_file}-2 +ct=`egrep '^[a-z]' ${cfg_file}-2 | wc -l` +test ${ct} -eq 0 || failure "arg values still stacked" + +# # # # # # # # # # TEST OPERATION # # # # # # # # # # + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of cfg-edit.test diff --git a/autoopts/test/cond.test b/autoopts/test/cond.test new file mode 100755 index 0000000..8767eda --- /dev/null +++ b/autoopts/test/cond.test @@ -0,0 +1,194 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# cond.test --- test conditionally compiled option +# +# Time-stamp: "2012-03-31 13:09:15 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo "creating ${testname}.def in `pwd`" +testname="${testname}" test_main="${test_main}" \ +argument="${argument}" long_opts="${long_opts}" \ +${SHELLX} ${stdopts} option:'opt init' second=020 || \ + failure "Could not run stdopts.def" +cat >> ${testname}.def <<EOF +flag = { + name = condition; + value = c; + ifdef = COND; + descrip = "cond test"; + arg-type = number; + doc = mumble; +}; + +flag = { + name = interfere; + value = I; + descrip = "cond interference test"; + arg-type = number; + doc = stumble; +}; +EOF +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +# # # # # # # # # # FIRST TEST # # # # # # # # # + +compile "-?" +mv ${testname} ${testname}-1 +echo creating ${testname}-1.help +clean_help > ${testname}-1.help <<'_EOF_' +test_cond - Test AutoOpts for cond +USAGE: cond [ -<flag> [<val>] ]... + Flg Arg Option-Name Description + -o Str option The option option descrip + -s Num second The second option descrip + -I Num interfere cond interference test + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +_EOF_ + +cmp -s ${testname}-1.help ${testname}.help || \ + failure "TEST 1 FAILED${nl}`diff ${testname}-1.help ${testname}.help`" + +./${testname}-1 -c 123 2>/dev/null && \ + failure "*DID* process -c option" + +# # # # # # # # # # SECOND TEST # # # # # # # # # + +INC="${INC} -DCOND=1" +compile "-?" +mv ${testname} ${testname}-2 +clean_help > ${testname}-2.help <<'_EOF_' +test_cond - Test AutoOpts for cond +USAGE: cond [ -<flag> [<val>] ]... + Flg Arg Option-Name Description + -o Str option The option option descrip + -s Num second The second option descrip + -c Num condition cond test + -I Num interfere cond interference test + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +_EOF_ + +cmp -s ${testname}-2.help ${testname}.help || \ + failure "TEST 2 FAILED${nl}`diff ${testname}-2.help ${testname}.help`" + +# # # # # # # # # # THIRD TEST # # # # # # # # # + +echo guard-option-names\; >> ${testname}.def +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || failure AutoGen could not process + +( cc_cmd=`echo ${cc_cmd} | \ + ${SED} "s/-DTEST_TEST/-DSECOND -DTEST_TEST/" ` + eval "$cc_cmd" 2>&1 ) \ + | ${SED} -n '/undefining SECOND due to option name conflict/p' \ + > ${testname}-cc.log + +test -s ${testname}-cc.log || \ + failure "warning diffs: 'undefining SECOND' not found" + +# # # # # # # # # # FOURTH TEST # # # # # # # # # + +${SED} '/value = c/s/$/ deprecated;/' ${testname}.def > ${testname}.def4 + +echo ${AG_L} ${testname}.def4 +${AG_L} ${testname}.def4 || \ + failure AutoGen could not process ${testname}.def4 + +compile "-?" +mv ${testname} ${testname}-4 +cmp -s ${testname}-1.help ${testname}.help || \ + failure "TEST 4 FAILED${nl}`diff ${testname}-1.help ${testname}.help`" + +./${testname}-4 -c 123 || \ + failure "could not process -c option" + +# # # # # # # # # # FIFTH TEST # # # # # # # # # + +${SED} '/deprecated/s/deprecated.*/arg-range = "0->1000";/' \ + ${testname}.def4 > ${testname}.def5 + +echo ${AG_L} ${testname}.def5 +${AG_L} ${testname}.def5 || \ + failure AutoGen could not process ${testname}.def5 + +compile "-?" +mv ${testname} ${testname}-5 +clean_help > ${testname}-5.help <<'_EOF_' +test_cond - Test AutoOpts for cond +USAGE: cond [ -<flag> [<val>] ]... + Flg Arg Option-Name Description + -o Str option The option option descrip + -s Num second The second option descrip + -c Num condition cond test + - It must be in the range: + 0 to 1000 + -I Num interfere cond interference test + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +_EOF_ + +cmp -s ${testname}-5.help ${testname}.help || \ + failure "TEST 5 FAILED${nl}`diff -u ${testname}-5.help ${testname}.help`" + +# # # # # # # # # # SIXTH TEST # # # # # # # # # + +INC=`echo ${INC} | sed 's/ -DCOND=1//'` +compile "-?" +mv ${testname} ${testname}-6 +clean_help > ${testname}-6.help <<'_EOF_' +test_cond - Test AutoOpts for cond +USAGE: cond [ -<flag> [<val>] ]... + Flg Arg Option-Name Description + -o Str option The option option descrip + -s Num second The second option descrip + -I Num interfere cond interference test + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +_EOF_ + +cmp -s ${testname}-6.help ${testname}.help || \ + failure "TEST 6 FAILED${nl}`diff -u ${testname}-6.help ${testname}.help`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of cond.test diff --git a/autoopts/test/config.test b/autoopts/test/config.test new file mode 100755 index 0000000..d8b6280 --- /dev/null +++ b/autoopts/test/config.test @@ -0,0 +1,201 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# rc.test --- test loading and saving of rc files +# +# Time-stamp: "2011-02-02 12:10:27 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- +. ./defs + +# # # # # # # # # # PROGRAM FILE # # # # # # # # # + +cat > ${testname}.c <<- _EOTest_ + #include <stdio.h> + #include "config.h" + #include <autoopts/options.h> + + int print_entry( const tOptionValue* pGV ); + int print_entry( const tOptionValue* pGV ) { + if (pGV == NULL) { + fprintf( stderr, "ENTRY NOT FOUND\n" ); + return 1; + } + printf( "%-8s -- ", pGV->pzName ); + switch (pGV->valType) { + case OPARG_TYPE_NONE: + fputs( "no value\n", stdout ); break; + + case OPARG_TYPE_STRING: + printf( "string: %s\n", pGV->v.strVal ); break; + + case OPARG_TYPE_ENUMERATION: + printf( "enum: %d\n", pGV->v.enumVal ); break; + + case OPARG_TYPE_BOOLEAN: + printf( "bool: %s\n", + pGV->v.boolVal ? "TRUE" : "false" ); break; + + case OPARG_TYPE_MEMBERSHIP: + printf( "members: 0x%08lX\n", (unsigned long)pGV->v.setVal ); break; + + case OPARG_TYPE_NUMERIC: + printf( "integer: %ld\n", pGV->v.longVal ); break; + + case OPARG_TYPE_HIERARCHY: + printf( "nested: 0x%08lX\n", (unsigned long)pGV->v.nestVal ); break; + + default: + printf( "bad type: %d\n", pGV->valType ); + return 1; + } + return 0; + } + + int main( int argc, char** argv ) { + int res = 0; + const tOptionValue* pOV; + if ((argc < 3) || (argv[1][0] == '-')) { + fputs( "help\n", stdout ); + return 0; + } + pOV = configFileLoad( *++argv ); + if (pOV == NULL) { + fprintf( stderr, "Could not load: %s\n", *argv ); + return 1; + } + argc -= 2; + while (argc-- > 0) { + const tOptionValue* pGV = optionGetValue( pOV, *++argv ); + res |= print_entry( pGV ); + } + + { + const tOptionValue* pGV = optionGetValue( pOV, "n4_ty" ); + pGV = optionGetValue( pGV, "b4r" ); + if (pGV->valType != OPARG_TYPE_BOOLEAN) { + res = 1; + } else if (pGV->v.boolVal) { + fputs( "YES!!\n", stdout ); + } else { + fputs( "oops!!\n", stdout ); + res = 1; + } + } + + { + const tOptionValue* pGV = optionGetValue( pOV, NULL ); + while (pGV != NULL) { + res |= print_entry( pGV ); + pGV = optionNextValue( pOV, pGV ); + } + } + + print_entry( pOV ); + optionUnloadNested( pOV ); + return res; + } + _EOTest_ + +compile --help + +# # # # # # # # # # RUN TESTS # # # # # # # # # + +echo Constructing test ${testname} files +cat > ${testname}.cfg <<- \_EOConfig_ + mumble = grumble + grumble : rumble + + stumble "The\tquick\ + brown fox\tjumped\n\ + over everything." + + stumble2 The\ + quick\ + brown\ + \ + fix. + + <n4_ty type=nested> + foo : foolish + <b4r type=bool> YES!! </b4r> + </n4_ty> + alpha, beta ', gamma' + <beta cooked> "Carol\tTine\n" + </beta> + <zzyzx type=integer> 42 </zzyzx> + _EOConfig_ + +cat > ${testname}.res <<- \_EOResult_ + mumble -- string: grumble + grumble -- string: rumble + stumble -- string: The quickbrown fox jumped + over everything. + alpha -- no value + beta -- string: , gamma + zzyzx -- integer: 42 + YES!! + alpha -- no value + beta -- string: , gamma + beta -- string: Carol Tine + + grumble -- string: rumble + mumble -- string: grumble + n4_ty -- nested: 0xXXXXXXXX + stumble -- string: The quickbrown fox jumped + over everything. + stumble2 -- string: The + quick + brown + + fix. + zzyzx -- integer: 42 + ./config.cfg -- nested: 0xXXXXXXXX + _EOResult_ + +./${testname} ./${testname}.cfg mumble grumble stumble alpha beta zzyzx \ + > ${testname}.tmp-out || { + failure "Cannot run ${testname}" +} + +${SED} '/ -- nested:/s/0x.*/0xXXXXXXXX/' \ + ${testname}.tmp-out > ${testname}.out +cmp ${testname}.out ${testname}.res || { + failure "`diff -c ${testname}.out ${testname}.res`" +} + +./${testname} ${testname}.cfg gamma >/dev/null && \ + failure "found non-existent value" + +# # # # # # # # # # CLEANUP # # # # # # # # # + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of config.test diff --git a/autoopts/test/defs.in b/autoopts/test/defs.in new file mode 100644 index 0000000..d7669ab --- /dev/null +++ b/autoopts/test/defs.in @@ -0,0 +1,351 @@ +#! /bin/echo this_file_should_be_sourced,_not_executed +# -*- Mode: Shell-script -*- +# +# defs --- define the environment for autogen tests. +# +# Time-stamp: "2012-05-13 16:02:07 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# +# C O N F I G U R E D V A L U E S +# +# Make sure srcdir is an absolute path. Supply the variable +# if it does not exist. We want to be able to run the tests +# stand-alone!! +# +cfg_vals() +{ + case `uname -s` in + SunOS ) + if test "X$BASH_VERSION" = X + then + # On Solaris, make certain we do not use /bin/sh + sh=`which bash` + test "X$sh" = X && sh=/usr/xpg4/bin/sh + BASH_VERSION=not-good-enough + export BASH_VERSION + exec $sh "$0" "$@" + fi + ;; + esac + + script_name=$1 + set -a + . ${top_builddir}/config/shdefs + progname=`echo "$script_name" | ${SED} 's,^.*/,,'` + testname=`echo "$progname" | ${SED} 's,\..*$,,'` + test_name=`echo ${testname} | ${SED} 's/-/_/g'` + PS4=">${testname}-\${FUNCNAME}> " + test -z "$srcdir" && exit 1 + srcdir=`cd $srcdir >/dev/null && pwd` + ( exec 2>/dev/null; ulimit -c unlimited ) && \ + ulimit -c unlimited + + test -z "${CFLAGS}" && CFLAGS='@CFLAGS@' + CFLAGS="${CFLAGS} @DEFS@" + test -z "${testsubdir}" && testsubdir=testdir + test -z "${PAGER}" && PAGER=more + nl=' +' ht=' ' + + stdopts=${top_srcdir}/autoopts/test/stdopts.def + test_main=yes + use_flags=true + sed_omit_license="/-\*- buffer-read-only:/,/^ \*\//d" + TERM='' + set +a + + ( + test_local() { + local local_works=yes + } + test_local + ) || eval 'local() { : ; }' + + vars=`set | ${SED} -n '/^\(LANG\|LC_[A-Z_]*\)=/s/=.*//p'` 2>/dev/null + test "X$vars" = X || unset $vars +} + +# If only the "rm(1)" command could be relied upon.... +# +purge() +{ + rm -rf ${*} 2>/dev/null + bad='' + for f + do test -f ${f} -o -d ${f} && bad="${bad} ${f}" + done + test -z "$bad" && return 0 + + set -- $bad + test "x${RANDOM}" = "x${RANDOM}" && RANDOM=`expr 0${RANDOM} + 1 2>/dev/null` + + f=ZZPURGE-${1}-${RANDOM}-$$ + if test $# -gt 1 + then mkdir ${f} + mv $* ${f}/. + else mv $1 ${f} + fi +} + +init_tests() +{ + logfile=`pwd`/testdir/${testname}.log + exec 8>&2 1>${logfile} 2>&1 + + TMPDIR=`pwd`/testdir/${testname}-tmpd + mkdir ${TMPDIR} + + f=`\cd ${LIBGUILE_PATH}/../bin && pwd` + PATH=${f}:${PATH} + echo PATH is ${PATH} >&2 + + builddir=`pwd` + testsubdir=testdir + CFLAGS=`echo ${CFLAGS} | \ + ${SED} "s/-Werror[^ ${ht}]*//g;s/-Wextra//g"` + + lo_dir=${top_builddir}/autoopts + test -d ${lo_dir}/.libs && lo_dir=${lo_dir}/.libs + test "X${LD_LIBRARY_PATH}" = X || LD_LIBRARY_PATH=:${LD_LIBRARY_PATH} + LD_LIBRARY_PATH=${lo_dir}:${LIBGUILE_PATH}${LD_LIBRARY_PATH} + + case ${AG_VERSION} in + *pre* ) GUILE_WARN_DEPRECATED=detailed ;; + * ) GUILE_WARN_DEPRECATED=no ;; + esac + + case "$LIB" in + *-lgen* ) : ;; + * ) + for f in /usr/lib*/libgen.so /lib*/libgen.so + do + test -f $f && { + LIB="${LIB} -lgen" + break + } + done + ;; + esac + lo_lib=`find ${lo_dir} -type f -name libopts*.${OBJEXT}` + LIB="${lo_lib} ${LIB}" + + AG_L=run_ag\ ao + agl_opts="-L${top_builddir}/autoopts/tpl -L${top_srcdir}/autoopts/tpl" + + export TMPDIR PATH LD_LIBRARY_PATH \ + GUILE_WARN_DEPRECATED LIB AG_L agl_opts \ + CC LIBGUILE AG_VERSION +} + +be_silent() +{ + setx=: + VERBOSE=false + purge testdir + + # Sometimes, MSDos FS cannot even rename the directory!! + # + if test -d testdir + then purge testdir/* testdir/.??* + else msg=echo + mkdir testdir || exit 1 + fi + + run_ag() + { + local opts='' + shift + + case " $* " in + *' -L'* ) : ;; + * ) opts="${agl_opts}" ;; + esac + + ${AGexe} ${opts} "$@" + } + + init_tests +} + +be_verbose() +{ + set -x + setx='set -x' + msg=: + VERBOSE=true + test -d testdir || mkdir testdir || exit 1 + + run_ag() + { + local tfile=${testname}-aglog-${1}-$$.log + shift + local opts='' + local tr="--trace=every --trace-out=>>${tfile}" + + case " $* " in + *' -L'* ) : ;; + * ) opts="${agl_opts}" ;; + esac + + MALLOC_CHECK_=2 \ + ${AGexe} ${opts} ${tr} "$@" + } + + init_tests +} + +cfg_inc() +{ + cd testdir || { + echo "Cannot make or change into testdir" >&8 + exit 1 + } + testsubdir=`pwd` + + dirs=` + for f in ${top_builddir} ${top_srcdir} + do + for d in . autoopts agen5 + do + cd $f/$d + pwd >&9 + cd - + done 9>&1 1>/dev/null + done | sort -u | ${SED} 's/^/-I/'` + + INC=`echo ${dirs} ${CPPFLAGS}` + + : "=== Running $progname for ${testname} using ${SHELL} ===" + chmod +w * > /dev/null 2>&1 || : + ${VERBOSE} && SHELLX="${SHELL} -x" || SHELLX="${SHELL}" +} + +clean_help() { + test -z "$sedcmd" && s= || s="${sedcmd}${nl}" + s="${s}/^Packaged by/d${nl}" + s="${s}/^Report .* bugs to/d${nl}" + s="${s}/[Pp]lease send bug reports/d${nl}" + s="${s}/^[ ${ht}]*\$/d" + + ${SED} "${s}" +} + +compile() +{ + ${setx} + test "X${Csrc}" = "X" && Csrc="${testname}" + test "X${Cexe}" = "X" && Cexe="${Csrc}" + test "X${Dnam}" = "X" && Dnam="${testname}" + + d=`echo TEST_TEST_${Dnam}_OPTS | /usr/bin/tr '[a-z]-' '[A-Z]_'` + cc_cmd="${CC} ${CFLAGS} -D$d ${INC} -o ${Cexe} ${Csrc}.c ${LIB}" + eval ${cc_cmd} || \ + failure cannot compile ${Csrc}.c + if test $# -gt 0 + then + ./${Cexe} ${*} ${dosed} || \ + failure cannot obtain help output for ${Csrc} + fi | clean_help > ${Csrc}.help + Csrc='' Cexe='' Dnam='' +} + +cleanup() +{ + trap '' 15 + ${setx} + ${VERBOSE} || { + cd ${builddir} + purge testdir + test -d testdir && mv testdir ZZJUNK-$$ + } + ${msg} ${testname} done +} + +# A standard failure function +# +failure() +{ + trap '' 15 + ${setx} + cd ${testsubdir} + if test -d ../FAILURES + then ( \cd ../FAILURES ; purge -rf ${testname}* .*${testname}* ) + else mkdir ../FAILURES ; fi + + exec > /dev/tty 2>&8 + cat ${logfile} >&2 + + { + mv -f ${testname}* .*${testname}* ../FAILURES || : + } 2>/dev/null + for f in core* + do test -f ${f} && mv -f ${f} ../FAILURES/${testname}-${f} ; done + + echo FAILURE: "$*" >&8 + exit 1 +} + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + +cfg_vals $0 + +case "${VERBOSE}" in +'' | [Nn]* | 0 | [Ff]* ) + be_silent ;; + +[Yy]* | [0-9] | [Tt]* ) + be_verbose ;; + +* ) + case "$-" in + *x* ) be_verbose ;; + * ) be_silent ;; + esac +esac + +cfg_inc + +trap "failure 'test ${testname} killed on timeout'" 15 +( ( exec > /dev/null 2>&1 </dev/null + test -z "${kill_delay}" && kill_delay=3 + kill_delay=`expr $kill_delay '*' $AG_TIMEOUT` + sleep ${kill_delay} + ps -p $$ || exit + kill -15 $$ + sleep 1 + ps -p $$ || exit + mv -f `dirname $logfile` ${builddir}/FAILED-${testname} + kill -9 $$ +) & +) + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# defs.in ends here diff --git a/autoopts/test/doc.test b/autoopts/test/doc.test new file mode 100755 index 0000000..d0c2989 --- /dev/null +++ b/autoopts/test/doc.test @@ -0,0 +1,848 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# +# doc.test --- test doc templates +# +# Time-stamp: "2012-08-11 08:54:27 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +# +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + +. ./defs + +test_src=${srcdir}/${testname}.test + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # +echo make defs from test file +sed "1,/^##* *BEGIN-DEFS/d + /^prog-name/s/=.*/= ${testname};/ + \\@^// *END-DEFS@q" \ + ${test_src} > ${testname}.def + +# # # # # # # # # # TEXI DOC CHECK # # # # # # # # # +${AGexe} ${agl_opts} -Tagtexi-cmd ${testname}.def +test -f invoke-${testname}.menu -a -f invoke-${testname}.texi || \ + failure "invoke-${testname}.{menu,texi} not built" +sed '/^@ignore/,/^@end ignore/d' \ + invoke-${testname}.texi > ${testname}-res.texi +rm -f invoke-${testname}.menu invoke-${testname}.texi + +sed "1,/^##* *BEGIN-TEXI/d + /^@ignore/,/^@end ignore/d + /^## END-TEXI/{;s/.*//;q;}" \ + ${test_src} > ${testname}-base.texi + +outfiles="${testname}-res.texi ${testname}-base.texi" +cmp -s ${outfiles} || \ + failure "Differences: ${outfiles}${nl}`diff ${outfiles}`" + +# # # # # # # # # # MAN DOC CHECK # # # # # # # # # +${AGexe} ${agl_opts} -Tagman-cmd ${testname}.def +test -f ${testname}.1 || \ + failure "${testname}.1 not built" + +{ + sed '/^\.\\"/d;/^\.TH/s/ *".*//' ${testname}.1 + rm -f ${testname}.1 + echo +} > ${testname}-res.1 + +sed "1,/^##* *BEGIN-MAN/d + /^## END-MAN/{;s/.*//;q;}" ${test_src} > ${testname}-base.1 + +outfiles="${testname}-base.1 ${testname}-res.1" +cmp -s ${outfiles} || \ + failure "Differences: ${outfiles}${nl}`diff ${outfiles}`" + +# # # # # # # # # # MDOC DOC CHECK # # # # # # # # # +${AGexe} ${agl_opts} -Tagmdoc-cmd ${testname}.def +test -f ${testname}.1 || \ + failure "${testname}.1 not built" + +{ + ${EGREP} -v '^\.(Dd |Os |\\")' ${testname}.1 + echo +} > ${testname}-mdoc-res.1 + +sed "1,/^##* *BEGIN-MDOC/d + /^## END-MDOC/{;s/.*//;q;}" ${test_src} > ${testname}-mdoc-base.1 + +outfiles="${testname}-mdoc-base.1 ${testname}-mdoc-res.1" +cmp -s ${outfiles} || \ + failure "Differences: ${outfiles}${nl}`diff ${outfiles}`" + +# # # # # # # # # # POT CHECK # # # # # # # # # +${AGexe} ${agl_opts} -Tdef2pot ${testname}.def +test -s ${testname}.pot || \ + failure "${testname}.pot not built" + +{ + sed -e '/^# *Copyright/s/).*/)/' \ + -e '/^$/d' \ + -e 's/>, 20[0-9][0-9]\./>./' \ + -e '/POT-Creation-Date:/s/ 2[0-9].*/\\n"/' \ + ${testname}.pot + echo +} > ${testname}-res.pot + +sed "1,/^##* *BEGIN-POT/d + /^$/d + /^## END-POT/{;s/.*//;q;}" ${test_src} > ${testname}-base.pot + +outfiles="${testname}-base.pot ${testname}-res.pot" +cmp -s ${outfiles} || \ + failure "Differences: ${outfiles}${nl}`diff ${outfiles}`" + +# # # # # # # # # # # FINISH # # # # # # # # # # # + +cleanup + +exit 0 + +# # # # # # # # # # # OPTION DEFS + +cat <<_End_Of_Definitions_ +## BEGIN-DEFS +AutoGen Definitions options; +prog-name = gnutls-cli; +prog-title = "GnuTLS client"; +prog-desc = "Simple client program to set up a TLS connection."; +short-usage = <<- _EOUsage_ + Usage: gnutls-cli [options] hostname + gnutls-cli --help for usage instructions. + _EOUsage_; +prog-group = "GnuTLS"; +detail = <<- _EODetail_ + Simple client program to set up a TLS connection to some other computer. + It sets up a TLS connection and forwards data from the standard input + to the secured socket and vice versa. + _EODetail_; + +gnu-usage; +no-misuse-usage; +disable-save; +reorder-args; +no-xlate = opt; +argument = "[hostname]"; +long-opts; + +copyright = { + date = "2000-2012"; + owner = "Free Software Foundation"; + author = "Nikos Mavrogiannopoulos, Simon Josefsson and others; " + "see /usr/share/doc/gnutls-bin/AUTHORS for a complete list."; + eaddr = "bug-gnutls@gnu.org"; + type = gpl; +}; +version = "3.0.12"; +help-value = h; +more-help-value = M; + +flag = { + name = debug; + value = d; + arg-type = number; + arg-range = "0->9999"; + descrip = "Enable @code{debugging}"; + doc = 'really enable debugging'; +}; + +flag = { + name = mtu; + arg-type = number; + arg-range = "0->17000"; + descrip = "Set MTU for datagram TLS"; + doc = "Really set MTU for datagram TLS"; +}; + +flag = { + name = group-2; + descrip = "second group of options"; + documentation; +}; + +flag = { + name = crlf; + descrip = "Send CR LF instead of LF"; + doc = "Really send CR LF instead of LF"; +}; + +flag = { + name = x509fmtder; + descrip = "Use DER format for certificates to read from"; + doc = "Really use DER format for certificates to read from"; +}; + +flag = { + name = group-3; + descrip = "third group of options"; + documentation; +}; + +flag = { + name = recordsize; + arg-type = number; + arg-range = "0->4096"; + descrip = "The maximum record size to advertize"; + doc = "Really the maximum record size to advertize"; +}; + +flag = { + name = priority; + arg-type = string; + descrip = "Priorities string"; + doc = <<- _EODoc_ + TLS algorithms and protocols to enable. You can + use predefined sets of ciphersuites such as PERFORMANCE, + NORMAL, SECURE128, SECURE256. + + Check the GnuTLS manual on section ``Priority strings'' for more + information on allowed keywords + _EODoc_; +}; + + +doc-section = { + ds-type = 'SEE ALSO'; + ds-format = texi; + omit-texi; + ds-text = 'gnutls-cli-debug(1), gnutls-serv(1)'; +}; + +doc-section = { + ds-type = EXAMPLES; + ds-format = texi; + ds-text = <<- _EOT_ + To connect to a server using PSK authentication, you need to enable + the choice of PSK by using a cipher priority parameter such as in the + example below. + @example + $ ./gnutls-cli -p 5556 localhost --pskusername psk_identity \\ + --pskkey 88f3824b3e5659f52d00e959bacab954b6540344 \\ + --priority NORMAL:-KX-ALL:+ECDHE-PSK:+DHE-PSK:+PSK + Resolving 'localhost'... + Connecting to '127.0.0.1:5556'... + - PSK authentication. + - Version: TLS1.1 + - Key Exchange: PSK + - Cipher: AES-128-CBC + - MAC: SHA1 + - Compression: NULL + - Handshake was completed + + - Simple Client Mode: + @end example + By keeping the --pskusername parameter and removing the --pskkey + parameter, it will query only for the password during the handshake. + + To list the ciphersuites in a priority string: + @example + $ ./gnutls-cli --priority SECURE192 -l + Cipher suites for SECURE192 + TLS_ECDHE_ECDSA_AES_256_CBC_SHA384 0xc0, 0x24 TLS1.2 + TLS_ECDHE_ECDSA_AES_256_GCM_SHA384 0xc0, 0x2e TLS1.2 + TLS_ECDHE_RSA_AES_256_GCM_SHA384 0xc0, 0x30 TLS1.2 + TLS_DHE_RSA_AES_256_CBC_SHA256 0x00, 0x6b TLS1.2 + TLS_DHE_DSS_AES_256_CBC_SHA256 0x00, 0x6a TLS1.2 + TLS_RSA_AES_256_CBC_SHA256 0x00, 0x3d TLS1.2 + @end example + _EOT_; +}; +// END-DEFS +_End_Of_Definitions_ + +# # # # # # # # # # # TEXI TEXT + +cat <<_End_Of_TexInfo_ +## BEGIN-TEXI +@node doc Invocation +@section Invoking doc +@pindex doc +@cindex GnuTLS client +Simple client program to set up a TLS connection to some other computer. +It sets up a TLS connection and forwards data from the standard input +to the secured socket and vice versa. + +This section was generated by @strong{AutoGen}, +using the @code{agtexi-cmd} template and the option descriptions for the @code{doc} program. +This software is released under the GNU General Public License, version 3 or later. + +@menu +* doc usage:: doc help/usage (@option{--help}) +* doc base-options:: Base options +* doc group-2:: group-2 options +* doc group-3:: group-3 options +* doc exit status:: exit status +* doc Examples:: Examples +@end menu + +@node doc usage +@subsection doc help/usage (@option{--help}) +@cindex doc help + +This is the automatically generated usage text for doc. + +The text printed is the same whether selected with the @code{help} option +(@option{--help}) or the @code{more-help} option (@option{--more-help}). @code{more-help} will print +the usage text by passing it through a pager program. +@code{more-help} is disabled on platforms without a working +@code{fork(2)} function. The @code{PAGER} environment variable is +used to select the program, defaulting to @file{more}. Both will exit +with a status code of 0. + +@exampleindent 0 +@example +doc is unavailable - no --help +@end example +@exampleindent 4 + +@node doc +@subsection Base options +@subsubheading debug option (-d). +@anchor{doc debug} +@cindex doc-debug + +This is the ``enable @code{debugging}'' option. +This option takes an argument number. +really enable debugging +@subsubheading mtu option. +@anchor{doc mtu} +@cindex doc-mtu + +This is the ``set mtu for datagram tls'' option. +This option takes an argument number. +Really set MTU for datagram TLS +@node doc group-2 +@subsection group-2 options +second group of options. +@subsubheading crlf option. +@anchor{doc crlf} +@cindex doc-crlf + +This is the ``send cr lf instead of lf'' option. +Really send CR LF instead of LF +@subsubheading x509fmtder option. +@anchor{doc x509fmtder} +@cindex doc-x509fmtder + +This is the ``use der format for certificates to read from'' option. +Really use DER format for certificates to read from +@node doc group-3 +@subsection group-3 options +third group of options. +@subsubheading recordsize option. +@anchor{doc recordsize} +@cindex doc-recordsize + +This is the ``the maximum record size to advertize'' option. +This option takes an argument number. +Really the maximum record size to advertize +@subsubheading priority option. +@anchor{doc priority} +@cindex doc-priority + +This is the ``priorities string'' option. +This option takes an argument string. +TLS algorithms and protocols to enable. You can +use predefined sets of ciphersuites such as PERFORMANCE, +NORMAL, SECURE128, SECURE256. + +Check the GnuTLS manual on section ``Priority strings'' for more +information on allowed keywords +@node doc exit status +@subsection doc exit status + +One of the following exit values will be returned: +@table @samp +@item 0 (EXIT_SUCCESS) +Successful program execution. +@item 1 (EXIT_FAILURE) +The operation failed or the command syntax was not valid. +@end table +@node doc Examples +@subsection doc Examples +To connect to a server using PSK authentication, you need to enable +the choice of PSK by using a cipher priority parameter such as in the +example below. +@example +$ ./gnutls-cli -p 5556 localhost --pskusername psk_identity \\ + --pskkey 88f3824b3e5659f52d00e959bacab954b6540344 \\ + --priority NORMAL:-KX-ALL:+ECDHE-PSK:+DHE-PSK:+PSK +Resolving 'localhost'... +Connecting to '127.0.0.1:5556'... +- PSK authentication. +- Version: TLS1.1 +- Key Exchange: PSK +- Cipher: AES-128-CBC +- MAC: SHA1 +- Compression: NULL +- Handshake was completed + +- Simple Client Mode: +@end example +By keeping the --pskusername parameter and removing the --pskkey +parameter, it will query only for the password during the handshake. + +To list the ciphersuites in a priority string: +@example +$ ./gnutls-cli --priority SECURE192 -l +Cipher suites for SECURE192 +TLS_ECDHE_ECDSA_AES_256_CBC_SHA384 0xc0, 0x24 TLS1.2 +TLS_ECDHE_ECDSA_AES_256_GCM_SHA384 0xc0, 0x2e TLS1.2 +TLS_ECDHE_RSA_AES_256_GCM_SHA384 0xc0, 0x30 TLS1.2 +TLS_DHE_RSA_AES_256_CBC_SHA256 0x00, 0x6b TLS1.2 +TLS_DHE_DSS_AES_256_CBC_SHA256 0x00, 0x6a TLS1.2 +TLS_RSA_AES_256_CBC_SHA256 0x00, 0x3d TLS1.2 +@end example +## END-TEXI +_End_Of_TexInfo_ + +# # # # # # # # # # # MAN PAGE + +cat <<_End_Of_ManPage_ +## BEGIN-MAN +.TH doc 1 +.SH NAME +doc \- GnuTLS client +.SH SYNOPSIS +.B doc +.RB [ \-\fIflag\fP " [\fIvalue\fP]]... [" \-\-\fIopt\-name\fP " [[=| ]\fIvalue\fP]]..." [hostname] +.PP +Operands and options may be intermixed. They will be reordered. +.SH "DESCRIPTION" +Simple client program to set up a TLS connection to some other computer. +It sets up a TLS connection and forwards data from the standard input +to the secured socket and vice versa. +.SH "OPTIONS" +.TP +.BR \-d " \fInumber\fP, " \-\-debug "=" \fInumber\fP +Enable \fBdebugging\fP. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 9999 +.fi +.in -4 +.sp +really enable debugging +.TP +.BR \-\-mtu "=\fInumber\fP" +Set MTU for datagram TLS. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 17000 +.fi +.in -4 +.sp +Really set MTU for datagram TLS +.SS "second group of options" +.TP +.BR \-\-crlf +Send CR LF instead of LF. +.sp +Really send CR LF instead of LF +.TP +.BR \-\-x509fmtder +Use DER format for certificates to read from. +.sp +Really use DER format for certificates to read from +.SS "third group of options" +.TP +.BR \-\-recordsize "=\fInumber\fP" +The maximum record size to advertize. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 4096 +.fi +.in -4 +.sp +Really the maximum record size to advertize +.TP +.BR \-\-priority "=\fIstring\fP" +Priorities string. +.sp +TLS algorithms and protocols to enable. You can +use predefined sets of ciphersuites such as PERFORMANCE, +NORMAL, SECURE128, SECURE256. +Check the GnuTLS manual on section \(lqPriority strings\(rq for more +information on allowed keywords +.TP +.BR \-h , " \-\-help" +Display usage information and exit. +.TP +.BR \-M , " \-\-more-help" +Pass the extended usage information through a pager. +.TP +.BR \-v " [{\fIv|c|n\fP}]," " \-\-version" "[=\fI{v|c|n}\fP]" +Output version of program and exit. The default mode is `v', a simple +version. The `c' mode will print copyright information and `n' will +print the full copyright notice. +.SH EXAMPLES +To connect to a server using PSK authentication, you need to enable +the choice of PSK by using a cipher priority parameter such as in the +example below. +.br +.in +4 +.nf +$ ./gnutls\-cli \-p 5556 localhost \-\-pskusername psk_identity \\ + \-\-pskkey 88f3824b3e5659f52d00e959bacab954b6540344 \\ + \-\-priority NORMAL:\-KX\-ALL:+ECDHE\-PSK:+DHE\-PSK:+PSK +Resolving 'localhost'... +Connecting to '127.0.0.1:5556'... +- PSK authentication. +- Version: TLS1.1 +- Key Exchange: PSK +- Cipher: AES\-128\-CBC +- MAC: SHA1 +- Compression: NULL +- Handshake was completed +- Simple Client Mode: +.in -4 +.fi +By keeping the \-\-pskusername parameter and removing the \-\-pskkey +parameter, it will query only for the password during the handshake. +.sp +To list the ciphersuites in a priority string: +.br +.in +4 +.nf +$ ./gnutls\-cli \-\-priority SECURE192 \-l +Cipher suites for SECURE192 +TLS_ECDHE_ECDSA_AES_256_CBC_SHA384 0xc0, 0x24 TLS1.2 +TLS_ECDHE_ECDSA_AES_256_GCM_SHA384 0xc0, 0x2e TLS1.2 +TLS_ECDHE_RSA_AES_256_GCM_SHA384 0xc0, 0x30 TLS1.2 +TLS_DHE_RSA_AES_256_CBC_SHA256 0x00, 0x6b TLS1.2 +TLS_DHE_DSS_AES_256_CBC_SHA256 0x00, 0x6a TLS1.2 +TLS_RSA_AES_256_CBC_SHA256 0x00, 0x3d TLS1.2 +.in -4 +.fi +.SH "EXIT STATUS" +One of the following exit values will be returned: +.TP +.BR 0 " (EXIT_SUCCESS)" +Successful program execution. +.TP +.BR 1 " (EXIT_FAILURE)" +The operation failed or the command syntax was not valid. +.SH "SEE ALSO" +gnutls\-cli\-debug(1), gnutls\-serv(1) +.SH "AUTHORS" +Nikos Mavrogiannopoulos, Simon Josefsson and others; see /usr/share/doc/gnutls-bin/AUTHORS for a complete list. +.SH "COPYRIGHT" +Copyright (C) 2000-2012 Free Software Foundation all rights reserved. +This program is released under the terms of the GNU General Public License, version 3 or later. +.SH "BUGS" +Please send bug reports to: bug-gnutls@gnu.org +.SH "NOTES" +This manual page was \fIAutoGen\fP-erated from the \fBdoc\fP +option definitions. +## END-MAN +_End_Of_ManPage_ + +# # # # # # # # # # # MAN PAGE + +cat <<_End_Of_MdocPage_ +## BEGIN-MDOC +.Dt DOC 1 User Commands +.Sh NAME +.Nm doc +.Nd GnuTLS client +.Sh SYNOPSIS +.Nm +.Op Fl flags +.Op Fl flag Ar value +.Op Fl \-option-name Ar value +[hostname] +.Pp +Operands and options may be intermixed. They will be reordered. +.Pp +.Sh "DESCRIPTION" +Simple client program to set up a TLS connection to some other computer. +It sets up a TLS connection and forwards data from the standard input +to the secured socket and vice versa. +.Sh "OPTIONS" +.Bl -tag +.It \-d " \fInumber\fP, " \-\-debug "=" \fInumber\fP +Enable \fBdebugging\fP. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 9999 +.fi +.in -4 +.sp +really enable debugging +.It \-\-mtu "=\fInumber\fP" +Set MTU for datagram TLS. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 17000 +.fi +.in -4 +.sp +Really set MTU for datagram TLS +.Ss "second group of options" +.It \-\-crlf +Send CR LF instead of LF. +.sp +Really send CR LF instead of LF +.It \-\-x509fmtder +Use DER format for certificates to read from. +.sp +Really use DER format for certificates to read from +.Ss "third group of options" +.It \-\-recordsize "=\fInumber\fP" +The maximum record size to advertize. +This option takes an integer number as its argument. +The value of \fInumber\fP is constrained to being: +.in +4 +.nf +.na +in the range 0 through 4096 +.fi +.in -4 +.sp +Really the maximum record size to advertize +.It \-\-priority "=\fIstring\fP" +Priorities string. +.sp +TLS algorithms and protocols to enable. You can +use predefined sets of ciphersuites such as PERFORMANCE, +NORMAL, SECURE128, SECURE256. +.sp +Check the GnuTLS manual on section \(lqPriority strings\(rq for more +information on allowed keywords +.It \-h , " \-\-help" +Display usage information and exit. +.It \-M , " \-\-more-help" +Pass the extended usage information through a pager. +.It \-v " [{\fIv|c|n\fP}]," " \-\-version" "[=\fI{v|c|n}\fP]" +Output version of program and exit. The default mode is `v', a simple +version. The `c' mode will print copyright information and `n' will +print the full copyright notice. +.El +.Sh EXAMPLES +To connect to a server using PSK authentication, you need to enable +the choice of PSK by using a cipher priority parameter such as in the +example below. +.Bd -literal -offset indent +$ ./gnutls\-cli \-p 5556 localhost \-\-pskusername psk_identity \\ + \-\-pskkey 88f3824b3e5659f52d00e959bacab954b6540344 \\ + \-\-priority NORMAL:\-KX\-ALL:+ECDHE\-PSK:+DHE\-PSK:+PSK +Resolving 'localhost'... +Connecting to '127.0.0.1:5556'... +- PSK authentication. +- Version: TLS1.1 +- Key Exchange: PSK +- Cipher: AES\-128\-CBC +- MAC: SHA1 +- Compression: NULL +- Handshake was completed +- Simple Client Mode: +.Ed +By keeping the \-\-pskusername parameter and removing the \-\-pskkey +parameter, it will query only for the password during the handshake. +.sp +To list the ciphersuites in a priority string: +.Bd -literal -offset indent +$ ./gnutls\-cli \-\-priority SECURE192 \-l +Cipher suites for SECURE192 +TLS_ECDHE_ECDSA_AES_256_CBC_SHA384 0xc0, 0x24 TLS1.2 +TLS_ECDHE_ECDSA_AES_256_GCM_SHA384 0xc0, 0x2e TLS1.2 +TLS_ECDHE_RSA_AES_256_GCM_SHA384 0xc0, 0x30 TLS1.2 +TLS_DHE_RSA_AES_256_CBC_SHA256 0x00, 0x6b TLS1.2 +TLS_DHE_DSS_AES_256_CBC_SHA256 0x00, 0x6a TLS1.2 +TLS_RSA_AES_256_CBC_SHA256 0x00, 0x3d TLS1.2 +.Ed +.Sh "EXIT STATUS" +One of the following exit values will be returned: +.Bl -tag +.It 0 " (EXIT_SUCCESS)" +Successful program execution. +.It 1 " (EXIT_FAILURE)" +The operation failed or the command syntax was not valid. +.El +.Sh "SEE ALSO" +gnutls\-cli\-debug(1), gnutls\-serv(1) +.Sh "AUTHORS" +Nikos Mavrogiannopoulos, Simon Josefsson and others; see /usr/share/doc/gnutls-bin/AUTHORS for a complete list. +.Sh "COPYRIGHT" +Copyright (C) 2000-2012 Free Software Foundation all rights reserved. +This program is released under the terms of the GNU General Public License, version 3 or later. +.Sh "BUGS" +Please send bug reports to: bug-gnutls@gnu.org +.Sh "NOTES" +This manual page was \fIAutoGen\fP-erated from the \fBdoc\fP +option definitions. +## END-MDOC +_End_Of_MdocPage_ + +# # # # # # # # # # # POT PAGE + +cat <<_End_Of_PotPage_ +## BEGIN-POT +# localization template (.pot) for doc.def of doc, +# this file is used to generate localized manual for doc. +# Copyright (C) +# This file is distributed under the terms of the +# the GNU General Public License, version 3 or later +# The program owners may be reached via: +# Free Software Foundation <bug-gnutls@gnu.org>. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: doc 3.0.12\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date:\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: doc.def:3 +msgid "GnuTLS client" +msgstr "" + +#: doc.def:41 +msgid "Enable debugging" +msgstr "" + +#: doc.def:42 +msgid "really enable debugging" +msgstr "" + +#: doc.def:49 +msgid "Set MTU for datagram TLS" +msgstr "" + +#: doc.def:50 +msgid "Really set MTU for datagram TLS" +msgstr "" + +#: doc.def:55 +msgid "second group of options" +msgstr "" + +#: doc.def:61 +msgid "Send CR LF instead of LF" +msgstr "" + +#: doc.def:62 +msgid "Really send CR LF instead of LF" +msgstr "" + +#: doc.def:67 +msgid "Use DER format for certificates to read from" +msgstr "" + +#: doc.def:68 +msgid "Really use DER format for certificates to read from" +msgstr "" + +#: doc.def:73 +msgid "third group of options" +msgstr "" + +#: doc.def:81 +msgid "The maximum record size to advertize" +msgstr "" + +#: doc.def:82 +msgid "Really the maximum record size to advertize" +msgstr "" + +#: doc.def:88 +msgid "Priorities string" +msgstr "" + +#: doc.def:90 +msgid "TLS algorithms and protocols to enable. You can use predefined sets of\n" + "ciphersuites such as PERFORMANCE, NORMAL, SECURE128, SECURE256.\n\n" + "Check the GnuTLS manual on section ``Priority strings'' for more\n" + "information on allowed keywords" +msgstr "" + +#: doc.def:104 +msgid "gnutls-cli-debug(1), gnutls-serv(1)" +msgstr "" + +#: doc.def:111 +msgid "To connect to a server using PSK authentication, you need to enable the\n" + "choice of PSK by using a cipher priority parameter such as in the\n" + "example below. @example $ ./gnutls-cli -p 5556 localhost --pskusername\n" + "psk_identity \\\\ --pskkey 88f3824b3e5659f52d00e959bacab954b6540344 \\\\\n" + "--priority NORMAL:-KX-ALL:+ECDHE-PSK:+DHE-PSK:+PSK Resolving\n" + "'localhost'... Connecting to '127.0.0.1:5556'... - PSK authentication.\n" + "- Version: TLS1.1 - Key Exchange: PSK - Cipher: AES-128-CBC - MAC: SHA1\n" + "- Compression: NULL - Handshake was completed\n\n" + "- Simple Client Mode: @end example By keeping the --pskusername\n" + "parameter and removing the --pskkey parameter, it will query only for\n" + "the password during the handshake.\n\n" + "To list the ciphersuites in a priority string: @example $ ./gnutls-cli\n" + "--priority SECURE192 -l Cipher suites for SECURE192\n" + "TLS_ECDHE_ECDSA_AES_256_CBC_SHA384 0xc0, 0x24 TLS1.2\n" + "TLS_ECDHE_ECDSA_AES_256_GCM_SHA384 0xc0, 0x2e TLS1.2\n" + "TLS_ECDHE_RSA_AES_256_GCM_SHA384 0xc0, 0x30 TLS1.2\n" + "TLS_DHE_RSA_AES_256_CBC_SHA256 0x00, 0x6b TLS1.2\n" + "TLS_DHE_DSS_AES_256_CBC_SHA256 0x00, 0x6a TLS1.2\n" + "TLS_RSA_AES_256_CBC_SHA256 0x00, 0x3d TLS1.2 @end example" +msgstr "" + +#: doc.def:11 +msgid "Simple client program to set up a TLS connection to some other computer.\n" + "It sets up a TLS connection and forwards data from the standard input to\n" + "the secured socket and vice versa." +msgstr "" + +#: +msgid "This program is released under the terms of the GNU General Public License, version 3 or later." +msgstr "" + +#: doc.def:21 +msgid "[hostname]" +msgstr "" +## END-POT +_End_Of_PotPage_ + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of doc.test diff --git a/autoopts/test/enums.test b/autoopts/test/enums.test new file mode 100755 index 0000000..d3edf55 --- /dev/null +++ b/autoopts/test/enums.test @@ -0,0 +1,309 @@ +#! /bin/sh +# -*- Mode: shell-script -*- +# ---------------------------------------------------------------------- +# enums.test --- test enums program attribute +# make sure that when it is not specified +# then option processing consumes all args. +# +# Time-stamp: "2012-08-11 08:31:49 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +cat > ${testname}.def <<- _EOF_ + autogen definitions options; + + prog-name = ${testname}-test; + prog-title = 'test complex main procedure'; + config-header = config.h; + + argument = '[ <node> ]'; + long-opts; + + flag = { + name = print; + value = p; + descrip = 'Print operational info'; + arg-type = keyword; + arg-name = type; + min = 1; + equivalence = print; + keyword = one, two, three, four, five, six, seven, eight, nine, ten; + }; + + flag = { + name = dump-log; + value = D; + descrip = 'Dump the program log'; + equivalence = print; + }; + + flag = { + name = all-dump; + value = A; + equivalence = print; + descrip = 'Dump everything we\'ve got'; + }; + + flag = { + name = set; + value = s; + descrip = 'set options'; + arg-type = set; + arg-name = 'opt[, ...]'; + arg-default = first,fifth,ninth,thirteenth; + equivalence = print; + keyword = first, second, third, fourth, fifth, sixth, seventh, + eighth, ninth, tenth, eleventh, twelfth, thirteenth, + fourteenth, fifteenth, sixteenth; + }; + + flag = { + name = unset; + value = u; + descrip = 'unset debug options'; + arg-type = string; + arg-name = 'opt[, ...]'; + equivalence = print; + flag-proc = set; + }; + + flag = { + name = msg-num; + value = m; + descrip = 'message number'; + no-preset; + arg-type = string; + arg-name = id; + max = NOLIMIT; + + flag-code = <<- _EndOfFlagCode_ + /* + * 'set' and 'unset' must be acted upon immediately + * -- we may get more of them. + */ + switch (WHICH_IDX_PRINT) { + case NO_EQUIVALENT: + case INDEX_OPT_PRINT: + case INDEX_OPT_DUMP_LOG: + case INDEX_OPT_ALL_DUMP: + if (COUNT_OPT( MSG_NUM ) > 1) { + fputs("Except for 'set' and 'unset' functions, " + "only one 'msg-num' is allowed\n", stderr); + USAGE(EXIT_FAILURE); + } + break; + case INDEX_OPT_SET: + set_options(1, pOptDesc->pzLastArg); + break; + case INDEX_OPT_UNSET: + set_options(0, pOptDesc->pzLastArg); + break; + }; + _EndOfFlagCode_; + }; + /* + cat <<_EOF_ + * for emacs */ + + export = "#include <sys/types.h>\n" + "#include <sys/stat.h>\n" + "#include <stdio.h>\n" + "#include <stdlib.h>\n" + "#include <fcntl.h>\n" + "#include \"config.h\"\n" + "#include \"compat/compat.h\""; + + include = 'void set_options(int mode, char const* pzArg);'; + + main = { + main-type = include; + tpl = ${testname}.tpl; + }; + _EOF_ + +# # # # # # # # # # TEMPLATE FILE # # # # # # # # # +# +# In one case we must not use built in echo. +# +cat > ${testname}.tpl <<- \__EOF + [= AutoGen5 Template -*- Mode: C -*- =] + [=(define proc-list "")=] + typedef int (do_proc_t)(void); + extern do_proc_t + [= (set! proc-list (string-append "do_print_undefined,\ndo_print_" + (join ",\ndo_print_" (stack "flag[0].keyword")) )) + (set! proc-list + (shell (string-append "${CLexe} -I4 --spread=1 <<_EOF_\n" + proc-list "\n_EOF_")) ) + proc-list =]; + do_proc_t* do_proc[] = { + [= (. proc-list) =] }; + + [=(shellf "procs='%s' ; ix=0 ; for p in ${procs} + do + p=`echo $p | sed s/,//` + echo int ${p}'(void) {' + printf ' fputs(\"'${p}'\\\\n\", stdout);\n' + echo \" return ${ix}; }\" + ix=`expr $ix + 1` + done" proc-list) =] + + int + do_dump_log(void) + { + return WHICH_IDX_PRINT != INDEX_OPT_DUMP_LOG; + } + + int + do_all_dump(void) + { + return WHICH_IDX_PRINT != INDEX_OPT_ALL_DUMP; + } + + int + do_set(int which_way) + { + printf("PRINT = 0x%lX\n", (unsigned long)DESC(PRINT).optCookie); + printf("SET = 0x%lX\n", (unsigned long)DESC(SET).optCookie); + if (which_way) + printf("0x%lX\n", OPT_VALUE_SET); + else + printf("0x%lX\n", (~ OPT_VALUE_SET) & SET_MEMBERSHIP_MASK); + return 0; + } + + void + set_options(int mode, char const* pzArg) + { + exit(atoi(pzArg)); + } + __EOF + +cat >> ${testname}.tpl <<- __EOF + int + main( int argc, char** argv ) + { + { + int ct = optionProcess(&${testname}_testOptions, argc, argv); + argc -= ct; + argv += ct; + } + + if (argc > 1) + return EXIT_FAILURE; + + /* + * Invoke the proper operational procedure. + */ + { + int res = 0; + switch (WHICH_IDX_PRINT) { + case INDEX_OPT_PRINT: res = do_proc[OPT_VALUE_PRINT](); break; + case INDEX_OPT_DUMP_LOG: res = do_dump_log(); break; + case INDEX_OPT_ALL_DUMP: res = do_all_dump(); break; + case INDEX_OPT_SET: res = do_set(1); break; + case INDEX_OPT_UNSET: res = do_set(0); break; + } + return res; + } + } + __EOF + +# # # # # # # # # # CREATE PROGRAM # # # # # # # # # + +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +compile "-?" + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +basehlp=${testname}.hlp +echo creating ${basehlp} +clean_help > ${basehlp} <<_EOF_ +${testname}-test - test complex main procedure +USAGE: ${testname} { -<flag> [<val>] | --<name>[{=| }<val>] }... [ <node> ] + Flg Arg Option-Name Req? Description + -p KWd print YES Print operational info + -D no dump-log opt Dump the program log + - an alternate for print + -A no all-dump opt Dump everything we've got + - an alternate for print + -s Mbr set opt set options + - an alternate for print + -u Str unset opt unset debug options + - an alternate for print + -m Str msg-num opt message number + - may not be preset + - may appear multiple times + -? no help opt Display extended usage information and exit + -! no more-help opt Extended usage information passed thru pager + +Options are specified by doubled hyphens and their name or by a single +hyphen and the flag character. + +The valid "print" option keywords are: + one two three four five six seven eight nine ten + or an integer from 1 through 10 +The valid "set" option keywords are: + first second third fourth fifth sixth seventh + eighth ninth tenth eleventh twelfth thirteenth fourteenth + fifteenth sixteenth + or an integer mask with any of the lower 16 bits set +or you may use a numeric representation. Preceding these with a '!' will +clear the bits, specifying 'none' will clear all bits, and 'all' will set them +all. Multiple entries may be passed as an option argument list. +_EOF_ + +cmp -s ${testname}.h*lp || \ + failure "`diff ${basehlp} ${testname}.help`" + +# # # # # # # # # # TEST OPERATION # # # # # # # # # # + +ix=0 +for f in one two three four five six seven eight nine ten +do + ix=`expr $ix + 1` + txt=`./${testname} -p $f` + test $? -eq $ix || \ + failure "'./${testname} -p $f' did not yield $ix" + test "${txt}" = "do_print_${f}" || \ + failure "'./${testname} -p $f' did not print 'do_print_${f}'" +done + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of enums.test diff --git a/autoopts/test/equiv.test b/autoopts/test/equiv.test new file mode 100755 index 0000000..2c4cc74 --- /dev/null +++ b/autoopts/test/equiv.test @@ -0,0 +1,274 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# +# equiv.test --- test option equivivalence classes +# +# Time-stamp: "2012-02-12 09:28:59 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo "creating ${testname}.def in `pwd`" +CFLAGS="-g -static" \ +testname="${testname}" test_main="${test_main}" \ +argument="${argument}" long_opts="${long_opts}" \ +${SHELLX} ${stdopts} option:'opt init' second=020 || \ + failure "Could not run stdopts.def" +cat >> ${testname}.def <<'_EOF_' +long-opts; + +flag = { + name = alpha; + descrip = "alpha opt"; + equivalence = alpha; + doc = 'alpha mumbling'; + arg-type = str; + arg-optional; +}; + +flag = { + name = beta; + descrip = "beta opt"; + equivalence = alpha; + doc = 'beta mumbling'; + arg-type = num; +}; + +flag = { + name = gamma; + descrip = "gamma opt"; + equivalence = alpha; + doc = 'gamma mumbling'; + arg-type = bool; +}; + +flag = { + name = omega; + descrip = "omega opt"; + equivalence = alpha; + doc = 'omega mumbling'; + arg-type = key; + keyword = uno, dos, tres, mucho; + arg-optional; + arg-default = mucho; +}; +_EOF_ +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure "AutoGen could not process - exited $?" + +compile "-?" + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +echo creating ${testname}-base.help +clean_help > ${testname}-base.help <<_EOF_ +test_${testname} - Test AutoOpts for ${testname} +USAGE: equiv [ -<flag> [<val>] | --<name>[{=| }<val>] ]... + Flg Arg Option-Name Description + -o Str option The option option descrip + -s Num second The second option descrip + opt alpha alpha opt + Num beta beta opt + - an alternate for alpha + T/F gamma gamma opt + - an alternate for alpha + opt omega omega opt + - an alternate for alpha + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +Options are specified by doubled hyphens and their name or by a single +hyphen and the flag character. + +The valid "omega" option keywords are: + uno dos tres mucho + or an integer from 0 through 3 +_EOF_ + +cmp -s ${testname}*.help || \ + failure "`diff ${testname}-base.help ${testname}.help`" + +cat > ${testname}-base.out <<_EOF_ +OPTION_CT=3 +export OPTION_CT +TEST_EQUIV_SECOND=2 # 0x2 +export TEST_EQUIV_SECOND +TEST_EQUIV_ALPHA=1 # 0x1 +export TEST_EQUIV_ALPHA +=== --beta 5 -o opt === +OPTION_CT=4 +export OPTION_CT +TEST_EQUIV_OPTION='opt' +export TEST_EQUIV_OPTION +TEST_EQUIV_ALPHA_MODE='BETA' +export TEST_EQUIV_ALPHA_MODE +TEST_EQUIV_BETA=5 # 0x5 +export TEST_EQUIV_BETA +=== --gamma Yes! === +OPTION_CT=2 +export OPTION_CT +TEST_EQUIV_ALPHA_MODE='GAMMA' +export TEST_EQUIV_ALPHA_MODE +TEST_EQUIV_GAMMA='true' +export TEST_EQUIV_GAMMA +=== --gamma false === +OPTION_CT=2 +export OPTION_CT +TEST_EQUIV_ALPHA_MODE='GAMMA' +export TEST_EQUIV_ALPHA_MODE +TEST_EQUIV_GAMMA='false' +export TEST_EQUIV_GAMMA +=== --omega tres === +OPTION_CT=2 +export OPTION_CT +TEST_EQUIV_ALPHA_MODE='OMEGA' +export TEST_EQUIV_ALPHA_MODE +TEST_EQUIV_OMEGA='tres' +export TEST_EQUIV_OMEGA +_EOF_ + +( set -e +x + ./${testname} --alpha -s 2 + echo === --beta 5 -o opt === + ./${testname} --beta 5 -o opt + echo === --gamma Yes! === + ./${testname} --gamma Yes! + echo === --gamma false === + ./${testname} --gamma false + echo === --omega tres === + ./${testname} --omega tres ) > ${testname}.out + +cmp -s ${testname}-base.out ${testname}.out || \ + failure "` + diff -c ${testname}-base.out ${testname}.out`" + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +echo creating ${testname}-base2.help +clean_help > ${testname}-base2.help <<_EOF_ +test_${testname} - Test AutoOpts for ${testname} +USAGE: equiv [ -<flag> [<val>] | --<name>[{=| }<val>] ]... + Flg Arg Option-Name Description + -o Str option The option option descrip + -s Num second The second option descrip + opt alpha alpha opt + Num beta beta opt + - an alternate for alpha + T/F gamma gamma opt + - an alternate for alpha + opt omega omega opt + - an alternate for alpha + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + -> opt save-opts Save the option state to a config file + -< Str load-opts Load options from a config file + - disabled as --no-load-opts + - may appear multiple times + +Options are specified by doubled hyphens and their name or by a single +hyphen and the flag character. + +The following option preset mechanisms are supported: + - reading file ..../testdir/.test_equivrc + +The valid "omega" option keywords are: + uno dos tres mucho + or an integer from 0 through 3 +_EOF_ + +echo 'homerc = "$$";' >> ${testname}.def + +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +compile "-?" +${SED} '/^ - reading file/s, file .*/testdir/, file ..../testdir/,' \ + ${testname}.help > ${testname}-test2.help +cmp -s ${testname}-base2.help ${testname}-test2.help || \ + failure "`diff ${testname}-base2.help ${testname}-test2.help`" + +echo 'gamma Yes' > .test_equivrc + +cat > ${testname}-base.out2 <<_EOF_ +=== -o opt === +OPTION_CT=2 +export OPTION_CT +TEST_EQUIV_OPTION='opt' +export TEST_EQUIV_OPTION +TEST_EQUIV_ALPHA_MODE='GAMMA' +export TEST_EQUIV_ALPHA_MODE +TEST_EQUIV_GAMMA='true' +export TEST_EQUIV_GAMMA +=== --gamma Yes! === +OPTION_CT=2 +export OPTION_CT +TEST_EQUIV_ALPHA_MODE='GAMMA' +export TEST_EQUIV_ALPHA_MODE +TEST_EQUIV_GAMMA='true' +export TEST_EQUIV_GAMMA +=== --gamma false === +OPTION_CT=2 +export OPTION_CT +TEST_EQUIV_ALPHA_MODE='GAMMA' +export TEST_EQUIV_ALPHA_MODE +TEST_EQUIV_GAMMA='false' +export TEST_EQUIV_GAMMA +=== --omega tres === +OPTION_CT=2 +export OPTION_CT +TEST_EQUIV_ALPHA_MODE='OMEGA' +export TEST_EQUIV_ALPHA_MODE +TEST_EQUIV_OMEGA='tres' +export TEST_EQUIV_OMEGA +_EOF_ + +( set -e + echo === -o opt === + ./${testname} -o opt + echo === --gamma Yes! === + ./${testname} --gamma Yes! + echo === --gamma false === + ./${testname} --gamma false + echo === --omega tres === + ./${testname} --omega tres ) > ${testname}.out2 + +cmp -s ${testname}-base.out2 ${testname}.out2 || \ + failure "` + diff -c ${testname}-base.out2 ${testname}.out2`" + +./${testname} --omega tres --beta 12 2>/dev/null && \ + failure "${testname}-2 ERROR: conflicting options accepted" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of equiv.test diff --git a/autoopts/test/errors.test b/autoopts/test/errors.test new file mode 100755 index 0000000..89f508e --- /dev/null +++ b/autoopts/test/errors.test @@ -0,0 +1,232 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# errors.test --- test argument program attribute +# make sure that when it is not specified +# then option processing consumes all args. +# +# Time-stamp: "2011-08-07 17:37:02 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo "creating ${testname}.def in `pwd`" + +testname="${testname}" \ +test_main="${test_main}" \ +argument="arg ..." \ +long_opts="yes" \ +${SHELLX} ${stdopts} option second:fumble ignored || \ + failure "Could not run stdopts.def" + +echo 'reorder-args;' >> ${testname}.def +${SED} -e '/"second"/a\ + must-set;' \ + -e '/"ignored"/a\ + omitted-usage = "we have dumped this"; ifdef = IGNORE_THIS;' \ + ${testname}.def > ${testname}.tmp +mv -f ${testname}.tmp ${testname}.def +echo "homerc = ${testname}RC;" >> ${testname}.def + +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +mkdir ${testname}RC +compile "--help" + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +echo creating ${testname}.res-help +clean_help > ${testname}.res-help <<'_EOF_' +test_errors - Test AutoOpts for errors +USAGE: errors [ -<flag> [<val>] | --<name>[{=| }<val>] ]... arg ... + Flg Arg Option-Name Description + -o no option The option option descrip + -s Str second The second option descrip + -i --- ignored we have dumped this + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + -> opt save-opts Save the option state to a config file + -< Str load-opts Load options from a config file + - disabled as --no-load-opts + - may appear multiple times + +Options are specified by doubled hyphens and their name or by a single +hyphen and the flag character. +Operands and options may be intermixed. They will be reordered. + +The following option preset mechanisms are supported: + - reading file errorsRC/.test_errorsrc +_EOF_ + +clean_help > ${testname}.ignored-expected <<\_EOF_ +errors: The ``ignored'' option has been disabled -- we have dumped this +test_errors - Test AutoOpts for errors +USAGE: errors [ -<flag> [<val>] | --<name>[{=| }<val>] ]... arg ... + Flg Arg Option-Name Description + -o no option The option option descrip + -s Str second The second option descrip + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + -> opt save-opts Save the option state to a config file + -< Str load-opts Load options from a config file + +Options are specified by doubled hyphens and their name or by a single +hyphen and the flag character. +Operands and options may be intermixed. They will be reordered. +_EOF_ + +dir=`pwd -P` || dir=`pwd` +${SED} "s#${dir}/##" ${testname}.help > ${testname}.bas-help +cmp -s ${testname}.*-help || \ + failure "help output: `diff ${testname}.*-help`" + +./${testname} -s foo -o -s bar 2> /dev/null && \ + failure ${testname} should not accept multiple options + +./${testname} -o -s foo > /dev/null 2>&1 && \ + failure ${testname} must have arguments + +./${testname} -o -s foo mumble > /dev/null || \ + failure ${testname} stumbled somehow + +./${testname} -o > /dev/null 2>&1 && \ + failure ${testname} "'option'" must have argument + +./${testname} -o mumble > /dev/null 2>&1 && \ + failure ${testname} must have second argument + +echo "second bumble" > ${testname}RC/.test_errorsrc +./${testname} -o mumble > /dev/null || \ + failure ${testname} did not see errorsRC/.test_errorsrc + +./${testname} --ignored > ${testname}.ignored 2>&1 && \ + failure "${testname} accepted --ignored" + +clean_help < ${testname}.ignored > ${testname}.ignored-result +cmp -s ${testname}.ignored-* || \ + failure "${testname}.ignored error: `diff ${testname}.ignored-*`" + +mv ${testname}RC/.test_errorsrc ${testname}RC/test_errors.rc +./${testname} --load=${testname}RC/test_errors.rc -o mumble > /dev/null || \ + failure ${testname} did not see errorsRC/test_errors.rc + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo "allow_errors;" >> ${testname}.def + +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process allow-errors + +compile "--help" + +${SED} "s#${dir}/##" ${testname}.help > ${testname}.bas-help +cmp -s ${testname}.*-help || \ + failure "help output: `diff ${testname}.*-help`" + +# This time, having a duplicate should be ignored... +# +./${testname} -s foo -o -s bar mumble 2> /dev/null 1>&2 || \ + failure ${testname} should not object to multiple options + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +${SED} '/second option/a\ + max = "10";' ${testname}.def > XX +mv -f XX ${testname}.def +cat >> ${testname}.def << '_EOF_' +flag = { + name = "another"; + max = '5'; + descrip = "Another option descrip"; + value = 'X'; +}; + +_EOF_ + +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process gnu-usage + +compile "--help" + +# # # # # # # # # # SORTED ARGS OUTPUT FILE # # # # # # # # # +test -n "${POSIXLY_CORRECT}" && { + POSIXLY_CORRECT='' + unset POSIXLY_CORRECT +} + +echo creating ${testname}-sh.samp +cat > ${testname}-sh.samp <<'_EOF_' +OPTION_CT=4 +export OPTION_CT +TEST_ERRORS_OPTION=1 # 0x1 +export TEST_ERRORS_OPTION +TEST_ERRORS_SECOND='foo' +export TEST_ERRORS_SECOND +TEST_ERRORS_ANOTHER=1 # 0x1 +export TEST_ERRORS_ANOTHER +set -- 'mum'\''ble' '-X' 'stumble' +OPTION_CT=0 +_EOF_ + +./${testname} "mum'ble" -os foo -X -- -X stumble > ${testname}-sh.out + +cmp -s ${testname}-sh.out ${testname}-sh.samp || \ + failure "`diff ${testname}-sh.samp ${testname}-sh.out`" + +cat >> ${testname}.def << '_EOF_' +flag = { + name = "still-another"; + ifdef = true ; ifndef = false; + descrip = "Another option descrip"; + value = 'Y'; +}; +_EOF_ + +case "${BASH_VERSION}" in +not-good-enough ) + echo "You are running Solaris without bash available." + echo "duplicate option flags cannot be tested." + ;; + +* ) + ${SED} '/ value /s/Y/X/;s/ ifndef =.*//' ${testname}.def > ${testname}-2.def + ${AG_L} ${testname}-2.def && \ + failure AutoGen processed conflicting flag values + ;; +esac + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of errors.test diff --git a/autoopts/test/getopt.test b/autoopts/test/getopt.test new file mode 100755 index 0000000..383c6fc --- /dev/null +++ b/autoopts/test/getopt.test @@ -0,0 +1,668 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# +# getopt.test --- test getopt_long argument processing +# +# Time-stamp: "2012-05-12 19:54:26 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +# +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + +. ./defs + +set -x +PS4='>${FUNCNAME:-go}> ' + +CC="${CC} ${CFLAGS} ${INC}" +CFLAGS='' +INC='' +export AUTOGEN_TEMPL_DIRS=${TMPDIR} + +compile_getopt() { + run_ag opts -b${testname}-bn ${testname}.def || \ + failure "AutoGen could not process ${testname}.def #${1}" + + # Remove the variable comments so we can test against the expected result + # + ${SED} '2,/and the template file/d + /\$''Id.*\$/d + /Last template edit:/d' getopt-test_${testname}.c \ + > ${testname}${1}-getopt.c + + # Finally, compile this thing: + # + ${CC} ${CFLAGS} -c ${testname}${1}-getopt.c || \ + failure "could not compile ${testname}1-getopt.c" + + ${SED} "${sed_omit_license}"' + /Packaged by /d + s@^Report .* bugs to.*"@\\n"@ + s@^please send bug.*"@\\n"@ + s@\\n\\n\\n\\$@\\n\\n\\@ + s@\(and the flag character\.\\n.\)n\\$@\1@' ${testname}${1}-getopt.c \ + > ${testname}${1}-res.c + cmp -s ${testname}${1}-base.c ${testname}${1}-res.c || { set +x ; \ + failure "`diff -c ${testname}${1}-base.c ${testname}${1}-res.c`" ; } +} + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# +# Fix up a test-specific include directory: +# +# The getopt template presumes that everything has been installed. +# However, we have to work with the local stuff. So, remove the +# "autoopts-config" probing and replace with local stuff: +# +go_init() +{ + mkdir -p ${TMPDIR}/autoopts + + CFLAGS="-I${TMPDIR}" + LDFLAGS="${LDFLAGS} ${LIB}" + export CFLAGS LDFLAGS TMPDIR + + aolib=`find ${top_builddir}/autoopts -type f -name libopts.a` + case " ${LDFLAGS} " in + *' -lgen '* ) aolib=${aolib}\ -lgen ;; + esac + + cd ${top_srcdir}/autoopts/tpl + cp *.* ${TMPDIR}/. + chmod u+w ${TMPDIR}/* + + cd ${top_builddir}/autoopts/tpl + cp *.* ${TMPDIR}/. + chmod u+w ${TMPDIR}/* + + cd ${builddir}/testdir + ${SED} -e "/^cflags=/s@=.*@='-I${TMPDIR}/autoopts -I${top_builddir}'@" \ + -e "/^ldflags=/s@=.*@='${aolib}'@" \ + ${TMPDIR}/usage.tlib > ${TMPDIR}/usage.tlib-XX + mv -f ${TMPDIR}/usage.tlib-XX ${TMPDIR}/usage.tlib + + # In order to compile correctly, we have to temporarily install the options.h + # header in our TMPDIR. We also must find that header first. Tweak CFLAGS: + # + DESTdestdir=${TMPDIR}/autoopts \ + top_builddir=${top_builddir} \ + CONFIG_SHELL="${SHELL}" \ + ${SHELLX} -x ${top_srcdir}/autoopts/install-hook.sh + AUTOGEN_TEMPL_DIRS=${TMPDIR} + export AUTOGEN_TEMPL_DIRS +} + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # +go_samples() { + +echo "creating ${testname}.def in `pwd`" + +cat >> ${testname}.def <<_EOF_ +AutoGen definitions getopt; + +prog-name = "test_${testname}"; +prog-title = "Test AutoOpts for ${testname}"; +test-main = 'yes'; +config-header = 'config.h'; + +settable; +version = '1.2.3'; +help-value = 'h'; +gnu-usage; +no-libopts; + +copyright = { + date = "2003-2012"; + owner = "Odyssey Computing Concepts, Inc."; + author= "Bruce Korb"; + eaddr = "bkorb@gnu.org"; + type = lgpl; +}; + +flag = { + name = "option"; + descrip = "The option option descrip"; + value = 'o'; + arg_type = string; arg_default = 'opt init'; +}; + +flag = { + name = "second"; + descrip = "The second option descrip"; + value = 's'; + arg_type = string; arg_default = '020'; +}; + +flag = { + name = no_val; + descrip = 'option with no flag'; + value = 'F'; /* REMOVE */ + flags-must = max_val; +}; + +flag = { + name = max_val; + descrip = 'option with max ct'; + value = 'X'; /* REMOVE */ + max = '5'; +}; + +flag = { + name = min2_val; + descrip = 'option with min ct'; + value = 'M'; /* REMOVE */ + max = '50'; + flags-cant = max_val; + min = '5'; +}; + +flag = { + name = min_val; + descrip = 'option with min ct'; + value = '2'; /* REMOVE */ + max = '50'; + min = '5'; +}; +_EOF_ + +# # # # # # # # # # BASE-1 OUTPUT FILE # # # # # # # # # + +echo creating ${testname}1-base.c + +cat > ${testname}1-base.c <<\_EndOfSample_ +#include "getopt-test_getopt.h" + +#include <sys/types.h> + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include "getopt-bn.h" + +#ifndef DIRCH +# if defined(_WIN32) && !defined(__CYGWIN__) +# define DIRCH '\\' +# else +# define DIRCH '/' +# endif +#endif +/* + * Option flag character list + */ +static char z_opts[] = "o:s:FXM2hv"; + +/* + * AutoOpts library replacement routines: + */ +void +optionUsage (tOptions* pOptions, int status) +{ + if (status != 0) + fprintf (stderr, _("Try `%s -h' for more information.\n"), + test_getoptOptions.pzProgName); + else + { + fputs (_("test_getopt - Test AutoOpts for getopt - Ver. 1.2.3\n\ +USAGE: test_getopt { -<flag> [<val>] }...\n\n\ + -o str The option option descrip\n\ + -s str The second option descrip\n\ + -F option with no flag\n\ + -X option with max ct\n\ + -M option with min ct\n\ + -2 option with min ct\n\ + -v Output version information and exit\n\ + -h Display extended usage information and exit\n\n\ +\n"), stdout); + } + + exit (status); +} + +void +optionPrintVersion( + tOptions* pOptions, + tOptDesc* pOptDesc ) +{ + char const * pz_by = + _("test_getopt 1.2.3\n\ +Written by Bruce Korb.\n\n\ +copyright (c) 2003-2012 Odyssey Computing Concepts, Inc.\n\ +This is free software; see the source for copying conditions. There is NO\n\ +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"); + + fputs (pz_by, stdout); + exit (EXIT_SUCCESS); +} + +/* + * If an option appears more often than is allowed, ... + */ +static void +usage_too_many (tOptDesc* pOptDesc) +{ + char const * pz = + _("test_getopt error: the '%s' option appears more than %d times\n"); + fprintf (stderr, pz, pOptDesc->pz_Name, pOptDesc->optMaxCt); + USAGE(EXIT_FAILURE); +} + +/* + * There is at least one option that must appear. + */ +static void +usage_too_few (tOptDesc* pOptDesc) +{ + char const * pz = + _("test_getopt error: the '%s' option must appear %d times\n"); + fprintf (stderr, pz, pOptDesc->pz_Name, pOptDesc->optMinCt); + USAGE(EXIT_FAILURE); +} + +/* + * There is at least one pair of options that may not appear together + * on the command line. + */ +static void +usage_cannot (char const* pz_what, char const* pz_cant) +{ + char const * pz = + _("test_getopt error: the `%s' option conflicts with the `%s' option.\n"); + fprintf (stderr, pz, pz_what, pz_cant); + USAGE(EXIT_FAILURE); +} + +/* + * There is at least one pair of options that are required to appear + * together on the command line. + */ +static void +usage_must (char const* pz_what, char const* pz_must) +{ + char const * pz = + _("test_getopt error: the `%s' option requires the `%s' option.\n"); + fprintf (stderr, pz, pz_what, pz_must); + USAGE(EXIT_FAILURE); +} + +/* + * Process the options for the "test_getopt" program. + * This function was generated to use the getopt(3posix) function. + * There are 8 options for this program, + * including "help (usage)" and "version". + */ +int +process_test_getopt_opts (int argc, char** argv) +{ + { + char * pz_prog = strrchr (argv[0], DIRCH); + /* + * This violates the const-ness of the pzProgName field. + * The const-ness is to prevent accidents. This is not accidental. + */ + char ** pp = (char **)(void *)&(test_getoptOptions.pzProgName); + + if (pz_prog != NULL) + pz_prog++; + else + pz_prog = argv[0]; + *pp = pz_prog; + } + + for (;;) { + switch (getopt (argc, argv, z_opts)) { + case -1: goto leave_processing; + case 0: break; + + case VALUE_OPT_OPTION: + if (HAVE_OPT( OPTION )) + usage_too_many (&DESC(OPTION)); + SET_OPT_OPTION(optarg); + break; + + case VALUE_OPT_SECOND: + if (HAVE_OPT( SECOND )) + usage_too_many (&DESC(SECOND)); + SET_OPT_SECOND(optarg); + break; + + case VALUE_OPT_NO_VAL: + if (HAVE_OPT( NO_VAL )) + usage_too_many (&DESC(NO_VAL)); + SET_OPT_NO_VAL; + break; + + case VALUE_OPT_MAX_VAL: + if (DESC(MAX_VAL).optOccCt++ >= DESC(MAX_VAL).optMaxCt) + usage_too_many (&DESC(MAX_VAL)); + SET_OPT_MAX_VAL; + break; + + case VALUE_OPT_MIN2_VAL: + if (DESC(MIN2_VAL).optOccCt++ >= DESC(MIN2_VAL).optMaxCt) + usage_too_many (&DESC(MIN2_VAL)); + SET_OPT_MIN2_VAL; + break; + + case VALUE_OPT_MIN_VAL: + if (DESC(MIN_VAL).optOccCt++ >= DESC(MIN_VAL).optMaxCt) + usage_too_many (&DESC(MIN_VAL)); + SET_OPT_MIN_VAL; + break; + + case VALUE_OPT_HELP: + USAGE(EXIT_SUCCESS); + /* NOTREACHED */ + + case VALUE_OPT_VERSION: + optionPrintVersion (&test_getoptOptions, &DESC(VERSION)); + /* NOTREACHED */ + + default: + USAGE(EXIT_FAILURE); + } + } leave_processing:; + + if (HAVE_OPT( NO_VAL )) { + if (! HAVE_OPT( MAX_VAL )) + usage_must (DESC(NO_VAL).pz_Name, DESC(MAX_VAL).pz_Name); + } + + if (HAVE_OPT( MIN2_VAL )) { + if (HAVE_OPT( MAX_VAL )) + usage_cannot (DESC(MIN2_VAL).pz_Name, DESC(MAX_VAL).pz_Name); + if (DESC(MIN2_VAL).optOccCt < DESC(MIN2_VAL).optMinCt) + usage_too_few (&DESC(MIN2_VAL)); + } + else + usage_too_few (&DESC(MIN2_VAL)); + + if (DESC(MIN_VAL).optOccCt < DESC(MIN_VAL).optMinCt) + usage_too_few (&DESC(MIN_VAL)); + + return 0; +} +_EndOfSample_ + +# # # # # # # # # # BASE-2 OUTPUT FILE # # # # # # # # # + +echo creating ${testname}2-base.c + +cat > ${testname}2-base.c <<\_EndOfSample_ +#include "getopt-test_getopt.h" + +#include <sys/types.h> + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <getopt.h> +#include "getopt-bn.h" + +#ifndef DIRCH +# if defined(_WIN32) && !defined(__CYGWIN__) +# define DIRCH '\\' +# else +# define DIRCH '/' +# endif +#endif + +/* + * getopt_long option descriptor + */ +static struct option a_long_opts[] = { + { "option", 1, NULL, VALUE_OPT_OPTION }, + { "second", 1, NULL, VALUE_OPT_SECOND }, + { "no_val", 0, NULL, VALUE_OPT_NO_VAL }, + { "max_val", 0, NULL, VALUE_OPT_MAX_VAL }, + { "min2_val", 0, NULL, VALUE_OPT_MIN2_VAL }, + { "min_val", 0, NULL, VALUE_OPT_MIN_VAL }, + { "help", 0, NULL, VALUE_OPT_HELP }, + { "version", 0, NULL, VALUE_OPT_VERSION }, + { NULL, 0, NULL, 0 } +}; + +/* + * Option flag character list + */ +static char z_opts[] = "o:s:h"; + +/* + * AutoOpts library replacement routines: + */ +void +optionUsage (tOptions* pOptions, int status) +{ + if (status != 0) + fprintf (stderr, _("Try `%s --help' for more information.\n"), + test_getoptOptions.pzProgName); + else + { + fputs (_("test_getopt - Test AutoOpts for getopt - Ver. 1.2.3\n\ +USAGE: test_getopt { -<flag> [<val>] | --<name>[{=| }<val>] }...\n\n\ + -o, --option=str The option option descrip\n\ + -s, --second=str The second option descrip\n\ + --no-val option with no flag\n\ + --max-val option with max ct\n\ + --min2-val option with min ct\n\ + --min-val option with min ct\n\ + --version Output version information and exit\n\ + -h, --help Display extended usage information and exit\n\n\ +Options are specified by doubled hyphens and their name or by a single\n\ +hyphen and the flag character.\n\ +\n"), stdout); + } + + exit (status); +} + +void +optionPrintVersion( + tOptions* pOptions, + tOptDesc* pOptDesc ) +{ + char const * pz_by = + _("test_getopt 1.2.3\n\ +Written by Bruce Korb.\n\n\ +copyright (c) 2003-2012 Odyssey Computing Concepts, Inc.\n\ +This is free software; see the source for copying conditions. There is NO\n\ +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"); + + fputs (pz_by, stdout); + exit (EXIT_SUCCESS); +} + +/* + * If an option appears more often than is allowed, ... + */ +static void +usage_too_many (tOptDesc* pOptDesc) +{ + char const * pz = + _("test_getopt error: the '%s' option appears more than %d times\n"); + fprintf (stderr, pz, pOptDesc->pz_Name, pOptDesc->optMaxCt); + USAGE(EXIT_FAILURE); +} + +/* + * There is at least one option that must appear. + */ +static void +usage_too_few (tOptDesc* pOptDesc) +{ + char const * pz = + _("test_getopt error: the '%s' option must appear %d times\n"); + fprintf (stderr, pz, pOptDesc->pz_Name, pOptDesc->optMinCt); + USAGE(EXIT_FAILURE); +} + +/* + * There is at least one pair of options that may not appear together + * on the command line. + */ +static void +usage_cannot (char const* pz_what, char const* pz_cant) +{ + char const * pz = + _("test_getopt error: the `%s' option conflicts with the `%s' option.\n"); + fprintf (stderr, pz, pz_what, pz_cant); + USAGE(EXIT_FAILURE); +} + +/* + * There is at least one pair of options that are required to appear + * together on the command line. + */ +static void +usage_must (char const* pz_what, char const* pz_must) +{ + char const * pz = + _("test_getopt error: the `%s' option requires the `%s' option.\n"); + fprintf (stderr, pz, pz_what, pz_must); + USAGE(EXIT_FAILURE); +} + +/* + * Process the options for the "test_getopt" program. + * This function was generated to use the getopt_long(3GNU) function. + * There are 8 options for this program, + * including "help (usage)" and "version". + */ +int +process_test_getopt_opts (int argc, char** argv) +{ + { + char * pz_prog = strrchr (argv[0], DIRCH); + /* + * This violates the const-ness of the pzProgName field. + * The const-ness is to prevent accidents. This is not accidental. + */ + char ** pp = (char **)(void *)&(test_getoptOptions.pzProgName); + + if (pz_prog != NULL) + pz_prog++; + else + pz_prog = argv[0]; + *pp = pz_prog; + } + + for (;;) { + switch (getopt_long (argc, argv, z_opts, a_long_opts, NULL)) { + case -1: goto leave_processing; + case 0: break; + + case VALUE_OPT_OPTION: + if (HAVE_OPT( OPTION )) + usage_too_many (&DESC(OPTION)); + SET_OPT_OPTION(optarg); + break; + + case VALUE_OPT_SECOND: + if (HAVE_OPT( SECOND )) + usage_too_many (&DESC(SECOND)); + SET_OPT_SECOND(optarg); + break; + + case VALUE_OPT_NO_VAL: + if (HAVE_OPT( NO_VAL )) + usage_too_many (&DESC(NO_VAL)); + SET_OPT_NO_VAL; + break; + + case VALUE_OPT_MAX_VAL: + if (DESC(MAX_VAL).optOccCt++ >= DESC(MAX_VAL).optMaxCt) + usage_too_many (&DESC(MAX_VAL)); + SET_OPT_MAX_VAL; + break; + + case VALUE_OPT_MIN2_VAL: + if (DESC(MIN2_VAL).optOccCt++ >= DESC(MIN2_VAL).optMaxCt) + usage_too_many (&DESC(MIN2_VAL)); + SET_OPT_MIN2_VAL; + break; + + case VALUE_OPT_MIN_VAL: + if (DESC(MIN_VAL).optOccCt++ >= DESC(MIN_VAL).optMaxCt) + usage_too_many (&DESC(MIN_VAL)); + SET_OPT_MIN_VAL; + break; + + case VALUE_OPT_HELP: + USAGE(EXIT_SUCCESS); + /* NOTREACHED */ + + case VALUE_OPT_VERSION: + optionPrintVersion (&test_getoptOptions, &DESC(VERSION)); + /* NOTREACHED */ + + default: + USAGE(EXIT_FAILURE); + } + } leave_processing:; + + if (HAVE_OPT( NO_VAL )) { + if (! HAVE_OPT( MAX_VAL )) + usage_must (DESC(NO_VAL).pz_Name, DESC(MAX_VAL).pz_Name); + } + + if (HAVE_OPT( MIN2_VAL )) { + if (HAVE_OPT( MAX_VAL )) + usage_cannot (DESC(MIN2_VAL).pz_Name, DESC(MAX_VAL).pz_Name); + if (DESC(MIN2_VAL).optOccCt < DESC(MIN2_VAL).optMinCt) + usage_too_few (&DESC(MIN2_VAL)); + } + else + usage_too_few (&DESC(MIN2_VAL)); + + if (DESC(MIN_VAL).optOccCt < DESC(MIN_VAL).optMinCt) + usage_too_few (&DESC(MIN_VAL)); + + return 0; +} +_EndOfSample_ +} + +# # # # # # # # # # RESULTS TESTING # # # # # # # # # + +go_init +go_samples +compile_getopt 1 + +${GREP} 'getopt_long' /usr/include/getopt.h >/dev/null && { + CFLAGS="${CFLAGS} -D_GNU_SOURCE=1" + ${SED} '/REMOVE/d;$a\ +long-opts;\ +version-value; +' ${testname}.def > ${testname}2.def + mv -f ${testname}2.def ${testname}.def + + compile_getopt 2 +} + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## sh-basic-offset: 2 +## End: + +# end of getopt.test diff --git a/autoopts/test/handler.test b/autoopts/test/handler.test new file mode 100755 index 0000000..ac7d4a4 --- /dev/null +++ b/autoopts/test/handler.test @@ -0,0 +1,254 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# handler.test --- test option handling +# make sure that when it is not specified +# then option processing consumes all args. +# +# Time-stamp: "2012-08-11 08:14:34 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo "creating ${testname}.def in `pwd`" +cat > ${testname}.def <<_EOF_ +AutoGen Definitions options; +prog-name = ${testname}; +prog-title = "Testing ${testname}"; + +flag = { + name = first; + descrip = "first description"; + extract_code; +}; + +flag = { + name = second; + descrip = "second description"; + arg-type = keyword; + keyword = alpha, beta, gamma, omega; +}; + +flag = { + name = third; + descrip = "third description"; + flag_code = " SomeCodeOrOther();"; +}; + +flag = { + name = fourth; + descrip = "fourth description"; + arg-type = keyword; + keyword = alpha, beta, gamma, omega; + arg-default = gamma; + arg-optional; +}; + +flag = { + name = fifth; + descrip = "fifth description"; + flag_proc = first; +}; + +flag = { + name = sixth; + descrip = "sixth description"; + arg-type = set-member; + keyword = alpha, beta, gamma, omega; + arg-default = gamma, beta; +}; +_EOF_ + +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +${SED} '/START =/a\ +SampleCode();\ +XXX-REMOVE-XXX' ${testname}.c > ${testname}.tmp +chmod 644 ${testname}.c +${SED} -e '/^XXX-REMOVE-XXX$/d;s/XXX-REMOVE-XXX//' \ + ${testname}.tmp > ${testname}.c + +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +# We are testing to ensure the procedures are created correctly. +# The template line numbers and time stamps and all that cruft +# vary too much, so sed them away. +# +${SED} -e '1,/Create the static procedure(s) declared above/d' \ + -e '/extracted from.*near line/d' \ + -e '/^#line/d' \ + -e 's@handler_opt_strs+[0-9]*@handler_opt_strs+NNN@g' \ + -e 's@+NNN, *@+NNN, @g' \ + -e '/^#ifndef *PKGDATADIR/,$d' \ + ${testname}.c > ${testname}.test + +# # # # # # # # # # SAMPLE OUTPUT FILE # # # # # # # # # + +echo creating ${testname}.sample +cat > ${testname}.sample <<\_EOF_ + */ +/** + * The callout function that invokes the optionUsage function. + * + * @param pOptions the AutoOpts option description structure + * @param pOptDesc the descriptor for the "help" (usage) option. + * @noreturn + */ +static void +doUsageOpt(tOptions * pOptions, tOptDesc * pOptDesc) +{ + optionUsage(&handlerOptions, HANDLER_EXIT_SUCCESS); + /* NOTREACHED */ + (void)pOptDesc; + (void)pOptions; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** + * Code to handle the first option. + * + * @param pOptions the handler options data structure + * @param pOptDesc the option descriptor for this option. + */ +static void +doOptFirst(tOptions* pOptions, tOptDesc* pOptDesc) +{ +/* START =-= First Opt Code =-= DO NOT CHANGE THIS COMMENT */ +SampleCode(); +/* END =-= First Opt Code =-= DO NOT CHANGE THIS COMMENT */ + (void)pOptDesc; + (void)pOptions; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** + * Code to handle the second option. + * + * @param pOptions the handler options data structure + * @param pOptDesc the option descriptor for this option. + */ +static void +doOptSecond(tOptions* pOptions, tOptDesc* pOptDesc) +{ + + static char const zDef[2] = { 0x7F, 0 }; + static char const * const azNames[5] = { zDef, + handler_opt_strs+NNN, handler_opt_strs+NNN, handler_opt_strs+NNN, + handler_opt_strs+NNN }; + + if (pOptions <= OPTPROC_EMIT_LIMIT) { + (void) optionEnumerationVal(pOptions, pOptDesc, azNames, 5); + return; /* protect AutoOpts client code from internal callbacks */ + } + + pOptDesc->optArg.argEnum = + optionEnumerationVal(pOptions, pOptDesc, azNames, 5); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** + * Code to handle the third option. + * + * @param pOptions the handler options data structure + * @param pOptDesc the option descriptor for this option. + */ +static void +doOptThird(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from handler.def, line 21 */ + SomeCodeOrOther(); + (void)pOptDesc; + (void)pOptions; +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** + * Code to handle the fourth option. + * + * @param pOptions the handler options data structure + * @param pOptDesc the option descriptor for this option. + */ +static void +doOptFourth(tOptions* pOptions, tOptDesc* pOptDesc) +{ + + static char const * const azNames[4] = { + handler_opt_strs+NNN, handler_opt_strs+NNN, handler_opt_strs+NNN, + handler_opt_strs+NNN }; + + if (pOptions <= OPTPROC_EMIT_LIMIT) { + (void) optionEnumerationVal(pOptions, pOptDesc, azNames, 4); + return; /* protect AutoOpts client code from internal callbacks */ + } + + if (pOptDesc->optArg.argString == NULL) + pOptDesc->optArg.argEnum = FOURTH_GAMMA; + else + pOptDesc->optArg.argEnum = + optionEnumerationVal(pOptions, pOptDesc, azNames, 4); +} + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** + * Code to handle the sixth option. + * + * @param pOptions the handler options data structure + * @param pOptDesc the option descriptor for this option. + */ +static void +doOptSixth(tOptions* pOptions, tOptDesc* pOptDesc) +{ + + static char const * const azNames[4] = { + "alpha", "beta", "gamma", "omega" + }; + /* + * This function handles special invalid values for "pOptions" + */ + optionSetMembers(pOptions, pOptDesc, azNames, 4); +} + +/** + * The directory containing the data associated with handler. + */ +_EOF_ + +cmp -s ${testname}.test ${testname}.sample || { + failure "`diff -c ${testname}.test ${testname}.sample`" ; } + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of handler.test diff --git a/autoopts/test/immediate.test b/autoopts/test/immediate.test new file mode 100755 index 0000000..c7edbce --- /dev/null +++ b/autoopts/test/immediate.test @@ -0,0 +1,121 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# immediate.test --- test immediate option handling +# +# Time-stamp: "2012-01-29 13:33:03 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo "creating ${testname}.def in `pwd`" + +cat > ${testname}.def << _EOF_ +AutoGen definitions options; + +prog-name = "test_${testname}"; +prog-title = "Test AutoOpts for ${testname}"; +include = "#include <stdio.h>\nint invocation_ct = 0;"; +config-header = 'config.h'; +version = '1.0'; +copyright = { + date = "1992-2012"; + owner = "Bruce Korb"; + eaddr = "autogen-users@lists.sourceforge.net"; + type = gpl; +}; + +flag = { + name = "second"; + descrip = "The second option descrip"; + immediate = also; + immed-disable = also; + disable = not; + arg-type = string; + flag-code = " invocation_ct++;"; +}; + +main = { + main-type = main; + main-text = ' printf( "invocation_ct = %d\\n", invocation_ct );'; +}; + +_EOF_ + +INC=`echo ${INC} | ${SED} 's/-lguile//;s/-lqthreads//'` +CFLAGS="-g`echo ' '${CFLAGS}' ' | \ + ${SED} 's, -O2 , ,;s/ -g[^ ]* / /'`" + +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +sedcmd="/All arguments are named options./q" +compile "help" + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +echo creating ${testname}.hlp +clean_help > ${testname}.hlp << '_EOF_' +test_immediate - Test AutoOpts for immediate - Ver. 1.0 +USAGE: immediate [ <option-name>[{=| }<val>] ]... + Arg Option-Name Description + Str second The second option descrip + - disabled as --not-second + opt version Output version information and exit + no help Display extended usage information and exit + no more-help Extended usage information passed thru pager + +All arguments are named options. +_EOF_ + +cmp -s ${testname}.help ${testname}.hlp || { set +x ; \ + failure "`diff -c ${testname}.hlp ${testname}.help`" ; } + +f=`./${testname} second=hand` +test "$f" = "invocation_ct = 2" || \ + failure "enabled option not processed twice" + +f=`./${testname} not-second` +test "$f" = "invocation_ct = 2" || \ + failure "DIS-abled option not processed twice" + +f=`./${testname} help version=c | ${FGREP} 'USAGE:'` +test -z "${f}" && failure "no USAGE: in help text" + +f=`./${testname} version=c help | ${FGREP} -i 'copyright (c)'` +test -z "${f}" && failure "no 'copyright (c)' in version text" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of immediate.test diff --git a/autoopts/test/keyword.test b/autoopts/test/keyword.test new file mode 100755 index 0000000..03b8720 --- /dev/null +++ b/autoopts/test/keyword.test @@ -0,0 +1,449 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# keyword.test --- keyword option processing +# +# Time-stamp: "2012-02-28 19:42:00 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo "creating ${testname}.def in `pwd`" +testname="${testname}" test_main="" \ +argument="${argument}" long_opts="yes" \ +${SHELLX} ${stdopts} option:'opt init' || failure "Could not run stdopts.def" +cat >> ${testname}.def <<- _EndOfDef_ + help_value = X; + homerc = '.'; + rcfile = ${testname}.cfg; + + flag = { + name = trace; + arg-type = keyword; + arg-default = nothing; + arg-name = level; + descrip = "tracing level of detail"; + keyword = nothing, templates, block-macros, expressions, + explanations; + }; + + flag = { + name = sets; + arg-type = set-members; + arg-default = second, fourth; + arg-name = member-list; + descrip = "set membership testing"; + keyword = first, second, third, fourth, fifth, + sixth, seventh, eighth, ninth, tenth, + eleventh, twelfth, thirteenth, fourteenth, fifteenth, + sixteenth, seventeenth, eighteenth; + }; + main = { main-type = shell-process; }; + _EndOfDef_ + +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +compile "-X" + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +echo creating ${testname}.res-help +clean_help > ${testname}.res-help <<\_EOF_ +test_keyword - Test AutoOpts for keyword +USAGE: keyword [ -<flag> [<val>] | --<name>[{=| }<val>] ]... + Flg Arg Option-Name Description + -o Str option The option option descrip + KWd trace tracing level of detail + Mbr sets set membership testing + - is a set membership option + -X no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + -> opt save-opts Save the option state to a config file + -< Str load-opts Load options from a config file + - disabled as --no-load-opts + - may appear multiple times + +Options are specified by doubled hyphens and their name or by a single +hyphen and the flag character. + +The following option preset mechanisms are supported: + - reading file ./keyword.cfg + +The valid "trace" option keywords are: + nothing templates block-macros expressions explanations + or an integer from 0 through 4 +The valid "sets" option keywords are: + first second third fourth fifth sixth + seventh eighth ninth tenth eleventh twelfth + thirteenth fourteenth fifteenth sixteenth seventeenth eighteenth + or an integer mask with any of the lower 18 bits set +or you may use a numeric representation. Preceding these with a '!' will +clear the bits, specifying 'none' will clear all bits, and 'all' will set them +all. Multiple entries may be passed as an option argument list. +_EOF_ + +dir=`pwd -P` || dir=`pwd` +${SED} "s#${dir}/##" ${testname}.help > ${testname}.bas-help +cmp -s ${testname}.*-help || \ + failure "help output: `diff ${testname}.*-help`" + +./${testname} --trace=exp > /dev/null 2>&1 && \ + failure "${testname} accepted ambiguous keyword" + +./${testname} --trace=999 > /dev/null 2>&1 && \ + failure "${testname} accepted too much tracing" + +./${testname} --trace=~0 > /dev/null 2>&1 || \ + failure "${testname} would not accept max tracing" + +./${testname} --trace=expr --set=thirteen,ninth,third > ${testname}.t1-s || \ + failure "${testname} did not handle its options" + +./${testname} --trace=expr --set=thirteen,ninth,third --save=${testname}.cfg || \ + failure "${testname} could not save its options" + +${EGREP} -v '^#' ${testname}.cfg > ${testname}res.cfg || \ + failure "${testname} could not create ${testname}.cfg" + +cat > ${testname}base.cfg <<- \_EndIni_ + trace expressions + sets none + second + third + fourth + ninth + thirteenth + _EndIni_ + +cmp -s ${testname}base.cfg ${testname}res.cfg || \ + failure "`diff ${testname}base.cfg ${testname}res.cfg`" + +cat > ${testname}.t1-b <<- \_EndTst_ + OPTION_CT=2 + export OPTION_CT + TEST_KEYWORD_TRACE='expressions' + export TEST_KEYWORD_TRACE + TEST_KEYWORD_SETS=4366 # 0x110E + export TEST_KEYWORD_SETS + typeset -x -i SETS_FIRST=1 # 0x1 + typeset -x -i SETS_SECOND=2 # 0x2 + typeset -x -i SETS_THIRD=4 # 0x4 + typeset -x -i SETS_FOURTH=8 # 0x8 + typeset -x -i SETS_FIFTH=16 # 0x10 + typeset -x -i SETS_SIXTH=32 # 0x20 + typeset -x -i SETS_SEVENTH=64 # 0x40 + typeset -x -i SETS_EIGHTH=128 # 0x80 + typeset -x -i SETS_NINTH=256 # 0x100 + typeset -x -i SETS_TENTH=512 # 0x200 + typeset -x -i SETS_ELEVENTH=1024 # 0x400 + typeset -x -i SETS_TWELFTH=2048 # 0x800 + typeset -x -i SETS_THIRTEENTH=4096 # 0x1000 + typeset -x -i SETS_FOURTEENTH=8192 # 0x2000 + typeset -x -i SETS_FIFTEENTH=16384 # 0x4000 + typeset -x -i SETS_SIXTEENTH=32768 # 0x8000 + typeset -x -i SETS_SEVENTEENTH=65536 # 0x10000 + typeset -x -i SETS_EIGHTEENTH=131072 # 0x20000 + _EndTst_ + +cmp -s ${testname}.t1-* || \ + failure "`diff ${testname}.t1-*`" + +${AG_L} -T agman-cmd.tpl ${testname}.def +test -f test_${testname}.1 || \ + failure "'test_${testname}.1' was not produced" +mv test_${testname}.1 ${testname}.1 + +cat > ${testname}-base.1 <<\_EOMan_ +test_keyword \- Test AutoOpts for keyword +.SH SYNOPSIS +.B test_keyword +.\" Mixture of short (flag) options and long options +.RB [ \-\fIflag\fP " [\fIvalue\fP]]... [" \-\-\fIopt\-name\fP " [[=| ]\fIvalue\fP]]..." +.PP +All arguments must be options. +.SH "DESCRIPTION" +There is no description for this command. +.SH "OPTIONS" +.TP +.BR \-o " \fIstring\fP, " \-\-option "=" \fIstring\fP +The option option descrip. +The default \fIstring\fP for this option is: +.ti +4 + opt init +.sp +This option has not been fully documented. +.TP +.BR \-\-trace "=\fIlevel\fP" +tracing level of detail. +This option takes a keyword as its argument. The argument sets an enumeration value that can +be tested by comparing them against the option value macro. +The available keywords are: +.in +4 +.nf +.na +nothing templates block-macros +expressions explanations +.fi +or their numeric equivalent. +.in -4 +.sp +The default \fIlevel\fP for this option is: +.ti +4 + nothing +.sp +This option has not been fully documented. +.TP +.BR \-\-sets "=\fImember\-list\fP" +set membership testing. +This option takes a keyword as its argument list. Each entry turns on or off +membership bits. The bits are set by name or numeric value and cleared +by preceding the name or number with an exclamation character ('!'). +They can all be cleared with the magic name \fInone\fR and they can all be set +with +.IR all . +A single option will process a list of these values. +The available keywords are: +.in +4 +.nf +.na +first second third fourth +fifth sixth seventh eighth +ninth tenth eleventh twelfth +thirteenth fourteenth fifteenth sixteenth +seventeenth eighteenth +.fi +or their numeric equivalent. +.in -4 +.sp +The default \fImember\-list\fP for this option is: +.ti +4 + second + fourth +.sp +This option has not been fully documented. +.TP +.BR \-X , " \-\-help" +Display usage information and exit. +.TP +.BR \-! , " \-\-more-help" +Pass the extended usage information through a pager. +.TP +.BR \-> " [\fIrcfile\fP]," " \-\-save-opts" "[=\fIrcfile\fP]" +Save the option state to \fIrcfile\fP. The default is the \fIlast\fP +configuration file listed in the \fBOPTION PRESETS\fP section, below. +.TP +.BR \-< " \fIrcfile\fP," " \-\-load-opts" "=\fIrcfile\fP," " \-\-no-load-opts" +Load options from \fIrcfile\fP. +The \fIno-load-opts\fP form will disable the loading +of earlier RC/INI files. \fI\-\-no-load-opts\fP is handled early, +out of order. +.SH "OPTION PRESETS" +Any option that is not marked as \fInot presettable\fP may be preset +by loading values from configuration ("RC" or ".INI") file(s). +The file "\fI./keyword.cfg\fP" will be used, if present. +.SH "FILES" +See \fBOPTION PRESETS\fP for configuration files. +.SH "EXIT STATUS" +One of the following exit values will be returned: +.TP +.BR 0 " (EXIT_SUCCESS)" +Successful program execution. +.TP +.BR 1 " (EXIT_FAILURE)" +The operation failed or the command syntax was not valid. +.TP +.BR 66 " (EX_NOINPUT)" +A specified configuration file could not be loaded. +.TP +.BR 70 " (EX_SOFTWARE)" +libopts had an internal operational error. Please report +it to autogen-users@lists.sourceforge.net. Thank you. +.SH "NOTES" +This manual page was \fIAutoGen\fP-erated from the \fBtest_keyword\fP +option definitions. +_EOMan_ + +${SED} '1,/^\.SH NAME/d' ${testname}.1 > ${testname}-res.1 +cmp -s ${testname}-base.1 ${testname}-res.1 || \ + failure "`diff ${testname}-base.1 ${testname}-res.1`" + +# # # # # # # # # # CHECK OUT MDOC # # # # # # # # # # # + +${AG_L} -T agmdoc-cmd.tpl ${testname}.def +test -f test_${testname}.1 || \ + failure "'test_${testname}.1' was not produced" +mv test_${testname}.1 ${testname}.mdoc + +cat > ${testname}-base.mdoc <<\_EOMan_ +.Dt TEST_KEYWORD 1 User Commands +.Sh NAME +.Nm test_keyword +.Nd Test AutoOpts for keyword +.Sh SYNOPSIS +.Nm +.\" Mixture of short (flag) options and long options +.Op Fl flags +.Op Fl flag Ar value +.Op Fl \-option-name Ar value +.Pp +All arguments must be options. +.Pp +.Sh "DESCRIPTION" +There is no description for this command. +.Sh "OPTIONS" +.Bl -tag +.It \-o " \fIstring\fP, " \-\-option "=" \fIstring\fP +The option option descrip. +The default \fIstring\fP for this option is: +.ti +4 + opt init +.sp +This option has not been fully documented. +.It \-\-trace "=\fIlevel\fP" +tracing level of detail. +This option takes a keyword as its argument. The argument sets an enumeration value that can +be tested by comparing them against the option value macro. +The available keywords are: +.in +4 +.nf +.na +nothing templates block-macros +expressions explanations +.fi +or their numeric equivalent. +.in -4 +.sp +The default \fIlevel\fP for this option is: +.ti +4 + nothing +.sp +This option has not been fully documented. +.It \-\-sets "=\fImember\-list\fP" +set membership testing. +This option takes a keyword as its argument list. Each entry turns on or off +membership bits. The bits are set by name or numeric value and cleared +by preceding the name or number with an exclamation character ('!'). +They can all be cleared with the magic name \fInone\fR and they can all be set +with +.IR all . +A single option will process a list of these values. +The available keywords are: +.in +4 +.nf +.na +first second third fourth +fifth sixth seventh eighth +ninth tenth eleventh twelfth +thirteenth fourteenth fifteenth sixteenth +seventeenth eighteenth +.fi +or their numeric equivalent. +.in -4 +.sp +The default \fImember\-list\fP for this option is: +.ti +4 + second + fourth +.sp +This option has not been fully documented. +.It \-X , " \-\-help" +Display usage information and exit. +.It \-! , " \-\-more-help" +Pass the extended usage information through a pager. +.It \-> " [\fIrcfile\fP]," " \-\-save-opts" "[=\fIrcfile\fP]" +Save the option state to \fIrcfile\fP. The default is the \fIlast\fP +configuration file listed in the \fBOPTION PRESETS\fP section, below. +.It \-< " \fIrcfile\fP," " \-\-load-opts" "=\fIrcfile\fP," " \-\-no-load-opts" +Load options from \fIrcfile\fP. +The \fIno-load-opts\fP form will disable the loading +of earlier RC/INI files. \fI\-\-no-load-opts\fP is handled early, +out of order. +.El +.Sh "OPTION PRESETS" +Any option that is not marked as \fInot presettable\fP may be preset +by loading values from configuration ("RC" or ".INI") file(s). +The file "\fI./keyword.cfg\fP" will be used, if present. +.Sh "FILES" +See \fBOPTION PRESETS\fP for configuration files. +.Sh "EXIT STATUS" +One of the following exit values will be returned: +.Bl -tag +.It 0 " (EXIT_SUCCESS)" +Successful program execution. +.It 1 " (EXIT_FAILURE)" +The operation failed or the command syntax was not valid. +.It 66 " (EX_NOINPUT)" +A specified configuration file could not be loaded. +.It 70 " (EX_SOFTWARE)" +libopts had an internal operational error. Please report +it to autogen-users@lists.sourceforge.net. Thank you. +.El +.Sh "NOTES" +This manual page was \fIAutoGen\fP-erated from the \fBtest_keyword\fP +option definitions. +_EOMan_ + +${SED} '/DO NOT EDIT/,/and the template file/d;/^\.Os /d;/^\.Dd /d' \ + ${testname}.mdoc > ${testname}-res.mdoc +cmp -s ${testname}-base.mdoc ${testname}-res.mdoc || \ + failure "`diff ${testname}-base.mdoc ${testname}-res.mdoc`" + +# # # # # # # # # # CHECK OUT VAL2STR # # # # # # # # # # # + +exec 3> ${testname}_2.def +${SED} '/^prog-name/s/";/_2";/;/^main *=/,$d' ${testname}.def >&3 +cat >&3 <<- \_EOF_ + include = '#include <stdio.h>'; + main = { + main-type = main; + main-text = + ' printf( "%s\n", OPT_TRACE_VAL2STR( OPT_VALUE_TRACE ));'; + }; + _EOF_ +exec 3>&- + +echo ${AG_L} ${testname}_2.def +${AG_L} ${testname}_2.def || \ + failure AutoGen could not process + +Csrc=${testname}_2 +Dnam=${Csrc} +compile "-X" || failure "cannot compile ${testname}_2" + +val=`./${testname}_2 --trace=expr 2>&1` || \ + failure "cannot run ${testname}_2" + +case "${val}" in +expressions) : ;; +* ) failure "${testname}_2 returned '${val}', not 'expressions': + ${testname}_2 --trace=expr" ;; +esac + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of keyword.test diff --git a/autoopts/test/library.test b/autoopts/test/library.test new file mode 100755 index 0000000..f463e3e --- /dev/null +++ b/autoopts/test/library.test @@ -0,0 +1,170 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# library.test --- test library options +# +# Time-stamp: "2013-03-10 07:14:58 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +DEND=\<\<'- _DESC_END_' + +cat > ${testname}-libopts.def <<- _EODefs_ + flag = { name = zzyzx-opts; + documentation; + lib-name = zzyzx; + descrip = ${DEND} + This option introduces the options for the + zzyzx library + _DESC_END_; + }; + flag = { + name = library; + value = c; + ifdef = LIBOPTS; + descrip = "library test"; + doc = mumble; + }; + _EODefs_ + +cat > ${testname}-lib.def <<- _EODefs_ + + AutoGen definitions options; + + prog-name = ${testname}; + prog-title = lib-${testname}; + config-header = 'config.h'; + + library; + #include ${testname}-libopts.def + _EODefs_ + +cat > ${testname}-prog.def <<- _EOF_ + + AutoGen definitions options; + + prog-name = test-lib-prog; + prog-title = 'Test ${testname} Program'; + config-header = 'config.h'; + + flag = { + name = program; + value = p; + descrip = "${testname} program test"; + doc = stumble; + }; + + #include ${testname}-libopts.def + _EOF_ + +echo ${AG_L} ${testname}-lib.def +${AG_L} ${testname}-lib.def || \ + failure AutoGen could not process ${testname}-lib.def + +echo ${AG_L} ${testname}-prog.def +${AG_L} ${testname}-prog.def || \ + failure AutoGen could not process ${testname}-prog.def + +for f in lib prog +do + ${SED} -e '1,/include <autoopts\/options.h>/d' \ + -e '/endif .* AUTOOPTS_.*_H_GUARD/,$d' \ + -e 's/near line [0-9]*/near line XXX/' \ + ${testname}-${f}.h > ${testname}-${f}.h-res || \ + failure could not sed ${testname}-${f}.h +done + +# # # # # # # # # # TEST PROGRAM # # # # # # # # # # + +cat > ${testname}-lib.c <<- _EOCode_ + #include <stdlib.h> + #define LIBOPTS + #include "${testname}-lib.h" + void check_library_opt( void ); + void check_library_opt( void ) { + if (HAVE_OPT(LIBRARY)) return; + exit( EXIT_FAILURE ); } + _EOCode_ +test $? -eq 0 || failure cannot create ${testname}-lib.c + +${CC} ${CFLAGS} ${INC} -o ${testname}-lib.o -c ${testname}-lib.c +test $? -eq 0 || failure cannot compile ${testname}-lib.c + +cat > ${testname}-main.c <<- _EOCode_ + #include <stdio.h> + #include <stdlib.h> + #define LIBOPTS + #include "${testname}-prog.c" + extern void check_library_opt( void ); + int main( int argc, char** argv ) { + (void)optionProcess( &test_lib_progOptions, argc, argv ); + check_library_opt(); + return EXIT_SUCCESS; } + _EOCode_ + +${CC} ${CFLAGS} ${INC} -o ${testname} ${testname}-main.c ${testname}-lib.o ${LIB} +test $? -eq 0 || failure cannot compile ${testname}-main.c + +./${testname} -c || failure library option not detected + +# # # # # # # # # # HELP OUTPUT # # # # # # # # # # + +./${testname} -? | clean_help > ${testname}.help-sample + +clean_help > ${testname}.help-base <<- _EOHelp_ +test-lib-prog - Test library Program +USAGE: library [ -<flag> ]... + Flg Arg Option-Name Description + -p no program library program test + +This option introduces the options for the zzyzx library: + + Flg Arg Option-Name Description + -c no library library test + +version, usage and configuration options: + + Flg Arg Option-Name Description + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + + _EOHelp_ + +cmp ${testname}.help-* || \ + failure "help output mismatch: +`diff ${testname}.help-*`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of library.test diff --git a/autoopts/test/main.test b/autoopts/test/main.test new file mode 100755 index 0000000..0c4b124 --- /dev/null +++ b/autoopts/test/main.test @@ -0,0 +1,127 @@ +#! /bin/sh +# -*- Mode: Shell-Script -*- +# ---------------------------------------------------------------------- +# main.test --- test main program attribute +# make sure that when it is not specified +# then option processing consumes all args. +# +# Time-stamp: "2011-08-07 17:33:19 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo "creating ${testname}.def in `pwd`" +testname="${testname}" \ +argument="${argument}" long_opts="${long_opts}" \ +${SHELLX} ${stdopts} option:'opt init' second=020 || \ + failure "Could not run stdopts.def" + +exec 4> ${testname}.def2 +${SED} '/test_main=/d' ${testname}.def >&4 +unset test_main +cat >&4 <<- _EOF_ + explain = 'This is some explanatory text.'; + argument = '[ <argument> ... ]'; + main = { + handler-proc = fumble; + fumble-code = 'printf( "%s\n", pz_entry );'; + main-type = for-each; + }; + _EOF_ +exec 4>&- +mv -f ${testname}.def2 ${testname}.def + +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +compile "-?" + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +basehlp=${testname}.hlp +echo creating ${basehlp} +clean_help > ${basehlp} <<'_EOF_' +test_main - Test AutoOpts for main +USAGE: main [ -<flag> [<val>] ]... [ <argument> ... ] + Flg Arg Option-Name Description + -o Str option The option option descrip + -s Num second The second option descrip + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + + +This is some explanatory text. +If no arguments are provided, input arguments are read from stdin, +one per line; blank and '#'-prefixed lines are comments. +'stdin' may not be a terminal (tty). +_EOF_ + +cmp -s ${testname}.h*lp || \ + failure "`diff ${basehlp} ${testname}.help`" + +# # # # # # # # # # TEST OPERATION # # # # # # # # # # + +./${testname} > ${testname}.out < ${testname}.hlp + +clean_help > ${testname}.base <<\_EOF_ +test_main - Test AutoOpts for main +USAGE: main [ -<flag> [<val>] ]... [ <argument> ... ] +Flg Arg Option-Name Description +-o Str option The option option descrip +-s Num second The second option descrip +-? no help Display extended usage information and exit +-! no more-help Extended usage information passed thru pager +This is some explanatory text. +If no arguments are provided, input arguments are read from stdin, +one per line; blank and '#'-prefixed lines are comments. +'stdin' may not be a terminal (tty). +_EOF_ + +cmp -s ${testname}.base ${testname}.out || \ + failure "`diff ${testname}.base ${testname}.out`" + +./${testname} -s 5 the quick 'brown fox' > ${testname}.out2 + +cat > ${testname}.base2 <<\_EOF_ +the +quick +brown fox +_EOF_ + +cmp -s ${testname}.base2 ${testname}.out2 || \ + failure "`diff ${testname}.base2 ${testname}.out2`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of main.test diff --git a/autoopts/test/nested.test b/autoopts/test/nested.test new file mode 100755 index 0000000..34c9a55 --- /dev/null +++ b/autoopts/test/nested.test @@ -0,0 +1,266 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# nested.test --- test nested option values +# +# Time-stamp: "2012-03-31 13:10:48 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +exec 5> ${testname}.def +cat >&5 <<- _EOF_ + + AutoGen definitions options; + + config-header = 'config.h'; + prog-name = "test_${testname}"; + prog-title = "Test AutoOpts for ${testname}"; + homerc = ${testname}.d/${testname}.cfg; + + flag = { + name = struct; + value = s; + max = NOLIMIT; + descrip = 'structured argument val'; + arg-type = nested; + }; + main = { + main-type = main; + _EOF_ + +test -d ${testname}.d || mkdir -p ${testname}.d + +echo ' main-text = <''<- _EOCode_' >&5 +cat >&5 <<- _EOF_ + { + int ix = 0; + const tOptionValue* pOV = + optionFindValue(&DESC(STRUCT), NULL, NULL); + do { + printf("\nstruct opt #%d:\n", ++ix); + res |= print_entry( pOV ); + pOV = optionFindNextValue(&DESC(STRUCT), pOV, NULL, NULL); + } while (pOV != NULL); + } + _EOF_ + +echo "_EOCode_; };" >&5 + +echo 'include = <''<- _EOSubr_' >&5 +cat >&5 <<- _EOF_ + #include <stdio.h> + + int print_nested( const tOptionValue* pGV ); + int print_entry( const tOptionValue* pGV ); + int print_entry( const tOptionValue* pGV ) { + if (pGV == NULL) { + fprintf( stderr, "ENTRY NOT FOUND\n" ); + return 1; + } + printf( "%-8s -- ", pGV->pzName ); + switch (pGV->valType) { + case OPARG_TYPE_NONE: + fputs( "no value\n", stdout ); break; + + case OPARG_TYPE_STRING: + printf( "string: %s\n", pGV->v.strVal ); break; + + case OPARG_TYPE_ENUMERATION: + printf( "enum: %d\n", pGV->v.enumVal ); break; + + case OPARG_TYPE_BOOLEAN: + printf( "bool: %s\n", + pGV->v.boolVal ? "TRUE" : "false" ); break; + + case OPARG_TYPE_MEMBERSHIP: + printf("members: 0x%08lX\n", (unsigned long)pGV->v.setVal); break; + + case OPARG_TYPE_NUMERIC: + printf( "integer: %ld\n", pGV->v.longVal ); break; + + case OPARG_TYPE_HIERARCHY: + printf( "nested: 0x%08lX\n", (unsigned long)pGV->v.nestVal ); + return print_nested( pGV ); + break; + + default: + printf( "bad type: %d\n", pGV->valType ); + return 1; + } + return 0; + } + + int print_nested( const tOptionValue* pGV ) { + int res = 0; + const tOptionValue* pOV = optionGetValue( pGV, NULL ); + while (pOV != NULL) { + res |= print_entry( pOV ); + pOV = optionNextValue( pGV, pOV ); + } + return res; + } + _EOF_ +echo "_EOSubr_;" >&5 + +exec 5>&- + +# # # # # # # # # # CREATE PROGRAM # # # # # # # # # + +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +compile "-?" + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +basehelp=${testname}-base.help +echo creating ${basehelp} +clean_help > ${basehelp} <<_EOF_ +test_${testname} - Test AutoOpts for ${testname} +USAGE: ${testname} [ -<flag> [<val>] ]... + Flg Arg Option-Name Description + -s Cpx struct structured argument val + - may appear multiple times + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + -> opt save-opts Save the option state to a config file + -< Str load-opts Load options from a config file + - disabled as --no-load-opts + - may appear multiple times + + +The following option preset mechanisms are supported: + - reading file ${testname}.cfg +_EOF_ + +${SED} "/ - reading file/s/ file .*/ file ${testname}.cfg/" \ + ${testname}.help > X$$ +mv -f X$$ ${testname}.help + +cmp -s ${basehelp} ${testname}.help || \ + failure "`diff ${basehelp} ${testname}.help`" + +# # # # # # # # # # SINGLE ARG TEST # # # # # # # # # + +cat > ${testname}-res1.base <<- _EOF_ + + struct opt #1: + struct -- nested: 0xXXXXXXXX + able -- no value + bar -- integer: 1234 + foo -- no value + stumble -- no value + _EOF_ + +./${testname} -s 'stumble, foo, <bar type=integer>1234</bar> able' | \ +${SED} '/ nested:/s/ 0x.*/ 0xXXXXXXXX/' > ${testname}-res1.out || \ + failure "FAILED: \ +./${testname} -s 'stumble, foo, <bar type=integer>1234</bar> baz'" + +cmp -s ${testname}-res1.* || \ + failure "`diff ${testname}-res1.*`" + +# # # # # # # # # # DOUBLE ARG TEST # # # # # # # # # + +arg1="stumble, <foo>foo${ht}lish</foo>, <bar type=integer>1234</bar>, able" +arg2='foo, <bar type=integer>4321</bar> <gr type=nested>one, two=2, three</gr>' +(./${testname} -s "${arg1}" -s "${arg2}" \ + | ${SED} '/ nested:/s/ 0x.*/ 0xXXXXXXXX/' ) > ${testname}-res2.out || \ + failure "FAILED: ./${testname} ${arg1} ${arg2}" + +cat > ${testname}-res2.base <<- _EOF_ + + struct opt #1: + struct -- nested: 0xXXXXXXXX + able -- no value + bar -- integer: 1234 + foo -- string: foo lish + stumble -- no value + + struct opt #2: + struct -- nested: 0xXXXXXXXX + bar -- integer: 4321 + foo -- no value + gr -- nested: 0xXXXXXXXX + one -- no value + three -- no value + two -- string: 2 + _EOF_ + +cmp -s ${testname}-res2.* || \ + failure "`diff ${testname}-res2.*`" + +./${testname} -s "${arg1}" -s "${arg2}" '->' +${SED} -e '3s/.*/# ***DATE***/' ${testname}.d/${testname}.cfg > ${testname}.XX +mv -f ${testname}.XX ${testname}.d/${testname}.cfg +cat > ${testname}-res3.base <<- _EOF_ + # test_nested - Test AutoOpts for nested + # preset/initialization file + # ***DATE*** + # + <struct type=nested> + <able/> + <bar type=integer>0x4D2</bar> + <foo>foo	lish</foo> + <stumble/> + </struct> + <struct type=nested> + <bar type=integer>0x10E1</bar> + <foo/> + <gr type=nested> + <one/> + <three/> + <two>2</two> + </gr> + </struct> + _EOF_ +files=${testname}-res3.base\ ${testname}.d/${testname}.cfg +cmp -s ${files} || \ + failure "saved config${nl}`diff ${files}`" + +# Copy the config file and verify that the contents are the same. +# +./${testname} "->${testname}.d/${testname}.cfg2" +${SED} -e '3s/.*/# ***DATE***/' ${testname}.d/${testname}.cfg2 > ${testname}.XX +mv -f ${testname}.XX ${testname}.d/${testname}.cfg2 +files=${testname}.d/${testname}.cfg\ ${testname}.d/${testname}.cfg2 +cmp -s ${files} || \ + failure "re-saved config${nl}`diff ${files}`" + +# # # # # # # # # # TEST OPERATION # # # # # # # # # # + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of nested.test diff --git a/autoopts/test/nls.test b/autoopts/test/nls.test new file mode 100755 index 0000000..1455515 --- /dev/null +++ b/autoopts/test/nls.test @@ -0,0 +1,156 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# nls.test --- test NLS, sort-of +# +# Time-stamp: "2011-08-07 17:36:29 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- + +. ./defs +AUTOGEN_TEMPL_DIRS=`cd ${srcdir}/..;pwd` +export AUTOGEN_TEMPL_DIRS + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo "creating ${testname}.def in `pwd`" +testname="${testname}" test_main="YES" \ +argument="${argument}" long_opts="YES" \ +${SHELLX} ${stdopts} option:'opt init' second=020 || \ + failure "Could not run stdopts.def" + +echo 'export = "extern char* gettext( char const* );";' >> ${testname}.def +CC="${CC} ${CFLAGS} -DENABLE_NLS=1 ${INC}" +CFLAGS='' +INC='' + +compile_with_nls() { + + echo ${AG_L} ${testname}.def + ${AG_L} ${testname}.def || \ + failure AutoGen could not process + + chmod u+w ${testname}.[ch] + cat >> ${testname}.c <<'_EOF_' +#include <ctype.h> +char* +gettext( char const* pzS ) +{ + static char z[ 4096 ]; + char* pzD = z + sizeof(z) - 1; + int ct = 0; + int found_nl = 0; + if (pzS == NULL) + return NULL; + if (strchr(pzS, '%') != NULL) + return (void *)pzS; + *--pzD = '\0'; + while (*pzS == ' ') pzS++; + for (;;) { + char ch = *(pzS++); + if (ch == '\0') + break; + *(--pzD) = ch; + ct++; + if (ch != '\n') + continue; + found_nl = 1; + while (*pzS == ' ') pzS++; + } + if (found_nl) + strcpy(z + sizeof(z) - 2, "\n"); + while (*pzD == '\n') + pzD++; + return pzD; +} +_EOF_ + + sedcmd='/ot sgub .* tropeR$/d;/ yb degakcaP/d' + compile "--pleh" + mv ${testname}.help ${testname}-${1}.help + cmp -s ${testname}-${1}.help ${testname}-${1}.hlp || { set +x ; \ + failure "`diff -c ${testname}-${1}.hlp ${testname}-${1}.help`" ; } +} + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +echo creating ${testname}.hlp +clean_help > ${testname}-1.hlp <<'_EOF_' +test_nls - Test AutoOpts for nls +USAGE: nls [ -<flag> [<val>] | --<name>[{=| }<val>] ]... +noitpircseD emaN-noitpO grA glF + -o rtS noitpo pircsed noitpo noitpo ehT + -s muN dnoces pircsed noitpo dnoces ehT + -? on pleh tixe dna noitamrofni egasu dednetxe yalpsiD + -! on pleh-erom regap urht dessap noitamrofni egasu dednetxE + +.retcarahc galf eht dna nehpyh +elgnis a yb ro eman rieht dna snehpyh delbuod yb deificeps era snoitpO +_EOF_ + +compile_with_nls 1 + +mv ${testname}.def ${testname}-1.def + +exec 3> ${testname}.def +cat ${testname}-1.def >&3 +echo 'full-usage = <''<''- _EOF_' >&3 +clean_help >&3 <<'_EOF_' +test_nls - Test AutoOpts for nls +USAGE: nls [ -<flag> [<val>] | --<name>[{=| }<val>] ]... + Flg Arg Option-Name Description + -o Str option The option descrip + -s Num second The second descrip + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +Options are specified by doubled hyphens and their name or by a single +hyphen and the flag character. +_EOF_ +echo '_EOF_;' >&3 +exec 3>&- + +clean_help > ${testname}-2.hlp <<'_EOF_' +.retcarahc galf eht dna nehpyh +elgnis a yb ro eman rieht dna snehpyh delbuod yb deificeps era snoitpO + +regap urht dessap noitamrofni egasu dednetxE pleh-erom on !- +tixe dna noitamrofni egasu dednetxe yalpsiD pleh on ?- +pircsed dnoces ehT dnoces muN s- +pircsed noitpo ehT noitpo rtS o- +noitpircseD emaN-noitpO grA glF +...] ]>lav<} |={[>eman<-- | ]>lav<[ >galf<- [ sln :EGASU +sln rof stpOotuA tseT - sln_tset +_EOF_ + +compile_with_nls 2 +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of nls.test diff --git a/autoopts/test/rc.test b/autoopts/test/rc.test new file mode 100755 index 0000000..18e005d --- /dev/null +++ b/autoopts/test/rc.test @@ -0,0 +1,240 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- + +# rc.test --- test loading and saving of rc files +# +# Time-stamp: "2012-05-13 13:21:58 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + +. ./defs + +AUTOOPTS_TRACE=every +AUTOOPTS_TRACE_OUT=">>`pwd`/${testname}-ag-trace.txt" +export AUTOOPTS_TRACE AUTOOPTS_TRACE_OUT + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +: "creating ${testname}.def in `pwd`" + +TESTNAME=RC +export TESTNAME + +test_main="yes" \ +argument="mumble" long_opts="yes" \ +${SHELLX} ${stdopts} option second:init third: || \ + failure "Could not run stdopts.def" + +cat >> ${testname}.def <<_EOF_ +homerc = "\$\$/${testname}.rc"; +rcfile = ${testname}.file; +environrc; +_EOF_ + +${AG_L} ${testname}.def || \ + failure AutoGen could not process A + +# # # # # # # # # # VALIDATE HELP # # # # # # # # # + +clean_help > ${testname}-base1.help <<_EOF_ +test_rc - Test AutoOpts for rc +USAGE: rc [ -<flag> [<val>] | --<name>[{=| }<val>] ]... mumble + Flg Arg Option-Name Description + -o no option The option option descrip + -s Str second The second option descrip + -t Str third The third option descrip + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + -> opt save-opts Save the option state to a config file + -< Str load-opts Load options from a config file + - disabled as --no-load-opts + - may appear multiple times + +Options are specified by doubled hyphens and their name or by a single +hyphen and the flag character. + +The following option preset mechanisms are supported: + - reading file ..../${testname}.rc/rc.file + - examining environment variables named TEST_RC_* +_EOF_ + +mkdir ${testname}.rc ${testname}.run +compile "--help" +${SED} 's@\( - reading file \).*\(/'${testname}.rc/rc.file'\)@\1....\2@' \ + ${testname}.help > ${testname}-res1.help +cmp ${testname}-*1.help || \ + failure "`diff ${testname}-*.help`" + +# # # # # # # # # # DO THE REAL TEST # # # # # # # # # + +# Install an initialization for the "second" option. +# That goes into the ${testname}.rc directory. +# We change into the ${testname}.run directory and run the program. +# It should pick up the value saved into the ${testname}.rc dir. +# +./${testname} --second=third '->'${testname}.rc/${testname}.file + +cd ${testname}.run +../${testname} -t xxx MUMBLE > ${testname}.cmds + +# This is what the output should be: +# +cat > ${testname}.test <<'_EOF_' +OPTION_CT=2 +export OPTION_CT +TEST_RC_SECOND='third' +export TEST_RC_SECOND +TEST_RC_THIRD='xxx' +export TEST_RC_THIRD +_EOF_ + + +cmp ${testname}.cmds ${testname}.test || { + df="`diff -c ${testname}.test ${testname}.cmds`" + cd .. + failure "${df}" +} + +# # # # # + +TEST_RC=--no-load ../${testname} -t xxx MUMBLE > ${testname}-2.cmds + +# This is what the output should be: +# +cat > ${testname}-2.test <<'_EOF_' +OPTION_CT=2 +export OPTION_CT +TEST_RC_THIRD='xxx' +export TEST_RC_THIRD +_EOF_ + +cmp ${testname}-2.cmds ${testname}-2.test || { + df="`diff -c ${testname}-2.test ${testname}-2.cmds`" + cd .. + failure "${df}" +} + +# # # # # # # # # # SECOND TEST OUTPUT FILE # # # # # # # # # + +cat >> ../${testname}.rc/${testname}.file <<_EOF_ +[TEST_MUMBLE] +second fourth +<!-- This is a comment + and it should have no effect --> +[TEST_${TESTNAME}] +second = fifth + +# this is another comment +# +[TEST_STUMBLE] +second : sixth +_EOF_ + +../${testname} -t yyy MUMBLE > ${testname}.cmds + +# This is what the output should be: +# +cat > ${testname}.test <<'_EOF_' +OPTION_CT=2 +export OPTION_CT +TEST_RC_SECOND='fifth' +export TEST_RC_SECOND +TEST_RC_THIRD='yyy' +export TEST_RC_THIRD +_EOF_ + +cmp ${testname}.cmds ${testname}.test || { + df="`diff -c ${testname}.test ${testname}.cmds`" + cd .. + failure "${df}" +} + +mv ../${testname}.rc/${testname}.file ../${testname}.rc/${testname}.save +( ${SED} '/^[TEST_MUMBLE]/,$d' ../${testname}.rc/${testname}.save + cat <<- _EOF_ + <?program test-mumble> + second fourth + <!-- This is a comment + and it should have no effect --> + <?program test-${testname}> + <second cooked> + fifth + </second> + # this is another comment + # + <?program test-stumble> + second : sixth + _EOF_ +) > ../${testname}.rc/${testname}.file + +../${testname} -t yyy MUMBLE > ${testname}.cmds + +cmp ${testname}.cmds ${testname}.test || { + df="USING <?program>: `diff -c ${testname}.test ${testname}.cmds`" + cd .. + failure "${df}" +} + +# # # # # # # # # # THIRD TEST OUTPUT FILE # # # # # # # # # + +cd ${testsubdir} + +echo 'disable-save;' >> ${testname}.def + +${AG_L} ${testname}.def || \ + failure AutoGen could not process B + +compile "--help" +${SED} 's@\( - reading file \).*\(/'${testname}.rc/rc.file'\)@\1....\2@' \ + ${testname}.help > ${testname}-res2.help +egrep -v ' save-opts +Save ' ${testname}-base1.help > ${testname}-base2.help + +cmp ${testname}-*2.help || \ + failure "`diff ${testname}-*2.help`" + +echo 'disable-load;' >> ${testname}.def + +${AG_L} ${testname}.def || \ + failure AutoGen could not process B + +compile "--help" +${SED} 's@\( - reading file \).*\(/'${testname}.rc/rc.file'\)@\1....\2@' \ + ${testname}.help > ${testname}-res3.help + +${SED} -e '/ load-opts *Load /,/multiple times$/d' \ + -e '/ save-opts *Save /d' \ + ${testname}-base1.help > ${testname}-base3.help + +cmp ${testname}-*3.help || \ + failure "`diff ${testname}-*3.help`" + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of rc.test diff --git a/autoopts/test/shell.test b/autoopts/test/shell.test new file mode 100755 index 0000000..1a47b2f --- /dev/null +++ b/autoopts/test/shell.test @@ -0,0 +1,457 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# shell.test --- test shell program attribute +# make sure that when it is not specified +# then option processing consumes all args. +# +# Time-stamp: "2012-08-11 08:51:08 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo "creating ${testname}.def in `pwd`" + + testname="${testname}" \ +test_main="${test_main}" \ + argument="reg-arg [ ... ]" \ +long_opts=true \ +${SHELLX} ${stdopts} option: second || failure "Could not run stdopts.def" + +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +compile "-?" + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +echo creating ${testname}.hlp +clean_help > ${testname}.hlp <<'_EOF_' +test_shell - Test AutoOpts for shell +USAGE: shell [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \ + reg-arg [ ... ] + Flg Arg Option-Name Description + -o Str option The option option descrip + -s no second The second option descrip + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +Options are specified by doubled hyphens and their name or by a single +hyphen and the flag character. +_EOF_ + +cmp -s ${testname}.h*lp || \ + failure "`diff ${testname}.hlp ${testname}.help`" + +./${testname} -X 2> /dev/null && \ + failure ${testname} should not accept bogus options + +./${testname} -o 2> /dev/null && \ + failure ${testname} should not accept missing options argument + +./${testname} 2> /dev/null && \ + failure ${testname} must have an argument + +# # # # # # # # # # SHELL OUTPUT FILE # # # # # # # # # + +echo creating ${testname}.out +cat > ${testname}.out <<_EOF_ +OPTION_CT=3 +export OPTION_CT +TEST_SHELL_OPTION='opt-arg' +export TEST_SHELL_OPTION +TEST_SHELL_SECOND=1 # 0x1 +export TEST_SHELL_SECOND +_EOF_ + +./${testname} -o opt-arg -s a1 a2 > ${testname}.test || \ + failure ${testname} did not handle its options + +cmp -s ${testname}.test ${testname}.out || \ + failure "`diff ${testname}.out ${testname}.test`" + +${SED} '/test-main/s/yes/optionParseShell/' ${testname}.def > XX +mv -f XX ${testname}.def + +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +sedcmd='/Note that.*is only useful/,/will be regenerated/d' +compile "-?" + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +echo creating second ${testname}.hlp +clean_help > ${testname}.hlp <<'_EOF_' +genshellopt - Generate Shell Option Processing Script - Ver. 1 +USAGE: shell [ -<flag> [<val>] | --<name>[{=| }<val>] ]... + Flg Arg Option-Name Description + -o Str script Output Script File + -s Str shell Shell name (follows "#!" magic) + - disabled as --no-shell + - enabled by default + -v opt version Output version information and exit + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +Options are specified by doubled hyphens and their name or by a single +hyphen and the flag character. + +Note that ``shell'' is only useful if the output file does not already +exist. If it does, then the shell name and optional first argument will +be extracted from the script file. + +If the script file already exists and contains Automated Option Processing +text, the second line of the file through the ending tag will be replaced +by the newly generated text. The first ``#!'' line will be regenerated. + += = = = = = = = + +This incarnation of genshell will produce +a shell script to parse the options for test_shell: + +test_shell - Test AutoOpts for shell +USAGE: test_shell [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \ + reg-arg [ ... ] + Flg Arg Option-Name Description + -o Str option The option option descrip + -s no second The second option descrip + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +Options are specified by doubled hyphens and their name or by a single +hyphen and the flag character. +_EOF_ + +files=${testname}.hlp\ ${testname}.help +cmp -s ${files} || \ + failure "script generator help output mismatch: `diff -c ${files}`" + +# # # # # # # # # # SCRIPT OUTPUT FILE # # # # # # # # # + +echo creating ${testname}.sht +exec 3> ${testname}.sht +echo "#! ${SHELL}" >&3 +cat >&3 <<'_EOF_' +# +TEST_SHELL_LONGUSAGE_TEXT='test_shell - Test AutoOpts for shell +USAGE: test_shell [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \ + reg-arg [ ... ] + Flg Arg Option-Name Description + -o Str option The option option descrip + -s no second The second option descrip + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +Options are specified by doubled hyphens and their name or by a single +hyphen and the flag character.' + +TEST_SHELL_USAGE_TEXT='test_shell - Test AutoOpts for shell +USAGE: test_shell [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \ + reg-arg [ ... ] + Flg Arg Option-Name Description + -o Str option The option option descrip + -s no second The second option descrip + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +Options are specified by doubled hyphens and their name or by a single +hyphen and the flag character.' + + +TEST_SHELL_OPTION=${TEST_SHELL_OPTION} +TEST_SHELL_OPTION_set=false +export TEST_SHELL_OPTION + +TEST_SHELL_SECOND=${TEST_SHELL_SECOND} +TEST_SHELL_SECOND_set=false +export TEST_SHELL_SECOND + +OPT_PROCESS=true +OPT_ARG=$1 +while ${OPT_PROCESS} && [ $# -gt 0 ] +do + OPT_ELEMENT='' + OPT_ARG_VAL='' + + case "${OPT_ARG}" in + -- ) + OPT_PROCESS=false + shift + ;; + --* ) + OPT_CODE=`echo "X${OPT_ARG}"|sed 's/^X-*//'` + shift + OPT_ARG=$1 + case "${OPT_CODE}" in *=* ) + OPT_ARG_VAL=`echo "${OPT_CODE}"|sed 's/^[^=]*=//'` + OPT_CODE=`echo "${OPT_CODE}"|sed 's/=.*$//'` ;; esac + case "${OPT_CODE}" in + 'op' | \ + 'opt' | \ + 'opti' | \ + 'optio' | \ + 'option' ) + if [ -n "${TEST_SHELL_OPTION}" ] && ${TEST_SHELL_OPTION_set} ; then + echo Error: duplicate OPTION option >&2 + echo "$TEST_SHELL_USAGE_TEXT" + exit 1 ; fi + TEST_SHELL_OPTION_set=true + OPT_NAME='OPTION' + OPT_ARG_NEEDED=YES + ;; + + 'se' | \ + 'sec' | \ + 'seco' | \ + 'secon' | \ + 'second' ) + if [ -n "${TEST_SHELL_SECOND}" ] && ${TEST_SHELL_SECOND_set} ; then + echo Error: duplicate SECOND option >&2 + echo "$TEST_SHELL_USAGE_TEXT" + exit 1 ; fi + TEST_SHELL_SECOND_set=true + OPT_NAME='SECOND' + eval TEST_SHELL_SECOND${OPT_ELEMENT}=true + export TEST_SHELL_SECOND${OPT_ELEMENT} + OPT_ARG_NEEDED=NO + ;; + + 'he' | \ + 'hel' | \ + 'help' ) + echo "$TEST_SHELL_LONGUSAGE_TEXT" + exit 0 + ;; + + 'mo' | \ + 'mor' | \ + 'more' | \ + 'more-' | \ + 'more-h' | \ + 'more-he' | \ + 'more-hel' | \ + 'more-help' ) + echo "$TEST_SHELL_LONGUSAGE_TEXT" | ${PAGER-more} + exit 0 + ;; + + * ) + echo Unknown option: "${OPT_CODE}" >&2 + echo "$TEST_SHELL_USAGE_TEXT" + exit 1 + ;; + esac + + case "${OPT_ARG_NEEDED}" in + NO ) + OPT_ARG_VAL='' + ;; + YES ) + if [ -z "${OPT_ARG_VAL}" ] + then + if [ $# -eq 0 ] + then + echo No argument provided for ${OPT_NAME} option >&2 + echo "$TEST_SHELL_USAGE_TEXT" + exit 1 + fi + OPT_ARG_VAL=${OPT_ARG} + shift + OPT_ARG=$1 + fi + ;; + OK ) + if [ -z "${OPT_ARG_VAL}" ] && [ $# -gt 0 ] + then + case "${OPT_ARG}" in -* ) ;; * ) + OPT_ARG_VAL=${OPT_ARG} + shift + OPT_ARG=$1 ;; esac + fi + ;; + esac + ;; + + -* ) + OPT_CODE=`echo "X${OPT_ARG}" | sed 's/X-\(.\).*/\1/'` + OPT_ARG=` echo "X${OPT_ARG}" | sed 's/X-.//'` + case "${OPT_CODE}" in + 'o' ) + if [ -n "${TEST_SHELL_OPTION}" ] && ${TEST_SHELL_OPTION_set} ; then + echo Error: duplicate OPTION option >&2 + echo "$TEST_SHELL_USAGE_TEXT" + exit 1 ; fi + TEST_SHELL_OPTION_set=true + OPT_NAME='OPTION' + OPT_ARG_NEEDED=YES + ;; + + 's' ) + if [ -n "${TEST_SHELL_SECOND}" ] && ${TEST_SHELL_SECOND_set} ; then + echo Error: duplicate SECOND option >&2 + echo "$TEST_SHELL_USAGE_TEXT" + exit 1 ; fi + TEST_SHELL_SECOND_set=true + OPT_NAME='SECOND' + eval TEST_SHELL_SECOND${OPT_ELEMENT}=true + export TEST_SHELL_SECOND${OPT_ELEMENT} + OPT_ARG_NEEDED=NO + ;; + + '?' ) + echo "$TEST_SHELL_LONGUSAGE_TEXT" + exit 0 + ;; + + '!' ) + echo "$TEST_SHELL_LONGUSAGE_TEXT" | ${PAGER-more} + exit 0 + ;; + + * ) + echo Unknown flag: "${OPT_CODE}" >&2 + echo "$TEST_SHELL_USAGE_TEXT" + exit 1 + ;; + esac + + case "${OPT_ARG_NEEDED}" in + NO ) + if [ -n "${OPT_ARG}" ] + then + OPT_ARG=-${OPT_ARG} + else + shift + OPT_ARG=$1 + fi + ;; + YES ) + if [ -n "${OPT_ARG}" ] + then + OPT_ARG_VAL=${OPT_ARG} + else + if [ $# -eq 0 ] + then + echo No argument provided for ${OPT_NAME} option >&2 + echo "$TEST_SHELL_USAGE_TEXT" + exit 1 + fi + shift + OPT_ARG_VAL=$1 + fi + shift + OPT_ARG=$1 + ;; + OK ) + if [ -n "${OPT_ARG}" ] + then + OPT_ARG_VAL=${OPT_ARG} + shift + OPT_ARG=$1 + else + shift + if [ $# -gt 0 ] + then + case "$1" in -* ) ;; * ) + OPT_ARG_VAL=$1 + shift ;; esac + OPT_ARG=$1 + fi + fi + ;; + esac + ;; + + * ) + OPT_PROCESS=false + ;; + esac + if [ -n "${OPT_ARG_VAL}" ] + then + eval TEST_SHELL_${OPT_NAME}${OPT_ELEMENT}="'${OPT_ARG_VAL}'" + export TEST_SHELL_${OPT_NAME}${OPT_ELEMENT} + fi +done +unset OPT_PROCESS || : +unset OPT_ELEMENT || : +unset OPT_ARG || : +unset OPT_ARG_NEEDED || : +unset OPT_NAME || : +unset OPT_CODE || : +unset OPT_ARG_VAL || : + +# # # # # # # # # # +# +# END OF AUTOMATED OPTION PROCESSING +# +# # # # # # # # # # -- do not modify this marker -- + +env | grep '^TEST_SHELL_' +_EOF_ +exec 3>&- + +# # # # # # # # # # SCRIPT OUTPUT TESTING # # # # # # # # # + +rm -f ${testname}.sh +./${testname} -o ${testname}.sh + +sedcmd='2,/From the.*option def/d' +${FGREP} 'Packaged by ' ${testname}.sh >/dev/null && { + sedcmd=${sedcmd}${nl}'/^Packaged by /d + /^Report .* bugs to /d + /and the flag character\.$/s/$/'"'/" +} + +${SED} "$sedcmd" ${testname}.sh > ${testname}.shx +cmp -s ${testname}.sh[tx] || \ + failure "`diff ${testname}.sh[tx]`" + +# # # # # # # # # # SCRIPT PROCESSING TEST # # # # # # # # # + +./${testname}.sh --opt opt-arg -s a1 a2 | sort > ${testname}.test || \ + failure ${testname} did not handle its options + +sort > ${testname}.out <<_EOF_ +TEST_SHELL_OPTION=opt-arg +TEST_SHELL_SECOND=true +_EOF_ + +cmp -s ${testname}.out ${testname}.test || \ + failure "`diff ${testname}.out ${testname}.test`" + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of shell.test diff --git a/autoopts/test/stdopts.def b/autoopts/test/stdopts.def new file mode 100644 index 0000000..e89745c --- /dev/null +++ b/autoopts/test/stdopts.def @@ -0,0 +1,109 @@ +#! /bin/sh + +## Time-stamp: "2012-05-13 12:44:49 bkorb" +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd + +# This is the standard set of options for testing option processing +# It is expected to be dot + +exec 5> $testname.def +cat >&5 <<- _EOF_ + + AutoGen definitions options; + + config-header = 'config.h'; + prog-name = "test_${testname}"; + prog-title = "Test AutoOpts for ${testname}"; + _EOF_ + +echo test_main $test_main +echo argument $argument +echo long_opts $long_opts + +{ + test -n "${test_main}" && echo "test-main = '${test_main}';" + test -n "${argument}" && echo "argument = '${argument}';" + test -n "${long_opts}" && echo "long-opts;" +} >&5 + +for flag +do + fname=`echo "${flag}" | ${SED} 's/[^a-zA-Z0-9_-].*//'` + flag=`echo "${flag}" | ${SED} "s/^${fname}//"` + + case "${flag}" in + :* ) + aval=`echo $flag | ${SED} 's/^://'` + arg=" arg-type = string;" + test -n "${aval}" && arg="${arg} arg_default = '${aval}';" + ;; + + =* ) + aval=`echo $flag | ${SED} 's/=//'` + arg=" arg-type = number;" + test -n "${aval}" && arg="${arg} arg_default = '${aval}';" + ;; + + @* ) + arg=`echo $flag | ${SED} 's/@//'` + case "${arg}" in + *=* ) default=`echo $flag | ${SED} 's/.*=//'` + arg=`echo $arg | ${SED} 's/=.*//'` + arg=" arg-type = '${arg}'; arg-default='${default}';" + ;; + + * ) + arg=" arg-type = '${arg}';" + ;; + esac + ;; + + * ) + unset arg + ;; + esac + + cat <<-_EOF_ + flag = { + name = "${fname}"; + descrip = "The ${fname} option descrip"; + _EOF_ + + ${use_flags} && { + fname=`echo ${fname} | ${SED} 's/\(.\).*/\1/'` + echo " value = '${fname}';" + } + test -n "${arg}" && echo "${arg}" + echo "};" + echo +done >&5 + +exec 5>&- +ls -l ${testname}.def + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of stdopts.def diff --git a/autoopts/test/stdopts.test b/autoopts/test/stdopts.test new file mode 100755 index 0000000..21ba56c --- /dev/null +++ b/autoopts/test/stdopts.test @@ -0,0 +1,161 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# stdopts.test --- test standard options +# +# Time-stamp: "2013-03-10 07:14:45 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo "creating ${testname}.def in `pwd`" +cat > ${testname}.def <<- _EOF_ + + AutoGen Definitions options; + + prog-name = test_${testname}; + prog-title = "${testname} test"; + config-header = 'config.h'; + test-main; + long-opts; + + #define VERBOSE_ENUM + #define VERBOSE_FLAG + + #include stdoptions + _EOF_ + +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +compile "-?" + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +echo creating ${testname}.hlp +clean_help > ${testname}.hbase <<- _EOF_ + test_stdopts - stdopts test + USAGE: stdopts [ -<flag> [<val>] | --<name>[{=| }<val>] ]... + + The following options are commonly used and are provided and supported + by AutoOpts: + + Flg Arg Option-Name Description + -V KWd verbose run program with progress info + + version, usage and configuration options: + + Flg Arg Option-Name Description + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + + Options are specified by doubled hyphens and their name or by a single + hyphen and the flag character. + + The valid "verbose" option keywords are: + silent quiet brief informative verbose + or an integer from 0 through 4 + _EOF_ + +# When building with DEBUG set, we get an unanticipated option: +# +${GREP} -v 'run program with debugging info' ${testname}.help > ${testname}.hres + +cmp -s ${testname}.h[br]* || \ + failure "MISCOMPARE: `diff ${testname}.h[br]*`" + +./${testname} --verbose=exp > /dev/null 2>&1 && \ + failure ${testname} accepted ambiguous keyword + +./${testname} --verbose=inf > ${testname}.out || \ + failure ${testname} did not handle its options + +cat > ${testname}.oex <<_EOF_ +OPTION_CT=1 +export OPTION_CT +TEST_STDOPTS_VERBOSE='informative' +export TEST_STDOPTS_VERBOSE +_EOF_ + +cmp -s ${testname}.o* || \ + failure "`diff ${testname}.o??`" + +# # # # # # # # # # USAGE OPTION # # # # # # # # # # # + +( ${SED} "s/${testname}/${testname}-2/g" ${testname}.def + echo 'usage-opt;' +) > ${testname}-2.def + +testname=${testname}-2 + +${AG_L} ${testname}.def || { + testname=${testname%-2} + failure AutoGen could not process +} + +compile "--usage" + +clean_help > ${testname}.hbase <<- _EOF_ + test_stdopts-2 - stdopts-2 test + USAGE: stdopts-2 [ -<flag> [<val>] | --<name>[{=| }<val>] ]... + Flg Arg Option-Name Description + -V KWd verbose run program with progress info + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + -u no usage Abbreviated usage to stdout + + Options are specified by doubled hyphens and their name or by a single + hyphen and the flag character. + _EOF_ + +# When building with DEBUG set, we get an unanticipated option: +# +${GREP} -v 'run program with debugging info' ${testname}.help > ${testname}.hres + +cmp -s ${testname}.h[br]* || { + testname=${testname%-2} + failure "MISCOMPARE: `diff ${testname}-2.h[br]*`" +} + +use=` + set +x + exec 2>&1 + exec 1>/dev/null + ./${testname} --usage` +test $? -eq 0 || failure usage failure +test "X${use}" = X || failure misdirected usage + +testname=${testname%-2} +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of stdopts.test diff --git a/autoopts/test/time.test b/autoopts/test/time.test new file mode 100755 index 0000000..855ae88 --- /dev/null +++ b/autoopts/test/time.test @@ -0,0 +1,101 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# time.test --- test time duration argument +# +# Time-stamp: "2011-08-07 17:34:14 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo "creating ${testname}.def in `pwd`" +unset test_main +export testname argument long_opts + +${SHELLX} ${stdopts} ${testname}@time='1d 2 h 15:10' +here='<<' +cat >> ${testname}.def <<- _EOF_ + main = { + main-type = main; + main-text = ${here}- CodeEnd + printf("arg %s represents %d seconds", argv[-1], + OPT_VALUE_TIME); + return 0; + CodeEnd; + }; + _EOF_ + +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +compile "-?" + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +basehlp=${testname}.hlp +echo creating ${basehlp} +clean_help > ${basehlp} <<'_EOF_' +test_time - Test AutoOpts for time +USAGE: time [ -<flag> [<val>] ]... + Flg Arg Option-Name Description + -t Tim time The time option descrip + -? no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +_EOF_ + +cmp -s ${testname}.h*lp || \ + failure "`diff ${basehlp} ${testname}.help`" + +time_val=213791 + +ck() { + tim=`./${testname} -t "$*" | \ + ${SED} -n 's/.* represents \([0-9]*\) seconds/\1/p'` + test -z "${tim}" && failure ${testname} could not parse "$*" + test ${tim} -eq ${time_val} || \ + failure ${testname} misevaluated "$*" +} + +ck 2 d 11h 23:11 +ck 2 d 11h 23m 11s + +tim=`./${testname} -t '2 d 10h 83:11'` && \ + failure ${testname} handled bad options + +# # # # # # # # # # T E S T E N D # # # # # # # # # # + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of argument.test diff --git a/autoopts/test/usage.test b/autoopts/test/usage.test new file mode 100755 index 0000000..33a21a5 --- /dev/null +++ b/autoopts/test/usage.test @@ -0,0 +1,656 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# usage.test --- test all the ways usage text can be printed. +# +## Time-stamp: "2011-08-07 17:20:27 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- + +${VERBOSE} && kill_delay=10 || kill_delay=5 +. ./defs + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +# ============= usage_LGFRA.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_LGFRA.hlp' +test_usage_LGFRA - Checkout usage_LGFRA Options +USAGE: usage_LGFRA { -<flag> [<val>] | --<name>[{=| }<val>] }... \ + cmd-arg ... +X +X -L, --check-dirs=str Checkout directory list +X --show-defs[=arg] Show the definition tree +X -?, --help Display extended usage information and exit +X -!, --more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_LGFRp.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_LGFRp.hlp' +test_usage_LGFRp - Checkout usage_LGFRp Options +USAGE: usage_LGFRp { -<flag> | --<name> }... cmd-arg ... +X +X -L, --check-dirs Checkout directory list +X --show-defs Show the definition tree +X -?, --help Display extended usage information and exit +X -!, --more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_LGFoA.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_LGFoA.hlp' +test_usage_LGFoA - Checkout usage_LGFoA Options +USAGE: usage_LGFoA [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \ + cmd-arg ... +X +X -L, --check-dirs=str Checkout directory list +X --show-defs[=arg] Show the definition tree +X -?, --help Display extended usage information and exit +X -!, --more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_LGFop.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_LGFop.hlp' +test_usage_LGFop - Checkout usage_LGFop Options +USAGE: usage_LGFop [ -<flag> | --<name> ]... cmd-arg ... +X +X -L, --check-dirs Checkout directory list +X --show-defs Show the definition tree +X -?, --help Display extended usage information and exit +X -!, --more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_LGsRA.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_LGsRA.hlp' +test_usage_LGsRA - Checkout usage_LGsRA Options +USAGE: usage_LGsRA { --<name>[{=| }<val>] }... cmd-arg ... +X +X --check-dirs=str Checkout directory list +X --show-defs[=arg] Show the definition tree +X --help Display extended usage information and exit +X --more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_LGsRp.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_LGsRp.hlp' +test_usage_LGsRp - Checkout usage_LGsRp Options +USAGE: usage_LGsRp { --<name> }... cmd-arg ... +X +X --check-dirs Checkout directory list +X --show-defs Show the definition tree +X --help Display extended usage information and exit +X --more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_LGsoA.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_LGsoA.hlp' +test_usage_LGsoA - Checkout usage_LGsoA Options +USAGE: usage_LGsoA [ --<name>[{=| }<val>] ]... cmd-arg ... +X +X --check-dirs=str Checkout directory list +X --show-defs[=arg] Show the definition tree +X --help Display extended usage information and exit +X --more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_LGsop.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_LGsop.hlp' +test_usage_LGsop - Checkout usage_LGsop Options +USAGE: usage_LGsop [ --<name> ]... cmd-arg ... +X +X --check-dirs Checkout directory list +X --show-defs Show the definition tree +X --help Display extended usage information and exit +X --more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_LaFRA.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_LaFRA.hlp' +test_usage_LaFRA - Checkout usage_LaFRA Options +USAGE: usage_LaFRA { -<flag> [<val>] | --<name>[{=| }<val>] }... \ + cmd-arg ... +X Flg Arg Option-Name Req? Description +X -L Str check-dirs YES Checkout directory list +X opt show-defs opt Show the definition tree +X -? no help opt Display extended usage information and exit +X -! no more-help opt Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_LaFRp.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_LaFRp.hlp' +test_usage_LaFRp - Checkout usage_LaFRp Options +USAGE: usage_LaFRp { -<flag> | --<name> }... cmd-arg ... +X Flg Arg Option-Name Req? Description +X -L no check-dirs YES Checkout directory list +X no show-defs opt Show the definition tree +X -? no help opt Display extended usage information and exit +X -! no more-help opt Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_LaFoA.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_LaFoA.hlp' +test_usage_LaFoA - Checkout usage_LaFoA Options +USAGE: usage_LaFoA [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \ + cmd-arg ... +X Flg Arg Option-Name Description +X -L Str check-dirs Checkout directory list +X opt show-defs Show the definition tree +X -? no help Display extended usage information and exit +X -! no more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_LaFop.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_LaFop.hlp' +test_usage_LaFop - Checkout usage_LaFop Options +USAGE: usage_LaFop [ -<flag> | --<name> ]... cmd-arg ... +X Flg Arg Option-Name Description +X -L no check-dirs Checkout directory list +X no show-defs Show the definition tree +X -? no help Display extended usage information and exit +X -! no more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_LasRA.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_LasRA.hlp' +test_usage_LasRA - Checkout usage_LasRA Options +USAGE: usage_LasRA { --<name>[{=| }<val>] }... cmd-arg ... +X Arg Option-Name Req? Description +X Str check-dirs YES Checkout directory list +X opt show-defs opt Show the definition tree +X no help opt Display extended usage information and exit +X no more-help opt Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_LasRp.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_LasRp.hlp' +test_usage_LasRp - Checkout usage_LasRp Options +USAGE: usage_LasRp { --<name> }... cmd-arg ... +X Arg Option-Name Req? Description +X no check-dirs YES Checkout directory list +X no show-defs opt Show the definition tree +X no help opt Display extended usage information and exit +X no more-help opt Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_LasoA.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_LasoA.hlp' +test_usage_LasoA - Checkout usage_LasoA Options +USAGE: usage_LasoA [ --<name>[{=| }<val>] ]... cmd-arg ... +X Arg Option-Name Description +X Str check-dirs Checkout directory list +X opt show-defs Show the definition tree +X no help Display extended usage information and exit +X no more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_Lasop.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_Lasop.hlp' +test_usage_Lasop - Checkout usage_Lasop Options +USAGE: usage_Lasop [ --<name> ]... cmd-arg ... +X Arg Option-Name Description +X no check-dirs Checkout directory list +X no show-defs Show the definition tree +X no help Display extended usage information and exit +X no more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_sGFRA.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_sGFRA.hlp' +test_usage_sGFRA - Checkout usage_sGFRA Options +USAGE: usage_sGFRA { -<flag> [<val>] }... cmd-arg ... +X +X -L str Checkout directory list +X -s [arg] Show the definition tree +X -? Display extended usage information and exit +X -! Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_sGFRp.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_sGFRp.hlp' +test_usage_sGFRp - Checkout usage_sGFRp Options +USAGE: usage_sGFRp { -<flag> }... cmd-arg ... +X +X -L Checkout directory list +X -s Show the definition tree +X -? Display extended usage information and exit +X -! Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_sGFoA.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_sGFoA.hlp' +test_usage_sGFoA - Checkout usage_sGFoA Options +USAGE: usage_sGFoA [ -<flag> [<val>] ]... cmd-arg ... +X +X -L str Checkout directory list +X -s [arg] Show the definition tree +X -? Display extended usage information and exit +X -! Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_sGFop.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_sGFop.hlp' +test_usage_sGFop - Checkout usage_sGFop Options +USAGE: usage_sGFop [ -<flag> ]... cmd-arg ... +X +X -L Checkout directory list +X -s Show the definition tree +X -? Display extended usage information and exit +X -! Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_sGsRA.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_sGsRA.hlp' +test_usage_sGsRA - Checkout usage_sGsRA Options +USAGE: usage_sGsRA { <option-name>[{=| }<val>] }... +X +X check-dirs=str Checkout directory list +X show-defs[=arg] Show the definition tree +X help Display extended usage information and exit +X more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_sGsRp.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_sGsRp.hlp' +test_usage_sGsRp - Checkout usage_sGsRp Options +USAGE: usage_sGsRp { <option-name> }... +X +X check-dirs Checkout directory list +X show-defs Show the definition tree +X help Display extended usage information and exit +X more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_sGsoA.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_sGsoA.hlp' +test_usage_sGsoA - Checkout usage_sGsoA Options +USAGE: usage_sGsoA [ <option-name>[{=| }<val>] ]... +X +X check-dirs=str Checkout directory list +X show-defs[=arg] Show the definition tree +X help Display extended usage information and exit +X more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_sGsop.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_sGsop.hlp' +test_usage_sGsop - Checkout usage_sGsop Options +USAGE: usage_sGsop [ <option-name> ]... +X +X check-dirs Checkout directory list +X show-defs Show the definition tree +X help Display extended usage information and exit +X more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_saFRA.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_saFRA.hlp' +test_usage_saFRA - Checkout usage_saFRA Options +USAGE: usage_saFRA { -<flag> [<val>] }... cmd-arg ... +X Flg Arg Option-Name Req? Description +X -L Str check-dirs YES Checkout directory list +X -s opt show-defs opt Show the definition tree +X -? no help opt Display extended usage information and exit +X -! no more-help opt Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_saFRp.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_saFRp.hlp' +test_usage_saFRp - Checkout usage_saFRp Options +USAGE: usage_saFRp { -<flag> }... cmd-arg ... +X Flg Arg Option-Name Req? Description +X -L no check-dirs YES Checkout directory list +X -s no show-defs opt Show the definition tree +X -? no help opt Display extended usage information and exit +X -! no more-help opt Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_saFoA.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_saFoA.hlp' +test_usage_saFoA - Checkout usage_saFoA Options +USAGE: usage_saFoA [ -<flag> [<val>] ]... cmd-arg ... +X Flg Arg Option-Name Description +X -L Str check-dirs Checkout directory list +X -s opt show-defs Show the definition tree +X -? no help Display extended usage information and exit +X -! no more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_saFop.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_saFop.hlp' +test_usage_saFop - Checkout usage_saFop Options +USAGE: usage_saFop [ -<flag> ]... cmd-arg ... +X Flg Arg Option-Name Description +X -L no check-dirs Checkout directory list +X -s no show-defs Show the definition tree +X -? no help Display extended usage information and exit +X -! no more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_sasRA.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_sasRA.hlp' +test_usage_sasRA - Checkout usage_sasRA Options +USAGE: usage_sasRA { <option-name>[{=| }<val>] }... +X Arg Option-Name Req? Description +X Str check-dirs YES Checkout directory list +X opt show-defs opt Show the definition tree +X no help opt Display extended usage information and exit +X no more-help opt Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_sasRp.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_sasRp.hlp' +test_usage_sasRp - Checkout usage_sasRp Options +USAGE: usage_sasRp { <option-name> }... +X Arg Option-Name Req? Description +X no check-dirs YES Checkout directory list +X no show-defs opt Show the definition tree +X no help opt Display extended usage information and exit +X no more-help opt Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_sasoA.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_sasoA.hlp' +test_usage_sasoA - Checkout usage_sasoA Options +USAGE: usage_sasoA [ <option-name>[{=| }<val>] ]... +X Arg Option-Name Description +X Str check-dirs Checkout directory list +X opt show-defs Show the definition tree +X no help Display extended usage information and exit +X no more-help Extended usage information passed thru pager +SHAR_EOF + +# ============= usage_sasop.hlp ============== +${SED} 's/^X//;/^[ ]*$/d' << 'SHAR_EOF' > 'usage_sasop.hlp' +test_usage_sasop - Checkout usage_sasop Options +USAGE: usage_sasop [ <option-name> ]... +X Arg Option-Name Description +X no check-dirs Checkout directory list +X no show-defs Show the definition tree +X no help Display extended usage information and exit +X no more-help Extended usage information passed thru pager +SHAR_EOF + +# # # # # # # # # # DEFINITIONS FILES # # # # # # # # # + +emit_defs() +{ + exec 4> $1.def + cat >&4 <<- _EOF_ + AutoGen Definitions options; + prog-name = test_$1; + prog-title = "Checkout $1 Options"; + config-header = 'config.h'; + test-main; + _EOF_ + + cmd_arg="argument = 'cmd-arg ...';" + if ${long_opts} + then + echo "long-opts;" >&4 + if ${flag_opts} + then detail="Long and short (flag) options are accepted." + else detail="Only long options are accepted." ; fi + else + if ${flag_opts} + then detail="Only short (flag) options are accepted." + else detail="All command line arguments must be named options." + cmd_arg='' + fi + fi + + if ${gnu_usage} + then + echo "gnu-usage;" >&4 + detail="${detail}${nl}Usage should be in GNU style." + else + detail="${detail}${nl}Usage is in AutoOpts traditional style." + fi + + cat >&4 <<- _EOF_ + ${cmd_arg} + flag = { + name = check_dirs; + descrip = "Checkout directory list"; + _EOF_ + + if ${flag_opts} + then + echo " value = L;" >&4 + fi + + if ${req_opts} + then + echo " min = '1';" >&4 + detail="${detail}${nl}The check-dirs option is required." + else + detail="${detail}${nl}There are no required options." + fi + + if ${arg_opts} + then + echo " arg-type = string;" >&4 + echo " arg-name = dir;" >&4 + detail="${detail}${nl}Some options require arguments." + else + detail="${detail}${nl}No options require arguments." + fi + + cat >&4 <<- _EOF_ + }; + + flag = { + name = show_defs; + descrip = "Show the definition tree"; + _EOF_ + + if ${flag_opts} + then + ${long_opts} || echo " value = s;" >&4 + fi + + if ${arg_opts} + then + echo " arg-type = number;" >&4 + echo " arg-name = depth;" >&4 + echo " arg-optional;" >&4 + fi + + echo "};" >&4 + echo "detail = '${detail}';" >&4 + + exec 4>&- +} + +run_usage_test() { + ${arg_opts} && name="${rname}A" || name="${rname}p" + testname=${tname}_${name} + emit_defs ${testname} + test_list="${test_list} ${testname}" + echo firstline >> ${defnames_raw} + ${AG_L} ${testname}.def >> ${defnames_raw} || { + cat ${defnames_raw} + failure "AutoGen could not process $testname" + } + + ${SED} \ + -e '1,/definition names looked up/d' \ + -e '/end of looked up def/,$d' ${defnames_raw} \ + ${defnames_raw} >> ${defnames_file} + compile ${helpstr} + ${SED} -e '/Extended usage information passed thru pager/q' \ + ${testname}.help > XXX + mv XXX ${testname}.help + cmp -s ${testname}.help ${testname}.hlp || \ + failure "FAILED ${testname} hlp -> help +`diff ${testname}.hlp ${testname}.help`" +} + +test_list="" +tname=${testname} +defnames_raw=${TMPDIR}/defnames.raw +defnames_file=${TMPDIR}/defnames.uniq +AG_L=${AG_L}\ --used-defines + +case "$-" in +*x* ) setx='set -x' ;; +* ) setx='' ;; +esac + +stime=$(date +%s) + +for long_opts in true false +do + ${long_opts} && lname=L || lname=s + + for gnu_usage in true false + do + ${gnu_usage} && uname="${lname}G" || uname="${lname}a" + + for flag_opts in true false + do + ${flag_opts} && fname="${uname}F" || fname="${uname}s" + + if ${long_opts} + then helpstr=--help + + elif ${flag_opts} + then helpstr='-?' + + else helpstr=help + fi + + for req_opts in true false + do + ${req_opts} && rname="${fname}R" || rname="${fname}o" + + for arg_opts in true false + do + run_usage_test + done + done + done + done +done + +test -z "${DEBUG_USAGE}" && cleanup && exit 0 + +sort -u -o ${defnames_file} ${defnames_file} +cat > ${defnames_raw} <<- _EOF_ + aliases + allow_errors + arg_default + arg_optional + arg_range + arg_type + argument + call_proc + code + config_header + copyright + default + deprecated + descrip + detail + disable + documentation + eaddr + enable + enabled + environrc + equivalence + exit_name + explain + export + extract_code + field + file_fail_code + flag + flag_code + flag_proc + flags_cant + flags_must + full_usage + gnu_usage + guard_option_names + help_value + homerc + ifdef + ifndef + immed_disable + immediate + include + lib_name + library + long_opts + main + main_text + main_type + max + min + more_help_value + must_set + name + no_command + no_libopts + no_misuse_usage + no_preset + no_xlate + nomem_fail_code + omitted_usage + package + prefix + prefix_enum + preserve_case + prog_name + prog_title + reorder_args + resettable + scaled + settable + short_usage + stack_arg + std_value + test_main + translators + unstack_arg + usage + usage_message + usage_opt + usage_type + val_name + val_upname + value + version + _EOF_ + +cmp ${defnames_raw} ${defnames_file} || \ + failure "${defnames_raw} and ${defnames_file} do not compare${nl}` + diff ${defnames_raw} ${defnames_file}`" +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of usage.test diff --git a/autoopts/test/vendor.test b/autoopts/test/vendor.test new file mode 100755 index 0000000..a9d0ac8 --- /dev/null +++ b/autoopts/test/vendor.test @@ -0,0 +1,174 @@ +#! /bin/sh +# -*- Mode: shell-script -*- +# ---------------------------------------------------------------------- +# vendor.test --- test the vendor-opt option +# +# Time-stamp: "2012-03-31 13:11:19 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +# +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +{ + sedcmd=' +s/long-opts;/vendor-opt;/ +/#include "autogen.h"/d +/^prog-name/s/=.*/= '${testname}';/ +s/AutoGen/'${testname}'/g +/^include /s/= '${testname}'5 Temp/= AutoGen5 Temp/ +/^config-header/s/=.*/= '${testname}'-config.h;/ +/call-proc *=/d +/#ifndef XML/,/^#endif/ { + /^#else/,/^#endif/d + /^#/d +} +/flag-code =.*_EOCode_/,/_EOCode_;/d +/flag-code *=/d +' + + ${SED} "$sedcmd" ${top_srcdir}/agen5/opts.def + cat <<- _EOF_ + config-header = ${testname}-config.h; + help-value = h; + save-opts-value = S; + load-opts-value = P; + gnu-usage; + main = { main-type = shell-process; }; + include = '#undef DEBUG_ENABLED'; + _EOF_ +} > ${testname}.def + +{ + sed '/^#endif.*_CONFIG_H/d' ${top_builddir}/config.h + sed '1,/#define *COMPAT_H_GUARD/d + /^#endif .* COMPAT_H_GUARD/{ + s/COMPAT_H_GUARD/AUTOGEN_CONFIG_H/ + q + }' ${top_srcdir}/compat/compat.h +} > ./${testname}-config.h + +echo ${AG_L} ${testname}.def +${AG_L} ${testname}.def || \ + failure AutoGen could not process + +sedcmd='' +HOME=${TMPDIR} compile "-h" +${SED} 1d ${testname}.help > ${testname}.$$ +mv -f ${testname}.$$ ${testname}.help + +clean_help > ${testname}.hlp <<_EOF_ +USAGE: ${testname} [ -<flag> [<val>] ]... [ <def-file> ] +The following options select definitions, templates and scheme functions +to use: + -L str Template search directory list + - may appear multiple times + -T str Override template file + - may not be preset + -l str Library template file + - may appear multiple times + -S str Scheme code file to load + -F str Load scheme function library + -m Do not use in-mem streams +The following options modify how output is handled: + -b str Base name for output file(s) + - may not be preset +The following options are often useful while debugging new templates: + -t num Time limit for server shell + - It must be in the range: + 0 to 3600 + --- show-defs This option has been disabled + -C Leave a core dump on a failure exit +These options can be used to control what gets processed in the +definitions files and template files: + -s str Omit the file with this suffix + - prohibits these options: + select-suffix + - may not be preset + - may appear multiple times + -o str specify this output suffix + - may not be preset + - may appear multiple times + -D str name to add to definition list + - may appear multiple times + -U str definition list removal pattern + - an alternate for define +This option is used to automate dependency tracking: + -M [arg] emit make dependency file + - may not be preset + - may appear multiple times +version, usage and configuration options: + -R str Reset an option's state + -v [arg] Output version information and exit + -h Display extended usage information and exit + -! Extended usage information passed thru pager + -u Abbreviated usage to stdout + -S [arg] Save the option state to a config file + -P str Load options from a config file + - disabled as --no-load-opts + - may appear multiple times +The next option supports vendor supported extra options: + -W str vendor supported additional options + These additional options are: + definitions=str Definitions input file + - disabled as --no-definitions + - enabled by default + - may not be preset + shell=str name or path name of shell to use + equate=str characters considered equivalent + source-time set mod times to latest source + - disabled as --no-source-time + writable Allow output files to be writable + - disabled as --not-writable + loop-limit=num Limit on increment loops + - is scalable with a suffix: k/K/m/M/g/G/t/T + - It must lie in one of the ranges: + -1 exactly, or + 1 to 16777216 + trace=KWd tracing level of detail + trace-out=str tracing output file or filter + used-defines Show the definitions used + - may not be preset +${testname} creates text files from templates using external definitions. + +The following option preset mechanisms are supported: + - reading file \$HOME/.${testname}rc + - reading file ./.${testname}rc + - examining environment variables named ` + echo ${testname} | tr 'a-z' 'A-Z'`_* + +The valid "trace" option keywords are: + nothing debug-message server-shell templates block-macros + expressions everything + or an integer from 0 through 6 + +${testname} is a tool designed for generating program files that contain +repetitive text with varied substitutions. +_EOF_ + +cmp -s ${testname}.h*lp || \ + failure "`diff ${testname}.hlp ${testname}.help`" + +cleanup diff --git a/autoopts/test/vers.test b/autoopts/test/vers.test new file mode 100755 index 0000000..55fb435 --- /dev/null +++ b/autoopts/test/vers.test @@ -0,0 +1,107 @@ +#! /bin/sh +# -*- Mode: Shell-script -*- +# ---------------------------------------------------------------------- +# vers.test --- test vers program attribute +# make sure that when it is not specified +# then option processing consumes all args. +# +# Time-stamp: "2011-08-07 17:35:55 bkorb" +# Author: Bruce Korb <bkorb@gnu.org> +## +## This file is part of AutoOpts, a companion to AutoGen. +## AutoOpts is free software. +## AutoOpts is Copyright (c) 1992-2012 by Bruce Korb - all rights reserved +## +## AutoOpts is available under any one of two licenses. The license +## in use must be one of these two and the choice is under the control +## of the user of the license. +## +## The GNU Lesser General Public License, version 3 or later +## See the files "COPYING.lgplv3" and "COPYING.gplv3" +## +## The Modified Berkeley Software Distribution License +## See the file "COPYING.mbsd" +## +## These files have the following md5sums: +## +## 43b91e8ca915626ed3818ffb1b71248b pkg/libopts/COPYING.gplv3 +## 06a1a2e4760c90ea5e1dad8dfaac4d39 pkg/libopts/COPYING.lgplv3 +## 66a5cedaf62c4b2637025f049f9b826f pkg/libopts/COPYING.mbsd +## +# ---------------------------------------------------------------------- + +. ./defs + +# # # # # # # # # # DEFINITIONS FILE # # # # # # # # # + +echo "creating $testname.def in `pwd`" +testname="$testname" test_main="${test_main}" \ +argument="${argument}" long_opts="${long_opts}" \ +${SHELLX} ${stdopts} option second || failure "Could not construct stdopts" +echo 'help-value = h;' >> $testname.def +echo 'version-value = V;' >> $testname.def + +echo ${AG_L} $testname.def +${AG_L} $testname.def || \ + failure AutoGen could not process + +compile "-h" + + +# # # # # # # # # # HELP OUTPUT FILE # # # # # # # # # + +echo creating $testname.hlp +clean_help > $testname.hlp <<'_EOF_' +test_vers - Test AutoOpts for vers +USAGE: vers [ -<flag> ]... + Flg Arg Option-Name Description + -o no option The option option descrip + -s no second The second option descrip + -h no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +_EOF_ + +cmp -s $testname.h*lp || \ + failure help output mismatch + +./$testname -v 2> /dev/null && \ + failure $testname should not accept version option + +ver="`echo '$Revision: 4.8 $'|${SED} 's/.*: *\([0-9.a-z]*\).*/\1/'`" +echo "version = '$ver';" >> $testname.def + +echo ${AG_L} $testname.def +${AG_L} $testname.def || \ + failure AutoGen could not process + +compile "-h" + +./$testname -V 2> /dev/null || \ + failure "$testname '*SHOULD*' accept version option" + +echo recreating $testname.hlp +clean_help > $testname.hlp <<_EOF_ +test_vers - Test AutoOpts for vers - Ver. ${ver} +USAGE: vers [ -<flag> ]... + Flg Arg Option-Name Description + -o no option The option option descrip + -s no second The second option descrip + -V opt version Output version information and exit + -h no help Display extended usage information and exit + -! no more-help Extended usage information passed thru pager + +_EOF_ + +cmp -s $testname.h*lp || \ + failure versioned help output mismatch + +cleanup + +## Local Variables: +## mode: shell-script +## indent-tabs-mode: nil +## sh-indentation: 2 +## End: + +# end of vers.test |