Closed Bug 1454404 Opened 6 years ago Closed 6 years ago

./mach should use `adb` from `.mozbuild` as setup through ./mach bootstrap, not try to find it in $PATH and fail with cryptic error messages (ADBError: [Errno 2] No such file or directory: adb is not executable.)


(Firefox for Android Graveyard :: Testing, defect)

Not set


(firefox61 fixed)

Firefox 61
Tracking Status
firefox61 --- fixed


(Reporter: Gijs, Assigned: gbrown)




(1 file)


1. empty env,
2. clone mozilla-unified, update to central
3. run ./mach bootstrap, pick option 3 (android artifact)
4. ./mach build && ./mach mochitest --flavor plain dom/base/test/


it works


when it comes to running the test, it first checks for adb stuff:

 0:01.68 adb INFO adbd running as root
 0:01.80 adb INFO su -c supported
 0:01.91 adb INFO su 0 supported
 0:02.33 adb INFO /system/bin/ls -a supported
 0:02.45 adb INFO Native cp support: True
 0:02.56 adb INFO Native chmod -R support: True

and then it fails:

Error running mach:

    ['mochitest', '--flavor', 'plain', 'dom/base/test']

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

The details of the failure are as follows:

ADBError: [Errno 2] No such file or directory: adb is not executable.

  File "/Users/gkruitbosch/dev/firefox-unified/testing/mochitest/", line 428, in run_mochitest_general
  File "/Users/gkruitbosch/dev/firefox-unified/testing/mochitest/", line 180, in run_android_test
    return runtestsremote.run_test_harness(parser, options)
  File "/Users/gkruitbosch/dev/builds/android/_tests/testing/mochitest/", line 341, in run_test_harness
    mochitest = MochiRemote(options)
  File "/Users/gkruitbosch/dev/builds/android/_tests/testing/mochitest/", line 46, in __init__
  File "/Users/gkruitbosch/dev/firefox-unified/testing/mozbase/mozdevice/mozdevice/", line 84, in __init__
  File "/Users/gkruitbosch/dev/firefox-unified/testing/mozbase/mozdevice/mozdevice/", line 560, in __init__
    timeout=timeout, verbose=verbose)
  File "/Users/gkruitbosch/dev/firefox-unified/testing/mozbase/mozdevice/mozdevice/", line 179, in __init__
    raise ADBError('%s: %s is not executable.' % (exc, adb))

It seems the second time it tries to find adb in $PATH. Adding its dir to $PATH fixes the error and makes it run the same adb stuff a second time. I dunno why it needs to run twice, but it'd be nice if the user didn't have to figure out the error themselves (or even have to manually tweak $PATH themselves).
Summary: ./mach should use `adb` from `.mozbuild` as setup through ./mach bootstrap, not try to find it in $PATH and fail with cryptic error messages → ./mach should use `adb` from `.mozbuild` as setup through ./mach bootstrap, not try to find it in $PATH and fail with cryptic error messages (ADBError: [Errno 2] No such file or directory: adb is not executable.)
Looks like this is failing in the test harness. The mach command should be passing adb_path to the harnesses.
Assignee: nobody → gbrown
Component: Build Config → Testing
Product: Toolkit → Firefox for Android
In mach, when --adbpath is specified, mach should use that and instruct the test harness should use that.

In mach, when --adbpath is not specified, mach should query the build system to find adb, then mach and the test harness should use that.

When --adbpath is not specified to a test harness, the harness should use 'adb' to try to pick up adb from the $PATH, as a last resort.

On treeherder, mach is not used and mozharness typically does not specify --adbpath, so the fallback to $PATH is normally relied on.

This behavior was broken (slightly, quietly) by patches in bug 1440714, which changed the --adbpath defaults for most harnesses from None to 'adb'. With the new defaults, most mach checks for adbpath mistakenly believe --adbpath has been specified, causing failures when adb is not in $PATH and not actually specified by --adbpath.
Blocks: 1440714
Change the harness adb-path option defaults to None, so that mach can detect when a path is not specified:

Then change the path used for ADBAndroid initialization to use 'adb' as a last resort -- options.adbPath or 'adb' -- in case the harness is running outside mach and --adb-path is not specified.

I tested this locally with mach and adb not in my $PATH -- all's well.
Attachment #8968294 - Flags: review?(jmaher)
Comment on attachment 8968294 [details] [diff] [review]
change --adb_path defaults so mach test commands do not rely on $PATH

Review of attachment 8968294 [details] [diff] [review]:

Attachment #8968294 - Flags: review?(jmaher) → review+
Pushed by
Pass adb path from Android mach commands to test harnesses; r=jmaher
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 61
See Also: → 1547933
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.