summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2018-03-06 21:48:11 +1030
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-03-15 00:20:42 +0000
commit9628122e69c19d52e694b48f48a446a39b01bf5f (patch)
tree79ac2595f74c5a80b4132469d56451c5baf1c64f
parent4aa13789225e43546e627f2c556ddc4e2c0c4fad (diff)
downloadphosphor-networkd-9628122e69c19d52e694b48f48a446a39b01bf5f.tar.gz
phosphor-networkd-9628122e69c19d52e694b48f48a446a39b01bf5f.zip
test_rtnetlink: Improve exception handling by not handling them
All the test was doing was verifying that an exception hadn't occurred. The test would fail if one had, so we're better off just not doing the dance. Change-Id: Iff7d9e4947e86b24f4cf99ddbac3e9c42e63f1d3 Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
-rw-r--r--test/test_rtnetlink.cpp63
1 files changed, 27 insertions, 36 deletions
diff --git a/test/test_rtnetlink.cpp b/test/test_rtnetlink.cpp
index 77b771a..71e5443 100644
--- a/test/test_rtnetlink.cpp
+++ b/test/test_rtnetlink.cpp
@@ -102,45 +102,36 @@ class TestRtNetlink : public testing::Test
TEST_F(TestRtNetlink, WithSingleInterface)
{
- bool caughtException = false;
using namespace std::chrono;
- try
+ // Adds the following ip in the getifaddrs list.
+ mock_addIP("igb5", "127.0.0.1", "255.255.255.128",
+ IFF_UP | IFF_RUNNING);
+ constexpr auto BUFSIZE = 4096;
+ std::array<char, BUFSIZE> msgBuf = {0};
+
+ // point the header and the msg structure pointers into the buffer.
+ auto nlMsg = reinterpret_cast<nlmsghdr*>(msgBuf.data());
+ // Length of message
+ nlMsg->nlmsg_len = NLMSG_LENGTH(sizeof(rtmsg));
+ nlMsg->nlmsg_type = RTM_GETADDR;
+ nlMsg->nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST;
+ nlMsg->nlmsg_seq = 0;
+ nlMsg->nlmsg_pid = getpid();
+
+ EXPECT_EQ(false, isInterfaceAdded("igb5"));
+ // Send the request
+ send(smartSock(), nlMsg, nlMsg->nlmsg_len, 0);
+
+ int i = 2;
+ while (i--)
{
- // Adds the following ip in the getifaddrs list.
- mock_addIP("igb5", "127.0.0.1", "255.255.255.128",
- IFF_UP | IFF_RUNNING);
- constexpr auto BUFSIZE = 4096;
- std::array<char, BUFSIZE> msgBuf = {0};
-
- // point the header and the msg structure pointers into the buffer.
- auto nlMsg = reinterpret_cast<nlmsghdr*>(msgBuf.data());
- // Length of message
- nlMsg->nlmsg_len = NLMSG_LENGTH(sizeof(rtmsg));
- nlMsg->nlmsg_type = RTM_GETADDR;
- nlMsg->nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST;
- nlMsg->nlmsg_seq = 0;
- nlMsg->nlmsg_pid = getpid();
-
- EXPECT_EQ(false, isInterfaceAdded("igb5"));
- // Send the request
- send(smartSock(), nlMsg, nlMsg->nlmsg_len, 0);
-
- int i = 2;
- while (i--)
- {
- //wait for timer to expire
- std::this_thread::sleep_for(
- std::chrono::milliseconds(refreshTimeout));
- sd_event_run(eventPtr.get(), 10);
- };
+ //wait for timer to expire
+ std::this_thread::sleep_for(
+ std::chrono::milliseconds(refreshTimeout));
+ sd_event_run(eventPtr.get(), 10);
+ };
- EXPECT_EQ(true, isInterfaceAdded("igb5"));
- }
- catch (std::exception& e)
- {
- caughtException = true;
- }
- EXPECT_EQ(false, caughtException);
+ EXPECT_EQ(true, isInterfaceAdded("igb5"));
}
}// namespce network
OpenPOWER on IntegriCloud