[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r22152 - in gnunet/src: include nse stream testing
From: |
gnunet |
Subject: |
[GNUnet-SVN] r22152 - in gnunet/src: include nse stream testing |
Date: |
Wed, 20 Jun 2012 14:41:35 +0200 |
Author: grothoff
Date: 2012-06-20 14:41:35 +0200 (Wed, 20 Jun 2012)
New Revision: 22152
Modified:
gnunet/src/include/gnunet_testing_lib-new.h
gnunet/src/nse/Makefile.am
gnunet/src/stream/Makefile.am
gnunet/src/stream/stream_api.c
gnunet/src/stream/test_stream_big.c
gnunet/src/testing/testing.c
Log:
-working on stream
Modified: gnunet/src/include/gnunet_testing_lib-new.h
===================================================================
--- gnunet/src/include/gnunet_testing_lib-new.h 2012-06-20 12:16:32 UTC (rev
22151)
+++ gnunet/src/include/gnunet_testing_lib-new.h 2012-06-20 12:41:35 UTC (rev
22152)
@@ -177,6 +177,17 @@
/**
+ * Obtain the peer identity from a peer handle.
+ *
+ * @param peer peer handle for which we want the peer's identity
+ * @param id identifier for the daemon, will be set
+ */
+void
+GNUNET_TESTING_peer_get_identity (struct GNUNET_TESTING_Peer *peer,
+ struct GNUNET_PeerIdentity *id);
+
+
+/**
* Start the peer.
*
* @param peer peer to start
@@ -224,10 +235,11 @@
*
* @param cls closure
* @param cfg configuration of the peer that was started
+ * @param peer identity of the peer that was created
*/
typedef void (*GNUNET_TESTING_RestartableTestMain)(void *cls,
- const struct
GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_TESTING_Peer *peer);
+ const struct
GNUNET_CONFIGURATION_Handle *cfg,
+ const struct
GNUNET_TESTING_Peer *peer);
/**
@@ -287,6 +299,10 @@
* The only difference is that we handle the GNUNET_TESTING_Peer to
* the RestartableTestMain, so that the peer can be destroyed and re-created
* to simulate failure in tests.
+ *
+ * FIXME: change 'GNUNET_TESTING_TestMain' to have the 'restartable' signature
+ * and remove this extra function (in some sense, make this the primary one,
+ * but keep the old name).
*/
int
GNUNET_TESTING_service_run_restartable (const char *testdir,
Modified: gnunet/src/nse/Makefile.am
===================================================================
--- gnunet/src/nse/Makefile.am 2012-06-20 12:16:32 UTC (rev 22151)
+++ gnunet/src/nse/Makefile.am 2012-06-20 12:41:35 UTC (rev 22152)
@@ -34,7 +34,7 @@
gnunet-nse-profiler
gnunet_nse_profiler_SOURCES = \
- gnunet-nse-profiler.c
+ gnunet-nse-profiler.c
gnunet_nse_profiler_LDADD = -lm \
$(top_builddir)/src/nse/libgnunetnse.la \
$(top_builddir)/src/util/libgnunetutil.la \
Modified: gnunet/src/stream/Makefile.am
===================================================================
--- gnunet/src/stream/Makefile.am 2012-06-20 12:16:32 UTC (rev 22151)
+++ gnunet/src/stream/Makefile.am 2012-06-20 12:41:35 UTC (rev 22152)
@@ -62,7 +62,7 @@
test_stream_big_LDADD = \
$(top_builddir)/src/stream/libgnunetstream.la \
$(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/testing_old/libgnunettesting_old.la
+ $(top_builddir)/src/testing/libgnunettesting.la
test_stream_sequence_wraparound_SOURCES = \
test_stream_sequence_wraparound.c
Modified: gnunet/src/stream/stream_api.c
===================================================================
--- gnunet/src/stream/stream_api.c 2012-06-20 12:16:32 UTC (rev 22151)
+++ gnunet/src/stream/stream_api.c 2012-06-20 12:41:35 UTC (rev 22152)
@@ -702,6 +702,7 @@
return size;
}
+
/**
* Writes data using the given socket. The amount of data written is limited by
* the receiver_window_size
@@ -711,6 +712,7 @@
static void
write_data (struct GNUNET_STREAM_Socket *socket);
+
/**
* Task for retransmitting data messages if they aren't ACK before their ack
* deadline
@@ -1294,7 +1296,6 @@
socket->write_offset = 0;
socket->read_offset = 0;
socket->state = STATE_ESTABLISHED;
- /* FIXME: What if listen_cb is NULL */
if (NULL != socket->lsocket)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1306,12 +1307,12 @@
&socket->other_peer))
{
socket->state = STATE_CLOSED;
- /* FIXME: We should close in a decent way */
+ /* FIXME: We should close in a decent way (send RST) */
GNUNET_MESH_tunnel_destroy (socket->tunnel); /* Destroy the tunnel */
GNUNET_free (socket);
}
}
- else if (socket->open_cb)
+ else if (NULL != socket->open_cb)
socket->open_cb (socket->open_cls, socket);
}
@@ -1404,6 +1405,7 @@
socket->state = STATE_CLOSED;
}
+
/**
* Returns a new HelloAckMessage. Also sets the write sequence number for the
* socket
@@ -3068,7 +3070,6 @@
if (GNUNET_SCHEDULER_NO_TASK != handle->close_msg_retransmission_task_id)
GNUNET_SCHEDULER_cancel (handle->close_msg_retransmission_task_id);
GNUNET_free (handle);
- return;
}
@@ -3180,6 +3181,7 @@
enum GNUNET_STREAM_Option option;
va_list vargs;
+ GNUNET_assert (NULL != listen_cb);
lsocket = GNUNET_malloc (sizeof (struct GNUNET_STREAM_ListenSocket));
lsocket->cfg = GNUNET_CONFIGURATION_dup (cfg);
lsocket->lockmanager = GNUNET_LOCKMANAGER_connect (lsocket->cfg);
@@ -3376,7 +3378,6 @@
}
-
/**
* Tries to read data from the stream.
*
@@ -3479,7 +3480,6 @@
GNUNET_free (socket->write_handle);
socket->write_handle = NULL;
- return;
}
@@ -3491,5 +3491,7 @@
void
GNUNET_STREAM_io_read_cancel (struct GNUNET_STREAM_IOReadHandle *ioh)
{
- return;
+ // FIXME: do stuff
}
+
+/* end of stream_api.c */
Modified: gnunet/src/stream/test_stream_big.c
===================================================================
--- gnunet/src/stream/test_stream_big.c 2012-06-20 12:16:32 UTC (rev 22151)
+++ gnunet/src/stream/test_stream_big.c 2012-06-20 12:41:35 UTC (rev 22152)
@@ -29,7 +29,7 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_stream_lib.h"
-#include "gnunet_testing_lib.h"
+#include "gnunet_testing_lib-new.h"
#define LOG(kind, ...) \
GNUNET_log (kind, __VA_ARGS__);
@@ -48,6 +48,8 @@
*/
struct GNUNET_STREAM_Socket *socket;
+ struct GNUNET_PeerIdentity self;
+
/**
* Peer's io write handle
*/
@@ -69,11 +71,10 @@
unsigned int bytes_read;
};
-static struct GNUNET_OS_Process *arm_pid;
static struct PeerData peer1;
static struct PeerData peer2;
static struct GNUNET_STREAM_ListenSocket *peer2_listen_socket;
-static struct GNUNET_CONFIGURATION_Handle *config;
+static const struct GNUNET_CONFIGURATION_Handle *config;
static GNUNET_SCHEDULER_TaskIdentifier abort_task;
static GNUNET_SCHEDULER_TaskIdentifier test_task;
@@ -100,16 +101,7 @@
{
GNUNET_SCHEDULER_cancel (abort_task);
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: arm\n");
- if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM))
- {
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Wait\n");
- /* Free the duplicated configuration */
- GNUNET_CONFIGURATION_destroy (config);
- GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid));
- GNUNET_OS_process_destroy (arm_pid);
}
@@ -340,14 +332,10 @@
stream_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct PeerData *peer = cls;
- struct GNUNET_PeerIdentity self;
- GNUNET_assert (&peer1 == peer);
- GNUNET_assert (GNUNET_OK == GNUNET_TESTING_get_peer_identity (config,
- &self));
/* Connect to stream */
peer->socket = GNUNET_STREAM_open (config,
- &self, /* Null for local peer? */
+ &peer2.self, /* Null for local
peer? */
10, /* App port */
&stream_open_cb,
&peer1,
@@ -357,87 +345,45 @@
/**
- * Testing function
+ * Initialize framework and start test
*
- * @param cls NULL
- * @param tc the task context
+ * @param cls closure
+ * @param cfg configuration of the peer that was started
+ * @param peer identity of the peer that was created
*/
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)
{
struct GNUNET_PeerIdentity self;
-
- test_task = GNUNET_SCHEDULER_NO_TASK;
- /* Get our identity */
- GNUNET_assert (GNUNET_OK == GNUNET_TESTING_get_peer_identity (config,
- &self));
-
+
+ GNUNET_TESTING_peer_get_identity (peer, &self);
+ config = cfg;
+ abort_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
+ (GNUNET_TIME_UNIT_SECONDS, 60), &do_abort,
+ NULL);
peer2_listen_socket = GNUNET_STREAM_listen (config,
10, /* App port */
&stream_listen_cb,
NULL,
GNUNET_STREAM_OPTION_END);
GNUNET_assert (NULL != peer2_listen_socket);
+ peer1.self = self;
+ peer2.self = self;
GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS(2), &stream_connect, &peer1);
}
-
/**
- * Initialize framework and start test
- */
-static void
-run (void *cls, char *const *args, const char *cfgfile,
- const struct GNUNET_CONFIGURATION_Handle *cfg)
-{
- /* Duplicate the configuration */
- 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_stream_local.conf", NULL);
-
- abort_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_SECONDS, 60), &do_abort,
- NULL);
- test_task = GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS(3), &test, NULL);
-}
-
-/**
* Main function
*/
int main (int argc, char **argv)
{
- int ret;
-
- char *const argv2[] = { "test-stream-big",
- "-c", "test_stream_local.conf",
- "-L", "DEBUG",
- NULL
- };
-
- struct GNUNET_GETOPT_CommandLineOption options[] = {
- GNUNET_GETOPT_OPTION_END
- };
-
- ret =
- GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
- "test-stream-big", "nohelp", options, &run, NULL);
-
- if (GNUNET_OK != ret)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "run failed with error code %d\n",
- ret);
+ if (0 != GNUNET_TESTING_service_run_restartable ("test-stream-big",
+ "arm",
+ "test_stream_local.conf",
+ &run, NULL))
return 1;
- }
- if (GNUNET_SYSERR == result)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "test failed\n");
- return 1;
- }
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test ok\n");
- return 0;
+ return (GNUNET_SYSERR == result) ? 1 : 0;
}
Modified: gnunet/src/testing/testing.c
===================================================================
--- gnunet/src/testing/testing.c 2012-06-20 12:16:32 UTC (rev 22151)
+++ gnunet/src/testing/testing.c 2012-06-20 12:41:35 UTC (rev 22152)
@@ -800,6 +800,21 @@
/**
+ * Obtain the peer identity from a peer handle.
+ *
+ * @param peer peer handle for which we want the peer's identity
+ * @param id identifier for the daemon, will be set
+ */
+void
+GNUNET_TESTING_peer_get_identity (struct GNUNET_TESTING_Peer *peer,
+ struct GNUNET_PeerIdentity *id)
+{
+ GNUNET_assert (0); // FIXME-SREE.
+ // *id = peer->id;
+}
+
+
+/**
* Start the peer.
*
* @param peer peer to start
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r22152 - in gnunet/src: include nse stream testing,
gnunet <=