gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r486 - GNUnet/src/applications/gap


From: grothoff
Subject: [GNUnet-SVN] r486 - GNUnet/src/applications/gap
Date: Fri, 25 Mar 2005 14:16:18 -0800 (PST)

Author: grothoff
Date: 2005-03-25 14:16:17 -0800 (Fri, 25 Mar 2005)
New Revision: 486

Added:
   GNUnet/src/applications/gap/gaptest.c
   GNUnet/src/applications/gap/peer1.conf
   GNUnet/src/applications/gap/peer1/
   GNUnet/src/applications/gap/peer2.conf
   GNUnet/src/applications/gap/peer2/
Modified:
   GNUnet/src/applications/gap/Makefile.am
Log:
towards gaptest

Modified: GNUnet/src/applications/gap/Makefile.am
===================================================================
--- GNUnet/src/applications/gap/Makefile.am     2005-03-25 22:15:51 UTC (rev 
485)
+++ GNUnet/src/applications/gap/Makefile.am     2005-03-25 22:16:17 UTC (rev 
486)
@@ -15,3 +15,21 @@
   -export-dynamic -avoid-version -module \
   $(LDADD)
 
+
+
+check_PROGRAMS = \
+  gaptest 
+
+TESTS = $(check_PROGRAMS)
+
+gaptest_SOURCES = \
+  gaptest.c 
+gaptest_LDADD = \
+  $(top_builddir)/src/applications/fs/lib/libgnunetfs.la \
+  $(top_builddir)/src/util/libgnunetutil.la 
+
+EXTRA_DIST = \
+  peer1.conf \
+  peer2.conf \
+  peer1/.hostkey \
+  peer2/.hostkey 

