gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r37906 - gnunet/src/multicast


From: gnunet
Subject: [GNUnet-SVN] r37906 - gnunet/src/multicast
Date: Wed, 7 Sep 2016 19:45:15 +0200

Author: xrs
Date: 2016-09-07 19:45:15 +0200 (Wed, 07 Sep 2016)
New Revision: 37906

Added:
   gnunet/src/multicast/test_multicast_multipeer.c
Modified:
   gnunet/src/multicast/Makefile.am
   gnunet/src/multicast/test_multicast.c
   gnunet/src/multicast/test_multicast.conf
Log:
Add new testcase for multipeer scenario. 


Modified: gnunet/src/multicast/Makefile.am
===================================================================
--- gnunet/src/multicast/Makefile.am    2016-09-07 16:39:15 UTC (rev 37905)
+++ gnunet/src/multicast/Makefile.am    2016-09-07 17:45:15 UTC (rev 37906)
@@ -52,7 +52,8 @@
 
 
 check_PROGRAMS = \
- test_multicast
+ test_multicast \
+ test_multicast_multipeer
 
 if ENABLE_TEST_RUN
 AM_TESTS_ENVIRONMENT=export 
GNUNET_PREFIX=$${GNUNET_PREFIX:address@hidden@};export 
PATH=$${GNUNET_PREFIX:address@hidden@}/bin:$$PATH;
@@ -66,3 +67,11 @@
   $(top_builddir)/src/testing/libgnunettesting.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(top_builddir)/src/core/libgnunetcore.la
+
+test_multicast_multipeer_SOURCE = \
+ test_multicast_multipeer.c
+test_multicast_multipeer_LDADD = \
+  libgnunetmulticast.la \
+  $(top_builddir)/src/testbed/libgnunettestbed.la \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(top_builddir)/src/core/libgnunetcore.la

Modified: gnunet/src/multicast/test_multicast.c
===================================================================
--- gnunet/src/multicast/test_multicast.c       2016-09-07 16:39:15 UTC (rev 
37905)
+++ gnunet/src/multicast/test_multicast.c       2016-09-07 17:45:15 UTC (rev 
37906)
@@ -441,7 +441,7 @@
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Test #%u: verify message content, take first 3 bytes: %.3s\n", 
-              test, &req[1]);
+              test, (char *)&req[1]);
   GNUNET_assert (0 == memcmp (&req[1], "abc", 3));
 
   // Test 7 starts here 

Modified: gnunet/src/multicast/test_multicast.conf
===================================================================
--- gnunet/src/multicast/test_multicast.conf    2016-09-07 16:39:15 UTC (rev 
37905)
+++ gnunet/src/multicast/test_multicast.conf    2016-09-07 17:45:15 UTC (rev 
37906)
@@ -0,0 +1,4 @@
+[arm]
+GLOBAL_POSTFIX=-L ERROR
+
+#PREFIX = sakura -t test-multicast -e cgdb --args

Added: gnunet/src/multicast/test_multicast_multipeer.c
===================================================================
--- gnunet/src/multicast/test_multicast_multipeer.c                             
(rev 0)
+++ gnunet/src/multicast/test_multicast_multipeer.c     2016-09-07 17:45:15 UTC 
(rev 37906)
@@ -0,0 +1,172 @@
+/*
+ * This file is part of GNUnet
+ * Copyright (C) 2013 GNUnet e.V.
+ *
+ * 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/**
+ * @file multicast/test_multicast_multipeers.c
+ * @brief Tests for the Multicast API with multiple peers.
+ * @author xrs
+ */
+
+#include <inttypes.h>
+
+#include "platform.h"
+#include "gnunet_crypto_lib.h"
+#include "gnunet_common.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_testbed_service.h"
+#include "gnunet_core_service.h"
+#include "gnunet_multicast_service.h"
+
+#define NUM_PEERS 2
+
+static struct GNUNET_TESTBED_Operation *multicast_peer0;
+static struct GNUNET_TESTBED_Operation *multicast_peer1;
+
+static struct GNUNET_SCHEDULER_Task * shutdown_tid;
+
+
+/**
+ * Global result for testcase.
+ */
+static int result;
+
+
+/**
+ * Function run on CTRL-C or shutdown (i.e. success/timeout/etc.).
+ * Cleans up.
+ */
+static void
+shutdown_task (void *cls)
+{
+  shutdown_tid = NULL;
+  //if (NULL != dht_op)
+  //{
+    // GNUNET_TESTBED_operation_done (dht_op); 
+    //dht_op = NULL;
+    //dht_handle = NULL;
+  //}
+  result = GNUNET_OK;
+  GNUNET_SCHEDULER_shutdown (); /* Also kills the testbed */
+}
+
+
+static void 
+service_close_peer0 (void *cls, void *op_result) {
+  /* Disconnect from service */
+}
+
+/**
+ * Function run when service multicast has started and is providing us
+ * with a configuration file.
+ */ 
+static void *
+service_conf_peer0 (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+  /* Use the provided configuration to connect to service */
+  return NULL;
+}
+
+/**
+ * Test logic of peer "0" being origin starts here. 
+ *
+ * @param cls closure, for the example: NULL
+ * @param op should be equal to "dht_op"
+ * @param ca_result result of the connect operation, the
+ *        connection to the DHT service
+ * @param emsg error message, if testbed somehow failed to
+ *        connect to the DHT.
+ */
+static void
+service_connect_peer0 (void *cls,
+        struct GNUNET_TESTBED_Operation *op,
+        void *ca_result,
+        const char *emsg)
+{
+  /* Connection to service successful. Here we'd usually do something with 
+   * the service. */
+}
+
+/**
+ * Main function inovked from TESTBED once all of the
+ * peers are up and running.  This one then connects
+ * just to the multicast service of peer 0 and 1.
+ * Peer 0 is going to be origin.
+ * Peer 1 is going to be one member.
+ * Origin will start a multicast group and the member will try to join it. 
+ * After that we execute some multicast test. 
+ *
+ * @param cls closure
+ * @param h the run handle
+ * @param peers started peers for the test
+ * @param num_peers size of the 'peers' array
+ * @param links_succeeded number of links between peers that were created
+ * @param links_failed number of links testbed was unable to establish
+ */
+static void
+test_master (void *cls,
+             struct GNUNET_TESTBED_RunHandle *h,
+             unsigned int num_peers,
+             struct GNUNET_TESTBED_Peer **peers,
+             unsigned int links_succeeded,
+             unsigned int links_failed)
+{
+  /* Testbed is ready with peers running and connected in a pre-defined overlay
+     topology (FIXME)  */
+
+  /* connect to a peers service */
+  multicast_peer0 = GNUNET_TESTBED_service_connect
+      (NULL,                    /* Closure for operation */
+       peers[0],                /* The peer whose service to connect to */
+       "multicast",             /* The name of the service */
+       service_connect_peer0,   /* callback to call after a handle to service
+                                   is opened */
+       NULL,                    /* closure for the above callback */
+       service_conf_peer0,      /* callback to call with peer's configuration;
+                                   this should open the needed service 
connection */
+       service_close_peer0,     /* callback to be called when closing the
+                                   opened service connection */
+       NULL);                   /* closure for the above two callbacks */
+  shutdown_tid = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
+                                               &shutdown_task, NULL);
+}
+
+
+int
+main (int argc, char *argv[])
+{
+  int ret;
+
+  result = GNUNET_SYSERR;
+  ret = GNUNET_TESTBED_test_run
+      ("test-multicast-multipeer",  /* test case name */
+       "test_multicast.conf", /* template configuration */
+       NUM_PEERS,       /* number of peers to start */
+       0LL, /* Event mask - set to 0 for no event notifications */
+       NULL, /* Controller event callback */
+       NULL, /* Closure for controller event callback */
+       &test_master, /* continuation callback to be called when testbed setup 
is
+                        complete */
+       NULL); /* Closure for the test_master callback */
+  if ( (GNUNET_OK != ret) || (GNUNET_OK != result) )
+    return 1;
+  return 0;
+}
+
+/* end of test_multicast_multipeer.c */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]