aboutsummaryrefslogtreecommitdiffstats
path: root/test/gtest/test_tle_udp_stream.cpp
diff options
context:
space:
mode:
authorKonstantin Ananyev <konstantin.ananyev@intel.com>2017-02-21 18:12:20 +0000
committerKonstantin Ananyev <konstantin.ananyev@intel.com>2017-02-24 16:37:08 +0000
commitaa97dd1ce910b839fed46ad55d1e70e403f5a930 (patch)
treef6f0fd494eaf499859bff9f20f5ddfac9ab99233 /test/gtest/test_tle_udp_stream.cpp
parentf5f10013ffef8e4ac1071087b8492fe6380d98fe (diff)
Introduce first version of TCP code.
Supported functionality: - open/close - listen/accept/connect - send/recv In order to achieve that libtle_udp library was reworked into libtle_l4p library that supports both TCP and UDP protocols. New libtle_timer library was introduced (thanks to Cisco guys and Dave Barach <dbarach@cisco.com> for sharing their timer code with us). Sample application was also reworked significantly to support both TCP and UDP traffic handling. New UT were introduced. Change-Id: I806b05011f521e89b58db403cfdd484a37beb775 Signed-off-by: Mohammad Abdul Awal <mohammad.abdul.awal@intel.com> Signed-off-by: Karol Latecki <karolx.latecki@intel.com> Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com> Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Diffstat (limited to 'test/gtest/test_tle_udp_stream.cpp')
-rw-r--r--test/gtest/test_tle_udp_stream.cpp78
1 files changed, 70 insertions, 8 deletions
diff --git a/test/gtest/test_tle_udp_stream.cpp b/test/gtest/test_tle_udp_stream.cpp
index 22a1b44..44a8a65 100644
--- a/test/gtest/test_tle_udp_stream.cpp
+++ b/test/gtest/test_tle_udp_stream.cpp
@@ -14,15 +14,14 @@
*/
#include "test_tle_udp_stream.h"
+#include <arpa/inet.h>
TEST_F(test_tle_udp_stream, stream_test_open)
{
stream = tle_udp_stream_open(ctx,
(const struct tle_udp_stream_param *)&stream_prm);
EXPECT_NE(stream, nullptr);
- ret = tle_udp_stream_close(stream);
-
- EXPECT_EQ(ret, 0);
+ streams.push_back(stream);
}
TEST_F(test_tle_udp_stream, stream_test_open_nullctx)
@@ -60,8 +59,20 @@ TEST_F(test_tle_udp_stream, stream_test_open_close_open_close)
(const struct tle_udp_stream_param*)&stream_prm);
EXPECT_NE(stream, nullptr);
- ret = tle_udp_stream_close(stream);
- EXPECT_EQ(ret, 0);
+ streams.push_back(stream);
+}
+
+TEST_F(test_tle_udp_stream, stream_test_open_duplicate)
+{
+ stream = tle_udp_stream_open(ctx,
+ (const struct tle_udp_stream_param *)&stream_prm);
+ EXPECT_NE(stream, nullptr);
+ streams.push_back(stream);
+
+ stream = tle_udp_stream_open(ctx,
+ (const struct tle_udp_stream_param *)&stream_prm);
+ EXPECT_EQ(stream, nullptr);
+ EXPECT_EQ(rte_errno, EEXIST);
}
TEST_F(test_tle_udp_stream, stream_test_close)
@@ -80,7 +91,6 @@ TEST_F(test_tle_udp_stream, stream_test_close_null)
EXPECT_EQ(ret, -EINVAL);
}
-
TEST_F(test_tle_udp_stream, stream_test_close_already)
{
stream = tle_udp_stream_open(ctx,
@@ -92,6 +102,7 @@ TEST_F(test_tle_udp_stream, stream_test_close_already)
ret = tle_udp_stream_close(stream);
EXPECT_NE(ret, 0);
+ EXPECT_EQ(ret, -EINVAL);
}
TEST_F(test_tle_udp_stream, stream_get_param)
@@ -101,6 +112,7 @@ TEST_F(test_tle_udp_stream, stream_get_param)
stream = tle_udp_stream_open(ctx,
(const struct tle_udp_stream_param *)&stream_prm);
EXPECT_NE(stream, nullptr);
+ streams.push_back(stream);
ret = tle_udp_stream_get_param(stream,&prm);
EXPECT_EQ(ret, 0);
@@ -113,6 +125,7 @@ TEST_F(test_tle_udp_stream, stream_get_param_streamnull)
stream = tle_udp_stream_open(ctx,
(const struct tle_udp_stream_param *)&stream_prm);
EXPECT_NE(stream, nullptr);
+ streams.push_back(stream);
ret = tle_udp_stream_get_param(nullptr, &prm);
EXPECT_EQ(ret, -EINVAL);
@@ -125,10 +138,59 @@ TEST_F(test_tle_udp_stream, stream_get_param_prmnull)
stream = tle_udp_stream_open(ctx,
(const struct tle_udp_stream_param *)&stream_prm);
EXPECT_NE(stream, nullptr);
+ streams.push_back(stream);
ret = tle_udp_stream_get_param(stream, nullptr);
EXPECT_EQ(ret, -EINVAL);
}
-
-
+TEST_F(test_tle_udp_stream_max, stream_test_open_max)
+{
+ int i, j, cnt;
+ struct in_addr src_s;
+ struct in_addr dst_s;
+ int dst_port = 32678;
+ struct sockaddr_in *l_ipv4;
+ struct sockaddr_in *r_ipv4;
+
+ /* Set fields that will not change in sockaddr structures */
+ inet_pton(AF_INET, base_l_ipv4, &src_s);
+ l_ipv4 = (struct sockaddr_in *) &stream_prm.local_addr;
+ l_ipv4->sin_family = AF_INET;
+ l_ipv4->sin_port = htons(0);
+
+ inet_pton(AF_INET, base_r_ipv4, &dst_s);
+ r_ipv4 = (struct sockaddr_in *) &stream_prm.remote_addr;
+ r_ipv4->sin_family = AF_INET;
+
+ for(i = 0, cnt = 0; i < devs.size(); i++) {
+ /* Get base IPv4 address and increment it if needed for
+ * stream source address;
+ * Incrementing only highest octet
+ */
+
+ l_ipv4->sin_addr.s_addr = src_s.s_addr + i;
+
+ for(j = 0; j < nb_streams; j++, cnt++) {
+ /* Get base IPv4 address and increment it if needed for
+ * stream destination address
+ */
+ r_ipv4->sin_port = htons(dst_port + j);
+ r_ipv4->sin_addr.s_addr =
+ htonl(ntohl(dst_s.s_addr) + j);
+
+ stream = tle_udp_stream_open(ctx,
+ (const struct tle_udp_stream_param *)
+ &stream_prm);
+
+ if (cnt < MAX_STREAMS) {
+ EXPECT_EQ(rte_errno, 0);
+ ASSERT_NE(stream, nullptr);
+ streams.push_back(stream);
+ } else if (cnt >= MAX_STREAMS) {
+ EXPECT_EQ(stream, nullptr);
+ EXPECT_EQ(rte_errno, ENFILE);
+ }
+ }
+ }
+}