Permalink
Browse files

added B2GRunner to run tests in b2g pandaboard environment

  • Loading branch information...
1 parent 21de273 commit 82ded35098a729d056ffb13d43137259982f2004 @malini committed Aug 1, 2012
Showing with 78 additions and 8 deletions.
  1. +3 −0 .gitmodules
  2. +4 −0 README.md
  3. +20 −6 bin/runtest.py
  4. +1 −0 bootstrap.sh
  5. +1 −1 src/eideticker/eideticker/__init__.py
  6. +49 −1 src/eideticker/eideticker/runner.py
View
@@ -22,3 +22,6 @@
[submodule "src/orangutan"]
path = src/orangutan
url = git://github.com/wlach/orangutan.git
+[submodule "src/marionette_client"]
+ path = src/marionette_client
+ url = git://github.com/mozilla/marionette_client
View
@@ -50,6 +50,10 @@ ip address of your phone, then set the following environment variables:
export DM_TRANS=sut
export TEST_DEVICE=<device ip of phone>
+If you are using a B2G pandaboard with adb, then you'll need sudo privileges for adb:
+
+ adb kill-server
+ sudo adb start-server
#### Console Mode
Console mode is meant for internal profiling. You run a program
View
@@ -123,12 +123,23 @@ def main(args=sys.argv[1:]):
parser.add_option("--startup-test", action="store_true",
dest="startup_test",
help="do a startup test: full capture, no actions")
+ parser.add_option("--b2g", action="store_true",
+ dest="b2g", default=False,
+ help="Run in B2G environment. You do not need to pass an appname")
options, args = parser.parse_args()
- if len(args) != 2:
- parser.error("incorrect number of arguments")
- (appname, testpath) = args
+ testpath, appname = None, None
+ if options.b2g:
+ if len(args) != 1:
+ parser.error("incorrect number of arguments")
+ sys.exit(1)
+ testpath = args[0]
+ else:
+ if len(args) != 2:
+ parser.error("incorrect number of arguments")
+ sys.exit(1)
+ (appname, testpath) = args
# Tests must be in src/tests/... unless it is a startup test and the
# path is about:home (indicating we want to measure startup to the
# home screen)
@@ -142,7 +153,7 @@ def main(args=sys.argv[1:]):
except:
print "Test must be relative to %s" % TEST_DIR
sys.exit(1)
-
+
actions = None
if not options.startup_test:
actions_path = os.path.join(os.path.dirname(testpath), "actions.json")
@@ -170,7 +181,7 @@ def main(args=sys.argv[1:]):
# Create a device object to interface with the phone
device = eideticker.getDevice(options)
- if device.processExist(appname):
+ if appname and device.processExist(appname):
print "An instance of %s is running. Please stop it before running Eideticker." % appname
sys.exit(1)
@@ -238,7 +249,10 @@ def main(args=sys.argv[1:]):
http.httpd.server_port,
testpath_rel)
print "Test URL is: %s" % url
- runner = eideticker.BrowserRunner(device, appname, url)
+ if options.b2g:
+ runner = eideticker.B2GRunner(device, url)
+ else:
+ runner = eideticker.BrowserRunner(device, appname, url)
# FIXME: currently start capture before launching app because we wait until app is
# launched -- would be better to make waiting optional and then start capture
# after triggering app launch to reduce latency?
View
@@ -71,3 +71,4 @@ make -C src/videocapture/videocapture/decklink
./bin/pip install -e src/mozbase/mozdevice
./bin/pip install -e src/templeton
./bin/pip install -e src/mozregression
+./bin/pip install -e src/marionette_client
@@ -2,7 +2,7 @@
# 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 runner import BrowserRunner
+from runner import BrowserRunner, B2GRunner
from options import OptionParser
from device import getDevice
from apk import get_fennec_appinfo
@@ -4,6 +4,54 @@
import mozprofile
import os
+import time
+
+from marionette import Marionette
+
+class B2GRunner(object):
+ remote_profile_dir = None
+
+ def __init__(self, dm, url, marionette_host='localhost', marionette_port=2828):
+ self.dm = dm
+ self.url = url
+ self.marionette = Marionette(marionette_host, marionette_port)
+
+ def start(self):
+ """
+ #restart b2g so we start with a clean slate
+ self.dm.checkCmd(['shell', 'stop', 'b2g'])
+ # Wait for a bit to make sure B2G has completely shut down.
+ time.sleep(10)
+ self.dm.checkCmd(['shell', 'start', 'b2g'])
+ """
+ #TODO: how to check for when b2g is up? procs?
+
+ #forward the marionette port
+ self.dm.checkCmd(['forward',
+ 'tcp:%s' % self.marionette.port,
+ 'tcp:%s' % self.marionette.port])
+
+ #enable ethernet connection
+ #ethFile = open("ethFile", "rw")
+ #self.dm.shell("netcfg eth0 dhcp", ethFile)
+ print "running netcfg, it may take some time"
+ #self.dm.checkCmd(['shell', 'netcfg', 'eth0', 'dhcp'])
+ print "sleeping"
+ #time.sleep(4)
+ print "launching"
+ #launch app
+ session = self.marionette.start_session()
+ print "got session"
+ if 'b2g' not in session:
+ raise Exception("bad session value %s returned by start_session" % session)
+
+ # start the tests by navigating to the mochitest url
+ print "loading test"
+ self.marionette.execute_script("window.location.href='%s';" % self.url)
+ print "loaded"
+
+ def stop(self):
+ self.marionette.delete_session()
class BrowserRunner(object):
@@ -49,7 +97,7 @@ def start(self):
# sometimes fennec fails to start, so we'll try three times...
for i in range(3):
- print "Launching %s (try %s of 3)" % (self.appname, (i+1))
+ print "Launching fennec (try %s of 3)" % (i+1)
if self.dm.launchFennec(self.appname, url=self.url, extraArgs=args):
return
raise Exception("Failed to start Fennec after three tries")

0 comments on commit 82ded35

Please sign in to comment.