Script to download CTS Manual and Verifier suites
BUG=b:63827123
TEST=./cts_download.sh OPTION --download-path --cts_version
Change-Id: Ia0b0f032d43f9ee420afbe0ae5b024b5078a561f
Reviewed-on: https://chromium-review.googlesource.com/756877
Commit-Ready: Kishan Kanchi <kkanchi@google.com>
Tested-by: Kishan Kanchi <kkanchi@google.com>
Reviewed-by: Kishan Kanchi <kkanchi@google.com>
Reviewed-by: danny chan <dchan@chromium.org>
diff --git a/provingground/cts/cts_download.sh b/provingground/cts/cts_download.sh
index a62a640..f67d8b0 100755
--- a/provingground/cts/cts_download.sh
+++ b/provingground/cts/cts_download.sh
@@ -2,109 +2,165 @@
# Copyright 2017 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-# This script downloads the Android-cts suite from the below website:
-# https://source.android.com/compatibility/cts/downloads.
+# This script downloads the Android-cts and Android-cts-verifier suites
+# from @ https://source.android.com/compatibility/cts/downloads.
# The downloaded zip file is unzipped and placed according to the versioning.
-
# Usage information to be displayed.
usage_info() {
cat <<EOF
Usage:
-./cts_download.sh --download_path <path> --cts_version <cts_version>
+./cts_download.sh [OPTION] --path <path> --version <cts_version>
+Positions (1) (2) (3) (4) (5)
+
Sample usage:
-./cts_download.sh --download_path ~/Desktop --cts_version 7.1_r6
+./cts_download.sh [OPTION] --path ~/Desktop --version 7.1_r6
+
+[OPTION]
+Please provide one of them.
+ -v, to download only Verifier suites
+ -m, to download only Manual Test suites
+ -vm,-mv to download both Manual and Verifier Test suites
EOF
}
+Download_Suite()
+{
+ # Downloading the Zipped Android File from the URL:
+ # https://source.android.com/compatibility/cts/downloads
+ Download_Url="https://dl.google.com/dl/android/cts/$ANDROID_FILE"
+ if wget $Download_Url -P tmp/ ; then
+ # Clearing the previous unzip file.
+ rm -rf "${CTS_Folder}"
+ # Unzipping the Android version.
+ unzip "tmp/$ANDROID_FILE"
+ # Creating directory for x86
+ DDIR="$DOWNLOAD_PATH/CTS"
+ DDIR="$DDIR/$ANDROID_VERSION_NAME/$CTS_VERSION"
+ DDIR="$DDIR/$FOLDER_NAME/$ABI"
+ mkdir -p $DDIR
+ mv -b $CTS_Folder $DDIR
+ rm tmp/android*.zip*
+ else
+ echo "Requested CTS verison does not exists @"
+ echo "https://source.android.com/compatibility/cts/downloads."
+ exit 0
+ fi
+}
main() {
- # Display the help information if the parameter is -h or --help.
- if [[ $1 == "-h" || $1 == "--help" ]]; then
- usage_info
- exit 0
- fi
- # Checking if all the #4 parameters are provided.
- if [[ $# -ne 4 ]]; then
- usage_info
- exit 0
- fi
+ # Checking if all the #5 parameters are provided.
+ if [[ $# -ne 5 ]]; then
+ usage_info
+ exit 0
+ fi
+
+ # Checking if the second parameter is "--path".
+ if [[ $2 != "--path" ]]; then
+ echo "Second parameter should be --path"
+ usage_info
+ exit 0
+ fi
+
+ # Checking if the 4th paramter is "--version".
+ if [[ $4 != "--version" ]]; then
+ echo "Fourth Parameter should be --version"
+ usage_info
+ exit 0
+ fi
+
+
+ # Reading the OPTION.
+ OPTION="$1"
+
# Reading the Download Path.
- DOWNLOAD_PATH=$2
+ DOWNLOAD_PATH="$3"
# Reading the CTS Version.
- CTS_VERSION=$4
-
- readonly CTS_FOLDER="android-cts"
+ CTS_VERSION="$5"
# Verifying the Download Path.
- if [[ ! -d "${DOWNLOAD_PATH}" ]]; then
- echo The Download path provided is invalid
+ if [[ ! -d "$DOWNLOAD_PATH" ]]; then
+ echo "The Download path provided is invalid"
exit 1
fi
# Verifying the CTS VERSION format provided.
- if echo "${CTS_VERSION}" | \
- egrep -i -v -q '^[0-9]+.+[0-9]+_+[r]+[[0-9]|[1-9][0-9]$'; then
+ CTS_VERSION_FORMAT='^[0-9]+.+[0-9]+_+[r]+[[0-9]|[1-9][0-9]$'
+ if egrep -i -q -v $CTS_VERSION_FORMAT <<<$CTS_VERSION; then
cat <<EOF
- Specified CTS Version format is mismatched
- Sample CTS Version Format is 7.1_r6
+ Specified CTS Version format is mismatched.
+ Sample CTS Version Format is 7.1_r6.
EOF
- exit 1
+ exit 1
fi
# Extracting the Android version from CTS version.
ANDROID_VERSION="${CTS_VERSION%.*}"
# Creating Folders according to the Android version.
- # "M" for 6 (Marshmallow).
# "N" for 7 (Nougat).
# "O" for 8 (Yet to be named).
-
declare -A MAPPING=(
- [6]="M"
[7]="N"
[8]="O"
)
- ANDROID_VERSION_NAME=${MAPPING[${ANDROID_VERSION}]}
- if [[ -z "${ANDROID_VERSION_NAME}" ]]; then
- echo "CTS version shall start with 6, 7 or 8"
+
+ ANDROID_VERSION_NAME=${MAPPING[$ANDROID_VERSION]}
+ if [[ -z "$ANDROID_VERSION_NAME" ]]; then
+ echo "CTS version shall start with 7,8 and so on.."
exit 1
fi
# Creating a temp directory to download the android file.
mkdir -p tmp
- # Download, unzip and move to the CTS file to the provided location.
- for ABI in x86 arm; do
- if [[ "${ABI}" = "x86" ]]; then
- ANDROID_FILE=android-cts-"${CTS_VERSION}"-linux_x86-x86.zip
- elif [[ "${ABI}" = "arm" ]]; then
- ANDROID_FILE=android-cts-"${CTS_VERSION}"-linux_x86-arm.zip
- fi
- # Downloading the zipped Android Test Suite from the URL:
- # https://source.android.com/compatibility/cts/downloads.
- if wget "https://dl.google.com/dl/android/cts/"$ANDROID_FILE \
- -P tmp/ ; then
- # Clearing the previous unzip file.
- rm -rf "${CTS_FOLDER}"
- # Unzipping the Android version.
- unzip tmp/"${ANDROID_FILE}"
- # Creating directory for x86.
- mkdir -p \
- "${DOWNLOAD_PATH}"/CTS/"${ANDROID_VERSION_NAME}"/"${CTS_VERSION}"/"${ABI}"
- # Moving android-cts folder to x86 hierarchy.
- mv -b android-cts \
- "${DOWNLOAD_PATH}"/CTS/"${ANDROID_VERSION_NAME}"/"${CTS_VERSION}"/"${ABI}"
- # Clearing the previous downloaded ZIP file.
- rm tmp/android*.zip*
- else
- # URL not found.
- echo Requested CTS verison does not exists @\
- https://source.android.com/compatibility/cts/downloads
- exit 1
- fi
- done
- echo "The android-cts files are downloaded successfully to "\
- "${DOWNLOAD_PATH}"/CTS/"${ANDROID_VERSION_NAME}"/"${CTS_VERSION}"
+
+ # Checking if the Verifier OPTION is submitted
+ # If yes, setting Verifier_Tests flag.
+ if [ "${OPTION:1:1}" = "v" ] || [ "${OPTION:2:2}" = "v" ]; then
+ Verifier_Tests="SET"
+ fi
+
+ # Checking if the Manual Suite OPTION is submitted
+ # If yes, setting Manual_Tests flag.
+ if [ "${OPTION:1:1}" = "m" ] || [ "${OPTION:2:2}" = "m" ]; then
+ Manual_Tests="SET"
+ fi
+
+ readonly x86_folder="linux_x86-x86"
+ readonly arm_folder="linux_x86-arm"
+
+ # If the Verifier OPTION is provided, Download the Verifier Tests Suite
+ if [ "$Verifier_Tests" ]; then
+ CTS_Folder="android-cts-verifier"
+ # Download, unzip and move the Verifier Tests suite to the path
+ for ABI in x86 arm; do
+ if [ "$ABI" = "x86" ]; then
+ ANDROID_FILE="android-cts-verifier-${CTS_VERSION}-${x86_folder}.zip"
+ elif [ "$ABI" = "arm" ]; then
+ ANDROID_FILE="android-cts-verifier-${CTS_VERSION}-${arm_folder}.zip"
+ fi
+ FOLDER_NAME="Verifier_Tests"
+ Download_Suite
+ done
+ fi
+
+ # If the Manual OPTION is provided, Download the Manual Tests Suite
+ if [ "$Manual_Tests" ]; then
+ # Download, unzip and move the Manual Tests suite to the path
+ CTS_Folder="android-cts"
+ for ABI in x86 arm; do
+ if [ "$ABI" = "x86" ]; then
+ ANDROID_FILE="android-cts-${CTS_VERSION}-${x86_folder}.zip"
+ elif [ "$ABI" = "arm" ]; then
+ ANDROID_FILE="android-cts-${CTS_VERSION}-${arm_folder}.zip"
+ fi
+ FOLDER_NAME="Manual_Tests"
+ Download_Suite
+ done
+ fi
+
+ echo "The cts files are loaded successfully to "\
+ "$DOWNLOAD_PATH/CTS/$ANDROID_VERSION_NAME/$CTS_VERSION"
}
main "$@"