Added: GNUnet/src/applications/gap/gaptest.c
===================================================================
--- GNUnet/src/applications/gap/gaptest.c       2005-03-25 22:15:51 UTC (rev 
485)
+++ GNUnet/src/applications/gap/gaptest.c       2005-03-25 22:16:17 UTC (rev 
486)
@@ -0,0 +1,206 @@
+/*
+     This file is part of GNUnet.
+     (C) 2005 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 2, 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 applications/session/sessiontest.c
+ * @brief Session establishment testcase
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "gnunet_protocols.h"
+#include "gnunet_stats_lib.h"
+#include <sys/wait.h>
+
+static int parseOptions(int argc,
+                       char ** argv) {
+  FREENONNULL(setConfigurationString("GNUNETD",
+                                    "LOGFILE",
+                                    NULL));
+  return OK;
+}
+
+/**
+ * Identity of peer 2 (hardwired).
+ */
+static PeerIdentity peer2;
+
+static int waitForConnect(const char * name,
+                         unsigned long long value,
+                         void * cls) {
+  if ( (value > 0) &&
+       (0 == strcmp(_("# of connected peers"),
+                   name)) )
+    return SYSERR;
+  return OK;
+}
+
+/**
+ * Testcase to test p2p session key exchange.
+ *
+ * @param argc number of arguments from the command line
+ * @param argv command line arguments
+ * @return 0: ok, -1: error
+ */
+int main(int argc, char ** argv) {
+  pid_t daemon1;
+  pid_t daemon2;
+  int ret;
+  int status;
+  GNUNET_TCP_SOCKET * sock;
+  int left;
+
+  GNUNET_ASSERT(OK ==
+               enc2hash("BV3AS3KMIIBVIFCGEG907N6NTDTH26B7T6FODUSLSGK"
+                        "5B2Q58IEU1VF5FTR838449CSHVBOAHLDVQAOA33O77F"
+                        "OPDA8F1VIKESLSNBO",
+                        &peer2.hashPubKey));
+  daemon1 = fork();
+  if (daemon1 == 0) {
+    if (0 != execlp("gnunetd", /* what binary to execute, must be in $PATH! */
+                   "gnunetd", /* arg0, path to gnunet binary */
+                   "-d",  /* do not daemonize so we can easily kill you */
+                   "-c",
+                   "peer1.conf", /* configuration file */
+                   NULL)) {
+      fprintf(stderr,
+             _("'%s' failed: %s\n"),
+             "execlp",
+             STRERROR(errno));
+      return -1;
+    }
+  }
+  daemon2 = fork();
+  if (daemon2 == 0) {
+    if (0 != execlp("gnunetd", /* what binary to execute, must be in $PATH! */
+                   "gnunetd", /* arg0, path to gnunet binary */
+                   "-d",  /* do not daemonize so we can easily kill you */
+                   "-c",
+                   "peer2.conf", /* configuration file */
+                   NULL)) {
+      fprintf(stderr,
+             _("'%s' failed: %s\n"),
+             "execlp",
+             STRERROR(errno));
+      return -1;
+    }
+  }
+  /* in case existing HELOs have expired */
+  sleep(5);
+  system("cp peer1/data/hosts/* peer2/data/hosts/");
+  system("cp peer2/data/hosts/* peer1/data/hosts/");
+  if (daemon1 != -1) {
+    if (0 != kill(daemon1, SIGTERM))
+      DIE_STRERROR("kill");
+    if (daemon1 != waitpid(daemon1, &status, 0))
+      DIE_STRERROR("waitpid");
+  }
+  if (daemon2 != -1) {
+    if (0 != kill(daemon2, SIGTERM))
+      DIE_STRERROR("kill");
+    if (daemon2 != waitpid(daemon2, &status, 0))
+      DIE_STRERROR("waitpid");
+  }
+
+  /* re-start, this time we're sure up-to-date HELOs are available */
+  daemon1 = fork();
+  if (daemon1 == 0) {
+    if (0 != execlp("gnunetd", /* what binary to execute, must be in $PATH! */
+                   "gnunetd", /* arg0, path to gnunet binary */
+                   "-d",  /* do not daemonize so we can easily kill you */
+                   "-c",
+                   "peer1.conf", /* configuration file */
+                   NULL)) {
+      fprintf(stderr,
+             _("'%s' failed: %s\n"),
+             "execlp",
+             STRERROR(errno));
+      return -1;
+    }
+  }
+  daemon2 = fork();
+  if (daemon2 == 0) {
+    if (0 != execlp("gnunetd", /* what binary to execute, must be in $PATH! */
+                   "gnunetd", /* arg0, path to gnunet binary */
+                   "-d",  /* do not daemonize so we can easily kill you */
+                   "-c",
+                   "peer2.conf", /* configuration file */
+                   NULL)) {
+      fprintf(stderr,
+             _("'%s' failed: %s\n"),
+             "execlp",
+             STRERROR(errno));
+      return -1;
+    }
+  }
+  sleep(5);
+
+
+  ret = 0;
+  left = 5;
+  /* wait for connection or abort with error */
+  initUtil(argc, argv, &parseOptions);
+  do {
+    sock = getClientSocket();
+    if (sock == NULL) {
+      printf(_("Waiting for gnunetd to start (%u iterations left)...\n"),
+            left);
+      sleep(1);
+      left--;
+      if (left == 0) {
+       ret = 1;
+       break;
+      }
+    }
+  } while (sock == NULL);
+
+  left = 30; /* how many iterations should we wait? */
+  while (OK == requestStatistics(sock,
+                                &waitForConnect,
+                                NULL)) {
+    printf(_("Waiting for peers to connect (%u iterations left)...\n"),
+          left);
+    sleep(5);
+    left--;
+    if (left == 0) {
+      ret = 1;
+      break;
+    }
+  }
+  releaseClientSocket(sock);
+  doneUtil();
+
+  /* also shutdown daemons again */
+  if (daemon1 != -1) {
+    if (0 != kill(daemon1, SIGTERM))
+      DIE_STRERROR("kill");
+    if (daemon1 != waitpid(daemon1, &status, 0))
+      DIE_STRERROR("waitpid");
+  }
+  if (daemon2 != -1) {
+    if (0 != kill(daemon2, SIGTERM))
+      DIE_STRERROR("kill");
+    if (daemon2 != waitpid(daemon2, &status, 0))
+      DIE_STRERROR("waitpid");
+  }
+  return ret;
+}
+
+/* end of sessiontest.c */

