Merge changes I804a0ba0,I5667cbb4,Ic2c85f3c
* changes:
[NFCT.NS.11] Add NAT conntrack event notification
[NFCT.NS.10] Parse CTA_TUPLE_PROTO
[NFCT.NS.9] Parse CTA_TUPLE_ORIG and CTA_TUPLE_REPLY
diff --git a/tests/unit/src/com/android/net/module/util/TrackRecordTest.kt b/tests/unit/src/com/android/net/module/util/TrackRecordTest.kt
index c2bdcd4..9fb4d8c 100644
--- a/tests/unit/src/com/android/net/module/util/TrackRecordTest.kt
+++ b/tests/unit/src/com/android/net/module/util/TrackRecordTest.kt
@@ -30,6 +30,7 @@
import org.junit.runners.JUnit4
import java.util.concurrent.CyclicBarrier
import java.util.concurrent.TimeUnit
+import java.util.concurrent.atomic.AtomicInteger
import kotlin.system.measureTimeMillis
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
@@ -183,6 +184,33 @@
}
@Test
+ fun testConcurrentPollDisallowed() {
+ val failures = AtomicInteger(0)
+ val readHead = ArrayTrackRecord<Int>().newReadHead()
+ val barrier = CyclicBarrier(2)
+ Thread {
+ barrier.await(LONG_TIMEOUT, TimeUnit.MILLISECONDS) // barrier 1
+ try {
+ readHead.poll(LONG_TIMEOUT)
+ } catch (e: ConcurrentModificationException) {
+ failures.incrementAndGet()
+ // Unblock the other thread
+ readHead.add(0)
+ }
+ }.start()
+ barrier.await() // barrier 1
+ try {
+ readHead.poll(LONG_TIMEOUT)
+ } catch (e: ConcurrentModificationException) {
+ failures.incrementAndGet()
+ // Unblock the other thread
+ readHead.add(0)
+ }
+ // One of the threads must have gotten an exception.
+ assertEquals(failures.get(), 1)
+ }
+
+ @Test
fun testPollWakesUp() {
val record = ArrayTrackRecord<Int>()
val barrier = CyclicBarrier(2)
diff --git a/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java b/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
index 4d032c2..8f42a61 100644
--- a/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
+++ b/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
@@ -2285,9 +2285,10 @@
setStatus(mFallbackConnection, 204);
nm.forceReevaluation(Process.myUid());
// Expect to send HTTP, HTTPs, FALLBACK and evaluation results.
- runNetworkTest(VALIDATION_RESULT_INVALID,
+ verifyNetworkTested(VALIDATION_RESULT_INVALID,
NETWORK_VALIDATION_PROBE_DNS | NETWORK_VALIDATION_PROBE_FALLBACK,
null /* redirectUrl */);
+ HandlerUtils.waitForIdle(nm.getHandler(), HANDLER_TIMEOUT_MS);
}
@Test