From ae27ecf5ad170b85e0056b14d5a3df62d21b0114 Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Tue, 26 Jan 2021 15:12:25 +0900 Subject: [PATCH] Fix a WTF in IpServerTest. Bug: 178324405 Test: atest TetheringTests Change-Id: I2069ea79f982e6bb197388edd7820a05d1e651f1 --- Tethering/tests/unit/src/android/net/ip/IpServerTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Tethering/tests/unit/src/android/net/ip/IpServerTest.java b/Tethering/tests/unit/src/android/net/ip/IpServerTest.java index 9b42c73c79..66b2adbb04 100644 --- a/Tethering/tests/unit/src/android/net/ip/IpServerTest.java +++ b/Tethering/tests/unit/src/android/net/ip/IpServerTest.java @@ -881,6 +881,11 @@ public class IpServerTest { .thenReturn(buildEmptyTetherStatsParcel(UPSTREAM_IFINDEX)); when(mNetd.tetherOffloadGetAndClearStats(UPSTREAM_IFINDEX2)) .thenReturn(buildEmptyTetherStatsParcel(UPSTREAM_IFINDEX2)); + // When the last rule is removed, tetherOffloadGetAndClearStats will log a WTF (and + // potentially crash the test) if the stats map is empty. + final TetherStatsValue allZeros = new TetherStatsValue(0, 0, 0, 0, 0, 0); + when(mBpfStatsMap.getValue(new TetherStatsKey(UPSTREAM_IFINDEX))).thenReturn(allZeros); + when(mBpfStatsMap.getValue(new TetherStatsKey(UPSTREAM_IFINDEX2))).thenReturn(allZeros); } @Test