diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.ac | 8 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/cmdline.opt | 18 | ||||
-rw-r--r-- | tests/.gitignore | 6 | ||||
-rw-r--r-- | tests/Makefile.am | 86 | ||||
-rw-r--r-- | tests/atlocal.in | 10 | ||||
-rw-r--r-- | tests/gmatch.at | 49 | ||||
-rw-r--r-- | tests/guile-itr.at | 83 | ||||
-rw-r--r-- | tests/guile-list.at | 60 | ||||
-rw-r--r-- | tests/guile-list2.at | 62 | ||||
-rw-r--r-- | tests/list.at | 58 | ||||
-rw-r--r-- | tests/literal.at | 48 | ||||
-rw-r--r-- | tests/locus.at | 59 | ||||
-rw-r--r-- | tests/lookupfail.at | 29 | ||||
-rw-r--r-- | tests/parent.at | 48 | ||||
-rw-r--r-- | tests/path.at | 59 | ||||
-rw-r--r-- | tests/smatch.at | 48 | ||||
-rw-r--r-- | tests/testsuite.at | 90 | ||||
-rw-r--r-- | tests/up.at | 48 | ||||
-rw-r--r-- | tests/value.at | 58 | ||||
-rw-r--r-- | tests/version.at | 33 |
22 files changed, 958 insertions, 7 deletions
diff --git a/Makefile.am b/Makefile.am index cdc0c53..dab4333 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,7 +16,7 @@ ACLOCAL_AMFLAGS = -I grecs/am -I gint -SUBDIRS = grecs gint src doc +SUBDIRS = grecs gint src doc tests .PHONY: ChangeLog ChangeLog: diff --git a/configure.ac b/configure.ac index 44241f1..138058b 100644 --- a/configure.ac +++ b/configure.ac @@ -45,10 +45,10 @@ GRECS_SETUP(grecs, [tests getopt git2chg all-parsers syntax-doc]) GINT_INIT([gint], [1.8 with-guile], [use_guile=yes], [use_guile=no]) AM_CONDITIONAL([CFPEEK_COND_GUILE],[test $use_guile = yes]) -dnl # Initialize the test suite. -dnl AC_CONFIG_TESTDIR(tests) -dnl AC_CONFIG_FILES([tests/Makefile tests/atlocal]) -dnl AM_MISSING_PROG([AUTOM4TE], [autom4te]) +# Initialize the test suite. +AC_CONFIG_TESTDIR(tests) +AC_CONFIG_FILES([tests/Makefile tests/atlocal]) +AM_MISSING_PROG([AUTOM4TE], [autom4te]) AC_CONFIG_FILES([Makefile gint/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index b77c0c4..061956c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,7 +28,7 @@ cfpeek_SOURCES = \ script.c LDADD=@GRECS_LDADD@ @GUILE_LIBS@ -INCLUDES = @GRECS_INCLUDES@ @GUILE_INCLUDES@ +INCLUDES = -I$(top_srcdir) @GRECS_INCLUDES@ @GUILE_INCLUDES@ AM_CPPFLAGS= \ -DDEFAULT_PREPROCESSOR="$(DEFAULT_PREPROCESSOR)" @@ -46,4 +46,5 @@ DOT_X_FILES = $(CFPEEK_GUILE_SRC:.c=.x) DOT_DOC_FILES = $(CFPEEK_GUILE_SRC:.c=.doc) CLEANFILES = DISTCLEANFILES = +MAINTAINERCLEANFILES = include ../gint/gint.mk diff --git a/src/cmdline.opt b/src/cmdline.opt index 8ddfffd..a8d134d 100644 --- a/src/cmdline.opt +++ b/src/cmdline.opt @@ -18,6 +18,7 @@ # include <getopt.h> #endif #include <unistd.h> +#include "grecs/gitid.h" static struct grecs_txtacc *pp_cmd_acc; char *program_name; @@ -27,6 +28,9 @@ char *program_name; #define PREPROC_DEFAULT 2 static int preproc_settings = PREPROC_NOT_SET; +#define CFPEEK_NODE_FLAG_DEFAULT \ + (GRECS_NODE_FLAG_PATH|GRECS_NODE_FLAG_VALUE|GRECS_NODE_FLAG_DESCEND) + static int flags_on, flags_off; struct format_flag { @@ -77,7 +81,7 @@ struct format_flag format_flag_table[] = { { "descend", NULL, "descend into subnodes", GRECS_NODE_FLAG_DESCEND }, { "default", NULL, "set default options", - GRECS_NODE_FLAG_DEFAULT }, + CFPEEK_NODE_FLAG_DEFAULT }, { NULL } }; @@ -325,6 +329,17 @@ END OPTIONS_END void +cfpeek_version_hook(FILE *stream) +{ + fprintf(stream, "compiled with:\n"); + fprintf(stream, " Grecs %s\n", GRECS_GIT_ID); +#ifdef GUILE_VERSION + fprintf(stream, " Guile %s\n", GUILE_VERSION); +#endif +} + + +void parse_options(int argc, char *argv[]) { program_name = strrchr(argv[0], '/'); @@ -333,6 +348,7 @@ parse_options(int argc, char *argv[]) else program_name = argv[0]; print_help_hook = flags_help; + print_version_hook = cfpeek_version_hook; GETOPT(argc, argv, file_index, exit(EX_USAGE)) if (!(flags_on & _GRECS_NODE_MASK_OUTPUT)) flags_on |= GRECS_NODE_FLAG_PATH|GRECS_NODE_FLAG_VALUE; diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 0000000..93f8f46 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,6 @@ +atconfig +atlocal +package.m4 +testsuite +testsuite.dir +testsuite.log diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..3b0c870 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,86 @@ +# This file is part of cfpeek +# Copyright (C) 2011 Sergey Poznyakoff +# +# Cfpeek is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Cfpeek is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cfpeek. If not, see <http://www.gnu.org/licenses/>. + +EXTRA_DIST = \ + $(TESTSUITE_AT)\ + testsuite\ + package.m4 + +DISTCLEANFILES = atconfig $(check_SCRIPTS) +MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) + + +## ------------ ## +## package.m4. ## +## ------------ ## + +$(srcdir)/package.m4: $(top_srcdir)/configure.ac $(top_srcdir)/@GRECS_SUBDIR@/am/grecs.m4 + $(AM_V_GEN){ \ + echo '# Signature of the current package.'; \ + echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \ + echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \ + echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \ + echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \ + echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \ + } >$(srcdir)/package.m4 + +# + +## ------------ ## +## Test suite. ## +## ------------ ## + +TESTSUITE_AT = \ + gmatch.at\ + guile-list.at\ + guile-list2.at\ + guile-itr.at\ + list.at\ + locus.at\ + literal.at\ + lookupfail.at\ + parent.at\ + path.at\ + smatch.at\ + testsuite.at\ + up.at\ + value.at\ + version.at + +TESTSUITE = $(srcdir)/testsuite +M4=m4 + +AUTOTEST = $(AUTOM4TE) --language=autotest +$(TESTSUITE): package.m4 $(TESTSUITE_AT) + $(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp + mv $@.tmp $@ + +atconfig: $(top_builddir)/config.status + cd $(top_builddir) && ./config.status tests/$@ + +clean-local: + test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean + +check-local: atconfig atlocal $(TESTSUITE) + $(SHELL) $(TESTSUITE) + +# Run the test suite on the *installed* tree. +#installcheck-local: +# $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin + + + + diff --git a/tests/atlocal.in b/tests/atlocal.in new file mode 100644 index 0000000..236f4c3 --- /dev/null +++ b/tests/atlocal.in @@ -0,0 +1,10 @@ +# @configure_input@ -*- shell-script -*- +# Configurable variable values for Cfpeek test suite. +# Copyright (C) 2011 Sergey Poznyakoff + +PATH=@abs_top_builddir@/src:$PATH + +XFAILFILE=$abs_builddir/.badversion + +trap "cleanup; test -r $XFAILFILE && cat $XFAILFILE; exit $?" 1 2 13 15 + diff --git a/tests/gmatch.at b/tests/gmatch.at new file mode 100644 index 0000000..0297630 --- /dev/null +++ b/tests/gmatch.at @@ -0,0 +1,49 @@ +# This file is part of cfpeek -*- autotest -*- +# Copyright (C) 2011 Sergey Poznyakoff +# +# Cfpeek is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Cfpeek is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cfpeek. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Look-up: * wildcard]) + +CFPEEK_TEST([ +user smith; +group mail; +pidfile "/var/run/example"; + +logging { + facility daemon; + tag example; +} + +program a { + command "a.out"; + logging { + facility local0; + tag a; + } +} + +program b { + command "b.out"; + wait yes; + pidfile /var/run/b.pid; +} +], +[cfpeek @ .*.pidfile], +[EX_OK], +[.pidfile: /var/run/example +.program="b".pidfile: /var/run/b.pid +]) + +AT_CLEANUP diff --git a/tests/guile-itr.at b/tests/guile-itr.at new file mode 100644 index 0000000..4cc8d2b --- /dev/null +++ b/tests/guile-itr.at @@ -0,0 +1,83 @@ +# This file is part of cfpeek -*- autotest -*- +# Copyright (C) 2011 Sergey Poznyakoff +# +# Cfpeek is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Cfpeek is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cfpeek. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Guile: iteration over nodes]) +AT_KEYWORDS([guile listing]) + +CFPEEK_TEST_GUILE([ +user smith; +group mail; +pidfile "/var/run/example"; + +logging { + facility daemon; + tag example; +} + +program a { + command "a.out"; + logging { + facility local0; + tag a; + } +} + +program b { + command "b.out"; + wait yes; + pidfile /var/run/b.pid; +} +], +[(define (cfpeek node) + (if (not (= (grecs-node-type node) grecs-node-root)) + (let ((loc (grecs-node-locus node))) + (display (car loc)) + (display ":") + (display (cdr loc)) + (display ": ") + (display (grecs-node-ident node)) + (display ": ") + (display (grecs-node-path node)) + (cond ((grecs-node-has-value? node) + (display ":: ") + (display (grecs-node-value node)))) + (newline))) + + (if (grecs-node-down? node) + (cfpeek (grecs-node-down node))) + (if (grecs-node-next? node) + (cfpeek (grecs-node-next node)))) +], +[cfpeek @ .], +[EX_OK], +[./test.cf:2: user: .user:: smith +./test.cf:3: group: .group:: mail +./test.cf:4: pidfile: .pidfile:: /var/run/example +./test.cf:6: logging: .logging +./test.cf:7: facility: .logging.facility:: daemon +./test.cf:8: tag: .logging.tag:: example +./test.cf:11: program: .program="a":: a +./test.cf:12: command: .program="a".command:: a.out +./test.cf:13: logging: .program="a".logging +./test.cf:14: facility: .program="a".logging.facility:: local0 +./test.cf:15: tag: .program="a".logging.tag:: a +./test.cf:19: program: .program="b":: b +./test.cf:20: command: .program="b".command:: b.out +./test.cf:21: wait: .program="b".wait:: yes +./test.cf:22: pidfile: .program="b".pidfile:: /var/run/b.pid +]) + +AT_CLEANUP diff --git a/tests/guile-list.at b/tests/guile-list.at new file mode 100644 index 0000000..eb36307 --- /dev/null +++ b/tests/guile-list.at @@ -0,0 +1,60 @@ +# This file is part of cfpeek -*- autotest -*- +# Copyright (C) 2011 Sergey Poznyakoff +# +# Cfpeek is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Cfpeek is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cfpeek. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Guile: listing]) +AT_KEYWORDS([guile listing]) + +CFPEEK_TEST_GUILE([ +user smith; +group mail; +pidfile "/var/run/example"; + +logging { + facility daemon; + tag example; +} + +program a { + command "a.out"; + logging { + facility local0; + tag a; + } +} + +program b { + command "b.out"; + wait yes; + pidfile /var/run/b.pid; +} +], +[], +[cfpeek -e '(display node)(newline)'], +[EX_OK], +[#<node .user: "smith"> +#<node .group: "mail"> +#<node .pidfile: "/var/run/example"> +#<node .logging.facility: "daemon"> +#<node .logging.tag: "example"> +#<node .program="a".command: "a.out"> +#<node .program="a".logging.facility: "local0"> +#<node .program="a".logging.tag: "a"> +#<node .program="b".command: "b.out"> +#<node .program="b".wait: "yes"> +#<node .program="b".pidfile: "/var/run/b.pid"> +]) + +AT_CLEANUP diff --git a/tests/guile-list2.at b/tests/guile-list2.at new file mode 100644 index 0000000..b5f3270 --- /dev/null +++ b/tests/guile-list2.at @@ -0,0 +1,62 @@ +# This file is part of cfpeek -*- autotest -*- +# Copyright (C) 2011 Sergey Poznyakoff +# +# Cfpeek is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Cfpeek is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cfpeek. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Guile: listing (-f)]) +AT_KEYWORDS([guile listing]) + +CFPEEK_TEST_GUILE([ +user smith; +group mail; +pidfile "/var/run/example"; + +logging { + facility daemon; + tag example; +} + +program a { + command "a.out"; + logging { + facility local0; + tag a; + } +} + +program b { + command "b.out"; + wait yes; + pidfile /var/run/b.pid; +} +], +[(define (cfpeek node) + (display node)(newline)) +], +[cfpeek], +[EX_OK], +[#<node .user: "smith"> +#<node .group: "mail"> +#<node .pidfile: "/var/run/example"> +#<node .logging.facility: "daemon"> +#<node .logging.tag: "example"> +#<node .program="a".command: "a.out"> +#<node .program="a".logging.facility: "local0"> +#<node .program="a".logging.tag: "a"> +#<node .program="b".command: "b.out"> +#<node .program="b".wait: "yes"> +#<node .program="b".pidfile: "/var/run/b.pid"> +]) + +AT_CLEANUP diff --git a/tests/list.at b/tests/list.at new file mode 100644 index 0000000..47660fe --- /dev/null +++ b/tests/list.at @@ -0,0 +1,58 @@ +# This file is part of cfpeek +# Copyright (C) 2011 Sergey Poznyakoff +# +# Cfpeek is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Cfpeek is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cfpeek. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Literal look-up]) + +CFPEEK_TEST([ +user smith; +group mail; +pidfile "/var/run/example"; + +logging { + facility daemon; + tag example; +} + +program a { + command "a.out"; + logging { + facility local0; + tag a; + } +} + +program b { + command "b.out"; + wait yes; + pidfile /var/run/b.pid; +} +], +[cfpeek], +[EX_OK], +[.user: smith +.group: mail +.pidfile: /var/run/example +.logging.facility: daemon +.logging.tag: example +.program="a".command: a.out +.program="a".logging.facility: local0 +.program="a".logging.tag: a +.program="b".command: b.out +.program="b".wait: yes +.program="b".pidfile: /var/run/b.pid +]) + +AT_CLEANUP diff --git a/tests/literal.at b/tests/literal.at new file mode 100644 index 0000000..5154b72 --- /dev/null +++ b/tests/literal.at @@ -0,0 +1,48 @@ +# This file is part of cfpeek -*- autotest -*- +# Copyright (C) 2011 Sergey Poznyakoff +# +# Cfpeek is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Cfpeek is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cfpeek. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Literal look-up]) + +CFPEEK_TEST([ +user smith; +group mail; +pidfile "/var/run/example"; + +logging { + facility daemon; + tag example; +} + +program a { + command "a.out"; + logging { + facility local0; + tag a; + } +} + +program b { + command "b.out"; + wait yes; + pidfile /var/run/b.pid; +} +], +[cfpeek -L @ .pidfile], +[EX_OK], +[.pidfile: /var/run/example +]) + +AT_CLEANUP diff --git a/tests/locus.at b/tests/locus.at new file mode 100644 index 0000000..5fe5918 --- /dev/null +++ b/tests/locus.at @@ -0,0 +1,59 @@ +# This file is part of cfpeek +# Copyright (C) 2011 Sergey Poznyakoff +# +# Cfpeek is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Cfpeek is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cfpeek. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Locus option]) +AT_KEYWORDS([format]) + +CFPEEK_TEST([ +user smith; +group mail; +pidfile "/var/run/example"; + +logging { + facility daemon; + tag example; +} + +program a { + command "a.out"; + logging { + facility local0; + tag a; + } +} + +program b { + command "b.out"; + wait yes; + pidfile /var/run/b.pid; +} +], +[cfpeek -Hdefault,locus], +[EX_OK], +[./test.cf:2: .user: smith +./test.cf:3: .group: mail +./test.cf:4: .pidfile: /var/run/example +./test.cf:7: .logging.facility: daemon +./test.cf:8: .logging.tag: example +./test.cf:12: .program="a".command: a.out +./test.cf:14: .program="a".logging.facility: local0 +./test.cf:15: .program="a".logging.tag: a +./test.cf:20: .program="b".command: b.out +./test.cf:21: .program="b".wait: yes +./test.cf:22: .program="b".pidfile: /var/run/b.pid +]) + +AT_CLEANUP diff --git a/tests/lookupfail.at b/tests/lookupfail.at new file mode 100644 index 0000000..08dbc04 --- /dev/null +++ b/tests/lookupfail.at @@ -0,0 +1,29 @@ +# This file is part of cfpeek -*- autotest -*- +# Copyright (C) 2011 Sergey Poznyakoff +# +# Cfpeek is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Cfpeek is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cfpeek. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Look-up failure]) + +CFPEEK_TEST([ +user smith; +group mail; +], +[cfpeek -L @ .pidfile], +[EX_NOTFOUND], +[], +[cfpeek: .pidfile: not found +]) + +AT_CLEANUP diff --git a/tests/parent.at b/tests/parent.at new file mode 100644 index 0000000..836eb92 --- /dev/null +++ b/tests/parent.at @@ -0,0 +1,48 @@ +# This file is part of cfpeek -*- autotest -*- +# Copyright (C) 2011 Sergey Poznyakoff +# +# Cfpeek is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Cfpeek is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cfpeek. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Parent option]) + +CFPEEK_TEST([ +user smith; +group mail; +pidfile "/var/run/example"; + +logging { + facility daemon; + tag example; +} + +program a { + command "a.out"; + logging { + facility local0; + tag a; + } +} + +program b { + command "b.out"; + wait yes; + pidfile /var/run/b.pid; +} +], +[cfpeek -Hparent=program,nodescend,novalue @ .*.facility=local0], +[EX_OK], +[.program="a" +]) + +AT_CLEANUP diff --git a/tests/path.at b/tests/path.at new file mode 100644 index 0000000..a61549e --- /dev/null +++ b/tests/path.at @@ -0,0 +1,59 @@ +# This file is part of cfpeek +# Copyright (C) 2011 Sergey Poznyakoff +# +# Cfpeek is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Cfpeek is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cfpeek. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Path option]) +AT_KEYWORDS([format]) + +CFPEEK_TEST([ +user smith; +group mail; +pidfile "/var/run/example"; + +logging { + facility daemon; + tag example; +} + +program a { + command "a.out"; + logging { + facility local0; + tag a; + } +} + +program b { + command "b.out"; + wait yes; + pidfile /var/run/b.pid; +} +], +[cfpeek -Hpath], +[EX_OK], +[.user +.group +.pidfile +.logging.facility +.logging.tag +.program="a".command +.program="a".logging.facility +.program="a".logging.tag +.program="b".command +.program="b".wait +.program="b".pidfile +]) + +AT_CLEANUP diff --git a/tests/smatch.at b/tests/smatch.at new file mode 100644 index 0000000..0e5e55c --- /dev/null +++ b/tests/smatch.at @@ -0,0 +1,48 @@ +# This file is part of cfpeek -*- autotest -*- +# Copyright (C) 2011 Sergey Poznyakoff +# +# Cfpeek is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Cfpeek is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cfpeek. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Literal look-up]) + +CFPEEK_TEST([ +user smith; +group mail; +pidfile "/var/run/example"; + +logging { + facility daemon; + tag example; +} + +program a { + command "a.out"; + logging { + facility local0; + tag a; + } +} + +program b { + command "b.out"; + wait yes; + pidfile /var/run/b.pid; +} +], +[cfpeek @ .%.pidfile], +[EX_OK], +[.program="b".pidfile: /var/run/b.pid +]) + +AT_CLEANUP diff --git a/tests/testsuite.at b/tests/testsuite.at new file mode 100644 index 0000000..1204b2d --- /dev/null +++ b/tests/testsuite.at @@ -0,0 +1,90 @@ +# This file is part of cfpeek +# Copyright (C) 2011 Sergey Poznyakoff +# +# Cfpeek is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Cfpeek is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cfpeek. If not, see <http://www.gnu.org/licenses/>. + +m4_version_prereq([2.52g]) + +dnl # Standard exit codes (from sysexits.h) +m4_define([EX_OK], 0) dnl successful termination +m4_define([EX_NOTFOUND], 1) dnl some keys not found +m4_define([EX_PARSE], 2) dnl error parsing input file +m4_define([EX_SCRIPTFAIL], 3) dnl extension script failed + +m4_define([EX__BASE], 64) dnl base value for error messages +m4_define([EX_USAGE], 64) dnl command line usage error +m4_define([EX_DATAERR], 65) dnl data format error +m4_define([EX_NOINPUT], 66) dnl cannot open input +m4_define([EX_NOUSER], 67) dnl addressee unknown +m4_define([EX_NOHOST], 68) dnl host name unknown +m4_define([EX_UNAVAILABLE], 69) dnl service unavailable +m4_define([EX_SOFTWARE], 70) dnl internal software error +m4_define([EX_OSERR], 71) dnl system error (e.g., can't fork) +m4_define([EX_OSFILE], 72) dnl critical OS file missing +m4_define([EX_CANTCREAT], 73) dnl can't create (user) output file +m4_define([EX_IOERR], 74) dnl input/output error +m4_define([EX_TEMPFAIL], 75) dnl temp failure; user is invited to retry +m4_define([EX_PROTOCOL], 76) dnl remote error in protocol +m4_define([EX_NOPERM], 77) dnl permission denied +m4_define([EX_CONFIG], 78) dnl configuration error + +m4_define([AT_SKIP_TEST],[exit 77]) + +m4_define([PREREQ_GUILE], +[cfpeek --version|grep Guile >/dev/null || AT_SKIP_TEST]) + +dnl CFPEEK_TEST([config],[cmd],[status],[stdout],[stderr]) +m4_define([CFPEEK_TEST],[ +AT_DATA([test.cf],[$1]) +m4_pushdef([__cfpeek_command],[m4_if(m4_index([$2],[@]),-1,[$2 ./test.cf],dnl +[m4_bpatsubst([$2],@,[./test.cf])])]) +AT_CHECK([__cfpeek_command],[$3],[$4],[$5]) +m4_popdef([__cfpeek_command])]) + +dnl CFPEEK_TEST_GUILE([config],[script],[cmd],[status],[stdout],[stderr]) +m4_define([CFPEEK_TEST_GUILE],[ +AT_DATA([test.cf],[$1 +]) +m4_pushdef([__cfpeek_script]) +m4_if([$2],,,[ +AT_DATA([test.scm],[$2 +]) +m4_define([__cfpeek_script],[-f test.scm])]) +m4_pushdef([__cfpeek_command],[m4_if(m4_index([$3],[@]),-1,[$3 __cfpeek_script ./test.cf],dnl +[m4_bpatsubst([$3],@,[__cfpeek_script ./test.cf])])]) +AT_CHECK([PREREQ_GUILE +__cfpeek_command],[$4],[$5],[$6]) +m4_popdef([__cfpeek_command]) +m4_popdef([__cfpeek_script])]) + +dnl # Begin tests + +AT_INIT +m4_include([version.at]) +m4_include([list.at]) +m4_include([locus.at]) +m4_include([path.at]) +m4_include([value.at]) +m4_include([literal.at]) +m4_include([smatch.at]) +m4_include([gmatch.at]) +m4_include([lookupfail.at]) +m4_include([up.at]) +m4_include([parent.at]) + +m4_include([guile-list.at]) +m4_include([guile-list2.at]) +m4_include([guile-itr.at]) + +# End of testsuite.at diff --git a/tests/up.at b/tests/up.at new file mode 100644 index 0000000..4a787d9 --- /dev/null +++ b/tests/up.at @@ -0,0 +1,48 @@ +# This file is part of cfpeek -*- autotest -*- +# Copyright (C) 2011 Sergey Poznyakoff +# +# Cfpeek is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# Cfpeek is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cfpeek. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Up option]) + +CFPEEK_TEST([ +user smith; +group mail; +pidfile "/var/run/example"; + +logging { + facility daemon; + tag example; +} + +program a { + command "a.out"; + logging { + facility local0; + tag a; + } +} + +program b { + command "b.out"; + wait yes; + pidfile /var/run/b.pid; +} +], +[cfpeek -Hup=1,nodescend,novalue @ .*.wait=yes], +[EX_OK], +[.program="b" +]) + +AT_CLEANUP diff --git a/tests/value.at b/tests/value.at new file mode 100644 index 0000000..bc28046 --- /dev/null +++ b/tests/value.at @@ -0,0 +1,58 @@ +# This file is part of cfpeek +# Copyright (C) 2011 Sergey Poznyakoff |