aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/.gitignore1
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/forlan01.at77
-rw-r--r--tests/testsuite.at4
-rw-r--r--tests/tforlan.c100
5 files changed, 184 insertions, 0 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
index 99d3c9c..8b76ee0 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -4,6 +4,7 @@ package.m4
4testsuite 4testsuite
5testsuite.dir 5testsuite.dir
6testsuite.log 6testsuite.log
7tforlan
7thmac 8thmac
8turlenc 9turlenc
9txml 10txml
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 82cae7e..4d567b3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -40,6 +40,7 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
40## ------------ ## 40## ------------ ##
41 41
42TESTSUITE_AT = \ 42TESTSUITE_AT = \
43 forlan01.at\
43 hmac01.at\ 44 hmac01.at\
44 hmac02.at\ 45 hmac02.at\
45 hmac03.at\ 46 hmac03.at\
@@ -69,6 +70,7 @@ check-local: atconfig atlocal $(TESTSUITE)
69# $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin 70# $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
70 71
71noinst_PROGRAMS = \ 72noinst_PROGRAMS = \
73 tforlan\
72 thmac\ 74 thmac\
73 turlenc\ 75 turlenc\
74 txml 76 txml
diff --git a/tests/forlan01.at b/tests/forlan01.at
new file mode 100644
index 0000000..cf826e9
--- /dev/null
+++ b/tests/forlan01.at
@@ -0,0 +1,77 @@
1# This file is part of Eclat -*- Autotest -*-
2# Copyright (C) 2012 Sergey Poznyakoff
3#
4# Eclat is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# Eclat is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with Eclat. If not, see <http://www.gnu.org/licenses/>.
16
17AT_SETUP([dump])
18AT_KEYWORDS([forlan forlan01])
19
20AT_DATA([input],[// test format for DescribeTags
21if (.DescribeTagsResponse) {
22 if (.DescribeTagsResponse.tagSet.item.resourceId[[i-deadbeef]] &&
23 parent(last).key[[hostname]])
24 print(parent(last).value);
25} else if (.Response.Errors)
26 error(.Response.Errors.Error.Message);
27else
28 dump();
29])
30
31AT_CHECK([tforlan -D input],
32[0],
33[0001: COND
340002: NODE
350003: COMP ABS
360004: LIT: "DescribeTagsResponse"
370005: IFTRUE 0001
380006: COND
390007: AND
400008: NODE
410009: COMP ABS
420010: LIT: "DescribeTagsResponse"
430011: LIT: "tagSet"
440012: LIT: "item"
450013: TEST: resourceId[[i-deadbeef]]
460014: NODE
470015: COMP
480016: CALL: parent
490017: LAST
500018: TEST: key[[hostname]]
510019: IFTRUE 0006
520020: CALL: print
530021: COMP
540022: CALL: parent
550023: LAST
560024: LIT: "value"
570025: IFFALSE 0006
580026: IFFALSE 0001
590027: COND
600028: NODE
610029: COMP ABS
620030: LIT: "Response"
630031: LIT: "Errors"
640032: IFTRUE 0027
650033: CALL: error
660034: COMP ABS
670035: LIT: "Response"
680036: LIT: "Errors"
690037: LIT: "Error"
700038: LIT: "Message"
710039: IFFALSE 0027
720040: CALL: dump
73])
74
75AT_CLEANUP
76
77
diff --git a/tests/testsuite.at b/tests/testsuite.at
index f40b8a7..81e91f4 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -29,4 +29,8 @@ m4_include([urlenc01.at])
29 29
30AT_BANNER([XML Processing]) 30AT_BANNER([XML Processing])
31m4_include([xml01.at]) 31m4_include([xml01.at])
32
33AT_BANNER([Forlan])
34m4_include([forlan01.at])
35
32# End of testsuite.at 36# End of testsuite.at
diff --git a/tests/tforlan.c b/tests/tforlan.c
new file mode 100644
index 0000000..9fc3495
--- /dev/null
+++ b/tests/tforlan.c
@@ -0,0 +1,100 @@
1/* This file is part of Eclat.
2 Copyright (C) 2012 Sergey Poznyakoff.
3
4 Eclat is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
7 any later version.
8
9 Eclat is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with Eclat. If not, see <http://www.gnu.org/licenses/>. */
16
17#include <config.h>
18#include <stdio.h>
19#include <stdlib.h>
20#include <unistd.h>
21#ifdef HAVE_GETOPT_H
22# include <getopt.h>
23#endif
24#include <errno.h>
25#include <sysexits.h>
26#include <libeclat.h>
27#include "forlan.h"
28#include <sys/stat.h>
29
30void
31usage()
32{
33 printf("usage: %s [-dD] FILE [INPUT]\n");
34}
35
36int
37main(int argc, char **argv)
38{
39 FILE *fp;
40 char *buf;
41 size_t len;
42 struct stat st;
43 struct grecs_locus_point pt;
44 int rc;
45 int dump_option = 0;
46
47 set_program_name(argv[0]);
48 forlan_init();
49
50 while ((rc = getopt(argc, argv, "Dd:h")) != EOF)
51 switch (rc) {
52 case 'D':
53 dump_option++;
54 break;
55
56 case 'd':
57 if (parse_debug_level(optarg))
58 die(EX_USAGE, "bad debug category or level");
59 break;
60
61 case 'h':
62 usage();
63 return 0;
64
65 default:
66 exit(EX_USAGE);
67 }
68 argc -= optind;
69 argv += optind;
70
71
72 if (argc == 0 || argc > 2)
73 die(EX_USAGE, "one or two arguments expected");
74 if (stat(argv[0], &st))
75 die(EX_UNAVAILABLE, "cannot stat input file \"%s\": %s",
76 argv[0], strerror(errno));
77 len = st.st_size;
78 buf = grecs_malloc(len);
79 fp = fopen(argv[0], "r");
80 if (!fp)
81 die(EX_UNAVAILABLE, "cannot open input file \"%s\": %s",
82 argv[0], strerror(errno));
83 if (fread(buf, len, 1, fp) != 1)
84 die(EX_UNAVAILABLE, "error reading from \"%s\": %s",
85 argv[0], strerror(errno));
86 fclose(fp);
87
88 pt.file = argv[0];
89 pt.line = 1;
90 pt.col = 0;
91
92 rc = forlan_parse(buf, len, &pt);
93 if (rc == 0) {
94 if (dump_option)
95 forlan_dump_tree(stdout, forlan_parse_tree);
96 forlan_node_free(forlan_parse_tree);
97 }
98 return rc ? EX_UNAVAILABLE : 0;
99}
100

Return to:

Send suggestions and report system problems to the System administrator.