#!/bin/bash # # Copyright (C) 2007 The Android Open Source Project # # 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. # Set up prog to be the path of this script, including following symlinks, # and set up progdir to be the fully-qualified pathname of its directory. prog="$0" while [ -h "${prog}" ]; do newProg=`/bin/ls -ld "${prog}"` newProg=`expr "${newProg}" : ".* -> \(.*\)$"` if expr "x${newProg}" : 'x/' >/dev/null; then prog="${newProg}" else progdir=`dirname "${prog}"` prog="${progdir}/${newProg}" fi done oldwd=`pwd` progdir=`dirname "${prog}"` cd "${progdir}" progdir=`pwd` prog="${progdir}"/`basename "${prog}"` if [[ -z "${JAVA_HOME}" ]]; then unix=$(uname | tr '[A-Z]' '[a-z]') JAVA_HOME="${progdir}/../../../prebuilts/jdk/jdk8/${unix}-x86" fi if [[ ! -d "${JAVA_HOME}" ]]; then echo "Missing JAVA_HOME directory: $JAVA_HOME" 1>&2 exit 1 fi export JAVAC="${JAVA_HOME}/bin/javac" if [ "!" -e "$JAVAC" ]; then echo "Missing JAVAC executable: ${JAVAC}" 1>&2 exit 1 fi info="info.txt" run="run" expected="expected.txt" output="out.txt" clean_on_exit="yes" dev_mode="no" update_mode="no" tmpdir=/tmp/test-$$ usage="no" while [[ "x$1" = "x-"* ]]; do case $1 in --dev) dev_mode="yes" ;; --no-clean) clean_on_exit="no" ;; --output_dir) tmpdir=$2 shift ;; --update) update_mode="yes" ;; --help) usage="yes" ;; *) usage="yes" ;; esac shift done if [ "x$1" = "x" ]; then testdir=`basename "$oldwd"` else testdir="$1" fi if [ '!' -d "$testdir" ]; then td2=`echo ${testdir}-*` if [ '!' -d "$td2" ]; then echo "${testdir}: no such test directory" 1>&2 usage="yes" fi testdir="$td2" fi if [ "$update_mode" = "yes" -a "$dev_mode" = "yes" ] ; then echo Error: --dev is incompatible with --update. 1>&2 usage="yes" fi if [ "$usage" = "yes" ]; then prog=`basename $prog` ( echo "usage:" echo " $prog --help Print this message." echo " $prog testname Run test normally." echo " $prog --dev testname Development mode (dump to stdout)." echo " $prog --update testname Update mode (replace expected.txt)." echo " Omitting the test name uses the current directory as the test." echo "options:" echo " --output_dir