blob: dc6d6d244cc7cbf61b7f93e8fda7bb6b6fbf7469 [file] [log] [blame]
Mads Ager418d1ca2017-05-22 09:35:49 +02001#!/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
7function 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.
21package com.android.tools.r8.art.${testGeneratingToolchain}.${compilerUnderTest};
22
23import static com.android.tools.r8.R8RunArtTestsTest.DexTool.${testGeneratingToolchainEnum};
24
25import com.android.tools.r8.R8RunArtTestsTest;
26import 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 */
33public 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}
46EOF
47}
48
49TESTDIR="tests/art"
50TOOLCHAINS=("dx" "jack" "none")
51DESTINATIONDIR="build/generated/test/java/com/android/tools/r8/art"
52
53if [ ! -e $TESTDIR ]; then
54 echo "Missing art tests in $TESTDIR."
55 exit
56fi
57
58for 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
75done