+/**
+ * shortcut to exit during failure
+ */
+#define FAIL_TEST(cond) do { \
+ if (!(cond)) { \
+ GNUNET_break(0); \
+ if (NULL != abort_task) \
+ GNUNET_SCHEDULER_cancel (abort_task); \
+ abort_task = NULL; \
+ if (NULL == shutdown_task) \
+ shutdown_task = GNUNET_SCHEDULER_add_now (do_shutdown, NULL); \
+ return; \
+ } \
+ } while (0)
+
+
+/**
+ * abort task to run on test timed out
+ *
+ * @param cls NULL
+ * @param tc the task context
+ */
+static void
+do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
+ abort_task = NULL;
+ if (NULL != shutdown_task)
+ GNUNET_SCHEDULER_cancel (shutdown_task);
+ do_shutdown (cls, tc);
+}
+
+
+/**
+ * Callback to be called when the requested peer information is available
+ *
+ * @param cb_cls the closure from GNUNET_TETSBED_peer_get_information()
+ * @param op the operation this callback corresponds to
+ * @param pinfo the result; will be NULL if the operation has failed
+ * @param emsg error message if the operation has failed; will be NULL if the
+ * operation is successfull
+ */
+static void
+peerinfo_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op_,
+ const struct GNUNET_TESTBED_PeerInformation *pinfo,
+ const char *emsg)
+{
+ FAIL_TEST (op == op_);
+ FAIL_TEST (NULL == cb_cls);
+ FAIL_TEST (NULL == emsg);
+ FAIL_TEST (GNUNET_TESTBED_PIT_IDENTITY == pinfo->pit);
+ FAIL_TEST (NULL != pinfo->result.id);
+ GNUNET_TESTBED_operation_done (op);
+ op = NULL;
+ result = GNUNET_OK;
+ shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
+}
+
+
+/**
+ * Callback to be called when an operation is completed
+ *
+ * @param cls the callback closure from functions generating an operation
+ * @param op the operation that has been finished
+ * @param emsg error message in case the operation has failed; will be NULL if
+ * operation has executed successfully.
+ */
+static void
+op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op_, const char *emsg)
+{
+ FAIL_TEST (NULL == cls);
+ FAIL_TEST (op == op_);
+ if (NULL != emsg)
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING, "%s\n", emsg);
+ FAIL_TEST (0);
+ }
+ GNUNET_TESTBED_operation_done (op);
+ op = GNUNET_TESTBED_peer_get_information (peers[0],
+ GNUNET_TESTBED_PIT_IDENTITY,
+ &peerinfo_cb, NULL);
+}
+