aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-05-19 22:36:34 +0200
committerChristian Grothoff <christian@grothoff.org>2024-05-19 22:36:34 +0200
commit6cee76d4891df988b764568b87c28eac87325b02 (patch)
treeedffd2ae36ce28f57abbaab059a16bd877394f41
parente21e50a0ca8fa23d6d0c22e539dd398cfe96b1f8 (diff)
downloadgnunet-6cee76d4891df988b764568b87c28eac87325b02.tar.gz
gnunet-6cee76d4891df988b764568b87c28eac87325b02.zip
add gnunet-testing-netjail-launcher.c
-rw-r--r--src/lib/testing/.gitignore1
-rw-r--r--src/lib/testing/Makefile.am12
-rw-r--r--src/lib/testing/gnunet-testing-netjail-launcher.c83
3 files changed, 95 insertions, 1 deletions
diff --git a/src/lib/testing/.gitignore b/src/lib/testing/.gitignore
index 2ec414afd..2e66a9259 100644
--- a/src/lib/testing/.gitignore
+++ b/src/lib/testing/.gitignore
@@ -8,3 +8,4 @@ test_testing_servicestartup
8test_testing_sharedservices 8test_testing_sharedservices
9gnunet-cmds-helper 9gnunet-cmds-helper
10test_testing_api 10test_testing_api
11gnunet-testing-netjail-launcher
diff --git a/src/lib/testing/Makefile.am b/src/lib/testing/Makefile.am
index 7acdf709d..fa4be886d 100644
--- a/src/lib/testing/Makefile.am
+++ b/src/lib/testing/Makefile.am
@@ -21,7 +21,7 @@ gnunet_cmds_helper_SOURCES = \
21gnunet_cmds_helper_LDADD = $(XLIB) \ 21gnunet_cmds_helper_LDADD = $(XLIB) \
22 libgnunettesting.la \ 22 libgnunettesting.la \
23 $(top_builddir)/src/lib/util/libgnunetutil.la \ 23 $(top_builddir)/src/lib/util/libgnunetutil.la \
24 $(LTLIBINTL) $(Z_LIBS) 24 $(LTLIBINTL)
25 25
26libgnunettesting_la_SOURCES = \ 26libgnunettesting_la_SOURCES = \
27 testing_api_barrier.c testing_api_barrier.h \ 27 testing_api_barrier.c testing_api_barrier.h \
@@ -50,6 +50,16 @@ libgnunettesting_la_LDFLAGS = \
50AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH; 50AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;
51 51
52 52
53bin_PROGRAMS = \
54 gnunet-testing-netjail-launcher
55
56gnunet_testing_netjail_launcher_SOURCES = \
57 gnunet-testing-netjail-launcher.c
58gnunet_testing_netjail_launcher_LDADD = $(XLIB) \
59 libgnunettesting.la \
60 $(top_builddir)/src/lib/util/libgnunetutil.la \
61 $(LTLIBINTL)
62
53check_PROGRAMS = \ 63check_PROGRAMS = \
54 test_testing_api 64 test_testing_api
55 65
diff --git a/src/lib/testing/gnunet-testing-netjail-launcher.c b/src/lib/testing/gnunet-testing-netjail-launcher.c
new file mode 100644
index 000000000..4a2d4f725
--- /dev/null
+++ b/src/lib/testing/gnunet-testing-netjail-launcher.c
@@ -0,0 +1,83 @@
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/gnunet-testing-netjail-launcher.c
23 * @brief Generic program to start testcases in an configurable topology.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_testing_lib.h"
28#include "gnunet_util_lib.h"
29
30#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600)
31
32int
33main (int argc,
34 char *const *argv)
35{
36 char *filename = NULL;
37 char *topology_data = NULL;
38
39 GNUNET_log_setup ("test-netjail",
40 "INFO",
41 NULL);
42 if (NULL == argv[1])
43 {
44 GNUNET_break (0);
45 return EXIT_FAILURE;
46 }
47 if (0 == strcmp ("-s", argv[1]))
48 {
49 topology_data = argv[2];
50 if (NULL == topology_data)
51 {
52 GNUNET_break (0);
53 return EXIT_FAILURE;
54 }
55 }
56 else
57 {
58 filename = argv[1];
59 }
60 {
61 struct GNUNET_TESTING_Command commands[] = {
62 NULL == filename
63 ? GNUNET_TESTING_cmd_load_topology_from_string (
64 "load-topology",
65 topology_data)
66 : GNUNET_TESTING_cmd_load_topology_from_file (
67 "load-topology",
68 filename),
69 GNUNET_TESTING_cmd_netjail_setup (
70 "netjail-start",
71 GNUNET_TESTING_NETJAIL_START_SCRIPT,
72 "load-topology"),
73 GNUNET_TESTING_cmd_netjail_start_helpers (
74 "netjail-start-testbed",
75 "load-topology",
76 TIMEOUT),
77 GNUNET_TESTING_cmd_end ()
78 };
79
80 return GNUNET_TESTING_main (commands,
81 TIMEOUT);
82 }
83}