diff options
Diffstat (limited to 'src/lib/testing/testing_api_cmds.c')
-rw-r--r-- | src/lib/testing/testing_api_cmds.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/src/lib/testing/testing_api_cmds.c b/src/lib/testing/testing_api_cmds.c new file mode 100644 index 000000000..31d35f6c4 --- /dev/null +++ b/src/lib/testing/testing_api_cmds.c | |||
@@ -0,0 +1,92 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | Copyright (C) 2021-2024 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/testing_api_loop.c | ||
23 | * @brief main interpreter loop for testcases | ||
24 | * @author Christian Grothoff (GNU Taler testing) | ||
25 | * @author Marcello Stanisci (GNU Taler testing) | ||
26 | * @author t3sserakt | ||
27 | */ | ||
28 | #include "platform.h" | ||
29 | #include "gnunet_util_lib.h" | ||
30 | #include "gnunet_testing_lib.h" | ||
31 | |||
32 | |||
33 | struct GNUNET_TESTING_Command | ||
34 | GNUNET_TESTING_command_new_ac ( | ||
35 | void *cls, | ||
36 | const char *label, | ||
37 | GNUNET_TESTING_CommandRunRoutine run, | ||
38 | GNUNET_TESTING_CommandCleanupRoutine cleanup, | ||
39 | GNUNET_TESTING_CommandGetTraits traits, | ||
40 | struct GNUNET_TESTING_AsyncContext *ac) | ||
41 | { | ||
42 | struct GNUNET_TESTING_Command cmd = { | ||
43 | .cls = cls, | ||
44 | .run = run, | ||
45 | .ac = ac, | ||
46 | .cleanup = cleanup, | ||
47 | .traits = traits | ||
48 | }; | ||
49 | |||
50 | GNUNET_assert (NULL != run); | ||
51 | if (NULL != label) | ||
52 | GNUNET_TESTING_set_label (&cmd.label, | ||
53 | label); | ||
54 | return cmd; | ||
55 | } | ||
56 | |||
57 | |||
58 | void | ||
59 | GNUNET_TESTING_set_label ( | ||
60 | struct GNUNET_TESTING_CommandLabel *label, | ||
61 | const char *value) | ||
62 | { | ||
63 | size_t len; | ||
64 | |||
65 | len = strlen (value); | ||
66 | GNUNET_assert (len <= | ||
67 | GNUNET_TESTING_CMD_MAX_LABEL_LENGTH); | ||
68 | memcpy (label->value, | ||
69 | value, | ||
70 | len + 1); | ||
71 | } | ||
72 | |||
73 | |||
74 | struct GNUNET_TESTING_Command | ||
75 | GNUNET_TESTING_cmd_set_var ( | ||
76 | const char *name, | ||
77 | struct GNUNET_TESTING_Command cmd) | ||
78 | { | ||
79 | cmd.name = name; | ||
80 | return cmd; | ||
81 | } | ||
82 | |||
83 | |||
84 | struct GNUNET_TESTING_Command | ||
85 | GNUNET_TESTING_cmd_end (void) | ||
86 | { | ||
87 | struct GNUNET_TESTING_Command cmd = { | ||
88 | .run = NULL | ||
89 | }; | ||
90 | |||
91 | return cmd; | ||
92 | } | ||