#define VERBOSE GNUNET_NO
-
/**
* How long until we give up on connecting the peers?
*/
#DEBUG = YES
#PREFIX = xterm -e xterm -T peerinfo -e gdb --args
#BINARY = /home/mrwiggles/documents/research/gnunet/gnunet-ng/src/peerinfo/.libs/gnunet-service-peerinfo
-#PREFIX = valgrind --tool=memcheck --log-file=peerinfo%p
+PREFIX = valgrind --tool=memcheck --log-file=peerinfo%p
[core]
PORT = 2570
#DEBUG = YES
[testing]
-NUM_PEERS = 5
+NUM_PEERS = 20
WEAKRANDOM = YES
TOPOLOGY = CLIQUE
CONNECT_TOPOLOGY_OPTION = CONNECT_MINIMUM
-CONNECT_TOPOLOGY_OPTION_MODIFIER = 1.0
+CONNECT_TOPOLOGY_OPTION_MODIFIER = 2.0
F2F = YES
#DEBUG = YES
[testing]
-NUM_PEERS = 5
+NUM_PEERS = 20
WEAKRANDOM = YES
TOPOLOGY = CLIQUE
CONNECT_TOPOLOGY_OPTION = CONNECT_RANDOM_SUBSET
-CONNECT_TOPOLOGY_OPTION_MODIFIER = .5
+CONNECT_TOPOLOGY_OPTION_MODIFIER = .15
F2F = YES
#include "platform.h"
#include "gnunet_testing_lib.h"
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
#define NUM_PEERS 4
static struct GNUNET_SCHEDULER_Handle *sched;
+/**
+ * Check whether peers successfully shut down.
+ */
+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
+ if (ok == 0)
+ ok = 666;
+ }
+ else
+ {
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "All peers successfully shut down!\n");
+#endif
+ }
+}
+
static void
my_cb (void *cls,
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Too many peers failed, ending test!\n");
ok = 1;
- GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+ GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
}
return;
}
if (peers_left == 0)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers started successfully, ending test!\n");
- GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+ GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
ok = 0;
}
else if (failed_peers == peers_left)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Too many peers failed, ending test!\n");
ok = 1;
- GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+ GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
}
}
static char *hostnames;
+/**
+ * Check whether peers successfully shut down.
+ */
+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
+ if (ok == 0)
+ ok = 666;
+ }
+ else
+ {
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "All peers successfully shut down!\n");
+#endif
+ }
+}
+
static void
my_cb (void *cls,
peers_left--;
if (peers_left == 0)
{
- GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+ GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
ok = 0;
}
else if (peers_failed == peers_left)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Too many peers failed, ending test!\n");
- GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+ GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
}
}
#include "gnunet_testing_lib.h"
#include "gnunet_core_service.h"
-#define VERBOSE GNUNET_YES
+#define VERBOSE GNUNET_NO
/**
* How long until we fail the whole testcase?
static struct TestMessageContext *test_messages;
+/**
+ * Check whether peers successfully shut down.
+ */
+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
+ if (ok == 0)
+ ok = 666;
+ }
+ else
+ {
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "All peers successfully shut down!\n");
+#endif
+ }
+}
+
static void
finish_testing ()
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Calling daemons_stop\n");
#endif
- GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
-#if VERBOSE
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "daemons_stop finished\n");
-#endif
+ GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
+
if (dotOutFile != NULL)
{
fprintf(dotOutFile, "}");
if (pg != NULL)
{
- GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+ GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
ok = 7331; /* Opposite of leet */
}
else
}
}
-
-
static size_t
transmit_ready (void *cls, size_t size, void *buf)
{
uint32_t uid;
};
+
+/**
+ * Check whether peers successfully shut down.
+ */
+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
+ if (ok == 0)
+ ok = 666;
+ }
+ else
+ {
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "All peers successfully shut down!\n");
+#endif
+ }
+}
+
static void
finish_testing ()
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Calling daemons_stop\n");
#endif
- GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+ GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"daemons_stop finished\n");
if (pg != NULL)
{
- GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+ GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
ok = 7331; /* Opposite of leet */
}
else
uint32_t uid;
};
+/**
+ * Check whether peers successfully shut down.
+ */
+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
+ if (ok == 0)
+ ok = 666;
+ }
+ else
+ {
+#if VERBOSE
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "All peers successfully shut down!\n");
+#endif
+ }
+}
+
static void
finish_testing ()
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Calling daemons_stop\n");
#endif
- GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+ GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
#if VERBOSE
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"daemons_stop finished\n");
if (pg != NULL)
{
- GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
+ GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
ok = 7331; /* Opposite of leet */
}
else
/**
* @file testing/testing_group.c
* @brief convenience API for writing testcases for GNUnet
+ * @author Nathan Evans
* @author Christian Grothoff
*
- * FIXME: have connection processor functions take a cls argument
- * which specifies where to write the connection information
- * instead of assuming it's certain peergroup places. (maybe?)
- * FIXME: create static struct which contains the TOPOLOGY enum, the
- * associated string, and the function used to create it.
- * Then replace the create_X calls with topology_struct[i][2]
- * or something. (Store function pointers instead of using
- * switch statements)
*/
#include "platform.h"
#include "gnunet_arm_service.h"
* 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 32000
+#define HIGH_PORT 56000
#define MAX_OUTSTANDING_CONNECTIONS 50
};
+
+struct ShutdownContext
+{
+ /**
+ * Total peers to wait for
+ */
+ int total_peers;
+
+ /**
+ * Number of peers successfully shut down
+ */
+ int peers_down;
+
+ /**
+ * Number of peers failed to shut down
+ */
+ int peers_failed;
+
+ /**
+ * Callback to call when all peers either
+ * shutdown or failed to shutdown
+ */
+ GNUNET_TESTING_NotifyCompletion cb;
+
+ /**
+ * Closure for cb
+ */
+ void *cb_cls;
+};
+
struct CreateTopologyContext
{
}
+/**
+ * Callback for shutting down peers in a peer group.
+ *
+ * @param cls closure (struct ShutdownContext)
+ * @param emsg NULL on success
+ */
+void internal_shutdown_callback (void *cls,
+ const char *emsg)
+{
+ struct ShutdownContext *shutdown_ctx = cls;
+
+ if (emsg == NULL)
+ {
+ shutdown_ctx->peers_down++;
+ }
+ else
+ {
+ shutdown_ctx->peers_failed++;
+ }
+
+ if ((shutdown_ctx->cb != NULL) && (shutdown_ctx->peers_down + shutdown_ctx->peers_failed == shutdown_ctx->total_peers))
+ {
+ if (shutdown_ctx->peers_failed > 0)
+ shutdown_ctx->cb(shutdown_ctx->cb_cls, "Not all peers successfully shut down!");
+ else
+ shutdown_ctx->cb(shutdown_ctx->cb_cls, NULL);
+ GNUNET_free(shutdown_ctx);
+ }
+}
+
/**
* Shutdown all peers started in the given group.
*
* @param pg handle to the peer group
* @param timeout how long to wait for shutdown
+ * @param cb callback to notify upon success or failure
+ * @param cb_cls closure for cb
*/
void
GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg,
- struct GNUNET_TIME_Relative timeout)
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_TESTING_NotifyCompletion cb,
+ void *cb_cls)
{
unsigned int off;
+ struct ShutdownContext *shutdown_ctx;
+ GNUNET_TESTING_NotifyCompletion shutdown_cb;
+ void *shutdown_cb_cls;
- for (off = 0; off < pg->total; off++)
+ GNUNET_assert(pg->total > 0);
+
+ shutdown_cb = NULL;
+ shutdown_ctx = NULL;
+
+ if (cb != NULL)
{
- /* FIXME: should we wait for our continuations to be called
- here? This would require us to take a continuation as
- well... */
+ shutdown_ctx = GNUNET_malloc(sizeof(struct ShutdownContext));
+ shutdown_ctx->cb = cb;
+ shutdown_ctx->cb_cls = cb_cls;
+ shutdown_ctx->total_peers = pg->total;
+ shutdown_cb = &internal_shutdown_callback;
+ shutdown_cb_cls = cb_cls;
+ }
+ for (off = 0; off < pg->total; off++)
+ {
if (NULL != pg->peers[off].daemon)
- GNUNET_TESTING_daemon_stop (pg->peers[off].daemon, timeout, NULL, NULL, GNUNET_YES, GNUNET_NO);
+ GNUNET_TESTING_daemon_stop (pg->peers[off].daemon, timeout, shutdown_cb, shutdown_ctx, GNUNET_YES, GNUNET_NO);
if (NULL != pg->peers[off].cfg)
GNUNET_CONFIGURATION_destroy (pg->peers[off].cfg);
if (pg->peers[off].allowed_peers != NULL)