BpfMapTest: add fd leak test
Test that there is no fd leak with persistent fd cache. Bug: 236320567 Test: atest BpfMapTest#testNoFdLeaks (cached fd) [PASSED] Test: atest BpfMapTest#testNoFdLeaks (noncached fd) [FAILED] (as expected) [8/14] com.android.networkstack.tethering.BpfMapTest#testNoFdLeaks: FAILED (241ms) STACKTRACE: java.lang.AssertionError: Fd leak after 1000 iterations: expected:<89> but was:<1089> at org.junit.Assert.fail(Assert.java:89) at org.junit.Assert.failNotEquals(Assert.java:835) at org.junit.Assert.assertEquals(Assert.java:647) at com.android.networkstack.tethering.BpfMapTest.testNoFdLeaks(BpfMapTest.java:420) Test Code: fd noncached BpfMap frameworks/libs/net/common/device/com/android/net/module/util/BpfMap.java @@ -97,7 +97,7 @@ public class BpfMap<K extends Struct, V extends Struct> implements IBpfMap<K, V> */ public BpfMap(@NonNull final String path, final int flag, final Class<K> key, final Class<V> value) throws ErrnoException, NullPointerException { - mMapFd = cachedBpfFdGet(path, flag); + mMapFd = ParcelFileDescriptor.adoptFd(nativeBpfFdGet(path, flag)); Change-Id: I66f477fd1c291c56bccc97d385b2a554c2367b5a
Loading
Please register or sign in to comment