An ephemeral VM always boots unprovisioned, and Android 16 then runs adbd in trade-in mode: the transport looks healthy and advertises shell_v2, but every command except `tradeinmode` is refused with "error: closed". wait-vm-startup.sh now waits for a usable transport rather than merely a connected one, detects the condition, and escapes it with the single command trade-in mode permits -- `tradeinmode evaluate` -- before marking the device provisioned, which is what actually turns trade-in mode off. All steps are idempotent, so it is a no-op on a provisioned guest.
EtchDroid end-to-end tests
This directory contains code to test EtchDroid on real and emulated devices.
The tests are written in Python using pytest, making use of Appium for interactive UI testing.
Test modules
The tests are divided into two modules:
test_generic.py: tests that run on any device, including real devices, provided that a USB drive of at least 2GB is connected (it will be erased).test_qemu.py: tests that must be run using QEMU (not the Android emulator!), since they interact with the QEMU monitor console to connect and disconnect emulated USB drives.
Requirements
- The Android SDK must be installed. It should either be stored under
~/Android/Sdk(Android Studio default) or specified using theANDROID_HOMEenvironment variable. uvmust be installed7z,qemu-imgandqemufor VM testing.nodeandnpmto install Appium:# Inside the appium-tests/ directory npm ci
On a real device
Warning
The tests will erase the content of the connected USB drive. Some wear is to be expected on the drive since random data will be written to it.
- Connect the device to the computer using wireless ADB (for older devices: connect via USB and run
adb tcpip 5555 && adb connect <device-ip>:5555). - Connect a USB drive of at least 2GB to the device.
- Build and install EtchDroid:
./gradlew installFossDebug - Run the tests using
pytestfrom theappium-tests/directory, excluding those specifically designed to run in a VM:uv run pytest -m "not qemu" -sv
In a virtual machine (recommended, Linux-only)
Note
Running the tests in a VM is recommended over a physical device since it allows testing the USB hotplugging logic without risking damage to physical drives. The VM is configured to use a virtual USB drive that can be safely erased and re-created on each test run.
Make sure to have qemu-system-x86_64 installed.
-
Prepare the VM files:
./appium-tests/scripts/prepare-vm.shThis will download the Bliss OS ISO, extract the required files, and create a virtual USB drive image in the
.appium-vm/directory. -
Launch QEMU (in a separate terminal):
./appium-tests/scripts/run-vm.shThis starts the VM with a GTK UI and redirects the serial console to stdio. ADB will be available on
localhost:5556. -
Wait for startup and configure:
./appium-tests/scripts/wait-vm-startup.shThis script waits for the VM to be reachable via ADB and applies necessary settings (like setting the default launcher) for the tests to run reliably.
We recommend running this script at least once before running the tests to ensure the VM is properly configured, even if the ADB connection is working already.
-
Build and install EtchDroid:
./gradlew installFossDebug -
Run the tests from the
appium-tests/directory:uv run pytest -sv
Notes
- The tests expect a USB drive to be connected before the tests start (the script handles this for QEMU).
- Warning: The tests will erase the content of the connected USB drive if run on a physical device.
- Both the QMP and monitor sockets are used by the tests to simulate USB hotplugging in QEMU.