diff options
author | t3sserakt <t3ss@posteo.de> | 2021-07-16 21:05:11 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-07-16 21:05:11 +0200 |
commit | 33830e71f8e80334e0c8cf5527b1f2b20804485e (patch) | |
tree | be8bb3af17046a3e7c77ca6f11639c24e938211d /src/testing/testing_api_cmd_system_create.c | |
parent | 71f230fbb6f270f6b501934acadb6f57026c353d (diff) | |
download | gnunet-33830e71f8e80334e0c8cf5527b1f2b20804485e.tar.gz gnunet-33830e71f8e80334e0c8cf5527b1f2b20804485e.zip |
- started to implement several cmds to start peers^Ctestcase plugin will be started directly from helper, functionality to communicate between master cmd loop and local cmd loop, code compiles, test is not working atm.
Diffstat (limited to 'src/testing/testing_api_cmd_system_create.c')
-rw-r--r-- | src/testing/testing_api_cmd_system_create.c | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/src/testing/testing_api_cmd_system_create.c b/src/testing/testing_api_cmd_system_create.c new file mode 100644 index 000000000..ad0aa4f90 --- /dev/null +++ b/src/testing/testing_api_cmd_system_create.c | |||
@@ -0,0 +1,110 @@ | |||
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 | |||
30 | struct TestSystemState | ||
31 | { | ||
32 | struct GNUNET_TESTING_System *test_system; | ||
33 | }; | ||
34 | |||
35 | |||
36 | static void | ||
37 | system_create_run (void *cls, | ||
38 | const struct GNUNET_TESTING_Command *cmd, | ||
39 | struct GNUNET_TESTING_Interpreter *is) | ||
40 | { | ||
41 | struct TestSystemState *tss = cls; | ||
42 | |||
43 | tss->test_system = GNUNET_TESTING_system_create (tss->testdir, | ||
44 | NULL, | ||
45 | NULL, | ||
46 | NULL); | ||
47 | } | ||
48 | |||
49 | static int | ||
50 | system_create_traits (void *cls, | ||
51 | const void **ret, | ||
52 | const char *trait, | ||
53 | unsigned int index) | ||
54 | { | ||
55 | struct TestSystemState *tss = cls; | ||
56 | struct GNUNET_TESTING_System *test_system = tss->test_system; | ||
57 | |||
58 | struct GNUNET_TESTING_Trait traits[] = { | ||
59 | { | ||
60 | .index = 0, | ||
61 | .trait_name = "test_system", | ||
62 | .ptr = (const void *) test_system, | ||
63 | }, | ||
64 | GNUNET_TESTING_trait_end () | ||
65 | }; | ||
66 | |||
67 | return GNUNET_TESTING_get_trait (traits, | ||
68 | ret, | ||
69 | trait, | ||
70 | index); | ||
71 | } | ||
72 | |||
73 | |||
74 | int | ||
75 | GNUNET_TESTING_get_trait_test_system (const struct | ||
76 | GNUNET_TESTING_Command *cmd, | ||
77 | struct GNUNET_TESTING_System **test_system) | ||
78 | { | ||
79 | return cmd->traits (cmd->cls, | ||
80 | (const void **) test_system, | ||
81 | "test_system", | ||
82 | (unsigned int) 0); | ||
83 | } | ||
84 | |||
85 | |||
86 | /** | ||
87 | * Create command. | ||
88 | * | ||
89 | * @param label name for command. | ||
90 | * @return command. | ||
91 | */ | ||
92 | struct GNUNET_TESTING_Command | ||
93 | GNUNET_TESTING_cmd_system_create (const char *label, | ||
94 | const char *testdir) | ||
95 | { | ||
96 | struct TestSystemState *tss; | ||
97 | |||
98 | tss = GNUNET_new (struct TestSystemState); | ||
99 | tss->testdir = testdir; | ||
100 | |||
101 | struct GNUNET_TESTING_Command cmd = { | ||
102 | .cls = tss, | ||
103 | .label = label, | ||
104 | .run = &system_create_run, | ||
105 | .cleanup = &system_create_cleanup, | ||
106 | .traits = &system_create_traits | ||
107 | }; | ||
108 | |||
109 | return cmd; | ||
110 | } | ||