diff options
author | Martin Willi <martin@strongswan.org> | 2005-11-07 09:11:58 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2005-11-07 09:11:58 +0000 |
commit | 9317c2a1c68c987eb34e499762e95e9d81f09beb (patch) | |
tree | 49dab900b2bd5664b08f121554f64526094dd067 /Source/charon/tests | |
parent | e15f7292ec4663977c1ee0414634ca738949a087 (diff) | |
download | strongswan-9317c2a1c68c987eb34e499762e95e9d81f09beb.tar.bz2 strongswan-9317c2a1c68c987eb34e499762e95e9d81f09beb.tar.xz |
- revised packet and socket interface
- tested
Diffstat (limited to 'Source/charon/tests')
-rw-r--r-- | Source/charon/tests/send_queue_test.c | 2 | ||||
-rw-r--r-- | Source/charon/tests/socket_test.c | 31 |
2 files changed, 23 insertions, 10 deletions
diff --git a/Source/charon/tests/send_queue_test.c b/Source/charon/tests/send_queue_test.c index 0298899a9..603b6b0d4 100644 --- a/Source/charon/tests/send_queue_test.c +++ b/Source/charon/tests/send_queue_test.c @@ -67,7 +67,7 @@ static void test_send_queue_sender(send_queue_test_t * testinfo) int i; for (i = 0; i < testinfo->insert_item_count; i++) { - packet_t *packet = packet_create(); + packet_t *packet = packet_create(AF_INET); testinfo->tester->assert_true(testinfo->tester,(packet != NULL), "create packet call check"); testinfo->tester->assert_true(testinfo->tester,(testinfo->send_queue->add(testinfo->send_queue,packet) == SUCCESS), "add packet call check"); } diff --git a/Source/charon/tests/socket_test.c b/Source/charon/tests/socket_test.c index 230808782..8d735ac13 100644 --- a/Source/charon/tests/socket_test.c +++ b/Source/charon/tests/socket_test.c @@ -32,20 +32,33 @@ */ void test_socket(tester_t *tester) { - socket_t *skt = socket_create(); - packet_t *pkt = packet_create(); + int packet_count = 5; + int current; + socket_t *skt = socket_create(4500); + packet_t *pkt = packet_create(AF_INET); char *test_string = "Testing functionality of socket_t"; pkt->data.ptr = test_string; pkt->data.len = strlen(test_string); - pkt->receiver.addr.sin_family = AF_INET; - pkt->receiver.addr.sin_addr.s_addr = inet_addr("127.0.0.1"); - pkt->receiver.addr.sin_port = htons(500); - - skt->send(skt, pkt); + /* send to previously bound socket */ + pkt->set_destination(pkt, "127.0.0.1", 4500); + + /* send packet_count packets */ + for (current = 0; current < packet_count; current++) + { + if (skt->send(skt, pkt) == FAILED) + { + tester->assert_true(tester, 0, "packet send"); + } + } pkt->destroy(pkt); - skt->receive(skt, &pkt); - tester->assert_false(tester, strcmp(test_string, pkt->data.ptr), "packet exchange"); + /* receive packet_count packets */ + for (current = 0; current < packet_count; current++) + { + skt->receive(skt, &pkt); + tester->assert_false(tester, strcmp(test_string, pkt->data.ptr), "packet exchange"); + pkt->destroy(pkt); + } } |