aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_system_create.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_system_create.c')
-rw-r--r--src/testing/testing_api_cmd_system_create.c151
1 files changed, 0 insertions, 151 deletions
diff --git a/src/testing/testing_api_cmd_system_create.c b/src/testing/testing_api_cmd_system_create.c
deleted file mode 100644
index 275132684..000000000
--- a/src/testing/testing_api_cmd_system_create.c
+++ /dev/null
@@ -1,151 +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_system_create.c
23 * @brief cmd to create a testing system handle.
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 "gnunet_testing_lib.h"
31
32/**
33 * Struct to hold information for callbacks.
34 *
35 */
36struct TestSystemState
37{
38 struct GNUNET_TESTING_System *test_system;
39
40 const char *testdir;
41};
42
43
44/**
45 * The run method of this cmd will setup a test environment for a node.
46 *
47 */
48static void
49system_create_run (void *cls,
50 struct GNUNET_TESTING_Interpreter *is)
51{
52 struct TestSystemState *tss = cls;
53
54 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
55 "system create\n");
56
57 tss->test_system = GNUNET_TESTING_system_create (tss->testdir,
58 NULL,
59 NULL,
60 NULL);
61 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
62 "system created\n");
63}
64
65
66/**
67 * This function prepares an array with traits.
68 *
69 */
70static int
71system_create_traits (void *cls,
72 const void **ret,
73 const char *trait,
74 unsigned int index)
75{
76 struct TestSystemState *tss = cls;
77 struct GNUNET_TESTING_System *test_system = tss->test_system;
78
79 struct GNUNET_TESTING_Trait traits[] = {
80 {
81 .index = 0,
82 .trait_name = "test_system",
83 .ptr = (const void *) test_system,
84 },
85 GNUNET_TESTING_trait_end ()
86 };
87
88 return GNUNET_TESTING_get_trait (traits,
89 ret,
90 trait,
91 index);
92}
93
94
95/**
96 * Function to get the trait with struct GNUNET_TESTING_System
97 *
98 * @param[out] test_system The struct GNUNET_TESTING_System.
99 * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
100 */
101int
102GNUNET_TESTING_get_trait_test_system (const struct
103 GNUNET_TESTING_Command *cmd,
104 struct GNUNET_TESTING_System **test_system)
105{
106 return cmd->traits (cmd->cls,
107 (const void **) test_system,
108 "test_system",
109 (unsigned int) 0);
110}
111
112
113/**
114 * The cleanup function of this cmd frees resources the cmd allocated.
115 *
116 */
117static void
118system_create_cleanup (void *cls)
119{
120 struct TestSystemState *tss = cls;
121
122 GNUNET_free (tss);
123}
124
125
126/**
127 * Create command.
128 *
129 * @param label name for command.
130 * @param label name for the test environment directory.
131 * @return command.
132 */
133struct GNUNET_TESTING_Command
134GNUNET_TESTING_cmd_system_create (const char *label,
135 const char *testdir)
136{
137 struct TestSystemState *tss;
138
139 tss = GNUNET_new (struct TestSystemState);
140 tss->testdir = testdir;
141
142 struct GNUNET_TESTING_Command cmd = {
143 .cls = tss,
144 .label = label,
145 .run = &system_create_run,
146 .cleanup = &system_create_cleanup,
147 .traits = &system_create_traits
148 };
149
150 return cmd;
151}