diff options
Diffstat (limited to 'src/testing/testing_api_cmd_local_test_finished.c')
-rw-r--r-- | src/testing/testing_api_cmd_local_test_finished.c | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/src/testing/testing_api_cmd_local_test_finished.c b/src/testing/testing_api_cmd_local_test_finished.c deleted file mode 100644 index 709c6b62f..000000000 --- a/src/testing/testing_api_cmd_local_test_finished.c +++ /dev/null | |||
@@ -1,120 +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_finished.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 | * Struct to hold information for callbacks. | ||
40 | * | ||
41 | */ | ||
42 | struct LocalFinishedState | ||
43 | { | ||
44 | |||
45 | /** | ||
46 | * Callback to write messages to the master loop. | ||
47 | * | ||
48 | */ | ||
49 | TESTING_CMD_HELPER_write_cb write_message; | ||
50 | |||
51 | /** | ||
52 | * The message send back to the master loop. | ||
53 | * | ||
54 | */ | ||
55 | struct GNUNET_CMDS_LOCAL_FINISHED *reply; | ||
56 | }; | ||
57 | |||
58 | |||
59 | /** | ||
60 | * The cleanup function of this cmd frees resources the cmd allocated. | ||
61 | * | ||
62 | */ | ||
63 | static void | ||
64 | local_test_finished_cleanup (void *cls) | ||
65 | { | ||
66 | struct LocalFinishedState *lfs = cls; | ||
67 | |||
68 | GNUNET_free (lfs); | ||
69 | } | ||
70 | |||
71 | |||
72 | /** | ||
73 | * This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED message to the master loop. | ||
74 | * | ||
75 | */ | ||
76 | static void | ||
77 | local_test_finished_run (void *cls, | ||
78 | struct GNUNET_TESTING_Interpreter *is) | ||
79 | { | ||
80 | struct LocalFinishedState *lfs = cls; | ||
81 | struct GNUNET_CMDS_LOCAL_FINISHED *reply; | ||
82 | size_t msg_length; | ||
83 | |||
84 | msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED); | ||
85 | reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED); | ||
86 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED); | ||
87 | reply->header.size = htons ((uint16_t) msg_length); | ||
88 | lfs->reply = reply; | ||
89 | lfs->write_message ((struct GNUNET_MessageHeader *) reply, | ||
90 | msg_length); | ||
91 | } | ||
92 | |||
93 | |||
94 | /** | ||
95 | * Create command. | ||
96 | * | ||
97 | * @param label name for command. | ||
98 | * @param write_message Callback to write messages to the master loop. | ||
99 | * @return command. | ||
100 | */ | ||
101 | struct GNUNET_TESTING_Command | ||
102 | GNUNET_TESTING_cmd_local_test_finished ( | ||
103 | const char *label, | ||
104 | TESTING_CMD_HELPER_write_cb write_message) | ||
105 | { | ||
106 | struct LocalFinishedState *lfs; | ||
107 | |||
108 | lfs = GNUNET_new (struct LocalFinishedState); | ||
109 | lfs->write_message = write_message; | ||
110 | { | ||
111 | struct GNUNET_TESTING_Command cmd = { | ||
112 | .cls = lfs, | ||
113 | .label = label, | ||
114 | .run = &local_test_finished_run, | ||
115 | .cleanup = &local_test_finished_cleanup, | ||
116 | }; | ||
117 | |||
118 | return cmd; | ||
119 | } | ||
120 | } | ||