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.c123
1 files changed, 0 insertions, 123 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 1f470a6c1..000000000
--- a/src/testing/testing_api_cmd_local_test_prepared.c
+++ /dev/null
@@ -1,123 +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 GNUNET_TESTING_make_trait_local_prepared_state ((const void *) lfs),
51 GNUNET_TESTING_trait_end ()
52 };
53 return GNUNET_TESTING_get_trait (traits,
54 ret,
55 trait,
56 index);
57}
58
59
60/**
61 * The cleanup function of this cmd frees resources the cmd allocated.
62 *
63 */
64static void
65local_test_prepared_cleanup (void *cls)
66{
67 struct LocalPreparedState *lfs = cls;
68
69 GNUNET_free (lfs);
70}
71
72
73/**
74 * This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TESTS_PREPARED message to the master loop.
75 *
76 */
77static void
78local_test_prepared_run (void *cls,
79 struct GNUNET_TESTING_Interpreter *is)
80{
81 struct LocalPreparedState *lfs = cls;
82
83 struct GNUNET_CMDS_LOCAL_TEST_PREPARED *reply;
84 size_t msg_length;
85
86 msg_length = sizeof(struct GNUNET_CMDS_LOCAL_TEST_PREPARED);
87 reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_TEST_PREPARED);
88 reply->header.type = htons (
89 GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED);
90 reply->header.size = htons ((uint16_t) msg_length);
91 lfs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length);
92}
93
94
95/**
96 * Create command.
97 *
98 * @param label name for command.
99 * @param write_message Callback to write messages to the master loop.
100 * @param all_local_tests_prepared Flag which will be set from outside.
101 * @return command.
102 */
103struct GNUNET_TESTING_Command
104GNUNET_TESTING_cmd_local_test_prepared (const char *label,
105 TESTING_CMD_HELPER_write_cb
106 write_message)
107{
108 struct LocalPreparedState *lfs;
109
110 lfs = GNUNET_new (struct LocalPreparedState);
111 lfs->write_message = write_message;
112
113 struct GNUNET_TESTING_Command cmd = {
114 .cls = lfs,
115 .label = label,
116 .run = &local_test_prepared_run,
117 .ac = &lfs->ac,
118 .cleanup = &local_test_prepared_cleanup,
119 .traits = &local_test_prepared_traits
120 };
121
122 return cmd;
123}