dovecot-2.1-pigeonhole: testsuite: added test_message_print comm...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Sat Nov 26 15:19:56 EET 2011
details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/8af074872b41
changeset: 1556:8af074872b41
user: Stephan Bosch <stephan at rename-it.nl>
date: Sat Nov 26 14:06:50 2011 +0100
description:
testsuite: added test_message_print command to print the current message content.
diffstat:
src/testsuite/cmd-test-message.c | 89 ++++++++++++++++++++++++++++++++++++++++++++-
src/testsuite/ext-testsuite.c | 2 +
src/testsuite/testsuite-common.h | 3 +
3 files changed, 93 insertions(+), 1 deletions(-)
diffs (190 lines):
diff -r df95edf614c4 -r 8af074872b41 src/testsuite/cmd-test-message.c
--- a/src/testsuite/cmd-test-message.c Sat Nov 26 11:49:07 2011 +0100
+++ b/src/testsuite/cmd-test-message.c Sat Nov 26 14:06:50 2011 +0100
@@ -1,8 +1,12 @@
/* Copyright (c) 2002-2011 Pigeonhole authors, see the included COPYING file
*/
+#include "lib.h"
+#include "istream.h"
+
#include "sieve-common.h"
#include "sieve-commands.h"
+#include "sieve-message.h"
#include "sieve-validator.h"
#include "sieve-generator.h"
#include "sieve-interpreter.h"
@@ -15,7 +19,10 @@
#include "testsuite-mailstore.h"
/*
- * Test_message command
+ * Commands
+ */
+
+/* Test_message command
*
* Syntax:
* test_message ( :smtp / :mailbox <mailbox: string> ) <index: number>
@@ -41,6 +48,25 @@
NULL
};
+/* Test_message_print command
+ *
+ * Syntax:
+ * test_message_print
+ */
+
+static bool cmd_test_message_print_generate
+ (const struct sieve_codegen_env *cgenv, struct sieve_command *cmd);
+
+const struct sieve_command_def cmd_test_message_print = {
+ "test_message_print",
+ SCT_COMMAND,
+ 0, 0, FALSE, FALSE,
+ NULL, NULL, NULL, NULL,
+ cmd_test_message_print_generate
+ , NULL
+};
+
+
/*
* Operations
*/
@@ -75,6 +101,21 @@
cmd_test_message_mailbox_operation_execute
};
+/* Test_message_print operation */
+
+static bool cmd_test_message_print_operation_dump
+ (const struct sieve_dumptime_env *denv, sieve_size_t *address);
+static int cmd_test_message_print_operation_execute
+ (const struct sieve_runtime_env *renv, sieve_size_t *address);
+
+const struct sieve_operation_def test_message_print_operation = {
+ "TEST_MESSAGE_PRINT",
+ &testsuite_extension,
+ TESTSUITE_OPERATION_TEST_MESSAGE_PRINT,
+ cmd_test_message_print_operation_dump,
+ cmd_test_message_print_operation_execute
+};
+
/*
* Compiler context data
*/
@@ -254,6 +295,15 @@
return TRUE;
}
+static bool cmd_test_message_print_generate
+(const struct sieve_codegen_env *cgenv, struct sieve_command *cmd)
+{
+ /* Emit operation */
+ sieve_operation_emit
+ (cgenv->sblock, cmd->ext, &test_message_print_operation);
+ return TRUE;
+}
+
/*
* Code dump
*/
@@ -292,6 +342,15 @@
sieve_opr_number_dump(denv, address, "index");
}
+static bool cmd_test_message_print_operation_dump
+(const struct sieve_dumptime_env *denv, sieve_size_t *address ATTR_UNUSED)
+{
+ sieve_code_dumpf(denv, "TEST_MESSAGE_PRINT");
+
+ return TRUE;
+}
+
+
/*
* Intepretation
*/
@@ -420,7 +479,35 @@
return SIEVE_EXEC_OK;
}
+static int cmd_test_message_print_operation_execute
+(const struct sieve_runtime_env *renv, sieve_size_t *address ATTR_UNUSED)
+{
+ struct mail *mail = sieve_message_get_mail(renv->msgctx);
+ struct istream *input;
+ const unsigned char *data;
+ size_t size;
+ int ret;
+ if (mail_get_stream(mail, NULL, NULL, &input) < 0) {
+ sieve_runtime_error(renv, NULL,
+ "test_message_print: failed to read current message");
+ return SIEVE_EXEC_OK;
+ }
+ printf("\n--MESSAGE: \n");
+
+ /* Pipe the message to the outgoing SMTP transport */
+ while ((ret=i_stream_read_data(input, &data, &size, 0)) > 0) {
+ write(1, data, size);
+ i_stream_skip(input, size);
+ }
+ printf("\n--MESSAGE--\n");
+
+ return SIEVE_EXEC_OK;
+}
+
+
+
+
diff -r df95edf614c4 -r 8af074872b41 src/testsuite/ext-testsuite.c
--- a/src/testsuite/ext-testsuite.c Sat Nov 26 11:49:07 2011 +0100
+++ b/src/testsuite/ext-testsuite.c Sat Nov 26 14:06:50 2011 +0100
@@ -69,6 +69,7 @@
&test_result_print_operation,
&test_message_smtp_operation,
&test_message_mailbox_operation,
+ &test_message_print_operation,
&test_mailbox_create_operation,
&test_mailbox_delete_operation,
&test_binary_load_operation,
@@ -125,6 +126,7 @@
sieve_validator_register_command(valdtr, ext, &cmd_test_result_print);
sieve_validator_register_command(valdtr, ext, &cmd_test_result_reset);
sieve_validator_register_command(valdtr, ext, &cmd_test_message);
+ sieve_validator_register_command(valdtr, ext, &cmd_test_message_print);
sieve_validator_register_command(valdtr, ext, &cmd_test_mailbox_create);
sieve_validator_register_command(valdtr, ext, &cmd_test_mailbox_delete);
sieve_validator_register_command(valdtr, ext, &cmd_test_binary_load);
diff -r df95edf614c4 -r 8af074872b41 src/testsuite/testsuite-common.h
--- a/src/testsuite/testsuite-common.h Sat Nov 26 11:49:07 2011 +0100
+++ b/src/testsuite/testsuite-common.h Sat Nov 26 14:06:50 2011 +0100
@@ -57,6 +57,7 @@
extern const struct sieve_command_def cmd_test_result_reset;
extern const struct sieve_command_def cmd_test_result_print;
extern const struct sieve_command_def cmd_test_message;
+extern const struct sieve_command_def cmd_test_message_print;
extern const struct sieve_command_def cmd_test_mailbox;
extern const struct sieve_command_def cmd_test_mailbox_create;
extern const struct sieve_command_def cmd_test_mailbox_delete;
@@ -96,6 +97,7 @@
TESTSUITE_OPERATION_TEST_RESULT_PRINT,
TESTSUITE_OPERATION_TEST_MESSAGE_SMTP,
TESTSUITE_OPERATION_TEST_MESSAGE_MAILBOX,
+ TESTSUITE_OPERATION_TEST_MESSAGE_PRINT,
TESTSUITE_OPERATION_TEST_MAILBOX_CREATE,
TESTSUITE_OPERATION_TEST_MAILBOX_DELETE,
TESTSUITE_OPERATION_TEST_BINARY_LOAD,
@@ -119,6 +121,7 @@
extern const struct sieve_operation_def test_result_print_operation;
extern const struct sieve_operation_def test_message_smtp_operation;
extern const struct sieve_operation_def test_message_mailbox_operation;
+extern const struct sieve_operation_def test_message_print_operation;
extern const struct sieve_operation_def test_mailbox_create_operation;
extern const struct sieve_operation_def test_mailbox_delete_operation;
extern const struct sieve_operation_def test_binary_load_operation;
More information about the dovecot-cvs
mailing list