Closed Bug 1340233 Opened 7 years ago Closed 7 years ago

Kill running Firefox instances before launching a test

Categories

(Firefox for Android Graveyard :: Testing, defect, P3)

All
Android
defect

Tracking

(firefox54 fixed, firefox55 fixed)

RESOLVED FIXED
Firefox 55
Tracking Status
firefox54 --- fixed
firefox55 --- fixed

People

(Reporter: JanH, Assigned: gbrown)

References

Details

Attachments

(1 file)

Running tests (e.g. mochitests) fails if the Firefox process is already running, because the startup commands passed by the test harness (use of custom profile etc.) are ignored in that case.

Since
- it's annoying always having to swipe Firefox away from the task list before starting the next run
- something (Sync ?) can cause the Firefox process to start up invisibly in background, so even if you did swipe Firefox away the test might still fail

it would be nice if the test harness could automatically kill any already running instance before starting the test run.
I tested using the emulator from "mach android-emulator --version 6.0". I installed fennec, opened it, hit the Home button, used 'adb shell ps' to check the pid, then ran 'mach mochitest <dir>'. Debugging killProcess, I saw it attempt to kill the correct pid, and another 'adb shell ps' confirmed that the old pid was killed. The harness started a new instance of fennec with a new pid.

There might be variation in kill behavior across different versions of Android, especially before/after Android N. Also of course, shell permissions (root) will play a part on different devices.

Another possibility is that the harness is indeed reliably killing existing fennecs, but that their state is restored, making it look like they weren't killed. I think I see tabs from the killed fennec restored in the mochitest fennec...not sure what can be done about that.
Priority: -- → P3
Maybe it might be worth using |adb shell am force-stop <package name>| as well (or perhaps even instead)?
Assignee: nobody → gbrown
:gandalf reported something like this on irc, following up on a problem reported in bug 1354055. He was running on a device (rooted unknown, android version unknown) and running firefox before running mach. I had some concern that he might have multiple versions of firefox installed, but that was not substantiated.

I tried the same thing on emulators and found firefox was correctly killed before starting the test, but maybe there are cases where force-stop will work better.

I'd also like to try improving the logging to guard against this situation: "Cannot start test because firefox is already running!"?
Comment on attachment 8857270 [details] [diff] [review]
try force-stop first in dm.killProcess

Review of attachment 8857270 [details] [diff] [review]:
-----------------------------------------------------------------

nice
Attachment #8857270 - Flags: review?(jmaher) → review+
Pushed by gbrown@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/d6c7b5d5f38f
Take more care when killing browser before starting Android tests; r=jmaher
https://hg.mozilla.org/mozilla-central/rev/d6c7b5d5f38f
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 55
Depends on: 1395718
Blocks: 1448697
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: