[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r10988 - gnunet/src/hostlist
From: |
gnunet |
Subject: |
[GNUnet-SVN] r10988 - gnunet/src/hostlist |
Date: |
Tue, 20 Apr 2010 13:39:22 +0200 |
Author: wachs
Date: 2010-04-20 13:39:22 +0200 (Tue, 20 Apr 2010)
New Revision: 10988
Added:
gnunet/src/hostlist/test_learning_adv_peer.conf
gnunet/src/hostlist/test_learning_learn_peer.conf
Modified:
gnunet/src/hostlist/test_gnunet_daemon_hostlist_learning.c
Log:
creating a correct testcase
Modified: gnunet/src/hostlist/test_gnunet_daemon_hostlist_learning.c
===================================================================
--- gnunet/src/hostlist/test_gnunet_daemon_hostlist_learning.c 2010-04-19
15:28:10 UTC (rev 10987)
+++ gnunet/src/hostlist/test_gnunet_daemon_hostlist_learning.c 2010-04-20
11:39:22 UTC (rev 10988)
@@ -18,24 +18,26 @@
Boston, MA 02111-1307, USA.
*/
/**
- * @file hostlist/test_gnunet_daemon_hostlist_learning.c
+ * @file hostlist/test_gnunet_daemon_hostlist.c
* @brief test for gnunet_daemon_hostslist.c
- * @author Christian Grothoff, Matthias Wachs
+ * @author Christian Grothoff
*/
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_arm_service.h"
#include "gnunet_transport_service.h"
+#define VERBOSE GNUNET_YES
#define START_ARM GNUNET_YES
+
/**
* How long until we give up on transmitting the message?
*/
-#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 150)
+#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10)
-static int ok;
+static int failure;
static struct GNUNET_SCHEDULER_Handle *sched;
@@ -52,23 +54,22 @@
#endif
};
-static struct PeerContext p1;
+static struct PeerContext adv_peer;
-static struct PeerContext p2;
+static struct PeerContext learn_peer;
-
static void
clean_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- if (p1.th != NULL)
+ if (adv_peer.th != NULL)
{
- GNUNET_TRANSPORT_disconnect (p1.th);
- p1.th = NULL;
+ GNUNET_TRANSPORT_disconnect (adv_peer.th);
+ adv_peer.th = NULL;
}
- if (p2.th != NULL)
+ if (learn_peer.th != NULL)
{
- GNUNET_TRANSPORT_disconnect (p2.th);
- p2.th = NULL;
+ GNUNET_TRANSPORT_disconnect (learn_peer.th);
+ learn_peer.th = NULL;
}
GNUNET_SCHEDULER_shutdown (sched);
}
@@ -81,60 +82,34 @@
{
timeout_task = GNUNET_SCHEDULER_NO_TASK;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Timeout trying to connect peers, test failed.\n");
+ "Timeout while executing testcase, test failed.\n");
+ failure = GNUNET_YES;
clean_up (NULL, tc);
}
-
-/**
- * Function called to notify transport users that another
- * peer connected to us.
- *
- * @param cls closure
- * @param peer the peer that connected
- * @param latency current latency of the connection
- * @param distance in overlay hops, as given by transport plugin
- */
static void
-notify_connect (void *cls,
- const struct GNUNET_PeerIdentity * peer,
- struct GNUNET_TIME_Relative latency,
- unsigned int distance)
+setup_learn_peer (struct PeerContext *p, const char *cfgname)
{
- if (peer == NULL)
- return;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Peers connected, shutting down.\n");
- /*
- ok = 0;
- if (timeout_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (sched,
- timeout_task);
- timeout_task = GNUNET_SCHEDULER_NO_TASK;
- }
- GNUNET_SCHEDULER_add_now (sched,
- &clean_up, NULL);
- */
+ p->cfg = GNUNET_CONFIGURATION_create ();
+#if START_ARM
+ p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ "gnunet-service-arm",
+#if VERBOSE
+ "-L", "DEBUG",
+#endif
+ "-c", cfgname, NULL);
+#endif
+ GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
+ GNUNET_ARM_start_services (p->cfg, sched, "core", NULL);
+ p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL,
+ NULL, NULL);
+ GNUNET_assert (p->th != NULL);
}
static void
-process_hello (void *cls,
- const struct GNUNET_MessageHeader *message)
+setup_adv_peer (struct PeerContext *p, const char *cfgname)
{
- struct PeerContext *p = cls;
-
- GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received HELLO, starting hostlist service.\n");
- GNUNET_ARM_start_services (p->cfg, sched, "hostlist", NULL);
-}
-
-
-static void
-setup_peer (struct PeerContext *p, const char *cfgname)
-{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
@@ -147,21 +122,21 @@
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
GNUNET_ARM_start_services (p->cfg, sched, "core", NULL);
p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL,
- ¬ify_connect, NULL);
+ NULL, NULL);
GNUNET_assert (p->th != NULL);
- GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
}
+
static void
waitpid_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct PeerContext *p = cls;
#if START_ARM
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Killing ARM process.\n");
+ "Killing ARM process.\n");
if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
@@ -175,20 +150,20 @@
static void
stop_cb (void *cls,
- int success)
+ int success)
{
struct PeerContext *p = cls;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- success
- ? "ARM stopped core service\n"
- : "ARM failed to stop core service\n");
+ success
+ ? "ARM stopped core service\n"
+ : "ARM failed to stop core service\n");
GNUNET_ARM_disconnect (p->arm);
p->arm = NULL;
/* make sure this runs after all other tasks are done */
GNUNET_SCHEDULER_add_delayed (sched,
- GNUNET_TIME_UNIT_SECONDS,
- &waitpid_task, p);
+ GNUNET_TIME_UNIT_SECONDS,
+ &waitpid_task, p);
}
@@ -196,10 +171,10 @@
stop_arm (struct PeerContext *p)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Asking ARM to stop core service\n");
+ "Asking ARM to stop core service\n");
p->arm = GNUNET_ARM_connect (p->cfg, sched, NULL);
GNUNET_ARM_stop_service (p->arm, "core", GNUNET_TIME_UNIT_SECONDS,
- &stop_cb, p);
+ &stop_cb, p);
}
@@ -209,8 +184,8 @@
static void
shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- stop_arm (&p1);
- stop_arm (&p2);
+ stop_arm (&adv_peer);
+ stop_arm (&learn_peer);
}
@@ -221,27 +196,25 @@
const char *cfgfile,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
- GNUNET_assert (ok == 1);
- ok++;
+ failure = GNUNET_NO;
sched = s;
-
timeout_task = GNUNET_SCHEDULER_add_delayed (sched,
- TIMEOUT,
- &timeout_error,
- NULL);
+ TIMEOUT,
+ &timeout_error,
+ NULL);
GNUNET_SCHEDULER_add_delayed (sched,
- GNUNET_TIME_UNIT_FOREVER_REL,
- &shutdown_task,
- NULL);
- setup_peer (&p1, "learning_peer1.conf");
- setup_peer (&p2, "learning_peer2.conf");
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &shutdown_task,
+ NULL);
+ setup_adv_peer (&adv_peer, "test_learning_adv_peer.conf");
+ setup_learn_peer (&learn_peer, "test_learning_learn_peer.conf");
}
static int
check ()
{
- char *const argv[] = { "test_gnunet_daemon_hostlist_learning",
+ char *const argv[] = { "test-gnunet-daemon-hostlist",
"-c", "learning_data.conf",
#if VERBOSE
"-L", "DEBUG",
@@ -251,23 +224,22 @@
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END
};
- ok = 1;
+ failure = GNUNET_NO;
GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
- argv, "test_gnunet_daemon_hostlist_learning",
- "nohelp", options, &run, &ok);
-
- return ok;
+ argv, "test-gnunet-daemon-hostlist",
+ "nohelp", options, &run, NULL);
+ return failure;
}
-
int
main (int argc, char *argv[])
{
int ret;
+
GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-hostlist-peer-1");
GNUNET_DISK_directory_remove ("/tmp/test-gnunetd-hostlist-peer-2");
- GNUNET_log_setup ("test-gnunet-daemon-hostlist_learning",
+ GNUNET_log_setup ("test-gnunet-daemon-hostlist",
#if VERBOSE
"DEBUG",
#else
Copied: gnunet/src/hostlist/test_learning_adv_peer.conf (from rev 10987,
gnunet/src/hostlist/learning_peer2.conf)
===================================================================
--- gnunet/src/hostlist/test_learning_adv_peer.conf
(rev 0)
+++ gnunet/src/hostlist/test_learning_adv_peer.conf 2010-04-20 11:39:22 UTC
(rev 10988)
@@ -0,0 +1,46 @@
+[PATHS]
+SERVICEHOME = /tmp/test-gnunetd-hostlist-peer-2/
+DEFAULTCONFIG = test_learning_adv_peer.conf
+
+[resolver]
+PORT = 22964
+
+[transport]
+PORT = 22965
+PLUGINS = tcp
+#DEBUG = YES
+
+[arm]
+PORT = 22966
+DEFAULTSERVICES = resolver transport core statistics topology hostlist
+#GLOBAL_PREFIX = xterm -e gdb -x cmd --args
+#DEBUG=NO
+
+[statistics]
+PORT = 22967
+
+[transport-tcp]
+PORT = 22968
+
+[peerinfo]
+PORT = 22969
+
+[core]
+PORT = 22970
+#DEBUG = YES
+#PREFIX = valgrind --tool=memcheck
+
+[testing]
+WEAKRANDOM = YES
+
+[hostlist]
+HTTPPORT = 12981s
+SERVERS = http://localhost:12980/
+OPTIONS = -b -p -a
+DEBUG = YES
+HOSTLISTFILE = hostlists_adv_peer.file
+#BINARY = /home/grothoff/bin/gnunet-daemon-hostlist
+
+[topology]
+#DEBUG = YES
+#PREFIX = valgrind --tool=memcheck
Copied: gnunet/src/hostlist/test_learning_learn_peer.conf (from rev 10987,
gnunet/src/hostlist/learning_peer1.conf)
===================================================================
--- gnunet/src/hostlist/test_learning_learn_peer.conf
(rev 0)
+++ gnunet/src/hostlist/test_learning_learn_peer.conf 2010-04-20 11:39:22 UTC
(rev 10988)
@@ -0,0 +1,46 @@
+[PATHS]
+SERVICEHOME = /tmp/test-gnunetd-hostlist-peer-1/
+DEFAULTCONFIG = test_learning_learn_peer.conf
+[resolver]
+PORT = 12964
+
+[transport]
+PORT = 12965
+PLUGINS = tcp
+#DEBUG = YES
+
+[arm]
+PORT = 12966
+DEFAULTSERVICES = resolver transport core statistics topology hostlist
+#GLOBAL_PREFIX = xterm -e gdb -x cmd --args
+#DEBUG=NO
+
+[statistics]
+PORT = 12967
+
+[transport-tcp]
+PORT = 12968
+
+[peerinfo]
+PORT = 12969
+
+[core]
+PORT = 12970
+#DEBUG = YES
+#PREFIX = valgrind --tool=memcheck
+
+[testing]
+WEAKRANDOM = YES
+
+[hostlist]
+HTTPPORT = 12980
+SERVERS = http://localhost:12981/
+OPTIONS = -b -p -e
+DEBUG = YES
+HOSTLISTFILE = hostlists_learn_peer.file
+#BINARY = /home/grothoff/bin/gnunet-daemon-hostlist
+
+
+[topology]
+#DEBUG = YES
+#PREFIX = valgrind --tool=memcheck
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r10988 - gnunet/src/hostlist,
gnunet <=