From de4be1ce45cd11bc4e25631da90a376f3e8fa0a0 Mon Sep 17 00:00:00 2001 From: Kyle Manna Date: Tue, 2 Dec 2014 16:44:06 -0800 Subject: [PATCH] tests: Add kitkat sync test * Create a simple script to test fetching of a repo. * Very useful for testing local git mirrors. --- tests/sync-kitkat.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 tests/sync-kitkat.sh diff --git a/tests/sync-kitkat.sh b/tests/sync-kitkat.sh new file mode 100755 index 0000000..a8e5036 --- /dev/null +++ b/tests/sync-kitkat.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Test script file that maps itself into a docker container and runs +# +# Example invocation: +# +# $ AOSP_VOL=$PWD/build ./sync-kitkat.sh +# +set -ex + +if [ "$1" = "docker" ]; then + TEST_BRANCH=${TEST_BRANCH:-android-4.4.4_r2.0.1} + TEST_URL=${TEST_URL:-https://android.googlesource.com/platform/manifest} + + repo init --depth 1 -u "$TEST_URL" -b "$TEST_BRANCH" + + # Use default sync '-j' value embedded in manifest file to be polite + repo sync + retval=$? + + echo "repo sync returned: $retval" + exit $retval +else + aosp_url="https://raw.githubusercontent.com/kylemanna/docker-aosp/master/utils/aosp" + args="run.sh docker" + export AOSP_EXTRA_ARGS="-v $(cd $(dirname $0) && pwd -P)/$(basename $0):/usr/local/bin/run.sh:ro" + export AOSP_VOL=/vol1 + export AOSP_IMAGE=aosp + + [ -n "$TEST_URL" ] && AOSP_EXTRA_ARGS+=" -e TEST_URL=$TEST_URL" + [ -n "$TEST_BRANCH" ] && AOSP_EXTRA_ARGS+=" -e TEST_BRANCH=$TEST_BRANCHcY" + + # + # Try to invoke the aosp wrapper with the following priority: + # + # 1. If AOSP_BIN is set, use that + # 2. If aosp is found in the shell $PATH + # 3. Grab it from the web + # + if [ -n "$AOSP_BIN" ]; then + $AOSP_BIN $args + elif [ -x "../utils/aosp" ]; then + ../utils/aosp $args + elif [ -n "$(type -P aosp)" ]; then + aosp $args + else + if [ -n "$(type -P curl)" ]; then + bash <(curl -s $aosp_url) $args + elif [ -n "$(type -P wget)" ]; then + bash <(wget -q $aosp_url -O -) $args + else + echo "Unable to run the aosp binary" + fi + fi +fi