From 0e4c7cdccfc4105f9c6e529cfa0e3722104b0ddf Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 4 Nov 2012 21:01:22 +0000 Subject: -misc bugfixes, travel hacking --- src/chat/test_chat.c | 97 +++++++++++++++----------------------------- src/chat/test_chat_private.c | 8 ---- 2 files changed, 33 insertions(+), 72 deletions(-) (limited to 'src/chat') diff --git a/src/chat/test_chat.c b/src/chat/test_chat.c index 24a1e38da..78b31f1b1 100644 --- a/src/chat/test_chat.c +++ b/src/chat/test_chat.c @@ -37,10 +37,6 @@ #include "gnunet_arm_service.h" #include "gnunet_chat_service.h" -#define VERBOSE GNUNET_NO - -#define START_ARM GNUNET_YES - /** * How long until we give up on passing the test? */ @@ -49,9 +45,7 @@ struct PeerContext { struct GNUNET_CONFIGURATION_Handle *cfg; -#if START_ARM struct GNUNET_OS_Process *arm_proc; -#endif }; struct Wanted @@ -120,12 +114,10 @@ setup_peer (struct PeerContext *p, const char *cfgname) binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); -#if START_ARM p->arm_proc = GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, binary, "gnunet-service-arm", "-c", cfgname, NULL); -#endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); GNUNET_free (binary); } @@ -134,7 +126,6 @@ setup_peer (struct PeerContext *p, const char *cfgname) static void stop_arm (struct PeerContext *p) { -#if START_ARM if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) @@ -143,7 +134,6 @@ stop_arm (struct PeerContext *p) GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_destroy (p->arm_proc); p->arm_proc = NULL; -#endif GNUNET_CONFIGURATION_destroy (p->cfg); } @@ -168,9 +158,8 @@ abort_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void timeout_kill (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { -#if VERBOSE - printf ("Timed out, stopping the test.\n"); -#endif + fprintf (stderr, + "Timed out, stopping the test.\n"); kill_task = GNUNET_SCHEDULER_NO_TASK; if (wait_task != GNUNET_SCHEDULER_NO_TASK) { @@ -187,9 +176,8 @@ join_cb (void *cls) { struct Wanted *want = cls; -#if VERBOSE - printf ("%s has joined\n", want->me); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "%s has joined\n", want->me); if (NULL != want->next_task) GNUNET_SCHEDULER_add_now (want->next_task, want->next_task_cls); return GNUNET_OK; @@ -204,13 +192,12 @@ member_list_cb (void *cls, const struct GNUNET_CONTAINER_MetaData *member_info, struct Wanted *want = cls; struct GNUNET_HashCode sender; -#if VERBOSE - printf ("%s - told that %s has %s\n", want->me, - member_info == - NULL ? NULL : GNUNET_CONTAINER_meta_data_get_by_type (member_info, - EXTRACTOR_METATYPE_TITLE), - member_info == NULL ? "left" : "joined"); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "%s - told that %s has %s\n", want->me, + member_info == + NULL ? NULL : GNUNET_CONTAINER_meta_data_get_by_type (member_info, + EXTRACTOR_METATYPE_TITLE), + member_info == NULL ? "left" : "joined"); GNUNET_CRYPTO_hash (member_id, sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), &sender); @@ -242,12 +229,12 @@ receive_cb (void *cls, struct GNUNET_CHAT_Room *room, { struct Wanted *want = cls; -#if VERBOSE - printf ("%s - told that %s said %s\n", want->me, - meta == NULL ? NULL : GNUNET_CONTAINER_meta_data_get_by_type (meta, - EXTRACTOR_METATYPE_TITLE), - message); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + + "%s - told that %s said %s\n", want->me, + meta == NULL ? NULL : GNUNET_CONTAINER_meta_data_get_by_type (meta, + EXTRACTOR_METATYPE_TITLE), + message); if ((0 == strcmp (message, want->msg)) && (((sender == NULL) && (want->sender == NULL)) || ((sender != NULL) && (want->sender != NULL) && @@ -280,12 +267,11 @@ confirmation_cb (void *cls, struct GNUNET_CHAT_Room *room, { struct Wanted *want = cls; -#if VERBOSE - printf ("%s - told that %s acknowledged message #%d\n", want->me, - GNUNET_CONTAINER_meta_data_get_by_type (want->meta, - EXTRACTOR_METATYPE_TITLE), - orig_seq_number); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "%s - told that %s acknowledged message #%d\n", want->me, + GNUNET_CONTAINER_meta_data_get_by_type (want->meta, + EXTRACTOR_METATYPE_TITLE), + orig_seq_number); if ((0 == memcmp (receiver, want->sender, sizeof (struct GNUNET_HashCode))) && (orig_seq_number == want->sequence_number) && (timestamp.abs_value >= want->timestamp.abs_value)) @@ -308,9 +294,6 @@ wait_until_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { GNUNET_SCHEDULER_Task task = cls; -#if VERBOSE - printf ("Waiting...\n"); -#endif if (is_ready) { wait_task = GNUNET_SCHEDULER_NO_TASK; @@ -327,9 +310,8 @@ wait_until_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void disconnect_alice (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { -#if VERBOSE - printf ("Alice is leaving.\n"); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Alice is leaving.\n"); if (is_p2p) stop_arm (&p2); GNUNET_CHAT_leave_room (alice_room); @@ -342,9 +324,8 @@ disconnect_alice (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void disconnect_bob (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { -#if VERBOSE - printf ("Bod is leaving.\n"); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Bob is leaving.\n"); alice_wanted.meta = NULL; alice_wanted.sender = &bob; alice_wanted.msg = NULL; @@ -366,10 +347,8 @@ set_ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void send_to_alice (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { -#if VERBOSE - printf ("Bob says 'Hi!'\n"); -#endif - + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Bob says 'Hi!'\n"); alice_wanted.meta = bob_meta; alice_wanted.sender = &bob; alice_wanted.msg = "Hi Alice!"; @@ -388,9 +367,8 @@ send_to_bob (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) enum GNUNET_CHAT_MsgOptions options; uint32_t *seq = NULL; -#if VERBOSE - printf ("Alice says 'Hi!'\n"); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Alice says 'Hi!'\n"); if (is_ackn) { options = GNUNET_CHAT_MSG_ACKNOWLEDGED; @@ -449,9 +427,8 @@ prepare_for_alice_task (void *cls, static void join_bob_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { -#if VERBOSE - printf ("Bob joining\n"); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Bob joining\n"); alice_wanted.meta = bob_meta; alice_wanted.sender = &bob; alice_wanted.msg = NULL; @@ -480,9 +457,8 @@ join_bob_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) static void join_alice_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { -#if VERBOSE - printf ("Alice joining\n"); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Alice joining\n"); alice_wanted.next_task = &join_bob_task; alice_wanted.next_task_cls = NULL; alice_room = @@ -537,9 +513,6 @@ main (int argc, char *argv[]) "test-chat", "-c", "test_chat_data.conf", -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { @@ -547,11 +520,7 @@ main (int argc, char *argv[]) }; GNUNET_log_setup ("test_chat", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); if (strstr (argv[0], "p2p") != NULL) { diff --git a/src/chat/test_chat_private.c b/src/chat/test_chat_private.c index 64150c107..b911d091f 100644 --- a/src/chat/test_chat_private.c +++ b/src/chat/test_chat_private.c @@ -32,8 +32,6 @@ #define VERBOSE GNUNET_NO -#define START_ARM GNUNET_YES - /** * How long until we give up on passing the test? */ @@ -47,9 +45,7 @@ struct PeerContext { struct GNUNET_CONFIGURATION_Handle *cfg; -#if START_ARM struct GNUNET_OS_Process *arm_proc; -#endif }; struct Wanted @@ -134,12 +130,10 @@ setup_peer (struct PeerContext *p, const char *cfgname) binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); -#if START_ARM p->arm_proc = GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, binary, "gnunet-service-arm", "-c", cfgname, NULL); -#endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); GNUNET_free (binary); } @@ -148,7 +142,6 @@ setup_peer (struct PeerContext *p, const char *cfgname) static void stop_arm (struct PeerContext *p) { -#if START_ARM if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) @@ -157,7 +150,6 @@ stop_arm (struct PeerContext *p) GNUNET_OS_process_get_pid (p->arm_proc)); GNUNET_OS_process_destroy (p->arm_proc); p->arm_proc = NULL; -#endif GNUNET_CONFIGURATION_destroy (p->cfg); } -- cgit v1.2.3