/*
This file is part of GNUnet
- (C) 2008--2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2008--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
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.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
* @file testbed/test_testbed_api_statistics.c
* @brief testcase for testing GNUNET_TESTBED_get_statistics() implementation
- * @author Sree Harsha Totakura <sreeharsha@totakura.in>
+ * @author Sree Harsha Totakura <sreeharsha@totakura.in>
*/
#include "platform.h"
-#include "gnunet_common.h"
+#include "gnunet_util_lib.h"
#include "gnunet_testbed_service.h"
/**
/**
* Abort task identifier
*/
-static GNUNET_SCHEDULER_TaskIdentifier abort_task;
+static struct GNUNET_SCHEDULER_Task * abort_task;
/**
* Global testing result
*/
static int result;
+/**
+ * The peers we have seen in the statistics iterator
+ */
+static struct GNUNET_TESTBED_Peer **seen_peers;
+
+/**
+ * Number of peers in the above array
+ */
+static unsigned int num_seen_peers;
+
+
/**
* Fail testcase
*/
#define FAIL_TEST(cond, ret) do { \
if (!(cond)) { \
GNUNET_break(0); \
- if (GNUNET_SCHEDULER_NO_TASK != abort_task) \
+ if (NULL != abort_task) \
GNUNET_SCHEDULER_cancel (abort_task); \
abort_task = GNUNET_SCHEDULER_add_now (&do_abort, NULL); \
ret; \
* Abort task
*
* @param cls NULL
- * @param tc scheduler task context
*/
static void
-do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_abort (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test timed out -- Aborting\n");
- abort_task = GNUNET_SCHEDULER_NO_TASK;
+ abort_task = NULL;
if (NULL != op)
- {
+ {
GNUNET_TESTBED_operation_done (op);
op = NULL;
}
const char *subsystem, const char *name, uint64_t value,
int is_persistent)
{
- static struct GNUNET_TESTBED_Peer **seen_peers;
- static unsigned int num_seen_peers;
unsigned int cnt;
-
+
FAIL_TEST (cls == dummy_cls, return GNUNET_SYSERR);
for (cnt = 0; cnt < num_seen_peers; cnt++)
FAIL_TEST (peer != seen_peers[cnt], return GNUNET_SYSERR);
FAIL_TEST (NULL != subsystem, return GNUNET_SYSERR);
- FAIL_TEST (NULL != name, return GNUNET_SYSERR);
+ FAIL_TEST (NULL != name, return GNUNET_SYSERR);
GNUNET_array_append (seen_peers, num_seen_peers,
(struct GNUNET_TESTBED_Peer *) peer);
return GNUNET_SYSERR;
* Signature of a main function for a testcase.
*
* @param cls closure
+ * @param h the run handle
* @param num_peers number of peers in 'peers'
- * @param peers handle to peers run in the testbed
+ * @param peers_ handle to peers run in the testbed
+ * @param links_succeeded the number of overlay link connection attempts that
+ * succeeded
+ * @param links_failed the number of overlay link connection attempts that
+ * failed
*/
static void
-test_master (void *cls, unsigned int num_peers,
- struct GNUNET_TESTBED_Peer **peers_)
+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)
{
FAIL_TEST (NUM_PEERS == num_peers, return);
peers = peers_;
NUM_PEERS,
1LL, NULL, NULL,
&test_master, NULL);
+ GNUNET_free_non_null (seen_peers);
if (GNUNET_OK != result)
return 1;
return 0;