Added: GNUnet/src/applications/gap/peer1.conf
===================================================================
--- GNUnet/src/applications/gap/peer1.conf      2005-03-25 22:15:51 UTC (rev 
485)
+++ GNUnet/src/applications/gap/peer1.conf      2005-03-25 22:16:17 UTC (rev 
486)
@@ -0,0 +1,60 @@
+# This is the configuration for the GNUnet daemon when running
+# the test in this directory (make check).
+
+GNUNETD_HOME     = peer1
+
+[GNUNETD]
+# VALGRIND        = 300
+HELOEXPIRES     = 60
+LOGLEVEL        = WARNING
+LOGFILE         = $GNUNETD_HOME/log
+KEEPLOG         = 0
+PIDFILE         = $GNUNETD_HOME/gnunetd.pid
+HOSTS          = $GNUNETD_HOME/data/hosts/
+APPLICATIONS = "advertising topology fs stats"
+TRANSPORTS = "tcp"
+
+[MODULES]
+topology = "topology_default"
+
+[NETWORK]
+PORT = 2087
+INTERFACE = eth0
+HELOEXCHANGE = NO
+TRUSTED = 127.0.0.0/8;
+
+[LOAD]
+INTERFACES          = eth0
+BASICLIMITING       = YES
+MAXNETUPBPSTOTAL    = 50000
+MAXNETDOWNBPSTOTAL  = 50000
+MAXCPULOAD         = 100
+
+[TCP]
+PORT = 2086
+# BLACKLIST = 
+
+[UDP]
+PORT = 2086
+# BLACKLIST = 
+MTU = 1472
+
+[UDP6]
+# Default port is 2088 and MTU is 1452.
+PORT = 2088
+# BLACKLIST = 
+MTU = 1452
+
+[TCP6]
+
+# Default port is 2088 and MTU is 1440.
+PORT = 2088
+# BLACKLIST = 
+MTU = 1440
+
+[HTTP]
+# Default port is 1080 and MTU is 1400.
+PORT = 1080
+# BLACKLIST =
+
+

Added: GNUnet/src/applications/gap/peer2.conf
===================================================================
--- GNUnet/src/applications/gap/peer2.conf      2005-03-25 22:15:51 UTC (rev 
485)
+++ GNUnet/src/applications/gap/peer2.conf      2005-03-25 22:16:17 UTC (rev 
486)
@@ -0,0 +1,60 @@
+# This is the configuration for the GNUnet daemon when running
+# the test in this directory (make check).
+
+GNUNETD_HOME     = peer2
+
+[GNUNETD]
+# VALGRIND        = 300
+HELOEXPIRES     = 60
+LOGLEVEL        = WARNING
+LOGFILE         = $GNUNETD_HOME/log
+KEEPLOG         = 0
+PIDFILE         = $GNUNETD_HOME/gnunetd.pid
+HOSTS          = $GNUNETD_HOME/data/hosts/
+APPLICATIONS = "advertising topology fs"
+TRANSPORTS  = "tcp"
+
+[MODULES]
+topology = "topology_default"
+
+[NETWORK]
+PORT = 12087
+INTERFACE = eth0
+HELOEXCHANGE = NO
+TRUSTED = 127.0.0.0/8;
+
+[LOAD]
+INTERFACES          = eth0
+BASICLIMITING       = YES
+MAXNETUPBPSTOTAL    = 50000
+MAXNETDOWNBPSTOTAL  = 50000
+MAXCPULOAD         = 100
+
+[TCP]
+PORT = 12086
+# BLACKLIST = 
+
+[UDP]
+PORT = 12086
+# BLACKLIST = 
+MTU = 1472
+
+[UDP6]
+# Default port is 2088 and MTU is 1452.
+PORT = 12088
+# BLACKLIST = 
+MTU = 1452
+
+[TCP6]
+
+# Default port is 2088 and MTU is 1440.
+PORT = 12088
+# BLACKLIST = 
+MTU = 1440
+
+[HTTP]
+# Default port is 1080 and MTU is 1400.
+PORT = 11080
+# BLACKLIST =
+
+





reply via email to

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