QA SoftVision Team/Mobile/Robocop automation setup: Difference between revisions

 
(37 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= General Info =  
= General Info =  
* [June 2, 2017] This page seems outdated, and describes a manual procedure for setting up a Firefox for Android build and test environment. Currently, something like 'mach bootstrap && mach build && mach package && mach robocop' should replace all of this, under most circumstances. See https://wiki.mozilla.org/Mobile/Fennec/Android/Testing.
* This document will help you set up the enviroment and create the builds to test, create and run automated tests using Robocop
* This document will help you set up the enviroment and create the builds to test, create and run automated tests using Robocop
* In order to run the tests you will need one build to be installed on the device - the Firefox Mobile build - and a second desktop build to send the commands to device - the automation build.
* In order to run the tests you will need one build to be installed on the device - the Firefox Mobile build - and a second desktop build to send the commands to device - the automation build.
Line 5: Line 6:
= Steps to setup enviroment and start running tests=
= Steps to setup enviroment and start running tests=
'''Note''':  
'''Note''':  
* To make things easyer you can run '''$sudo su''' in the Terminal you use so that all commands are run in admin mode and you do not need to add sudo befoare each command but '''make sure you are careful with what you run in the terminal as admin mode will allow you to make changes to core file system'''
* If in the terminal you run "sudo su" '''remove the sudo command used before each command found here'''
* If in the terminal you run "sudo su" '''remove the sudo command used before each command found here'''
* '''Do not run sudo mode when working with hg'''
* '''Do not run sudo mode when working with hg'''
Line 19: Line 19:


= Detailed steps =
= Detailed steps =
== Install kDiff ==
* kDiff3 is a merge tool that can verify the differences between the source codes allowing the user to download only the code that is different when updating the source files
* The easiest way to install kDiff3 is from the Ubuntu Software Manager


== Install Java ==
== Install Java ==
Line 33: Line 29:


* Get java from the 3rd party repository
* Get java from the 3rd party repository
  sudo add-apt-repository ppa:nilarimogard/webupd8
  sudo add-apt-repository ppa:webupd8team/java
  sudo apt-get update
  sudo apt-get update
  sudo apt-get install update-java
  sudo apt-get install oracle-java7-installer
 
* Install java
sudo update-java
 
* When asked what version to update to choose: "java-7-oracle"
 
* Install OpenJDK Java 7 Runtime from the Software Center


== Install ccache ==
== Install ccache ==
* ccache will help spead up the compilation process when recompilating newer versions of the code
* ccache will help speed up the compilation process when recompilating newer versions of the code
* Run in terminal
* Run in terminal
  sudo apt-get install ccache
  sudo apt-get install ccache
* Add ccache to the PATH variable
* Add ccache to the PATH variable
sudo export PATH=/usr/lib/ccache:$PATH
**Enter root by running:
  sudo su
**Run export to set the PATH variable
  export PATH=/usr/lib/ccache:$PATH
* Extend the ccache to improve build time:
ccache --max-size 8G
 
== Install gold linker ==
* Using the gold linker improves the linking time reducing the compile time significantly
sudo apt-get install binutils-gold


== Install Mercurial ==  
== Install Mercurial ==  
Line 66: Line 64:
  [ui]
  [ui]
  username = Your Real Name <user@example.com>
  username = Your Real Name <user@example.com>
  merge = your-merge-program (or internal:merge)
  merge = internal:merge
   
   
  [diff]
  [diff]
Line 75: Line 73:
  [defaults]
  [defaults]
  commit = -v
  commit = -v
=== Configure kDiff as merge tool ===
* Setting kDiff as the merge tool for Mercuial
* Add in .hgrc
[merge-tools]
kdiff3.args=--auto -L1 base --L2 local --L3 other $base $local $other -o $output
kdiff3.regkey=Software\KDiff3
kdiff3.regappend=\kdiff3.exe
kdiff3.fixeol=True
kdiff3.gui=True
   
   
=== Configure mq ===
=== Configure mq ===
Line 130: Line 118:
==== Pushing the changes localy ====
==== Pushing the changes localy ====


  hg qpush
  hg qpush -v


==== Refreshing the files ====
==== Refreshing the files ====
Line 146: Line 134:
*These binaries are required in order to get the Android SDK to work on Linux x64
*These binaries are required in order to get the Android SDK to work on Linux x64
* Run in the terminal the command
* Run in the terminal the command
sudo apt-get install libglapi-mesa:i386
sudo apt-get install ia32-libs-multiarch
  sudo apt-get install ia32-libs
  sudo apt-get install ia32-libs


=== Install Android NDK ===
=== Install Android NDK ===
* Download the archive and unpack it
* Download the archive and unpack it
  wget http://dl.google.com/android/ndk/android-ndk-r8c-linux-x86.tar.bz2
  wget http://dl.google.com/android/ndk/android-ndk-r8e-linux-x86_64.tar.bz2
  tar -xjf android-ndk-r8c-linux-x86.tar.bz2
  tar -xjf android-ndk-r8e-linux-x86_64.tar.bz2


=== Install Android SDK ===
=== Install Android SDK ===
* Download the archive and unpack it
* Download the archive and unpack it
  wget http://dl.google.com/android/android-sdk_r15-linux.tgz
  wget http://dl.google.com/android/android-sdk_r22.0.5-linux.tgz
  tar -xzf android-sdk_r15-linux.tgz
  tar -xzf android-sdk_r22.0.5-linux.tgz


=== Update Android SDK ===
=== Update Android SDK ===
* run in the terminal from the home file
* You can run the update form the Android sdk manager. Just run the "android" script from android-sdk-dir/tools/. Current used version of Android SDK is 22.0.5
sudo ./android-sdk-linux/tools/android update sdk -u
* Make sure you have Android SDK platform-tools 18.0.1 and Android SDK build-tools 17 and 18.0.1
sudo ./android-sdk-linux/tools/android update adb
 
* it is also a good idea to add the lines in the .profile file found in /home the command to make android sdk available from anywhere
* it is also a good idea to add the lines in the .profile file found in /home the command to make android sdk available from anywhere
  export PATH=$PATH:/home/<user>/android-sdk-linux/platform-tools:/home/<user>/android-sdk-linux/tools
  export PATH=$PATH:/home/<user>/android-sdk-linux/platform-tools:/home/<user>/android-sdk-linux/tools
=== Change permissions for SDK and NDK ===
* Change the permissions for sdk and ndk and also for the .android folders to make sure they can be accessed from anywhere
chmod 0777 -R sdk_or_ndk_dir
chmod 0777 -R .android


== Create .mozconfig files ==
== Create .mozconfig files ==
* You have to create a .mozconfig file for each build
* You have to create a .mozconfig file for each build
* Use gedit or any other file editor to create the .mozconfig file in the root directory of the build
* Use gedit or any other file editor to create the .mozconfig file in the root directory of the build
* In the sources you can find the standard build mozconfigs here: mobile/android/config/mozconfigs/android/nightly
* Update the filepaths in the config file to mirror the locations on your system
* Update the filepaths in the config file to mirror the locations on your system


=== Config file for Firefox Mobile ===
=== Config file for the automation build (Desktop Build) ===
. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-android
mk_add_options MOZ_MAKE_FLAGS="-s -j4"
ac_add_options --enable-debug
ac_add_options --disable-optimize
ac_add_options --with-ccache
ac_add_options --disable-crashreporter
# Android SDK/NDK
ac_add_options --with-android-ndk="/dir/to/android-tools/android-ndk-r8c"
ac_add_options --with-android-sdk="/dir/to/android-tools/android-sdk-macosx/platforms/android-16"
ac_add_options --with-android-version=5
ac_add_options --with-android-tools="/dir/to/android-tools/android-sdk-macosx/tools"
# Android options
## Native UI:
ac_add_options --enable-application=mobile/android
ac_add_options --target=arm-linux-androideabi
ac_add_options --with-endian=little
 
=== Config file for the automation build ===


  ac_add_options --enable-application=browser
  ac_add_options --enable-application=browser
  mk_add_options MOZ_OBJDIR=./objdir-firefox
  mk_add_options MOZ_OBJDIR=./objdir-firefox
=== Mozconfig for ARMv7 (Firefox Mobile)===
<pre> . $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-android
mk_add_options MOZ_MAKE_FLAGS="-s -j8"
ac_add_options --enable-debug
ac_add_options --enable-optimize
ac_add_options --with-ccache
ac_add_options --disable-crashreporter
# Android SDK/NDK
ac_add_options --with-android-ndk="/home/adriantamas/android-ndk-r8e"
ac_add_options --with-android-sdk="/home/adriantamas/android-sdk-linux/platforms/android-16"
ac_add_options --with-android-version=9
# Android options
## Native UI:
ac_add_options --enable-application=mobile/android
ac_add_options --target=arm-linux-androideabi
ac_add_options --with-endian=little </pre>
=== Mozconfig for ARMv6 builds ===
<pre> . $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-android
mk_add_options MOZ_MAKE_FLAGS="-s -j8"
ac_add_options --enable-debug
ac_add_options --enable-optimize
ac_add_options --with-ccache
ac_add_options --disable-crashreporter
# Android SDK/NDK
ac_add_options --with-android-ndk="/home/adriantamas/android-ndk-r8e"
ac_add_options --with-android-sdk="/home/adriantamas/android-sdk-linux/platforms/android-16"
ac_add_options --with-android-version=9
# Android options
## Native UI:
ac_add_options --enable-application=mobile/android
ac_add_options --target=arm-linux-androideabi
ac_add_options --with-arch=armv6
ac_add_options --with-endian=little
export MOZ_PKG_SPECIAL=armv6</pre>
=== Mozconfig for X86 ===
<pre> . $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-android
mk_add_options MOZ_MAKE_FLAGS="-s -j8"
ac_add_options --enable-debug
ac_add_options --enable-optimize
ac_add_options --with-ccache
ac_add_options --disable-crashreporter
# Android SDK/NDK
ac_add_options --with-android-ndk="/home/adriantamas/android-ndk-r8e"
ac_add_options --with-android-sdk="/home/adriantamas/android-sdk-linux/platforms/android-16"
ac_add_options --with-android-version=9
# Android options
## Native UI:
ac_add_options --enable-application=mobile/android
ac_add_options --target=i386-linux-android
ac_add_options --with-endian=little </pre>


== Make the builds ==
== Make the builds ==
Line 201: Line 234:
* run command in the source directory for each build
* run command in the source directory for each build
* make sure the PATH variable is updated with the path to the Android SDK in each terminal
* make sure the PATH variable is updated with the path to the Android SDK in each terminal
  sudo make -f client.mk
  make -f client.mk


=== Make the Android package ===
=== Make the Android package ===
   
   
  cd obj-android/
  cd obj-android/
  sudo make package
  make package


=== Install the package on Android ===
=== Install the package on Android ===
Line 230: Line 263:
=== Running all the tests ===
=== Running all the tests ===
* Run command from the object directory under the Firefox mobile source repository
* Run command from the object directory under the Firefox mobile source repository
  sudo make mochitest-robotium
  make mochitest-robotium


=== Running a single test ===
=== Running a single test ===
* testLoad is the name of one of the tests
* testLoad is the name of one of the tests
   
   
  sudo TEST_PATH=testLoad make mochitest-robotium
  TEST_PATH=testLoad make mochitest-robocop


=== Copy the terminal to a file for test results logging ===
=== Copy the terminal to a file for test results logging ===
  sudo make mochitest-robotium | tee logfile.txt
  make mochitest-robotium | tee logfile.txt
                   or
                   or
  sudo TEST_PATH=testLoad make mochitest-robotium | tee logfile.txt
  TEST_PATH=testLoad make mochitest-robocop | tee logfile.txt
 
=== Run tests remotely via the SUTAgent ===
* In order to run tests remotely you will need to setup the SUTAgent ([https://wiki.mozilla.org/QA_SoftVision_Team/Mobile/Pandaboard_setup#Using_the_SUTAgent How to install])
* The device will have to be in the same network as the pc you are trying to run the tests from
* After getting the IP of the device just substitute the variables in the command:
<pre> _virtualenv/bin/python _tests/testing/mochitest/runtestsremote.py --robocop-path=./dist --robocop-ids=./dist/fennec_ids.txt --console-level=INFO --log-file=./mochitest-robotium.log --file-level=INFO  --dm_trans=sut --app=org.mozilla.fennec_root --deviceIP=192.168.77.104 --xre-path=/home/adriantamas/desktopc/objdir-firefox/dist/bin --robocop=./build/mobile/robocop/robocop.ini </pre>
* If you want to select which tests, from the existing tests in the build, to run in the testrun just create a robocop.ini file and specify it with the --robocop variable
 
=== Run tests via adb to behave as remote ===
* You can run tests through adb but using the runtestsremote script
* Run the command in a terminal with admin privilages from the obj-android directory of the mobile build
<pre> _virtualenv/bin/python _tests/testing/mochitest/runtestsremote.py --robocop-path=./dist --robocop-ids=./dist/fennec_ids.txt --console-level=INFO --log-file=./mochitest-robotium.log --file-level=INFO  --dm_trans=adb --app=org.mozilla.fennec_root --deviceIP= --xre-path=/home/adriantamas/desktopc/objdir-firefox/dist/bin --robocop=robocop.ini  </pre>
* In this run the --robocop parameter is set to get a robocop.ini file from the obj-android directory. You can either set it to the same as the remote run via SUTAgent to run all the tests all you can make a copy of it in obj-android and activate what tests you want to run or make multiple copies of the same test to run it over and over
Confirmed users
1,759

edits