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

 
(23 intermediate revisions by one other user 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 38: Line 34:


== 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 59: 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 68: 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 150: Line 145:
=== 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 ==
Line 167: Line 165:
* 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=9
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 NDK r8e x86_64 build ===
=== 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
<pre> . $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-android
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-android
mk_add_options MOZ_MAKE_FLAGS="-s -j8"
mk_add_options MOZ_MAKE_FLAGS="-s -j8"
ac_add_options --enable-debug
ac_add_options --enable-debug
ac_add_options --disable-optimize
ac_add_options --enable-optimize
ac_add_options --with-ccache
ac_add_options --with-ccache
ac_add_options --disable-crashreporter
ac_add_options --disable-crashreporter
Line 203: Line 200:
ac_add_options --with-android-sdk="/home/adriantamas/android-sdk-linux/platforms/android-16"
ac_add_options --with-android-sdk="/home/adriantamas/android-sdk-linux/platforms/android-16"
ac_add_options --with-android-version=9
ac_add_options --with-android-version=9
ac_add_options --with-android-tools="/home/adriantamas/android-sdk-linux/tools"
ac_add_options --with-android-toolchain="/home/adriantamas/android-ndk-r8e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64"
# Android options
# Android options
## Native UI:
## Native UI:
ac_add_options --enable-application=mobile/android
ac_add_options --enable-application=mobile/android
ac_add_options --target=arm-linux-androideabi
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>
ac_add_options --with-endian=little </pre>


Line 217: 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 246: 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 ===
=== Run tests remotely via the SUTAgent ===
Line 264: Line 281:
<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>
<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
* 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