diff options
author | t3sserakt <t3ss@posteo.de> | 2021-07-19 19:53:56 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-07-19 19:53:56 +0200 |
commit | 9d7ff3c3fbee189367da05a1517777c76a80b23b (patch) | |
tree | 176adc853f033261c03e01fa57840c30806d4ad7 /src/testing | |
parent | 33830e71f8e80334e0c8cf5527b1f2b20804485e (diff) | |
download | gnunet-9d7ff3c3fbee189367da05a1517777c76a80b23b.tar.gz gnunet-9d7ff3c3fbee189367da05a1517777c76a80b23b.zip |
- finished first prototype for running several local testcase.
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/testing_api_cmd_send_peer_ready.c | 104 | ||||
-rw-r--r-- | src/testing/testing_api_loop.c | 4 |
2 files changed, 106 insertions, 2 deletions
diff --git a/src/testing/testing_api_cmd_send_peer_ready.c b/src/testing/testing_api_cmd_send_peer_ready.c new file mode 100644 index 000000000..27761c4d5 --- /dev/null +++ b/src/testing/testing_api_cmd_send_peer_ready.c | |||
@@ -0,0 +1,104 @@ | |||
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_send_peer_ready.c | ||
23 | * @brief cmd to send a helper message if peer is ready. | ||
24 | * @author t3sserakt | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testing_ng_lib.h" | ||
29 | #include "testbed_api.h" | ||
30 | #include "testbed_helper.h" | ||
31 | |||
32 | |||
33 | struct SendPeerReadyState | ||
34 | { | ||
35 | TESTBED_CMD_HELPER_write_cb write_message; | ||
36 | |||
37 | struct GNUNET_CMDS_PEER_STARTED *reply; | ||
38 | }; | ||
39 | |||
40 | |||
41 | static int | ||
42 | send_peer_ready_traits (void *cls, | ||
43 | const void **ret, | ||
44 | const char *trait, | ||
45 | unsigned int index) | ||
46 | { | ||
47 | return GNUNET_OK; | ||
48 | } | ||
49 | |||
50 | |||
51 | static void | ||
52 | send_peer_ready_cleanup (void *cls, | ||
53 | const struct GNUNET_TESTING_Command *cmd) | ||
54 | { | ||
55 | struct SendPeerReadyState *sprs = cls; | ||
56 | |||
57 | GNUNET_free (sprs->reply); | ||
58 | GNUNET_free (sprs); | ||
59 | } | ||
60 | |||
61 | |||
62 | static void | ||
63 | send_peer_ready_run (void *cls, | ||
64 | const struct GNUNET_TESTING_Command *cmd, | ||
65 | struct GNUNET_TESTING_Interpreter *is) | ||
66 | { | ||
67 | struct SendPeerReadyState *sprs = cls; | ||
68 | struct GNUNET_CMDS_PEER_STARTED *reply; | ||
69 | size_t msg_length; | ||
70 | |||
71 | msg_length = sizeof(struct GNUNET_CMDS_HelperInit);// GNUNET_CMDS_PEER_STARTED); | ||
72 | reply = GNUNET_new (struct GNUNET_CMDS_PEER_STARTED); | ||
73 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED); | ||
74 | reply->header.size = htons ((uint16_t) msg_length); | ||
75 | sprs->reply = reply; | ||
76 | sprs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length); | ||
77 | } | ||
78 | |||
79 | |||
80 | /** | ||
81 | * Create command. | ||
82 | * | ||
83 | * @param label name for command. | ||
84 | * @return command. | ||
85 | */ | ||
86 | struct GNUNET_TESTING_Command | ||
87 | GNUNET_TESTING_cmd_send_peer_ready (const char *label, | ||
88 | TESTBED_CMD_HELPER_write_cb write_message) | ||
89 | { | ||
90 | struct SendPeerReadyState *sprs; | ||
91 | |||
92 | sprs = GNUNET_new (struct SendPeerReadyState); | ||
93 | sprs->write_message = write_message; | ||
94 | |||
95 | struct GNUNET_TESTING_Command cmd = { | ||
96 | .cls = sprs, | ||
97 | .label = label, | ||
98 | .run = &send_peer_ready_run, | ||
99 | .cleanup = &send_peer_ready_cleanup, | ||
100 | .traits = &send_peer_ready_traits | ||
101 | }; | ||
102 | |||
103 | return cmd; | ||
104 | } | ||
diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c index 7b7dc010a..f4fa4e17e 100644 --- a/src/testing/testing_api_loop.c +++ b/src/testing/testing_api_loop.c | |||
@@ -415,7 +415,7 @@ interpreter_run (void *cls) | |||
415 | if (NULL == cmd->label) | 415 | if (NULL == cmd->label) |
416 | { | 416 | { |
417 | 417 | ||
418 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 418 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
419 | "Running command END %p\n", | 419 | "Running command END %p\n", |
420 | is); | 420 | is); |
421 | is->result = GNUNET_OK; | 421 | is->result = GNUNET_OK; |
@@ -424,7 +424,7 @@ interpreter_run (void *cls) | |||
424 | } | 424 | } |
425 | else if (NULL != cmd) | 425 | else if (NULL != cmd) |
426 | { | 426 | { |
427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 427 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
428 | "Running command `%s' %p\n", | 428 | "Running command `%s' %p\n", |
429 | cmd->label, | 429 | cmd->label, |
430 | is); | 430 | is); |