summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChenbo Feng <fengc@google.com>2019-04-09 11:53:45 -0700
committerChenbo Feng <fengc@google.com>2019-04-09 17:28:12 -0700
commitef01d8dc6807fc4adc9968bd79d93bcf87664046 (patch)
tree5c0876b8aa0b7f6f74666ea95e81798ad1d1fb20
parent244865a0260154ae1b179f9efae1ad2a175e8593 (diff)
Set the rlimit for unit tests
If the device does not have a sufficient global rlimit set, the unit tests will fail because it cannot create test maps. Since the unit tests are usually running as root, let them manually set the rlimit before the test start to prevent the failure. Bug: 119279144 Bug: 129246448 Test: netd_unit_test, libnetdbpf_test Change-Id: Ia882809eee2ddf9d0e0d41cfffa754366962db3d
-rw-r--r--libnetdbpf/BpfNetworkStatsTest.cpp1
-rw-r--r--server/TrafficControllerTest.cpp1
2 files changed, 2 insertions, 0 deletions
diff --git a/libnetdbpf/BpfNetworkStatsTest.cpp b/libnetdbpf/BpfNetworkStatsTest.cpp
index 9ebe11f6..8153127a 100644
--- a/libnetdbpf/BpfNetworkStatsTest.cpp
+++ b/libnetdbpf/BpfNetworkStatsTest.cpp
@@ -78,6 +78,7 @@ class BpfNetworkStatsHelperTest : public testing::Test {
void SetUp() {
SKIP_IF_BPF_NOT_SUPPORTED;
+ ASSERT_EQ(0, setrlimitForTest());
mFakeCookieTagMap = BpfMap<uint64_t, UidTag>(createMap(
BPF_MAP_TYPE_HASH, sizeof(uint64_t), sizeof(struct UidTag), TEST_MAP_SIZE, 0));
diff --git a/server/TrafficControllerTest.cpp b/server/TrafficControllerTest.cpp
index cdc62d5f..b4acd662 100644
--- a/server/TrafficControllerTest.cpp
+++ b/server/TrafficControllerTest.cpp
@@ -71,6 +71,7 @@ class TrafficControllerTest : public ::testing::Test {
void SetUp() {
std::lock_guard ownerGuard(mTc.mOwnerMatchMutex);
SKIP_IF_BPF_NOT_SUPPORTED;
+ ASSERT_EQ(0, setrlimitForTest());
mFakeCookieTagMap.reset(createMap(BPF_MAP_TYPE_HASH, sizeof(uint64_t),
sizeof(struct UidTag), TEST_MAP_SIZE, 0));