[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r22738 - gnunet/src/testbed
From: |
gnunet |
Subject: |
[GNUnet-SVN] r22738 - gnunet/src/testbed |
Date: |
Wed, 18 Jul 2012 10:35:38 +0200 |
Author: harsha
Date: 2012-07-18 10:35:38 +0200 (Wed, 18 Jul 2012)
New Revision: 22738
Modified:
gnunet/src/testbed/Makefile.am
gnunet/src/testbed/gnunet-testbed-helper.c
gnunet/src/testbed/test_gnunet_testbed_helper.c
Log:
fixed test_gnunet_testbed_helper
Modified: gnunet/src/testbed/Makefile.am
===================================================================
--- gnunet/src/testbed/Makefile.am 2012-07-18 07:43:48 UTC (rev 22737)
+++ gnunet/src/testbed/Makefile.am 2012-07-18 08:35:38 UTC (rev 22738)
@@ -72,7 +72,7 @@
if ENABLE_TEST_RUN
TESTS = \
test_testbed_api_hosts \
- #test_gnunet_testbed_helper
+ test_gnunet_testbed_helper
endif
test_testbed_api_hosts_SOURCES = \
Modified: gnunet/src/testbed/gnunet-testbed-helper.c
===================================================================
--- gnunet/src/testbed/gnunet-testbed-helper.c 2012-07-18 07:43:48 UTC (rev
22737)
+++ gnunet/src/testbed/gnunet-testbed-helper.c 2012-07-18 08:35:38 UTC (rev
22738)
@@ -152,7 +152,7 @@
if (NULL != stdin_fd)
(void) GNUNET_DISK_file_close (stdin_fd);
if (NULL != stdout_fd)
- (void) GNUNET_DISK_file_close (stdin_fd);
+ (void) GNUNET_DISK_file_close (stdout_fd);
GNUNET_SERVER_mst_destroy (tokenizer);
tokenizer = NULL;
if (NULL != testbed)
@@ -420,6 +420,7 @@
};
ret = GNUNET_OK;
+ //sleep (60);
if (GNUNET_OK !=
GNUNET_PROGRAM_run (argc, argv, "gnunet-testbed-helper",
"Helper for starting gnunet-service-testbed",
Modified: gnunet/src/testbed/test_gnunet_testbed_helper.c
===================================================================
--- gnunet/src/testbed/test_gnunet_testbed_helper.c 2012-07-18 07:43:48 UTC
(rev 22737)
+++ gnunet/src/testbed/test_gnunet_testbed_helper.c 2012-07-18 08:35:38 UTC
(rev 22738)
@@ -27,6 +27,7 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testbed_service.h"
+#include <zlib.h>
#include "testbed_api.h"
#include "testbed_helper.h"
@@ -69,7 +70,12 @@
*/
static struct GNUNET_CONFIGURATION_Handle *cfg;
+/**
+ * Global testing status
+ */
+static int result;
+
/**
* Shutdown nicely
*
@@ -97,9 +103,11 @@
static void
do_abort (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ abort_task = GNUNET_SCHEDULER_NO_TASK;
LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
- abort_task = GNUNET_SCHEDULER_NO_TASK;
- GNUNET_HELPER_send_cancel (shandle);
+ result = GNUNET_SYSERR;
+ if (NULL != shandle)
+ GNUNET_HELPER_send_cancel (shandle);
if (GNUNET_SCHEDULER_NO_TASK == shutdown_task)
shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
}
@@ -119,14 +127,63 @@
shandle = NULL;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Message sent\n");
GNUNET_assert (GNUNET_OK == result);
+}
+
+
+/**
+ * Functions with this signature are called whenever a
+ * complete message is received by the tokenizer.
+ *
+ * Do not call GNUNET_SERVER_mst_destroy in callback
+ *
+ * @param cls closure
+ * @param client identification of the client
+ * @param message the actual message
+ *
+ * @return GNUNET_OK on success, GNUNET_SYSERR to stop further processing
+ */
+static int
+mst_cb (void *cls, void *client, const struct GNUNET_MessageHeader *message)
+{
+ const struct GNUNET_TESTBED_HelperReply *msg;
+ char *config;
+ uLongf config_size;
+ uLongf xconfig_size;
+
+ msg = (const struct GNUNET_TESTBED_HelperReply *) message;
+ GNUNET_assert (sizeof (struct GNUNET_TESTBED_HelperReply)
+ < ntohs (msg->header.size));
+ GNUNET_assert (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY
+ == ntohs (msg->header.type));
+ config_size = (uLongf) ntohs (msg->config_size);
+ xconfig_size = (uLongf) (ntohs (msg->header.size)
+ - sizeof (struct GNUNET_TESTBED_HelperReply));
+ config = GNUNET_malloc (config_size);
+ GNUNET_assert (Z_OK == uncompress ((Bytef *) config, &config_size,
+ (const Bytef *) &msg[1], xconfig_size));
if (GNUNET_SCHEDULER_NO_TASK == shutdown_task)
shutdown_task = GNUNET_SCHEDULER_add_delayed
- (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5),
+ (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
&do_shutdown, NULL);
+ return GNUNET_OK;
}
/**
+ * Callback that will be called when the helper process dies. This is not
called
+ * when the helper process is stoped using GNUNET_HELPER_stop()
+ *
+ * @param cls the closure from GNUNET_HELPER_start()
+ */
+static void
+exp_cb (void *cls)
+{
+ helper = NULL;
+ result = GNUNET_SYSERR;
+}
+
+
+/**
* Main function that will be run.
*
* @param cls closure
@@ -146,7 +203,7 @@
helper = GNUNET_HELPER_start ("gnunet-testbed-helper",
binary_argv,
- NULL, NULL, NULL);
+ &mst_cb, &exp_cb, NULL);
GNUNET_assert (NULL != helper);
cfg = GNUNET_CONFIGURATION_dup (cfg2);
msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_name, cfg);
@@ -171,13 +228,14 @@
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END
};
-
+
+ result = GNUNET_OK;
if (GNUNET_OK !=
GNUNET_PROGRAM_run (argc, argv, "test_gnunet_testbed_helper",
"Testcase for testing gnunet-testbed-helper.c",
options, &run, NULL))
return 1;
- return 0;
+ return (GNUNET_OK == result) ? 0 : 1;
}
/* end of test_gnunet_testbed_helper.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r22738 - gnunet/src/testbed,
gnunet <=