dovecot-2.1-pigeonhole: Testsuite: added support for executing s...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Sun Aug 5 01:30:26 EEST 2012
details: http://hg.rename-it.nl/dovecot-2.1-pigeonhole/rev/e44101914a27
changeset: 1633:e44101914a27
user: Stephan Bosch <stephan at rename-it.nl>
date: Sun Aug 05 00:30:14 2012 +0200
description:
Testsuite: added support for executing sub-scripts and added tst variables namespace.
Added test for interaction between include extension and dict script location support.
diffstat:
src/testsuite/Makefile.am | 3 +
src/testsuite/cmd-test-binary.c | 4 +-
src/testsuite/ext-testsuite.c | 31 +-
src/testsuite/testsuite-common.c | 56 ++++-
src/testsuite/testsuite-common.h | 21 +-
src/testsuite/testsuite-script.c | 71 ++++--
src/testsuite/testsuite-script.h | 6 +-
src/testsuite/testsuite-variables.c | 186 ++++++++++++++++
src/testsuite/testsuite-variables.h | 14 +
src/testsuite/testsuite.c | 2 +-
tests/extensions/include/execute.svtest | 41 +-
tests/extensions/include/execute/namespace.sieve | 26 ++
tests/extensions/include/included-global/namespace.dict | 4 +
tests/extensions/include/included/namespace.dict | 4 +
14 files changed, 405 insertions(+), 64 deletions(-)
diffs (truncated from 772 to 300 lines):
diff -r 09e393e4274b -r e44101914a27 src/testsuite/Makefile.am
--- a/src/testsuite/Makefile.am Sat Aug 04 09:34:21 2012 +0200
+++ b/src/testsuite/Makefile.am Sun Aug 05 00:30:14 2012 +0200
@@ -2,6 +2,7 @@
AM_CPPFLAGS = \
-I$(top_srcdir)/src/lib-sieve \
+ -I$(top_srcdir)/src/lib-sieve/plugins/variables \
-I$(top_srcdir)/src/lib-sieve-tool \
$(LIBDOVECOT_INCLUDE) \
$(LIBDOVECOT_SERVICE_INCLUDE)
@@ -38,6 +39,7 @@
testsuite-settings.c \
testsuite-objects.c \
testsuite-substitutions.c \
+ testsuite-variables.c \
testsuite-arguments.c \
testsuite-message.c \
testsuite-log.c \
@@ -56,6 +58,7 @@
testsuite-settings.h \
testsuite-objects.h \
testsuite-substitutions.h \
+ testsuite-variables.h \
testsuite-arguments.h \
testsuite-message.h \
testsuite-log.h \
diff -r 09e393e4274b -r e44101914a27 src/testsuite/cmd-test-binary.c
--- a/src/testsuite/cmd-test-binary.c Sat Aug 04 09:34:21 2012 +0200
+++ b/src/testsuite/cmd-test-binary.c Sun Aug 05 00:30:14 2012 +0200
@@ -176,7 +176,7 @@
}
if ( sbin != NULL ) {
- testsuite_script_set_binary(sbin);
+ testsuite_script_set_binary(renv, sbin);
sieve_binary_unref(&sbin);
} else {
@@ -186,7 +186,7 @@
}
} else if ( sieve_operation_is(oprtn, test_binary_save_operation) ) {
- struct sieve_binary *sbin = testsuite_script_get_binary();
+ struct sieve_binary *sbin = testsuite_script_get_binary(renv);
if ( sieve_runtime_trace_active(renv, SIEVE_TRLVL_COMMANDS) ) {
sieve_runtime_trace(renv, 0, "testsuite: test_binary_save command");
diff -r 09e393e4274b -r e44101914a27 src/testsuite/ext-testsuite.c
--- a/src/testsuite/ext-testsuite.c Sat Aug 04 09:34:21 2012 +0200
+++ b/src/testsuite/ext-testsuite.c Sun Aug 05 00:30:14 2012 +0200
@@ -45,6 +45,7 @@
#include "sieve-result.h"
#include "testsuite-common.h"
+#include "testsuite-variables.h"
#include "testsuite-arguments.h"
/*
@@ -76,16 +77,17 @@
&test_binary_save_operation
};
-/*
- * Operands
+/*
+ * Operands
*/
-const struct sieve_operand_def *testsuite_operands[] = {
+const struct sieve_operand_def *testsuite_operands[] = {
&testsuite_object_operand,
- &testsuite_substitution_operand
+ &testsuite_substitution_operand,
+ &testsuite_namespace_operand
};
-
-/*
+
+/*
* Extension
*/
@@ -95,6 +97,9 @@
(const struct sieve_extension *ext, struct sieve_validator *valdtr);
static bool ext_testsuite_generator_load
(const struct sieve_extension *ext, const struct sieve_codegen_env *cgenv);
+static bool ext_testsuite_interpreter_load
+ (const struct sieve_extension *ext, const struct sieve_runtime_env *renv,
+ sieve_size_t *address);
static bool ext_testsuite_binary_load
(const struct sieve_extension *ext, struct sieve_binary *sbin);
@@ -105,7 +110,7 @@
NULL, NULL,
ext_testsuite_validator_load,
ext_testsuite_generator_load,
- NULL,
+ ext_testsuite_interpreter_load,
ext_testsuite_binary_load,
NULL, NULL,
SIEVE_EXT_DEFINE_OPERATIONS(testsuite_operations),
@@ -142,6 +147,8 @@
/* sieve_validator_argument_override(valdtr, SAT_VAR_STRING, ext,
&testsuite_string_argument);*/
+ testsuite_variables_init(ext, valdtr);
+
return testsuite_validator_context_initialize(valdtr);
}
@@ -151,9 +158,15 @@
return testsuite_generator_context_initialize(cgenv->gentr, ext);
}
+static bool ext_testsuite_interpreter_load
+(const struct sieve_extension *ext, const struct sieve_runtime_env *renv,
+ sieve_size_t *address ATTR_UNUSED)
+{
+ return testsuite_interpreter_context_initialize(renv->interp, ext);
+}
+
static bool ext_testsuite_binary_load
-(const struct sieve_extension *ext ATTR_UNUSED,
- struct sieve_binary *sbin ATTR_UNUSED)
+(const struct sieve_extension *ext ATTR_UNUSED, struct sieve_binary *sbin ATTR_UNUSED)
{
return TRUE;
}
diff -r 09e393e4274b -r e44101914a27 src/testsuite/testsuite-common.c
--- a/src/testsuite/testsuite-common.c Sat Aug 04 09:34:21 2012 +0200
+++ b/src/testsuite/testsuite-common.c Sun Aug 05 00:30:14 2012 +0200
@@ -17,6 +17,7 @@
#include "sieve-message.h"
#include "sieve-commands.h"
#include "sieve-extensions.h"
+#include "sieve-binary.h"
#include "sieve-validator.h"
#include "sieve-generator.h"
#include "sieve-interpreter.h"
@@ -45,6 +46,7 @@
*/
struct sieve_instance *testsuite_sieve_instance = NULL;
+char *testsuite_test_path = NULL;
/* Test context */
@@ -103,6 +105,48 @@
}
/*
+ * Interpreter context
+ */
+
+static void testsuite_interpreter_free
+(const struct sieve_extension *ext ATTR_UNUSED,
+ struct sieve_interpreter *interp ATTR_UNUSED, void *context)
+{
+ struct testsuite_interpreter_context *ctx =
+ (struct testsuite_interpreter_context *)context;
+
+ if ( ctx->compiled_script != NULL )
+ sieve_binary_unref(&ctx->compiled_script);
+}
+
+const struct sieve_interpreter_extension testsuite_interpreter_ext = {
+ &testsuite_extension,
+ NULL,
+ testsuite_interpreter_free,
+};
+
+bool testsuite_interpreter_context_initialize
+(struct sieve_interpreter *interp, const struct sieve_extension *this_ext)
+{
+ pool_t pool = sieve_interpreter_pool(interp);
+ struct testsuite_interpreter_context *ctx =
+ p_new(pool, struct testsuite_interpreter_context, 1);
+
+ sieve_interpreter_extension_register
+ (interp, this_ext, &testsuite_interpreter_ext, ctx);
+ return TRUE;
+}
+
+struct testsuite_interpreter_context *testsuite_interpreter_context_get
+(struct sieve_interpreter *interp, const struct sieve_extension *this_ext)
+{
+ struct testsuite_interpreter_context *ctx =
+ sieve_interpreter_extension_get_context(interp, this_ext);
+
+ return ctx;
+}
+
+/*
* Test context
*/
@@ -234,28 +278,34 @@
* Main testsuite init/deinit
*/
-void testsuite_init(struct sieve_instance *svinst, bool log_stdout)
+void testsuite_init
+(struct sieve_instance *svinst, const char *test_path, bool log_stdout)
{
testsuite_sieve_instance = svinst;
testsuite_test_context_init();
testsuite_log_init(log_stdout);
testsuite_tmp_dir_init();
-
+
testsuite_script_init();
testsuite_binary_init();
testsuite_smtp_init();
testsuite_ext = sieve_extension_register
(svinst, &testsuite_extension, TRUE);
+
+
+ testsuite_test_path = i_strdup(test_path);
}
void testsuite_deinit(void)
{
+ i_free(testsuite_test_path);
+
testsuite_smtp_deinit();
testsuite_binary_deinit();
testsuite_script_deinit();
-
+
testsuite_tmp_dir_deinit();
testsuite_log_deinit();
testsuite_test_context_deinit();
diff -r 09e393e4274b -r e44101914a27 src/testsuite/testsuite-common.h
--- a/src/testsuite/testsuite-common.h Sat Aug 04 09:34:21 2012 +0200
+++ b/src/testsuite/testsuite-common.h Sun Aug 05 00:30:14 2012 +0200
@@ -20,6 +20,8 @@
extern const struct sieve_script_env *testsuite_scriptenv;
+extern char *testsuite_test_path;
+
/*
* Validator context
@@ -45,6 +47,19 @@
(struct sieve_generator *gentr, const struct sieve_extension *this_ext);
/*
+ * Interpreter context
+ */
+
+struct testsuite_interpreter_context {
+ struct sieve_binary *compiled_script;
+};
+
+bool testsuite_interpreter_context_initialize
+ (struct sieve_interpreter *interp, const struct sieve_extension *this_ext);
+struct testsuite_interpreter_context *testsuite_interpreter_context_get
+ (struct sieve_interpreter *interp, const struct sieve_extension *this_ext);
+
+/*
* Commands
*/
@@ -136,7 +151,8 @@
enum testsuite_operand_code {
TESTSUITE_OPERAND_OBJECT,
- TESTSUITE_OPERAND_SUBSTITUTION
+ TESTSUITE_OPERAND_SUBSTITUTION,
+ TESTSUITE_OPERAND_NAMESPACE
};
/*
@@ -163,7 +179,8 @@
* Testsuite init/deinit
*/
-void testsuite_init(struct sieve_instance *svinst, bool log_stdout);
+void testsuite_init
+ (struct sieve_instance *svinst, const char *test_path, bool log_stdout);
void testsuite_deinit(void);
#endif /* __TESTSUITE_COMMON_H */
diff -r 09e393e4274b -r e44101914a27 src/testsuite/testsuite-script.c
--- a/src/testsuite/testsuite-script.c Sat Aug 04 09:34:21 2012 +0200
+++ b/src/testsuite/testsuite-script.c Sun Aug 05 00:30:14 2012 +0200
@@ -21,20 +21,14 @@
/*
* Tested script environment
- */
-
-struct sieve_binary *_testsuite_compiled_script;
+ */
void testsuite_script_init(void)
More information about the dovecot-cvs
mailing list