summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2019-06-06 03:29:37 +0200
committerJulius Bünger <buenger@mytum.de>2019-06-06 03:29:37 +0200
commit17cee253b6820e1c7aa18e51344a2fd5a14b809d (patch)
tree7f9a29ebf337bc60eeed6c657ac83238b43454db /src
parentc2eeb2f69ab1f0aa248781bebf04617cf9908e4b (diff)
TNG testing: Make executable name variable, try sending test data
Diffstat (limited to 'src')
-rw-r--r--src/transport/Makefile.am6
-rw-r--r--src/transport/test_communicator_unix.c25
-rw-r--r--src/transport/transport-testing2.c49
-rw-r--r--src/transport/transport-testing2.h1
4 files changed, 50 insertions, 31 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 4fd54ac88..5c3721faa 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -249,7 +249,9 @@ libexec_PROGRAMS = \
$(WLAN_BIN_DUMMY) \
$(BT_BIN) \
gnunet-service-transport \
- gnunet-communicator-unix
+ gnunet-communicator-unix \
+ gnunet-communicator-udp \
+ gnunet-communicator-tcp
@@ -600,6 +602,8 @@ if HAVE_GETOPT_BINARY
check_PROGRAMS += \
test_transport_api_slow_ats
endif
+check_PROGRAMS += \
+test_communicator_unix
endif
if ENABLE_TEST_RUN
diff --git a/src/transport/test_communicator_unix.c b/src/transport/test_communicator_unix.c
index e52391ef2..459af116a 100644
--- a/src/transport/test_communicator_unix.c
+++ b/src/transport/test_communicator_unix.c
@@ -32,18 +32,6 @@
#include <inttypes.h>
-/**
- * TODO
- * - start two communicators
- * - act like transport services
- * - get_server_addresses (service.c)
- * - open_listen_socket (service.c)
- * - GNUNET_MQ_queue_for_callbacks (service.c)
- * - let them communicate
- *
- */
-
-
#define LOG(kind,...) GNUNET_log_from (kind, "test_transport_communicator_unix", __VA_ARGS__)
@@ -55,6 +43,14 @@ static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_hs[NUM_PE
//static char *addresses[NUM_PEERS];
+
+#define PAYLOAD_SIZE 256
+
+//static char payload[PAYLOAD_SIZE] = "TEST PAYLOAD";
+//static char payload[] = "TEST PAYLOAD";
+static uint32_t payload = 42;
+
+
static void
communicator_available_cb (void *cls,
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
@@ -110,6 +106,9 @@ add_queue_cb (void *cls,
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Got Queue!\n");
+ GNUNET_TRANSPORT_TESTING_transport_communicator_send (tc_queue,
+ &payload,
+ sizeof (payload));
}
@@ -120,6 +119,7 @@ run (void *cls)
tc_hs[0] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
"transport",
+ "gnunet-communicator-unix",
"test_communicator_1.conf",
&communicator_available_cb,
NULL,
@@ -128,6 +128,7 @@ run (void *cls)
NULL); /* cls */
tc_hs[1] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
"transport",
+ "gnunet-communicator-unix",
"test_communicator_2.conf",
&communicator_available_cb,
&add_address_cb,
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index 9bbd15983..ff8e15719 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -541,19 +541,20 @@ shutdown_communicator (void *cls)
*/
static void
communicator_start (
- struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
+ const char *binary_name)
{
char *binary;
LOG (GNUNET_ERROR_TYPE_DEBUG, "communicator_start\n");
- binary = GNUNET_OS_get_libexec_binary_path ("gnunet-communicator-unix");
+ binary = GNUNET_OS_get_libexec_binary_path (binary_name);
tc_h->c_proc = GNUNET_OS_start_process (GNUNET_YES,
GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
NULL,
NULL,
NULL,
binary,
- "./gnunet-communicator-unix",
+ binary_name,
"-c",
tc_h->cfg_filename,
NULL);
@@ -583,14 +584,15 @@ communicator_start (
*/
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *
GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
- const char *service_name,
- const char *cfg_filename,
- GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback
- communicator_available_cb,
- GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb,
- GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb,
- GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb,
- void *cb_cls)
+ const char *service_name,
+ const char *binary_name,
+ const char *cfg_filename,
+ GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback
+ communicator_available_cb,
+ GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb,
+ GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb,
+ GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb,
+ void *cb_cls)
{
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h;
@@ -618,7 +620,8 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
transport_communicator_start (tc_h);
/* Schedule start communicator */
- communicator_start (tc_h);
+ communicator_start (tc_h,
+ binary_name);
return tc_h;
}
@@ -638,6 +641,7 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (
tc_queue =
GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue);
+ tc_queue->tc_h = tc_h;
prefix = GNUNET_HELLO_address_to_prefix (address);
if (NULL == prefix)
{
@@ -674,18 +678,27 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_send
GNUNET_TRANSPORT_TESTING_SuccessStatus cb,
void *cb_cls*/)
{
- // struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *tc_t;
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *tc_t;
+ struct GNUNET_MessageHeader *mh;
struct GNUNET_TRANSPORT_SendMessageTo *msg;
struct GNUNET_MQ_Envelope *env;
-
+ size_t inbox_size;
+
+ inbox_size = sizeof (struct GNUNET_MessageHeader) + payload_size;
+ mh = GNUNET_malloc (inbox_size);
+ mh->size = htons (inbox_size);
+ mh->type = GNUNET_MESSAGE_TYPE_DUMMY;
+ memcpy (&mh[1],
+ payload,
+ payload_size);
env = GNUNET_MQ_msg_extra (msg,
- payload_size,
+ inbox_size,
GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG);
msg->qid = htonl (tc_queue->qid);
msg->mid = tc_queue->mid++;
msg->receiver = tc_queue->peer_id;
- memcpy (&msg[1], payload, payload_size);
+ memcpy (&msg[1], mh, inbox_size);
+ GNUNET_free (mh);
GNUNET_MQ_send (tc_queue->tc_h->c_mq, env);
- GNUNET_break (0); /* fixme: return value? */
- return NULL; // tc_t;
+ return tc_t;
}
diff --git a/src/transport/transport-testing2.h b/src/transport/transport-testing2.h
index 4b9eb0f54..83d98baab 100644
--- a/src/transport/transport-testing2.h
+++ b/src/transport/transport-testing2.h
@@ -84,6 +84,7 @@ typedef void
struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *
GNUNET_TRANSPORT_TESTING_transport_communicator_service_start
(const char *service_name,
+ const char *binary_name,
const char *cfg_filename,
GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb,
GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb,