summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-prod (mdb) <android-build-team-robot@google.com>2019-11-19 21:08:07 +0000
committerandroid-build-prod (mdb) <android-build-team-robot@google.com>2019-11-19 21:08:07 +0000
commitc611b61b7f0ea8691f8cac35fa1dfe042bca0b34 (patch)
tree1a1e00114dd8b0f643483e8cbd6b000537b59a4b
parent5a2805599629d028b38fff13ecff17bd85759fc3 (diff)
parente3425844b86e42e6b5e86d3f9a20762c15cb0453 (diff)
downloadnetd-android10-tests-release.tar.gz
Change-Id: I42929232a16a49392a0684aa55dc8b6523a1750b
-rw-r--r--tests/netlink_listener_test.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/tests/netlink_listener_test.cpp b/tests/netlink_listener_test.cpp
index 901c1d0c..94e95246 100644
--- a/tests/netlink_listener_test.cpp
+++ b/tests/netlink_listener_test.cpp
@@ -103,7 +103,7 @@ class NetlinkListenerTest : public testing::Test {
return mCookieTagMap.iterateWithValue(checkGarbageTags);
}
- void checkMassiveSocketDestroy(const int totalNumber, bool expectError) {
+ void checkMassiveSocketDestroy(int totalNumber, bool expectError) {
std::unique_ptr<android::net::NetlinkListenerInterface> skDestroyListener;
auto result = android::net::TrafficController::makeSkDestroyListener();
if (!isOk(result)) {
@@ -118,16 +118,24 @@ class NetlinkListenerTest : public testing::Test {
int fds[totalNumber];
for (int i = 0; i < totalNumber; i++) {
fds[i] = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
- EXPECT_LE(0, fds[i]);
+ // The likely reason for a failure is running out of available file descriptors.
+ EXPECT_LE(0, fds[i]) << i << " of " << totalNumber;
+ if (fds[i] < 0) {
+ // EXPECT_LE already failed above, so test case is a failure, but we don't
+ // want potentially tens of thousands of extra failures creating and then
+ // closing all these fds cluttering up the logs.
+ totalNumber = i;
+ break;
+ };
qtaguid_tagSocket(fds[i], TEST_TAG, TEST_UID);
}
- // TODO: Use a separate thread that have it's own fd table so we can
- // close socket faster by terminating that threads.
+ // TODO: Use a separate thread that has it's own fd table so we can
+ // close sockets even faster simply by terminating that thread.
for (int i = 0; i < totalNumber; i++) {
EXPECT_EQ(0, close(fds[i]));
}
- // wait a bit for netlink listner to handle all the messages.
+ // wait a bit for netlink listener to handle all the messages.
usleep(SOCK_CLOSE_WAIT_US);
if (expectError) {
// If ENOBUFS triggered, check it only called into the handler once, ie.
@@ -153,5 +161,5 @@ TEST_F(NetlinkListenerTest, TestAllSocketUntagged) {
TEST_F(NetlinkListenerTest, TestSkDestroyError) {
SKIP_IF_BPF_NOT_SUPPORTED;
- checkMassiveSocketDestroy(50000, true);
+ checkMassiveSocketDestroy(32500, true);
}