diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-16 12:50:19 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-05-16 12:50:19 +0300 |
commit | 50e703a9a92e755f928699b705612cd4153ffb9f (patch) | |
tree | 4f1b4620217e1213d807631ceecf3a46efc30768 | |
parent | aa31497d9f0a3e96801d3752dd2d8f4ea20a2f4c (diff) | |
download | grecs-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.c | 15 | ||||
-rw-r--r-- | tests/Makefile.am | 4 | ||||
-rw-r--r-- | tests/gcffmt.c | 15 | ||||
-rw-r--r-- | tests/git.conf | 13 | ||||
-rw-r--r-- | tests/meta1.conf | 136 | ||||
-rw-r--r-- | tests/parser-git.at | 32 | ||||
-rw-r--r-- | tests/parser-meta1.at | 122 | ||||
-rw-r--r-- | tests/testsuite.at | 3 |
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 { static int -input() +rawinput() { @@ -59,2 +59,13 @@ input() +static int +input() +{ + rawinput(); + if (input_char == '#') { + while (rawinput() && input_char != '\n') + ; + } + return input_char; +} + static void @@ -89,3 +100,3 @@ collect_string() { - while (input()) { + while (rawinput()) { 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 @@ -EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 gcf1.conf +EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 gcf1.conf meta1.conf git.conf DISTCLEANFILES = atconfig $(check_SCRIPTS) @@ -53,2 +53,4 @@ TESTSUITE_AT = \ join.at\ + parser-git.at\ + parser-meta1.at\ 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) "usage: %s [-h] [-locus] [-delim=char] [-reduce] [-sort] " - "file [file...]\n", + "[-type=grecs|bind|meta1|git] file [file...]\n", arg); @@ -61,3 +61,14 @@ main(int argc, char **argv) usage(progname, stdout, 0); - else if (arg[0] == '-') + else if (strncmp(arg, "-type=", 6) == 0) { + if (strcasecmp(arg+6, "GRECS") == 0) + grecs_parser_fun = grecs_grecs_parser; + else if (strcasecmp(arg+6, "META1") == 0) + grecs_parser_fun = grecs_meta1_parser; + else if (strcasecmp(arg+6, "BIND") == 0) + grecs_parser_fun = grecs_bind_parser; + else if (strcasecmp(arg+6, "GIT") == 0) + grecs_parser_fun = grecs_git_parser; + else + usage(progname, stderr, 1); + } else if (arg[0] == '-') 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 @@ +# Sample Git configuration file for Grecs +# +[core] # Comment + repositoryformatversion = 0 + filemode = true + bare = false # Comment + logallrefupdates = true +[remote "origin"] + fetch = +refs/heads/*:refs/remotes/origin/* + url = ssh://git.gnu.org.ua/gitroot/grecs.git +[branch "master"] + remote = origin + 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 @@ +# Sample MeTA1 configuration file for Grecs testsuite. + +hostname = "host.example.org"; + +smtps { + greeting = "220 example.org ESMTP Tossudament alcats\r\n"; + log_level = 12; + log { facility=mail; ident="smtps"; } + flags = { 8bitmime, + access }; + CDB_gid = 2262; + wait_for_server = 4; + listen_socket { type=inet; port = 25; } + start_action = pass; + pass_fd_socket = smtps/smtpsfd; + user = meta1s; + path = "/usr/local/libexec/smtps"; + arguments = "smtps -f /etc/meta1/meta1.conf"; + policy_milter { + socket { + type = inet; + address = 127.0.0.1; + port = 3333; + }; + timeout = 1800s; + flags = { accept_but_reconnect }; + }; + io_timeout = 300s; + module_timeout = 1000s; + auth { + flags = { noanonymous }; + } +} + +smtps MSA { + log_level = 11; + log { facility=mail; ident="MSA"; } + CDB_gid = 2262; + listen_socket { type=inet; port = 587; } + start_action = pass; + pass_fd_socket = smtps/msafd; + user = meta1s; + path = "/usr/local/libexec/smtps"; + arguments = "smtps -I 1 -N MSA -f /etc/meta1/meta1.conf"; +} + +smtpc { + log_level = 12; + log { facility=mail; ident="smtpc"; } + flags = { read_QUIT_reply, + separate_final_dot_and_QUIT, + talk_to_myself }; + LMTP_socket="lmtpsock"; + wait_for_server = 4; + start_action = wait; + user = meta1c; + path = "/usr/local/libexec/smtpc"; + arguments = "smtpc -f /etc/meta1/meta1.conf"; +} + +# must be previous to last in the list: started after smar +qmgr { + log_level = 12; + log { facility=mail; ident="qmgr"; } + wait_for_server = 4; + wait_for_client = 3; + start_action = wait; + user = meta1q; + restart_dependencies = { smtps, MSA, smtpc }; + path = "/usr/local/libexec/qmgr"; + arguments = "qmgr -f /etc/meta1/meta1.conf"; + control_socket = "qmgr/sock"; +} + + +# must be last in the list: started first +smar { + DNS { nameservers={ 10.11.0.1, 10.12.0.1 }; + flags = use_connect; } + log_level = 12; + log { facility=mail; ident="smar"; } + nameserver = 10.11.0.1; + start_action = wait; + user = meta1m; + restart_dependencies = { smtps, MSA, qmgr }; + path = "/usr/local/libexec/smar"; + arguments = "smar -f /etc/meta1/meta1.conf"; + + map mtdb { + type = hash; + file = "mt.db"; + } + mailertable { + name = mtdb; + flags = { full_address, domain }; + } + + map password { type = passwd; } + map userdb { + type = socket; + path = "/var/spool/meta1/smap/userdb"; + mapname = userdb; + min_connections = 10; + max_connections = 1024; + timeout = 5; + } + map locusr { + type = sequence; + maps = { password, userdb }; + } + + local_user_map { + name = "locusr"; + flags = { localpart, local_domains }; + } + + map lum { + type = socket; + path = "/var/spool/meta1/smap/userdb"; + mapname = alias; + min_connections = 10; + max_connections = 1024; + timeout = 6; + } + map stdal { file = "aliases.db"; type = hash; } + map ali { type = sequence; maps = { lum,stdal }; } + aliases { + name = ali; + flags = { localpart, local_domains }; + } + + map acc { type = socket; address = 127.0.0.1; port = 1025; mapname = access; } + access_map { + name = acc; + } +} 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 @@ +# This file is part of grecs -*- Autotest -*- +# Copyright (C) 2011 Sergey Poznyakoff +# +# Grecs 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. +# +# Grecs 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 Grecs. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([Git-style parser]) +AT_KEYWORDS([parser git]) + +AT_CHECK([gcffmt -type=git $abs_srcdir/git.conf], +[0], +[.core.repositoryformatversion: "0" +.core.filemode: "true" +.core.bare: "false" +.core.logallrefupdates: "true" +.remote="origin".fetch: "+refs/heads/*:refs/remotes/origin/*" +.remote="origin".url: "ssh://git.gnu.org.ua/gitroot/grecs.git" +.branch="master".remote: "origin" +.branch="master".merge: "refs/heads/master" +]) + +AT_CLEANUP diff --git a/tests/parser-meta1.at b/tests/parser-meta1.at new file mode 100644 index 0000000..ddfee1b --- /dev/null +++ b/tests/parser-meta1.at @@ -0,0 +1,122 @@ +# This file is part of grecs -*- Autotest -*- +# Copyright (C) 2011 Sergey Poznyakoff +# +# Grecs 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. +# +# Grecs 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 Grecs. If not, see <http://www.gnu.org/licenses/>. + +AT_SETUP([MeTA1-style parser]) +AT_KEYWORDS([parser meta1]) + +AT_CHECK([gcffmt -type=meta1 $abs_srcdir/meta1.conf], +[0], +[.hostname: "host.example.org" +.smtps.greeting: "220 example.org ESMTP Tossudament alcats\r\n" +.smtps.log_level: "12" +.smtps.log.facility: "mail" +.smtps.log.ident: "smtps" +.smtps.flags: ("8bitmime", "access") +.smtps.CDB_gid: "2262" +.smtps.wait_for_server: "4" +.smtps.listen_socket.type: "inet" +.smtps.listen_socket.port: "25" +.smtps.start_action: "pass" +.smtps.pass_fd_socket: "smtps/smtpsfd" +.smtps.user: "meta1s" +.smtps.path: "/usr/local/libexec/smtps" +.smtps.arguments: "smtps -f /etc/meta1/meta1.conf" +.smtps.policy_milter.socket.type: "inet" +.smtps.policy_milter.socket.address: "127.0.0.1" +.smtps.policy_milter.socket.port: "3333" +.smtps.policy_milter.timeout: "1800s" +.smtps.policy_milter.flags: ("accept_but_reconnect") +.smtps.io_timeout: "300s" +.smtps.module_timeout: "1000s" +.smtps.auth.flags: ("noanonymous") +.smtps="MSA".log_level: "11" +.smtps="MSA".log.facility: "mail" +.smtps="MSA".log.ident: "MSA" +.smtps="MSA".CDB_gid: "2262" +.smtps="MSA".listen_socket.type: "inet" +.smtps="MSA".listen_socket.port: "587" +.smtps="MSA".start_action: "pass" +.smtps="MSA".pass_fd_socket: "smtps/msafd" +.smtps="MSA".user: "meta1s" +.smtps="MSA".path: "/usr/local/libexec/smtps" +.smtps="MSA".arguments: "smtps -I 1 -N MSA -f /etc/meta1/meta1.conf" +.smtpc.log_level: "12" +.smtpc.log.facility: "mail" +.smtpc.log.ident: "smtpc" +.smtpc.flags: ("read_QUIT_reply", "separate_final_dot_and_QUIT", "talk_to_myself") +.smtpc.LMTP_socket: "lmtpsock" +.smtpc.wait_for_server: "4" +.smtpc.start_action: "wait" +.smtpc.user: "meta1c" +.smtpc.path: "/usr/local/libexec/smtpc" +.smtpc.arguments: "smtpc -f /etc/meta1/meta1.conf" +.qmgr.log_level: "12" +.qmgr.log.facility: "mail" +.qmgr.log.ident: "qmgr" +.qmgr.wait_for_server: "4" +.qmgr.wait_for_client: "3" +.qmgr.start_action: "wait" +.qmgr.user: "meta1q" +.qmgr.restart_dependencies: ("smtps", "MSA", "smtpc") +.qmgr.path: "/usr/local/libexec/qmgr" +.qmgr.arguments: "qmgr -f /etc/meta1/meta1.conf" +.qmgr.control_socket: "qmgr/sock" +.smar.DNS.nameservers: ("10.11.0.1", "10.12.0.1") +.smar.DNS.flags: "use_connect" +.smar.log_level: "12" +.smar.log.facility: "mail" +.smar.log.ident: "smar" +.smar.nameserver: "10.11.0.1" +.smar.start_action: "wait" +.smar.user: "meta1m" +.smar.restart_dependencies: ("smtps", "MSA", "qmgr") +.smar.path: "/usr/local/libexec/smar" +.smar.arguments: "smar -f /etc/meta1/meta1.conf" +.smar.map="mtdb".type: "hash" +.smar.map="mtdb".file: "mt.db" +.smar.mailertable.name: "mtdb" +.smar.mailertable.flags: ("full_address", "domain") +.smar.map="password".type: "passwd" +.smar.map="userdb".type: "socket" +.smar.map="userdb".path: "/var/spool/meta1/smap/userdb" +.smar.map="userdb".mapname: "userdb" +.smar.map="userdb".min_connections: "10" +.smar.map="userdb".max_connections: "1024" +.smar.map="userdb".timeout: "5" +.smar.map="locusr".type: "sequence" +.smar.map="locusr".maps: ("password", "userdb") +.smar.local_user_map.name: "locusr" +.smar.local_user_map.flags: ("localpart", "local_domains") +.smar.map="lum".type: "socket" +.smar.map="lum".path: "/var/spool/meta1/smap/userdb" +.smar.map="lum".mapname: "alias" +.smar.map="lum".min_connections: "10" +.smar.map="lum".max_connections: "1024" +.smar.map="lum".timeout: "6" +.smar.map="stdal".file: "aliases.db" +.smar.map="stdal".type: "hash" +.smar.map="ali".type: "sequence" +.smar.map="ali".maps: ("lum", "stdal") +.smar.aliases.name: "ali" +.smar.aliases.flags: ("localpart", "local_domains") +.smar.map="acc".type: "socket" +.smar.map="acc".address: "127.0.0.1" +.smar.map="acc".port: "1025" +.smar.map="acc".mapname: "access" +.smar.access_map.name: "acc" +]) + +AT_CLEANUP diff --git a/tests/testsuite.at b/tests/testsuite.at index 3816c00..b81b45e 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -75,2 +75,5 @@ m4_include([join.at]) +m4_include([parser-git.at]) +m4_include([parser-meta1.at]) + m4_include([vercmp.at]) |