* @author Sree Harsha Totakura
*/
-/**
- * To be fixed:
- * Should the handle be freed when the connection to service is lost?
- * Should cancel_request have a call back (else simultaneous calls break)
- */
#include "platform.h"
#include "gnunet_common.h"
}
if (GNUNET_NO == handle->in_replies)
{
+ handle->in_replies = GNUNET_YES;
GNUNET_CLIENT_receive (handle->conn,
&handle_replies,
handle,
GNUNET_TIME_UNIT_FOREVER_REL);
- handle->in_replies = GNUNET_YES;
}
return msg_size;
}
if ( (match->lock == lr->lock) && (0 == strcmp (match->domain, lr->domain)) )
{
- match->matched_entry = lr;
+ match->matched_entry = lr;
return GNUNET_NO;
}
return GNUNET_YES;
handle);
return;
}
+ handle->in_replies = GNUNET_YES;
GNUNET_CLIENT_receive (handle->conn,
&handle_replies,
handle,
GNUNET_TIME_UNIT_FOREVER_REL);
- handle->in_replies = GNUNET_YES;
if (GNUNET_MESSAGE_TYPE_LOCKMANAGER_SUCCESS != ntohs(msg->type))
{
GNUNET_break (0);
}
h->hashmap = GNUNET_CONTAINER_multihashmap_create (15);
GNUNET_assert (NULL != h->hashmap);
+ h->in_replies = GNUNET_YES;
GNUNET_CLIENT_receive (h->conn,
&handle_replies,
h,
- GNUNET_TIME_UNIT_FOREVER_REL);
- h->in_replies = GNUNET_YES;
+ GNUNET_TIME_UNIT_FOREVER_REL);
LOG (GNUNET_ERROR_TYPE_DEBUG, "%s() END\n", __func__);
return h;
}
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_lockmanager_service.h"
+#include "gnunet_testing_lib-new.h"
-#define VERBOSE GNUNET_YES
-
-#define VERBOSE_ARM 1
-
+/**
+ * Generic logging shortcut
+ */
#define LOG(kind,...) \
GNUNET_log (kind, __VA_ARGS__)
*/
static enum Test result;
-/**
- * The process id of the GNUNET ARM process
- */
-static struct GNUNET_OS_Process *arm_pid = NULL;
-
/**
* Configuration Handle
*/
-static struct GNUNET_CONFIGURATION_Handle *config;
+static const struct GNUNET_CONFIGURATION_Handle *config;
/**
* The handle to the lockmanager service
if (NULL != request2)
GNUNET_LOCKMANAGER_cancel_request (request2);
GNUNET_LOCKMANAGER_disconnect (handle);
- if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM))
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Kill gnunet-service-arm manually\n");
- }
- GNUNET_OS_process_wait (arm_pid);
- GNUNET_OS_process_destroy (arm_pid);
-
- if (NULL != config)
- GNUNET_CONFIGURATION_destroy (config);
+ GNUNET_SCHEDULER_shutdown ();
}
/**
- * Testing function
- *
- * @param cls NULL
- * @param tc the task context
+ * Main point of test execution
*/
static void
-test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
-{
+run (void *cls,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const struct GNUNET_TESTING_Peer *peer)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting test...\n");
+ config = cfg;
handle = GNUNET_LOCKMANAGER_connect (config);
GNUNET_assert (NULL != handle);
result = LOCK1_ACQUIRE;
99,
&status_cb,
NULL);
- abort_task_id = GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (10),
+ abort_task_id = GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (30),
&do_abort,
NULL);
}
-/**
- * Main point of test execution
- */
-static void
-run (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting test...\n");
- config = GNUNET_CONFIGURATION_dup (cfg);
- arm_pid =
- GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
- "gnunet-service-arm",
-#if VERBOSE_ARM
- "-L", "DEBUG",
-#endif
- "-c", "test_lockmanager_api.conf", NULL);
-
- GNUNET_assert (NULL != arm_pid);
- GNUNET_SCHEDULER_add_delayed (TIME_REL_SECONDS (3),
- &test,
- NULL);
-}
-
-
/**
* Main function
*/
int main (int argc, char **argv)
{
- int ret;
-
- char *const argv2[] = { "test_lockmanager_api",
- "-c", "test_lockmanager_api.conf",
-#if VERBOSE
- "-L", "DEBUG",
-#endif
- NULL
- };
-
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
-
- GNUNET_log_setup ("test_lockmanager_api",
-#if VERBOSE
- "DEBUG",
-#else
- "WARNING",
-#endif
- NULL);
- ret =
- GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
- "test_lockmanager_api", "nohelp", options, &run, NULL);
-
- if (GNUNET_OK != ret)
- {
- LOG (GNUNET_ERROR_TYPE_WARNING, "run failed with error code %d\n",
- ret);
- return 1;
- }
- if (TEST_FAIL == result)
- {
- LOG (GNUNET_ERROR_TYPE_WARNING, "test failed\n");
+ if (0 != GNUNET_TESTING_service_run_restartable ("test_lockmanager_api",
+ "arm",
+ "test_lockmanager_api.conf",
+ &run, NULL))
return 1;
- }
- LOG (GNUNET_ERROR_TYPE_INFO, "test OK\n");
- return 0;
+ return (TEST_FAIL == result) ? 1 : 0;
}