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

(Created page with "= Steps to setup enviroment and start running tests= 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...")
 
 
(68 intermediate revisions by 4 users not shown)
Line 1: Line 1:
= 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
* 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.
= Steps to setup enviroment and start running tests=
= Steps to setup enviroment and start running tests=
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 carefull with what you run in the terminal as admin mode will allow you to make changes to core file system'''
'''Note''':  
* 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'''


* Install Java and kDiff
* [https://wiki.mozilla.org/QA_SoftVision_Team/Mobile/Robocop_automation_setup#Install_Java_and_kDiff Install Java and kDiff]
* Install Mercurial
* [https://wiki.mozilla.org/QA_SoftVision_Team/Mobile/Robocop_automation_setup#Install_Mercurial Install Mercurial]
* Setup Mercurial
* [https://wiki.mozilla.org/QA_SoftVision_Team/Mobile/Robocop_automation_setup#Configuring_Mercurial_and_downloading_souces Setup Mercurial]
* Clone sources twice
* [https://wiki.mozilla.org/QA_SoftVision_Team/Mobile/Robocop_automation_setup#Download_sources_using_Mercurial Clone sources twice]
* Install Android SDK and NDK
* [https://wiki.mozilla.org/QA_SoftVision_Team/Mobile/Robocop_automation_setup#Install_and_configure_Android_SDK_and_NDK Install Android SDK and NDK]
* Build sources using .mozconfig files
* [https://wiki.mozilla.org/QA_SoftVision_Team/Mobile/Robocop_automation_setup#Create_.mozconfig_files Build sources using .mozconfig files]
* Package the mobile build and install
* [https://wiki.mozilla.org/QA_SoftVision_Team/Mobile/Robocop_automation_setup#Make_the_Android_package Package the mobile build and install]
* Run tests
* [https://wiki.mozilla.org/QA_SoftVision_Team/Mobile/Robocop_automation_setup#Run_Tests Run tests]


= Detailed steps =
= Detailed steps =


== Install Java and kDiff ==
== Install Java ==
* 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
* Download the java package form [http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html HERE] - download the .tar.gz version
* The easiest way to install them is from the Ubuntu Software Manager
* Extract the content to /home/java-7-oracle
* Move the content of the folder to /usr/lib/jvm
 
sudo mkdir -p  /usr/lib/jvm/ #just in case
sudo mv java-7-oracle /usr/lib/jvm/
 
* Get java from the 3rd party repository
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
 
== Install ccache ==
* ccache will help speed up the compilation process when recompilating newer versions of the code
* Run in terminal
sudo apt-get install ccache
* Add ccache to the PATH variable
**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 23: Line 55:
  sudo easy_install -U mercurial
  sudo easy_install -U mercurial


== Configuring Mercurial and downloading souces ==
== Configuring Mercurial and downloading sources ==
* All content of the configuration is general. Please update field where needed to work with your configuration
* All content of the configuration is general. Please update field where needed to work with your configuration


Line 32: 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 41: 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 73: Line 95:
* Replace <src> with desired directory
* Replace <src> with desired directory
* Clone the sources twice: 1 for the mobile build and one for the automation build
* Clone the sources twice: 1 for the mobile build and one for the automation build
* In order to clone the source code run the hg clone command


  hg clone http://hg.mozilla.org/mozilla-central/ <src>  
  hg clone http://hg.mozilla.org/mozilla-central/ <src>  
* Change "mozilla-central" to "mozilla-inbound", "mozilla-aurora", "mozilla-beta" or "mozilla-release" depending on which branch you want to run the tests on
* Cloning the sources to a specific revision
  hg clone -r <revision> http://hg.mozilla.org/mozilla-central/ <src>


=== Update sources ===
=== Update sources ===
Line 80: Line 108:


  hg pull -u
  hg pull -u
=== Adding a patch to the repository ===
* The repository needs to be a clean repository in order to apply the patch
==== Adding the patch ====
hg qimport <patch_name>
==== Pushing the changes localy ====
hg qpush -v
==== Refreshing the files ====
hg qrefresh
== Install and configure Android SDK and NDK ==
* in order to run tests you will need the Android SDK (Software development kit) and the Android NDK (Native-code development kit)
=== Install Geko Requirements ===
* Run in the terminal the command
sudo apt-get build-dep firefox
=== Install ia32-lib binaries ===
*These binaries are required in order to get the Android SDK to work on Linux x64
* 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
=== Install Android NDK ===
* Download the archive and unpack it
wget http://dl.google.com/android/ndk/android-ndk-r8e-linux-x86_64.tar.bz2
tar -xjf android-ndk-r8e-linux-x86_64.tar.bz2
=== Install Android SDK ===
* Download the archive and unpack it
wget http://dl.google.com/android/android-sdk_r22.0.5-linux.tgz
tar -xzf android-sdk_r22.0.5-linux.tgz
=== Update Android SDK ===
* 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
* Make sure you have Android SDK platform-tools 18.0.1 and Android SDK build-tools 17 and 18.0.1
* 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
=== 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 ==
* 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
* 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
=== Config file for the automation build (Desktop Build) ===
ac_add_options --enable-application=browser
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 ==
* The object folders for the builds are '''obj-android''' and can be found in the source directory
=== Make the builds ===
* 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 -f client.mk
=== Make the Android package ===
cd obj-android/
make package
=== Install the package on Android ===
* The package can be found in the "source directory"/obj-android/dist/
* Run the command from the android-sdk-linux/platform tools folder
./adb install /home/<user>/<sourse directory>/obj-android/dist/fennec-18.0a1.en-US.android-arm.apk
=== Uninstall the package ===
* You will need to remove both the automation build and the robocop apk in order to ensure that there will be no conflicts when you install a build from another branch or you run automation from builds made on other machines
* To find the package name
adb shell pm list packages
* To uninstall the package
adb uninstall <package_name>
* The package name should start with org.mozilla.<build_name>
== Run Tests ==
=== Set up the MOZ_HOST_BIN environment variable ===
* The variable should point to the bin directory of the automation (desktop) build
* The command can be added to .profile for convinence or just run in the Terminal
export MOZ_HOST_BIN=/ABSOLUTE/PATH/TO/FIREFOX/SOURCE/{objdir}/dist/bin
=== Running all the tests ===
* Run command from the object directory under the Firefox mobile source repository
make mochitest-robotium
=== Running a single test ===
* testLoad is the name of one of the tests
TEST_PATH=testLoad make mochitest-robocop
=== Copy the terminal to a file for test results logging ===
make mochitest-robotium | tee logfile.txt
                  or
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