summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2011-05-16 09:50:19 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-05-16 09:50:19 (GMT)
commit50e703a9a92e755f928699b705612cd4153ffb9f (patch) (unidiff)
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.
Diffstat (more/less context) (ignore whitespace changes)
-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
@@ -47,7 +47,7 @@ struct token {
47#define ISINITIAL(c) ((isascii(c) && isalpha(c)) || (c) == '_') 47#define ISINITIAL(c) ((isascii(c) && isalpha(c)) || (c) == '_')
48 48
49static int 49static int
50input() 50rawinput()
51{ 51{
52 if (!infile || feof(infile)) 52 if (!infile || feof(infile))
53 return 0; 53 return 0;
@@ -57,6 +57,17 @@ input()
57 return input_char; 57 return input_char;
58} 58}
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
61unput() 72unput()
62{ 73{
@@ -87,7 +98,7 @@ collect_tag()
87static void 98static void
88collect_string() 99collect_string()
89{ 100{
90 while (input()) { 101 while (rawinput()) {
91 if (input_char == '\\') { 102 if (input_char == '\\') {
92 if (!input()) { 103 if (!input()) {
93 grecs_error(&grecs_current_locus, 0, 104 grecs_error(&grecs_current_locus, 0,
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 73ffeae..f5d1f6f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -14,7 +14,7 @@
14# You should have received a copy of the GNU General Public License 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/>. 15# along with Grecs. If not, see <http://www.gnu.org/licenses/>.
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)
19MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) 19MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
20 20
@@ -51,6 +51,8 @@ TESTSUITE_AT = \
51 glob03.at\ 51 glob03.at\
52 enum.at\ 52 enum.at\
53 join.at\ 53 join.at\
54 parser-git.at\
55 parser-meta1.at\
54 peek00.at\ 56 peek00.at\
55 peek01.at\ 57 peek01.at\
56 peek02.at\ 58 peek02.at\
diff --git a/tests/gcffmt.c b/tests/gcffmt.c
index b4a4ece..51e3037 100644
--- a/tests/gcffmt.c
+++ b/tests/gcffmt.c
@@ -26,7 +26,7 @@ usage(const char *arg, FILE *fp, int code)
26{ 26{
27 fprintf(fp, 27 fprintf(fp,
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);
31 exit(code); 31 exit(code);
32} 32}
@@ -59,7 +59,18 @@ main(int argc, char **argv)
59 sort = 1; 59 sort = 1;
60 else if (strcmp(arg, "-h") == 0) 60 else if (strcmp(arg, "-h") == 0)
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);
64 else { 75 else {
65 file = arg; 76 file = arg;
diff --git a/tests/git.conf b/tests/git.conf
new file mode 100644
index 0000000..6e8b2b2
--- a/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
--- a/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
--- a/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
17AT_SETUP([Git-style parser])
18AT_KEYWORDS([parser git])
19
20AT_CHECK([gcffmt -type=git $abs_srcdir/git.conf],
21[0],
22[.core.repositoryformatversion: "0"
23.core.filemode: "true"
24.core.bare: "false"
25.core.logallrefupdates: "true"
26.remote="origin".fetch: "+refs/heads/*:refs/remotes/origin/*"
27.remote="origin".url: "ssh://git.gnu.org.ua/gitroot/grecs.git"
28.branch="master".remote: "origin"
29.branch="master".merge: "refs/heads/master"
30])
31
32AT_CLEANUP
diff --git a/tests/parser-meta1.at b/tests/parser-meta1.at
new file mode 100644
index 0000000..ddfee1b
--- a/dev/null
+++ b/tests/parser-meta1.at
@@ -0,0 +1,122 @@
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
17AT_SETUP([MeTA1-style parser])
18AT_KEYWORDS([parser meta1])
19
20AT_CHECK([gcffmt -type=meta1 $abs_srcdir/meta1.conf],
21[0],
22[.hostname: "host.example.org"
23.smtps.greeting: "220 example.org ESMTP Tossudament alcats\r\n"
24.smtps.log_level: "12"
25.smtps.log.facility: "mail"
26.smtps.log.ident: "smtps"
27.smtps.flags: ("8bitmime", "access")
28.smtps.CDB_gid: "2262"
29.smtps.wait_for_server: "4"
30.smtps.listen_socket.type: "inet"
31.smtps.listen_socket.port: "25"
32.smtps.start_action: "pass"
33.smtps.pass_fd_socket: "smtps/smtpsfd"
34.smtps.user: "meta1s"
35.smtps.path: "/usr/local/libexec/smtps"
36.smtps.arguments: "smtps -f /etc/meta1/meta1.conf"
37.smtps.policy_milter.socket.type: "inet"
38.smtps.policy_milter.socket.address: "127.0.0.1"
39.smtps.policy_milter.socket.port: "3333"
40.smtps.policy_milter.timeout: "1800s"
41.smtps.policy_milter.flags: ("accept_but_reconnect")
42.smtps.io_timeout: "300s"
43.smtps.module_timeout: "1000s"
44.smtps.auth.flags: ("noanonymous")
45.smtps="MSA".log_level: "11"
46.smtps="MSA".log.facility: "mail"
47.smtps="MSA".log.ident: "MSA"
48.smtps="MSA".CDB_gid: "2262"
49.smtps="MSA".listen_socket.type: "inet"
50.smtps="MSA".listen_socket.port: "587"
51.smtps="MSA".start_action: "pass"
52.smtps="MSA".pass_fd_socket: "smtps/msafd"
53.smtps="MSA".user: "meta1s"
54.smtps="MSA".path: "/usr/local/libexec/smtps"
55.smtps="MSA".arguments: "smtps -I 1 -N MSA -f /etc/meta1/meta1.conf"
56.smtpc.log_level: "12"
57.smtpc.log.facility: "mail"
58.smtpc.log.ident: "smtpc"
59.smtpc.flags: ("read_QUIT_reply", "separate_final_dot_and_QUIT", "talk_to_myself")
60.smtpc.LMTP_socket: "lmtpsock"
61.smtpc.wait_for_server: "4"
62.smtpc.start_action: "wait"
63.smtpc.user: "meta1c"
64.smtpc.path: "/usr/local/libexec/smtpc"
65.smtpc.arguments: "smtpc -f /etc/meta1/meta1.conf"
66.qmgr.log_level: "12"
67.qmgr.log.facility: "mail"
68.qmgr.log.ident: "qmgr"
69.qmgr.wait_for_server: "4"
70.qmgr.wait_for_client: "3"
71.qmgr.start_action: "wait"
72.qmgr.user: "meta1q"
73.qmgr.restart_dependencies: ("smtps", "MSA", "smtpc")
74.qmgr.path: "/usr/local/libexec/qmgr"
75.qmgr.arguments: "qmgr -f /etc/meta1/meta1.conf"
76.qmgr.control_socket: "qmgr/sock"
77.smar.DNS.nameservers: ("10.11.0.1", "10.12.0.1")
78.smar.DNS.flags: "use_connect"
79.smar.log_level: "12"
80.smar.log.facility: "mail"
81.smar.log.ident: "smar"
82.smar.nameserver: "10.11.0.1"
83.smar.start_action: "wait"
84.smar.user: "meta1m"
85.smar.restart_dependencies: ("smtps", "MSA", "qmgr")
86.smar.path: "/usr/local/libexec/smar"
87.smar.arguments: "smar -f /etc/meta1/meta1.conf"
88.smar.map="mtdb".type: "hash"
89.smar.map="mtdb".file: "mt.db"
90.smar.mailertable.name: "mtdb"
91.smar.mailertable.flags: ("full_address", "domain")
92.smar.map="password".type: "passwd"
93.smar.map="userdb".type: "socket"
94.smar.map="userdb".path: "/var/spool/meta1/smap/userdb"
95.smar.map="userdb".mapname: "userdb"
96.smar.map="userdb".min_connections: "10"
97.smar.map="userdb".max_connections: "1024"
98.smar.map="userdb".timeout: "5"
99.smar.map="locusr".type: "sequence"
100.smar.map="locusr".maps: ("password", "userdb")
101.smar.local_user_map.name: "locusr"
102.smar.local_user_map.flags: ("localpart", "local_domains")
103.smar.map="lum".type: "socket"
104.smar.map="lum".path: "/var/spool/meta1/smap/userdb"
105.smar.map="lum".mapname: "alias"
106.smar.map="lum".min_connections: "10"
107.smar.map="lum".max_connections: "1024"
108.smar.map="lum".timeout: "6"
109.smar.map="stdal".file: "aliases.db"
110.smar.map="stdal".type: "hash"
111.smar.map="ali".type: "sequence"
112.smar.map="ali".maps: ("lum", "stdal")
113.smar.aliases.name: "ali"
114.smar.aliases.flags: ("localpart", "local_domains")
115.smar.map="acc".type: "socket"
116.smar.map="acc".address: "127.0.0.1"
117.smar.map="acc".port: "1025"
118.smar.map="acc".mapname: "access"
119.smar.access_map.name: "acc"
120])
121
122AT_CLEANUP
diff --git a/tests/testsuite.at b/tests/testsuite.at
index 3816c00..b81b45e 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -73,6 +73,9 @@ m4_include([reduce03.at])
73 73
74m4_include([join.at]) 74m4_include([join.at])
75 75
76m4_include([parser-git.at])
77m4_include([parser-meta1.at])
78
76m4_include([vercmp.at]) 79m4_include([vercmp.at])
77 80
78# End of testsuite.at 81# End of testsuite.at

Return to:

Send suggestions and report system problems to the System administrator.