GNUnet  0.11.x
testing_api_cmd_system_create.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"
30 #include "gnunet_testing_lib.h"
31 
37 {
39 
40  const char *testdir;
41 };
42 
43 
48 static void
49 system_create_run (void *cls,
51 {
52  struct TestSystemState *tss = cls;
53 
55  "system create\n");
56 
58  NULL,
59  NULL,
60  NULL);
62  "system created\n");
63 }
64 
65 
70 static int
72  const void **ret,
73  const char *trait,
74  unsigned int index)
75 {
76  struct TestSystemState *tss = cls;
78 
79  struct GNUNET_TESTING_Trait traits[] = {
82  };
83 
84  return GNUNET_TESTING_get_trait (traits,
85  ret,
86  trait,
87  index);
88 }
89 
90 
95 static void
97 {
98  struct TestSystemState *tss = cls;
99 
100  GNUNET_free (tss);
101 }
102 
103 
113  const char *testdir)
114 {
115  struct TestSystemState *tss;
116 
117  tss = GNUNET_new (struct TestSystemState);
118  tss->testdir = testdir;
119 
120  struct GNUNET_TESTING_Command cmd = {
121  .cls = tss,
122  .label = label,
123  .run = &system_create_run,
124  .cleanup = &system_create_cleanup,
125  .traits = &system_create_traits
126  };
127 
128  return cmd;
129 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static struct GNUNET_NT_InterfaceScanner * is
Network scanner to determine network types.
static struct GNUNET_TESTING_System * test_system
Handle to the testing system.
#define GNUNET_log(kind,...)
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_test_system(const struct GNUNET_TESTING_System *value)
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.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_TESTING_System * GNUNET_TESTING_system_create(const char *testdir, const char *trusted_ip, const char *hostname, const struct GNUNET_TESTING_SharedService *shared_services)
Create a system handle.
Definition: testing.c:458
A command to be run by the interpreter.
const char * label
Label for the command.
void * cls
Closure for all commands with command-specific context information.
Global state of the interpreter, used by a command to access information about other commands.
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths a...
Definition: testing.c:103
unsigned int index
Index number associated with the trait.
Struct to hold information for callbacks.
struct GNUNET_TESTING_System * test_system
static void system_create_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will setup a test environment for a node.
static int system_create_traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_system_create(const char *label, const char *testdir)
Create command.
static void system_create_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.