Skip to content

Commit

Permalink
Merge pull request mozilla-b2g#188 from marshall/updateTests
Browse files Browse the repository at this point in the history
Bug 821412: Support for the new B2G update test frontend. r=dhylands
  • Loading branch information
marshall committed Jan 2, 2013
2 parents 2b24a29 + 0975518 commit e9dfbe2
Show file tree
Hide file tree
Showing 5 changed files with 403 additions and 70 deletions.
35 changes: 35 additions & 0 deletions scripts/updates.sh
@@ -0,0 +1,35 @@
#!/bin/bash

# Determine the absolute path of our location.
B2G_DIR=$(cd `dirname $0`/..; pwd)
. $B2G_DIR/setup.sh

# Use default Gecko location if it's not provided in .config.
if [ -z $GECKO_PATH ]; then
GECKO_PATH=$B2G_DIR/gecko
fi

# Run standard set of tests by default. Command line arguments can be
# specified to run specific tests (an individual test file, a directory,
# or an .ini file).
TEST_PATH=$GECKO_PATH/testing/marionette/client/marionette/tests/update-tests.ini
MARIONETTE_FLAGS+=" --homedir=$B2G_DIR --type=b2g-smoketest"

while [ $# -gt 0 ]; do
case "$1" in
--*)
MARIONETTE_FLAGS+=" $1" ;;
*)
MARIONETTE_TESTS+=" $1" ;;
esac
shift
done

MARIONETTE_TESTS=${MARIONETTE_TESTS:-$TEST_PATH}
echo "Running tests: $MARIONETTE_TESTS"

SCRIPT=$GECKO_PATH/testing/marionette/client/marionette/venv_b2g_update_test.sh
PYTHON=${PYTHON:-`which python`}

echo bash $SCRIPT "$PYTHON" $MARIONETTE_FLAGS $MARIONETTE_TESTS
bash $SCRIPT "$PYTHON" $MARIONETTE_FLAGS $MARIONETTE_TESTS
4 changes: 3 additions & 1 deletion test.sh
Expand Up @@ -3,7 +3,7 @@
B2G_HOME=$(dirname $BASH_SOURCE)

usage() {
echo "Usage: $0 [marionette|mochitest] (frontend-args)"
echo "Usage: $0 [marionette|mochitest|updates] (frontend-args)"
echo ""
echo "'marionette' is the default frontend"
}
Expand All @@ -20,6 +20,8 @@ case "$FRONTEND" in
SCRIPT=$B2G_HOME/scripts/mochitest.sh ;;
marionette)
SCRIPT=$B2G_HOME/scripts/marionette.sh ;;
updates)
SCRIPT=$B2G_HOME/scripts/updates.sh ;;
--help|-h|help)
usage
exit 0;;
Expand Down
86 changes: 86 additions & 0 deletions tools/update-tools/build-flash-fota.py
@@ -0,0 +1,86 @@
#!/usr/bin/env python
#
# Copyright (C) 2012 Mozilla Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Build A FOTA update zip that flashes the system partition

import argparse
import os
import sys
import tempfile
import update_tools

def build_flash_fota(args):
security_dir = os.path.join(update_tools.b2g_dir, "build", "target",
"product", "security")
public_key = args.public_key or os.path.join(security_dir,
args.dev_key + ".x509.pem")
private_key = args.private_key or os.path.join(security_dir,
args.dev_key + ".pk8")
output_zip = args.output or "flash.zip"

system = update_tools.Partition.create_system(args.system_fs_type,
args.system_location)
data = update_tools.Partition.create_data(args.data_fs_type,
args.data_location)
builder = update_tools.FlashFotaBuilder(system, data)
builder.build_flash_fota(args.system_dir, public_key, private_key,
output_zip)
print "FOTA Flash ZIP generated: %s" % output_zip

def main():
parser = argparse.ArgumentParser(usage="%(prog)s [options]",
epilog="Note: java is required to be on your PATH to sign the update.zip")

system_group = parser.add_argument_group("system options")
system_group.add_argument("--system-dir", dest="system_dir",
required=True, help="path to system directory. required")
system_group.add_argument("--system-fs-type", dest="system_fs_type",
default=None, required=True, help="filesystem type for /system. required")
system_group.add_argument("--system-location", dest="system_location",
default=None, required=True, help="device location for /system. required")

data_group = parser.add_argument_group("data options")
data_group.add_argument("--data-fs-type", dest="data_fs_type",
default=None, required=True, help="filesystem type for /data. required")
data_group.add_argument("--data-location", dest="data_location",
default=None, required=True, help="device location for /data. required")

signing_group = parser.add_argument_group("signing options")
signing_group.add_argument("-d", "--dev-key", dest="dev_key",
metavar="KEYNAME", default="testkey",
help="Use the named dev key pair in build/target/product/security. " +
"Possible keys: media, platform, shared, testkey. Default: testkey")

signing_group.add_argument("-k", "--private-key", dest="private_key",
metavar="PRIVATE_KEY", default=None,
help="Private key used for signing the update.zip. Overrides --dev-key.")

signing_group.add_argument("-K", "--public-key", dest="public_key",
metavar="PUBLIC_KEY", default=None,
help="Public key used for signing the update.zip. Overrides --dev-key.")

parser.add_argument("-o", "--output", dest="output", metavar="ZIP",
help="Output to ZIP. Default: flash.zip", default=None)

update_tools.validate_env(parser)
try:
build_flash_fota(parser.parse_args())
except update_tools.UpdateException, e:
print >>sys.stderr, "Error: %s" % e
sys.exit(1)

if __name__ == "__main__":
main()
7 changes: 6 additions & 1 deletion tools/update-tools/test-update.py
Expand Up @@ -26,12 +26,17 @@

def main():
options = UpdateXmlOptions(output_arg=False)
options.add_argument("--update-dir", dest="update_dir", metavar="DIR",
default=None, help="Use a local http directory instead of pushing " +
" Busybox to the device. Also requires --url-template")
options.parse_args()

try:
test_update = TestUpdate(options.build_xml(),
complete_mar=options.get_complete_mar(),
partial_mar=options.get_partial_mar())
partial_mar=options.get_partial_mar(),
url_template=options.get_url_template(),
update_dir=options.options.update_dir)

test_update.test_update()
except Exception, e:
Expand Down

0 comments on commit e9dfbe2

Please sign in to comment.