Closed Bug 1692253 Opened 4 years ago Closed 3 years ago

mozdevice.adb.ADBDEvice: Support yielding output with processes.


(Testing :: Mozbase, enhancement)

Firefox 87


(firefox88 fixed)

88 Branch
Tracking Status
firefox88 --- fixed


(Reporter: nbp, Assigned: nbp)




(1 file)

The JS test suite are processing the output of tests by using a generator to iterate over the list of outputs. To avoid spawning multiple adb processes while reading the output of each test as the output are produced we would batch commands. However we have to process the output as it is produced, as the amount of data produced could be very large otherwise.

Using an on another thread with stdout_callback set does not work, as the _timed_read_line implementation relies on signals which are not supported on a different thread than the main thread.

One proposal, is that instead of using an extra file to capture the output, we could use a subprocess.PIPE for stdout, implement a timeout using an additional Thread responsible of kill()-ing the process and recording the exitcode. In the mean time, the output can be collected by using the default stdout.readlines() iterator which would be blocking as long as the stdout is not closed by the adb command. Thus allowing the JS test suite to yield results as they are aggregated.

That sounds reasonable.

I'll just mention that android mochitest and reftest face a similar challenge: The firefox app under test generates a lot of test output over a long time. Those test harnesses use a simple compromise, using All test output is written to a file on device, the file is periodically pulled to the host, and new output dumped to the harness' stdout. The polling aspect is not optimal, but has been good enough for those test suites.

This change add the ability to yield the output as it is produced, by
creating a thread responsible for killing the process if it takes too

This way we can loop with blocking I/O on stdout in python, while the
process is running concurrently. The loop ends when the process exit
either by itself or after being killed by the timeout.

Pushed by
Create a thread to handle ADB process timeout. r=jmaher,gbrown
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 88 Branch
You need to log in before you can comment on or make changes to this bug.