[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r26945 - in gnunet/src: include testbed testing
From: |
gnunet |
Subject: |
[GNUnet-SVN] r26945 - in gnunet/src: include testbed testing |
Date: |
Fri, 19 Apr 2013 16:59:43 +0200 |
Author: harsha
Date: 2013-04-19 16:59:43 +0200 (Fri, 19 Apr 2013)
New Revision: 26945
Added:
gnunet/src/testing/test_testing_sharedservices.c
gnunet/src/testing/test_testing_sharedservices.conf
Modified:
gnunet/src/include/gnunet_testing_lib.h
gnunet/src/testbed/testbed.conf.in
gnunet/src/testing/
gnunet/src/testing/Makefile.am
gnunet/src/testing/test_testing_peerstartup.c
gnunet/src/testing/testing.c
Log:
- simple test case for service sharing in testing deployments
Modified: gnunet/src/include/gnunet_testing_lib.h
===================================================================
--- gnunet/src/include/gnunet_testing_lib.h 2013-04-19 14:58:06 UTC (rev
26944)
+++ gnunet/src/include/gnunet_testing_lib.h 2013-04-19 14:59:43 UTC (rev
26945)
@@ -111,7 +111,7 @@
GNUNET_TESTING_system_create (const char *testdir,
const char *trusted_ip,
const char *hostname,
- const struct GNUNET_TESTING_SharedService **
+ const struct GNUNET_TESTING_SharedService *
shared_services);
@@ -141,8 +141,8 @@
GNUNET_TESTING_system_create_with_portrange (const char *testdir,
const char *trusted_ip,
const char *hostname,
- const struct
- GNUNET_TESTING_SharedService **
+ const struct
+ GNUNET_TESTING_SharedService *
shared_services,
uint16_t lowport,
uint16_t highport);
Modified: gnunet/src/testbed/testbed.conf.in
===================================================================
--- gnunet/src/testbed/testbed.conf.in 2013-04-19 14:58:06 UTC (rev 26944)
+++ gnunet/src/testbed/testbed.conf.in 2013-04-19 14:59:43 UTC (rev 26945)
@@ -54,7 +54,7 @@
@UNIXONLY@ PORT = 2102
HOSTNAME = localhost
BINARY = gnunet-service-testbed-logger
-UNIXPaTH = /tmp/gnunet-gnunet-testbed-logger.sock
+UNIXPATH = /tmp/gnunet-gnunet-testbed-logger.sock
DIR = /tmp
UNIX_MATCH_UID = YES
UNIX_MATCH_GID = YES
Index: gnunet/src/testing
===================================================================
--- gnunet/src/testing 2013-04-19 14:58:06 UTC (rev 26944)
+++ gnunet/src/testing 2013-04-19 14:59:43 UTC (rev 26945)
Property changes on: gnunet/src/testing
___________________________________________________________________
Modified: svn:ignore
## -1,3 +1,4 ##
+test_testing_sharedservices
test_testing_new_servicestartup
test_testing_new_portreservation
test_testing_new_peerstartup
Modified: gnunet/src/testing/Makefile.am
===================================================================
--- gnunet/src/testing/Makefile.am 2013-04-19 14:58:06 UTC (rev 26944)
+++ gnunet/src/testing/Makefile.am 2013-04-19 14:59:43 UTC (rev 26945)
@@ -56,7 +56,8 @@
test_testing_portreservation \
test_testing_servicestartup \
test_testing_peerstartup \
- test_testing_peerstartup2
+ test_testing_peerstartup2 \
+ test_testing_sharedservices
if ENABLE_TEST_RUN
TESTS = \
@@ -64,7 +65,6 @@
test_testing_peerstartup \
test_testing_peerstartup2 \
test_testing_servicestartup
-
endif
test_testing_portreservation_SOURCES = \
@@ -91,6 +91,13 @@
$(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
+test_testing_sharedservices_SOURCES = \
+ test_testing_sharedservices.c
+test_testing_sharedservices_LDADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+
EXTRA_DIST = \
test_testing_defaults.conf
Modified: gnunet/src/testing/test_testing_peerstartup.c
===================================================================
--- gnunet/src/testing/test_testing_peerstartup.c 2013-04-19 14:58:06 UTC
(rev 26944)
+++ gnunet/src/testing/test_testing_peerstartup.c 2013-04-19 14:59:43 UTC
(rev 26945)
@@ -133,7 +133,7 @@
status = GNUNET_SYSERR;
if (GNUNET_OK !=
GNUNET_PROGRAM_run (argc, argv,
- "test_testing_new_peerstartup",
+ "test_testing_peerstartup",
"test case for peerstartup using new testing
library",
options, &run, NULL))
return 1;
Added: gnunet/src/testing/test_testing_sharedservices.c
===================================================================
--- gnunet/src/testing/test_testing_sharedservices.c
(rev 0)
+++ gnunet/src/testing/test_testing_sharedservices.c 2013-04-19 14:59:43 UTC
(rev 26945)
@@ -0,0 +1,167 @@
+/*
+ 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_sharedservices.c
+ * @brief test case for testing service sharing among peers started by testing
+ * @author Sree Harsha Totakura <address@hidden>
+ */
+
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_testing_lib.h"
+
+#define LOG(kind,...) \
+ GNUNET_log (kind, __VA_ARGS__)
+
+#define NUM_PEERS 4
+
+/**
+ * The status of the test
+ */
+int status;
+
+/**
+ * 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 *peers[NUM_PEERS];
+
+ /**
+ * 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;
+ struct GNUNET_TESTING_Peer *peer;
+ unsigned int cnt;
+
+ GNUNET_assert (NULL != test_ctx);
+ for (cnt = 0; cnt < NUM_PEERS; cnt++)
+ {
+ peer = test_ctx->peers[cnt];
+ if (NULL == peer)
+ continue;
+ (void) GNUNET_TESTING_peer_stop (peer);
+ GNUNET_TESTING_peer_destroy (peer);
+ }
+ if (NULL != test_ctx->cfg)
+ GNUNET_CONFIGURATION_destroy (test_ctx->cfg);
+ if (NULL != 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 TestingContext *test_ctx;
+ char *emsg;
+ struct GNUNET_PeerIdentity id;
+ struct GNUNET_TESTING_SharedService ss[] = {
+ {"peerinfo", cfg, 2},
+ {NULL, NULL, 0}
+ };
+ struct GNUNET_TESTING_Peer *peer;
+ unsigned int cnt;
+
+ test_ctx = GNUNET_malloc (sizeof (struct TestingContext));
+ test_ctx->system =
+ GNUNET_TESTING_system_create ("test-gnunet-testing",
+ "127.0.0.1", NULL, ss);
+ emsg = NULL;
+ if (NULL == test_ctx->system)
+ goto end;
+ test_ctx->cfg = GNUNET_CONFIGURATION_dup (cfg);
+ for (cnt = 0; cnt < NUM_PEERS; cnt++)
+ {
+ peer = GNUNET_TESTING_peer_configure (test_ctx->system,
+ test_ctx->cfg,
+ 0, &id, &emsg);
+ if (NULL == peer)
+ {
+ if (NULL != emsg)
+ printf ("Test failed upon error: %s", emsg);
+ goto end;
+ }
+ if (GNUNET_OK != GNUNET_TESTING_peer_start (peer))
+ {
+ GNUNET_TESTING_peer_destroy (peer);
+ goto end;
+ }
+ test_ctx->peers[cnt] = peer;
+ }
+ status = GNUNET_OK;
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+ &do_shutdown, test_ctx);
+ return;
+
+ end:
+ GNUNET_SCHEDULER_add_now (&do_shutdown, test_ctx);
+ GNUNET_free_non_null (emsg);
+}
+
+
+int main (int argc, char *argv[])
+{
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_END
+ };
+ char *const argv2[] = { "test_testing_sharedservices",
+ "-c", "test_testing_sharedservices.conf",
+ NULL
+ };
+
+ status = GNUNET_SYSERR;
+ if (GNUNET_OK !=
+ GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
+ "test_testing_sharedservices",
+ "test case for testing service sharing among peers
started by testing",
+ options, &run, NULL))
+ return 1;
+ return (GNUNET_OK == status) ? 0 : 3;
+}
+
+/* end of test_testing_sharedservices.c */
Copied: gnunet/src/testing/test_testing_sharedservices.conf (from rev 26921,
gnunet/src/testing/test_testing_defaults.conf)
===================================================================
--- gnunet/src/testing/test_testing_sharedservices.conf
(rev 0)
+++ gnunet/src/testing/test_testing_sharedservices.conf 2013-04-19 14:59:43 UTC
(rev 26945)
@@ -0,0 +1,84 @@
+[PATHS]
+SERVICEHOME = /tmp/test-gnunet-testing/
+
+[testbed-logger]
+PORT = 15000
+UNIXPATH = /tmp/testbed-logger.sock
+DIR = /tmp/testbed-logger
+
+[resolver]
+PORT = 2564
+
+[transport]
+PORT = 2565
+PLUGINS = tcp
+
+[transport-tcp]
+TESTING_IGNORE_KEYS = SOMETHING;KEY1;ACCEPT_FROM;
+
+[arm]
+PORT = 2566
+DEFAULTSERVICES =
+
+[statistics]
+PORT = 2567
+
+[transport-tcp]
+PORT = 2568
+BINDTO = 127.0.0.1
+
+[peerinfo]
+PORT = 2569
+AUTOSTART = NO
+
+[core]
+PORT = 2570
+
+[dht]
+AUTOSTART = NO
+
+[nat]
+DISABLEV6 = YES
+ENABLE_UPNP = NO
+BEHIND_NAT = NO
+ALLOW_NAT = NO
+INTERNAL_ADDRESS = 127.0.0.1
+EXTERNAL_ADDRESS = 127.0.0.1
+USE_LOCALADDR = NO
+
+[dns]
+AUTOSTART = NO
+
+[nse]
+AUTOSTART = NO
+
+[mesh]
+AUTOSTART = NO
+
+[datastore]
+AUTOSTART = NO
+
+[fs]
+AUTOSTART = NO
+
+[dv]
+AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
+
+[vpn]
+AUTOSTART = NO
+
+[gns]
+AUTOSTART = NO
+
+[namestore]
+AUTOSTART = NO
+
+[lockmanager]
+AUTOSTART = NO
+
+[consensus]
+AUTOSTART = NO
+
Modified: gnunet/src/testing/testing.c
===================================================================
--- gnunet/src/testing/testing.c 2013-04-19 14:58:06 UTC (rev 26944)
+++ gnunet/src/testing/testing.c 2013-04-19 14:59:43 UTC (rev 26945)
@@ -385,13 +385,13 @@
const char *trusted_ip,
const char *hostname,
const struct
- GNUNET_TESTING_SharedService **
+ GNUNET_TESTING_SharedService *
shared_services,
uint16_t lowport,
uint16_t highport)
{
struct GNUNET_TESTING_System *system;
- const struct GNUNET_TESTING_SharedService *tss;
+ struct GNUNET_TESTING_SharedService tss;
struct SharedService *ss;
unsigned int cnt;
@@ -416,17 +416,17 @@
}
if (NULL == shared_services)
return system;
- for (cnt = 0; NULL != (tss = shared_services[cnt]); cnt++)
+ for (cnt = 0; NULL != shared_services[cnt].service; cnt++)
{
+ tss = shared_services[cnt];
ss = GNUNET_malloc (sizeof (struct SharedService));
- ss->sname = GNUNET_strdup (tss->service);
- ss->cfg = GNUNET_CONFIGURATION_dup (tss->cfg);
+ ss->sname = GNUNET_strdup (tss.service);
ss->cfg = GNUNET_CONFIGURATION_create ();
- GNUNET_CONFIGURATION_iterate_section_values (tss->cfg, ss->sname,
+ GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, ss->sname,
&cfg_copy_iterator, ss->cfg);
- GNUNET_CONFIGURATION_iterate_section_values (tss->cfg, "TESTING",
+ GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, "TESTING",
&cfg_copy_iterator, ss->cfg);
- ss->share = tss->share;
+ ss->share = tss.share;
GNUNET_array_append (system->shared_services, system->n_shared_services,
ss);
}
@@ -456,7 +456,7 @@
GNUNET_TESTING_system_create (const char *testdir,
const char *trusted_ip,
const char *hostname,
- const struct GNUNET_TESTING_SharedService **
+ const struct GNUNET_TESTING_SharedService *
shared_services)
{
return GNUNET_TESTING_system_create_with_portrange (testdir,
@@ -486,18 +486,22 @@
start_shared_service_instance (struct SharedServiceInstance *i)
{
char *binary;
+ char *libexec_binary;
GNUNET_assert (NULL == i->proc);
GNUNET_assert (NULL != i->cfg_fn);
(void) GNUNET_asprintf (&binary, "gnunet-service-%s", i->ss->sname);
+ libexec_binary = GNUNET_OS_get_libexec_binary_path (binary);
+ GNUNET_free (binary);
i->proc = GNUNET_OS_start_process (PIPE_CONTROL,
GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
NULL, NULL,
- binary,
- binary,
+ libexec_binary,
+ libexec_binary,
"-c",
i->cfg_fn,
NULL);
+ GNUNET_free (libexec_binary);
if (NULL == i->proc)
return GNUNET_SYSERR;
return GNUNET_OK;
@@ -1004,6 +1008,7 @@
(void) GNUNET_asprintf (&i->cfg_fn, "%s/config", service_home);
GNUNET_CONFIGURATION_set_value_string (temp, "PATHS", "SERVICEHOME",
service_home);
+ GNUNET_free (service_home);
GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "UNIXPATH",
i->unix_sock);
GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "PORT",
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r26945 - in gnunet/src: include testbed testing,
gnunet <=