diff options
-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 | |||
@@ -44,22 +44,33 @@ struct token { | |||
44 | 44 | ||
45 | #define ISSPACE(c) (strchr(" \t\r\f\n", c) != NULL) | 45 | #define ISSPACE(c) (strchr(" \t\r\f\n", c) != NULL) |
46 | #define ISIDENT(c) ((isascii(c) && isalnum(c)) || (c) == '_') | 46 | #define ISIDENT(c) ((isascii(c) && isalnum(c)) || (c) == '_') |
47 | #define ISINITIAL(c) ((isascii(c) && isalpha(c)) || (c) == '_') | 47 | #define ISINITIAL(c) ((isascii(c) && isalpha(c)) || (c) == '_') |
48 | 48 | ||
49 | static int | 49 | static int |
50 | input() | 50 | rawinput() |
51 | { | 51 | { |
52 | if (!infile || feof(infile)) | 52 | if (!infile || feof(infile)) |
53 | return 0; | 53 | return 0; |
54 | input_char = fgetc(infile); | 54 | input_char = fgetc(infile); |
55 | if (input_char == '\n') | 55 | if (input_char == '\n') |
56 | grecs_current_locus.line++; | 56 | grecs_current_locus.line++; |
57 | return input_char; | 57 | return input_char; |
58 | } | 58 | } |
59 | 59 | ||
60 | static int | ||
61 | input() | ||
62 | { | ||
63 | rawinput(); | ||
64 | if (input_char == '#') { | ||
65 | while (rawinput() && input_char != '\n') | ||
66 | ; | ||
67 | } | ||
68 | return input_char; | ||
69 | } | ||
70 | |||
60 | static void | 71 | static void |
61 | unput() | 72 | unput() |
62 | { | 73 | { |
63 | if (!input_char) | 74 | if (!input_char) |
64 | return; | 75 | return; |
65 | if (input_char == '\n') | 76 | if (input_char == '\n') |
@@ -84,13 +95,13 @@ collect_tag() | |||
84 | tok.tag = grecs_txtacc_finish(acc, 0); | 95 | tok.tag = grecs_txtacc_finish(acc, 0); |
85 | } | 96 | } |
86 | 97 | ||
87 | static void | 98 | static void |
88 | collect_string() | 99 | collect_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, |
94 | "unexpected EOF in string"); | 105 | "unexpected EOF in string"); |
95 | break; | 106 | break; |
96 | } | 107 | } |
diff --git a/tests/Makefile.am b/tests/Makefile.am index 73ffeae..f5d1f6f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am | |||
@@ -11,13 +11,13 @@ | |||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | # GNU General Public License for more details. | 12 | # GNU General Public License for more details. |
13 | # | 13 | # |
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 | ||
17 | EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 gcf1.conf | 17 | EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 gcf1.conf meta1.conf git.conf |
18 | DISTCLEANFILES = atconfig $(check_SCRIPTS) | 18 | DISTCLEANFILES = atconfig $(check_SCRIPTS) |
19 | MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) | 19 | MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) |
20 | 20 | ||
21 | 21 | ||
22 | ## ------------ ## | 22 | ## ------------ ## |
23 | ## package.m4. ## | 23 | ## package.m4. ## |
@@ -48,12 +48,14 @@ TESTSUITE_AT = \ | |||
48 | glob00.at\ | 48 | glob00.at\ |
49 | glob01.at\ | 49 | glob01.at\ |
50 | glob02.at\ | 50 | glob02.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\ |
57 | peek03.at\ | 59 | peek03.at\ |
58 | reduce00.at\ | 60 | reduce00.at\ |
59 | reduce01.at\ | 61 | reduce01.at\ |
diff --git a/tests/gcffmt.c b/tests/gcffmt.c index b4a4ece..51e3037 100644 --- a/tests/gcffmt.c +++ b/tests/gcffmt.c | |||
@@ -23,13 +23,13 @@ | |||
23 | 23 | ||
24 | static void | 24 | static void |
25 | usage(const char *arg, FILE *fp, int code) | 25 | 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 | } |
33 | 33 | ||
34 | static int | 34 | static int |
35 | node_ident_cmp(struct grecs_node const *a, struct grecs_node const *b) | 35 | node_ident_cmp(struct grecs_node const *a, struct grecs_node const *b) |
@@ -56,13 +56,24 @@ main(int argc, char **argv) | |||
56 | else if (strcmp(arg, "-reduce") == 0) | 56 | else if (strcmp(arg, "-reduce") == 0) |
57 | reduce = 1; | 57 | reduce = 1; |
58 | else if (strcmp(arg, "-sort") == 0) | 58 | else if (strcmp(arg, "-sort") == 0) |
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; |
66 | --argc; | 77 | --argc; |
67 | break; | 78 | break; |
68 | } | 79 | } |
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 | |||
3 | hostname = "host.example.org"; | ||
4 | |||
5 | smtps { | ||
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 | |||
35 | smtps 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 | |||
47 | smtpc { | ||
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 | ||