Closed Bug 1522661 Opened 5 years ago Closed 4 years ago

[mozdevice] adb should support ANDROID_SERIAL environment variable

Categories

(Testing :: Mozbase, enhancement, P3)

enhancement

Tracking

(firefox81 fixed)

RESOLVED FIXED
81 Branch
Tracking Status
firefox81 --- fixed

People

(Reporter: botond, Assigned: bc)

References

Details

(Whiteboard: dev-prod-2020)

Attachments

(1 file)

I am trying to run a mochitest on an Android emulator, with a device also connected (for unrelated development).

I am trying to use ANDROID_SERIAL to tell the mach mochitest command to use the emulator, but it seems to be ignoring it:

$ ANDROID_SERIAL=emulator-5554 ./mach mochitest --keep-open=false mobile/android/tests/browser/chrome/test_session_scroll_position.html
cat: backend.TestManifestBackend.in: No such file or directory
Build configuration changed. Regenerating backend.
No handlers could be found for logger "mozbuild.frontend.reader"
 0:00.70 adb INFO Using adb 1.0.40
Error running mach:

    ['mochitest', '--keep-open=false', 'mobile/android/tests/browser/chrome/test_session_scroll_position.html']

The error occurred in code that was called by the mach command. This is either
a bug in the called code itself or in the way that mach is calling it.

You should consider filing a bug for this issue.

If filing a bug, please include the full output of mach, including this error
message.

The details of the failure are as follows:

ValueError: ADBDevice called with multiple devices attached and no device specified

  File "/home/botond/dev/mozilla/refactoring/testing/mochitest/mach_commands.py", line 460, in run_mochitest_general
    app=app, device_serial=device_serial)
  File "/home/botond/dev/mozilla/refactoring/testing/mozbase/mozrunner/mozrunner/devices/android_device.py", line 240, in verify_android_device
    device = _get_device(build_obj.substs, device_serial)
  File "/home/botond/dev/mozilla/refactoring/testing/mozbase/mozrunner/mozrunner/devices/android_device.py", line 102, in _get_device
    device = ADBDevice(adb=adb_path, verbose=verbose_logging, device=device_serial)
  File "/home/botond/dev/mozilla/refactoring/testing/mozbase/mozdevice/mozdevice/adb.py", line 599, in __init__
    self._device_serial = self._get_device_serial(device)
  File "/home/botond/dev/mozilla/refactoring/testing/mozbase/mozdevice/mozdevice/adb.py", line 758, in _get_device_serial
    raise ValueError("ADBDevice called with multiple devices "

I haven't figured out a way to get it to use the emulator without disconnecting the phone first.

You should be able to use

mach mochitest ... --deviceSerial=...

Thanks! I can confirm that works.

Might still be nice to pass through ANDROID_SERIAL to adb as an enhancement, but it's not super important given the mach option.

Yeah. That's an issue I keep coming back to but it is not a blocker. It would help with logging though since error messages would no longer contain the -s <serial> string. But most frameworks currently require the serial number and we would need additional work to support the environment variable in them as well. Moving this to mozbase/mozdevice. If we ever do fix this then we can think about making the frameworks support ANDROID_SERIAL as well.

Severity: normal → enhancement
Component: Testing → Mozbase
Product: Firefox for Android → Testing
Summary: |mach mochitest| on Android ignores ANDROID_SERIAL environment variable → [mozdevice] adb should support ANDROID_SERIAL environment variable
Whiteboard: [good first bug]

(In reply to Botond Ballo [:botond] from comment #3)

Thanks! I can confirm that works.

Hmm -- it doesn't work for |mach install|, though.

Priority: -- → P3

(In reply to Botond Ballo [:botond] from comment #5)

(In reply to Botond Ballo [:botond] from comment #3)

Thanks! I can confirm that works.

Hmm -- it doesn't work for |mach install|, though.

Ah, but ANDROID_SERIAL does work for mach install. So there's a way to work multiple devices, just as long as you remember each subcommand's idiosyncracies :)

Whiteboard: [good first bug] → [good first bug] dev-prod-2020
Keywords: good-first-bug
Whiteboard: [good first bug] dev-prod-2020 → dev-prod-2020

Geoff, this bug misses a mentor field. So it will never be picked-up that way.

Flags: needinfo?(gbrown)

Actually, as I recall, there are some complications in this bug (handling the env var + existing options and ensuring consistently between different automation layers) -- maybe not a g-f-b after all.

Flags: needinfo?(gbrown)
Keywords: good-first-bug
Assignee: nobody → bob
Blocks: 1654874
Status: NEW → ASSIGNED
Pushed by bclary@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/b69794d23f1c
[mozdevice 4.0.1] adb should use ANDROID_SERIAL environment variable if device not otherwise specified. r=gbrown
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 81 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: