diff options
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/Makefile.am | 43 | ||||
-rw-r--r-- | src/testing/Makefile.in | 126 | ||||
-rw-r--r-- | src/testing/gnunet-testing.c | 2 | ||||
-rw-r--r-- | src/testing/test_testing_2dtorus.c | 2 | ||||
-rw-r--r-- | src/testing/test_testing_2dtorus.conf | 6 | ||||
-rw-r--r-- | src/testing/test_testing_data_topology_2d_torus.conf | 3 | ||||
-rw-r--r-- | src/testing/test_testing_defaults.conf | 6 | ||||
-rw-r--r-- | src/testing/test_testing_group_remote.c | 2 | ||||
-rw-r--r-- | src/testing/test_testing_new_peerstartup.c | 161 | ||||
-rw-r--r-- | src/testing/test_testing_new_portreservation.c | 90 | ||||
-rw-r--r-- | src/testing/test_testing_new_servicestartup.c | 110 | ||||
-rw-r--r-- | src/testing/test_testing_topology.c | 105 | ||||
-rw-r--r-- | src/testing/test_testing_topology_blacklist.c | 2 | ||||
-rw-r--r-- | src/testing/test_testing_topology_churn.c | 28 | ||||
-rw-r--r-- | src/testing/testing.c | 235 | ||||
-rw-r--r-- | src/testing/testing_group.c | 354 | ||||
-rw-r--r-- | src/testing/testing_new.c | 1000 | ||||
-rw-r--r-- | src/testing/testing_peergroup.c | 72 |
18 files changed, 1818 insertions, 529 deletions
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am index 050691d..572c033 100644 --- a/src/testing/Makefile.am +++ b/src/testing/Makefile.am @@ -21,7 +21,7 @@ if HAVE_EXPENSIVE_TESTS test_testing_topology_clique_minimum \ test_testing_topology_clique_dfs \ test_testing_topology_churn \ - test_testing_topology_line + test_testing_topology_line \ test_testing_topology_blacklist \ test_testing_group_remote \ test_testing_topology_ring \ @@ -33,7 +33,9 @@ if HAVE_EXPENSIVE_TESTS test_testing_topology_scale_free endif -lib_LTLIBRARIES = libgnunettesting.la +lib_LTLIBRARIES = \ + libgnunettesting.la \ + libgnunettesting_new.la libgnunettesting_la_SOURCES = \ helper.c \ @@ -51,6 +53,16 @@ libgnunettesting_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) \ -version-info 0:1:0 + +libgnunettesting_new_la_SOURCES = \ + testing_new.c +libgnunettesting_new_la_LIBADD = \ + $(top_builddir)/src/util/libgnunetutil.la +libgnunettesting_new_la_LDFLAGS = \ + $(GN_LIB_LDFLAGS) \ + -version-info 0:1:0 + + bin_PROGRAMS = \ gnunet-testing @@ -77,7 +89,10 @@ check_PROGRAMS = \ test_testing_topology_erdos_renyi \ test_testing_topology_internat \ test_testing_topology_none \ - test_testing_topology_scale_free + test_testing_topology_scale_free \ + test_testing_new_portreservation \ + test_testing_new_peerstartup \ + test_testing_new_servicestartup if ENABLE_TEST_RUN TESTS = \ @@ -86,8 +101,9 @@ TESTS = \ test_testing_reconnect \ test_testing_group \ test_testing_peergroup \ - test_testing_topology_clique \ - test_testing_2dtorus + test_testing_new_portreservation \ + test_testing_new_peerstartup \ + test_testing_new_servicestartup endif gnunet_testing_SOURCES = \ @@ -253,6 +269,23 @@ test_testing_topology_none_LDADD = \ $(top_builddir)/src/core/libgnunetcore.la \ $(top_builddir)/src/util/libgnunetutil.la +test_testing_new_portreservation_SOURCES = \ + test_testing_new_portreservation.c +test_testing_new_portreservation_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting_new.la \ + $(top_builddir)/src/util/libgnunetutil.la + +test_testing_new_peerstartup_SOURCES = \ + test_testing_new_peerstartup.c +test_testing_new_peerstartup_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting_new.la \ + $(top_builddir)/src/util/libgnunetutil.la + +test_testing_new_servicestartup_SOURCES = \ + test_testing_new_servicestartup.c +test_testing_new_servicestartup_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting_new.la \ + $(top_builddir)/src/util/libgnunetutil.la EXTRA_DIST = \ test_testing_defaults.conf \ diff --git a/src/testing/Makefile.in b/src/testing/Makefile.in index 544d98d..459066f 100644 --- a/src/testing/Makefile.in +++ b/src/testing/Makefile.in @@ -58,14 +58,18 @@ check_PROGRAMS = test_testing$(EXEEXT) test_testing_connect$(EXEEXT) \ test_testing_topology_erdos_renyi$(EXEEXT) \ test_testing_topology_internat$(EXEEXT) \ test_testing_topology_none$(EXEEXT) \ - test_testing_topology_scale_free$(EXEEXT) + test_testing_topology_scale_free$(EXEEXT) \ + test_testing_new_portreservation$(EXEEXT) \ + test_testing_new_peerstartup$(EXEEXT) \ + test_testing_new_servicestartup$(EXEEXT) @ENABLE_TEST_RUN_TRUE@TESTS = test_testing$(EXEEXT) \ @ENABLE_TEST_RUN_TRUE@ test_testing_connect$(EXEEXT) \ @ENABLE_TEST_RUN_TRUE@ test_testing_reconnect$(EXEEXT) \ @ENABLE_TEST_RUN_TRUE@ test_testing_group$(EXEEXT) \ @ENABLE_TEST_RUN_TRUE@ test_testing_peergroup$(EXEEXT) \ -@ENABLE_TEST_RUN_TRUE@ test_testing_topology_clique$(EXEEXT) \ -@ENABLE_TEST_RUN_TRUE@ test_testing_2dtorus$(EXEEXT) +@ENABLE_TEST_RUN_TRUE@ test_testing_new_portreservation$(EXEEXT) \ +@ENABLE_TEST_RUN_TRUE@ test_testing_new_peerstartup$(EXEEXT) \ +@ENABLE_TEST_RUN_TRUE@ test_testing_new_servicestartup$(EXEEXT) subdir = src/testing DIST_COMMON = $(dist_pkgcfg_DATA) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in @@ -129,6 +133,15 @@ libgnunettesting_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(libgnunettesting_la_LDFLAGS) \ $(LDFLAGS) -o $@ +libgnunettesting_new_la_DEPENDENCIES = \ + $(top_builddir)/src/util/libgnunetutil.la +am_libgnunettesting_new_la_OBJECTS = testing_new.lo +libgnunettesting_new_la_OBJECTS = \ + $(am_libgnunettesting_new_la_OBJECTS) +libgnunettesting_new_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(AM_CFLAGS) $(CFLAGS) $(libgnunettesting_new_la_LDFLAGS) \ + $(LDFLAGS) -o $@ PROGRAMS = $(bin_PROGRAMS) am_gnunet_testing_OBJECTS = gnunet-testing.$(OBJEXT) gnunet_testing_OBJECTS = $(am_gnunet_testing_OBJECTS) @@ -159,6 +172,27 @@ test_testing_group_remote_OBJECTS = \ test_testing_group_remote_DEPENDENCIES = \ $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/util/libgnunetutil.la +am_test_testing_new_peerstartup_OBJECTS = \ + test_testing_new_peerstartup.$(OBJEXT) +test_testing_new_peerstartup_OBJECTS = \ + $(am_test_testing_new_peerstartup_OBJECTS) +test_testing_new_peerstartup_DEPENDENCIES = \ + $(top_builddir)/src/testing/libgnunettesting_new.la \ + $(top_builddir)/src/util/libgnunetutil.la +am_test_testing_new_portreservation_OBJECTS = \ + test_testing_new_portreservation.$(OBJEXT) +test_testing_new_portreservation_OBJECTS = \ + $(am_test_testing_new_portreservation_OBJECTS) +test_testing_new_portreservation_DEPENDENCIES = \ + $(top_builddir)/src/testing/libgnunettesting_new.la \ + $(top_builddir)/src/util/libgnunetutil.la +am_test_testing_new_servicestartup_OBJECTS = \ + test_testing_new_servicestartup.$(OBJEXT) +test_testing_new_servicestartup_OBJECTS = \ + $(am_test_testing_new_servicestartup_OBJECTS) +test_testing_new_servicestartup_DEPENDENCIES = \ + $(top_builddir)/src/testing/libgnunettesting_new.la \ + $(top_builddir)/src/util/libgnunetutil.la am_test_testing_peergroup_OBJECTS = test_testing_peergroup.$(OBJEXT) test_testing_peergroup_OBJECTS = $(am_test_testing_peergroup_OBJECTS) test_testing_peergroup_DEPENDENCIES = \ @@ -321,10 +355,14 @@ am__v_CCLD_0 = @echo " CCLD " $@; AM_V_GEN = $(am__v_GEN_$(V)) am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) am__v_GEN_0 = @echo " GEN " $@; -SOURCES = $(libgnunettesting_la_SOURCES) $(gnunet_testing_SOURCES) \ +SOURCES = $(libgnunettesting_la_SOURCES) \ + $(libgnunettesting_new_la_SOURCES) $(gnunet_testing_SOURCES) \ $(test_testing_SOURCES) $(test_testing_2dtorus_SOURCES) \ $(test_testing_connect_SOURCES) $(test_testing_group_SOURCES) \ $(test_testing_group_remote_SOURCES) \ + $(test_testing_new_peerstartup_SOURCES) \ + $(test_testing_new_portreservation_SOURCES) \ + $(test_testing_new_servicestartup_SOURCES) \ $(test_testing_peergroup_SOURCES) \ $(test_testing_reconnect_SOURCES) \ $(test_testing_topology_2d_torus_SOURCES) \ @@ -344,10 +382,13 @@ SOURCES = $(libgnunettesting_la_SOURCES) $(gnunet_testing_SOURCES) \ $(test_testing_topology_small_world_torus_SOURCES) \ $(test_testing_topology_stability_SOURCES) DIST_SOURCES = $(libgnunettesting_la_SOURCES) \ - $(gnunet_testing_SOURCES) $(test_testing_SOURCES) \ - $(test_testing_2dtorus_SOURCES) \ + $(libgnunettesting_new_la_SOURCES) $(gnunet_testing_SOURCES) \ + $(test_testing_SOURCES) $(test_testing_2dtorus_SOURCES) \ $(test_testing_connect_SOURCES) $(test_testing_group_SOURCES) \ $(test_testing_group_remote_SOURCES) \ + $(test_testing_new_peerstartup_SOURCES) \ + $(test_testing_new_portreservation_SOURCES) \ + $(test_testing_new_servicestartup_SOURCES) \ $(test_testing_peergroup_SOURCES) \ $(test_testing_reconnect_SOURCES) \ $(test_testing_topology_2d_torus_SOURCES) \ @@ -427,6 +468,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTLLIBS = @INTLLIBS@ INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +JAVAPORT = @JAVAPORT@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ @@ -460,6 +502,7 @@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ +MONKEYPREFIX = @MONKEYPREFIX@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ @@ -590,9 +633,21 @@ dist_pkgcfg_DATA = \ @HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_clique_minimum \ @HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_clique_dfs \ @HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_churn \ -@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_line +@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_line \ +@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_blacklist \ +@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_group_remote \ +@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_ring \ +@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_2d_torus \ +@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_small_world_ring \ +@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_small_world_torus \ +@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_erdos_renyi \ +@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_internat \ +@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_scale_free + +lib_LTLIBRARIES = \ + libgnunettesting.la \ + libgnunettesting_new.la -lib_LTLIBRARIES = libgnunettesting.la libgnunettesting_la_SOURCES = \ helper.c \ testing.c \ @@ -611,6 +666,16 @@ libgnunettesting_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) \ -version-info 0:1:0 +libgnunettesting_new_la_SOURCES = \ + testing_new.c + +libgnunettesting_new_la_LIBADD = \ + $(top_builddir)/src/util/libgnunetutil.la + +libgnunettesting_new_la_LDFLAGS = \ + $(GN_LIB_LDFLAGS) \ + -version-info 0:1:0 + gnunet_testing_SOURCES = \ gnunet-testing.c @@ -797,6 +862,27 @@ test_testing_topology_none_LDADD = \ $(top_builddir)/src/core/libgnunetcore.la \ $(top_builddir)/src/util/libgnunetutil.la +test_testing_new_portreservation_SOURCES = \ + test_testing_new_portreservation.c + +test_testing_new_portreservation_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting_new.la \ + $(top_builddir)/src/util/libgnunetutil.la + +test_testing_new_peerstartup_SOURCES = \ + test_testing_new_peerstartup.c + +test_testing_new_peerstartup_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting_new.la \ + $(top_builddir)/src/util/libgnunetutil.la + +test_testing_new_servicestartup_SOURCES = \ + test_testing_new_servicestartup.c + +test_testing_new_servicestartup_LDADD = \ + $(top_builddir)/src/testing/libgnunettesting_new.la \ + $(top_builddir)/src/util/libgnunetutil.la + EXTRA_DIST = \ test_testing_defaults.conf \ test_testing_data.conf \ @@ -888,6 +974,8 @@ clean-libLTLIBRARIES: done libgnunettesting.la: $(libgnunettesting_la_OBJECTS) $(libgnunettesting_la_DEPENDENCIES) $(AM_V_CCLD)$(libgnunettesting_la_LINK) -rpath $(libdir) $(libgnunettesting_la_OBJECTS) $(libgnunettesting_la_LIBADD) $(LIBS) +libgnunettesting_new.la: $(libgnunettesting_new_la_OBJECTS) $(libgnunettesting_new_la_DEPENDENCIES) + $(AM_V_CCLD)$(libgnunettesting_new_la_LINK) -rpath $(libdir) $(libgnunettesting_new_la_OBJECTS) $(libgnunettesting_new_la_LIBADD) $(LIBS) install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @@ -958,6 +1046,15 @@ test_testing_group$(EXEEXT): $(test_testing_group_OBJECTS) $(test_testing_group_ test_testing_group_remote$(EXEEXT): $(test_testing_group_remote_OBJECTS) $(test_testing_group_remote_DEPENDENCIES) @rm -f test_testing_group_remote$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_testing_group_remote_OBJECTS) $(test_testing_group_remote_LDADD) $(LIBS) +test_testing_new_peerstartup$(EXEEXT): $(test_testing_new_peerstartup_OBJECTS) $(test_testing_new_peerstartup_DEPENDENCIES) + @rm -f test_testing_new_peerstartup$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_testing_new_peerstartup_OBJECTS) $(test_testing_new_peerstartup_LDADD) $(LIBS) +test_testing_new_portreservation$(EXEEXT): $(test_testing_new_portreservation_OBJECTS) $(test_testing_new_portreservation_DEPENDENCIES) + @rm -f test_testing_new_portreservation$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_testing_new_portreservation_OBJECTS) $(test_testing_new_portreservation_LDADD) $(LIBS) +test_testing_new_servicestartup$(EXEEXT): $(test_testing_new_servicestartup_OBJECTS) $(test_testing_new_servicestartup_DEPENDENCIES) + @rm -f test_testing_new_servicestartup$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_testing_new_servicestartup_OBJECTS) $(test_testing_new_servicestartup_LDADD) $(LIBS) test_testing_peergroup$(EXEEXT): $(test_testing_peergroup_OBJECTS) $(test_testing_peergroup_DEPENDENCIES) @rm -f test_testing_peergroup$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_testing_peergroup_OBJECTS) $(test_testing_peergroup_LDADD) $(LIBS) @@ -1026,6 +1123,9 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_testing_connect.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_testing_group.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_testing_group_remote.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_testing_new_peerstartup.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_testing_new_portreservation.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_testing_new_servicestartup.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_testing_peergroup.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_testing_reconnect.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_testing_topology.Po@am__quote@ @@ -1033,6 +1133,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_testing_topology_churn.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testing.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testing_group.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testing_new.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testing_peergroup.Plo@am__quote@ .c.o: @@ -1386,15 +1487,6 @@ uninstall-am: uninstall-binPROGRAMS uninstall-dist_pkgcfgDATA \ tags uninstall uninstall-am uninstall-binPROGRAMS \ uninstall-dist_pkgcfgDATA uninstall-libLTLIBRARIES -@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_blacklist \ -@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_group_remote \ -@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_ring \ -@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_2d_torus \ -@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_small_world_ring \ -@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_small_world_torus \ -@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_erdos_renyi \ -@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_internat \ -@HAVE_EXPENSIVE_TESTS_TRUE@ test_testing_topology_scale_free # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/src/testing/gnunet-testing.c b/src/testing/gnunet-testing.c index 0caa28e..bdbb5e8 100644 --- a/src/testing/gnunet-testing.c +++ b/src/testing/gnunet-testing.c @@ -170,7 +170,7 @@ create_hostkeys (const unsigned int no) return 1; } - if (GNUNET_YES != GNUNET_DISK_file_size (hostkey_src_file, &fs, GNUNET_YES)) + if (GNUNET_OK != GNUNET_DISK_file_size (hostkey_src_file, &fs, GNUNET_YES, GNUNET_YES)) fs = 0; if (0 != (fs % HOSTKEYFILESIZE)) diff --git a/src/testing/test_testing_2dtorus.c b/src/testing/test_testing_2dtorus.c index 7b109bc..00a66d6 100644 --- a/src/testing/test_testing_2dtorus.c +++ b/src/testing/test_testing_2dtorus.c @@ -317,7 +317,7 @@ run (void *cls, char *const *args, const char *cfgfile, hosts); GNUNET_assert (pg != NULL); shutdown_handle = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (), + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); } diff --git a/src/testing/test_testing_2dtorus.conf b/src/testing/test_testing_2dtorus.conf index ba1db3a..54bb7c5 100644 --- a/src/testing/test_testing_2dtorus.conf +++ b/src/testing/test_testing_2dtorus.conf @@ -1,6 +1,7 @@ +@INLINE@ test_testing_defaults.conf [PATHS] -SERVICEHOME = /tmp/test_testing_small/ -DEFAULTCONFIG = test_testing_small.conf +SERVICEHOME = /tmp/test_testing_2dtorus/ +DEFAULTCONFIG = test_testing_2dtorus.conf [arm] PORT = 10010 @@ -29,6 +30,7 @@ PORT = 10011 [transport] PORT = 10002 AUTOSTART = YES +PLUGINS = tcp [nat] DISABLEV6 = YES diff --git a/src/testing/test_testing_data_topology_2d_torus.conf b/src/testing/test_testing_data_topology_2d_torus.conf index 45fd690..cbdaceb 100644 --- a/src/testing/test_testing_data_topology_2d_torus.conf +++ b/src/testing/test_testing_data_topology_2d_torus.conf @@ -1,8 +1,7 @@ @INLINE@ test_testing_defaults.conf [PATHS] -DEFAULTCONFIG = test_testing_data_topology_clique.conf +DEFAULTCONFIG = test_testing_data_topology_2d_torus.conf [TESTING] NUM_PEERS = 13 TOPOLOGY = 2D_TORUS - diff --git a/src/testing/test_testing_defaults.conf b/src/testing/test_testing_defaults.conf index 7b6c4c4..ba7e269 100644 --- a/src/testing/test_testing_defaults.conf +++ b/src/testing/test_testing_defaults.conf @@ -70,3 +70,9 @@ AUTOSTART = NO [gns] AUTOSTART = NO + +[namestore] +AUTOSTART = NO + +[lockmanager] +AUTOSTART = NO diff --git a/src/testing/test_testing_group_remote.c b/src/testing/test_testing_group_remote.c index e300f95..b06655c 100644 --- a/src/testing/test_testing_group_remote.c +++ b/src/testing/test_testing_group_remote.c @@ -171,7 +171,7 @@ run (void *cls, char *const *args, const char *cfgfile, data[count] = '\0'; temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host)); ret = - sscanf (buf, "%a[a-zA-Z0-9]@%a[a-zA-Z0-9.]:%hd", + SSCANF (buf, "%a[a-zA-Z0-9]@%a[a-zA-Z0-9.]:%hd", &temphost->username, &temphost->hostname, &temphost->port); if (3 == ret) { diff --git a/src/testing/test_testing_new_peerstartup.c b/src/testing/test_testing_new_peerstartup.c new file mode 100644 index 0000000..203df2f --- /dev/null +++ b/src/testing/test_testing_new_peerstartup.c @@ -0,0 +1,161 @@ +/* + This file is part of GNUnet + (C) 2008, 2009, 2012 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +/** + * @file testing/test_testing_new_peerstartup.c + * @brief test case for testing peer startup and shutdown using new testing + * library + * @author Sree Harsha Totakura + */ + +#include "platform.h" +#include "gnunet_configuration_lib.h" +#include "gnunet_os_lib.h" +#include "gnunet_testing_lib-new.h" + +#define LOG(kind,...) \ + GNUNET_log (kind, __VA_ARGS__) + +#define TIME_REL_SEC(sec) \ + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec) + +/** + * The testing context + */ +struct TestingContext +{ + /** + * The testing system + */ + struct GNUNET_TESTING_System *system; + + /** + * The peer which has been started by the testing system + */ + struct GNUNET_TESTING_Peer *peer; + + /** + * The running configuration of the peer + */ + struct GNUNET_CONFIGURATION_Handle *cfg; +}; + + +/** + * Task for shutdown + * + * @param cls the testing context + * @param tc the tast context + */ +static void +do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + struct TestingContext *test_ctx = cls; + + GNUNET_assert (GNUNET_OK == GNUNET_TESTING_peer_stop (test_ctx->peer)); + GNUNET_TESTING_peer_destroy (test_ctx->peer); + GNUNET_CONFIGURATION_destroy (test_ctx->cfg); + GNUNET_TESTING_hostkeys_unload (test_ctx->system); + GNUNET_TESTING_system_destroy (test_ctx->system, GNUNET_YES); + GNUNET_free (test_ctx); +} + + +/** + * Main point of test execution + */ +static void +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) +{ + struct GNUNET_TESTING_System *system; + struct GNUNET_TESTING_Peer *peer; + struct GNUNET_CONFIGURATION_Handle *new_cfg; + struct TestingContext *test_ctx; + char *data_dir; + char *hostkeys_file; + char *emsg; + char *_tmpdir; + char *tmpdir; +#ifdef MINGW + char *tmpdir_w; +#endif + + struct GNUNET_PeerIdentity id; + + _tmpdir = getenv ("TMP"); + if (NULL == _tmpdir) + _tmpdir = getenv ("TEMP"); + if (NULL == _tmpdir) + _tmpdir = getenv ("TMPDIR"); + if (NULL == _tmpdir) + _tmpdir = "/tmp"; + GNUNET_asprintf (&tmpdir, "%s/%s", _tmpdir, "test-gnunet-testing_new-XXXXXX"); +#ifdef MINGW + tmpdir_w = GNUNET_malloc (MAX_PATH + 1); + GNUNET_assert (ERROR_SUCCESS == plibc_conv_to_win_path (tmpdir, tmpdir_w)); + GNUNET_free (tmpdir); + tmpdir = tmpdir_w; + //GNUNET_assert (0 == _mktemp_s (tmpdir, strlen (tmpdir) + 1)); +#else + GNUNET_assert (mkdtemp (tmpdir) == tmpdir); +#endif + /* LOG (GNUNET_ERROR_TYPE_ERROR, */ + /* "Temporary directory: %s\n", tmpdir); */ + system = GNUNET_TESTING_system_create (tmpdir, + "localhost"); + GNUNET_assert (NULL != system); + GNUNET_free (tmpdir); + data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); + GNUNET_asprintf (&hostkeys_file, "%s/testing_hostkeys.dat", data_dir); + GNUNET_free (data_dir); + GNUNET_assert (GNUNET_OK == + GNUNET_TESTING_hostkeys_load (system, hostkeys_file)); + GNUNET_free (hostkeys_file); + new_cfg = GNUNET_CONFIGURATION_dup (cfg); + emsg = NULL; + peer = GNUNET_TESTING_peer_configure (system, new_cfg, 0, &id, &emsg); + GNUNET_assert (NULL != peer); + GNUNET_assert (NULL == emsg); + GNUNET_assert (GNUNET_OK == GNUNET_TESTING_peer_start (peer)); + test_ctx = GNUNET_malloc (sizeof (struct TestingContext)); + test_ctx->system = system; + test_ctx->peer = peer; + test_ctx->cfg = new_cfg; + GNUNET_SCHEDULER_add_delayed (TIME_REL_SEC (5), + &do_shutdown, test_ctx); + +} + + +int main (int argc, char *argv[]) +{ + struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_END + }; + + if (GNUNET_OK != + GNUNET_PROGRAM_run (argc, argv, + "test_testing_new_peerstartup", + "test case for peerstartup using new testing library", + options, &run, NULL)) + return 1; + return 0; +} diff --git a/src/testing/test_testing_new_portreservation.c b/src/testing/test_testing_new_portreservation.c new file mode 100644 index 0000000..4010944 --- /dev/null +++ b/src/testing/test_testing_new_portreservation.c @@ -0,0 +1,90 @@ +/* + This file is part of GNUnet + (C) 2008, 2009, 2012 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +/** + * @file testing/test_testing_new_portreservation.c + * @brief test case for testing port reservation routines from the new testing + * library API + * @author Sree Harsha Totakura + */ + +#include "platform.h" +#include "gnunet_util_lib.h" +#include "gnunet_testing_lib-new.h" + +#define LOG(kind,...) \ + GNUNET_log (kind, __VA_ARGS__) + +/** + * Main point of test execution + */ +static void +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) +{ + struct GNUNET_TESTING_System *system; + uint16_t new_port1; + uint16_t new_port2; + uint16_t old_port1; + + system = GNUNET_TESTING_system_create ("/tmp/gnunet-testing-new", + "localhost"); + GNUNET_assert (NULL != system); + new_port1 = GNUNET_TESTING_reserve_port (system, GNUNET_YES); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Reserved TCP port %u\n", new_port1); + GNUNET_assert (0 != new_port1); + new_port2 = GNUNET_TESTING_reserve_port (system, GNUNET_YES); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Reserved TCP port %u\n", new_port2); + GNUNET_assert (0 != new_port2); + GNUNET_assert (new_port1 != new_port2); + GNUNET_TESTING_release_port (system, GNUNET_YES, new_port1); + old_port1 = new_port1; + new_port1 = 0; + new_port1 = GNUNET_TESTING_reserve_port (system, GNUNET_YES); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Reserved TCP port %u\n", new_port1); + GNUNET_assert (0 != new_port1); + GNUNET_assert (old_port1 == new_port1); + GNUNET_TESTING_release_port (system, GNUNET_YES, new_port1); + GNUNET_TESTING_release_port (system, GNUNET_YES, new_port2); + GNUNET_TESTING_system_destroy (system, GNUNET_NO); +} + +int main (int argc, char *argv[]) +{ + struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_END + }; + if (GNUNET_OK != + GNUNET_PROGRAM_run (argc, + argv, + "test_testing_new_portreservation", + "test case for testing port reservation routines" + " from the new testing library API", + options, + &run, + NULL)) + { + return 1; + } + return 0; +} diff --git a/src/testing/test_testing_new_servicestartup.c b/src/testing/test_testing_new_servicestartup.c new file mode 100644 index 0000000..3b98688 --- /dev/null +++ b/src/testing/test_testing_new_servicestartup.c @@ -0,0 +1,110 @@ +/* + This file is part of GNUnet + (C) 2008, 2009, 2012 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +/** + * @file testing/test_testing_new_servicestartup.c + * @brief test case for testing service startup using new testing API + * @author Sree Harsha Totakura + */ + +#include "platform.h" +#include "gnunet_testing_lib-new.h" + + +#define LOG(kind,...) \ + GNUNET_log (kind, __VA_ARGS__) + +#define TIME_REL_SEC(sec) \ + GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec) + +/** + * Global test status + */ +static int test_success; + +/** + * The shutdown task. Used to signal that testing is done and service has to be + * stopped + * + * @param cls NULL + */ +static void +shutdown_task(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + test_success = GNUNET_YES; + GNUNET_SCHEDULER_shutdown (); +} + + +/** + * The testing callback function + * + * @param cls NULL + * @param cfg the configuration with which the current testing service is run + */ +static void +test_run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) +{ + GNUNET_assert (NULL == cls); + GNUNET_assert (NULL != cfg); + LOG (GNUNET_ERROR_TYPE_DEBUG, "Service arm started successfully\n"); + GNUNET_SCHEDULER_add_delayed (TIME_REL_SEC (3), &shutdown_task, NULL); +} + + +/** + * The main point of execution + */ +int main (int argc, char *argv[]) +{ + char *_tmpdir; + char *tmpdir; +#ifdef MINGW + char *tmpdir_w; +#endif + + GNUNET_log_setup ("test_testing_new_servicestartup", "DEBUG", NULL); + _tmpdir = getenv ("TMP"); + if (NULL == _tmpdir) + _tmpdir = getenv ("TEMP"); + if (NULL == _tmpdir) + _tmpdir = getenv ("TMPDIR"); + if (NULL == _tmpdir) + _tmpdir = "/tmp"; + GNUNET_asprintf (&tmpdir, "%s/%s", _tmpdir, "test-gnunet-testing_new-XXXXXX"); +#ifdef MINGW + tmpdir_w = GNUNET_malloc (MAX_PATH + 1); + GNUNET_assert (ERROR_SUCCESS == plibc_conv_to_win_path (tmpdir, tmpdir_w)); + GNUNET_free (tmpdir); + tmpdir = tmpdir_w; + //GNUNET_assert (0 == _mktemp_s (tmpdir, strlen (tmpdir) + 1)); +#else + GNUNET_assert (mkdtemp (tmpdir) == tmpdir); +#endif + + test_success = GNUNET_NO; + GNUNET_assert (0 == GNUNET_TESTING_service_run (tmpdir, + "arm", + "test_testing_defaults.conf", + &test_run, + NULL)); + GNUNET_free (tmpdir); + return (GNUNET_YES == test_success) ? 0 : 1; +} diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index ba5e237..b216544 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c @@ -26,7 +26,6 @@ #include "gnunet_core_service.h" #include "gnunet_os_lib.h" -#define VERBOSE GNUNET_NO #define PROGRESS_BARS GNUNET_YES @@ -167,25 +166,23 @@ static struct TestMessageContext *test_messages; /** * Check whether peers successfully shut down. */ -void +static void shutdown_callback (void *cls, const char *emsg) { if (emsg != NULL) { -#if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n"); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Shutdown of peers failed: %s!\n", + emsg); if (ok == 0) ok = 666; } else { -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers successfully shut down!\n"); -#endif } } + #if DELAY_FOR_LOGGING static void gather_log_data () @@ -200,12 +197,12 @@ gather_log_data () GNUNET_OS_start_process (NULL, NULL, "./memsize.pl", "memsize.pl", "totals.txt", peer_number, connect_number, NULL); GNUNET_OS_process_wait (mem_process); - GNUNET_OS_process_close (mem_process); + GNUNET_OS_process_destroy (mem_process); mem_process = NULL; } - #endif + static void finish_testing () { @@ -213,11 +210,8 @@ finish_testing () struct TestMessageContext *pos; struct TestMessageContext *free_pos; -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called finish testing, stopping daemons.\n"); -#endif - pos = test_messages; while (pos != NULL) { @@ -239,16 +233,11 @@ finish_testing () } GNUNET_free (free_pos); } -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", transmit_ready_scheduled, transmit_ready_failed, transmit_ready_called); -#endif - -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling daemons_stop\n"); -#endif GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); if (dotOutFile != NULL) @@ -256,7 +245,6 @@ finish_testing () FPRINTF (dotOutFile, "%s", "}"); FCLOSE (dotOutFile); } - ok = 0; } @@ -267,21 +255,20 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) struct TestMessageContext *pos = cls; /* Disconnect from the respective cores */ -#if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 1 `%4s'\n", GNUNET_i2s (&pos->peer1->id)); -#endif if (pos->peer1handle != NULL) + { GNUNET_CORE_disconnect (pos->peer1handle); -#if VERBOSE > 1 + pos->peer1handle = NULL; + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 2 `%4s'\n", GNUNET_i2s (&pos->peer2->id)); -#endif if (pos->peer2handle != NULL) + { GNUNET_CORE_disconnect (pos->peer2handle); - /* Set handles to NULL so test case can be ended properly */ - pos->peer1handle = NULL; - pos->peer2handle = NULL; + pos->peer2handle = NULL; + } pos->disconnect_task = GNUNET_SCHEDULER_NO_TASK; /* Decrement total connections so new can be established */ total_server_connections -= 2; @@ -316,6 +303,7 @@ stats_print (void *cls, const struct GNUNET_PeerIdentity *peer, } #endif + static void topology_cb (void *cls, const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second, const char *emsg) @@ -348,6 +336,7 @@ topology_cb (void *cls, const struct GNUNET_PeerIdentity *first, } } + static int process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message, @@ -382,14 +371,12 @@ process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, total_messages_received++; -#if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received message from `%4s', type %d.\n", GNUNET_i2s (peer), ntohs (message->type)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Total messages received %d, expected %d.\n", total_messages_received, expected_messages); -#endif if (total_messages_received == expected_messages) { @@ -416,13 +403,14 @@ process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, return GNUNET_OK; } + static void end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { char *msg = cls; - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "End badly was called (%s)... stopping daemons.\n", msg); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Ending with error: %s\n", msg); struct TestMessageContext *pos; struct TestMessageContext *free_pos; @@ -444,7 +432,6 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_free (free_pos); } -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", transmit_ready_scheduled, transmit_ready_failed, @@ -452,7 +439,6 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Total messages received %d, expected %d.\n", total_messages_received, expected_messages); -#endif if (pg != NULL) { @@ -469,6 +455,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } } + static size_t transmit_ready (void *cls, size_t size, void *buf) { @@ -481,12 +468,10 @@ transmit_ready (void *cls, size_t size, void *buf) m->header.size = htons (sizeof (struct GNUNET_TestMessage)); m->uid = htonl (pos->uid); transmit_ready_called++; -#if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "transmit ready for peer %s\ntransmit_ready's scheduled %d, transmit_ready's called %d\n", GNUNET_i2s (&pos->peer1->id), transmit_ready_scheduled, transmit_ready_called); -#endif return sizeof (struct GNUNET_TestMessage); } @@ -495,11 +480,13 @@ static struct GNUNET_CORE_MessageHandler no_handlers[] = { {NULL, 0, 0} }; + static struct GNUNET_CORE_MessageHandler handlers[] = { {&process_mtype, MTYPE, sizeof (struct GNUNET_TestMessage)}, {NULL, 0, 0} }; + static void init_notify_peer2 (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity) @@ -511,12 +498,10 @@ init_notify_peer2 (void *cls, struct GNUNET_CORE_Handle *server, pos->peer2connected = GNUNET_YES; if (pos->peer1notified == GNUNET_YES) /* Peer 1 has been notified of connection to peer 2 */ { -#if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n", GNUNET_i2s (my_identity), GNUNET_h2s (&pos->peer1->id.hashPubKey)); -#endif if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, GNUNET_YES, 0, TIMEOUT, &pos->peer2->id, @@ -535,6 +520,7 @@ init_notify_peer2 (void *cls, struct GNUNET_CORE_Handle *server, } } + /** * Method called whenever a given peer connects. * @@ -553,23 +539,19 @@ connect_notify_peers (void *cls, const struct GNUNET_PeerIdentity *peer, if (0 == memcmp (peer, &pos->peer2->id, sizeof (struct GNUNET_PeerIdentity))) { pos->peer1notified = GNUNET_YES; -#if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer `%s' notified of connection to peer `%s'\n", GNUNET_i2s (&pos->peer1->id), GNUNET_h2s (&peer->hashPubKey)); -#endif } else return; if (pos->peer2connected == GNUNET_YES) /* Already connected and notified of connection, send message! */ { -#if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n", GNUNET_i2s (&pos->peer2->id), GNUNET_h2s (&pos->peer1->id.hashPubKey)); -#endif if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, GNUNET_YES, 0, TIMEOUT, &pos->peer2->id, @@ -588,6 +570,7 @@ connect_notify_peers (void *cls, const struct GNUNET_PeerIdentity *peer, } } + static void init_notify_peer1 (void *cls, struct GNUNET_CORE_Handle *server, const struct GNUNET_PeerIdentity *my_identity) @@ -595,13 +578,9 @@ init_notify_peer1 (void *cls, struct GNUNET_CORE_Handle *server, struct TestMessageContext *pos = cls; total_server_connections++; - -#if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Core connection to `%4s' established, setting up handles\n", GNUNET_i2s (my_identity)); -#endif - /* * Connect to the receiving peer */ @@ -663,7 +642,7 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } -void +static void topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, const struct GNUNET_PeerIdentity *second, uint32_t distance, const struct GNUNET_CONFIGURATION_Handle *first_cfg, @@ -694,10 +673,8 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, fflush (stdout); #endif total_connections++; -#if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "connected peer %s to peer %s\n", first_daemon->shortname, second_daemon->shortname); -#endif temp_context = GNUNET_malloc (sizeof (struct TestMessageContext)); temp_context->peer1 = first_daemon; temp_context->peer2 = second_daemon; @@ -711,26 +688,22 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, FPRINTF (dotOutFile, "\tn%s -- n%s;\n", first_daemon->shortname, second_daemon->shortname); } -#if VERBOSE else { failed_connections++; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to connect peer %s to peer %s with error :\n%s\n", first_daemon->shortname, second_daemon->shortname, emsg); } -#endif if (total_connections == expected_connections) { #if PROGRESS_BARS FPRINTF (stdout, "%s", "100%%]\n"); #endif -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created %d total connections, which is our target number! Calling send messages.\n", total_connections); -#endif modnum = expected_messages / 4; dotnum = (expected_messages / 50) + 1; if (modnum == 0) @@ -777,26 +750,24 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, } else { -#if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d total connections, %d failed connections, Want %d (at least %d)\n", total_connections, failed_connections, expected_connections, expected_connections - (unsigned int) (fail_percentage * expected_connections)); -#endif } } + static void topology_creation_finished (void *cls, const char *emsg) { -#if VERBOSE if (emsg == NULL) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All topology connections created successfully!\n"); -#endif } + static void connect_topology () { @@ -810,7 +781,7 @@ connect_topology () connect_timeout, connect_attempts, &topology_creation_finished, NULL); #if PROGRESS_BARS - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %d expected connections\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d expected connections\n", expected_connections); #endif } @@ -884,10 +855,8 @@ peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, return; } GNUNET_assert (id != NULL); -#if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n", (num_peers - peers_left) + 1, num_peers); -#endif #if PROGRESS_BARS if ((num_peers - peers_left) % modnum == 0) { @@ -910,10 +879,8 @@ peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, #if PROGRESS_BARS FPRINTF (stdout, "%s", "100%%]\n"); #endif -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %d daemons started, now connecting peers!\n", num_peers); -#endif GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ @@ -952,12 +919,9 @@ hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, "Hostkey callback received error: %s\n", emsg); } -#if VERBOSE > 1 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hostkey (%d/%d) created for peer `%s'\n", num_peers - peers_left, num_peers, GNUNET_i2s (id)); -#endif - #if PROGRESS_BARS if ((num_peers - peers_left) % modnum == 0) { @@ -993,6 +957,7 @@ hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, } } + static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -1012,11 +977,8 @@ run (void *cls, char *const *args, const char *cfgfile, FPRINTF (dotOutFile, "%s", "strict graph G {\n"); } -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons based on config file %s\n", cfgfile); -#endif - if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome", &test_directory)) @@ -1069,7 +1031,7 @@ run (void *cls, char *const *args, const char *cfgfile, "connect_topology_option_modifier", &connect_topology_option_modifier_string)) { - if (sscanf + if (SSCANF (connect_topology_option_modifier_string, "%lf", &connect_topology_option_modifier) != 1) { @@ -1178,6 +1140,7 @@ run (void *cls, char *const *args, const char *cfgfile, } + static int check () { @@ -1192,9 +1155,6 @@ check () char *const argv[] = { binary_name, "-c", config_file_name, -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { @@ -1214,6 +1174,7 @@ check () return ok; } + int main (int argc, char *argv[]) { @@ -1238,11 +1199,7 @@ main (int argc, char *argv[]) GNUNET_asprintf (&dotOutFileName, "topology_%s.dot", topology_string); GNUNET_log_setup (our_binary_name, -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); ret = check (); GNUNET_free (topology_string); diff --git a/src/testing/test_testing_topology_blacklist.c b/src/testing/test_testing_topology_blacklist.c index ad39f7d..c90f48d 100644 --- a/src/testing/test_testing_topology_blacklist.c +++ b/src/testing/test_testing_topology_blacklist.c @@ -440,7 +440,7 @@ run (void *cls, char *const *args, const char *cfgfile, "connect_topology_option_modifier", &connect_topology_option_modifier_string)) { - if (sscanf + if (SSCANF (connect_topology_option_modifier_string, "%lf", &connect_topology_option_modifier) != 1) { diff --git a/src/testing/test_testing_topology_churn.c b/src/testing/test_testing_topology_churn.c index 3612089..9c0bbf2 100644 --- a/src/testing/test_testing_topology_churn.c +++ b/src/testing/test_testing_topology_churn.c @@ -25,7 +25,6 @@ #include "gnunet_testing_lib.h" #include "gnunet_core_service.h" -#define VERBOSE GNUNET_YES /** * How long until we fail the whole testcase? @@ -83,17 +82,13 @@ shutdown_callback (void *cls, const char *emsg) { if (emsg != NULL) { -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n"); -#endif if (ok == 0) ok = 666; } else { -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers successfully shut down!\n"); -#endif } } @@ -104,20 +99,11 @@ finish_testing () if (die_task != GNUNET_SCHEDULER_NO_TASK) GNUNET_SCHEDULER_cancel (die_task); - -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called finish testing, stopping daemons.\n"); -#endif - -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling daemons_stop\n"); -#endif GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "daemons_stop finished\n"); -#endif - ok = 0; } @@ -212,17 +198,13 @@ peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, return; } GNUNET_assert (id != NULL); -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n", (num_peers - peers_left) + 1, num_peers); -#endif peers_left--; if (peers_left == 0) { -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %d daemons started, now testing churn!\n", num_peers); -#endif GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ @@ -242,11 +224,8 @@ run (void *cls, char *const *args, const char *cfgfile, { ok = 1; -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons based on config file %s\n", cfgfile); -#endif - if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome", &test_directory)) @@ -295,9 +274,6 @@ check () char *const argv[] = { "test-testing-topology-churn", "-c", "test_testing_data_topology_churn.conf", -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { @@ -323,11 +299,7 @@ main (int argc, char *argv[]) int ret; GNUNET_log_setup ("test_testing_topology_churn", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); ret = check (); diff --git a/src/testing/testing.c b/src/testing/testing.c index 16cee90..31bea06 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -37,10 +37,6 @@ #include "gnunet_transport_service.h" #include "gnunet_hello_lib.h" -#define DEBUG_TESTING GNUNET_EXTRA_LOGGING - -#define DEBUG_TESTING_RECONNECT GNUNET_EXTRA_LOGGING - /** * Hack to deal with initial HELLO's being often devoid of addresses. * This hack causes 'process_hello' to ignore HELLOs without addresses. @@ -192,7 +188,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { case SP_COPYING: /* confirm copying complete */ - if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code)) + if (GNUNET_OK != GNUNET_OS_process_status (d->proc_arm_copying, &type, &code)) { if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0) { @@ -218,7 +214,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) cb (d->cb_cls, NULL, d->cfg, d, _("`scp' did not complete cleanly.\n")); return; } - GNUNET_OS_process_close (d->proc); + GNUNET_OS_process_destroy (d->proc_arm_copying); + d->proc_arm_copying = NULL; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully copied configuration file.\n"); d->phase = SP_COPIED; @@ -227,6 +224,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) /* Start create hostkey process if we don't already know the peer identity! */ if (GNUNET_NO == d->have_hostkey) { + GNUNET_assert (NULL == d->proc_arm_peerinfo); d->pipe_stdout = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO, GNUNET_YES); if (d->pipe_stdout == NULL) { @@ -246,7 +244,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) "Starting `%s', with command `%s %s %s %s'.\n", "gnunet-peerinfo", "gnunet-peerinfo", "-c", d->cfgfile, "-sq"); - d->proc = + d->proc_arm_peerinfo = GNUNET_OS_start_process (GNUNET_YES, NULL, d->pipe_stdout, "gnunet-peerinfo", "gnunet-peerinfo", "-c", d->cfgfile, "-sq", NULL); @@ -265,28 +263,24 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) d->cfgfile, "-sq"); if (d->ssh_port_str == NULL) { - d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, d->pipe_stdout, "ssh", "ssh", -#if !DEBUG_TESTING + d->proc_arm_peerinfo = GNUNET_OS_start_process (GNUNET_NO, NULL, d->pipe_stdout, "ssh", "ssh", "-q", -#endif dst, "gnunet-peerinfo", "-c", d->cfgfile, "-sq", NULL); } else { - d->proc = + d->proc_arm_peerinfo = GNUNET_OS_start_process (GNUNET_NO, NULL, d->pipe_stdout, "ssh", "ssh", "-p", d->ssh_port_str, -#if !DEBUG_TESTING "-q", -#endif dst, "gnunet-peerinfo", "-c", d->cfgfile, "-sq", NULL); } GNUNET_DISK_pipe_close_end (d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE); GNUNET_free (dst); } - if (NULL == d->proc) + if (NULL == d->proc_arm_peerinfo) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not start `%s' process to create hostkey.\n"), @@ -366,10 +360,10 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) d->cb = NULL; GNUNET_DISK_pipe_close (d->pipe_stdout); d->pipe_stdout = NULL; - (void) GNUNET_OS_process_kill (d->proc, SIGKILL); - GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->proc)); - GNUNET_OS_process_close (d->proc); - d->proc = NULL; + (void) GNUNET_OS_process_kill (d->proc_arm_peerinfo, SIGKILL); + GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->proc_arm_peerinfo)); + GNUNET_OS_process_destroy (d->proc_arm_peerinfo); + d->proc_arm_peerinfo = NULL; if (NULL != cb) cb (d->cb_cls, NULL, d->cfg, d, _("Failed to get hostkey!\n")); return; @@ -377,10 +371,10 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) d->shortname = GNUNET_strdup (GNUNET_i2s (&d->id)); GNUNET_DISK_pipe_close (d->pipe_stdout); d->pipe_stdout = NULL; - (void) GNUNET_OS_process_kill (d->proc, SIGKILL); - GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->proc)); - GNUNET_OS_process_close (d->proc); - d->proc = NULL; + (void) GNUNET_OS_process_kill (d->proc_arm_peerinfo, SIGKILL); + GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->proc_arm_peerinfo)); + GNUNET_OS_process_destroy (d->proc_arm_peerinfo); + d->proc_arm_peerinfo = NULL; d->have_hostkey = GNUNET_YES; if (d->hostkey_callback != NULL) { @@ -416,13 +410,12 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (NULL == d->hostname) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Starting `%s', with command `%s %s %s %s %s %s'.\n", - "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, "-L", "DEBUG", + "Starting `%s', with command `%s %s %s %s'.\n", + "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, "-s"); - d->proc = + d->proc_arm_start = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, - "-L", "DEBUG", "-s", "-q", "-T", GNUNET_TIME_relative_to_string (GNUNET_TIME_absolute_get_remaining @@ -436,19 +429,14 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) dst = GNUNET_strdup (d->hostname); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Starting `%s', with command `%s %s %s %s %s %s %s %s'.\n", + "Starting `%s', with command `%s %s %s %s %s %s %s'.\n", "gnunet-arm", "ssh", dst, "gnunet-arm", "-c", d->cfgfile, - "-L", "DEBUG", "-s", "-q"); + "-s", "-q"); if (d->ssh_port_str == NULL) { - d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", -#if !DEBUG_TESTING + d->proc_arm_start = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", "-q", -#endif dst, "gnunet-arm", -#if DEBUG_TESTING - "-L", "DEBUG", -#endif "-c", d->cfgfile, "-s", "-q", "-T", GNUNET_TIME_relative_to_string (GNUNET_TIME_absolute_get_remaining @@ -457,16 +445,11 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) else { - d->proc = + d->proc_arm_start = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", "-p", d->ssh_port_str, -#if !DEBUG_TESTING "-q", -#endif dst, "gnunet-arm", -#if DEBUG_TESTING - "-L", "DEBUG", -#endif "-c", d->cfgfile, "-s", "-q", "-T", GNUNET_TIME_relative_to_string (GNUNET_TIME_absolute_get_remaining @@ -474,7 +457,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } GNUNET_free (dst); } - if (NULL == d->proc) + if (NULL == d->proc_arm_start) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not start `%s' process to start GNUnet.\n"), @@ -495,9 +478,10 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) d->task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d); + // FIXME: busy wait? break; case SP_START_ARMING: - if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code)) + if (GNUNET_OK != GNUNET_OS_process_status (d->proc_arm_start, &type, &code)) { if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0) { @@ -520,10 +504,12 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } GNUNET_free_non_null (d->hostname); GNUNET_free_non_null (d->username); - GNUNET_free (d->proc); -// GNUNET_free (d); // FIXME (could this leak) + GNUNET_OS_process_destroy (d->proc_arm_start); + d->proc_arm_start = NULL; + d->username = NULL; d->hostname = NULL; // Quick hack to avoid crashing (testing need to be d->cfg = NULL; // overhauled anyway, and the error managing is + // GNUNET_free (d); // FIXME (could this leak) // pretty broken anyway. return; } @@ -531,11 +517,13 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) d->task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d); + // FIXME: busy wait? return; } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully started `%s'.\n", "gnunet-arm"); - GNUNET_free (d->proc); + GNUNET_OS_process_destroy (d->proc_arm_start); + d->proc_arm_start = NULL; d->phase = SP_START_CORE; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling CORE_connect\n"); /* Fall through */ @@ -600,7 +588,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) break; case SP_SERVICE_START: /* confirm gnunet-arm exited */ - if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code)) + if (GNUNET_OK != GNUNET_OS_process_status (d->proc_arm_srv_start, &type, &code)) { if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0) { @@ -640,10 +628,12 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) d->phase = SP_START_DONE; if (NULL != cb) cb (d->cb_cls, &d->id, d->cfg, d, NULL); + GNUNET_OS_process_destroy (d->proc_arm_srv_start); + d->proc_arm_srv_start = NULL; break; case SP_SERVICE_SHUTDOWN_START: /* confirm copying complete */ - if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code)) + if (GNUNET_OK != GNUNET_OS_process_status (d->proc_arm_srv_stop, &type, &code)) { if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0) { @@ -674,8 +664,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) d->dead_cb (d->dead_cb_cls, NULL); break; case SP_SHUTDOWN_START: - /* confirm copying complete */ - if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code)) + /* confirm copying complete !??? */ + if (GNUNET_OK != GNUNET_OS_process_status (d->proc_arm_stop, &type, &code)) { if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0) { @@ -704,8 +694,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_free_non_null (d->hostname); GNUNET_free_non_null (d->username); GNUNET_free_non_null (d->shortname); - GNUNET_free_non_null (d->proc); - d->proc = NULL; + GNUNET_OS_process_destroy (d->proc_arm_stop); + d->proc_arm_stop = NULL; GNUNET_free (d); return; } @@ -740,8 +730,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_free_non_null (d->hostname); GNUNET_free_non_null (d->username); GNUNET_free_non_null (d->shortname); - GNUNET_free_non_null (d->proc); - d->proc = NULL; + GNUNET_OS_process_destroy (d->proc_arm_stop); + d->proc_arm_stop = NULL; GNUNET_free (d); return; } @@ -776,8 +766,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_free_non_null (d->hello); d->hello = NULL; GNUNET_free_non_null (d->shortname); - GNUNET_free_non_null (d->proc); - d->proc = NULL; + GNUNET_OS_process_destroy (d->proc_arm_stop); + d->proc_arm_stop = NULL; d->shortname = NULL; if (d->churn == GNUNET_NO) GNUNET_free (d); @@ -785,7 +775,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) break; case SP_CONFIG_UPDATE: /* confirm copying complete */ - if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code)) + if (GNUNET_OK != GNUNET_OS_process_status (d->proc_arm_copying, &type, &code)) { if (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0) /* FIXME: config update should take timeout parameter! */ { @@ -902,14 +892,9 @@ GNUNET_TESTING_daemon_start_stopped_service (struct GNUNET_TESTING_Daemon *d, else arg = GNUNET_strdup (d->hostname); - d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", -#if !DEBUG_TESTING + d->proc_arm_srv_start = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", "-q", -#endif arg, "gnunet-arm", -#if DEBUG_TESTING - "-L", "DEBUG", -#endif "-c", d->cfgfile, "-i", service, "-q", "-T", GNUNET_TIME_relative_to_string (timeout), @@ -923,10 +908,7 @@ GNUNET_TESTING_daemon_start_stopped_service (struct GNUNET_TESTING_Daemon *d, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting gnunet-arm with config `%s' locally.\n", d->cfgfile); - d->proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gnunet-arm", -#if DEBUG_TESTING - "-L", "DEBUG", -#endif + d->proc_arm_srv_start = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, "-i", service, "-q", "-T", GNUNET_TIME_relative_to_string (timeout), @@ -978,14 +960,9 @@ GNUNET_TESTING_daemon_start_service (struct GNUNET_TESTING_Daemon *d, else arg = GNUNET_strdup (d->hostname); - d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", -#if !DEBUG_TESTING + d->proc_arm_srv_start = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", "-q", -#endif arg, "gnunet-arm", -#if DEBUG_TESTING - "-L", "DEBUG", -#endif "-c", d->cfgfile, "-i", service, "-q", "-T", GNUNET_TIME_relative_to_string (timeout), @@ -1000,10 +977,7 @@ GNUNET_TESTING_daemon_start_service (struct GNUNET_TESTING_Daemon *d, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting gnunet-arm with config `%s' locally.\n", d->cfgfile); - d->proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gnunet-arm", -#if DEBUG_TESTING - "-L", "DEBUG", -#endif + d->proc_arm_srv_start = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, "-i", service, "-q", "-T", GNUNET_TIME_relative_to_string (timeout), @@ -1210,10 +1184,8 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_free (baseservicehome); if (ret->ssh_port_str == NULL) { - ret->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", "-r", -#if !DEBUG_TESTING + ret->proc_arm_copying = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", "-r", "-q", -#endif servicehome, arg, NULL); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "copying directory with command scp -r %s %s\n", @@ -1221,16 +1193,14 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, } else { - ret->proc = + ret->proc_arm_copying = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", "-r", "-P", ret->ssh_port_str, -#if !DEBUG_TESTING "-q", -#endif servicehome, arg, NULL); } GNUNET_free (arg); - if (NULL == ret->proc) + if (NULL == ret->proc_arm_copying) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _ @@ -1334,14 +1304,9 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d, else arg = GNUNET_strdup (d->hostname); - d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", -#if !DEBUG_TESTING + d->proc_arm_stop = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", "-q", -#endif arg, "gnunet-arm", -#if DEBUG_TESTING - "-L", "DEBUG", -#endif "-c", d->cfgfile, "-e", "-r", NULL); /* Use -r to restart arm and all services */ @@ -1351,10 +1316,7 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile); - d->proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gnunet-arm", -#if DEBUG_TESTING - "-L", "DEBUG", -#endif + d->proc_arm_stop = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, "-e", "-r", NULL); } @@ -1414,15 +1376,10 @@ GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d, GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname); else arg = GNUNET_strdup (d->hostname); - - d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", -#if !DEBUG_TESTING + + d->proc_arm_srv_stop = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", "-q", -#endif arg, "gnunet-arm", -#if DEBUG_TESTING - "-L", "DEBUG", -#endif "-c", d->cfgfile, "-k", service, "-q", "-T", GNUNET_TIME_relative_to_string (timeout), @@ -1436,10 +1393,7 @@ GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile); - d->proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gnunet-arm", -#if DEBUG_TESTING - "-L", "DEBUG", -#endif + d->proc_arm_srv_stop = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, "-k", service, "-q", "-T", GNUNET_TIME_relative_to_string (timeout), @@ -1452,6 +1406,20 @@ GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d, /** + * Forcefully terminate a process and clean up the child. + * + * @param proc handle to process to kill + */ +static void +kill_and_close_process (struct GNUNET_OS_Process *proc) +{ + (void) GNUNET_OS_process_kill (proc, SIGKILL); + GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (proc)); + GNUNET_OS_process_destroy (proc); +} + + +/** * Stops a GNUnet daemon. * * @param d the daemon that should be stopped @@ -1482,10 +1450,35 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, d->dead = GNUNET_YES; return; } - - if ((d->running == GNUNET_NO) && (d->churn == GNUNET_YES)) /* Peer has already been stopped in churn context! */ + if (NULL != d->proc_arm_start) + { + kill_and_close_process (d->proc_arm_start); + d->proc_arm_start = NULL; + } + if (NULL != d->proc_arm_srv_start) { - /* Free what was left from churning! */ + kill_and_close_process (d->proc_arm_srv_start); + d->proc_arm_srv_start = NULL; + } + if (NULL != d->proc_arm_srv_stop) + { + kill_and_close_process (d->proc_arm_srv_stop); + d->proc_arm_srv_stop = NULL; + } + if (NULL != d->proc_arm_copying) + { + kill_and_close_process (d->proc_arm_copying); + d->proc_arm_copying = NULL; + } + if (NULL != d->proc_arm_peerinfo) + { + kill_and_close_process (d->proc_arm_peerinfo); + d->proc_arm_peerinfo = NULL; + } + if ((d->running == GNUNET_NO) && (d->churn == GNUNET_YES)) + { + /* Peer has already been stopped in churn context! + * Free what was left from churning! */ GNUNET_assert (d->cfg != NULL); GNUNET_CONFIGURATION_destroy (d->cfg); if (delete_files == GNUNET_YES) @@ -1500,6 +1493,10 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, GNUNET_free_non_null (d->username); if (NULL != d->dead_cb) d->dead_cb (d->dead_cb_cls, NULL); + /* FIXME: this should be an assert and the test below + should not be required, but testing is broken... */ + GNUNET_break (NULL == d->proc_arm_stop); + if (NULL == d->proc_arm_stop) GNUNET_free (d); return; } @@ -1537,6 +1534,8 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, d->th = NULL; } /* Check if this is a local or remote process */ + + if (NULL != d->hostname) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -1547,14 +1546,9 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, else arg = GNUNET_strdup (d->hostname); - d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", -#if !DEBUG_TESTING + d->proc_arm_stop = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", "-q", -#endif arg, "gnunet-arm", -#if DEBUG_TESTING - "-L", "DEBUG", -#endif "-c", d->cfgfile, "-e", "-q", "-T", GNUNET_TIME_relative_to_string (timeout), del_arg, NULL); @@ -1568,14 +1562,11 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile); - d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "gnunet-arm", "gnunet-arm", -#if DEBUG_TESTING - "-L", "DEBUG", -#endif + d->proc_arm_stop = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, "-e", "-q", "-T", GNUNET_TIME_relative_to_string (timeout), del_arg, NULL); - GNUNET_assert (NULL != d->proc); + GNUNET_assert (NULL != d->proc_arm_stop); } GNUNET_free_non_null (del_arg); @@ -1635,13 +1626,11 @@ GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d, GNUNET_asprintf (&arg, "%s@%s:%s", d->username, d->hostname, d->cfgfile); else GNUNET_asprintf (&arg, "%s:%s", d->hostname, d->cfgfile); - d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", -#if !DEBUG_TESTING + d->proc_arm_copying = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", "-q", -#endif d->cfgfile, arg, NULL); GNUNET_free (arg); - if (NULL == d->proc) + if (NULL == d->proc_arm_copying) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Could not start `%s' process to copy configuration file.\n"), @@ -2173,7 +2162,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to connect peer %s to peer %s\n", d1->shortname, d2->shortname); /* Core is up! Iterate over all _known_ peers first to check if we are already connected to the peer! */ - GNUNET_assert (GNUNET_OK == + GNUNET_assert (NULL != GNUNET_CORE_is_peer_connected (ctx->d1->cfg, &ctx->d2->id, &core_initial_iteration, ctx)); return ctx; diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 2d0e9ef..75c0e61 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c @@ -30,12 +30,6 @@ #include "gnunet_testing_lib.h" #include "gnunet_core_service.h" -#define VERBOSE_TESTING GNUNET_NO - -#define VERBOSE_TOPOLOGY GNUNET_NO - -#define DEBUG_CHURN GNUNET_EXTRA_LOGGING - #define USE_START_HELPER GNUNET_YES #define OLD 1 @@ -1357,7 +1351,7 @@ update_config (void *cls, const char *section, const char *option, GNUNET_asprintf (&single_variable, "single_%s_per_host", section); GNUNET_asprintf (&per_host_variable, "num_%s_per_host", section); - if ((0 == strcmp (option, "PORT")) && (1 == sscanf (value, "%u", &ival))) + if ((0 == strcmp (option, "PORT")) && (1 == SSCANF (value, "%u", &ival))) { if ((ival != 0) && (GNUNET_YES != @@ -1510,9 +1504,7 @@ GNUNET_TESTING_create_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32 ""); GNUNET_CONFIGURATION_set_value_string (uc.ret, "nse", "UNIXPATH", ""); - GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-tcp", - "USE_LOCALADDR", "YES"); - GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-udp", + GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "USE_LOCALADDR", "YES"); GNUNET_free_non_null (control_host); GNUNET_free (allowed_hosts); @@ -1540,10 +1532,7 @@ GNUNET_TESTING_create_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32 } else { - - GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-tcp", - "USE_LOCALADDR", "YES"); - GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-udp", + GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "USE_LOCALADDR", "YES"); GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "BINDTO", "127.0.0.1"); @@ -1835,17 +1824,13 @@ create_scale_free (struct GNUNET_TESTING_PeerGroup *pg, ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX)) / ((double) UINT64_MAX); -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Considering connecting peer %d to peer %d\n", outer_count, i); -#endif if (random < probability) { -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", outer_count, i); -#endif total_connections += proc (pg, outer_count, i, list, GNUNET_YES); } } @@ -1904,7 +1889,7 @@ create_small_world_ring (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE", &p_string)) { - if (sscanf (p_string, "%lf", &logNModifier) != 1) + if (SSCANF (p_string, "%lf", &logNModifier) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), @@ -1916,7 +1901,7 @@ create_small_world_ring (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY", &p_string)) { - if (sscanf (p_string, "%lf", &probability) != 1) + if (SSCANF (p_string, "%lf", &probability) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), @@ -1929,7 +1914,7 @@ create_small_world_ring (struct GNUNET_TESTING_PeerGroup *pg, if (connsPerPeer % 2 == 1) connsPerPeer += 1; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Target is %d connections per peer."), + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Target is %d connections per peer.", connsPerPeer); smallWorldConnections = 0; @@ -2017,7 +2002,7 @@ create_nated_internet (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE", &p_string)) { - if (sscanf (p_string, "%lf", &nat_percentage) != 1) + if (SSCANF (p_string, "%lf", &nat_percentage) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), @@ -2033,10 +2018,8 @@ create_nated_internet (struct GNUNET_TESTING_PeerGroup *pg, { if ((outer_count > cutoff) || (inner_count > cutoff)) { -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", outer_count, inner_count); -#endif connect_attempts += proc (pg, outer_count, inner_count, list, GNUNET_YES); } @@ -2076,7 +2059,7 @@ create_nated_internet_copy (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE", &p_string)) { - if (sscanf (p_string, "%lf", &nat_percentage) != 1) + if (SSCANF (p_string, "%lf", &nat_percentage) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), @@ -2104,10 +2087,8 @@ create_nated_internet_copy (struct GNUNET_TESTING_PeerGroup *pg, { if ((outer_count > cutoff) || (inner_count > cutoff)) { -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", outer_count, inner_count); -#endif connect_attempts += proc (pg, outer_count, inner_count, list, GNUNET_YES); add_connections (pg, outer_count, inner_count, ALLOWED, GNUNET_NO); @@ -2165,7 +2146,7 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE", &p_string)) { - if (sscanf (p_string, "%lf", &percentage) != 1) + if (SSCANF (p_string, "%lf", &percentage) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), @@ -2185,7 +2166,7 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY", &p_string)) { - if (sscanf (p_string, "%lf", &probability) != 1) + if (SSCANF (p_string, "%lf", &probability) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), @@ -2204,12 +2185,9 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg, toggle++; } } -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Connecting nodes in 2d torus topology: %u rows %u columns\n"), + "Connecting nodes in 2d torus topology: %u rows %u columns\n", rows, cols); -#endif - connect_attempts = 0; /* Rows and columns are all sorted out, now iterate over all nodes and connect each * to the node to its right and above. Once this is over, we'll have our torus! @@ -2241,13 +2219,11 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg, connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES); } natLog = log (pg->total); -#if VERBOSE_TESTING > 2 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("natural log of %d is %d, will run %d iterations\n"), pg->total, + "natural log of %d is %d, will run %d iterations\n", pg->total, natLog, (int) (natLog * percentage)); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Total connections added thus far: %u!\n"), connect_attempts); -#endif + "Total connections added thus far: %u!\n", connect_attempts); smallWorldConnections = 0; small_world_it = (unsigned int) (natLog * percentage); if (small_world_it < 1) @@ -2285,11 +2261,9 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg, } } connect_attempts += smallWorldConnections; -#if VERBOSE_TESTING > 2 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Total connections added for small world: %d!\n"), + "Total connections added for small world: %d!\n", smallWorldConnections); -#endif return connect_attempts; } @@ -2322,7 +2296,7 @@ create_erdos_renyi (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY", &p_string)) { - if (sscanf (p_string, "%lf", &probability) != 1) + if (SSCANF (p_string, "%lf", &probability) != 1) GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), @@ -2338,10 +2312,8 @@ create_erdos_renyi (struct GNUNET_TESTING_PeerGroup *pg, ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, UINT64_MAX)) / ((double) UINT64_MAX); -#if VERBOSE_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("rand is %f probability is %f\n"), + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "rand is %f probability is %f\n", temp_rand, probability); -#endif if (temp_rand < probability) { connect_attempts += @@ -2397,11 +2369,9 @@ create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg, toggle++; } } -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Connecting nodes in 2d torus topology: %u rows %u columns\n"), + "Connecting nodes in 2d torus topology: %u rows %u columns\n", rows, cols); -#endif /* Rows and columns are all sorted out, now iterate over all nodes and connect each * to the node to its right and above. Once this is over, we'll have our torus! * Special case for the last node (if the rows and columns are not equal), connect @@ -2416,10 +2386,8 @@ create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg, nodeToConnect = rows * cols - cols; else nodeToConnect = i - cols + 1; -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", i, nodeToConnect); -#endif connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES); /* Second connect to the node immediately above */ @@ -2434,10 +2402,8 @@ create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg, if (nodeToConnect < pg->total) { -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", i, nodeToConnect); -#endif connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES); } @@ -2479,10 +2445,8 @@ create_clique (struct GNUNET_TESTING_PeerGroup *pg, { for (inner_count = outer_count + 1; inner_count < pg->total; inner_count++) { -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", outer_count, inner_count); -#endif connect_attempts += proc (pg, outer_count, inner_count, list, check); update_meter (conn_meter); } @@ -2590,10 +2554,8 @@ create_line (struct GNUNET_TESTING_PeerGroup *pg, /* Connect each peer to the next highest numbered peer */ for (count = 0; count < pg->total - 1; count++) { -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", count, count + 1); -#endif connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES); } @@ -2675,10 +2637,8 @@ create_from_file (struct GNUNET_TESTING_PeerGroup *pg, char *filename, GNUNET_free (data); return connect_attempts; } -#if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found %u total peers in topology\n", total_peers); -#endif GNUNET_assert (total_peers == pg->total); curr_state = PEER_INDEX; while ((buf[count] != '\n') && (count < frstat.st_size - 1)) @@ -2769,10 +2729,8 @@ create_ring (struct GNUNET_TESTING_PeerGroup *pg, /* Connect each peer to the next highest numbered peer */ for (count = 0; count < pg->total - 1; count++) { -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", count, count + 1); -#endif connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES); } @@ -2927,15 +2885,10 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg) if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */ { GNUNET_asprintf (&arg, "%s/friends", temp_service_path); - procarr[pg_iter] = - GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "mv", "mv", mytemp, arg, NULL); - GNUNET_assert (procarr[pg_iter] != NULL); -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Copying file with command cp %s %s\n", mytemp, arg); -#endif - ret = GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: schedule this, throttle! */ - GNUNET_OS_process_close (procarr[pg_iter]); + "Copying file with RENAME(%s,%s)\n", mytemp, arg); + RENAME (mytemp, arg); + procarr[pg_iter] = NULL; GNUNET_free (arg); } else /* Remote, scp the file to the correct place */ @@ -2953,7 +2906,7 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg) GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", mytemp, arg, NULL); GNUNET_assert (procarr[pg_iter] != NULL); ret = GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: schedule this, throttle! */ - GNUNET_OS_process_close (procarr[pg_iter]); + GNUNET_OS_process_destroy (procarr[pg_iter]); if (ret != GNUNET_OK) { /* FIXME: free contents of 'procarr' array */ @@ -2964,10 +2917,8 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg) return ret; } procarr[pg_iter] = NULL; -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Copying file with command scp %s %s\n", mytemp, arg); -#endif GNUNET_free (arg); } GNUNET_free (temp_service_path); @@ -2982,10 +2933,8 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg) ret = GNUNET_OK; for (pg_iter = 0; pg_iter < pg->total; pg_iter++) { -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking copy status of file %d\n", pg_iter); -#endif if (procarr[pg_iter] != NULL) /* Check for already completed! */ { if (GNUNET_OS_process_status (procarr[pg_iter], &type, &return_code) != @@ -2999,11 +2948,9 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg) } else { - GNUNET_OS_process_close (procarr[pg_iter]); + GNUNET_OS_process_destroy (procarr[pg_iter]); procarr[pg_iter] = NULL; -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "File %d copied\n", pg_iter); -#endif } } } @@ -3015,10 +2962,8 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg) } } -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Finished copying all friend files!\n")); -#endif + "Finished copying all friend files!\n"); #endif GNUNET_free (procarr); return ret; @@ -3126,13 +3071,10 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */ { GNUNET_asprintf (&arg, "%s/blacklist", temp_service_path); - procarr[pg_iter] = - GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "mv", "mv", mytemp, arg, NULL); -#if VERBOSE_TESTING + RENAME (mytemp, arg); + procarr[pg_iter] = NULL; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Copying file with command cp %s %s\n"), mytemp, arg); -#endif - + "Copying file with RENAME (%s,%s)\n", mytemp, arg); GNUNET_free (arg); } else /* Remote, scp the file to the correct place */ @@ -3151,10 +3093,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_assert (procarr[pg_iter] != NULL); GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: add scheduled blacklist file copy that parallelizes file copying! */ -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Copying file with command scp %s %s\n"), mytemp, arg); -#endif + "Copying file with command scp %s %s\n", mytemp, arg); GNUNET_free (arg); } GNUNET_free (temp_service_path); @@ -3168,10 +3108,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, ret = GNUNET_OK; for (pg_iter = 0; pg_iter < pg->total; pg_iter++) { -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Checking copy status of file %d\n"), pg_iter); -#endif + "Checking copy status of file %d\n", pg_iter); if (procarr[pg_iter] != NULL) /* Check for already completed! */ { if (GNUNET_OS_process_status (procarr[pg_iter], &type, &return_code) != @@ -3185,11 +3123,9 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, } else { - GNUNET_OS_process_close (procarr[pg_iter]); + GNUNET_OS_process_destroy (procarr[pg_iter]); procarr[pg_iter] = NULL; -#if VERBOSE_TESTING - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("File %d copied\n"), pg_iter); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "File %d copied\n", pg_iter); } } } @@ -3201,10 +3137,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, } } -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Finished copying all blacklist files!\n")); -#endif + "Finished copying all blacklist files!\n"); GNUNET_free (procarr); return ret; } @@ -3401,11 +3335,8 @@ core_connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, #if BAD struct PeerData *other_peer; #endif -#if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected peer %s to peer %s\n", ctx->d1->shortname, GNUNET_i2s (peer)); -#endif - if (0 == memcmp (&send_hello_context->peer->daemon->id, peer, sizeof (struct GNUNET_PeerIdentity))) @@ -3523,16 +3454,12 @@ hello_sent_callback (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } send_hello_context->pg->remaining_hellos--; -#if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent HELLO, have %d remaining!\n", send_hello_context->pg->remaining_hellos); -#endif if (send_hello_context->peer_pos == NULL) /* All HELLOs (for this peer!) have been transmitted! */ { -#if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All hellos for this peer sent, disconnecting transport!\n"); -#endif GNUNET_assert (send_hello_context->peer->daemon->th != NULL); GNUNET_TRANSPORT_disconnect (send_hello_context->peer->daemon->th); send_hello_context->peer->daemon->th = NULL; @@ -3580,22 +3507,17 @@ schedule_send_hellos (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) (pg->outstanding_connects > pg->max_outstanding_connections)) || (pg->stop_connects == GNUNET_YES)) { -#if VERBOSE_TESTING > 2 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _ - ("Delaying connect, we have too many outstanding connections!\n")); -#endif + "Delaying connect, we have too many outstanding connections!\n"); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_send_hellos, send_hello_context); } else { -#if VERBOSE_TESTING > 2 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Creating connection, outstanding_connections is %d\n"), + "Creating connection, outstanding_connections is %d\n", outstanding_connects); -#endif if (send_hello_context->peer->daemon->th == NULL) { pg->outstanding_connects++; /* Actual TRANSPORT, CORE connections! */ @@ -3603,13 +3525,11 @@ schedule_send_hellos (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_TRANSPORT_connect (send_hello_context->peer->cfg, NULL, send_hello_context, NULL, NULL, NULL); } -#if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Offering HELLO of peer %s to peer %s\n"), + "Offering HELLO of peer %s to peer %s\n", send_hello_context->peer->daemon->shortname, pg->peers[send_hello_context->peer_pos->index]. daemon->shortname); -#endif GNUNET_TRANSPORT_offer_hello (send_hello_context->peer->daemon->th, (const struct GNUNET_MessageHeader *) pg->peers[send_hello_context->peer_pos-> @@ -3717,23 +3637,17 @@ schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if ((pg->outstanding_connects > pg->max_outstanding_connections) || (pg->stop_connects == GNUNET_YES)) { -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _ - ("Delaying connect, we have too many outstanding connections!\n")); -#endif + "Delaying connect, we have too many outstanding connections!\n"); connect_context->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_connect, connect_context); return; } -#if VERBOSE_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _ - ("Creating connection, outstanding_connections is %d (max %d)\n"), + "Creating connection, outstanding_connections is %d (max %d)\n", pg->outstanding_connects, pg->max_outstanding_connections); -#endif pg->outstanding_connects++; pg->total_connects_scheduled++; GNUNET_assert (NULL == connect_context->cc); @@ -3985,46 +3899,46 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg, switch (topology) { case GNUNET_TESTING_TOPOLOGY_CLIQUE: - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating clique topology\n")); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating clique topology\n"); num_connections = create_clique (pg, &add_connections, ALLOWED, GNUNET_NO); break; case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Creating small world (ring) topology\n")); + "Creating small world (ring) topology\n"); num_connections = create_small_world_ring (pg, &add_connections, ALLOWED); break; case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Creating small world (2d-torus) topology\n")); + "Creating small world (2d-torus) topology\n"); num_connections = create_small_world (pg, &add_connections, ALLOWED); break; case GNUNET_TESTING_TOPOLOGY_RING: - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating ring topology\n")); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating ring topology\n"); num_connections = create_ring (pg, &add_connections, ALLOWED); break; case GNUNET_TESTING_TOPOLOGY_2D_TORUS: - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating 2d torus topology\n")); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating 2d torus topology\n"); num_connections = create_2d_torus (pg, &add_connections, ALLOWED); break; case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI: - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating Erdos-Renyi topology\n")); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating Erdos-Renyi topology\n"); num_connections = create_erdos_renyi (pg, &add_connections, ALLOWED); break; case GNUNET_TESTING_TOPOLOGY_INTERNAT: - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating InterNAT topology\n")); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating InterNAT topology\n"); num_connections = create_nated_internet (pg, &add_connections, ALLOWED); break; case GNUNET_TESTING_TOPOLOGY_SCALE_FREE: - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating Scale Free topology\n")); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating Scale Free topology\n"); num_connections = create_scale_free (pg, &add_connections, ALLOWED); break; case GNUNET_TESTING_TOPOLOGY_LINE: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Creating straight line topology\n")); + "Creating straight line topology\n"); num_connections = create_line (pg, &add_connections, ALLOWED); break; case GNUNET_TESTING_TOPOLOGY_FROM_FILE: - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating topology from file!\n")); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating topology from file!\n"); if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "testing", "topology_file", &filename)) @@ -4055,13 +3969,13 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg, if (ret != GNUNET_OK) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Failed during friend file copying!\n")); + "Failed during friend file copying!\n"); return GNUNET_SYSERR; } else { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Friend files created/copied successfully!\n")); + "Friend files created/copied successfully!\n"); } } @@ -4078,43 +3992,43 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg, { case GNUNET_TESTING_TOPOLOGY_CLIQUE: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Blacklisting all but clique topology\n")); + "Blacklisting all but clique topology\n"); unblacklisted_connections = create_clique (pg, &remove_connections, BLACKLIST, GNUNET_NO); break; case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Blacklisting all but small world (ring) topology\n")); + "Blacklisting all but small world (ring) topology\n"); unblacklisted_connections = create_small_world_ring (pg, &remove_connections, BLACKLIST); break; case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Blacklisting all but small world (2d-torus) topology\n")); + "Blacklisting all but small world (2d-torus) topology\n"); unblacklisted_connections = create_small_world (pg, &remove_connections, BLACKLIST); break; case GNUNET_TESTING_TOPOLOGY_RING: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Blacklisting all but ring topology\n")); + "Blacklisting all but ring topology\n"); unblacklisted_connections = create_ring (pg, &remove_connections, BLACKLIST); break; case GNUNET_TESTING_TOPOLOGY_2D_TORUS: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Blacklisting all but 2d torus topology\n")); + "Blacklisting all but 2d torus topology\n"); unblacklisted_connections = create_2d_torus (pg, &remove_connections, BLACKLIST); break; case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Blacklisting all but Erdos-Renyi topology\n")); + "Blacklisting all but Erdos-Renyi topology\n"); unblacklisted_connections = create_erdos_renyi (pg, &remove_connections, BLACKLIST); break; case GNUNET_TESTING_TOPOLOGY_INTERNAT: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Blacklisting all but InterNAT topology\n")); + "Blacklisting all but InterNAT topology\n"); #if TOPOLOGY_HACK for (off = 0; off < pg->total; off++) @@ -4149,13 +4063,13 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg, break; case GNUNET_TESTING_TOPOLOGY_SCALE_FREE: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Blacklisting all but Scale Free topology\n")); + "Blacklisting all but Scale Free topology\n"); unblacklisted_connections = create_scale_free (pg, &remove_connections, BLACKLIST); break; case GNUNET_TESTING_TOPOLOGY_LINE: GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Blacklisting all but straight line topology\n")); + "Blacklisting all but straight line topology\n"); unblacklisted_connections = create_line (pg, &remove_connections, BLACKLIST); default: @@ -4170,13 +4084,13 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg, if (ret != GNUNET_OK) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Failed during blacklist file copying!\n")); + "Failed during blacklist file copying!\n"); return 0; } else { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Blacklist files created/copied successfully!\n")); + "Blacklist files created/copied successfully!\n"); } } return num_connections; @@ -4878,22 +4792,14 @@ schedule_get_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (topology_context->connected > topology_context->pg->max_outstanding_connections) { -#if VERBOSE_TESTING > 2 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _ - ("Delaying connect, we have too many outstanding connections!\n")); -#endif + "Delaying connect, we have too many outstanding connections!\n"); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_get_topology, core_context); } else { -#if VERBOSE_TESTING > 2 - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Creating connection, outstanding_connections is %d\n"), - outstanding_connects); -#endif topology_context->connected++; if (GNUNET_OK != @@ -4973,6 +4879,23 @@ internal_stats_callback (void *cls, const char *subsystem, const char *name, subsystem, name, value, is_persistent); } + +/** + * We don't need the statistics handle anymore, destroy it. + * + * @param cls Closure (the statistics handle to destroy) + * @param tc Task Context + */ +static void +internal_destroy_statistics (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + struct GNUNET_STATISTICS_Handle *h = cls; + + GNUNET_STATISTICS_destroy (h, GNUNET_NO); +} + + /** * Internal continuation call for statistics iteration. * @@ -4997,7 +4920,9 @@ internal_stats_cont (void *cls, int success) } if (core_context->stats_handle != NULL) - GNUNET_STATISTICS_destroy (core_context->stats_handle, GNUNET_NO); + /* Cannot destroy handle inside the continuation */ + GNUNET_SCHEDULER_add_now (&internal_destroy_statistics, + core_context->stats_handle); GNUNET_free (core_context); } @@ -5019,23 +4944,14 @@ schedule_get_statistics (void *cls, if (stats_context->connected > stats_context->pg->max_outstanding_connections) { -#if VERBOSE_TESTING > 2 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _ - ("Delaying connect, we have too many outstanding connections!\n")); -#endif + "Delaying connect, we have too many outstanding connections!\n"); GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100), &schedule_get_statistics, core_context); } else { -#if VERBOSE_TESTING > 2 - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Creating connection, outstanding_connections is %d\n"), - outstanding_connects); -#endif - stats_context->connected++; core_context->stats_handle = GNUNET_STATISTICS_create ("testing", core_context->daemon->cfg); @@ -5047,7 +4963,7 @@ schedule_get_statistics (void *cls, core_context->stats_get_handle = GNUNET_STATISTICS_get (core_context->stats_handle, NULL, NULL, - GNUNET_TIME_relative_get_forever (), + GNUNET_TIME_UNIT_FOREVER_REL, &internal_stats_cont, &internal_stats_callback, core_context); if (core_context->stats_get_handle == NULL) @@ -5258,71 +5174,51 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg, switch (topology) { case GNUNET_TESTING_TOPOLOGY_CLIQUE: -#if VERBOSE_TOPOLOGY GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Creating clique CONNECT topology\n")); -#endif + "Creating clique CONNECT topology\n"); create_clique (pg, &add_connections, CONNECT, GNUNET_NO); break; case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: -#if VERBOSE_TOPOLOGY GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Creating small world (ring) CONNECT topology\n")); -#endif + "Creating small world (ring) CONNECT topology\n"); create_small_world_ring (pg, &add_connections, CONNECT); break; case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD: -#if VERBOSE_TOPOLOGY GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Creating small world (2d-torus) CONNECT topology\n")); -#endif + "Creating small world (2d-torus) CONNECT topology\n"); create_small_world (pg, &add_connections, CONNECT); break; case GNUNET_TESTING_TOPOLOGY_RING: -#if VERBOSE_TOPOLOGY - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating ring CONNECT topology\n")); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating ring CONNECT topology\n"); create_ring (pg, &add_connections, CONNECT); break; case GNUNET_TESTING_TOPOLOGY_2D_TORUS: -#if VERBOSE_TOPOLOGY GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Creating 2d torus CONNECT topology\n")); -#endif + "Creating 2d torus CONNECT topology\n"); create_2d_torus (pg, &add_connections, CONNECT); break; case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI: -#if VERBOSE_TOPOLOGY GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Creating Erdos-Renyi CONNECT topology\n")); -#endif + "Creating Erdos-Renyi CONNECT topology\n"); create_erdos_renyi (pg, &add_connections, CONNECT); break; case GNUNET_TESTING_TOPOLOGY_INTERNAT: -#if VERBOSE_TOPOLOGY GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Creating InterNAT CONNECT topology\n")); -#endif + "Creating InterNAT CONNECT topology\n"); create_nated_internet (pg, &add_connections, CONNECT); break; case GNUNET_TESTING_TOPOLOGY_SCALE_FREE: -#if VERBOSE_TOPOLOGY GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Creating Scale Free CONNECT topology\n")); -#endif + "Creating Scale Free CONNECT topology\n"); create_scale_free (pg, &add_connections, CONNECT); break; case GNUNET_TESTING_TOPOLOGY_LINE: -#if VERBOSE_TOPOLOGY GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Creating straight line CONNECT topology\n")); -#endif + "Creating straight line CONNECT topology\n"); create_line (pg, &add_connections, CONNECT); break; case GNUNET_TESTING_TOPOLOGY_NONE: -#if VERBOSE_TOPOLOGY - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating no CONNECT topology\n")); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating no CONNECT topology\n"); copy_allowed_topology (pg); break; default: @@ -5334,39 +5230,29 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg, switch (options) { case GNUNET_TESTING_TOPOLOGY_OPTION_RANDOM: -#if VERBOSE_TOPOLOGY GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _ - ("Connecting random subset (%'.2f percent) of possible peers\n"), + "Connecting random subset (%'.2f percent) of possible peers\n", 100 * option_modifier); -#endif choose_random_connections (pg, option_modifier); break; case GNUNET_TESTING_TOPOLOGY_OPTION_MINIMUM: -#if VERBOSE_TOPOLOGY GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _("Connecting a minimum of %u peers each (if possible)\n"), + "Connecting a minimum of %u peers each (if possible)\n", (unsigned int) option_modifier); -#endif choose_minimum (pg, (unsigned int) option_modifier); break; case GNUNET_TESTING_TOPOLOGY_OPTION_DFS: -#if VERBOSE_TOPOLOGY GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - _ - ("Using DFS to connect a minimum of %u peers each (if possible)\n"), + "Using DFS to connect a minimum of %u peers each (if possible)\n", (unsigned int) option_modifier); -#endif #if FIXME perform_dfs (pg, (int) option_modifier); #endif break; case GNUNET_TESTING_TOPOLOGY_OPTION_ADD_CLOSEST: -#if VERBOSE_TOPOLOGY - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Finding additional %u closest peers each (if possible)\n"), + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Finding additional %u closest peers each (if possible)\n", (unsigned int) option_modifier); -#endif #if FIXME add_closest (pg, (unsigned int) option_modifier, &add_connections, CONNECT); #endif @@ -5418,9 +5304,9 @@ increment_outstanding_at_host (const char *hostname, struct OutstandingSSH *pos; pos = pg->ssh_head; - while ((pos != NULL) && (strcmp (pos->hostname, hostname) != 0)) + while ((NULL != pos) && (strcmp (pos->hostname, hostname) != 0)) pos = pos->next; - GNUNET_assert (pos != NULL); + GNUNET_assert (NULL != pos); pos->outstanding++; } @@ -5781,7 +5667,7 @@ check_peers_started (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } } - GNUNET_OS_process_close (helper->proc); + GNUNET_OS_process_destroy (helper->proc); } static void @@ -5809,10 +5695,8 @@ start_peer_helper (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", arg, "peerStartHelper.pl", tempdir, NULL); GNUNET_assert (helper->proc != NULL); -#if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "starting peers with cmd ssh %s %s %s\n", arg, "peerStartHelper.pl", tempdir); -#endif GNUNET_SCHEDULER_add_now (&check_peers_started, helper); GNUNET_free (tempdir); GNUNET_free (baseservicehome); @@ -6032,9 +5916,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_asprintf (&ssh_port_str, "%d", pg->hosts[i].sshport); proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", "-P", ssh_port_str, -#if !DEBUG_TESTING "-q", -#endif arg, "mkdir -p", tmpdir, NULL); } else @@ -6048,7 +5930,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_free (tmpdir); GNUNET_free (arg); GNUNET_OS_process_wait (proc); - GNUNET_OS_process_close (proc); + GNUNET_OS_process_destroy (proc); } GNUNET_free (baseservicehome); baseservicehome = NULL; @@ -6081,12 +5963,10 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, return NULL; } - if (GNUNET_YES != GNUNET_DISK_file_size (hostkeys_file, &fs, GNUNET_YES)) + if (GNUNET_OK != GNUNET_DISK_file_size (hostkeys_file, &fs, GNUNET_YES, GNUNET_YES)) fs = 0; -#if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Found file size %llu for hostkeys\n", fs); -#endif if (0 != (fs % HOSTKEYFILESIZE)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, @@ -6229,10 +6109,8 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME", &baseservicehome)) { -#if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "baseservice home is %s\n", baseservicehome); -#endif if (hostname != NULL) GNUNET_asprintf (&newservicehome, "%s/%s/", baseservicehome, hostname); @@ -6264,11 +6142,9 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "rsync", "rsync", "-r", newservicehome, arg, NULL); -#if DEBUG_TESTING GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "copying directory with command rsync -r %s %s\n", newservicehome, arg); -#endif GNUNET_free (newservicehome); GNUNET_free (arg); if (NULL == proc) @@ -6280,7 +6156,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_assert (0); } GNUNET_OS_process_wait (proc); - GNUNET_OS_process_close (proc); + GNUNET_OS_process_destroy (proc); } /* Now all the configuration files and hostkeys are copied to the remote host. Call the hostkey callback for each peer! */ GNUNET_SCHEDULER_add_now (&call_hostkey_callbacks, pg); @@ -6684,10 +6560,8 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg, for (i = 0; i < voff; i++) { -#if DEBUG_CHURN GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stopping peer %d!\n", running_arr[running_permute[i]]); -#endif GNUNET_assert (running_arr != NULL); peer_shutdown_ctx = GNUNET_malloc (sizeof (struct PeerShutdownContext)); peer_shutdown_ctx->daemon = @@ -6706,10 +6580,8 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg, } for (i = 0; i < von; i++) { -#if DEBUG_CHURN GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting up peer %d!\n", stopped_arr[stopped_permute[i]]); -#endif GNUNET_assert (stopped_arr != NULL); peer_restart_ctx = GNUNET_malloc (sizeof (struct PeerRestartContext)); peer_restart_ctx->churn_restart_ctx = churn_startup_ctx; @@ -6758,10 +6630,6 @@ GNUNET_TESTING_daemons_start_service (struct GNUNET_TESTING_PeerGroup *pg, for (i = 0; i < pg->total; i++) { -#if DEBUG_START - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting up service %s on peer %d!\n", - service, stopped_arr[stopped_permute[i]]); -#endif peer_start_ctx = GNUNET_malloc (sizeof (struct PeerServiceStartContext)); peer_start_ctx->start_ctx = start_ctx; peer_start_ctx->daemon = pg->peers[i].daemon; @@ -6883,10 +6751,8 @@ internal_shutdown_callback (void *cls, const char *emsg) } else { -#if VERBOSE_TESTING GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "internal_shutdown_callback", "Failed to stop a peer: %s\n", emsg); -#endif shutdown_ctx->peers_failed++; } @@ -6939,22 +6805,24 @@ schedule_shutdown_task (void *cls, { struct PeerShutdownContext *peer_shutdown_ctx = cls; struct ShutdownContext *shutdown_ctx; + struct GNUNET_TESTING_Daemon *d; GNUNET_assert (peer_shutdown_ctx != NULL); + d = peer_shutdown_ctx->daemon; shutdown_ctx = peer_shutdown_ctx->shutdown_ctx; GNUNET_assert (shutdown_ctx != NULL); if ((shutdown_ctx->outstanding < shutdown_ctx->pg->max_concurrent_ssh) || - ((peer_shutdown_ctx->daemon->hostname != NULL) && + ((d->hostname != NULL) && (count_outstanding_at_host - (peer_shutdown_ctx->daemon->hostname, + (d->hostname, shutdown_ctx->pg) < shutdown_ctx->pg->max_concurrent_ssh))) { - if (peer_shutdown_ctx->daemon->hostname != NULL) - increment_outstanding_at_host (peer_shutdown_ctx->daemon->hostname, + if (d->hostname != NULL) + increment_outstanding_at_host (d->hostname, shutdown_ctx->pg); shutdown_ctx->outstanding++; - GNUNET_TESTING_daemon_stop (peer_shutdown_ctx->daemon, + GNUNET_TESTING_daemon_stop (d, shutdown_ctx->timeout, &internal_shutdown_callback, peer_shutdown_ctx, shutdown_ctx->delete_files, GNUNET_NO); @@ -7034,7 +6902,7 @@ GNUNET_TESTING_hosts_load (const struct GNUNET_CONFIGURATION_Handle *cfg) data[count] = '\0'; temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host)); ret = - sscanf (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd", + SSCANF (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd", &temphost->username, &temphost->hostname, &temphost->port); if (3 == ret) { diff --git a/src/testing/testing_new.c b/src/testing/testing_new.c new file mode 100644 index 0000000..c45b89e --- /dev/null +++ b/src/testing/testing_new.c @@ -0,0 +1,1000 @@ +/* + This file is part of GNUnet + (C) 2008, 2009, 2012 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + */ + +/** + * @file testing/testing_new.c + * @brief convenience API for writing testcases for GNUnet + * Many testcases need to start and stop a peer/service + * and this library is supposed to make that easier + * for TESTCASES. Normal programs should always + * use functions from gnunet_{util,arm}_lib.h. This API is + * ONLY for writing testcases (or internal use of the testbed). + * @author Christian Grothoff + * + */ +#include "platform.h" +#include "gnunet_util_lib.h" +#include "gnunet_testing_lib-new.h" + +#define LOG(kind,...) \ + GNUNET_log_from (kind, "gnunettestingnew", __VA_ARGS__) + + +/** + * Size of a hostkey when written to a file + */ +#define HOSTKEYFILESIZE 914 + + +/** + * Handle for a system on which GNUnet peers are executed; + * a system is used for reserving unique paths and ports. + */ +struct GNUNET_TESTING_System +{ + /** + * Prefix (i.e. "/tmp/gnunet-testing/") we prepend to each + * SERVICEHOME. + */ + char *tmppath; + + /** + * The hostname of the controller + */ + char *controller; + + /** + * Hostkeys data, contains "HOSTKEYFILESIZE * total_hostkeys" bytes. + */ + char *hostkeys_data; + + /** + * Bitmap where each TCP port that has already been reserved for + * some GNUnet peer is recorded. Note that we additionally need to + * test if a port is already in use by non-GNUnet components before + * assigning it to a peer/service. If we detect that a port is + * already in use, we also mark it in this bitmap. So all the bits + * that are zero merely indicate ports that MIGHT be available for + * peers. + */ + uint32_t reserved_tcp_ports[65536 / 32]; + + /** + * Bitmap where each UDP port that has already been reserved for + * some GNUnet peer is recorded. Note that we additionally need to + * test if a port is already in use by non-GNUnet components before + * assigning it to a peer/service. If we detect that a port is + * already in use, we also mark it in this bitmap. So all the bits + * that are zero merely indicate ports that MIGHT be available for + * peers. + */ + uint32_t reserved_udp_ports[65536 / 32]; + + /** + * Counter we use to make service home paths unique on this system; + * the full path consists of the tmppath and this number. Each + * UNIXPATH for a peer is also modified to include the respective + * path counter to ensure uniqueness. This field is incremented + * by one for each configured peer. Even if peers are destroyed, + * we never re-use path counters. + */ + uint32_t path_counter; + + /** + * The number of hostkeys + */ + uint32_t total_hostkeys; +}; + + +/** + * Handle for a GNUnet peer controlled by testing. + */ +struct GNUNET_TESTING_Peer +{ + + /** + * Path to the configuration file for this peer. + */ + char *cfgfile; + + /** + * Binary to be executed during 'GNUNET_TESTING_peer_start'. + * Typically 'gnunet-service-arm' (but can be set to a + * specific service by 'GNUNET_TESTING_service_run' if + * necessary). + */ + char *main_binary; + + /** + * Handle to the running binary of the service, NULL if the + * peer/service is currently not running. + */ + struct GNUNET_OS_Process *main_process; +}; + + +/** + * Lowest port used for GNUnet testing. Should be high enough to not + * conflict with other applications running on the hosts but be low + * enough to not conflict with client-ports (typically starting around + * 32k). + */ +#define LOW_PORT 12000 + + +/** + * Highest port used for GNUnet testing. Should be low enough to not + * conflict with the port range for "local" ports (client apps; see + * /proc/sys/net/ipv4/ip_local_port_range on Linux for example). + */ +#define HIGH_PORT 56000 + + +/** + * Create a system handle. There must only be one system + * handle per operating system. + * + * @param tmppath prefix path to use for all service homes + * @param controller hostname of the controlling host, + * service configurations are modified to allow + * control connections from this host; can be NULL + * @return handle to this system, NULL on error + */ +struct GNUNET_TESTING_System * +GNUNET_TESTING_system_create (const char *tmppath, + const char *controller) +{ + struct GNUNET_TESTING_System *system; + + if (NULL == tmppath) + { + LOG (GNUNET_ERROR_TYPE_ERROR, _("tmppath cannot be NULL\n")); + return NULL; + } + system = GNUNET_malloc (sizeof (struct GNUNET_TESTING_System)); + system->tmppath = GNUNET_strdup (tmppath); + if (NULL != controller) + system->controller = GNUNET_strdup (controller); + return system; +} + + +/** + * Free system resources. + * + * @param system system to be freed + * @param remove_paths should the 'tmppath' and all subdirectories + * be removed (clean up on shutdown)? + */ +void +GNUNET_TESTING_system_destroy (struct GNUNET_TESTING_System *system, + int remove_paths) +{ + if (NULL != system->hostkeys_data) + { + GNUNET_break (0); /* Use GNUNET_TESTING_hostkeys_unload() */ + GNUNET_TESTING_hostkeys_unload (system); + } + if (GNUNET_YES == remove_paths) + GNUNET_DISK_directory_remove (system->tmppath); + GNUNET_free (system->tmppath); + GNUNET_free_non_null (system->controller); + GNUNET_free (system); +} + + +/** + * Reserve a TCP or UDP port for a peer. + * + * @param system system to use for reservation tracking + * @param is_tcp GNUNET_YES for TCP ports, GNUNET_NO for UDP + * @return 0 if no free port was available + */ +uint16_t +GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system, + int is_tcp) +{ + struct GNUNET_NETWORK_Handle *socket; + struct addrinfo hint; + struct addrinfo *ret; + uint32_t *port_buckets; + char *open_port_str; + int bind_status; + uint32_t xor_image; + uint16_t index; + uint16_t open_port; + uint16_t pos; + + /* + FIXME: Instead of using getaddrinfo we should try to determine the port + status by the following heurestics. + + On systems which support both IPv4 and IPv6, only ports open on both + address families are considered open. + On system with either IPv4 or IPv6. A port is considered open if it's + open in the respective address family + */ + hint.ai_family = AF_UNSPEC; /* IPv4 and IPv6 */ + hint.ai_socktype = (GNUNET_YES == is_tcp)? SOCK_STREAM : SOCK_DGRAM; + hint.ai_protocol = 0; + hint.ai_addrlen = 0; + hint.ai_addr = NULL; + hint.ai_canonname = NULL; + hint.ai_next = NULL; + hint.ai_flags = AI_PASSIVE | AI_NUMERICSERV; /* Wild card address */ + port_buckets = (GNUNET_YES == is_tcp) ? + system->reserved_tcp_ports : system->reserved_udp_ports; + for (index = (LOW_PORT / 32) + 1; index < (HIGH_PORT / 32); index++) + { + xor_image = (UINT32_MAX ^ port_buckets[index]); + if (0 == xor_image) /* Ports in the bucket are full */ + continue; + pos = 0; + while (pos < 32) + { + if (0 == ((xor_image >> pos) & 1U)) + { + pos++; + continue; + } + open_port = (index * 32) + pos; + GNUNET_asprintf (&open_port_str, "%u", (unsigned int) open_port); + ret = NULL; + GNUNET_assert (0 == getaddrinfo (NULL, open_port_str, &hint, &ret)); + GNUNET_free (open_port_str); + socket = GNUNET_NETWORK_socket_create (ret->ai_family, + (GNUNET_YES == is_tcp) ? + SOCK_STREAM : SOCK_DGRAM, + 0); + GNUNET_assert (NULL != socket); + bind_status = GNUNET_NETWORK_socket_bind (socket, + ret->ai_addr, + ret->ai_addrlen); + freeaddrinfo (ret); + GNUNET_NETWORK_socket_close (socket); + socket = NULL; + port_buckets[index] |= (1U << pos); /* Set the port bit */ + if (GNUNET_OK == bind_status) + { + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Found a free port %u\n", (unsigned int) open_port); + return open_port; + } + pos++; + } + } + return 0; +} + + +/** + * Release reservation of a TCP or UDP port for a peer + * (used during GNUNET_TESTING_peer_destroy). + * + * @param system system to use for reservation tracking + * @param is_tcp GNUNET_YES for TCP ports, GNUNET_NO for UDP + * @param port reserved port to release + */ +void +GNUNET_TESTING_release_port (struct GNUNET_TESTING_System *system, + int is_tcp, + uint16_t port) +{ + uint32_t *port_buckets; + uint16_t bucket; + uint16_t pos; + + port_buckets = (GNUNET_YES == is_tcp) ? + system->reserved_tcp_ports : system->reserved_udp_ports; + bucket = port / 32; + pos = port % 32; + LOG (GNUNET_ERROR_TYPE_DEBUG, "Releasing port %u\n", port); + if (0 == (port_buckets[bucket] & (1U << pos))) + { + GNUNET_break(0); /* Port was not reserved by us using reserve_port() */ + return; + } + port_buckets[bucket] &= ~(1U << pos); +} + + +/** + * Reserve a SERVICEHOME path for a peer. + * + * @param system system to use for reservation tracking + * @return NULL on error, otherwise fresh unique path to use + * as the servicehome for the peer; must be freed by the caller + */ +// static +char * +reserve_path (struct GNUNET_TESTING_System *system) +{ + char *reserved_path; + + GNUNET_asprintf (&reserved_path, + "%s/%u", system->tmppath, system->path_counter++); + return reserved_path; +} + + +/** + * Testing includes a number of pre-created hostkeys for faster peer + * startup. This function loads such keys into memory from a file. + * + * @param system the testing system handle + * @param filename the path of the hostkeys file + * @return GNUNET_OK on success; GNUNET_SYSERR on error + */ +int +GNUNET_TESTING_hostkeys_load (struct GNUNET_TESTING_System *system, + const char *filename) +{ + struct GNUNET_DISK_FileHandle *fd; + uint64_t fs; + + if (GNUNET_YES != GNUNET_DISK_file_test (filename)) + { + LOG (GNUNET_ERROR_TYPE_ERROR, + _("Hostkeys file not found: %s\n"), filename); + return GNUNET_SYSERR; + } + /* Check hostkey file size, read entire thing into memory */ + fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, + GNUNET_DISK_PERM_NONE); + if (NULL == fd) + { + LOG (GNUNET_ERROR_TYPE_ERROR, + _("Could not open hostkeys file: %s\n"), filename); + return GNUNET_SYSERR; + } + if (GNUNET_OK != + GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES)) + fs = 0; + if (0 == fs) + { + GNUNET_DISK_file_close (fd); + return GNUNET_SYSERR; /* File is empty */ + } + if (0 != (fs % HOSTKEYFILESIZE)) + { + GNUNET_DISK_file_close (fd); + LOG (GNUNET_ERROR_TYPE_ERROR, + _("Incorrect hostkey file format: %s\n"), filename); + return GNUNET_SYSERR; + } + GNUNET_break (NULL == system->hostkeys_data); + system->total_hostkeys = fs / HOSTKEYFILESIZE; + system->hostkeys_data = GNUNET_malloc_large (fs); /* free in hostkeys_unload */ + GNUNET_assert (fs == GNUNET_DISK_file_read (fd, system->hostkeys_data, fs)); + GNUNET_DISK_file_close (fd); + return GNUNET_OK; +} + + +/** + * Function to remove the loaded hostkeys + * + * @param system the testing system handle + */ +void +GNUNET_TESTING_hostkeys_unload (struct GNUNET_TESTING_System *system) +{ + GNUNET_break (NULL != system->hostkeys_data); + GNUNET_free_non_null (system->hostkeys_data); + system->hostkeys_data = NULL; + system->total_hostkeys = 0; +} + + +/** + * Testing includes a number of pre-created hostkeys for + * faster peer startup. This function can be used to + * access the n-th key of those pre-created hostkeys; note + * that these keys are ONLY useful for testing and not + * secure as the private keys are part of the public + * GNUnet source code. + * + * This is primarily a helper function used internally + * by 'GNUNET_TESTING_peer_configure'. + * + * @param system the testing system handle + * @param key_number desired pre-created hostkey to obtain + * @param id set to the peer's identity (hash of the public + * key; if NULL, GNUNET_SYSERR is returned immediately + * @return GNUNET_SYSERR on error (not enough keys) + */ +int +GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system, + uint32_t key_number, + struct GNUNET_PeerIdentity *id) +{ + struct GNUNET_CRYPTO_RsaPrivateKey *private_key; + struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded public_key; + + if ((NULL == id) || (NULL == system->hostkeys_data)) + return GNUNET_SYSERR; + if (key_number >= system->total_hostkeys) + { + LOG (GNUNET_ERROR_TYPE_ERROR, + _("Key number %u does not exist\n"), key_number); + return GNUNET_SYSERR; + } + private_key = GNUNET_CRYPTO_rsa_decode_key (system->hostkeys_data + + (key_number * HOSTKEYFILESIZE), + HOSTKEYFILESIZE); + if (NULL == private_key) + { + LOG (GNUNET_ERROR_TYPE_ERROR, + _("Error while decoding key %u\n"), key_number); + return GNUNET_SYSERR; + } + GNUNET_CRYPTO_rsa_key_get_public (private_key, &public_key); + GNUNET_CRYPTO_hash (&public_key, + sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), + &(id->hashPubKey)); + GNUNET_CRYPTO_rsa_key_free (private_key); + return GNUNET_OK; +} + + +/** + * Structure for holding data to build new configurations from a configuration + * template + */ +struct UpdateContext +{ + /** + * The system for which we are building configurations + */ + struct GNUNET_TESTING_System *system; + + /** + * The configuration we are building + */ + struct GNUNET_CONFIGURATION_Handle *cfg; + + /** + * The customized service home path for this peer + */ + char *service_home; + + /** + * build status - to signal error while building a configuration + */ + int status; +}; + + +/** + * Function to iterate over options. Copies + * the options to the target configuration, + * updating PORT values as needed. + * + * @param cls the UpdateContext + * @param section name of the section + * @param option name of the option + * @param value value of the option + */ +static void +update_config (void *cls, const char *section, const char *option, + const char *value) +{ + struct UpdateContext *uc = cls; + unsigned int ival; + char cval[12]; + char uval[128]; + char *single_variable; + char *per_host_variable; + unsigned long long num_per_host; + uint16_t new_port; + + if (GNUNET_OK != uc->status) + return; + if (! ((0 == strcmp (option, "PORT")) + || (0 == strcmp (option, "UNIXPATH")) + || (0 == strcmp (option, "HOSTNAME")))) + return; + GNUNET_asprintf (&single_variable, "single_%s_per_host", section); + GNUNET_asprintf (&per_host_variable, "num_%s_per_host", section); + if ((0 == strcmp (option, "PORT")) && (1 == SSCANF (value, "%u", &ival))) + { + if ((ival != 0) && + (GNUNET_YES != + GNUNET_CONFIGURATION_get_value_yesno (uc->cfg, "testing", + single_variable))) + { + /* FIXME: What about UDP? */ + new_port = GNUNET_TESTING_reserve_port (uc->system, GNUNET_YES); + if (0 == new_port) + { + uc->status = GNUNET_SYSERR; + return; + } + GNUNET_snprintf (cval, sizeof (cval), "%u", new_port); + value = cval; + } + else if ((ival != 0) && + (GNUNET_YES == + GNUNET_CONFIGURATION_get_value_yesno (uc->cfg, "testing", + single_variable)) && + GNUNET_CONFIGURATION_get_value_number (uc->cfg, "testing", + per_host_variable, + &num_per_host)) + { + /* GNUNET_snprintf (cval, sizeof (cval), "%u", */ + /* ival + ctx->fdnum % num_per_host); */ + /* value = cval; */ + GNUNET_break (0); /* FIXME */ + } + } + if (0 == strcmp (option, "UNIXPATH")) + { + if (GNUNET_YES != + GNUNET_CONFIGURATION_get_value_yesno (uc->cfg, "testing", + single_variable)) + { + GNUNET_snprintf (uval, sizeof (uval), "%s/%s.sock", + uc->service_home, section); + value = uval; + } + else if ((GNUNET_YES == + GNUNET_CONFIGURATION_get_value_number (uc->cfg, "testing", + per_host_variable, + &num_per_host)) && + (num_per_host > 0)) + { + GNUNET_break(0); /* FIXME */ + } + } + if ((0 == strcmp (option, "HOSTNAME")) && (NULL != uc->system->controller)) + { + value = uc->system->controller; + } + GNUNET_free (single_variable); + GNUNET_free (per_host_variable); + GNUNET_CONFIGURATION_set_value_string (uc->cfg, section, option, value); +} + + +/** + * Section iterator to set ACCEPT_FROM in all sections + * + * @param cls the UpdateContext + * @param section name of the section + */ +static void +update_config_sections (void *cls, + const char *section) +{ + struct UpdateContext *uc = cls; + char *orig_allowed_hosts; + char *allowed_hosts; + + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, "ACCEPT_FROM", + &orig_allowed_hosts)) + { + orig_allowed_hosts = GNUNET_strdup ("127.0.0.1;"); + } + if (NULL == uc->system->controller) + allowed_hosts = GNUNET_strdup (orig_allowed_hosts); + else + GNUNET_asprintf (&allowed_hosts, "%s %s;", orig_allowed_hosts, + uc->system->controller); + GNUNET_free (orig_allowed_hosts); + GNUNET_CONFIGURATION_set_value_string (uc->cfg, section, "ACCEPT_FROM", + allowed_hosts); + GNUNET_free (allowed_hosts); +} + + +/** + * Create a new configuration using the given configuration + * as a template; ports and paths will be modified to select + * available ports on the local system. If we run + * out of "*port" numbers, return SYSERR. + * + * This is primarily a helper function used internally + * by 'GNUNET_TESTING_peer_configure'. + * + * @param system system to use to coordinate resource usage + * @param cfg template configuration to update + * @return GNUNET_OK on success, GNUNET_SYSERR on error - the configuration will + * be incomplete and should not be used there upon + */ +int +GNUNET_TESTING_configuration_create (struct GNUNET_TESTING_System *system, + struct GNUNET_CONFIGURATION_Handle *cfg) +{ + struct UpdateContext uc; + + uc.system = system; + uc.cfg = cfg; + uc.status = GNUNET_OK; + GNUNET_asprintf (&uc.service_home, "%s/%u", system->tmppath, + system->path_counter++); + GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "SERVICEHOME", + uc.service_home); + /* make PORTs and UNIXPATHs unique */ + GNUNET_CONFIGURATION_iterate (cfg, &update_config, &uc); + /* allow connections to services from system controller host */ + GNUNET_CONFIGURATION_iterate_sections (cfg, &update_config_sections, &uc); + /* enable loopback-based connections between peers */ + GNUNET_CONFIGURATION_set_value_string (cfg, + "nat", + "USE_LOCALADDR", "YES"); + GNUNET_free (uc.service_home); + return uc.status; +} + + +/** + * Configure a GNUnet peer. GNUnet must be installed on the local + * system and available in the PATH. + * + * @param system system to use to coordinate resource usage + * @param cfg configuration to use; will be UPDATED (to reflect needed + * changes in port numbers and paths) + * @param key_number number of the hostkey to use for the peer + * @param id identifier for the daemon, will be set, can be NULL + * @param emsg set to error message (set to NULL on success), can be NULL + * @return handle to the peer, NULL on error + */ +struct GNUNET_TESTING_Peer * +GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system, + struct GNUNET_CONFIGURATION_Handle *cfg, + uint32_t key_number, + struct GNUNET_PeerIdentity *id, + char **emsg) +{ + struct GNUNET_TESTING_Peer *peer; + struct GNUNET_DISK_FileHandle *fd; + char *service_home; + char hostkey_filename[128]; + char *config_filename; + char *emsg_; + + if (NULL != emsg) + *emsg = NULL; + if (GNUNET_OK != GNUNET_TESTING_configuration_create (system, cfg)) + { + GNUNET_asprintf (&emsg_, + _("Failed to create configuration for peer (not enough free ports?)\n")); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", *emsg_); + if (NULL != emsg) + *emsg = emsg_; + else + GNUNET_free (emsg_); + return NULL; + } + if (key_number >= system->total_hostkeys) + { + GNUNET_asprintf (&emsg_, + _("You attempted to create a testbed with more than %u hosts. Please precompute more hostkeys first.\n"), + (unsigned int) system->total_hostkeys); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", *emsg_); + if (NULL != emsg) + *emsg = emsg_; + else + GNUNET_free (emsg_); + return NULL; + } + if ((NULL != id) && + (GNUNET_SYSERR == GNUNET_TESTING_hostkey_get (system, key_number, id))) + { + GNUNET_asprintf (&emsg_, + _("Failed to initialize hostkey for peer %u\n"), + (unsigned int) key_number); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", *emsg_); + if (NULL != emsg) + *emsg = emsg_; + else + GNUNET_free (emsg_); + return NULL; + } + GNUNET_assert (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", + "SERVICEHOME", + &service_home)); + GNUNET_snprintf (hostkey_filename, sizeof (hostkey_filename), "%s/.hostkey", + service_home); + fd = GNUNET_DISK_file_open (hostkey_filename, + GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_WRITE, + GNUNET_DISK_PERM_USER_READ + | GNUNET_DISK_PERM_USER_WRITE); + if (NULL == fd) + { + GNUNET_break (0); + return NULL; + } + if (HOSTKEYFILESIZE != + GNUNET_DISK_file_write (fd, system->hostkeys_data + + (key_number * HOSTKEYFILESIZE), + HOSTKEYFILESIZE)) + { + GNUNET_asprintf (&emsg_, + _("Failed to write hostkey file for peer %u: %s\n"), + (unsigned int) key_number, + STRERROR (errno)); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", *emsg_); + if (NULL != emsg) + *emsg = emsg_; + else + GNUNET_free (emsg_); + GNUNET_DISK_file_close (fd); + return NULL; + } + GNUNET_DISK_file_close (fd); + GNUNET_asprintf (&config_filename, "%s/config", service_home); + GNUNET_free (service_home); + if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, config_filename)) + { + GNUNET_asprintf (&emsg_, + _("Failed to write configuration file `%s' for peer %u: %s\n"), + config_filename, + (unsigned int) key_number, + STRERROR (errno)); + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s", *emsg_); + if (NULL != emsg) + *emsg = emsg_; + else + GNUNET_free (emsg_); + return NULL; + } + peer = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Peer)); + peer->cfgfile = config_filename; /* Free in peer_destroy */ + peer->main_binary = GNUNET_strdup ("gnunet-service-arm"); + return peer; +} + + +/** + * Start the peer. + * + * @param peer peer to start + * @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer already running) + */ +int +GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer) +{ + if (NULL != peer->main_process) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + GNUNET_assert (NULL != peer->cfgfile); + peer->main_process = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, + peer->main_binary, "-c", + peer->cfgfile, + NULL); + if (NULL == peer->main_process) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + _("Failed to start `%s': %s\n"), + peer->main_binary, + STRERROR (errno)); + return GNUNET_SYSERR; + } + return GNUNET_OK; +} + + +/** + * Stop the peer. + * + * @param peer peer to stop + * @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer not running) + */ +int +GNUNET_TESTING_peer_stop (struct GNUNET_TESTING_Peer *peer) +{ + if (NULL == peer->main_process) + { + GNUNET_break (0); + return GNUNET_SYSERR; + } + (void) GNUNET_OS_process_kill (peer->main_process, SIGTERM); + GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (peer->main_process)); + GNUNET_OS_process_destroy (peer->main_process); + peer->main_process = NULL; + return GNUNET_OK; +} + + +/** + * Destroy the peer. Releases resources locked during peer configuration. + * If the peer is still running, it will be stopped AND a warning will be + * printed (users of the API should stop the peer explicitly first). + * + * @param peer peer to destroy + */ +void +GNUNET_TESTING_peer_destroy (struct GNUNET_TESTING_Peer *peer) +{ + if (NULL != peer->main_process) + { + GNUNET_break (0); + GNUNET_TESTING_peer_stop (peer); + } + GNUNET_free (peer->cfgfile); + GNUNET_free (peer->main_binary); + GNUNET_free (peer); +} + + +/** + * Start a single peer and run a test using the testing library. + * Starts a peer using the given configuration and then invokes the + * given callback. This function ALSO initializes the scheduler loop + * and should thus be called directly from "main". The testcase + * should self-terminate by invoking 'GNUNET_SCHEDULER_shutdown'. + * + * @param tmppath path for storing temporary data for the test + * @param cfgfilename name of the configuration file to use; + * use NULL to only run with defaults + * @param tm main function of the testcase + * @param tm_cls closure for 'tm' + * @return 0 on success, 1 on error + */ +int +GNUNET_TESTING_peer_run (const char *tmppath, + const char *cfgfilename, + GNUNET_TESTING_TestMain tm, + void *tm_cls) +{ + return GNUNET_TESTING_service_run (tmppath, "arm", + cfgfilename, tm, tm_cls); +} + + +/** + * Structure for holding service data + */ +struct ServiceContext +{ + /** + * The configuration of the peer in which the service is run + */ + const struct GNUNET_CONFIGURATION_Handle *cfg; + + /** + * Callback to signal service startup + */ + GNUNET_TESTING_TestMain tm; + + /** + * Closure for the above callback + */ + void *tm_cls; +}; + + +/** + * Callback to be called when SCHEDULER has been started + * + * @param cls the ServiceContext + * @param tc the TaskContext + */ +static void +service_run_main (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + struct ServiceContext *sc = cls; + + sc->tm (sc->tm_cls, sc->cfg); +} + + +/** + * Start a single service (no ARM, except of course if the given + * service name is 'arm') and run a test using the testing library. + * Starts a service using the given configuration and then invokes the + * given callback. This function ALSO initializes the scheduler loop + * and should thus be called directly from "main". The testcase + * should self-terminate by invoking 'GNUNET_SCHEDULER_shutdown'. + * + * This function is useful if the testcase is for a single service + * and if that service doesn't itself depend on other services. + * + * @param tmppath path for storing temporary data for the test + * @param service_name name of the service to run + * @param cfgfilename name of the configuration file to use; + * use NULL to only run with defaults + * @param tm main function of the testcase + * @param tm_cls closure for 'tm' + * @return 0 on success, 1 on error + */ +int +GNUNET_TESTING_service_run (const char *tmppath, + const char *service_name, + const char *cfgfilename, + GNUNET_TESTING_TestMain tm, + void *tm_cls) +{ + struct ServiceContext sc; + struct GNUNET_TESTING_System *system; + struct GNUNET_TESTING_Peer *peer; + struct GNUNET_CONFIGURATION_Handle *cfg; + char *data_dir; + char *hostkeys_file; + + data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); + GNUNET_asprintf (&hostkeys_file, "%s/testing_hostkeys.dat", data_dir); + GNUNET_free (data_dir); + system = GNUNET_TESTING_system_create (tmppath, "localhost"); + if (NULL == system) + { + GNUNET_free (hostkeys_file); + return 1; + } + if (GNUNET_OK != GNUNET_TESTING_hostkeys_load (system, hostkeys_file)) + { + GNUNET_free (hostkeys_file); + GNUNET_TESTING_system_destroy (system, GNUNET_YES); + return 1; + } + GNUNET_free (hostkeys_file); + cfg = GNUNET_CONFIGURATION_create (); + if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfgfilename)) + { + LOG (GNUNET_ERROR_TYPE_ERROR, + _("Failed to load configuration from %s\n"), cfgfilename); + GNUNET_CONFIGURATION_destroy (cfg); + GNUNET_TESTING_system_destroy (system, GNUNET_YES); + return 1; + } + peer = GNUNET_TESTING_peer_configure (system, cfg, 0, NULL, NULL); + if (NULL == peer) + { + GNUNET_CONFIGURATION_destroy (cfg); + GNUNET_TESTING_hostkeys_unload (system); + GNUNET_TESTING_system_destroy (system, GNUNET_YES); + return 1; + } + GNUNET_TESTING_hostkeys_unload (system); + GNUNET_free (peer->main_binary); + GNUNET_asprintf (&peer->main_binary, "gnunet-service-%s", service_name); + if (GNUNET_OK != GNUNET_TESTING_peer_start (peer)) + { + GNUNET_TESTING_peer_destroy (peer); + GNUNET_CONFIGURATION_destroy (cfg); + GNUNET_TESTING_system_destroy (system, GNUNET_YES); + return 1; + } + sc.cfg = cfg; + sc.tm = tm; + sc.tm_cls = tm_cls; + GNUNET_SCHEDULER_run (&service_run_main, &sc); /* Scheduler loop */ + if (GNUNET_OK != GNUNET_TESTING_peer_stop (peer)) + { + GNUNET_TESTING_peer_destroy (peer); + GNUNET_CONFIGURATION_destroy (cfg); + GNUNET_TESTING_system_destroy (system, GNUNET_YES); + return 1; + } + GNUNET_TESTING_peer_destroy (peer); + GNUNET_CONFIGURATION_destroy (cfg); + GNUNET_TESTING_system_destroy (system, GNUNET_YES); + return 0; +} + + +/* end of testing_new.c */ diff --git a/src/testing/testing_peergroup.c b/src/testing/testing_peergroup.c index 0119d66..87504ed 100644 --- a/src/testing/testing_peergroup.c +++ b/src/testing/testing_peergroup.c @@ -445,46 +445,56 @@ internal_topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, pg_start_ctx->connect_cb (pg_start_ctx->cls, first, second, distance, first_cfg, second_cfg, first_daemon, second_daemon, emsg); - if (GNUNET_YES == update_meter (pg_start_ctx->connect_meter)) + if (GNUNET_YES != update_meter (pg_start_ctx->connect_meter)) { + /* No finished yet */ + return; + } #if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Created %d total connections, which is our target number! Starting next phase of testing.\n", - pg_start_ctx->total_connections); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Created %d total connections, which is our target number! Starting next phase of testing.\n", + pg_start_ctx->total_connections); #endif #if TIMING - total_duration = - GNUNET_TIME_absolute_get_difference (connect_start_time, - GNUNET_TIME_absolute_get - ()).rel_value / 1000; - failed_conns_per_sec_total = (double) failed_connections / total_duration; - conns_per_sec_total = (double) total_connections / total_duration; - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Overall connection info --- Total: %u, Total Failed %u/s\n", - total_connections, failed_connections); - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "Overall connection info --- Total: %.2f/s, Total Failed %.2f/s\n", - conns_per_sec_total, failed_conns_per_sec_total); + total_duration = + GNUNET_TIME_absolute_get_difference (connect_start_time, + GNUNET_TIME_absolute_get + ()).rel_value / 1000; + failed_conns_per_sec_total = (double) failed_connections / total_duration; + conns_per_sec_total = (double) total_connections / total_duration; + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Overall connection info --- Total: %u, Total Failed %u/s\n", + total_connections, failed_connections); + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Overall connection info --- Total: %.2f/s, Total Failed %.2f/s\n", + conns_per_sec_total, failed_conns_per_sec_total); #endif - GNUNET_assert (pg_start_ctx->die_task != GNUNET_SCHEDULER_NO_TASK); - GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); + GNUNET_assert (pg_start_ctx->die_task != GNUNET_SCHEDULER_NO_TASK); + GNUNET_SCHEDULER_cancel (pg_start_ctx->die_task); - /* Call final callback, signifying that the peer group has been started and connected */ - if (pg_start_ctx->peergroup_cb != NULL) - pg_start_ctx->peergroup_cb (pg_start_ctx->cls, NULL); + /* Call final callback, signifying that the peer group has been started and connected */ + if (pg_start_ctx->peergroup_cb != NULL) + pg_start_ctx->peergroup_cb (pg_start_ctx->cls, NULL); - if (pg_start_ctx->topology_output_file != NULL) - { - temp = GNUNET_asprintf (&temp_str, "}\n"); - if (temp > 0) - GNUNET_DISK_file_write (pg_start_ctx->topology_output_file, temp_str, - temp); - GNUNET_free (temp_str); - GNUNET_DISK_file_close (pg_start_ctx->topology_output_file); - } + if (pg_start_ctx->topology_output_file != NULL) + { + temp = GNUNET_asprintf (&temp_str, "}\n"); + if (temp > 0) + GNUNET_DISK_file_write (pg_start_ctx->topology_output_file, temp_str, + temp); + GNUNET_free (temp_str); + GNUNET_DISK_file_close (pg_start_ctx->topology_output_file); } + GNUNET_free_non_null (pg_start_ctx->fail_reason); + if (NULL != pg_start_ctx->hostkey_meter) + free_meter(pg_start_ctx->hostkey_meter); + if (NULL != pg_start_ctx->peer_start_meter) + free_meter(pg_start_ctx->peer_start_meter); + if (NULL != pg_start_ctx->connect_meter) + free_meter(pg_start_ctx->connect_meter); + GNUNET_free (pg_start_ctx); } @@ -932,7 +942,7 @@ GNUNET_TESTING_peergroup_start (const struct GNUNET_CONFIGURATION_Handle *cfg, "connect_topology_option_modifier", &temp_str)) { - if (sscanf + if (SSCANF (temp_str, "%lf", &pg_start_ctx->connect_topology_option_modifier) != 1) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |