2013-07-29 17:01:54 +00:00
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
2015-03-24 21:42:24 +00:00
from argparse import ArgumentParser
2014-11-05 00:59:40 +00:00
from urlparse import urlparse
2015-03-24 21:42:24 +00:00
import logging
2013-07-26 18:40:04 +00:00
import os
import tempfile
from mozprofile import DEFAULT_PORTS
2015-03-24 21:42:24 +00:00
import mozinfo
import moznetwork
from automation import Automation
2013-07-26 18:40:04 +00:00
2013-08-26 21:17:51 +00:00
here = os . path . abspath ( os . path . dirname ( __file__ ) )
2013-08-22 19:24:40 +00:00
2013-07-26 18:40:04 +00:00
try :
from mozbuild . base import MozbuildObject
2013-08-22 19:24:40 +00:00
build_obj = MozbuildObject . from_environment ( cwd = here )
2013-07-26 18:40:04 +00:00
except ImportError :
build_obj = None
__all__ = [ " MochitestOptions " , " B2GOptions " ]
VMWARE_RECORDING_HELPER_BASENAME = " vmwarerecordinghelper "
2015-02-13 19:42:02 +00:00
2015-03-24 21:42:24 +00:00
class MochitestOptions ( ArgumentParser ) :
2013-07-26 18:40:04 +00:00
""" Usage instructions for runtests.py.
All arguments are optional .
If - - chrome is specified , chrome tests will be run instead of web content tests .
If - - browser - chrome is specified , browser - chrome tests will be run instead of web content tests .
See < http : / / mochikit . com / doc / html / MochiKit / Logging . html > for details on the logging levels .
"""
LOG_LEVELS = ( " DEBUG " , " INFO " , " WARNING " , " ERROR " , " FATAL " )
LEVEL_STRING = " , " . join ( LOG_LEVELS )
mochitest_options = [
[ [ " --close-when-done " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-07-26 18:40:04 +00:00
" dest " : " closeWhenDone " ,
" default " : False ,
" help " : " close the application when tests are done running " ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --appname " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " app " ,
2013-07-31 20:45:54 +00:00
" default " : None ,
2013-07-26 18:40:04 +00:00
" help " : " absolute path to application, overriding default " ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --utility-path " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " utilityPath " ,
2013-07-26 18:40:04 +00:00
" default " : build_obj . bindir if build_obj is not None else None ,
" help " : " absolute path to directory containing utility programs (xpcshell, ssltunnel, certutil) " ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --certificate-path " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " certPath " ,
2013-07-26 18:40:04 +00:00
" help " : " absolute path to directory containing certificate store to use testing profile " ,
" default " : os . path . join ( build_obj . topsrcdir , ' build ' , ' pgo ' , ' certs ' ) if build_obj is not None else None ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --autorun " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-07-26 18:40:04 +00:00
" dest " : " autorun " ,
" help " : " start running tests when the application starts " ,
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --timeout " ] ,
2015-03-24 21:42:24 +00:00
{ " type " : int ,
2013-07-26 18:40:04 +00:00
" dest " : " timeout " ,
" help " : " per-test timeout in seconds " ,
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --total-chunks " ] ,
2015-03-24 21:42:24 +00:00
{ " type " : int ,
2013-07-26 18:40:04 +00:00
" dest " : " totalChunks " ,
" help " : " how many chunks to split the tests up into " ,
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --this-chunk " ] ,
2015-03-24 21:42:24 +00:00
{ " type " : int ,
2013-07-26 18:40:04 +00:00
" dest " : " thisChunk " ,
" help " : " which chunk to run " ,
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2015-03-26 19:21:45 +00:00
[ [ " --chunk-by-runtime " ] ,
{ " action " : " store_true " ,
" dest " : " chunkByRuntime " ,
" help " : " group tests such that each chunk has roughly the same runtime " ,
" default " : False ,
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --chunk-by-dir " ] ,
2015-03-24 21:42:24 +00:00
{ " type " : int ,
2013-07-26 18:40:04 +00:00
" dest " : " chunkByDir " ,
" help " : " group tests together in the same chunk that are in the same top chunkByDir directories " ,
" default " : 0 ,
2015-02-13 19:42:02 +00:00
} ] ,
2014-06-03 15:19:28 +00:00
[ [ " --run-by-dir " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2014-06-03 15:19:28 +00:00
" dest " : " runByDir " ,
" help " : " Run each directory in a single browser instance with a fresh profile " ,
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --shuffle " ] ,
2015-02-13 19:42:02 +00:00
{ " dest " : " shuffle " ,
2013-07-26 18:40:04 +00:00
" action " : " store_true " ,
" help " : " randomize test order " ,
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --console-level " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " consoleLevel " ,
2013-07-26 18:40:04 +00:00
" choices " : LOG_LEVELS ,
" metavar " : " LEVEL " ,
" help " : " one of %s to determine the level of console "
" logging " % LEVEL_STRING ,
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --chrome " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-07-26 18:40:04 +00:00
" dest " : " chrome " ,
" help " : " run chrome Mochitests " ,
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --ipcplugins " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-07-26 18:40:04 +00:00
" dest " : " ipcplugins " ,
" help " : " run ipcplugins Mochitests " ,
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --test-path " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " testPath " ,
2013-07-26 18:40:04 +00:00
" help " : " start in the given directory ' s tests " ,
" default " : " " ,
2015-02-13 19:42:02 +00:00
} ] ,
2014-07-04 11:55:00 +00:00
[ [ " --bisect-chunk " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " bisectChunk " ,
2014-07-04 11:55:00 +00:00
" help " : " Specify the failing test name to find the previous tests that may be causing the failure. " ,
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-10-28 19:24:55 +00:00
[ [ " --start-at " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " startAt " ,
2013-10-28 19:24:55 +00:00
" help " : " skip over tests until reaching the given test " ,
" default " : " " ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-10-28 19:24:55 +00:00
[ [ " --end-at " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " endAt " ,
2013-10-28 19:24:55 +00:00
" help " : " don ' t run any tests after the given one " ,
" default " : " " ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --browser-chrome " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-07-26 18:40:04 +00:00
" dest " : " browserChrome " ,
" help " : " run browser chrome Mochitests " ,
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2014-03-25 16:52:53 +00:00
[ [ " --subsuite " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " subsuite " ,
2014-03-25 16:52:53 +00:00
" help " : " subsuite of tests to run " ,
2015-02-10 14:38:29 +00:00
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2014-09-22 18:08:06 +00:00
[ [ " --jetpack-package " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2014-09-22 18:08:06 +00:00
" dest " : " jetpackPackage " ,
" help " : " run jetpack package tests " ,
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2014-09-22 18:08:06 +00:00
[ [ " --jetpack-addon " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2014-09-22 18:08:06 +00:00
" dest " : " jetpackAddon " ,
" help " : " run jetpack addon tests " ,
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --webapprt-content " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-07-26 18:40:04 +00:00
" dest " : " webapprtContent " ,
" help " : " run WebappRT content tests " ,
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --webapprt-chrome " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-07-26 18:40:04 +00:00
" dest " : " webapprtChrome " ,
" help " : " run WebappRT chrome tests " ,
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --a11y " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-07-26 18:40:04 +00:00
" dest " : " a11y " ,
" help " : " run accessibility Mochitests " ,
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --setenv " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " append " ,
2013-07-26 18:40:04 +00:00
" dest " : " environment " ,
" metavar " : " NAME=VALUE " ,
" help " : " sets the given variable in the application ' s "
2015-02-13 19:42:02 +00:00
" environment " ,
2013-07-26 18:40:04 +00:00
" default " : [ ] ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --exclude-extension " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " append " ,
2013-07-26 18:40:04 +00:00
" dest " : " extensionsToExclude " ,
" help " : " excludes the given extension from being installed "
2015-02-13 19:42:02 +00:00
" in the test profile " ,
2013-07-26 18:40:04 +00:00
" default " : [ ] ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --browser-arg " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " append " ,
2013-07-26 18:40:04 +00:00
" dest " : " browserArgs " ,
" metavar " : " ARG " ,
" help " : " provides an argument to the test application " ,
" default " : [ ] ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --leak-threshold " ] ,
2015-03-24 21:42:24 +00:00
{ " type " : int ,
2014-09-30 16:54:25 +00:00
" dest " : " defaultLeakThreshold " ,
2013-07-26 18:40:04 +00:00
" metavar " : " THRESHOLD " ,
2014-09-30 16:54:25 +00:00
" help " : " fail if the number of bytes leaked in default "
2015-02-13 19:42:02 +00:00
" processes through refcounted objects (or bytes "
" in classes with MOZ_COUNT_CTOR and MOZ_COUNT_DTOR) "
" is greater than the given number " ,
2013-07-26 18:40:04 +00:00
" default " : 0 ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --fatal-assertions " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-07-26 18:40:04 +00:00
" dest " : " fatalAssertions " ,
" help " : " abort testing whenever an assertion is hit "
2015-02-13 19:42:02 +00:00
" (requires a debug build to be effective) " ,
2013-07-26 18:40:04 +00:00
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --extra-profile-file " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " append " ,
2013-07-26 18:40:04 +00:00
" dest " : " extraProfileFiles " ,
" help " : " copy specified files/dirs to testing profile " ,
" default " : [ ] ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --install-extension " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " append " ,
2013-07-26 18:40:04 +00:00
" dest " : " extensionsToInstall " ,
" help " : " install the specified extension in the testing profile. "
2015-02-13 19:42:02 +00:00
" The extension file ' s name should be <id>.xpi where <id> is "
" the extension ' s id as indicated in its install.rdf. "
" An optional path can be specified too. " ,
2013-07-26 18:40:04 +00:00
" default " : [ ] ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --profile-path " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " profilePath " ,
2013-07-26 18:40:04 +00:00
" help " : " Directory where the profile will be stored. "
2015-02-13 19:42:02 +00:00
" This directory will be deleted after the tests are finished " ,
2014-06-17 22:38:13 +00:00
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --testing-modules-dir " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " testingModulesDir " ,
2013-07-26 18:40:04 +00:00
" help " : " Directory where testing-only JS modules are located. " ,
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --use-vmware-recording " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-07-26 18:40:04 +00:00
" dest " : " vmwareRecording " ,
" help " : " enables recording while the application is running "
2015-02-13 19:42:02 +00:00
" inside a VMware Workstation 7.0 or later VM " ,
2013-07-26 18:40:04 +00:00
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --repeat " ] ,
2015-03-24 21:42:24 +00:00
{ " type " : int ,
2013-07-26 18:40:04 +00:00
" dest " : " repeat " ,
" metavar " : " REPEAT " ,
" help " : " repeats the test or set of tests the given number of times, ie: repeat: 1 will run the test twice. " ,
" default " : 0 ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --run-until-failure " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-07-26 18:40:04 +00:00
" dest " : " runUntilFailure " ,
2013-11-05 15:48:36 +00:00
" help " : " Run tests repeatedly and stops on the first time a test fails. "
2015-02-13 19:42:02 +00:00
" Default cap is 30 runs, which can be overwritten with the --repeat parameter. " ,
2013-07-26 18:40:04 +00:00
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-08-02 12:48:06 +00:00
[ [ " --manifest " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " manifestFile " ,
2013-08-02 12:48:06 +00:00
" help " : " .ini format of tests to run. " ,
2013-07-26 18:40:04 +00:00
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2014-12-15 02:18:39 +00:00
[ [ " --testrun-manifest-file " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " testRunManifestFile " ,
2014-12-15 02:18:39 +00:00
" help " : " Overrides the default filename of the tests.json manifest file that is created from the manifest and used by the test runners to run the tests. Only useful when running multiple test runs simulatenously on the same machine. " ,
" default " : ' tests.json ' ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --failure-file " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " failureFile " ,
2013-07-26 18:40:04 +00:00
" help " : " Filename of the output file where we can store a .json list of failures to be run in the future with --run-only-tests. " ,
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --run-slower " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-07-26 18:40:04 +00:00
" dest " : " runSlower " ,
" help " : " Delay execution between test files. " ,
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --metro-immersive " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-07-26 18:40:04 +00:00
" dest " : " immersiveMode " ,
" help " : " launches tests in immersive browser " ,
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --httpd-path " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " httpdPath " ,
2013-07-26 18:40:04 +00:00
" default " : None ,
" help " : " path to the httpd.js file " ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --setpref " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " append " ,
2013-07-26 18:40:04 +00:00
" default " : [ ] ,
" dest " : " extraPrefs " ,
" metavar " : " PREF=VALUE " ,
" help " : " defines an extra user preference " ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-10-21 16:12:12 +00:00
[ [ " --jsdebugger " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-10-21 16:12:12 +00:00
" default " : False ,
" dest " : " jsdebugger " ,
" help " : " open the browser debugger " ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-11-01 19:23:34 +00:00
[ [ " --debug-on-failure " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-11-01 19:23:34 +00:00
" default " : False ,
" dest " : " debugOnFailure " ,
" help " : " breaks execution and enters the JS debugger on a test failure. Should be used together with --jsdebugger. "
2015-02-13 19:42:02 +00:00
} ] ,
2013-11-03 23:07:49 +00:00
[ [ " --e10s " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-11-03 23:07:49 +00:00
" default " : False ,
" dest " : " e10s " ,
" help " : " Run tests with electrolysis preferences and test filtering enabled. " ,
2015-02-13 19:42:02 +00:00
} ] ,
2014-12-10 09:34:03 +00:00
[ [ " --strict-content-sandbox " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2014-12-10 09:34:03 +00:00
" default " : False ,
" dest " : " strictContentSandbox " ,
" help " : " Run tests with a more strict content sandbox (Windows only). " ,
2015-02-13 19:42:02 +00:00
} ] ,
2015-01-13 01:07:00 +00:00
[ [ " --nested_oop " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2015-01-13 01:07:00 +00:00
" default " : False ,
" dest " : " nested_oop " ,
" help " : " Run tests with nested_oop preferences and test filtering enabled. " ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-11-13 19:48:10 +00:00
[ [ " --dmd-path " ] ,
2015-03-24 21:42:24 +00:00
{ " default " : None ,
2015-02-13 19:42:02 +00:00
" dest " : " dmdPath " ,
" help " : " Specifies the path to the directory containing the shared library for DMD. " ,
} ] ,
2013-11-21 16:33:43 +00:00
[ [ " --dump-output-directory " ] ,
2015-03-24 21:42:24 +00:00
{ " default " : None ,
2015-02-13 19:42:02 +00:00
" dest " : " dumpOutputDirectory " ,
" help " : " Specifies the directory in which to place dumped memory reports. " ,
} ] ,
2013-11-21 16:33:43 +00:00
[ [ " --dump-about-memory-after-test " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
" default " : False ,
" dest " : " dumpAboutMemoryAfterTest " ,
" help " : " Produce an about:memory dump after each test in the directory specified "
" by --dump-output-directory. "
} ] ,
2013-11-21 16:33:43 +00:00
[ [ " --dump-dmd-after-test " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
" default " : False ,
" dest " : " dumpDMDAfterTest " ,
" help " : " Produce a DMD dump after each test in the directory specified "
" by --dump-output-directory. "
} ] ,
2014-02-12 15:54:11 +00:00
[ [ " --slowscript " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
" default " : False ,
" dest " : " slowscript " ,
" help " : " Do not set the JS_DISABLE_SLOW_SCRIPT_SIGNALS env variable; "
" when not set, recoverable but misleading SIGSEGV instances "
" may occur in Ion/Odin JIT code. "
} ] ,
2014-04-12 02:23:00 +00:00
[ [ " --screenshot-on-fail " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
" default " : False ,
" dest " : " screenshotOnFail " ,
" help " : " Take screenshots on all test failures. Set $MOZ_UPLOAD_DIR to a directory for storing the screenshots. "
} ] ,
2014-03-07 16:42:07 +00:00
[ [ " --quiet " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
" default " : False ,
" dest " : " quiet " ,
" help " : " Do not print test log lines unless a failure occurs. "
} ] ,
2014-03-14 18:25:41 +00:00
[ [ " --pidfile " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " pidFile " ,
2014-03-14 18:25:41 +00:00
" help " : " name of the pidfile to generate " ,
" default " : " " ,
2015-02-13 19:42:02 +00:00
} ] ,
2014-05-01 11:18:00 +00:00
[ [ " --use-test-media-devices " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2014-05-01 11:18:00 +00:00
" default " : False ,
" dest " : " useTestMediaDevices " ,
" help " : " Use test media device drivers for media testing. " ,
2015-02-13 19:42:02 +00:00
} ] ,
2014-08-22 14:28:04 +00:00
[ [ " --gmp-path " ] ,
2015-03-24 21:42:24 +00:00
{ " default " : None ,
2014-08-22 14:28:04 +00:00
" dest " : " gmp_path " ,
" help " : " Path to fake GMP plugin. Will be deduced from the binary if not passed. " ,
2015-02-13 19:42:02 +00:00
} ] ,
2014-11-19 20:31:45 +00:00
[ [ " --xre-path " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " xrePath " ,
2014-11-19 20:31:45 +00:00
" default " : None , # individual scripts will set a sane default
" help " : " absolute path to directory containing XRE (probably xulrunner) " ,
2015-02-13 19:42:02 +00:00
} ] ,
2014-11-19 20:31:45 +00:00
[ [ " --symbols-path " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " symbolsPath " ,
2014-11-19 20:31:45 +00:00
" default " : None ,
" help " : " absolute path to directory containing breakpad symbols, or the URL of a zip file containing symbols " ,
2015-02-13 19:42:02 +00:00
} ] ,
2014-11-19 20:31:45 +00:00
[ [ " --debugger " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " debugger " ,
2014-11-19 20:31:45 +00:00
" help " : " use the given debugger to launch the application " ,
2015-02-13 19:42:02 +00:00
} ] ,
2014-11-19 20:31:45 +00:00
[ [ " --debugger-args " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " debuggerArgs " ,
2014-11-19 20:31:45 +00:00
" help " : " pass the given args to the debugger _before_ the application on the command line " ,
2015-02-13 19:42:02 +00:00
} ] ,
2014-11-19 20:31:45 +00:00
[ [ " --debugger-interactive " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2014-11-19 20:31:45 +00:00
" dest " : " debuggerInteractive " ,
" help " : " prevents the test harness from redirecting stdout and stderr for interactive debuggers " ,
2015-02-13 19:42:02 +00:00
} ] ,
2015-02-25 14:23:54 +00:00
[ [ " --max-timeouts " ] ,
2015-03-24 21:42:24 +00:00
{ " type " : int ,
" dest " : " maxTimeouts " ,
" help " : " maximum number of timeouts permitted before halting testing " ,
" default " : None ,
} ] ,
2015-03-19 20:15:33 +00:00
[ [ " --tag " ] ,
2015-03-24 21:42:24 +00:00
{ " action " : " append " ,
" dest " : " test_tags " ,
" default " : None ,
" help " : " filter out tests that don ' t have the given tag. Can be "
" used multiple times in which case the test must contain "
" at least one of the given tags. " ,
} ] ,
2015-04-10 17:45:22 +00:00
[ [ " --enable-cpow-warnings " ] ,
{ " action " : " store_true " ,
" dest " : " enableCPOWWarnings " ,
" help " : " enable logging of unsafe CPOW usage, which is disabled by default for tests " ,
} ] ,
2013-07-26 18:40:04 +00:00
]
2013-09-23 14:47:48 +00:00
def __init__ ( self , * * kwargs ) :
2015-03-24 21:42:24 +00:00
ArgumentParser . __init__ ( self , usage = self . __doc__ , * * kwargs )
2013-09-23 14:47:48 +00:00
for option , value in self . mochitest_options :
2014-06-17 22:38:13 +00:00
# Allocate new lists so references to original don't get mutated.
# allowing multiple uses within a single process.
if " default " in value and isinstance ( value [ " default " ] , list ) :
value [ " default " ] = [ ]
2015-03-24 21:42:24 +00:00
self . add_argument ( * option , * * value )
2013-07-26 18:40:04 +00:00
def verifyOptions ( self , options , mochitest ) :
""" verify correct options and cleanup paths """
2015-02-13 19:42:02 +00:00
# for test manifest parsing.
mozinfo . update ( { " strictContentSandbox " : options . strictContentSandbox } )
# for test manifest parsing.
mozinfo . update ( { " nested_oop " : options . nested_oop } )
2014-03-18 15:03:51 +00:00
2013-07-31 20:45:54 +00:00
if options . app is None :
if build_obj is not None :
options . app = build_obj . get_binary_path ( )
else :
2015-02-13 19:42:02 +00:00
self . error (
" could not find the application path, --appname must be specified " )
2013-07-31 20:45:54 +00:00
2013-07-26 18:40:04 +00:00
if options . totalChunks is not None and options . thisChunk is None :
2015-02-13 19:42:02 +00:00
self . error (
" thisChunk must be specified when totalChunks is specified " )
2013-07-26 18:40:04 +00:00
if options . totalChunks :
if not 1 < = options . thisChunk < = options . totalChunks :
self . error ( " thisChunk must be between 1 and totalChunks " )
2015-03-26 19:21:45 +00:00
if options . chunkByDir and options . chunkByRuntime :
self . error (
" can only use one of --chunk-by-dir or --chunk-by-runtime " )
2013-07-26 18:40:04 +00:00
if options . xrePath is None :
# default xrePath to the app path if not provided
# but only if an app path was explicitly provided
2015-03-24 21:42:24 +00:00
if options . app != self . get_default ( ' app ' ) :
2013-07-26 18:40:04 +00:00
options . xrePath = os . path . dirname ( options . app )
2014-09-29 18:51:25 +00:00
if mozinfo . isMac :
2015-02-13 19:42:02 +00:00
options . xrePath = os . path . join (
os . path . dirname (
options . xrePath ) ,
" Resources " )
2013-07-26 18:40:04 +00:00
elif build_obj is not None :
# otherwise default to dist/bin
options . xrePath = build_obj . bindir
else :
2015-02-13 19:42:02 +00:00
self . error (
" could not find xre directory, --xre-path must be specified " )
2013-07-26 18:40:04 +00:00
# allow relative paths
options . xrePath = mochitest . getFullPath ( options . xrePath )
2014-06-23 09:24:00 +00:00
if options . profilePath :
options . profilePath = mochitest . getFullPath ( options . profilePath )
2013-07-26 18:40:04 +00:00
options . app = mochitest . getFullPath ( options . app )
2013-11-13 19:48:10 +00:00
if options . dmdPath is not None :
options . dmdPath = mochitest . getFullPath ( options . dmdPath )
2013-07-26 18:40:04 +00:00
if not os . path . exists ( options . app ) :
msg = """ \
Error : Path % ( app ) s doesn ' t exist.
Are you executing $ objdir / _tests / testing / mochitest / runtests . py ? """
self . error ( msg % { " app " : options . app } )
return None
if options . utilityPath :
options . utilityPath = mochitest . getFullPath ( options . utilityPath )
if options . certPath :
options . certPath = mochitest . getFullPath ( options . certPath )
2015-02-13 19:42:02 +00:00
if options . symbolsPath and len (
urlparse (
options . symbolsPath ) . scheme ) < 2 :
2013-07-26 18:40:04 +00:00
options . symbolsPath = mochitest . getFullPath ( options . symbolsPath )
2013-09-23 14:47:48 +00:00
# Set server information on the options object
options . webServer = ' 127.0.0.1 '
options . httpPort = DEFAULT_PORTS [ ' http ' ]
options . sslPort = DEFAULT_PORTS [ ' https ' ]
# options.webSocketPort = DEFAULT_PORTS['ws']
2015-02-13 19:42:02 +00:00
# <- http://hg.mozilla.org/mozilla-central/file/b871dfb2186f/build/automation.py.in#l30
options . webSocketPort = str ( 9988 )
2013-09-23 14:47:48 +00:00
# The default websocket port is incorrect in mozprofile; it is
# set to the SSL proxy setting. See:
# see https://bugzilla.mozilla.org/show_bug.cgi?id=916517
2013-07-26 18:40:04 +00:00
if options . vmwareRecording :
2013-09-23 14:47:48 +00:00
if not mozinfo . isWin :
2015-02-13 19:42:02 +00:00
self . error (
" use-vmware-recording is only supported on Windows. " )
2013-07-26 18:40:04 +00:00
mochitest . vmwareHelperPath = os . path . join (
options . utilityPath , VMWARE_RECORDING_HELPER_BASENAME + " .dll " )
if not os . path . exists ( mochitest . vmwareHelperPath ) :
self . error ( " %s not found, cannot automate VMware recording. " %
mochitest . vmwareHelperPath )
if options . webapprtContent and options . webapprtChrome :
2015-02-13 19:42:02 +00:00
self . error (
" Only one of --webapprt-content and --webapprt-chrome may be given. " )
2013-07-26 18:40:04 +00:00
2013-10-21 16:12:12 +00:00
if options . jsdebugger :
options . extraPrefs + = [
" devtools.debugger.remote-enabled=true " ,
" devtools.chrome.enabled=true " ,
" devtools.debugger.prompt-connection=false "
]
options . autorun = False
2013-11-01 19:23:34 +00:00
if options . debugOnFailure and not options . jsdebugger :
2015-02-13 19:42:02 +00:00
self . error (
" --debug-on-failure should be used together with --jsdebugger. " )
2013-11-01 19:23:34 +00:00
2013-07-26 18:40:04 +00:00
# Try to guess the testing modules directory.
# This somewhat grotesque hack allows the buildbot machines to find the
# modules directory without having to configure the buildbot hosts. This
# code should never be executed in local runs because the build system
# should always set the flag that populates this variable. If buildbot ever
# passes this argument, this code can be deleted.
if options . testingModulesDir is None :
2014-04-16 14:29:39 +00:00
possible = os . path . join ( here , os . path . pardir , ' modules ' )
2013-07-26 18:40:04 +00:00
if os . path . isdir ( possible ) :
options . testingModulesDir = possible
# Even if buildbot is updated, we still want this, as the path we pass in
# to the app must be absolute and have proper slashes.
if options . testingModulesDir is not None :
2015-02-13 19:42:02 +00:00
options . testingModulesDir = os . path . normpath (
options . testingModulesDir )
2013-07-26 18:40:04 +00:00
if not os . path . isabs ( options . testingModulesDir ) :
2015-02-13 19:42:02 +00:00
options . testingModulesDir = os . path . abspath (
options . testingModulesDir )
2013-07-26 18:40:04 +00:00
if not os . path . isdir ( options . testingModulesDir ) :
self . error ( ' --testing-modules-dir not a directory: %s ' %
2015-02-13 19:42:02 +00:00
options . testingModulesDir )
2013-07-26 18:40:04 +00:00
2015-02-13 19:42:02 +00:00
options . testingModulesDir = options . testingModulesDir . replace (
' \\ ' ,
' / ' )
2013-07-26 18:40:04 +00:00
if options . testingModulesDir [ - 1 ] != ' / ' :
options . testingModulesDir + = ' / '
if options . immersiveMode :
2013-09-23 14:47:48 +00:00
if not mozinfo . isWin :
2013-07-26 18:40:04 +00:00
self . error ( " immersive is only supported on Windows 8 and up. " )
mochitest . immersiveHelperPath = os . path . join (
options . utilityPath , " metrotestharness.exe " )
if not os . path . exists ( mochitest . immersiveHelperPath ) :
self . error ( " %s not found, cannot launch immersive tests. " %
mochitest . immersiveHelperPath )
if options . runUntilFailure :
if not options . repeat :
options . repeat = 29
2013-08-02 12:48:06 +00:00
2013-11-21 16:33:43 +00:00
if options . dumpOutputDirectory is None :
options . dumpOutputDirectory = tempfile . gettempdir ( )
if options . dumpAboutMemoryAfterTest or options . dumpDMDAfterTest :
if not os . path . isdir ( options . dumpOutputDirectory ) :
self . error ( ' --dump-output-directory not a directory: %s ' %
options . dumpOutputDirectory )
2014-05-01 11:18:00 +00:00
if options . useTestMediaDevices :
if not mozinfo . isLinux :
2015-02-13 19:42:02 +00:00
self . error (
' --use-test-media-devices is only supported on Linux currently ' )
2014-05-01 11:18:00 +00:00
for f in [ ' /usr/bin/gst-launch-0.10 ' , ' /usr/bin/pactl ' ] :
if not os . path . isfile ( f ) :
2015-02-13 19:42:02 +00:00
self . error (
2015-03-05 01:54:08 +00:00
' Missing binary %s required for '
' --use-test-media-devices ' % f )
2014-05-01 11:18:00 +00:00
2015-01-13 01:07:00 +00:00
if options . nested_oop :
2015-02-13 19:42:02 +00:00
if not options . e10s :
options . e10s = True
2015-04-09 00:03:00 +00:00
mozinfo . update ( { " e10s " : options . e10s } ) # for test manifest parsing.
2015-01-13 01:07:00 +00:00
2014-09-30 16:54:25 +00:00
options . leakThresholds = {
" default " : options . defaultLeakThreshold ,
2015-02-13 19:42:02 +00:00
" tab " : 25000 , # See dependencies of bug 1051230.
# GMP rarely gets a log, but when it does, it leaks a little.
" geckomediaplugin " : 20000 ,
2014-09-30 16:54:25 +00:00
}
2015-02-13 19:42:02 +00:00
# Bug 1065098 - The geckomediaplugin process fails to produce a leak
# log for some reason.
2015-01-13 20:32:35 +00:00
options . ignoreMissingLeaks = [ " geckomediaplugin " ]
2014-09-30 21:17:27 +00:00
2015-02-13 19:42:02 +00:00
# Bug 1091917 - We exit early in tab processes on Windows, so we don't
# get leak logs yet.
2015-01-13 20:32:35 +00:00
if mozinfo . isWin :
options . ignoreMissingLeaks . append ( " tab " )
2015-01-14 18:06:46 +00:00
# Bug 1121539 - OSX-only intermittent tab process leak in test_ipc.html
if mozinfo . isMac :
2015-01-16 17:30:43 +00:00
options . leakThresholds [ " tab " ] = 100000
2015-01-14 18:06:46 +00:00
2013-07-26 18:40:04 +00:00
return options
class B2GOptions ( MochitestOptions ) :
b2g_options = [
[ [ " --b2gpath " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " b2gPath " ,
2013-07-26 18:40:04 +00:00
" help " : " path to B2G repo or qemu dir " ,
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --desktop " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-07-26 18:40:04 +00:00
" dest " : " desktop " ,
" help " : " Run the tests on a B2G desktop build " ,
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --marionette " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " marionette " ,
2013-07-26 18:40:04 +00:00
" help " : " host:port to use when connecting to Marionette " ,
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --emulator " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " emulator " ,
2013-07-26 18:40:04 +00:00
" help " : " Architecture of emulator to use: x86 or arm " ,
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2014-01-31 18:22:51 +00:00
[ [ " --wifi " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " wifi " ,
2014-01-31 18:22:51 +00:00
" help " : " Devine wifi configuration for on device mochitest " ,
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --sdcard " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " sdcard " ,
2013-07-26 18:40:04 +00:00
" help " : " Define size of sdcard: 1MB, 50MB...etc " ,
" default " : " 10MB " ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --no-window " ] ,
2015-02-13 19:42:02 +00:00
{ " action " : " store_true " ,
2013-07-26 18:40:04 +00:00
" dest " : " noWindow " ,
" help " : " Pass --no-window to the emulator " ,
" default " : False ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --adbpath " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " adbPath " ,
2013-07-26 18:40:04 +00:00
" help " : " path to adb " ,
" default " : " adb " ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --deviceIP " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " deviceIP " ,
2013-07-26 18:40:04 +00:00
" help " : " ip address of remote device to test " ,
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --devicePort " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " devicePort " ,
2013-07-26 18:40:04 +00:00
" help " : " port of remote device to test " ,
" default " : 20701 ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --remote-logfile " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " remoteLogFile " ,
2013-07-26 18:40:04 +00:00
" help " : " Name of log file on the device relative to the device root. \
PLEASE ONLY USE A FILENAME . " ,
2015-02-13 19:42:02 +00:00
" default " : None ,
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --remote-webserver " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " remoteWebServer " ,
2013-07-26 18:40:04 +00:00
" help " : " ip address where the remote web server is hosted at " ,
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --http-port " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " httpPort " ,
2013-07-26 18:40:04 +00:00
" help " : " ip address where the remote web server is hosted at " ,
2015-03-24 21:42:24 +00:00
" default " : DEFAULT_PORTS [ ' http ' ] ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --ssl-port " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " sslPort " ,
2013-07-26 18:40:04 +00:00
" help " : " ip address where the remote web server is hosted at " ,
2015-03-24 21:42:24 +00:00
" default " : DEFAULT_PORTS [ ' https ' ] ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --gecko-path " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " geckoPath " ,
2013-07-26 18:40:04 +00:00
" help " : " the path to a gecko distribution that should \
be installed on the emulator prior to test " ,
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ " --profile " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " profile " ,
2013-07-26 18:40:04 +00:00
" help " : " for desktop testing, the path to the \
gaia profile to use " ,
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2014-06-19 18:17:26 +00:00
[ [ " --logdir " ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : " logdir " ,
2014-06-19 18:17:26 +00:00
" help " : " directory to store log files " ,
2013-07-26 18:40:04 +00:00
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ ' --busybox ' ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : ' busybox ' ,
2013-07-26 18:40:04 +00:00
" help " : " Path to busybox binary to install on device " ,
" default " : None ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
[ [ ' --profile-data-dir ' ] ,
2015-03-24 21:42:24 +00:00
{ " dest " : ' profile_data_dir ' ,
2013-07-26 18:40:04 +00:00
" help " : " Path to a directory containing preference and other \
data to be installed into the profile " ,
" default " : os . path . join ( here , ' profile_data ' ) ,
2015-02-13 19:42:02 +00:00
} ] ,
2013-07-26 18:40:04 +00:00
]
def __init__ ( self ) :
MochitestOptions . __init__ ( self )
for option in self . b2g_options :
2015-03-24 21:42:24 +00:00
self . add_argument ( * option [ 0 ] , * * option [ 1 ] )
2013-07-26 18:40:04 +00:00
defaults = { }
defaults [ " logFile " ] = " mochitest.log "
defaults [ " autorun " ] = True
defaults [ " closeWhenDone " ] = True
defaults [ " extensionsToExclude " ] = [ " specialpowers " ]
2014-08-05 21:11:53 +00:00
# See dependencies of bug 1038943.
2015-02-27 06:31:00 +00:00
defaults [ " defaultLeakThreshold " ] = 5536
2013-07-26 18:40:04 +00:00
self . set_defaults ( * * defaults )
def verifyRemoteOptions ( self , options ) :
2015-02-13 19:42:02 +00:00
if options . remoteWebServer is None :
2013-07-26 18:40:04 +00:00
if os . name != " nt " :
options . remoteWebServer = moznetwork . get_ip ( )
else :
2015-02-13 19:42:02 +00:00
self . error (
" You must specify a --remote-webserver=<ip address> " )
2013-07-26 18:40:04 +00:00
options . webServer = options . remoteWebServer
if options . geckoPath and not options . emulator :
2015-02-13 19:42:02 +00:00
self . error (
" You must specify --emulator if you specify --gecko-path " )
2013-07-26 18:40:04 +00:00
2014-06-19 18:17:26 +00:00
if options . logdir and not options . emulator :
self . error ( " You must specify --emulator if you specify --logdir " )
2013-07-26 18:40:04 +00:00
if not os . path . isdir ( options . xrePath ) :
self . error ( " --xre-path ' %s ' is not a directory " % options . xrePath )
xpcshell = os . path . join ( options . xrePath , ' xpcshell ' )
if not os . access ( xpcshell , os . F_OK ) :
self . error ( ' xpcshell not found at %s ' % xpcshell )
if self . elf_arm ( xpcshell ) :
self . error ( ' --xre-path points to an ARM version of xpcshell; it '
' should instead point to a version that can run on '
' your desktop ' )
if options . pidFile != " " :
f = open ( options . pidFile , ' w ' )
f . write ( " %s " % os . getpid ( ) )
f . close ( )
return options
def verifyOptions ( self , options , mochitest ) :
# since we are reusing verifyOptions, it will exit if App is not found
temp = options . app
2013-08-26 21:17:51 +00:00
options . app = __file__
2013-07-26 18:40:04 +00:00
tempPort = options . httpPort
tempSSL = options . sslPort
tempIP = options . webServer
options = MochitestOptions . verifyOptions ( self , options , mochitest )
options . webServer = tempIP
options . app = temp
options . sslPort = tempSSL
options . httpPort = tempPort
2014-09-30 21:17:27 +00:00
# Bug 1071866 - B2G Mochitests do not always produce a leak log.
options . ignoreMissingLeaks . append ( " default " )
# Bug 1070068 - Leak logging does not work for tab processes on B2G.
2015-01-13 20:32:35 +00:00
options . ignoreMissingLeaks . append ( " tab " )
2014-09-30 21:17:27 +00:00
2013-07-26 18:40:04 +00:00
return options
def elf_arm ( self , filename ) :
data = open ( filename , ' rb ' ) . read ( 20 )
2015-02-13 19:42:02 +00:00
return data [ : 4 ] == " \x7f ELF " and ord ( data [ 18 ] ) == 40 # EM_ARM
2015-03-24 21:42:24 +00:00
class RemoteOptions ( MochitestOptions ) :
remote_options = [
[ [ " --remote-app-path " ] ,
{ " dest " : " remoteAppPath " ,
" help " : " Path to remote executable relative to device root using \
only forward slashes . Either this or app must be specified \
but not both . " ,
" default " : None ,
} ] ,
[ [ " --deviceIP " ] ,
{ " dest " : " deviceIP " ,
" help " : " ip address of remote device to test " ,
" default " : None ,
} ] ,
[ [ " --deviceSerial " ] ,
{ " dest " : " deviceSerial " ,
" help " : " ip address of remote device to test " ,
" default " : None ,
} ] ,
[ [ " --dm_trans " ] ,
{ " dest " : " dm_trans " ,
" default " : " sut " ,
" help " : " the transport to use to communicate with device: \
[ adb | sut ] ; default = sut " ,
} ] ,
[ [ " --devicePort " ] ,
{ " dest " : " devicePort " ,
" type " : int ,
" default " : 20701 ,
" help " : " port of remote device to test " ,
} ] ,
[ [ " --remote-product-name " ] ,
{ " dest " : " remoteProductName " ,
" default " : " fennec " ,
" help " : " The executable ' s name of remote product to test - either \
fennec or firefox , defaults to fennec " ,
} ] ,
[ [ " --remote-logfile " ] ,
{ " dest " : " remoteLogFile " ,
" default " : None ,
" help " : " Name of log file on the device relative to the device \
root . PLEASE ONLY USE A FILENAME . " ,
} ] ,
[ [ " --remote-webserver " ] ,
{ " dest " : " remoteWebServer " ,
" default " : None ,
" help " : " ip address where the remote web server is hosted at " ,
} ] ,
[ [ " --http-port " ] ,
{ " dest " : " httpPort " ,
" default " : DEFAULT_PORTS [ ' http ' ] ,
" help " : " http port of the remote web server " ,
} ] ,
[ [ " --ssl-port " ] ,
{ " dest " : " sslPort " ,
" default " : DEFAULT_PORTS [ ' https ' ] ,
" help " : " ssl port of the remote web server " ,
} ] ,
[ [ " --robocop-ini " ] ,
{ " dest " : " robocopIni " ,
" default " : " " ,
" help " : " name of the .ini file containing the list of tests to run " ,
} ] ,
[ [ " --robocop " ] ,
{ " dest " : " robocop " ,
" default " : " " ,
" help " : " name of the .ini file containing the list of tests to run. \
[ DEPRECATED - please use - - robocop - ini " ,
} ] ,
[ [ " --robocop-apk " ] ,
{ " dest " : " robocopApk " ,
" default " : " " ,
" help " : " name of the Robocop APK to use for ADB test running " ,
} ] ,
[ [ " --robocop-path " ] ,
{ " dest " : " robocopPath " ,
" default " : " " ,
" help " : " Path to the folder where robocop.apk is located at. \
Primarily used for ADB test running . \
[ DEPRECATED - please use - - robocop - apk ] " ,
} ] ,
[ [ " --robocop-ids " ] ,
{ " dest " : " robocopIds " ,
" default " : " " ,
" help " : " name of the file containing the view ID map \
( fennec_ids . txt ) " ,
} ] ,
[ [ " --remoteTestRoot " ] ,
{ " dest " : " remoteTestRoot " ,
" default " : None ,
" help " : " remote directory to use as test root \
( eg . / mnt / sdcard / tests or / data / local / tests ) " ,
} ] ,
]
def __init__ ( self , automation , * * kwargs ) :
self . _automation = automation or Automation ( )
MochitestOptions . __init__ ( self )
for option in self . remote_options :
self . add_argument ( * option [ 0 ] , * * option [ 1 ] )
defaults = { }
defaults [ " logFile " ] = " mochitest.log "
defaults [ " autorun " ] = True
defaults [ " closeWhenDone " ] = True
defaults [ " utilityPath " ] = None
self . set_defaults ( * * defaults )
def verifyRemoteOptions ( self , options , automation ) :
options_logger = logging . getLogger ( ' MochitestRemote ' )
if not options . remoteTestRoot :
options . remoteTestRoot = automation . _devicemanager . deviceRoot
if options . remoteWebServer is None :
if os . name != " nt " :
options . remoteWebServer = moznetwork . get_ip ( )
else :
options_logger . error (
" you must specify a --remote-webserver=<ip address> " )
return None
options . webServer = options . remoteWebServer
if ( options . dm_trans == ' sut ' and options . deviceIP is None ) :
options_logger . error (
" If --dm_trans = sut, you must provide a device IP " )
return None
if ( options . remoteLogFile is None ) :
options . remoteLogFile = options . remoteTestRoot + \
' /logs/mochitest.log '
if ( options . remoteLogFile . count ( ' / ' ) < 1 ) :
options . remoteLogFile = options . remoteTestRoot + \
' / ' + options . remoteLogFile
if ( options . remoteAppPath and options . app ) :
options_logger . error (
" You cannot specify both the remoteAppPath and the app setting " )
return None
elif ( options . remoteAppPath ) :
options . app = options . remoteTestRoot + " / " + options . remoteAppPath
elif ( options . app is None ) :
# Neither remoteAppPath nor app are set -- error
options_logger . error ( " You must specify either appPath or app " )
return None
# Only reset the xrePath if it wasn't provided
if ( options . xrePath is None ) :
options . xrePath = options . utilityPath
if ( options . pidFile != " " ) :
f = open ( options . pidFile , ' w ' )
f . write ( " %s " % os . getpid ( ) )
f . close ( )
# Robocop specific deprecated options.
if options . robocop :
if options . robocopIni :
options_logger . error (
" can not use deprecated --robocop and replacement --robocop-ini together " )
return None
options . robocopIni = options . robocop
del options . robocop
if options . robocopPath :
if options . robocopApk :
options_logger . error (
" can not use deprecated --robocop-path and replacement --robocop-apk together " )
return None
options . robocopApk = os . path . join (
options . robocopPath ,
' robocop.apk ' )
del options . robocopPath
# Robocop specific options
if options . robocopIni != " " :
if not os . path . exists ( options . robocopIni ) :
options_logger . error (
" Unable to find specified robocop .ini manifest ' %s ' " %
options . robocopIni )
return None
options . robocopIni = os . path . abspath ( options . robocopIni )
if options . robocopApk != " " :
if not os . path . exists ( options . robocopApk ) :
options_logger . error (
" Unable to find robocop APK ' %s ' " %
options . robocopApk )
return None
options . robocopApk = os . path . abspath ( options . robocopApk )
if options . robocopIds != " " :
if not os . path . exists ( options . robocopIds ) :
options_logger . error (
" Unable to find specified robocop IDs file ' %s ' " %
options . robocopIds )
return None
options . robocopIds = os . path . abspath ( options . robocopIds )
# allow us to keep original application around for cleanup while
# running robocop via 'am'
options . remoteappname = options . app
return options
def verifyOptions ( self , options , mochitest ) :
# since we are reusing verifyOptions, it will exit if App is not found
temp = options . app
options . app = __file__
tempPort = options . httpPort
tempSSL = options . sslPort
tempIP = options . webServer
# We are going to override this option later anyway, just pretend
# like it's not set for verification purposes.
options . dumpOutputDirectory = None
options = MochitestOptions . verifyOptions ( self , options , mochitest )
options . webServer = tempIP
options . app = temp
options . sslPort = tempSSL
options . httpPort = tempPort
return options