diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-10-31 21:19:37 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-10-31 21:19:37 +0000 |
commit | bfc865c4521d83f0bf4043017350ec4c8f65a34f (patch) | |
tree | 99af1695c33c256403c8178c4eb6b018aa77ea08 /src | |
parent | 6a7f8164026404f6e950d4df071cf71ef03e2ada (diff) | |
download | gnunet-bfc865c4521d83f0bf4043017350ec4c8f65a34f.tar.gz gnunet-bfc865c4521d83f0bf4043017350ec4c8f65a34f.zip |
various fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/testing/Makefile.am | 3 | ||||
-rw-r--r-- | src/testing/test_testing_connect.c | 2 | ||||
-rw-r--r-- | src/testing/test_testing_connect_peer1.conf | 2 | ||||
-rw-r--r-- | src/testing/test_testing_connect_peer2.conf | 2 | ||||
-rw-r--r-- | src/testing/test_testing_data.conf | 2 | ||||
-rw-r--r-- | src/testing/testing.c | 93 |
6 files changed, 75 insertions, 29 deletions
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am index 58e0f9e47..e62795a92 100644 --- a/src/testing/Makefile.am +++ b/src/testing/Makefile.am | |||
@@ -24,8 +24,7 @@ check_PROGRAMS = \ | |||
24 | test_testing \ | 24 | test_testing \ |
25 | test_testing_connect | 25 | test_testing_connect |
26 | 26 | ||
27 | TESTS = test_testing | 27 | TESTS = $(check_PROGRAMS) |
28 | # $(check_PROGRAMS) | ||
29 | 28 | ||
30 | test_testing_SOURCES = \ | 29 | test_testing_SOURCES = \ |
31 | test_testing.c | 30 | test_testing.c |
diff --git a/src/testing/test_testing_connect.c b/src/testing/test_testing_connect.c index 4e048851b..b6a2d859a 100644 --- a/src/testing/test_testing_connect.c +++ b/src/testing/test_testing_connect.c | |||
@@ -57,7 +57,7 @@ static void end2_cb(void *cls, | |||
57 | } | 57 | } |
58 | 58 | ||
59 | static void end1_cb(void *cls, | 59 | static void end1_cb(void *cls, |
60 | const char *emsg) | 60 | const char *emsg) |
61 | { | 61 | { |
62 | GNUNET_assert (emsg == NULL); | 62 | GNUNET_assert (emsg == NULL); |
63 | GNUNET_TESTING_daemon_stop (d2, &end2_cb, NULL); | 63 | GNUNET_TESTING_daemon_stop (d2, &end2_cb, NULL); |
diff --git a/src/testing/test_testing_connect_peer1.conf b/src/testing/test_testing_connect_peer1.conf index fd1baecb7..020504728 100644 --- a/src/testing/test_testing_connect_peer1.conf +++ b/src/testing/test_testing_connect_peer1.conf | |||
@@ -22,7 +22,7 @@ DEFAULTSERVICES = peerinfo transport core | |||
22 | PORT = 12567 | 22 | PORT = 12567 |
23 | HOSTNAME = localhost | 23 | HOSTNAME = localhost |
24 | 24 | ||
25 | [tcp] | 25 | [transport-tcp] |
26 | PORT = 12568 | 26 | PORT = 12568 |
27 | 27 | ||
28 | [peerinfo] | 28 | [peerinfo] |
diff --git a/src/testing/test_testing_connect_peer2.conf b/src/testing/test_testing_connect_peer2.conf index 44ba43a9d..196e96a84 100644 --- a/src/testing/test_testing_connect_peer2.conf +++ b/src/testing/test_testing_connect_peer2.conf | |||
@@ -22,7 +22,7 @@ HOSTNAME = localhost | |||
22 | PORT = 22567 | 22 | PORT = 22567 |
23 | HOSTNAME = localhost | 23 | HOSTNAME = localhost |
24 | 24 | ||
25 | [tcp] | 25 | [transport-tcp] |
26 | PORT = 22568 | 26 | PORT = 22568 |
27 | 27 | ||
28 | [peerinfo] | 28 | [peerinfo] |
diff --git a/src/testing/test_testing_data.conf b/src/testing/test_testing_data.conf index f314028d4..8af5d1a14 100644 --- a/src/testing/test_testing_data.conf +++ b/src/testing/test_testing_data.conf | |||
@@ -18,7 +18,7 @@ DEFAULTSERVICES = peerinfo transport core | |||
18 | [statistics] | 18 | [statistics] |
19 | PORT = 2567 | 19 | PORT = 2567 |
20 | 20 | ||
21 | [tcp] | 21 | [transport-tcp] |
22 | PORT = 2568 | 22 | PORT = 2568 |
23 | 23 | ||
24 | [peerinfo] | 24 | [peerinfo] |
diff --git a/src/testing/testing.c b/src/testing/testing.c index 0119e580f..b4d305e9e 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -40,7 +40,7 @@ | |||
40 | #include "gnunet_testing_lib.h" | 40 | #include "gnunet_testing_lib.h" |
41 | #include "gnunet_transport_service.h" | 41 | #include "gnunet_transport_service.h" |
42 | 42 | ||
43 | #define DEBUG_TESTING GNUNET_NO | 43 | #define DEBUG_TESTING GNUNET_YES |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * How long do we wait after starting gnunet-service-arm | 46 | * How long do we wait after starting gnunet-service-arm |
@@ -790,6 +790,7 @@ void GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, | |||
790 | return; | 790 | return; |
791 | } | 791 | } |
792 | GNUNET_CONFIGURATION_destroy (d->cfg); | 792 | GNUNET_CONFIGURATION_destroy (d->cfg); |
793 | GNUNET_break (GNUNET_OK == GNUNET_DISK_directory_remove (d->cfgfile)); | ||
793 | GNUNET_free (d->cfgfile); | 794 | GNUNET_free (d->cfgfile); |
794 | GNUNET_free_non_null (d->hostname); | 795 | GNUNET_free_non_null (d->hostname); |
795 | GNUNET_free_non_null (d->username); | 796 | GNUNET_free_non_null (d->username); |
@@ -915,12 +916,6 @@ struct ConnectContext | |||
915 | struct GNUNET_TRANSPORT_Handle *d2th; | 916 | struct GNUNET_TRANSPORT_Handle *d2th; |
916 | 917 | ||
917 | /** | 918 | /** |
918 | * When should this operation be complete (or we must trigger | ||
919 | * a timeout). | ||
920 | */ | ||
921 | struct GNUNET_TIME_Absolute timeout; | ||
922 | |||
923 | /** | ||
924 | * Function to call once we are done (or have timed out). | 919 | * Function to call once we are done (or have timed out). |
925 | */ | 920 | */ |
926 | GNUNET_TESTING_NotifyCompletion cb; | 921 | GNUNET_TESTING_NotifyCompletion cb; |
@@ -929,10 +924,47 @@ struct ConnectContext | |||
929 | * Closure for "nb". | 924 | * Closure for "nb". |
930 | */ | 925 | */ |
931 | void *cb_cls; | 926 | void *cb_cls; |
927 | |||
928 | /** | ||
929 | * Transmit handle for our request for transmission | ||
930 | * (as given to d2 asking to talk to d1). | ||
931 | */ | ||
932 | struct GNUNET_CORE_TransmitHandle *ntr; | ||
933 | |||
934 | /** | ||
935 | * When should this operation be complete (or we must trigger | ||
936 | * a timeout). | ||
937 | */ | ||
938 | struct GNUNET_TIME_Absolute timeout; | ||
939 | |||
932 | }; | 940 | }; |
933 | 941 | ||
934 | 942 | ||
935 | /** | 943 | /** |
944 | * Notify callback about success or failure of the attempt | ||
945 | * to connect the two peers | ||
946 | * | ||
947 | * @param cls our "struct ConnectContext" (freed) | ||
948 | * @param tc reason tells us if we succeeded or failed | ||
949 | */ | ||
950 | static void | ||
951 | notify_connect_result (void *cls, | ||
952 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
953 | { | ||
954 | struct ConnectContext *ctx = cls; | ||
955 | |||
956 | if (ctx->cb != NULL) | ||
957 | { | ||
958 | if ((tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT) != 0) | ||
959 | ctx->cb (ctx->cb_cls, _("Peers failed to connect")); | ||
960 | else | ||
961 | ctx->cb (ctx->cb_cls, NULL); | ||
962 | } | ||
963 | GNUNET_free (ctx); | ||
964 | } | ||
965 | |||
966 | |||
967 | /** | ||
936 | * Success, connection is up. Signal client our success. | 968 | * Success, connection is up. Signal client our success. |
937 | * | 969 | * |
938 | * @param cls our "struct ConnectContext" | 970 | * @param cls our "struct ConnectContext" |
@@ -945,16 +977,22 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
945 | { | 977 | { |
946 | struct ConnectContext *ctx = cls; | 978 | struct ConnectContext *ctx = cls; |
947 | 979 | ||
980 | #if DEBUG_TESTING | ||
981 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
982 | "Core notified us about readiness to transmit message, connection must be up!\n"); | ||
983 | #endif | ||
984 | ctx->ntr = NULL; | ||
948 | GNUNET_TRANSPORT_disconnect (ctx->d1th); | 985 | GNUNET_TRANSPORT_disconnect (ctx->d1th); |
986 | ctx->d1th = NULL; | ||
949 | GNUNET_TRANSPORT_disconnect (ctx->d2th); | 987 | GNUNET_TRANSPORT_disconnect (ctx->d2th); |
950 | if (NULL != ctx->cb) | 988 | ctx->d2th = NULL; |
951 | { | 989 | GNUNET_SCHEDULER_add_continuation (ctx->d1->sched, |
952 | if (buf == NULL) | 990 | GNUNET_NO, |
953 | ctx->cb (ctx->cb_cls, _("Peers failed to connect")); | 991 | ¬ify_connect_result, |
954 | else | 992 | ctx, |
955 | ctx->cb (ctx->cb_cls, NULL); | 993 | (buf == NULL) ? |
956 | } | 994 | GNUNET_SCHEDULER_REASON_TIMEOUT : |
957 | GNUNET_free (ctx); | 995 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
958 | return 0; | 996 | return 0; |
959 | } | 997 | } |
960 | 998 | ||
@@ -987,17 +1025,20 @@ process_hello (void *cls, | |||
987 | GNUNET_free (ctx); | 1025 | GNUNET_free (ctx); |
988 | return; | 1026 | return; |
989 | } | 1027 | } |
1028 | #if DEBUG_TESTING | ||
990 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1029 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
991 | "Received `%s' from transport service of `%4s'\n", | 1030 | "Received `%s' from transport service of `%4s'\n", |
992 | "HELLO", GNUNET_i2s (peer)); | 1031 | "HELLO", GNUNET_i2s (peer)); |
1032 | #endif | ||
993 | GNUNET_assert (message != NULL); | 1033 | GNUNET_assert (message != NULL); |
994 | GNUNET_TRANSPORT_offer_hello (ctx->d2th, message); | 1034 | GNUNET_TRANSPORT_offer_hello (ctx->d2th, message); |
995 | GNUNET_CORE_notify_transmit_ready (ctx->d2->server, | 1035 | ctx->ntr |
996 | 0, | 1036 | = GNUNET_CORE_notify_transmit_ready (ctx->d2->server, |
997 | GNUNET_TIME_absolute_get_remaining (ctx->timeout), | 1037 | 0, |
998 | &ctx->d1->id, | 1038 | GNUNET_TIME_absolute_get_remaining (ctx->timeout), |
999 | sizeof (struct GNUNET_MessageHeader), | 1039 | &ctx->d1->id, |
1000 | &transmit_ready, ctx); | 1040 | sizeof (struct GNUNET_MessageHeader), |
1041 | &transmit_ready, ctx); | ||
1001 | } | 1042 | } |
1002 | 1043 | ||
1003 | 1044 | ||
@@ -1032,7 +1073,10 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, | |||
1032 | ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 1073 | ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
1033 | ctx->cb = cb; | 1074 | ctx->cb = cb; |
1034 | ctx->cb_cls = cb_cls; | 1075 | ctx->cb_cls = cb_cls; |
1035 | ctx->d1th = GNUNET_TRANSPORT_connect (d1->sched, d1->cfg, d1, NULL, NULL, NULL); | 1076 | ctx->d1th = GNUNET_TRANSPORT_connect (d1->sched, |
1077 | d1->cfg, | ||
1078 | d1, | ||
1079 | NULL, NULL, NULL); | ||
1036 | if (ctx->d1th == NULL) | 1080 | if (ctx->d1th == NULL) |
1037 | { | 1081 | { |
1038 | GNUNET_free (ctx); | 1082 | GNUNET_free (ctx); |
@@ -1040,7 +1084,10 @@ void GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1, | |||
1040 | cb (cb_cls, _("Failed to connect to transport service!\n")); | 1084 | cb (cb_cls, _("Failed to connect to transport service!\n")); |
1041 | return; | 1085 | return; |
1042 | } | 1086 | } |
1043 | ctx->d2th = GNUNET_TRANSPORT_connect (d2->sched, d2->cfg, d2, NULL, NULL, NULL); | 1087 | ctx->d2th = GNUNET_TRANSPORT_connect (d2->sched, |
1088 | d2->cfg, | ||
1089 | d2, | ||
1090 | NULL, NULL, NULL); | ||
1044 | if (ctx->d2th == NULL) | 1091 | if (ctx->d2th == NULL) |
1045 | { | 1092 | { |
1046 | GNUNET_TRANSPORT_disconnect (ctx->d1th); | 1093 | GNUNET_TRANSPORT_disconnect (ctx->d1th); |