Coverage Report

Created: 2026-10-31 06:36

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/pigeonhole/src/testsuite/cmd-test-result.c
Line
Count
Source
1
/* Copyright (c) Pigeonhole authors, see top-level COPYING file */
2
3
#include "sieve-common.h"
4
#include "sieve-script.h"
5
#include "sieve-commands.h"
6
#include "sieve-validator.h"
7
#include "sieve-generator.h"
8
#include "sieve-interpreter.h"
9
#include "sieve-code.h"
10
#include "sieve-binary.h"
11
#include "sieve-dump.h"
12
#include "sieve.h"
13
14
#include "testsuite-common.h"
15
#include "testsuite-result.h"
16
#include "testsuite-message.h"
17
#include "testsuite-smtp.h"
18
19
/*
20
 * Commands
21
 */
22
23
static bool
24
cmd_test_result_generate(const struct sieve_codegen_env *cgenv,
25
       struct sieve_command *cmd);
26
27
/* Test_result_reset command
28
 *
29
 * Syntax:
30
 *   test_result_reset
31
 */
32
33
const struct sieve_command_def cmd_test_result_reset = {
34
  .identifier = "test_result_reset",
35
  .type = SCT_COMMAND,
36
  .positional_args = 0,
37
  .subtests = 0,
38
  .block_allowed = FALSE,
39
  .block_required = FALSE,
40
  .generate = cmd_test_result_generate,
41
};
42
43
/* Test_result_print command
44
 *
45
 * Syntax:
46
 *   test_result_print
47
 */
48
49
const struct sieve_command_def cmd_test_result_print = {
50
  .identifier = "test_result_print",
51
  .type = SCT_COMMAND,
52
  .positional_args = 0,
53
  .subtests = 0,
54
  .block_allowed = FALSE,
55
  .block_required = FALSE,
56
  .generate = cmd_test_result_generate,
57
};
58
59
/*
60
 * Operations
61
 */
62
63
/* test_result_reset */
64
65
static int
66
cmd_test_result_reset_operation_execute(const struct sieve_runtime_env *renv,
67
          sieve_size_t *address);
68
69
const struct sieve_operation_def test_result_reset_operation = {
70
  .mnemonic = "TEST_RESULT_RESET",
71
  .ext_def = &testsuite_extension,
72
  .code = TESTSUITE_OPERATION_TEST_RESULT_RESET,
73
  .execute = cmd_test_result_reset_operation_execute,
74
};
75
76
/* test_result_print */
77
78
static int
79
cmd_test_result_print_operation_execute(const struct sieve_runtime_env *renv,
80
          sieve_size_t *address);
81
82
const struct sieve_operation_def test_result_print_operation = {
83
  .mnemonic = "TEST_RESULT_PRINT",
84
  .ext_def = &testsuite_extension,
85
  .code = TESTSUITE_OPERATION_TEST_RESULT_PRINT,
86
  .execute = cmd_test_result_print_operation_execute,
87
};
88
89
/*
90
 * Code generation
91
 */
92
93
static bool
94
cmd_test_result_generate(const struct sieve_codegen_env *cgenv,
95
       struct sieve_command *cmd)
96
0
{
97
0
  if (sieve_command_is(cmd, cmd_test_result_reset)) {
98
0
    sieve_operation_emit(cgenv->sblock, cmd->ext,
99
0
             &test_result_reset_operation);
100
0
  } else if (sieve_command_is(cmd, cmd_test_result_print)) {
101
0
    sieve_operation_emit(cgenv->sblock, cmd->ext,
102
0
             &test_result_print_operation);
103
0
  } else {
104
0
    i_unreached();
105
0
  }
106
107
0
  return TRUE;
108
0
}
109
110
/*
111
 * Intepretation
112
 */
113
114
static int
115
cmd_test_result_reset_operation_execute(const struct sieve_runtime_env *renv,
116
          sieve_size_t *address ATTR_UNUSED)
117
0
{
118
0
  sieve_runtime_trace(renv, SIEVE_TRLVL_COMMANDS, "testsuite: "
119
0
          "test_result_reset command; reset script result");
120
121
0
  testsuite_result_reset(renv);
122
0
  testsuite_smtp_reset();
123
124
0
  return SIEVE_EXEC_OK;
125
0
}
126
127
static int
128
cmd_test_result_print_operation_execute(const struct sieve_runtime_env *renv,
129
          sieve_size_t *address ATTR_UNUSED)
130
0
{
131
0
  sieve_runtime_trace(renv, SIEVE_TRLVL_COMMANDS, "testsuite: "
132
0
          "test_result_print command; print script result ");
133
134
0
  testsuite_result_print(renv);
135
136
0
  return SIEVE_EXEC_OK;
137
0
}