A high-performance Android storage analyzer that bypasses MTP using a native C++ daemon, a Rust TCP bridge, and a React Treemap UI.
Rust
Reject transfer durations that overflow throughput (#143)
Vishnu Srivatsava8407d8295a6c
diff --git a/tests/benchmark_transfer.py b/tests/benchmark_transfer.pyindex 02c9954..b26a252 100644--- a/tests/benchmark_transfer.py+++ b/tests/benchmark_transfer.py@@ -116,11 +116,14 @@ def result(manifest, workload, copy, seconds, backend, compression):raise ValueError("Transfer seconds must be finite and positive")start = time.perf_counter()count, size = verify_copy(manifest, workload, copy)+ rate = size / MIB / seconds+ if not math.isfinite(rate):+ raise ValueError("Transfer duration is too small to report finite throughput")return {"fixture": manifest["fixture"], "workload": workload,"backend": backend, "compression": compression, "verified": True,"files": count, "bytes": size, "transfer_seconds": seconds,"verification_seconds": time.perf_counter() - start,- "mib_per_second": size / MIB / seconds}+ "mib_per_second": rate}def pull(workspace, serial, workload, output, compression="none", adb="adb"):diff --git a/tests/scan_ui_fixture.js b/tests/scan_ui_fixture.jsindex 8ac54f5..45a13ff 100644--- a/tests/scan_ui_fixture.js+++ b/tests/scan_ui_fixture.js@@ -734,7 +734,8 @@coverageSkipped = 0;stopOutcome = "acknowledged";selectDevice("phone-one");- await pause(20);+ await waitFor(() => picker().value === "phone-one" && document.querySelector("#btn-connect:enabled"),+ "Connect did not become ready for phone-one");document.querySelector("#btn-connect").click();await waitFor(() => rows().length === 129, "Explicit device switch did not scan");check(activeDevice === "phone-one" && scope().generation !== previousGeneration && document.querySelector("#connected-device").textContent.includes("phone-one"), "Device switch reused old results/identity");@@ -747,7 +748,8 @@await waitFor(() => document.querySelector("#btn-connect") && !document.querySelector("#btn-connect").disabled, "Stop with a pending confirmation did not finish");check(!button("NUKE IT") && picker().value === "phone-one", "Stop retained confirmation or forgot selection");selectDevice("phone-two");- await pause(20);+ await waitFor(() => picker().value === "phone-two" && document.querySelector("#btn-connect:enabled"),+ "Connect did not become ready for phone-two");document.querySelector("#btn-connect").click();await waitFor(() => rows().length === 129, "Switch back to the second phone failed");check(activeDevice === "phone-two" && !button("NUKE IT") && calls.filter(call => call.command === "delete_item").length === deleteCallsBeforeSwitch, "An old confirmation crossed device sessions");diff --git a/tests/test_transfer_benchmark.py b/tests/test_transfer_benchmark.pyindex 3480be8..a7af058 100644--- a/tests/test_transfer_benchmark.py+++ b/tests/test_transfer_benchmark.py@@ -160,6 +160,8 @@ class TransferBenchmarkTests(unittest.TestCase):for seconds in (0, -1, float("nan"), float("inf")):with self.assertRaises(ValueError):benchmark.result(self.manifest, "large", self.source / "large", seconds, "mtp", "unknown")+ with self.assertRaisesRegex(ValueError, "finite throughput"):+ benchmark.result(self.manifest, "large", self.source / "large", 1e-320, "mtp", "unknown")report = benchmark.result(self.manifest, "large", self.source / "large", 2, "mtp", "unknown")self.assertEqual(report["mib_per_second"], 0.5)