~ubuntu-branches/ubuntu/quantal/dovecot/quantal

« back to all changes in this revision

Viewing changes to sieve/src/testsuite/cmd-test.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short, Scott Kitterman
  • Date: 2010-06-22 10:33:51 UTC
  • mfrom: (1.13.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100622103351-ifbmnklp8kxrhb30
Tags: 1:1.2.12-0ubuntu1
* New upstream release:
  - deliver: Don't crash when a message with Auto-submitted: header gets
   rejected.
  - lib-storage: Fixed header searches to work correctly when there are
    multiple headers with same name.
  - dict client: Disconnect from dict server after 1 second of idling.
  - dict: If process crashed, it wasn't automatically restarted
  - dict file: If dict file's group permissions equal world permissions,
    don't try to change its gid.
  - maildir: Fixed a memory leak when copying with hardlinks.
  - maildir: Expunging last messages may have assert-crashed if their
    filenames had just changed.
 * Update sieve patch to 0.1.17
 * debian/dovecot-common.postinst: Add warning about expired certificate.
   (Debian Bug: #576455)
 * Silence lintian warnings.

 [Scott Kitterman]
 * Rename dovecot-postfix to mail-stack-delivery per server-maverick-mail-
   integration spec.
   - Update debian/rules
   - Convert existing package to a dummy package and add new binary in debian/control
   - Update maintainer scripts.
   - Move previously installed backups and config files to new package name
     space in preinst
   - Add new debian/mail-stack-delivery.prerm to handle downgrades
   - Rename debian/dovecot-postfix.* to debian/mail-stack-delivery.*

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
/*
16
16
 * Test command
17
17
 *
18
 
 * Syntax:
 
18
 * Syntax:   
19
19
 *   test <test-name: string> <block>
20
20
 */
21
21
 
24
24
static bool cmd_test_generate
25
25
        (const struct sieve_codegen_env *cgenv, struct sieve_command *md);
26
26
 
27
 
const struct sieve_command_def cmd_test = {
28
 
        "test",
29
 
        SCT_COMMAND,
 
27
const struct sieve_command_def cmd_test = { 
 
28
        "test", 
 
29
        SCT_COMMAND, 
30
30
        1, 0, TRUE, TRUE,
31
31
        NULL, NULL,
32
 
        cmd_test_validate,
33
 
        cmd_test_generate,
34
 
        NULL
 
32
        cmd_test_validate, 
 
33
        cmd_test_generate, 
 
34
        NULL 
35
35
};
36
36
 
37
 
/*
38
 
 * Test operations
 
37
/* 
 
38
 * Test operations 
39
39
 */
40
40
 
41
41
/* Test operation */
45
45
static int cmd_test_operation_execute
46
46
        (const struct sieve_runtime_env *renv, sieve_size_t *address);
47
47
 
48
 
const struct sieve_operation_def test_operation = {
 
48
const struct sieve_operation_def test_operation = { 
49
49
        "TEST",
50
 
        &testsuite_extension,
 
50
        &testsuite_extension, 
51
51
        TESTSUITE_OPERATION_TEST,
52
 
        cmd_test_operation_dump,
53
 
        cmd_test_operation_execute
 
52
        cmd_test_operation_dump, 
 
53
        cmd_test_operation_execute 
54
54
};
55
55
 
56
56
/* Test_finish operation */
58
58
static int cmd_test_finish_operation_execute
59
59
        (const struct sieve_runtime_env *renv, sieve_size_t *address);
60
60
 
61
 
const struct sieve_operation_def test_finish_operation = {
 
61
const struct sieve_operation_def test_finish_operation = { 
62
62
        "TEST-FINISH",
63
 
        &testsuite_extension,
 
63
        &testsuite_extension, 
64
64
        TESTSUITE_OPERATION_TEST_FINISH,
65
 
        NULL,
66
 
        cmd_test_finish_operation_execute
 
65
        NULL, 
 
66
        cmd_test_finish_operation_execute 
67
67
};
68
68
 
69
 
/*
70
 
 * Validation
 
69
/* 
 
70
 * Validation 
71
71
 */
72
72
 
73
73
static bool cmd_test_validate
74
 
(struct sieve_validator *valdtr ATTR_UNUSED, struct sieve_command *cmd)
 
74
(struct sieve_validator *valdtr ATTR_UNUSED, struct sieve_command *cmd) 
75
75
{
76
76
        struct sieve_ast_argument *arg = cmd->first_positional;
77
 
 
 
77
                
78
78
        /* Check valid command placement */
79
79
        if ( !sieve_command_is_toplevel(cmd) )
80
80
        {
82
82
                        "tests cannot be nested: test command must be issued at top-level");
83
83
                return FALSE;
84
84
        }
85
 
 
 
85
        
86
86
        if ( !sieve_validate_positional_argument
87
87
                (valdtr, cmd, arg, "test-name", 1, SAAT_STRING) ) {
88
88
                return FALSE;
89
89
        }
90
 
 
 
90
        
91
91
        return sieve_validator_argument_activate(valdtr, cmd, arg, FALSE);
92
92
}
93
93
 
94
 
/*
95
 
 * Code generation
 
94
/* 
 
95
 * Code generation 
96
96
 */
97
97
 
98
98
static inline struct testsuite_generator_context *
99
99
_get_generator_context(struct sieve_generator *gentr)
100
100
{
101
 
        return (struct testsuite_generator_context *)
 
101
        return (struct testsuite_generator_context *) 
102
102
                sieve_generator_extension_get_context(gentr, testsuite_ext);
103
103
}
104
104
 
105
105
static bool cmd_test_generate
106
106
        (const struct sieve_codegen_env *cgenv, struct sieve_command *cmd)
107
107
{
108
 
        struct testsuite_generator_context *genctx =
 
108
        struct testsuite_generator_context *genctx = 
109
109
                _get_generator_context(cgenv->gentr);
110
 
 
 
110
        
111
111
        sieve_operation_emit(cgenv->sbin, cmd->ext, &test_operation);
112
112
 
113
113
        /* Generate arguments */
114
114
        if ( !sieve_generate_arguments(cgenv, cmd, NULL) )
115
115
                return FALSE;
116
 
 
 
116
                
117
117
        /* Prepare jumplist */
118
118
        sieve_jumplist_reset(genctx->exit_jumps);
119
 
 
 
119
                
120
120
        /* Test body */
121
121
        if ( !sieve_generate_block(cgenv, cmd->ast_node) )
122
122
                return FALSE;
123
 
 
 
123
        
124
124
        sieve_operation_emit(cgenv->sbin, cmd->ext, &test_finish_operation);
125
 
 
 
125
        
126
126
        /* Resolve exit jumps to this point */
127
 
        sieve_jumplist_resolve(genctx->exit_jumps);
128
 
 
 
127
        sieve_jumplist_resolve(genctx->exit_jumps); 
 
128
                        
129
129
        return TRUE;
130
130
}
131
131
 
132
 
/*
 
132
/* 
133
133
 * Code dump
134
134
 */
135
 
 
 
135
 
136
136
static bool cmd_test_operation_dump
137
137
(const struct sieve_dumptime_env *denv, sieve_size_t *address)
138
138
{
139
139
        sieve_code_dumpf(denv, "TEST:");
140
140
        sieve_code_descend(denv);
141
141
 
142
 
        return
 
142
        return 
143
143
                sieve_opr_string_dump(denv, address, "test name");
144
144
}
145
145
 
156
156
                sieve_runtime_trace_error(renv, "invalid test name operand");
157
157
                return SIEVE_EXEC_BIN_CORRUPT;
158
158
        }
159
 
 
 
159
        
160
160
        sieve_runtime_trace(renv, "TEST \"%s\"", str_c(test_name));
161
161
 
162
162
        testsuite_test_start(test_name);
164
164
}
165
165
 
166
166
static int cmd_test_finish_operation_execute
167
 
(const struct sieve_runtime_env *renv ATTR_UNUSED,
 
167
(const struct sieve_runtime_env *renv ATTR_UNUSED, 
168
168
        sieve_size_t *address ATTR_UNUSED)
169
169
{
170
170
        sieve_runtime_trace(renv, "TEST FINISHED");
171
 
 
 
171
        
172
172
        testsuite_test_succeed(NULL);
173
173
        return SIEVE_EXEC_OK;
174
174
}