Modern Apps git

← Modern-Apps.git

tests: batch pure classes in vpn, euicc, networklocation, backup

Commit
7d7884890cf48dc520f81c5786e31e2811beb13f
Author
Vayun Mathur <[email protected]>
When
2026-11-21 23:57 UTC (14 days ago)
Parents
d0cb392
Split audit in four more modules (batch/quarantine per
module): vpn 136, euicc 105, networklocation 85, backup 71 -
all green both ways, walls roughly halved except backup
(flat, honest: small suite, nothing loads its inherited
native). Backup's audit caught a real leaked-ViewModel/
DataStore setUp deadlock via jstack; isolating the class
resolved it. New native/ViewModel classes must join the
lists (documented per file; full report in analysis/).

Diff

backup/build.gradle.kts
diff --git a/backup/build.gradle.kts b/backup/build.gradle.ktsindex 9104e5d67f..2a64643288 100644--- a/backup/build.gradle.kts+++ b/backup/build.gradle.kts@@ -15,6 +15,38 @@ android {     } } +// This module registers no Rust library of its own; it only inherits+// forkEvery = 1 because :library:e2ee-p2p (implementation dep below)+// registers libe2ee_pqc. No backup test actually loads that library:+// backup's crypto path is E2ee's pure-JCE AES-GCM plus the pure-JCE+// Hkdf, and nothing here references Pqc/PqcNative. So there are no+// nativeClasses โ€” the quarantine below exists purely for the shared-JVM+// polluters. Quarantine them into testDevUnitTestNative+// (forkEvery = 1); the remaining classes batch 20-per-JVM in+// testDevUnitTest, which depends on the quarantine task so the usual+// invocation still runs everything.+rustNativeTests {+    // Shared-JVM polluters keep forkEvery = 1 in the companion task:+    // BackupConfig is the module's only DataStore owner, and+    // BackupViewModel collects its settings flow in viewModelScope+    // forever (BackupViewModelTest itself documents that a leaked VM+    // deadlocks a later runBlocking DataStore edit on the paused main+    // looper); persisted DataStore state also leaks into classes+    // expecting defaults. Audit rule: any test instantiating+    // BackupViewModel or using BackupConfig directly belongs here.+    // All other classes batch.+    isolatedClasses.addAll(+        listOf(+            "com.vayunmathur.backup.NavigationAndRouteTest",+            "com.vayunmathur.backup.data.BackupConfigTest",+            "com.vayunmathur.backup.platform.BackupViewModelTest",+            "com.vayunmathur.backup.platform.KeyManagerAndWorkerTest",+            "com.vayunmathur.backup.service.ConfigurableBackupTransportTest",+            "com.vayunmathur.backup.service.TransportWithRepoTest",+        )+    )+}+ dependencies {     // Compile-only stubs for the framework's @SystemApi app-data backup transport     // classes (android.app.backup.BackupTransport + RestoreDescription/RestoreSet).
euicc/build.gradle.kts
diff --git a/euicc/build.gradle.kts b/euicc/build.gradle.ktsindex 94b48085a9..6a240f4c9d 100644--- a/euicc/build.gradle.kts+++ b/euicc/build.gradle.kts@@ -27,6 +27,43 @@ androidComponents { // See euicc/src/main/rust/. rustNativeLib("euicc") +// Only the classes below actually load libeuicc: they call EuiccNative+// externs directly, or open the ISD-R channel over the fake telephony+// shadow so the native core runs (any touch of EuiccNative, including+// installing activeChannel, initialises the object and loads the+// library). Tests that never open a channel โ€” the no-hardware+// EuiccManagerService/EuiccChannelManager paths throw before+// EuiccNative is touched โ€” and pure data/UI tests stay in the main+// task. Quarantine the loaders and the shared-JVM polluters below into+// testDevUnitTestNative (forkEvery = 1); the remaining classes batch+// 20-per-JVM in testDevUnitTest, which depends on the quarantine task so+// the usual invocation still runs everything.+rustNativeTests {+    nativeClasses.addAll(+        listOf(+            "com.vayunmathur.euicc.EuiccNativeTest",+            "com.vayunmathur.euicc.FakeEuiccIntegrationTest",+            "com.vayunmathur.euicc.FakeSmdpIntegrationTest",+            "com.vayunmathur.euicc.telephony.EuiccChannelManagerFakeTest",+        )+    )+    // Shared-JVM polluters keep forkEvery = 1 in the same companion+    // task: EuiccViewModel's init calls the process-wide+    // NetworkClient.init and launches a viewModelScope reload whose IO+    // work is never cleared when the test never calls onCleared; its+    // tests drain state by polling the main looper. Audit rule: any+    // test instantiating EuiccViewModel (or rendering Navigation,+    // which takes one) belongs here. This module's DataStore+    // dependency is unused by main/test sources, so no DataStore+    // polluters exist here. All other classes batch.+    isolatedClasses.addAll(+        listOf(+            "com.vayunmathur.euicc.NavigationAndActivitiesTest",+            "com.vayunmathur.euicc.platform.EuiccViewModelTest",+        )+    )+}+ dependencies {     // Compile-only stubs for the framework's @SystemApi eSIM LPA classes     // (android.service.euicc.*, EuiccProfileInfo). Provided by the framework at
networklocation/build.gradle.kts
diff --git a/networklocation/build.gradle.kts b/networklocation/build.gradle.ktsindex ea161d7a76..058f9ec144 100644--- a/networklocation/build.gradle.kts+++ b/networklocation/build.gradle.kts@@ -25,6 +25,30 @@ androidComponents { // search over geocoder.db. Both live in networklocation/src/main/rust/. rustNativeLib("networklocation") +// Only the classes below actually load libnetworklocation: they call+// the *Native bridges directly, or drive OfflineBeaconStore /+// GeocodeService / LocationReportingTask, which open and query through+// WpsStoreNative / GeocoderNative / NetworkLocationNative (touching a+// bridge's `available` already loads the library). Pure key/position+// math, feed, provider-contract and compose tests never touch a bridge+// and stay in the main task. Quarantine the loaders into+// testDevUnitTestNative (forkEvery = 1); the remaining classes batch+// 20-per-JVM in testDevUnitTest, which depends on the quarantine task so+// the usual invocation still runs everything. No isolatedClasses: this+// module has no ViewModel and no DataStore owner (OfflineDatabases is+// plain files, and every test installs/clears them itself), so no+// shared-JVM polluters exist here.+rustNativeTests {+    nativeClasses.addAll(+        listOf(+            "com.vayunmathur.networklocation.GeocodeServiceTest",+            "com.vayunmathur.networklocation.NativeBridgesTest",+            "com.vayunmathur.networklocation.provider.LocationReportingTaskTest",+            "com.vayunmathur.networklocation.provider.OfflineBeaconStoreTest",+        )+    )+}+ // The offline databases (geocoder.db, wifi.wpsdb up to ~2 GB, cells.wpsdb far // smaller) are NOT bundled. Shipping them as assets put a 3.5 GB APK in the MAOS system image, // which pushed the factory install zip past fastboot's 4 GiB zip limit. They are downloaded to
vpn/build.gradle.kts
diff --git a/vpn/build.gradle.kts b/vpn/build.gradle.ktsindex 110c7cfe0e..5c67f63502 100644--- a/vpn/build.gradle.kts+++ b/vpn/build.gradle.kts@@ -32,6 +32,46 @@ androidComponents {  rustNativeLib("vpn_wireguard", "vpn") +// Only the classes below actually load libvpn_wireguard: they call+// VpnNative key/tunnel externs directly (guarded by a nativeAvailable()+// probe, but the call still binds the library in that JVM). Tests that+// merely parse configs, inspect packets, or exercise the pure service+// helpers never touch VpnNative and stay in the main task. Quarantine+// the loaders and the shared-JVM polluters below into+// testDevUnitTestNative (forkEvery = 1); the remaining classes batch+// 20-per-JVM in testDevUnitTest, which depends on the quarantine task so+// the usual invocation still runs everything.+rustNativeTests {+    nativeClasses.addAll(+        listOf(+            "com.vayunmathur.vpn.service.FinalCoverageBatchTest",+            "com.vayunmathur.vpn.service.PumpLoopTest",+            "com.vayunmathur.vpn.service.TunnelSessionMoreTest",+            "com.vayunmathur.vpn.service.TwoTunnelRouteTest",+            "com.vayunmathur.vpn.service.VpnTunnelServiceTest",+            "com.vayunmathur.vpn.util.VpnNativeTest",+        )+    )+    // Shared-JVM polluters keep forkEvery = 1 in the same companion task:+    // VpnViewModel's init starts a never-ending viewModelScope poll loop+    // plus WhileSubscribed stateIn collectors that are never cleared when+    // the test never calls onCleared, and BypassList reads/writes the+    // process-wide DataStoreUtils singleton (persisted bypass set leaks+    // into classes expecting defaults). Audit rule: any test+    // instantiating VpnViewModel (or rendering a page that takes one) or+    // using BypassList directly belongs here. All other classes batch.+    isolatedClasses.addAll(+        listOf(+            "com.vayunmathur.vpn.platform.VpnViewModelTest",+            "com.vayunmathur.vpn.ui.FinalVpnBatchTest",+            "com.vayunmathur.vpn.ui.MainActivityAndBypassSwitchTest",+            "com.vayunmathur.vpn.ui.NavigationAndPagesTest",+            "com.vayunmathur.vpn.ui.PageCallbacksTest",+            "com.vayunmathur.vpn.ui.VpnComposeScreensTest",+        )+    )+}+ dependencies {     implementRoom(libs)     implementation(project(":library:room"))