Mobile/Fennec/Android/Testing: Difference between revisions

 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
This page has instructions for running Firefox tests locally on a device (Android phone, tablet, or emulator) of your choice.
This page has instructions for running Firefox tests locally on a device (Android phone, tablet, or emulator) of your choice.


Having trouble? Ping :gbrown on #mobile, or ask for help on #ateam.
Having trouble? Ping :gbrown on #mobile.


== For the impatient... ==
== For the impatient... ==
Line 14: Line 14:
   mach cppunittest
   mach cppunittest
   mach geckoview-junit
   mach geckoview-junit
  mach web-platform-test
  mach marionette-test
  mach test


They all run against a connected Android device using your Firefox for Android build. Don't have a device? These commands will offer to start an emulator.
They all run against a connected Android device using your Firefox for Android build. Don't have a device? These commands will offer to start an emulator.
Line 142: Line 145:


   mach robocop <test-name>
   mach robocop <test-name>
If you make changes to the tests and want to see them run on a device, you need to build the tests again and reinstall.
  mach build mobile/android/tests/browser/robocop
  mach robocop
This builds the tests in <tt>mobile/android/tests/browser/robocop</tt> and then installs the debug-signed Robocop APK onto the device. (Building <tt>mobile/android</tt> also builds the tests within <tt>mobile/android/tests</tt>.)


