diff options
author | Konstantin Ananyev <konstantin.ananyev@intel.com> | 2017-01-24 13:57:59 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@fd.io> | 2017-01-24 13:57:59 +0000 |
commit | 7d4d265734f48dd337754f745d6b74194b2822f8 (patch) | |
tree | 78da59e3e4b9bed638d63549f7e32d3af6822576 /test | |
parent | a18f8552ebe36f965c7bab161a329430acfe5cb8 (diff) | |
parent | 759bedcea5d15c6d1e2ffcc574f6a7e9333eea28 (diff) |
Merge "tldk test: Update tle_dev unit tests"
Diffstat (limited to 'test')
-rw-r--r-- | test/gtest/test_tle_udp_dev.cpp | 24 | ||||
-rw-r--r-- | test/gtest/test_tle_udp_dev.h | 9 |
2 files changed, 31 insertions, 2 deletions
diff --git a/test/gtest/test_tle_udp_dev.cpp b/test/gtest/test_tle_udp_dev.cpp index 8efb866..a58186e 100644 --- a/test/gtest/test_tle_udp_dev.cpp +++ b/test/gtest/test_tle_udp_dev.cpp @@ -53,6 +53,7 @@ TEST_F(udp_dev, udp_dev_add_only_ipv4) dev = tle_udp_add_dev(ctx, &dev_prm); ASSERT_NE(dev, (void *) NULL); EXPECT_EQ(rte_errno, 0); + devs.push_back(dev); } TEST_F(udp_dev, udp_dev_add_only_ipv6) @@ -70,6 +71,7 @@ TEST_F(udp_dev, udp_dev_add_nonexist_ipv4) dev = tle_udp_add_dev(ctx, &dev_prm); ASSERT_NE(dev, (void *) NULL); EXPECT_EQ(rte_errno, 0); + devs.push_back(dev); } TEST_F(udp_dev, udp_dev_add_positive) @@ -77,9 +79,21 @@ TEST_F(udp_dev, udp_dev_add_positive) dev = tle_udp_add_dev(ctx, &dev_prm); ASSERT_NE(dev, (void *) NULL); EXPECT_EQ(rte_errno, 0); + devs.push_back(dev); +} + +TEST_F(udp_dev, udp_dev_add_max) +{ + int i; + for(i = 0; i < RTE_MAX_ETHPORTS; i++) { + dev = tle_udp_add_dev(ctx, &dev_prm); + ASSERT_NE(dev, (void *) NULL); + EXPECT_EQ(rte_errno, 0); + devs.push_back(dev); + } dev = tle_udp_add_dev(ctx, &dev_prm); - ASSERT_NE(dev, (void *) NULL); - EXPECT_EQ(rte_errno, 0); + ASSERT_EQ(dev, (void *) NULL); + EXPECT_EQ(rte_errno, ENODEV); } TEST_F(udp_dev, udp_dev_del_positive) @@ -87,6 +101,12 @@ TEST_F(udp_dev, udp_dev_del_positive) dev = tle_udp_add_dev(ctx, &dev_prm); ASSERT_NE(dev, (void *) NULL); EXPECT_EQ(rte_errno, 0); + devs.push_back(dev); ASSERT_EQ(tle_udp_del_dev(dev), 0); EXPECT_EQ(rte_errno, 0); } + +TEST_F(udp_dev, udp_dev_del_null_dev) +{ + ASSERT_EQ(tle_udp_del_dev(dev), -EINVAL); +} diff --git a/test/gtest/test_tle_udp_dev.h b/test/gtest/test_tle_udp_dev.h index 3ecc5c7..02f544d 100644 --- a/test/gtest/test_tle_udp_dev.h +++ b/test/gtest/test_tle_udp_dev.h @@ -16,14 +16,19 @@ #ifndef TEST_TLE_UDP_DEV_H_ #define TEST_TLE_UDP_DEV_H_ +#include <algorithm> #include <arpa/inet.h> #include <gtest/gtest.h> + #include <rte_errno.h> + #include <tle_udp_impl.h> #define RX_NO_OFFLOAD 0 #define TX_NO_OFFLOAD 0 +using namespace std; + class udp_dev : public ::testing::Test { public: @@ -31,6 +36,7 @@ public: struct tle_udp_dev *dev; struct tle_udp_ctx_param prm; struct tle_udp_dev_param dev_prm; + vector<tle_udp_dev*> devs; virtual void SetUp(void) { @@ -56,6 +62,9 @@ public: virtual void TearDown(void) { + for(auto d : devs) { + tle_udp_del_dev(d); + } tle_udp_destroy(ctx); } }; |