Ensure no thread leak after NetworkStatsServiceTest
This change includes: 1. A mechanism in DevSdkIngoreRunnrer to dump thread counts before/after tests, and compare thread counts to detect leaks. 2. Add an annotation @MonitorThreadLeak for test classes to annotate the classes which should monitor thread leaks. 3. Annotated NetworkStatsServiceTest to apply the enforcement. Sample output: [1/2] android.net.connectivity.com.android.server.net.NetworkStatsServiceTest#testDumpStatsMap: PASSED (1.187s) [2/2] android.net.connectivity.com.android.server.net.NetworkStatsServiceTest#ThreadLeakMonitor: FAILED (7ms) STACKTRACE: java.lang.IllegalStateException: Expected threads: {binder:26055_3=1, Instr: androidx.test.runner.AndroidJUnitRunner=1, main=1, InstrumentationConnectionThread=1, binder:26055_2=1, binder:26055_1=1} but got: {binder:26055_3=1, NetworkStatsObservers=1, Instr: androidx.test.runner.AndroidJUnitRunner=1, main=1, InstrumentationConnectionThread=1, binder:26055_2=1, binder:26055_1=1} Test: atest ConnectivityCoverageTests:android.net.connectivity.com.android.server.net.NetworkStatsServiceTest \ --rerun-until-failure 100 Bug: 308544001 Bug: 307693729 Change-Id: Ia0bccb82c5985df608b8402009b32626b6b17c5a
Loading
Please register or sign in to comment