[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4817 - in GNUnet/src: applications/advertising application
From: |
gnunet |
Subject: |
[GNUnet-SVN] r4817 - in GNUnet/src: applications/advertising applications/dht/tools applications/identity applications/testing include |
Date: |
Sun, 27 May 2007 20:44:36 -0600 (MDT) |
Author: grothoff
Date: 2007-05-27 20:44:36 -0600 (Sun, 27 May 2007)
New Revision: 4817
Modified:
GNUnet/src/applications/advertising/advertising.c
GNUnet/src/applications/dht/tools/Makefile.am
GNUnet/src/applications/dht/tools/dhttest2.c
GNUnet/src/applications/identity/identity.c
GNUnet/src/applications/testing/gnunet-testing.conf
GNUnet/src/applications/testing/testing.c
GNUnet/src/applications/testing/testingtest.c
GNUnet/src/include/gnunet_protocols.h
Log:
getting dht test to compile again
Modified: GNUnet/src/applications/advertising/advertising.c
===================================================================
--- GNUnet/src/applications/advertising/advertising.c 2007-05-28 02:08:08 UTC
(rev 4816)
+++ GNUnet/src/applications/advertising/advertising.c 2007-05-28 02:44:36 UTC
(rev 4817)
@@ -685,7 +685,7 @@
static int
phelloHandler(const PeerIdentity * sender,
const MESSAGE_HEADER * message,
- TSession * session) {
+ TSession * session) {
receivedhello(message);
return OK;
}
Modified: GNUnet/src/applications/dht/tools/Makefile.am
===================================================================
--- GNUnet/src/applications/dht/tools/Makefile.am 2007-05-28 02:08:08 UTC
(rev 4816)
+++ GNUnet/src/applications/dht/tools/Makefile.am 2007-05-28 02:44:36 UTC
(rev 4817)
@@ -24,20 +24,20 @@
-#check_PROGRAMS = \
-# dhttest2
+check_PROGRAMS = \
+ dhttest2
-#TESTS = $(check_PROGRAMS)
+TESTS = $(check_PROGRAMS)
-#dhttest2_SOURCES = \
-# dhttest2.c
-#dhttest2_LDADD = \
-# $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
-# $(top_builddir)/src/applications/dht/tools/libgnunetdht_api.la \
-#
$(top_builddir)/src/applications/dht/module/libgnunetdht_datastore_memory.la \
-# $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
-# $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
-# $(top_builddir)/src/util/libgnunetutil.la
+dhttest2_SOURCES = \
+ dhttest2.c
+dhttest2_LDADD = \
+ $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
+ $(top_builddir)/src/applications/testing/libgnunettesting_api.la \
+ $(top_builddir)/src/applications/dht/tools/libgnunetdht_api.la \
+ $(top_builddir)/src/util/config_impl/libgnunetutil_config.la \
+ $(top_builddir)/src/util/network_client/libgnunetutil_network_client.la \
+ $(top_builddir)/src/util/libgnunetutil.la
EXTRA_DIST = \
check.conf \
Modified: GNUnet/src/applications/dht/tools/dhttest2.c
===================================================================
--- GNUnet/src/applications/dht/tools/dhttest2.c 2007-05-28 02:08:08 UTC
(rev 4816)
+++ GNUnet/src/applications/dht/tools/dhttest2.c 2007-05-28 02:44:36 UTC
(rev 4817)
@@ -27,33 +27,17 @@
#include "platform.h"
#include "gnunet_protocols.h"
#include "gnunet_dht_lib.h"
-#include "gnunet_dht_datastore_memory.h"
+#include "gnunet_testing_lib.h"
#include "gnunet_stats_lib.h"
#include "gnunet_util_config_impl.h"
#include "gnunet_util_network_client.h"
#include "gnunet_util_cron.h"
-/**
- * Identity of peer 2 (hardwired).
- */
-static PeerIdentity peer2;
-static int waitForConnect(const char * name,
- unsigned long long value,
- void * cls) {
- if ( (value > 0) &&
- (0 == strcmp(_("# of connected peers"),
- name)) )
- return SYSERR;
- return OK;
-}
-
#define START_PEERS 1
#define CHECK(a) do { if (!(a)) { ret = 1; GE_BREAK(ectx, 0); goto FAILURE; }
} while(0)
-#define CHECK2(a) do { if (!(a)) { ret = 1; GE_BREAK(ectx, 0); goto FAILURE2;
} } while(0)
-
/**
* Testcase to test gap routing (2 peers only).
* @return 0: ok, -1: error
@@ -63,21 +47,16 @@
#if START_PEERS
pid_t daemon1;
pid_t daemon2;
+ PeerIdentity peer1;
+ PeerIdentity peer2;
#endif
int ret;
- struct ClientServerConnection * sock;
- int left;
- DHT_TableId table;
- DHT_TableId key;
+ HashCode512 key;
DataContainer * value;
struct GE_Context * ectx;
struct GC_Configuration * cfg;
ectx = NULL;
- enc2hash("BV3AS3KMIIBVIFCGEG907N6NTDTH26B7T6FODUSLSGK"
- "5B2Q58IEU1VF5FTR838449CSHVBOAHLDVQAOA33O77F"
- "OPDA8F1VIKESLSNBO",
- &peer2.hashPubKey);
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
"check.conf")) {
@@ -85,96 +64,29 @@
return -1;
}
#if START_PEERS
- daemon1 = os_daemon_start(NULL,
- cfg,
- "peer1.conf",
- NO);
- daemon2 = os_daemon_start(NULL,
- cfg,
- "peer2.conf",
- NO);
-#endif
- /* in case existing hellos have expired */
- PTHREAD_SLEEP(30 * cronSECONDS);
- system("cp peer1/data/hosts/* peer2/data/hosts/");
- system("cp peer2/data/hosts/* peer1/data/hosts/");
- ret = 0;
-#if START_PEERS
- if (daemon1 != -1) {
- if (os_daemon_stop(NULL, daemon1) != YES)
- ret = 1;
+ if ( (OK != gnunet_testing_start_daemon(12087,
+ 10000,
+ "/tmp/dht-test-1",
+ "tcp",
+ "advertising dht",
+ &daemon1,
+ &peer1)) ||
+ (OK != gnunet_testing_start_daemon(22087,
+ 20000,
+ "/tmp/dht-test-2",
+ "tcp",
+ "advertising dht",
+ &daemon2,
+ &peer2)) ||
+ (OK != gnunet_testing_connect_daemons(12087,
+ 22087)) ) {
+ gnunet_testing_stop_daemon(12087, daemon1);
+ gnunet_testing_stop_daemon(12087, daemon2);
+ GC_free(cfg);
+ return -1;
}
- if (daemon2 != -1) {
- if (os_daemon_stop(NULL, daemon2) != YES)
- ret = 1;
- }
- if (ret != 0)
- return 1;
- daemon1 = os_daemon_start(NULL,
- cfg,
- "peer1.conf",
- NO);
- daemon2 = os_daemon_start(NULL,
- cfg,
- "peer2.conf",
- NO);
#endif
- if (OK == connection_wait_for_running(NULL,
- cfg,
- 30 * cronSECONDS)) {
- sock = client_connection_create(NULL,
- cfg);
- left = 30; /* how many iterations should we wait? */
- while (OK == requestStatistics(ectx,
- sock,
- &waitForConnect,
- NULL)) {
- printf("Waiting for peers to connect (%u iterations left)...\n",
- left);
- sleep(5);
- left--;
- if (left == 0) {
- ret = 1;
- break;
- }
- }
- connection_destroy(sock);
- } else {
- printf("Could not establish connection with peer.\n");
- ret = 1;
- }
- ret = 0;
- left = 5;
- /* wait for connection or abort with error */
- do {
- sock = client_connection_create(ectx, cfg);
- if (sock == NULL) {
- printf(_("Waiting for gnunetd to start (%u iterations left)...\n"),
- left);
- sleep(1);
- left--;
- CHECK(left > 0);
- }
- } while (sock == NULL);
-
- left = 30; /* how many iterations should we wait? */
- while (OK == requestStatistics(ectx,
- sock,
- &waitForConnect,
- NULL)) {
- printf(_("Waiting for peers to connect (%u iterations left)...\n"),
- left);
- sleep(5);
- left--;
- CHECK(left > 0);
- }
- connection_destroy(sock);
- printf("Peers connected. Running actual test.\n");
-
- memset(&table, 33, sizeof(DHT_TableId));
- store = create_blockstore_memory(65536);
-
/* actual test code */
hash("key2", 4, &key);
value = MALLOC(8);
@@ -185,18 +97,14 @@
printf("Peer1 stores key2\n");
CHECK(OK == DHT_LIB_put(cfg,
ectx,
- &table,
&key,
- 0,
+ DHT_STRING2STRING_BLOCK,
5 * cronSECONDS,
value));
printf("Peer1 gets key2\n");
CHECK(1 == DHT_LIB_get(cfg,
ectx,
- &table,
- 0,
- 0,
- 1,
+ DHT_STRING2STRING_BLOCK,
&key,
10 * cronSECONDS,
NULL,
@@ -216,37 +124,30 @@
'B',
4);
printf("Peer2 stores key.\n");
- CHECK2(OK == DHT_LIB_put(cfg,
- ectx,
- &table,
- &key,
- 0,
- 5 * cronSECONDS,
- value));
- printf("Peer2 gets key.\n");
- CHECK2(1 == DHT_LIB_get(cfg,
+ CHECK(OK == DHT_LIB_put(cfg,
ectx,
- &table,
- 0,
- 0,
- 1,
&key,
- 10 * cronSECONDS,
- NULL,
- NULL));
+ DHT_STRING2STRING_BLOCK,
+ 5 * cronSECONDS,
+ value));
+ printf("Peer2 gets key.\n");
+ CHECK(1 == DHT_LIB_get(cfg,
+ ectx,
+ DHT_STRING2STRING_BLOCK,
+ &key,
+ 10 * cronSECONDS,
+ NULL,
+ NULL));
hash("key2", 4, &key);
printf("Peer2 gets key2.\n");
- CHECK2(1 == DHT_LIB_get(cfg,
- ectx,
- &table,
- 0,
- 0,
- 1,
- &key,
- 60 * cronSECONDS,
- NULL,
- NULL));
+ CHECK(1 == DHT_LIB_get(cfg,
+ ectx,
+ DHT_STRING2STRING_BLOCK,
+ &key,
+ 60 * cronSECONDS,
+ NULL,
+ NULL));
printf("Peer2 tests successful.\n");
/* switch to peer1 */
@@ -258,10 +159,7 @@
printf("Peer1 gets key\n");
CHECK(1 == DHT_LIB_get(cfg,
ectx,
- &table,
- 0,
- 0,
- 1,
+ DHT_STRING2STRING_BLOCK,
&key,
60 * cronSECONDS,
NULL,
@@ -270,16 +168,9 @@
/* end of actual test code */
FAILURE:
-
#if START_PEERS
- if (daemon1 != -1) {
- if (os_daemon_stop(NULL, daemon1) != YES)
- ret = 1;
- }
- if (daemon2 != -1) {
- if (os_daemon_stop(NULL, daemon2) != YES)
- ret = 1;
- }
+ gnunet_testing_stop_daemon(12087, daemon1);
+ gnunet_testing_stop_daemon(12087, daemon2);
#endif
GC_free(cfg);
return ret;
Modified: GNUnet/src/applications/identity/identity.c
===================================================================
--- GNUnet/src/applications/identity/identity.c 2007-05-28 02:08:08 UTC (rev
4816)
+++ GNUnet/src/applications/identity/identity.c 2007-05-28 02:44:36 UTC (rev
4817)
@@ -1123,11 +1123,19 @@
const P2P_hello_MESSAGE * msg;
P2P_hello_MESSAGE * hello;
- if (sizeof(P2P_hello_MESSAGE) < ntohs(message->size))
+ if (sizeof(P2P_hello_MESSAGE) > ntohs(message->size)) {
+ GE_BREAK(NULL, 0);
return SYSERR;
+ }
msg = (const P2P_hello_MESSAGE*) message;
+ if (P2P_hello_MESSAGE_size(msg) != ntohs(message->size)) {
+ GE_BREAK(NULL, 0);
+ return SYSERR;
+ }
hello = MALLOC(ntohs(msg->header.size));
- memcpy(hello, msg, ntohs(msg->header.size));
+ memcpy(hello,
+ msg,
+ ntohs(msg->header.size));
hello->header.type = htons(p2p_PROTO_hello);
coreAPI->injectMessage(NULL,
(const char*) hello,
Modified: GNUnet/src/applications/testing/gnunet-testing.conf
===================================================================
--- GNUnet/src/applications/testing/gnunet-testing.conf 2007-05-28 02:08:08 UTC
(rev 4816)
+++ GNUnet/src/applications/testing/gnunet-testing.conf 2007-05-28 02:44:36 UTC
(rev 4817)
@@ -10,7 +10,7 @@
KEEPLOG = 0
PIDFILE = $GNUNETD_HOME/gnunetd.pid
HOSTS = $GNUNETD_HOME/data/hosts/
-APPLICATIONS = ""
+APPLICATIONS = "advertising"
TRANSPORTS = ""
[LOGGING]
Modified: GNUnet/src/applications/testing/testing.c
===================================================================
--- GNUnet/src/applications/testing/testing.c 2007-05-28 02:08:08 UTC (rev
4816)
+++ GNUnet/src/applications/testing/testing.c 2007-05-28 02:44:36 UTC (rev
4817)
@@ -93,6 +93,9 @@
cfg = GC_create_C_impl();
if (-1 == GC_parse_configuration(cfg,
dpath)) {
+ fprintf(stderr,
+ "Failed to read default configuration file `%s'\n",
+ dpath);
GC_free(cfg);
FREE(dpath);
return SYSERR;
@@ -140,6 +143,9 @@
CLOSE(ret);
if (0 != GC_write_configuration(cfg,
dpath)) {
+ fprintf(stderr,
+ "Failed to write peer configuration file `%s'\n",
+ dpath);
FREE(dpath);
GC_free(cfg);
return SYSERR;
@@ -163,6 +169,8 @@
dpath,
NO);
if (ret == -1) {
+ fprintf(stderr,
+ "Failed to start daemon!\n");
GC_free(cfg);
return SYSERR;
}
@@ -171,13 +179,15 @@
/* now get peer ID */
if (OK != connection_wait_for_running(NULL,
cfg,
- 30 * cronSECONDS)) {
+ 60 * cronSECONDS)) {
+ fprintf(stderr,
+ "Failed to confirm daemon running!\n");
GC_free(cfg);
UNLINK(dpath);
FREE(dpath);
return SYSERR;
}
- // UNLINK(dpath);
+ UNLINK(dpath);
FREE(dpath);
sock = client_connection_create(NULL,
cfg);
@@ -188,6 +198,9 @@
sizeof(PublicKey),
&peer->hashPubKey);
FREE(hello);
+ } else {
+ fprintf(stderr,
+ "Failed to obtain daemon's identity (is a transport loaded?)!\n");
}
connection_destroy(sock);
GC_free(cfg);
@@ -253,15 +266,25 @@
h2)) &&
(OK == gnunet_identity_peer_add(sock2,
h1)) ) {
- ret = 10;
- while (ret-- >= 0) {
+ ret = - 30;
+ fprintf(stderr,
+ _("Waiting for peers to connect"));
+ while ( (ret++ < -1) &&
+ (GNUNET_SHUTDOWN_TEST() == NO) ) {
+ fprintf(stderr, ".");
if (YES == gnunet_identity_request_connect(sock1,
&h2->senderIdentity)) {
ret = OK;
break;
}
+ if (YES == gnunet_identity_request_connect(sock2,
+ &h1->senderIdentity)) {
+ ret = OK;
+ break;
+ }
PTHREAD_SLEEP(2 * cronSECONDS);
}
+ fprintf(stderr, "%s\n", ret == OK ? "!" : "?");
}
FREENONNULL(h1);
FREENONNULL(h2);
@@ -271,6 +294,8 @@
fprintf(stderr,
"Failed to establish connection with peers.\n");
}
+ GC_free(cfg1);
+ GC_free(cfg2);
return ret;
}
Modified: GNUnet/src/applications/testing/testingtest.c
===================================================================
--- GNUnet/src/applications/testing/testingtest.c 2007-05-28 02:08:08 UTC
(rev 4816)
+++ GNUnet/src/applications/testing/testingtest.c 2007-05-28 02:44:36 UTC
(rev 4817)
@@ -44,7 +44,7 @@
10000,
"/tmp/gnunet-testing-1",
"tcp",
- "stats",
+ "advertising stats",
&daemon1,
&p1))
ret |= 1;
@@ -52,7 +52,7 @@
20000,
"/tmp/gnunet-testing-2",
"tcp",
- "stats",
+ "advertising stats",
&daemon2,
&p2))
ret |= 2;
Modified: GNUnet/src/include/gnunet_protocols.h
===================================================================
--- GNUnet/src/include/gnunet_protocols.h 2007-05-28 02:08:08 UTC (rev
4816)
+++ GNUnet/src/include/gnunet_protocols.h 2007-05-28 02:44:36 UTC (rev
4817)
@@ -463,7 +463,7 @@
#define KN_BLOCK 5
/**
- * DHT String2String (for dht-query/dht-join).
+ * DHT String2String (for dht-testing)
*/
#define DHT_STRING2STRING_BLOCK 7
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4817 - in GNUnet/src: applications/advertising applications/dht/tools applications/identity applications/testing include,
gnunet <=