GNUnet  0.19.5
testing_api_cmd_local_test_prepared.c
Go to the documentation of this file.
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 
26 #include "platform.h"
27 #include "gnunet_util_lib.h"
28 #include "gnunet_testing_ng_lib.h"
29 #include "gnunet_testing_plugin.h"
30 #include "gnunet_testing_barrier.h"
32 #include "testing_cmds.h"
33 
37 #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
38 
39 
46  const void **ret,
47  const char *trait,
48  unsigned int index)
49 {
50  struct LocalPreparedState *lfs = cls;
51  struct GNUNET_TESTING_Trait traits[] = {
54  };
55  return GNUNET_TESTING_get_trait (traits,
56  ret,
57  trait,
58  index);
59 }
60 
61 
66 static void
68 {
69  struct LocalPreparedState *lfs = cls;
70 
71  GNUNET_free (lfs);
72 }
73 
74 
79 static void
82 {
83  struct GNUNET_TESTING_LocalPreparedState *lfs = cls;
84 
86  size_t msg_length;
87 
88  msg_length = sizeof(struct GNUNET_TESTING_CommandLocalTestPrepared);
90  reply->header.type = htons (
92  reply->header.size = htons ((uint16_t) msg_length);
93  lfs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length);
94 }
95 
96 
101 {
103 
106 
107  return GNUNET_TESTING_command_new (lfs, label,
111  &lfs->ac);
112 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_TESTING_Interpreter * is
static int write_message(uint16_t message_type, const char *data, size_t data_length)
Write message to the master process.
API to manage barriers.
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_local_prepared_state(const struct GNUNET_TESTING_LocalPreparedState *value)
struct GNUNET_TESTING_Command GNUNET_TESTING_command_new(void *cls, const char *label, GNUNET_TESTING_CommandRunRoutine run, GNUNET_TESTING_CommandCleanupRoutine cleanup, GNUNET_TESTING_CommandGetTraits traits, struct GNUNET_TESTING_AsyncContext *ac)
Create a new command.
struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end(void)
"end" trait.
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait(const struct GNUNET_TESTING_Trait *traits, const void **ret, const char *trait, unsigned int index)
Extract a trait.
void(* GNUNET_TESTING_cmd_helper_write_cb)(struct GNUNET_MessageHeader *message, size_t msg_length)
Callback function to write messages from the helper process running on a netjail node to the master p...
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED
Header for all communications.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED.
Definition: testing_cmds.h:100
A command to be run by the interpreter.
char label[127+1]
Label for the command.
Global state of the interpreter, used by a command to access information about other commands.
Struct to hold information for callbacks.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
GNUNET_TESTING_cmd_helper_write_cb write_message
Callback to write messages to the master loop.
A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.
unsigned int index
Index number associated with the trait.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_local_test_prepared(const char *label, GNUNET_TESTING_cmd_helper_write_cb write_message)
This command sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TESTS_PREPARED message to the master loop.
static void local_test_prepared_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TESTS_PREPARED message to the master loop...
enum GNUNET_GenericReturnValue local_test_prepared_traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.
static void local_test_prepared_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.
Message formats for communication between testing cmds helper and testcase plugins.