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

From MozillaWiki
Jump to navigation Jump to search
No edit summary
Line 4: Line 4:


= 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 careful with what you run in the terminal as admin mode will allow you to make changes to core file system'''
'''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
* '''Do not run sudo mode when working with hg'''


* [https://wiki.mozilla.org/QA_SoftVision_Team/Mobile/Robocop_automation_setup#Install_Java_and_kDiff Install Java and kDiff]
* [https://wiki.mozilla.org/QA_SoftVision_Team/Mobile/Robocop_automation_setup#Install_Java_and_kDiff Install Java and kDiff]
Line 42: Line 45:
* ccache will help spead up the compilation process when recompilating newer versions of the code
* ccache will help spead up the compilation process when recompilating newer versions of the code
* Run in terminal
* Run in terminal
  apt-get install ccache
  sudo apt-get install ccache
* Add ccache to the PATH variable
* Add ccache to the PATH variable
  export PATH=/usr/lib/ccache:$PATH
  sudo export PATH=/usr/lib/ccache:$PATH


== Install Mercurial ==  
== Install Mercurial ==  
Line 166: Line 169:
  . $topsrcdir/browser/config/mozconfig
  . $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 -j10"
  mk_add_options MOZ_MAKE_FLAGS="-s -j4"
  ac_add_options --enable-debug
  ac_add_options --enable-debug
  ac_add_options --disable-optimize
  ac_add_options --disable-optimize
Line 194: Line 197:
=== Make the builds ===
=== Make the builds ===
* run command in the source directory for each build
* run command in the source directory for each build
  make -f client.mk
* make sure the PATH variable is updated with the path to the Android SDK in each terminal
  sudo make -f client.mk


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


=== Install the package on Android ===
=== Install the package on Android ===
Line 215: Line 219:
=== 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
  make mochitest-robotium
  sudo 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
   
   
  TEST_PATH=testLoad make mochitest-robotium
  sudo TEST_PATH=testLoad make mochitest-robotium


=== Copy the terminal to a file for test results logging ===
=== Copy the terminal to a file for test results logging ===
  make mochitest-robotium | tee logfile.txt
  sudo make mochitest-robotium | tee logfile.txt
                   or
                   or
  TEST_PATH=testLoad make mochitest-robotium | tee logfile.txt
  sudo TEST_PATH=testLoad make mochitest-robotium | tee logfile.txt

Revision as of 13:37, 3 December 2012

General Info

  • 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

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
  • Do not run sudo mode when working with hg

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

  • Download the java package form HERE - download the .tar.gz version
  • 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:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install update-java
  • Install java
sudo update-java
  • When asked what version to update to choose: "java-7-oracle"

Install ccache

  • ccache will help spead 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
sudo export PATH=/usr/lib/ccache:$PATH

Install Mercurial

  • Here is a link to the detailed information about Installing and setting up mercurial
  • To install Mercurial run in a Terminal the following commands:
sudo apt-get install python-setuptools python-dev build-essential
sudo easy_install -U mercurial

Configuring Mercurial and downloading sources

  • All content of the configuration is general. Please update field where needed to work with your configuration

Mercurial configuration

  • Create the file .hgrc in your home directory – you can use $ sudo gedit and save the file with the name .hgrc
  • Add in $HOME/.hgrc
[ui]
username = Your Real Name <user@example.com>
merge = your-merge-program (or internal:merge)

[diff]
git = 1
showfunc = 1
unified = 8
[defaults]
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

  • Add in .hgrc
[extensions]
mq =
[defaults]
qnew = -U
[mq]
plain = True

Configure repository

  • Add in .hgrc
[paths]
try = ssh://hg.mozilla.org/try/

Download sources using Mercurial

  • Replace <src> with desired directory
  • 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> 
  • Change "mozilla-central" to "mozilla-inbound", "mozilla-aurora", "mozilla-beta" or "mozilla-release" depending on which branch you want to run the tests on

Update sources

  • run command in the source directory
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

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 ia32-libs

Install Android NDK

  • Download the archive and unpack it
wget http://dl.google.com/android/ndk/android-ndk-r5c-linux-x86.tar.bz2
tar -xjf android-ndk-r5c-linux-x86.tar.bz2

Install Android SDK

  • Download the archive and unpack it
wget http://dl.google.com/android/android-sdk_r15-linux.tgz
tar -xzf android-sdk_r15-linux.tgz

Update Android SDK

  • run in the terminal from the home file
sudo ./android-sdk-linux/tools/android update sdk -u
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
export PATH=$PATH:/home/<user>/android-sdk-linux/platform-tools:/home/<user>/android-sdk-linux/tools

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
  • Update the filepaths in the config file to mirror the locations on your system

Config file for Firefox Mobile

. $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-r5c"
ac_add_options --with-android-sdk="/dir/to/android-tools/android-sdk-macosx/platforms/android-14"
ac_add_options --with-android-version=5
ac_add_options --with-android-tools="/dir/to/android-tools/android-sdk-macosx/tools"
ac_add_options --with-android-toolchain="/dir/to/android-tools/android-ndk-r5c/toolchains/arm-linux-androideabi- 4.4.3/prebuilt/darwin-x86"
ac_add_options --with-android-platform="/dir/to/android-tools/android-ndk-r5c/platforms/android-5/arch-arm"
# 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
mk_add_options MOZ_OBJDIR=./objdir-firefox

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
sudo make -f client.mk

Make the Android package

cd obj-android/
sudo 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

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
sudo make mochitest-robotium

Running a single test

  • testLoad is the name of one of the tests
sudo TEST_PATH=testLoad make mochitest-robotium

Copy the terminal to a file for test results logging

sudo make mochitest-robotium | tee logfile.txt
                 or
sudo TEST_PATH=testLoad make mochitest-robotium | tee logfile.txt