mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 12:55:46 +00:00
Backed out changeset db18074e2a25 to correct bug number
This commit is contained in:
parent
93d39a5941
commit
fc53564491
@ -2,3 +2,46 @@
|
|||||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
# 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/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
import os
|
||||||
|
import socket
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
class B2GInstance(object):
|
||||||
|
|
||||||
|
def __init__(self, host, port, b2gbin):
|
||||||
|
self.marionette_host = host
|
||||||
|
self.marionette_port = port
|
||||||
|
self.b2gbin = b2gbin
|
||||||
|
self.proc = None
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
if not os.getenv('GAIA'):
|
||||||
|
raise Exception("GAIA environment variable must be set to your gaia directory")
|
||||||
|
args = [self.b2gbin, '-profile', os.path.join(os.getenv('GAIA'), "profile")]
|
||||||
|
self.proc = subprocess.Popen(args,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
self.proc.terminate()
|
||||||
|
|
||||||
|
def wait_for_port(self, timeout=300):
|
||||||
|
assert(self.marionette_port)
|
||||||
|
starttime = datetime.datetime.now()
|
||||||
|
while datetime.datetime.now() - starttime < datetime.timedelta(seconds=timeout):
|
||||||
|
try:
|
||||||
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
sock.connect((self.marionette_host, self.marionette_port))
|
||||||
|
data = sock.recv(16)
|
||||||
|
sock.close()
|
||||||
|
if '"from"' in data:
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
import traceback
|
||||||
|
print traceback.format_exc()
|
||||||
|
time.sleep(1)
|
||||||
|
return False
|
||||||
|
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
import datetime
|
|
||||||
import socket
|
|
||||||
import time
|
|
||||||
from mozrunner import Runner
|
|
||||||
|
|
||||||
|
|
||||||
class GeckoInstance(object):
|
|
||||||
|
|
||||||
def __init__(self, host, port, bin, profile):
|
|
||||||
self.marionette_host = host
|
|
||||||
self.marionette_port = port
|
|
||||||
self.bin = bin
|
|
||||||
self.profile = profile
|
|
||||||
self.runner = None
|
|
||||||
|
|
||||||
def start(self):
|
|
||||||
profile = self.profile
|
|
||||||
if not profile:
|
|
||||||
prefs = {"dom.allow_XUL_XBL_for_file": True,
|
|
||||||
"marionette.defaultPrefs.enabled": True,
|
|
||||||
"marionette.defaultPrefs.port": 2828}
|
|
||||||
profile = {"preferences": prefs, "restore":False}
|
|
||||||
print "starting runner"
|
|
||||||
self.runner = Runner.create(binary=self.bin, profile_args=profile, cmdargs=['-no-remote'])
|
|
||||||
self.runner.start()
|
|
||||||
|
|
||||||
def close(self):
|
|
||||||
self.runner.stop()
|
|
||||||
self.runner.cleanup()
|
|
||||||
|
|
||||||
def wait_for_port(self, timeout=3000):
|
|
||||||
assert(self.marionette_port)
|
|
||||||
starttime = datetime.datetime.now()
|
|
||||||
while datetime.datetime.now() - starttime < datetime.timedelta(seconds=timeout):
|
|
||||||
try:
|
|
||||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
||||||
sock.connect((self.marionette_host, self.marionette_port))
|
|
||||||
data = sock.recv(16)
|
|
||||||
print "closing socket"
|
|
||||||
sock.close()
|
|
||||||
if '"from"' in data:
|
|
||||||
print "got data"
|
|
||||||
time.sleep(5)
|
|
||||||
return True
|
|
||||||
except:
|
|
||||||
import traceback
|
|
||||||
print traceback.format_exc()
|
|
||||||
time.sleep(1)
|
|
||||||
return False
|
|
@ -7,7 +7,7 @@ import socket
|
|||||||
from client import MarionetteClient
|
from client import MarionetteClient
|
||||||
from errors import *
|
from errors import *
|
||||||
from emulator import Emulator
|
from emulator import Emulator
|
||||||
from geckoinstance import GeckoInstance
|
from b2ginstance import B2GInstance
|
||||||
|
|
||||||
class HTMLElement(object):
|
class HTMLElement(object):
|
||||||
|
|
||||||
@ -70,13 +70,12 @@ class Marionette(object):
|
|||||||
CONTEXT_CHROME = 'chrome'
|
CONTEXT_CHROME = 'chrome'
|
||||||
CONTEXT_CONTENT = 'content'
|
CONTEXT_CONTENT = 'content'
|
||||||
|
|
||||||
def __init__(self, host='localhost', port=2828, bin=None, profile=None,
|
def __init__(self, host='localhost', port=2828, b2gbin=False,
|
||||||
emulator=None, emulatorBinary=None, connectToRunningEmulator=False,
|
emulator=None, emulatorBinary=None, connectToRunningEmulator=False,
|
||||||
homedir=None, baseurl=None, noWindow=False, logcat_dir=None):
|
homedir=None, baseurl=None, noWindow=False, logcat_dir=None):
|
||||||
self.host = host
|
self.host = host
|
||||||
self.port = self.local_port = port
|
self.port = self.local_port = port
|
||||||
self.bin = bin
|
self.b2gbin = b2gbin
|
||||||
self.profile = profile
|
|
||||||
self.session = None
|
self.session = None
|
||||||
self.window = None
|
self.window = None
|
||||||
self.emulator = None
|
self.emulator = None
|
||||||
@ -86,11 +85,10 @@ class Marionette(object):
|
|||||||
self.noWindow = noWindow
|
self.noWindow = noWindow
|
||||||
self.logcat_dir = logcat_dir
|
self.logcat_dir = logcat_dir
|
||||||
|
|
||||||
if bin:
|
if b2gbin:
|
||||||
self.instance = GeckoInstance(host=self.host, port=self.port,
|
self.b2ginstance = B2GInstance(host=self.host, port=self.port, b2gbin=self.b2gbin)
|
||||||
bin=self.bin, profile=self.profile)
|
self.b2ginstance.start()
|
||||||
self.instance.start()
|
assert(self.b2ginstance.wait_for_port())
|
||||||
assert(self.instance.wait_for_port())
|
|
||||||
if emulator:
|
if emulator:
|
||||||
self.emulator = Emulator(homedir=homedir,
|
self.emulator = Emulator(homedir=homedir,
|
||||||
noWindow=self.noWindow,
|
noWindow=self.noWindow,
|
||||||
@ -112,8 +110,8 @@ class Marionette(object):
|
|||||||
def __del__(self):
|
def __del__(self):
|
||||||
if self.emulator:
|
if self.emulator:
|
||||||
self.emulator.close()
|
self.emulator.close()
|
||||||
if self.bin:
|
if self.b2gbin:
|
||||||
self.instance.close()
|
self.b2ginstance.close()
|
||||||
for qemu in self.extra_emulators:
|
for qemu in self.extra_emulators:
|
||||||
qemu.emulator.close()
|
qemu.emulator.close()
|
||||||
|
|
||||||
|
@ -135,15 +135,14 @@ class MarionetteTextTestRunner(unittest.TextTestRunner):
|
|||||||
class MarionetteTestRunner(object):
|
class MarionetteTestRunner(object):
|
||||||
|
|
||||||
def __init__(self, address=None, emulator=None, emulatorBinary=None, homedir=None,
|
def __init__(self, address=None, emulator=None, emulatorBinary=None, homedir=None,
|
||||||
bin=None, profile=None, autolog=False, revision=None, es_server=None,
|
b2gbin=None, autolog=False, revision=None, es_server=None,
|
||||||
rest_server=None, logger=None, testgroup="marionette",
|
rest_server=None, logger=None, testgroup="marionette",
|
||||||
noWindow=False, logcat_dir=None):
|
noWindow=False, logcat_dir=None):
|
||||||
self.address = address
|
self.address = address
|
||||||
self.emulator = emulator
|
self.emulator = emulator
|
||||||
self.emulatorBinary = emulatorBinary
|
self.emulatorBinary = emulatorBinary
|
||||||
self.homedir = homedir
|
self.homedir = homedir
|
||||||
self.bin = bin
|
self.b2gbin = b2gbin
|
||||||
self.profile = profile
|
|
||||||
self.autolog = autolog
|
self.autolog = autolog
|
||||||
self.testgroup = testgroup
|
self.testgroup = testgroup
|
||||||
self.revision = revision
|
self.revision = revision
|
||||||
@ -188,16 +187,7 @@ class MarionetteTestRunner(object):
|
|||||||
|
|
||||||
def start_marionette(self):
|
def start_marionette(self):
|
||||||
assert(self.baseurl is not None)
|
assert(self.baseurl is not None)
|
||||||
if self.bin:
|
if self.address:
|
||||||
if self.address:
|
|
||||||
host, port = self.address.split(':')
|
|
||||||
else:
|
|
||||||
host = 'localhost'
|
|
||||||
port = 2828
|
|
||||||
self.marionette = Marionette(host=host, port=int(port),
|
|
||||||
bin=self.bin, profile=self.profile,
|
|
||||||
baseurl=self.baseurl)
|
|
||||||
elif self.address:
|
|
||||||
host, port = self.address.split(':')
|
host, port = self.address.split(':')
|
||||||
if self.emulator:
|
if self.emulator:
|
||||||
self.marionette = Marionette(host=host, port=int(port),
|
self.marionette = Marionette(host=host, port=int(port),
|
||||||
@ -205,6 +195,11 @@ class MarionetteTestRunner(object):
|
|||||||
homedir=self.homedir,
|
homedir=self.homedir,
|
||||||
baseurl=self.baseurl,
|
baseurl=self.baseurl,
|
||||||
logcat_dir=self.logcat_dir)
|
logcat_dir=self.logcat_dir)
|
||||||
|
if self.b2gbin:
|
||||||
|
self.marionette = Marionette(host=host,
|
||||||
|
port=int(port),
|
||||||
|
b2gbin=self.b2gbin,
|
||||||
|
baseurl=self.baseurl)
|
||||||
else:
|
else:
|
||||||
self.marionette = Marionette(host=host,
|
self.marionette = Marionette(host=host,
|
||||||
port=int(port),
|
port=int(port),
|
||||||
@ -217,7 +212,7 @@ class MarionetteTestRunner(object):
|
|||||||
noWindow=self.noWindow,
|
noWindow=self.noWindow,
|
||||||
logcat_dir=self.logcat_dir)
|
logcat_dir=self.logcat_dir)
|
||||||
else:
|
else:
|
||||||
raise Exception("must specify binary, address or emulator")
|
raise Exception("must specify address or emulator")
|
||||||
|
|
||||||
def post_to_autolog(self, elapsedtime):
|
def post_to_autolog(self, elapsedtime):
|
||||||
self.logger.info('posting results to autolog')
|
self.logger.info('posting results to autolog')
|
||||||
@ -272,9 +267,7 @@ class MarionetteTestRunner(object):
|
|||||||
|
|
||||||
def run_test(self, test, testtype):
|
def run_test(self, test, testtype):
|
||||||
if not self.httpd:
|
if not self.httpd:
|
||||||
print "starting httpd"
|
|
||||||
self.start_httpd()
|
self.start_httpd()
|
||||||
|
|
||||||
if not self.marionette:
|
if not self.marionette:
|
||||||
self.start_marionette()
|
self.start_marionette()
|
||||||
|
|
||||||
@ -397,11 +390,8 @@ if __name__ == "__main__":
|
|||||||
"tests from .ini files.")
|
"tests from .ini files.")
|
||||||
parser.add_option('--homedir', dest='homedir', action='store',
|
parser.add_option('--homedir', dest='homedir', action='store',
|
||||||
help='home directory of emulator files')
|
help='home directory of emulator files')
|
||||||
parser.add_option('--binary', dest='bin', action='store',
|
parser.add_option('--b2gbin', dest='b2gbin', action='store',
|
||||||
help='gecko executable to launch before running the test')
|
help='b2g executable')
|
||||||
parser.add_option('--profile', dest='profile', action='store',
|
|
||||||
help='profile to use when launching the gecko process. If not '
|
|
||||||
'passed, then a profile will be constructed and used.')
|
|
||||||
|
|
||||||
options, tests = parser.parse_args()
|
options, tests = parser.parse_args()
|
||||||
|
|
||||||
@ -409,9 +399,9 @@ if __name__ == "__main__":
|
|||||||
parser.print_usage()
|
parser.print_usage()
|
||||||
parser.exit()
|
parser.exit()
|
||||||
|
|
||||||
if not options.emulator and not options.address and not options.bin:
|
if not options.emulator and not options.address:
|
||||||
parser.print_usage()
|
parser.print_usage()
|
||||||
print "must specify --binary, --emulator or --address"
|
print "must specify --emulator or --address"
|
||||||
parser.exit()
|
parser.exit()
|
||||||
|
|
||||||
# default to storing logcat output for emulator runs
|
# default to storing logcat output for emulator runs
|
||||||
@ -423,8 +413,7 @@ if __name__ == "__main__":
|
|||||||
emulatorBinary=options.emulatorBinary,
|
emulatorBinary=options.emulatorBinary,
|
||||||
homedir=options.homedir,
|
homedir=options.homedir,
|
||||||
logcat_dir=options.logcat_dir,
|
logcat_dir=options.logcat_dir,
|
||||||
bin=options.bin,
|
b2gbin=options.b2gbin,
|
||||||
profile=options.profile,
|
|
||||||
noWindow=options.noWindow,
|
noWindow=options.noWindow,
|
||||||
revision=options.revision,
|
revision=options.revision,
|
||||||
testgroup=options.testgroup,
|
testgroup=options.testgroup,
|
||||||
|
Loading…
Reference in New Issue
Block a user