DEV Community

Ai2th
Ai2th

Posted on

Linxr | Part 10 — Automated End-to-End Testing for Mobile Virtual Machines

In Part 9, we detailed automatic disk expansion. In this installment (Part 10), we share how we built automated End-to-End (E2E) testing pipelines for Android QEMU virtual machines!


Automated Quality Assurance for Mobile VMs

Testing a virtual machine running inside an Android app sandbox presents unique challenges:

  • How do you verify QEMU booted cleanly without manual screen inspection?
  • How do you measure boot speed benchmarks across different device models?
  • How do you validate vCPU and RAM resource limits automatically?

Kotlin Instrumentation Test Pipeline

We created dedicated Android JUnit instrumentation tests (VmE2ETest.kt and VmResourceTest.kt):

@RunWith(AndroidJUnit4::class)
class VmE2ETest {

    @Test
    fun testVmBootAndSshConnection() {
        val context = InstrumentationRegistry.getInstrumentation().targetContext
        val vmManager = VmManager(context)

        // 1. Start QEMU VM
        val bootSuccess = vmManager.startVm(vCpus = 2, ramMb = 2048)
        assertTrue("VM failed to boot within timeout", bootSuccess)

        // 2. Execute test command over SSH
        val sshClient = SshClient("127.0.0.1", 2222, "root", "alpine")
        val output = sshClient.executeCommand("uname -a && docker --version")

        assertTrue(output.contains("Linux"))
        assertTrue(output.contains("Docker"))
    }
}
Enter fullscreen mode Exit fullscreen mode

These tests run automatically on physical test devices via ADB, logging boot timings, verifying SSH socket readiness, and guaranteeing release stability before Play Store uploads.


Download Linxr

Top comments (0)