/src/pigeonhole/src/testsuite/tst-test-result-execute.c
Line | Count | Source |
1 | | /* Copyright (c) 2002-2018 Pigeonhole authors, see the included COPYING file |
2 | | */ |
3 | | |
4 | | #include "sieve-common.h" |
5 | | #include "sieve-script.h" |
6 | | #include "sieve-commands.h" |
7 | | #include "sieve-validator.h" |
8 | | #include "sieve-generator.h" |
9 | | #include "sieve-interpreter.h" |
10 | | #include "sieve-code.h" |
11 | | #include "sieve-binary.h" |
12 | | #include "sieve-dump.h" |
13 | | #include "sieve.h" |
14 | | |
15 | | #include "testsuite-common.h" |
16 | | #include "testsuite-result.h" |
17 | | |
18 | | /* |
19 | | * Test_result_execute command |
20 | | * |
21 | | * Syntax: |
22 | | * test_result_execute |
23 | | */ |
24 | | |
25 | | static bool tst_test_result_execute_generate |
26 | | (const struct sieve_codegen_env *cgenv, struct sieve_command *cmd); |
27 | | |
28 | | const struct sieve_command_def tst_test_result_execute = { |
29 | | .identifier = "test_result_execute", |
30 | | .type = SCT_TEST, |
31 | | .positional_args = 0, |
32 | | .subtests = 0, |
33 | | .block_allowed = FALSE, |
34 | | .block_required = FALSE, |
35 | | .generate = tst_test_result_execute_generate |
36 | | }; |
37 | | |
38 | | /* |
39 | | * Operation |
40 | | */ |
41 | | |
42 | | static int tst_test_result_execute_operation_execute |
43 | | (const struct sieve_runtime_env *renv, sieve_size_t *address); |
44 | | |
45 | | const struct sieve_operation_def test_result_execute_operation = { |
46 | | .mnemonic = "TEST_RESULT_EXECUTE", |
47 | | .ext_def = &testsuite_extension, |
48 | | .code = TESTSUITE_OPERATION_TEST_RESULT_EXECUTE, |
49 | | .execute = tst_test_result_execute_operation_execute |
50 | | }; |
51 | | |
52 | | /* |
53 | | * Code generation |
54 | | */ |
55 | | |
56 | | static bool tst_test_result_execute_generate |
57 | | (const struct sieve_codegen_env *cgenv, struct sieve_command *tst) |
58 | 0 | { |
59 | 0 | sieve_operation_emit(cgenv->sblock, tst->ext, &test_result_execute_operation); |
60 | |
|
61 | 0 | return TRUE; |
62 | 0 | } |
63 | | |
64 | | /* |
65 | | * Intepretation |
66 | | */ |
67 | | |
68 | | static int tst_test_result_execute_operation_execute |
69 | | (const struct sieve_runtime_env *renv, sieve_size_t *address ATTR_UNUSED) |
70 | 0 | { |
71 | 0 | bool result = TRUE; |
72 | | |
73 | | /* |
74 | | * Perform operation |
75 | | */ |
76 | |
|
77 | 0 | sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, |
78 | 0 | "testsuite: test_result_execute test"); |
79 | |
|
80 | 0 | result = testsuite_result_execute(renv); |
81 | |
|
82 | 0 | if ( sieve_runtime_trace_active(renv, SIEVE_TRLVL_TESTS) ) { |
83 | 0 | sieve_runtime_trace_descend(renv); |
84 | 0 | sieve_runtime_trace(renv, 0, "execution of result %s", |
85 | 0 | ( result ? "succeeded" : "failed" )); |
86 | 0 | } |
87 | | |
88 | | /* Set result */ |
89 | 0 | sieve_interpreter_set_test_result(renv->interp, result); |
90 | |
|
91 | 0 | return SIEVE_EXEC_OK; |
92 | 0 | } |
93 | | |
94 | | |
95 | | |
96 | | |