aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-16 12:50:19 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-05-16 12:50:19 +0300
commit50e703a9a92e755f928699b705612cd4153ffb9f (patch)
tree4f1b4620217e1213d807631ceecf3a46efc30768
parentaa31497d9f0a3e96801d3752dd2d8f4ea20a2f4c (diff)
downloadgrecs-50e703a9a92e755f928699b705612cd4153ffb9f.tar.gz
grecs-50e703a9a92e755f928699b705612cd4153ffb9f.tar.bz2
Add tests for MeTA1 and Git parsers.
* src/git-parser.c: Hanlde end-of-line comments. * tests/Makefile.am (EXTRA_DIST): Add meta1.conf and git.conf (TESTSUITE_AT): Add parser-git.at and parser-meta1.at. * tests/testsuite.at: Include parser-git.at and parser-meta1.at. * tests/meta1.conf: New file. * tests/git.conf: New file. * tests/parser-git.at: New file. * tests/parser-meta1.at: New file. * tests/gcffmt.c (main): Handle -type= option.
-rw-r--r--src/git-parser.c15
-rw-r--r--tests/Makefile.am4
-rw-r--r--tests/gcffmt.c15
-rw-r--r--tests/git.conf13
-rw-r--r--tests/meta1.conf136
-rw-r--r--tests/parser-git.at32
-rw-r--r--tests/parser-meta1.at122
-rw-r--r--tests/testsuite.at3
8 files changed, 335 insertions, 5 deletions
diff --git a/src/git-parser.c b/src/git-parser.c
index e0675ef..117a8fc 100644
--- a/src/git-parser.c
+++ b/src/git-parser.c
@@ -49,3 +49,3 @@ struct token {
49static int 49static int
50input() 50rawinput()
51{ 51{
@@ -59,2 +59,13 @@ input()
59 59
60static int
61input()
62{
63 rawinput();
64 if (input_char == '#') {
65 while (rawinput() && input_char != '\n')
66 ;
67 }
68 return input_char;
69}
70
60static void 71static void
@@ -89,3 +100,3 @@ collect_string()
89{ 100{
90 while (input()) { 101 while (rawinput()) {
91 if (input_char == '\\') { 102 if (input_char == '\\') {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 73ffeae..f5d1f6f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -16,3 +16,3 @@
16 16
17EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 gcf1.conf 17EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 gcf1.conf meta1.conf git.conf
18DISTCLEANFILES = atconfig $(check_SCRIPTS) 18DISTCLEANFILES = atconfig $(check_SCRIPTS)
@@ -53,2 +53,4 @@ TESTSUITE_AT = \
53 join.at\ 53 join.at\
54 parser-git.at\
55 parser-meta1.at\
54 peek00.at\ 56 peek00.at\
diff --git a/tests/gcffmt.c b/tests/gcffmt.c
index b4a4ece..51e3037 100644
--- a/tests/gcffmt.c
+++ b/tests/gcffmt.c
@@ -28,3 +28,3 @@ usage(const char *arg, FILE *fp, int code)
28 "usage: %s [-h] [-locus] [-delim=char] [-reduce] [-sort] " 28 "usage: %s [-h] [-locus] [-delim=char] [-reduce] [-sort] "
29 "file [file...]\n", 29 "[-type=grecs|bind|meta1|git] file [file...]\n",
30 arg); 30 arg);
@@ -61,3 +61,14 @@ main(int argc, char **argv)
61 usage(progname, stdout, 0); 61 usage(progname, stdout, 0);
62 else if (arg[0] == '-') 62 else if (strncmp(arg, "-type=", 6) == 0) {
63 if (strcasecmp(arg+6, "GRECS") == 0)
64 grecs_parser_fun = grecs_grecs_parser;
65 else if (strcasecmp(arg+6, "META1") == 0)
66 grecs_parser_fun = grecs_meta1_parser;
67 else if (strcasecmp(arg+6, "BIND") == 0)
68 grecs_parser_fun = grecs_bind_parser;
69 else if (strcasecmp(arg+6, "GIT") == 0)
70 grecs_parser_fun = grecs_git_parser;
71 else
72 usage(progname, stderr, 1);
73 } else if (arg[0] == '-')
63 usage(progname, stderr, 1); 74 usage(progname, stderr, 1);
diff --git a/tests/git.conf b/tests/git.conf
new file mode 100644
index 0000000..6e8b2b2
--- /dev/null
+++ b/tests/git.conf
@@ -0,0 +1,13 @@
1# Sample Git configuration file for Grecs
2#
3[core] # Comment
4 repositoryformatversion = 0
5 filemode = true
6 bare = false # Comment
7 logallrefupdates = true
8[remote "origin"]
9 fetch = +refs/heads/*:refs/remotes/origin/*
10 url = ssh://git.gnu.org.ua/gitroot/grecs.git
11[branch "master"]
12 remote = origin
13 merge = refs/heads/master
diff --git a/tests/meta1.conf b/tests/meta1.conf
new file mode 100644
index 0000000..22ac218
--- /dev/null
+++ b/tests/meta1.conf
@@ -0,0 +1,136 @@
1# Sample MeTA1 configuration file for Grecs testsuite.
2
3hostname = "host.example.org";
4
5smtps {
6 greeting = "220 example.org ESMTP Tossudament alcats\r\n";
7 log_level = 12;
8 log { facility=mail; ident="smtps"; }
9 flags = { 8bitmime,
10 access };
11 CDB_gid = 2262;
12 wait_for_server = 4;
13 listen_socket { type=inet; port = 25; }
14 start_action = pass;
15 pass_fd_socket = smtps/smtpsfd;
16 user = meta1s;
17 path = "/usr/local/libexec/smtps";
18 arguments = "smtps -f /etc/meta1/meta1.conf";
19 policy_milter {
20 socket {
21 type = inet;
22 address = 127.0.0.1;
23 port = 3333;
24 };
25 timeout = 1800s;
26 flags = { accept_but_reconnect };
27 };
28 io_timeout = 300s;
29 module_timeout = 1000s;
30 auth {
31 flags = { noanonymous };
32 }
33}
34
35smtps MSA {
36 log_level = 11;
37 log { facility=mail; ident="MSA"; }
38 CDB_gid = 2262;
39 listen_socket { type=inet; port = 587; }
40 start_action = pass;
41 pass_fd_socket = smtps/msafd;
42 user = meta1s;
43 path = "/usr/local/libexec/smtps";
44 arguments = "smtps -I 1 -N MSA -f /etc/meta1/meta1.conf";
45}
46
47smtpc {
48 log_level = 12;
49 log { facility=mail; ident="smtpc"; }
50 flags = { read_QUIT_reply,
51 separate_final_dot_and_QUIT,
52 talk_to_myself };
53 LMTP_socket="lmtpsock";
54 wait_for_server = 4;
55 start_action = wait;
56 user = meta1c;
57 path = "/usr/local/libexec/smtpc";
58 arguments = "smtpc -f /etc/meta1/meta1.conf";
59}
60
61# must be previous to last in the list: started after smar
62qmgr {
63 log_level = 12;
64 log { facility=mail; ident="qmgr"; }
65 wait_for_server = 4;
66 wait_for_client = 3;
67 start_action = wait;
68 user = meta1q;
69 restart_dependencies = { smtps, MSA, smtpc };
70 path = "/usr/local/libexec/qmgr";
71 arguments = "qmgr -f /etc/meta1/meta1.conf";
72 control_socket = "qmgr/sock";
73}
74
75
76# must be last in the list: started first
77smar {
78 DNS { nameservers={ 10.11.0.1, 10.12.0.1 };
79 flags = use_connect; }
80 log_level = 12;
81 log { facility=mail; ident="smar"; }
82 nameserver = 10.11.0.1;
83 start_action = wait;
84 user = meta1m;
85 restart_dependencies = { smtps, MSA, qmgr };
86 path = "/usr/local/libexec/smar";
87 arguments = "smar -f /etc/meta1/meta1.conf";
88
89 map mtdb {
90 type = hash;
91 file = "mt.db";
92 }
93 mailertable {
94 name = mtdb;
95 flags = { full_address, domain };
96 }
97
98 map password { type = passwd; }
99 map userdb {
100 type = socket;
101 path = "/var/spool/meta1/smap/userdb";
102 mapname = userdb;
103 min_connections = 10;
104 max_connections = 1024;
105 timeout = 5;
106 }
107 map locusr {
108 type = sequence;
109 maps = { password, userdb };
110 }
111
112 local_user_map {
113 name = "locusr";
114 flags = { localpart, local_domains };
115 }
116
117 map lum {
118 type = socket;
119 path = "/var/spool/meta1/smap/userdb";
120 mapname = alias;
121 min_connections = 10;
122 max_connections = 1024;
123 timeout = 6;
124 }
125 map stdal { file = "aliases.db"; type = hash; }
126 map ali { type = sequence; maps = { lum,stdal }; }
127 aliases {
128 name = ali;
129 flags = { localpart, local_domains };
130 }
131
132 map acc { type = socket; address = 127.0.0.1; port = 1025; mapname = access; }
133 access_map {
134 name = acc;
135 }
136}
diff --git a/tests/parser-git.at b/tests/parser-git.at
new file mode 100644
index 0000000..fbfd0d4
--- /dev/null
+++ b/tests/parser-git.at
@@ -0,0 +1,32 @@
1# This file is part of grecs -*- Autotest -*-
2# Copyright (C) 2011 Sergey Poznyakoff
3#
4# Grecs 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# Grecs 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 Grecs. If not, see <http://www.gnu.org/licenses/>.
16
17