diff --git a/testing/luciddream/README.md b/testing/luciddream/README.md deleted file mode 100644 index f9aeab079fd8..000000000000 --- a/testing/luciddream/README.md +++ /dev/null @@ -1,59 +0,0 @@ -Luciddream is a test harness for running tests between a Firefox browser and another device, such as a Firefox OS emulator. - -The primary goal of the project is to be able to test the Firefox Developer Tools' [remote debugging feature](https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging), where the developer tools can be used to debug web content running in another browser or device. Mozilla currently doesn't have any automated testing of this feature, so getting some automated tests running is a high priority. - -The first planned milestone (for Q4 2014) is to stand up a prototype of a harness, in the process figuring out what the harness will look like and what tests will look like. This work is tracked in [bug 1064253](https://bugzilla.mozilla.org/show_bug.cgi?id=1064253) and is nearing completion. The current harness is based on the [Marionette Test Runner](https://developer.mozilla.org/en-US/docs/Marionette_Test_Runner), and tests right now are a subclass of [Marionette Python tests](https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/Marionette_Python_Tests). - -The second planned milestone (for Q1 2015) is to get the harness running in Mozilla's continuous integration environment. Whether this will be in the legacy Buildbot environment or the new TaskCluster environment is yet to be determined. The bare minimum for this milestone will be having the tests run per-checkin against a Firefox Linux desktop build and a Firefox OS emulator both built from the same changeset. A stretch goal for this milestone will be to get tests running against a Firefox Linux desktop build per-checkin paired with stable release builds of the Firefox OS emulator, to be able to test backwards-compatibility of remote debugging. It's likely that as part of this work the repository of record will move from GitHub to mozilla-central, and the harness may be renamed from the current codename to a more descriptive (but less fun) name. - -Future directions will likely include testing Firefox desktop remote debugging against other platforms, such as Firefox for Android, desktop Chrome, Chrome for Android, and Safari on iOS. - -Points of Contact -================= - -The primary developer of this project is Ted Mielczarek (@luser), ted on irc.mozilla.org, :ted in bugzilla.mozilla.org. - -The primary DevTools point of contact is Alexandre Poirot (@ochameau), ochameau on irc.mozilla.org, :ochameau in bugzilla.mozilla.org. - -Installation and Configuration -============================== - -Currently running Luciddream is only supported on Linux, as the Firefox OS emulator is only well-supported there. - -Install this module and its Python prerequisites in a virtualenv: -``` - virtualenv ./ve - . ./ve/bin/activate - python setup.py develop -``` - -[Download a Firefox build](http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-mozilla-central/) (if you don't already have one). - - -Download one of: -* [A Firefox OS emulator build](http://pvtbuilds.pvt.build.mozilla.org/pub/mozilla.org/b2g/tinderbox-builds/mozilla-central-emulator/) (if you don't already have one, this link requires Mozilla VPN access). -* [A B2G desktop build](http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/latest-mozilla-central/) - - -Unzip both your Firefox and your Firefox OS emulator/B2G desktop somewhere. - -If you're on a 64-bit Ubuntu, you may need to do some fiddling to ensure you have the 32-bit OpenGL libraries available. See the "Solution : have both 32bit and 64bit OpenGL libs installed, with the right symlinks" section [in this blog post](http://rishav006.wordpress.com/2014/05/19/how-to-build-b2g-emulator-in-linux-environment/). - - -Running Tests -============= - -To run with a Firefox OS emulator: -``` -runluciddream --b2gpath /path/to/b2g-distro/ --browser-path /path/to/firefox/firefox example-tests/luciddream.ini -``` - -To run with B2G desktop: -``` -runluciddream --b2g-desktop-path /path/to/b2g/b2g --browser-path /path/to/firefox/firefox example-tests/luciddream.ini -``` - -If you're using a locally-built B2G desktop build which doesn't have a Gaia profile included you should get Gaia and build a profile, and then pass that in with the `--gaia-profile` option: -``` -runluciddream --b2g-desktop-path /path/to/obj-b2g/dist/bin/b2g --gaia-profile /path/to/gaia/profile --browser-path /path/to/firefox/firefox example-tests/luciddream.ini -``` diff --git a/testing/luciddream/example-tests/luciddream.ini b/testing/luciddream/example-tests/luciddream.ini deleted file mode 100644 index 824123e25abe..000000000000 --- a/testing/luciddream/example-tests/luciddream.ini +++ /dev/null @@ -1 +0,0 @@ -[test_sample.py] diff --git a/testing/luciddream/example-tests/test.js b/testing/luciddream/example-tests/test.js deleted file mode 100644 index 6d83e76ec9a0..000000000000 --- a/testing/luciddream/example-tests/test.js +++ /dev/null @@ -1,6 +0,0 @@ -ok(true, "Assertion from a JS script!"); -//ok(false, "test failure"); -setTimeout(function() { - ok(true, "Assertion from setTimeout!"); - finish(); -}, 15); diff --git a/testing/luciddream/example-tests/test_sample.py b/testing/luciddream/example-tests/test_sample.py deleted file mode 100644 index 6e7df1c5265f..000000000000 --- a/testing/luciddream/example-tests/test_sample.py +++ /dev/null @@ -1,15 +0,0 @@ -# Any copyright is dedicated to the Public Domain. -# http://creativecommons.org/publicdomain/zero/1.0/ - -from luciddream import LucidDreamTestCase - -class TestSample(LucidDreamTestCase): - def test_sample(self): - #TODO: make this better - self.assertIsNotNone(self.marionette.session) - self.assertIsNotNone(self.browser.session) - - def test_js(self): - 'Test that we can run a JavaScript test in both Marionette instances' - self.run_js_test('test.js', self.marionette) - self.run_js_test('test.js', self.browser) diff --git a/testing/luciddream/luciddream/__init__.py b/testing/luciddream/luciddream/__init__.py deleted file mode 100644 index 54128e68b64d..000000000000 --- a/testing/luciddream/luciddream/__init__.py +++ /dev/null @@ -1,111 +0,0 @@ -# -# 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/. -# - -import os -import sys -from marionette.marionette_test import MarionetteTestCase, MarionetteJSTestCase -from marionette_driver.errors import ScriptTimeoutException - -class LucidDreamTestCase(MarionetteTestCase): - def __init__(self, marionette_weakref, browser=None, logger=None, **kwargs): - self.browser = browser - self.logger = logger - MarionetteTestCase.__init__(self, marionette_weakref, **kwargs) - - def run_js_test(self, filename, marionette): - ''' - Run a JavaScript test file and collect its set of assertions - into the current test's results. - - :param filename: The path to the JavaScript test file to execute. - May be relative to the current script. - :param marionette: The Marionette object in which to execute the test. - ''' - caller_file = sys._getframe(1).f_globals.get('__file__', '') - caller_file = os.path.abspath(caller_file) - script = os.path.join(os.path.dirname(caller_file), filename) - self.assert_(os.path.exists(script), 'Script "%s" must exist' % script) - if hasattr(MarionetteTestCase, 'run_js_test'): - return MarionetteTestCase.run_js_test(self, script, marionette) - #XXX: copy/pasted from marionette_test.py, refactor this! - f = open(script, 'r') - js = f.read() - args = [] - - head_js = MarionetteJSTestCase.head_js_re.search(js); - if head_js: - head_js = head_js.group(3) - head = open(os.path.join(os.path.dirname(script), head_js), 'r') - js = head.read() + js; - - context = MarionetteJSTestCase.context_re.search(js) - if context: - context = context.group(3) - else: - context = 'content' - marionette.set_context(context) - - if context != "chrome": - marionette.navigate('data:text/html,test page') - - timeout = MarionetteJSTestCase.timeout_re.search(js) - if timeout: - timeout = timeout.group(3) - marionette.set_script_timeout(timeout) - - inactivity_timeout = MarionetteJSTestCase.inactivity_timeout_re.search(js) - if inactivity_timeout: - inactivity_timeout = inactivity_timeout.group(3) - - try: - results = marionette.execute_js_script(js, - args, - special_powers=True, - inactivity_timeout=inactivity_timeout, - filename=os.path.basename(script)) - - self.assertTrue(not 'timeout' in script, - 'expected timeout not triggered') - - if 'fail' in script: - self.assertTrue(len(results['failures']) > 0, - "expected test failures didn't occur") - else: - for failure in results['failures']: - diag = "" if failure.get('diag') is None else failure['diag'] - name = "got false, expected true" if failure.get('name') is None else failure['name'] - self.logger.test_status(self.test_name, name, 'FAIL', - message=diag) - for failure in results['expectedFailures']: - diag = "" if failure.get('diag') is None else failure['diag'] - name = "got false, expected false" if failure.get('name') is None else failure['name'] - self.logger.test_status(self.test_name, name, 'FAIL', - expected='FAIL', message=diag) - for failure in results['unexpectedSuccesses']: - diag = "" if failure.get('diag') is None else failure['diag'] - name = "got true, expected false" if failure.get('name') is None else failure['name'] - self.logger.test_status(self.test_name, name, 'PASS', - expected='FAIL', message=diag) - self.assertEqual(0, len(results['failures']), - '%d tests failed' % len(results['failures'])) - if len(results['unexpectedSuccesses']) > 0: - raise _UnexpectedSuccess('') - if len(results['expectedFailures']) > 0: - raise _ExpectedFailure((AssertionError, AssertionError(''), None)) - - self.assertTrue(results['passed'] - + len(results['failures']) - + len(results['expectedFailures']) - + len(results['unexpectedSuccesses']) > 0, - 'no tests run') - - except ScriptTimeoutException: - if 'timeout' in script: - # expected exception - pass - else: - self.loglines = marionette.get_logs() - raise diff --git a/testing/luciddream/luciddream/runluciddream.py b/testing/luciddream/luciddream/runluciddream.py deleted file mode 100644 index 6b7c133e28de..000000000000 --- a/testing/luciddream/luciddream/runluciddream.py +++ /dev/null @@ -1,157 +0,0 @@ -#!/usr/bin/env python -# -# 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/. -# - -from __future__ import print_function -import argparse -import os -import sys - -from luciddream import LucidDreamTestCase -from marionette import Marionette -from marionette.runner import BaseMarionetteTestRunner -import marionette -import mozlog - - -class CommandLineError(Exception): - pass - - -def validate_options(options): - if not (options.emulator_path or options.b2g_desktop_path): - raise CommandLineError('You must specify --emulator-path or ' + - '--b2g-desktop-path') - if options.emulator_path and options.b2g_desktop_path: - raise CommandLineError('You may only use one of --emulator-path or ' + - '--b2g-desktop-path') - if options.gaia_profile and options.emulator_path: - raise CommandLineError('You may not use --gaia-profile with ' + - '--emulator-path') - if not options.browser_path: - raise CommandLineError('You must specify --browser-path') - if not os.path.isfile(options.manifest): - raise CommandLineError('The manifest at "%s" does not exist!' - % options.manifest) - - -# BaseMarionetteOptions has a lot of stuff we don't care about, and -# it seems hard to apply directly to this problem. We can revisit this -# decision later if necessary. -def parse_args(in_args): - parser = argparse.ArgumentParser(description='Run Luciddream tests.') - parser.add_argument('--emulator-arch', dest='emulator_arch', action='store', - default='arm', - help='Architecture of emulator to use: x86 or arm') - parser.add_argument('--emulator-path', dest='emulator_path', action='store', - help='path to B2G repo or qemu dir') - parser.add_argument('--b2g-desktop-path', dest='b2g_desktop_path', - action='store', - help='path to B2G desktop binary') - parser.add_argument('--browser-path', dest='browser_path', action='store', - help='path to Firefox binary') - parser.add_argument('--gaia-profile', dest='gaia_profile', action='store', - help='path to Gaia profile') - parser.add_argument('--startup-timeout', dest='startup_timeout', action='store', - default=60, type=int, - help='max time to wait for Marionette to be available after launching binary') - parser.add_argument('manifest', metavar='MANIFEST', action='store', - help='path to manifest of tests to run') - mozlog.commandline.add_logging_group(parser) - - args = parser.parse_args(in_args) - try: - validate_options(args) - return args - except CommandLineError as e: - print('Error: ', e.args[0], file=sys.stderr) - parser.print_help() - raise - - -class LucidDreamTestRunner(BaseMarionetteTestRunner): - def __init__(self, **kwargs): - BaseMarionetteTestRunner.__init__(self, **kwargs) - #TODO: handle something like MarionetteJSTestCase - self.test_handlers = [LucidDreamTestCase] - - -def start_browser(browser_path, app_args, startup_timeout): - ''' - Start a Firefox browser and return a Marionette instance that - can talk to it. - ''' - marionette = Marionette( - bin=browser_path, - # Need to avoid the browser and emulator's ports stepping - # on each others' toes. - port=2929, - app_args=app_args, - gecko_log="firefox.log", - startup_timeout=startup_timeout - ) - runner = marionette.runner - if runner: - runner.start() - marionette.wait_for_port() - marionette.start_session() - marionette.set_context(marionette.CONTEXT_CHROME) - return marionette - - -# TODO: make ../../marionette/harness/marionette/runtests.py importable -# so we can just use cli from there. A lot of this is copy/paste from that function. -def run(browser_path=None, b2g_desktop_path=None, emulator_path=None, - emulator_arch=None, gaia_profile=None, manifest=None, browser_args=None, - **kwargs): - # It's sort of debatable here whether the marionette instance managed - # by the test runner should be the browser or the emulator. Right now - # it's the emulator because it feels like there's more fiddly setup around - # that, but longer-term if we want to run tests against different - # (non-B2G) targets this won't match up very well, so maybe it ought to - # be the browser? - browser = start_browser(browser_path, browser_args, kwargs['startup_timeout']) - - kwargs["browser"] = browser - if not "logger" in kwargs: - logger = mozlog.commandline.setup_logging( - "luciddream", kwargs, {"tbpl": sys.stdout}) - kwargs["logger"] = logger - - if emulator_path: - kwargs['homedir'] = emulator_path - kwargs['emulator'] = emulator_arch - elif b2g_desktop_path: - # Work around bug 859952 - if '-bin' not in b2g_desktop_path: - if b2g_desktop_path.endswith('.exe'): - newpath = b2g_desktop_path[:-4] + '-bin.exe' - else: - newpath = b2g_desktop_path + '-bin' - if os.path.exists(newpath): - b2g_desktop_path = newpath - kwargs['binary'] = b2g_desktop_path - kwargs['app'] = 'b2gdesktop' - if gaia_profile: - kwargs['profile'] = gaia_profile - else: - kwargs['profile'] = os.path.join( - os.path.dirname(b2g_desktop_path), - 'gaia', - 'profile' - ) - runner = LucidDreamTestRunner(**kwargs) - runner.run_tests([manifest]) - if runner.failed > 0: - sys.exit(10) - sys.exit(0) - -def main(): - args = parse_args(sys.argv[1:]) - run(**vars(args)) - -if __name__ == '__main__': - main() diff --git a/testing/luciddream/mach_commands.py b/testing/luciddream/mach_commands.py deleted file mode 100644 index 6e2f14b11dd8..000000000000 --- a/testing/luciddream/mach_commands.py +++ /dev/null @@ -1,97 +0,0 @@ -# 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/. - -# Integrates luciddream test runner with mach. - -from __future__ import absolute_import - -import os - -from mozbuild.base import ( - MachCommandBase, - MachCommandConditions as conditions, - MozbuildObject, -) - -from mach.decorators import ( - CommandArgument, - CommandProvider, - Command, -) - -class LucidDreamRunner(MozbuildObject): - """Run luciddream tests.""" - def run_tests(self, **kwargs): - self._run_make(target='jetpack-tests') - -@CommandProvider -class MachCommands(MachCommandBase): - @Command('luciddream', category='testing', - description='Run the luciddream test suite (remote debugging).') - @CommandArgument("--consoles", action="store_true", - help="Open jsconsole in both runtimes.") - @CommandArgument('--b2g-desktop', dest="b2g_desktop_path", type=str, default=None, - help='Path to b2g desktop binary.') - @CommandArgument('--browser', dest="browser_path", type=str, default=None, - help='Path to firefox binary.') - @CommandArgument('--gaia-profile', type=str, default=None, - help='Path to gaia profile, optional, if not bundled with b2g desktop.') - @CommandArgument('--emulator', dest="emulator_path", type=str, default=None, - help='Path to android emulator.') - @CommandArgument('--emulator-arch', type=str, default="arm", - help='Emulator arch: x86 or arm.') - @CommandArgument('test_paths', default=None, nargs='*', metavar='TEST', - help='Test to run. Can be specified as a single file, a ' - 'directory, or omitted. If omitted, the entire test suite is ' - 'executed.') - def run_luciddream_test(self, browser_path, b2g_desktop_path, test_paths, consoles, **params): - # import luciddream lazily as its marionette dependency make ./mach clobber fails - # early on TBPL - import luciddream.runluciddream - - # get_binary_path is going to throw if we haven't built any product - # but luciddream can still be run if we provide both binaries... - binary_path=False - try: - binary_path = self.get_binary_path() - except Exception: - pass - - # otherwise, if we have a build, automatically fetch the binary - if conditions.is_b2g(self): - if not b2g_desktop_path and binary_path: - b2g_desktop_path = binary_path - else: - if not browser_path and binary_path: - browser_path = binary_path - - if not browser_path: - print "Need firefox binary path via --browser_path argument" - return 1 - elif not os.path.exists(browser_path): - print "Firefox binary doesn't exists: " + browser_path - return 1 - - if not b2g_desktop_path: - print "Need b2g desktop binary path via --b2g-desktop argument" - return 1 - elif not os.path.exists(b2g_desktop_path): - print "B2G desktop binary doesn't exists: " + b2g_desktop_path - return 1 - - if not test_paths or len(test_paths) == 0: - print "Please specify a test manifest to run" - return 1 - - browser_args = None - if consoles: - browser_args = ["-jsconsole"] - if "app_args" in params and isinstance(params["app_args"], list): - params["app_args"].append("-jsconsole") - else: - params["app_args"] = ["-jsconsole"] - - for test in test_paths: - luciddream.runluciddream.run(browser_path=browser_path, b2g_desktop_path=b2g_desktop_path, - manifest=test, browser_args=browser_args, **params) diff --git a/testing/luciddream/requirements.txt b/testing/luciddream/requirements.txt deleted file mode 100644 index 514d955d5424..000000000000 --- a/testing/luciddream/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -marionette-client >= 1.1.0 -mozlog >= 3.0 diff --git a/testing/luciddream/setup.py b/testing/luciddream/setup.py deleted file mode 100644 index 8b70ed15126b..000000000000 --- a/testing/luciddream/setup.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python -# -# 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/. -# - -import os -from setuptools import setup, find_packages - -try: - here = os.path.dirname(os.path.abspath(__file__)) - description = file(os.path.join(here, 'README.md')).read() -except IOError: - description = '' - -version = '0.1' - -dependencies = open('requirements.txt', 'r').read().splitlines() - -setup( - name='luciddream', - version=version, - description=''' - Luciddream is a test harness for running tests between - a Firefox browser and another device, such as a Firefox OS - emulator. - ''', - long_description=description, - classifiers=[], # Get strings from http://www.python.org/pypi?%3Aaction=list_classifiers - author='Ted Mielczarek', - author_email='ted@mielczarek.org', - url='', - license='MPL 2.0', - packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), - include_package_data=True, - package_data={'': ['*.js', '*.css', '*.html', '*.txt', '*.xpi', '*.rdf', '*.xul', '*.jsm', '*.xml'],}, - zip_safe=False, - install_requires=dependencies, - entry_points = { - 'console_scripts': ['runluciddream=luciddream.runluciddream:main'], - } - ) diff --git a/testing/mozharness/configs/luciddream/linux_config.py b/testing/mozharness/configs/luciddream/linux_config.py deleted file mode 100644 index 566f305c3f76..000000000000 --- a/testing/mozharness/configs/luciddream/linux_config.py +++ /dev/null @@ -1,65 +0,0 @@ -# This is a template config file for luciddream production. -import os -import platform - -HG_SHARE_BASE_DIR = "/builds/hg-shared" - -if platform.system().lower() == 'darwin': - xre_url = "https://api.pub.build.mozilla.org/tooltool/sha512/4d8d7a37d90c34a2a2fda3066a8fe85c189b183d05389cb957fc6fed31f10a6924e50c1b84488ff61c015293803f58a3aed5d4819374d04c8e0ee2b9e3997278" -else: - xre_url = "https://api.pub.build.mozilla.org/tooltool/sha512/dc9503b21c87b5a469118746f99e4f41d73888972ce735fa10a80f6d218086da0e3da525d9a4cd8e4ea497ec199fef720e4a525873d77a1af304ac505e076462" - -config = { - # mozharness script options - "xre_url": xre_url, - "b2gdesktop_url": "http://ftp.mozilla.org/pub/mozilla.org/b2g/nightly/2015/03/2015-03-09-00-25-06-mozilla-b2g37_v2_2/b2g-37.0.multi.linux-i686.tar.bz2", - - # mozharness configuration - "vcs_share_base": HG_SHARE_BASE_DIR, - "exes": { - 'python': '/tools/buildbot/bin/python', - 'virtualenv': ['/tools/buildbot/bin/python', '/tools/misc-python/virtualenv.py'], - 'tooltool.py': "/tools/tooltool.py", - 'gittool.py': '%(abs_tools_dir)s/buildfarm/utils/gittool.py', - }, - - "find_links": [ - "http://pypi.pvt.build.mozilla.org/pub", - "http://pypi.pub.build.mozilla.org/pub", - ], - "pip_index": False, - - "suite_definitions": { - "luciddream-emulator": { - "options": [ - "--startup-timeout=300", - "--log-raw=%(raw_log_file)s", - "--log-errorsummary=%(error_summary_file)s", - "--browser-path=%(browser_path)s", - "--b2gpath=%(emulator_path)s", - "%(test_manifest)s" - ], - }, - "luciddream-b2gdt": { - "options": [ - "--startup-timeout=300", - "--log-raw=%(raw_log_file)s", - "--log-errorsummary=%(error_summary_file)s", - "--browser-path=%(browser_path)s", - "--b2g-desktop-path=%(fxos_desktop_path)s", - "--gaia-profile=%(gaia_profile)s", - "%(test_manifest)s" - ], - }, - }, - - "buildbot_json_path": "buildprops.json", - - "default_blob_upload_servers": [ - "https://blobupload.elasticbeanstalk.com", - ], - "blob_uploader_auth_file": os.path.join(os.getcwd(), "oauth.txt"), - "download_symbols": "ondemand", - "download_minidump_stackwalk": True, - "tooltool_cache": "/builds/tooltool_cache", -}