From: Robin Lee Date: Thu, 15 Sep 2016 01:55:25 +0000 (+0900) Subject: DO NOT MERGE Fix getaddrinfo test to use random mapping ids X-Git-Tag: android-x86-7.1-r1~16 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;ds=sidebyside;h=137088fbf8c359f61e7721f8c4246aea04995d97;p=android-x86%2Fsystem-netd.git DO NOT MERGE Fix getaddrinfo test to use random mapping ids This seems to have been intended but it's just using the loop index. In fact the only thing the random index is used for is an assert to check that it is a valid index. Also stops the test segfaulting if num_queries > num_hosts (cherry picked from commit c4aba0ab2e9539a5e185e3800d47b3fcda9af779) Change-Id: Iae2369676c08fa8f8110c3cdebb0e4294a60b4b2 --- diff --git a/tests/netd_test.cpp b/tests/netd_test.cpp index 45ed211..1096fc7 100644 --- a/tests/netd_test.cpp +++ b/tests/netd_test.cpp @@ -380,8 +380,7 @@ protected: thread = std::thread([this, &servers, &dns, &mappings, num_queries]() { for (unsigned i = 0 ; i < num_queries ; ++i) { uint32_t ofs = arc4random_uniform(mappings.size()); - ASSERT_TRUE(ofs < mappings.size()); - auto& mapping = mappings[i]; + auto& mapping = mappings[ofs]; addrinfo* result = nullptr; int rv = getaddrinfo(mapping.host.c_str(), nullptr, nullptr, &result); EXPECT_EQ(0, rv) << "error [" << rv << "] " << gai_strerror(rv);