aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_local_test_prepared.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_local_test_prepared.c')
-rw-r--r--src/testing/testing_api_cmd_local_test_prepared.c146
1 files changed, 0 insertions, 146 deletions
diff --git a/src/testing/testing_api_cmd_local_test_prepared.c b/src/testing/testing_api_cmd_local_test_prepared.c
deleted file mode 100644
index 9dc7dfa9a..000000000
--- a/src/testing/testing_api_cmd_local_test_prepared.c
+++ /dev/null
@@ -1,146 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file testing_api_cmd_local_test_prepared.c
23 * @brief cmd to block the interpreter loop until all peers started.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h"
29#include "gnunet_testing_netjail_lib.h"
30#include "testing_cmds.h"
31
32/**
33 * Generic logging shortcut
34 */
35#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
36
37
38/**
39 * This function prepares an array with traits.
40 *
41 */
42enum GNUNET_GenericReturnValue
43local_test_prepared_traits (void *cls,
44 const void **ret,
45 const char *trait,
46 unsigned int index)
47{
48 struct LocalPreparedState *lfs = cls;
49 struct GNUNET_TESTING_Trait traits[] = {
50 {
51 .index = 0,
52 .trait_name = "state",
53 .ptr = (const void *) lfs,
54 },
55 GNUNET_TESTING_trait_end ()
56 };
57 return GNUNET_TESTING_get_trait (traits,
58 ret,
59 trait,
60 index);
61}
62
63
64/**
65 * Function to get the trait with the struct LocalPreparedState.
66 *
67 * @param[out] lfs struct LocalPreparedState.
68 * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
69 *
70 */
71enum GNUNET_GenericReturnValue
72GNUNET_TESTING_get_trait_local_prepared_state (
73 const struct GNUNET_TESTING_Command *cmd,
74 struct LocalPreparedState **lfs)
75{
76 return cmd->traits (cmd->cls,
77 (const void **) lfs,
78 "state",
79 (unsigned int) 0);
80}
81
82
83/**
84 * The cleanup function of this cmd frees resources the cmd allocated.
85 *
86 */
87static void
88local_test_prepared_cleanup (void *cls)
89{
90 struct LocalPreparedState *lfs = cls;
91
92 GNUNET_free (lfs);
93}
94
95
96/**
97 * This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TESTS_PREPARED message to the master loop.
98 *
99 */
100static void
101local_test_prepared_run (void *cls,
102 struct GNUNET_TESTING_Interpreter *is)
103{
104 struct LocalPreparedState *lfs = cls;
105
106 struct GNUNET_CMDS_LOCAL_TEST_PREPARED *reply;
107 size_t msg_length;
108
109 msg_length = sizeof(struct GNUNET_CMDS_LOCAL_TEST_PREPARED);
110 reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_TEST_PREPARED);
111 reply->header.type = htons (
112 GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED);
113 reply->header.size = htons ((uint16_t) msg_length);
114 lfs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length);
115}
116
117
118/**
119 * Create command.
120 *
121 * @param label name for command.
122 * @param write_message Callback to write messages to the master loop.
123 * @param all_local_tests_prepared Flag which will be set from outside.
124 * @return command.
125 */
126struct GNUNET_TESTING_Command
127GNUNET_TESTING_cmd_local_test_prepared (const char *label,
128 TESTING_CMD_HELPER_write_cb
129 write_message)
130{
131 struct LocalPreparedState *lfs;
132
133 lfs = GNUNET_new (struct LocalPreparedState);
134 lfs->write_message = write_message;
135
136 struct GNUNET_TESTING_Command cmd = {
137 .cls = lfs,
138 .label = label,
139 .run = &local_test_prepared_run,
140 .ac = &lfs->ac,
141 .cleanup = &local_test_prepared_cleanup,
142 .traits = &local_test_prepared_traits
143 };
144
145 return cmd;
146}