Mercurial > dovecot > original-hg > imaptest
changeset 279:f7dce257fc41
tests: Support APPENDs with the actual message body parameter.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 29 Aug 2012 17:13:08 +0300 |
parents | d18a1b646f7a |
children | b98aa1b41481 |
files | src/test-exec.c src/test-parser.c src/test-parser.h |
diffstat | 3 files changed, 36 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/test-exec.c Wed Aug 29 17:01:28 2012 +0300 +++ b/src/test-exec.c Wed Aug 29 17:13:08 2012 +0300 @@ -690,6 +690,32 @@ return strcasecmp(str, "bad") == 0; } +static bool +append_has_body(struct test_exec_context *ctx, const char *str_args) +{ + ARRAY_TYPE(imap_arg_list) *arg_list; + const struct imap_arg *args; + const char *error; + + /* mailbox [(flags)] ["datetime"] */ + arg_list = test_parse_imap_args(ctx->pool, str_args, &error); + if (arg_list == NULL) + return FALSE; + args = array_idx(arg_list, 0); + if (args->type == IMAP_ARG_EOL) + return FALSE; + + if (args[1].type == IMAP_ARG_LIST) + args++; + if (args[1].type == IMAP_ARG_STRING) + args++; + + return args[1].type == IMAP_ARG_LITERAL || + args[1].type == IMAP_ARG_LITERAL_SIZE || + args[1].type == IMAP_ARG_LITERAL_SIZE_NONSYNC || + imap_arg_atom_equals(&args[1], "catenate"); +} + static void test_send_next_command(struct test_exec_context *ctx) { struct test_command *const *cmdp; @@ -721,7 +747,8 @@ client->state = STATE_APPEND; (void)client_append_full(client, NULL, NULL, NULL, test_cmd_callback, &ctx->cur_cmd); - } else if (strncasecmp(cmdline, "append ", 7) == 0) { + } else if (strncasecmp(cmdline, "append ", 7) == 0 && + !append_has_body(ctx, cmdline+7)) { client->state = STATE_APPEND; (void)client_append(client, cmdline + 7, FALSE, test_cmd_callback, &ctx->cur_cmd);
--- a/src/test-parser.c Wed Aug 29 17:01:28 2012 +0300 +++ b/src/test-parser.c Wed Aug 29 17:13:08 2012 +0300 @@ -124,9 +124,8 @@ return list; } -static ARRAY_TYPE(imap_arg_list) * -test_parse_imap_args(struct test_parser *parser, const char *line, - const char **error_r) +ARRAY_TYPE(imap_arg_list) * +test_parse_imap_args(pool_t pool, const char *line, const char **error_r) { struct imap_parser *imap_parser; struct istream *input; @@ -149,7 +148,7 @@ &fatal)); } } else { - dup_args = test_parse_imap_args_dup(parser->pool, args); + dup_args = test_parse_imap_args_dup(pool, args); } imap_parser_unref(&imap_parser); i_stream_unref(&input); @@ -339,7 +338,7 @@ if (!array_is_created(&cmd->untagged)) p_array_init(&cmd->untagged, parser->pool, 8); - args_arr = test_parse_imap_args(parser, line, error_r); + args_arr = test_parse_imap_args(parser->pool, line, error_r); if (args_arr == NULL) return FALSE; @@ -397,7 +396,7 @@ struct test_command *cmd = parser->cur_cmd; ARRAY_TYPE(imap_arg_list) *args; - args = test_parse_imap_args(parser, line, error_r); + args = test_parse_imap_args(parser->pool, line, error_r); cmd->reply = array_idx(args, 0); return cmd->reply != NULL; }
--- a/src/test-parser.h Wed Aug 29 17:01:28 2012 +0300 +++ b/src/test-parser.h Wed Aug 29 17:13:08 2012 +0300 @@ -60,4 +60,7 @@ /* Return an array of tests. They're freed when the parser is deinitialized. */ const ARRAY_TYPE(test) *test_parser_get_tests(struct test_parser *parser); +ARRAY_TYPE(imap_arg_list) * +test_parse_imap_args(pool_t pool, const char *line, const char **error_r); + #endif