Notes:
Notes:
* Mach is self documenting!  For help, try <tt>mach help robocop</tt>.
* To run one test at a time, find the test name (like "testLoad") in <tt>mobile/android/tests/browser/robocop/robocop.ini</tt> and pass it as an argument, like: <tt>mach robocop testLoad</tt>.
* To run one test at a time, find the test name (like "testLoad") in <tt>mobile/android/tests/browser/robocop/robocop.ini</tt> and pass it as an argument, like: <tt>mach robocop testLoad</tt>.
* A rooted device is recommended, but may not be required. Test harnesses may need to kill processes, copy and delete files, or perform other operations which may require special permissions on some devices.
* A rooted device is required. Test harnesses may need to kill processes, copy and delete files, or perform other operations which may require special permissions on some devices.
*Additional tips at [[Auto-tools/Projects/Robocop#Frequently_found_errors]]
* Additional tips at [[Auto-tools/Projects/Robocop#Frequently_found_errors]]


=== Static analysis ===
=== Static analysis ===
Line 228: Line 223:


Notes:
Notes:
* A rooted device is recommended, but may not be required. Test harnesses may need to kill processes, copy and delete files, or perform other operations which may require special permissions on some devices.
* A rooted device is required. Test harnesses may need to kill processes, copy and delete files, or perform other operations which may require special permissions on some devices.
* Setup can take several minutes! Setup is faster if unzip is available on the remote device; if your device does not have unzip, try installing busybox.
* Setup can take several minutes! Setup is faster if unzip is available on the remote device; if your device does not have unzip, try installing busybox.


Line 286: Line 281:
== Running tests on the Android emulator ==
== Running tests on the Android emulator ==


The "Android 4.3 API16+ opt" and "Android 4.3 API16+ debug" tests on treeherder run in an Android ARM emulator. "Android 4.2 x86 opt" tests run in an Android x86 emulator. For best results reproducing test failures, try server is recommended: '''Running the same tests on the same emulator on different host hardware may produce different results'''.
The "Android 4.3 API16+ opt" and "Android 4.3 API16+ debug" tests on treeherder run in an Android ARM emulator. "Android 7.0 x86_64 opt/debug" tests run in an Android x86 emulator. For best results reproducing test failures, try server is recommended: '''Running the same tests on the same emulator on different host hardware may produce different results'''.


Still, if you want to run the emulator locally, using the same Android image used for tests on treeherder, it is simple:
Still, if you want to run the emulator locally, using the same Android image used for tests on treeherder, it is simple:
Line 294: Line 289:
That 'android-emulator' command will download the Android 4.3 API16+ Android image from tooltool, install it, and launch the Android emulator using all the same parameters used for tests on treeherder. (The Android SDK must be installed locally. mach will try to find the emulator binary in your $PATH environment variable, via the $ANDROID_SDK_ROOT environment variable, through your Android build configuration, and finally in the default location used by 'mach bootstrap'.)
That 'android-emulator' command will download the Android 4.3 API16+ Android image from tooltool, install it, and launch the Android emulator using all the same parameters used for tests on treeherder. (The Android SDK must be installed locally. mach will try to find the emulator binary in your $PATH environment variable, via the $ANDROID_SDK_ROOT environment variable, through your Android build configuration, and finally in the default location used by 'mach bootstrap'.)


To use the Android 4.2 x86 image:
To use the Android 7.0 x86_64 image:


   ./mach android-emulator --version x86
   ./mach android-emulator --version x86-7.0


(On Linux, the x86 emulator requires that kvm is installed. The resulting emulator is much faster than the arm emulator.)
(On Linux, the x86 emulator requires that kvm is installed. The resulting emulator is '''much''' faster than the arm emulator.)


The first time you run an emulator with any particular version, it may take several minutes to download and install the image; subsequent runs will be '''much''' faster.
The first time you run an emulator with any particular version, it may take several minutes to download and install the image; subsequent runs will be '''much''' faster.
Line 312: Line 307:
   ./mach android-emulator && ./mach install && ./mach mochitest
   ./mach android-emulator && ./mach install && ./mach mochitest


For the '''very''' lazy, most mach test commands check that an Android device is connected; if not, they suggest running an emulator. Similarly, if tests are requested on a device that doesn't have Firefox installed, mach will offer to install it. So if you just run "mach mochitest" without a phone connected and without an emulator running, you might get:
For your convenience, most mach test commands check that an Android device is connected; if not, they suggest running an emulator. Similarly, if tests are requested on a device that doesn't have Firefox installed, mach will offer to install it. So if you just run "mach mochitest" without a phone connected and without an emulator running, you might get:


   $ ./mach mochitest testing/mochitest/tests/Harness_sanity
   $ ./mach mochitest testing/mochitest/tests/Harness_sanity
Line 331: Line 326:
   ...
   ...


=== Testing with stock AVD images (Android 4.x+ only) ===
=== Multiple emulators/devices ===


Testing with the above configurations is ideal, but in some cases you may prefer to use stock AVD device images from the Nexus profiles available.
It is possible to test with multiple emulators or devices using the --deviceSerial argument:
 
# From the Android Virtual Device (AVD) Manager, click 'Create....'
# Choose a Nexus phone or tablet device configuration. (Nexus 9 for tablets, Nexus 5 for phones is recommended).
# Choose a system image with API level 16 or 18. (If you're not sure if you want arm or x86 then you probably want arm). If no suitable image is available, one can be installed with the Android SDK Manager.
# Next, check 'Use Host GPU' if possible. See [http://developer.android.com/tools/devices/emulator.html#acceleration Using Hardware Acceleration].
# Hit Finish and that should be it. If you have setup Firefox for Android to [[Mobile/Fennec/Android/IDEs|run on your IDE]], you should be able to launch the emulator straight from there as well.
 
=== Multiple emulators ===
 
It's also possible to test with multiple emulators by correctly setting the ANDROID_SERIAL environment variable to the device ID seen in ''adb devices'':
     $ adb devices
     $ adb devices
     List of devices attached
     List of devices attached
Line 361: Line 346:


=== Advanced setup ===
=== Advanced setup ===
Alternatively, if one of the prebuilt host utilities packages is not appropriate for you or does not work, you can fetch the host utils by using the '''getxre''' utility that comes with [[Mobile/Fennec/Android/GDB|JimDB]]. This utility will download the correct binaries for your host machine, and set the appropriate permissions. You should prefer the prebuilt host utilities because they are more likely to be tested and are significantly smaller downloads than the intermediate packages downloaded by <tt>getxre</tt>. (<tt>getxre</tt> does what the [[Packaging_Android_host_utilities|packaging instructions]] describe, except it has not been updated for current Firefox package structure on Mac OS X.) In the following stanza, replace <tt>$DIR</tt> with an output directory, such as <tt>~/.mozbuild/host-utils</tt>.
  wget https://github.com/darchons/android-gdbutils/raw/master/python/getxre.py
  python getxre.py -d $DIR
  export MOZ_HOST_BIN=$DIR/bin


Alternatively, you can build desktop Firefox with a mozconfig which might be as simple as:
Alternatively, you can build desktop Firefox with a mozconfig which might be as simple as:
Line 395: Line 374:


   --remoteTestRoot=<remote-directory>
   --remoteTestRoot=<remote-directory>
== S1/S2 Automation ==
These tests start Firefox for Android with a URL and measure the time to throbber start, time to throbber stop, and drawing end times.
S1/S2 graphs can be viewed at:  http://phonedash.mozilla.org/
Manual run instructions can be found at: https://etherpad.mozilla.org/fennec-perf-ts-take2
See also: https://wiki.mozilla.org/Mobile/Performance/S1S2-Tests
== Eideticker ==
Eideticker measures perceived Firefox performance by video capturing automated browser interactions.
Eideticker is no longer running Android tests. Historical data can be viewed at: http://eideticker.mozilla.org/
See also:
** http://wrla.ch/blog/2011/11/measuring-what-the-user-sees/
** http://wrla.ch/blog/2012/03/announcing-the-eideticker-mobile-performance-dashboard/
** https://github.com/mozilla/eideticker


== Trouble-shooting testing problems ==
== Trouble-shooting testing problems ==
Line 431: Line 390:
** Make sure _SERVER_ADDR in the test output is the same as your machine's IP address.
** Make sure _SERVER_ADDR in the test output is the same as your machine's IP address.
* If using MOZ_HOST_BIN, ensure the binaries in your MOZ_HOST_BIN folder are executable, in case you pull them down from the FTP site. You might see "OSError: [Errno 13] Permission denied" if they are not executable. Use chmod to fix them. Check certutil, pk12util and ssltunnel.
* If using MOZ_HOST_BIN, ensure the binaries in your MOZ_HOST_BIN folder are executable, in case you pull them down from the FTP site. You might see "OSError: [Errno 13] Permission denied" if they are not executable. Use chmod to fix them. Check certutil, pk12util and ssltunnel.
* Is your device rooted? Many test suites require root permissions. Don't want to root your device? Consider using an emulator with 'mach android-emulator'.
Confirmed users
1,759

edits