Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file |
| 4 | # for details. All rights reserved. Use of this source code is governed by a |
| 5 | # BSD-style license that can be found in the LICENSE file. |
| 6 | |
| 7 | function generate_test() { |
| 8 | local name=$1 |
| 9 | local testClassName=$2 |
| 10 | local testGeneratingToolchain=$3 |
| 11 | # The bash uppercase substitution ^^ is not supported on the bash version on Mac OS. |
| 12 | local testGeneratingToolchainEnum=$(echo $testGeneratingToolchain | tr /a-z/ /A-Z/) |
| 13 | local fileName=$4 |
| 14 | local compilerUnderTest=$5 |
| 15 | local compilerUnderTestEnum=$(echo ${compilerUnderTest} | tr /a-z/ /A-Z/) |
| 16 | |
| 17 | cat <<EOF > $fileName |
| 18 | // Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file |
| 19 | // for details. All rights reserved. Use of this source code is governed by a |
| 20 | // BSD-style license that can be found in the LICENSE file. |
| 21 | package com.android.tools.r8.art.${testGeneratingToolchain}.${compilerUnderTest}; |
| 22 | |
| 23 | import static com.android.tools.r8.R8RunArtTestsTest.DexTool.${testGeneratingToolchainEnum}; |
| 24 | |
| 25 | import com.android.tools.r8.R8RunArtTestsTest; |
| 26 | import org.junit.Test; |
| 27 | |
| 28 | /** |
| 29 | * Auto-generated test for the art ${name} test using the ${testGeneratingToolchain} toolchain. |
| 30 | * |
| 31 | * DO NOT EDIT THIS FILE. EDIT THE HERE DOCUMENT TEMPLATE IN scripts/create-art-tests.sh INSTEAD! |
| 32 | */ |
| 33 | public class ${testClassName} extends R8RunArtTestsTest { |
| 34 | |
| 35 | public ${testClassName}() { |
| 36 | super("${name}", ${testGeneratingToolchainEnum}); |
| 37 | } |
| 38 | |
| 39 | @Test |
| 40 | public void run${testClassName}() throws Throwable { |
| 41 | // For testing with other Art VMs than the default pass the VM version as a argument to |
| 42 | // runArtTest, e.g. runArtTest(ToolHelper.ART_4_4_4). |
| 43 | runArtTest(CompilerUnderTest.${compilerUnderTestEnum}); |
| 44 | } |
| 45 | } |
| 46 | EOF |
| 47 | } |
| 48 | |
| 49 | TESTDIR="tests/art" |
| 50 | TOOLCHAINS=("dx" "jack" "none") |
| 51 | DESTINATIONDIR="build/generated/test/java/com/android/tools/r8/art" |
| 52 | |
| 53 | if [ ! -e $TESTDIR ]; then |
| 54 | echo "Missing art tests in $TESTDIR." |
| 55 | exit |
| 56 | fi |
| 57 | |
| 58 | for TOOLCHAIN in ${TOOLCHAINS[@]}; do |
| 59 | for d in $DESTINATIONDIR/$TOOLCHAIN/r8 $DESTINATIONDIR/$TOOLCHAIN/d8; do |
| 60 | rm -rf $d |
| 61 | mkdir -p $d |
| 62 | done |
| 63 | # class files are found in the dx directory. |
| 64 | if [ "$TOOLCHAIN" == "none" ]; then |
| 65 | SOURCEDIR=${TESTDIR}/dx |
| 66 | else |
| 67 | SOURCEDIR=${TESTDIR}/${TOOLCHAIN} |
| 68 | fi |
| 69 | for TEST in ${SOURCEDIR}/*; do |
| 70 | TESTNAME=$(basename $TEST) |
| 71 | TESTCLASSNAME="Art${TESTNAME//-/_}Test" |
| 72 | generate_test $TESTNAME $TESTCLASSNAME ${TOOLCHAIN} $DESTINATIONDIR/$TOOLCHAIN/r8/$TESTCLASSNAME.java r8 |
| 73 | generate_test $TESTNAME $TESTCLASSNAME ${TOOLCHAIN} $DESTINATIONDIR/$TOOLCHAIN/d8/$TESTCLASSNAME.java d8 |
| 74 | done |
| 75 | done |