diff options
Diffstat (limited to 'jack/tests/com')
113 files changed, 14 insertions, 11465 deletions
diff --git a/jack/tests/com/android/jack/AllTests.java b/jack/tests/com/android/jack/AllTests.java index 7624b6c..68d6759 100644 --- a/jack/tests/com/android/jack/AllTests.java +++ b/jack/tests/com/android/jack/AllTests.java @@ -16,22 +16,14 @@ package com.android.jack; -import com.android.jack.analysis.dfa.reachingdefs.ReachingDefsTest; import com.android.jack.backend.dex.rop.RopRegisterManagerTest; -import com.android.jack.errorhandling.ErrorHandlingAllTests; -import com.android.jack.experimental.incremental.DependencyAllTests; import com.android.jack.ir.ast.MarkerCollectorTest; import com.android.jack.jayce.v0002.io.EscapeStringTest; -import com.android.jack.multidex.MultiDexOverflowTests; -import com.android.jack.multidex.MultiDexTests; import com.android.jack.optimizations.ExpressionSimplifierTest; -import com.android.jack.optimizations.UselessVariableCopyTest; import com.android.jack.preprocessor.PreProcessorTest; -import com.android.jack.tools.merger.MergerAllTests; import com.android.jack.tracer.TracingTest; import com.android.jack.transformations.ast.string.StringSplittingTest; import com.android.jack.transformations.cast.UselessCastRemoverTest; -import com.android.jack.transformations.flow.CompileFlowTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -43,77 +35,34 @@ import org.junit.runners.Suite.SuiteClasses; */ @RunWith(Suite.class) @SuiteClasses(value = { - AnnotationTest.class, - ArithmeticTest.class, - ArrayTest.class, - AssertionTest.class, - AssignmentTest.class, - BoxTest.class, - BridgeTest.class, - CastTest.class, com.android.jack.cfg.AllTests.class, com.android.jack.compile.androidtree.AllTests.class, com.android.jack.compile.androidtree.dalvik.AllTests.class, com.android.jack.frontend.AllTests.class, com.android.jack.gwt.AllTests.class, - com.android.jack.java7.AllTest.class, com.android.jack.shrob.AllTests.class, com.android.jack.transformations.ast.AllTests.class, - ComparisonTest.class, - CompileFlowTest.class, - CompileTimeTest.class, - ConcatTest.class, ConditionalTest.class, - ConstantTest.class, - DependencyAllTests.class, - DxTest.class, - EnumTest.class, - ErrorTest.class, - ErrorHandlingAllTests.class, EscapeStringTest.class, ExpressionSimplifierTest.class, FibonacciThreeAddressTest.class, - FieldAccessTest.class, - FieldTest.class, - FileConflictTest.class, FinallyTest.class, - FlowTest.class, - GenericTest.class, - IfTest.class, - ImplicitCastTest.class, - ImportTest.class, - InnerTest.class, - InvokesTest.class, JarjarTest.class, - LookupTest.class, MainTest.class, MarkerCollectorTest.class, - MergerAllTests.class, - MultiDexOverflowTests.class, - MultiDexTests.class, + /* MultiDexOverflowTests.class, */ + /* MultiDexTests.class, */ NoClasspathTest.class, - NoPackageTest.class, - OpcodesTest.class, - OrderTest.class, PreProcessorTest.class, - ReachingDefsTest.class, - ResourceTest.class, - ReturnTest.class, +// ReachingDefsTest.class, RopRegisterManagerTest.class, StaticValuesTest.class, StringSplittingTest.class, - SwitchesTest.class, - SynchronizeTest.class, - ThreeAddressTest.class, - ThrowsTest.class, ToolchainTest.class, - TryCatchTest.class, Types.class, UnaryTest.class, UselessCastRemoverTest.class, - UselessVariableCopyTest.class, WithPhantomTest.class, - ClasspathTest.class, TracingTest.class}) public class AllTests { } diff --git a/jack/tests/com/android/jack/AnnotationTest.java b/jack/tests/com/android/jack/AnnotationTest.java deleted file mode 100644 index cc21ce9..0000000 --- a/jack/tests/com/android/jack/AnnotationTest.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import com.android.jack.category.RedundantTests; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.File; - -/** - * JUnit test for compilation of annotation. - */ -public class AnnotationTest { - - private static final File[] BOOTCLASSPATH = TestTools.getDefaultBootclasspath(); - private static final File ANNOTATION001_PATH = - TestTools.getJackTestsWithJackFolder("annotation/test001"); - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - @Category(RedundantTests.class) - public void test001() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - ANNOTATION001_PATH)); - } - - @Test - public void test001_2() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - new File(ANNOTATION001_PATH, "Annotation2.java"))); - } - - @Test - public void test001_3() throws Exception { - TestTools.checkStructure(BOOTCLASSPATH, null, - new File(ANNOTATION001_PATH, "Annotation2.java"), false /*withDebugInfo*/); - } - - @Test - public void test001_4() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(new File[] { - new File(ANNOTATION001_PATH, "Annotation8.java"), - new File(ANNOTATION001_PATH, "Annotated2.java")})); - } - - @Test - public void test001_5() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(new File[] { - new File(ANNOTATION001_PATH, "Annotation7.java"), - new File(ANNOTATION001_PATH, "Annotated3.java")})); - } - - @Test - public void test001_13() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - new File(ANNOTATION001_PATH, "Annotation13.java"))); - } - - @Test - public void test001_OneEnum() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - new File(ANNOTATION001_PATH, "OneEnum.java"))); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - @Category(RedundantTests.class) - public void test002() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("annotation/test002"))); - } - - @Test - @Category(RedundantTests.class) - public void test003() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("annotation/test003"))); - } - - @Test - @Category(RedundantTests.class) - public void test004() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("annotation/test004"))); - } - - @Test - @Category(RedundantTests.class) - public void test005() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("annotation/test005"))); - } - - @Test - @Category(RedundantTests.class) - public void test006() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("annotation/test006"))); - } - - @Test - @Category(RedundantTests.class) - public void test007() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("annotation/test007"))); - } - - @Test - @Category(RedundantTests.class) - public void test008() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("annotation/test008"))); - } - - @Test - @Category(RedundantTests.class) - public void test009() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("annotation/test009"))); - } - - /** - * Compares annotations in dex file to a reference. - */ - - @Test - public void test001Structure() throws Exception { - AnnotationTestTools.checkStructure(BOOTCLASSPATH, - null, - ANNOTATION001_PATH, - null); - } - - @Test - public void test002Structure() throws Exception { - AnnotationTestTools.checkStructure(BOOTCLASSPATH, - null, - TestTools.getJackTestsWithJackFolder("annotation/test002"), - null); - } - - @Test - public void test003Structure() throws Exception { - AnnotationTestTools.checkStructure(BOOTCLASSPATH, - null, - TestTools.getJackTestsWithJackFolder("annotation/test003"), - null); - } - - @Test - public void test004Structure() throws Exception { - AnnotationTestTools.checkStructure(BOOTCLASSPATH, - null, - TestTools.getJackTestsWithJackFolder("annotation/test004"), - null); - } - - @Test - public void test005Structure() throws Exception { - AnnotationTestTools.checkStructure(BOOTCLASSPATH, - null, - TestTools.getJackTestsWithJackFolder("annotation/test005"), - null); - } - - @Test - public void test006Structure() throws Exception { - AnnotationTestTools.checkStructure(BOOTCLASSPATH, - null, - TestTools.getJackTestsWithJackFolder("annotation/test006"), - null); - } - - @Test - public void test007Structure() throws Exception { - AnnotationTestTools.checkStructure(BOOTCLASSPATH, - null, - TestTools.getJackTestsWithJackFolder("annotation/test007"), - null); - } - - @Test - public void test008Structure() throws Exception { - AnnotationTestTools.checkStructure(BOOTCLASSPATH, - null, - TestTools.getJackTestsWithJackFolder("annotation/test008"), - null); - } - - @Test - public void test009Structure() throws Exception { - AnnotationTestTools.checkStructure(BOOTCLASSPATH, - null, - TestTools.getJackTestsWithJackFolder("annotation/test009"), - null); - } -} diff --git a/jack/tests/com/android/jack/AnnotationTestTools.java b/jack/tests/com/android/jack/AnnotationTestTools.java deleted file mode 100644 index 6501b06..0000000 --- a/jack/tests/com/android/jack/AnnotationTestTools.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack; - -import com.android.jack.backend.dex.DexFileWriter; - -import java.io.File; -import java.io.IOException; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -/** - * Tools for annotation tests - */ -public class AnnotationTestTools { - - public static void checkStructure(@CheckForNull File[] bootclasspath, - @CheckForNull File[] classpath, @Nonnull File fileOrSourceList, - ProguardFlags[] proguardFlags) throws Exception { - - String classpathStr = TestTools.getClasspathsAsString(bootclasspath, classpath); - - File jackDex = TestTools.createTempDir("jack", "dex"); - - boolean useEcjAsRefCompiler = false; - - TestTools.compileSourceToDex(new Options(), - fileOrSourceList, - classpathStr, - jackDex, - false /* zip */, - null /* jarjarRules */, - proguardFlags, - false /* withDebugInfo */); - - Options refOptions = TestTools.buildCommandLineArgs(bootclasspath, classpath, fileOrSourceList); - - compareDexToReference(jackDex, - refOptions, - proguardFlags, - bootclasspath, - classpath, - useEcjAsRefCompiler, - null); - } - - private static void compareDexToReference(@Nonnull File jackDexFolder, - @Nonnull Options compilerArgs, - @CheckForNull ProguardFlags[] proguardFlags, - @CheckForNull File[] bootclasspath, - @CheckForNull File[] classpath, - boolean useEcjAsRefCompiler, - @CheckForNull JarJarRules jarjarRules) - throws IOException, InterruptedException, DifferenceFoundException { - - // Prepare files and directories - File testDir = TestTools.createTempDir("jacktest", null); - - File refDex = TestTools.createReferenceCompilerFiles(testDir, - compilerArgs, - proguardFlags, - bootclasspath, - classpath, - false /* withDebugInfo */, - useEcjAsRefCompiler, - jarjarRules).dexFile; - - // Compare Jack Dex file to reference - DexAnnotationsComparator comparator = new DexAnnotationsComparator(); - comparator.compare(refDex, new File(jackDexFolder, DexFileWriter.DEX_FILENAME)); - } -} diff --git a/jack/tests/com/android/jack/ArithmeticTest.java b/jack/tests/com/android/jack/ArithmeticTest.java deleted file mode 100644 index 5f64099..0000000 --- a/jack/tests/com/android/jack/ArithmeticTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of arithmetic. - */ -public class ArithmeticTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testNew001() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("arithmetic/test001"))); - } - - @Test - public void testNew002() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("arithmetic/test002"))); - } - - @Test - public void testNew003() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("arithmetic/test003"))); - } - - @Test - public void testNew004() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("arithmetic/test004"))); - } -} diff --git a/jack/tests/com/android/jack/ArrayTest.java b/jack/tests/com/android/jack/ArrayTest.java deleted file mode 100644 index 9ecd72a..0000000 --- a/jack/tests/com/android/jack/ArrayTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of field access. - */ -public class ArrayTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that a source containing new array can compile to dex file. - */ - @Test - public void testNew001() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("newarray/test001"))); - } - - /** - * Verifies that a source containing new array can compile to dex file. - */ - @Test - public void testNew002() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("newarray/test002"))); - } - - /** - * Verifies that a source containing new array can compile to dex file. - */ - @Test - public void testNew003() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("newarray/test003"))); - } - - /** - * Verifies that a source containing new array can compile to dex file. - */ - @Test - public void testNew004() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("newarray/test004"))); - } - - @Test - public void testNew005() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("newarray/test005"))); - } - - @Test - public void testArray001() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("array/test001"))); - } -} diff --git a/jack/tests/com/android/jack/AssertionTest.java b/jack/tests/com/android/jack/AssertionTest.java deleted file mode 100644 index 45b4139..0000000 --- a/jack/tests/com/android/jack/AssertionTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of static field access. - */ -public class AssertionTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can be compiled from source to dex file. - */ - @Test - public void testCompile() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("assertion/test001"))); - } - - /** - * Verifies that the test source can be compiled from source to dex file. - */ - @Test - public void testCompile2() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("assertion/test002"))); - } - - /** - * Verifies that the test source can be compiled from source to dex file. - */ - @Test - public void testCompile3() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("assertion/test003"))); - } -} diff --git a/jack/tests/com/android/jack/AssignmentTest.java b/jack/tests/com/android/jack/AssignmentTest.java deleted file mode 100644 index a234c15..0000000 --- a/jack/tests/com/android/jack/AssignmentTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of assignments tests. - */ -public class AssignmentTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("assign"))); - } -} diff --git a/jack/tests/com/android/jack/BoxTest.java b/jack/tests/com/android/jack/BoxTest.java deleted file mode 100644 index c7ba359..0000000 --- a/jack/tests/com/android/jack/BoxTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -public class BoxTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void test001() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("box/test001"))); - } - -} diff --git a/jack/tests/com/android/jack/BridgeTest.java b/jack/tests/com/android/jack/BridgeTest.java deleted file mode 100644 index 2c4577d..0000000 --- a/jack/tests/com/android/jack/BridgeTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import com.android.jack.category.ExtraTests; - -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.File; -import java.util.ArrayList; - -/** - * JUnit test for compilation of bridges. - */ -public class BridgeTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void test001() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("bridge/test001"))); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Ignore("Tree") - @Test - public void test002() throws Exception { - File[] bootclasspath = new File[]{TestTools.getFromAndroidTree( - "out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.zip"), - TestTools.getFromAndroidTree( - "out/host/common/obj/JAVA_LIBRARIES/junit4-hostdex-jack_intermediates/classes.zip")}; - TestTools.runCompilation(TestTools.buildCommandLineArgs(bootclasspath, null, - TestTools.getJackTestsWithJackFolder("bridge/test002"))); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void test003() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("bridge/test003"))); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void test004() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("bridge/test004"))); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void test005() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("bridge/test005"))); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void test006() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("bridge/test006"))); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - @Category(ExtraTests.class) - public void test007() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("bridge/test007"))); - } - - @Test - public void test008() throws Exception { - Options options = new Options(); - File srcFolder = TestTools.getJackTestsWithJackFolder("bridge/test008"); - File jackZipOfGenericPackageProtected = TestTools.createTempFile("tmpBridge", ".zip"); - - // Build jack file from GenericPackageProtected.java - TestTools.compileSourceToJack(options, new File(srcFolder, "sub/GenericPackageProtected.java"), - TestTools.getDefaultBootclasspathString(), jackZipOfGenericPackageProtected, true /* zip */ - ); - - // Build jack file from PublicExtendsGeneric.java - File jackZipOfPublicExtendsGeneric = TestTools.createTempFile("tmpBridge", ".zip"); - TestTools.compileSourceToJack(options, new File(srcFolder, "sub/PublicExtendsGeneric.java"), - TestTools.getDefaultBootclasspathString() + File.pathSeparator - + jackZipOfGenericPackageProtected.getAbsolutePath(), jackZipOfPublicExtendsGeneric, true /* zip */ - ); - - // Build dex file representing Caller.java - options = new Options(); - options.jayceImport = new ArrayList<File>(1); - options.jayceImport.add(jackZipOfPublicExtendsGeneric); - File outDexFolder = TestTools.createTempDir("tmpBridge", "dex"); - TestTools.compileSourceToDex(options, new File(srcFolder, "Caller.java"), - TestTools.getDefaultBootclasspathString(), outDexFolder, false /* zip */); - } - - @Test - public void test009() throws Exception { - TestTools.compileSourceToDex( - new Options(), - TestTools.getJackTestsWithJackFolder("bridge/test009"), - TestTools.getDefaultBootclasspathString(), - TestTools.createTempFile("bridge009", ".zip"), - true /* zip */); - } -} diff --git a/jack/tests/com/android/jack/CastTest.java b/jack/tests/com/android/jack/CastTest.java deleted file mode 100644 index 60eb9a4..0000000 --- a/jack/tests/com/android/jack/CastTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of casts. - */ -public class CastTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("cast/explicit001"))); - } - - @Test - public void implicitCast001() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("cast/implicit001"))); - } - - @Test - public void implicitCast004() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("cast/implicit004"))); - } - - @Test - public void implicitCast005() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("cast/implicit005"))); - } -} diff --git a/jack/tests/com/android/jack/ClasspathTest.java b/jack/tests/com/android/jack/ClasspathTest.java deleted file mode 100644 index 021c81e..0000000 --- a/jack/tests/com/android/jack/ClasspathTest.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import com.android.jack.library.FileType; -import com.android.jack.library.LibraryReadingException; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; -import java.io.IOException; - -public class ClasspathTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void test001() throws Exception { - File libOut = TestTools.createTempDir("ClasspathTest", "lib"); - - Options libOptions = TestTools.buildCommandLineArgs( - TestTools.getJackTestLibFolder("classpath/test001")); - libOptions.setJayceOutputDir(libOut); - TestTools.runCompilation(libOptions); - - File testOut = TestTools.createTempDir("ClasspathTest", "test"); - Options testOptions = TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("classpath/test001")); - testOptions.setJayceOutputDir(testOut); - testOptions.setClasspath(libOut.getAbsolutePath()); - TestTools.runCompilation(testOptions); - } - - @Test - public void test002() throws Exception { - File testFolder = TestTools.getJackTestFolder("classpath/test002"); - File outFolder = TestTools.createTempDir("ClasspathTest2", "2"); - - File lib1Out = new File(outFolder, "lib1"); - { - if (!lib1Out.mkdir()) { - throw new AssertionError("Failed to create dir " + lib1Out.getAbsolutePath()); - } - Options lib1Options = TestTools.buildCommandLineArgs(new File(testFolder, "lib1")); - lib1Options.setJayceOutputDir(lib1Out); - TestTools.runCompilation(lib1Options); - } - - File lib1BisOut = new File(outFolder, "lib1override"); - { - if (!lib1BisOut.mkdir()) { - throw new AssertionError("Failed to create dir " + lib1BisOut.getAbsolutePath()); - } - Options lib1BisOptions = TestTools.buildCommandLineArgs(new File(testFolder, "lib1override")); - lib1BisOptions.setJayceOutputDir(lib1BisOut); - TestTools.runCompilation(lib1BisOptions); - } - - File lib2Out = new File(outFolder, "lib2"); - { - if (!lib2Out.mkdir()) { - throw new AssertionError("Failed to create dir " + lib2Out.getAbsolutePath()); - } - Options lib2Options = TestTools.buildCommandLineArgs(new File(testFolder, "lib2")); - lib2Options.setJayceOutputDir(lib2Out); - lib2Options.setClasspath(lib1Out.getAbsolutePath()); - TestTools.runCompilation(lib2Options); - } - - { - Options testOptions = TestTools.buildCommandLineArgs(new File(testFolder, "jack")); - testOptions.setOutputDir(outFolder); - testOptions.addJayceImport(lib2Out); - testOptions.setClasspath(lib1BisOut.getAbsolutePath()); - TestTools.runCompilation(testOptions); - } - } - - @Test - public void test003() throws Exception { - File libOut = TestTools.createTempDir("ClasspathTest", "lib"); - - Options libOptions = TestTools.buildCommandLineArgs( - TestTools.getJackTestLibFolder("classpath/test003")); - libOptions.setJayceOutputDir(libOut); - TestTools.runCompilation(libOptions); - - { - // reference compilation - File testOut = TestTools.createTempDir("ClasspathTest", "test"); - Options testOptions = TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("classpath/test003")); - testOptions.setJayceOutputDir(testOut); - testOptions.setClasspath(libOut.getAbsolutePath()); - TestTools.runCompilation(testOptions); - } - - { - // delete unused inner in classpath and check we can still compile with it - boolean deleted = - new File(libOut, FileType.JAYCE.getPrefix() - + "/com/android/jack/classpath/test003/lib/HasInnersClasses$InnerToDelete.jayce") - .delete(); - Assert.assertTrue(deleted); - File testOut = TestTools.createTempDir("ClasspathTest", "test"); - Options testOptions = TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("classpath/test003")); - testOptions.setJayceOutputDir(testOut); - testOptions.setClasspath(libOut.getAbsolutePath()); - TestTools.runCompilation(testOptions); - } - } - - @Test - public void libOfLib() throws Exception { - - String defaultClasspath = TestTools.getDefaultBootclasspathString(); - File libOfLibOut = TestTools.createTempFile("libOfLibOut", ".zip"); - String testName = "liboflib/lib2"; - File sourceDir = TestTools.getJackTestsWithJackFolder(testName); - TestTools.compileSourceToJack( - new Options(), sourceDir, defaultClasspath, libOfLibOut, true); - - File libOut = TestTools.createTempFile("libOut", ".zip"); - String testName2 = "liboflib/lib"; - String classpath = defaultClasspath + File.pathSeparatorChar + libOfLibOut.getAbsolutePath(); - File sourceDir2 = TestTools.getJackTestsWithJackFolder(testName2); - TestTools.compileSourceToJack( - new Options(), sourceDir2, classpath, libOut, true); - - File mainOut = TestTools.createTempFile("mainOut", ".zip"); - String testName3 = "liboflib/main"; - classpath = defaultClasspath + File.pathSeparatorChar + libOut.getAbsolutePath(); - File sourceDir3 = TestTools.getJackTestsWithJackFolder(testName3); - TestTools.compileSourceToJack( - new Options(), sourceDir3, classpath, mainOut, true); - } - - @Test - public void testMissingClasspathEntry() throws Exception { - String defaultClasspath = TestTools.getDefaultBootclasspathString(); - File srcDir = TestTools.getJackTestsWithJackFolder("classpath/test004"); - String classpathWithMissingEntry = defaultClasspath + File.pathSeparator + - new File(srcDir, "missing.jack").getAbsolutePath(); - - File testOut = TestTools.createTempFile("ClasspathTest", "missing"); - TestTools.compileSourceToJack(new Options(), srcDir, classpathWithMissingEntry, - testOut, true); - - Options strict = new Options(); - strict.addProperty(Jack.STRICT_CLASSPATH.getName(), "true"); - try { - TestTools.compileSourceToJack(strict, srcDir, classpathWithMissingEntry, - testOut, true); - Assert.fail(); - } catch (JackAbortException e) { - Assert.assertTrue(e.getCause() instanceof LibraryReadingException); - } - } - - @Test - public void testInvalidClasspathEntry() throws Exception { - File srcDir = TestTools.getJackTestsWithJackFolder("classpath/test004"); - compileWithInvalidClasspathEntry(srcDir, new File(srcDir, "Classpath004.java")); - compileWithInvalidClasspathEntry(srcDir, new File(srcDir, "invalid.jack")); - compileWithInvalidClasspathEntry(srcDir, new File(srcDir, "notjack.zip")); - } - - private void compileWithInvalidClasspathEntry(File srcDir, File invalidJack) throws IOException, - Exception { - Assert.assertTrue(invalidJack.isFile()); - String classpathWithInvalidEntry = TestTools.getDefaultBootclasspathString() + - File.pathSeparator + invalidJack.getAbsolutePath(); - - File testOut = TestTools.createTempFile("ClasspathTest", "invalid"); - TestTools.compileSourceToJack(new Options(), srcDir, classpathWithInvalidEntry, - testOut, true); - - Options strict = new Options(); - strict.addProperty(Jack.STRICT_CLASSPATH.getName(), "true"); - try { - TestTools.compileSourceToJack(strict, srcDir, classpathWithInvalidEntry, - testOut, true); - Assert.fail(); - } catch (JackAbortException e) { - Assert.assertTrue(e.getCause() instanceof LibraryReadingException); - } - } - -} diff --git a/jack/tests/com/android/jack/ComparisonTest.java b/jack/tests/com/android/jack/ComparisonTest.java deleted file mode 100644 index e5d16e8..0000000 --- a/jack/tests/com/android/jack/ComparisonTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -import java.io.File; - -/** - * JUnit test for compilation of comparisons. - */ -@Ignore("Tree") -public class ComparisonTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compile to dex file. - */ - @Test - public void testCompile() throws Exception { - File[] bootclasspath = new File[]{TestTools.getFromAndroidTree( - "out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/classes.zip"), - TestTools.getFromAndroidTree( - "out/host/common/obj/JAVA_LIBRARIES/junit4-hostdex-jack_intermediates/classes.zip")}; - TestTools.runCompilation(TestTools.buildCommandLineArgs(bootclasspath, null, - TestTools.getJackTestsWithJackFolder("comparison/test001"))); - } -} diff --git a/jack/tests/com/android/jack/CompileTimeTest.java b/jack/tests/com/android/jack/CompileTimeTest.java deleted file mode 100644 index 6b96de4..0000000 --- a/jack/tests/com/android/jack/CompileTimeTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test compiling big class. - */ -public class CompileTimeTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testCompileClassWithALotOfFields() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("compiletime/test001"))); - } - - @Test - public void testCompileClassWithALotOfMethods() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("compiletime/test002"))); - } -} diff --git a/jack/tests/com/android/jack/ConcatTest.java b/jack/tests/com/android/jack/ConcatTest.java deleted file mode 100644 index df156fc..0000000 --- a/jack/tests/com/android/jack/ConcatTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -public class ConcatTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testCompile001() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("string/concat001"))); - } - - @Test - public void testCompile002() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("string/concat002"))); - } - - @Test - public void testCompile003() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("string/concat003"))); - } -} diff --git a/jack/tests/com/android/jack/ConditionalTest.java b/jack/tests/com/android/jack/ConditionalTest.java index 8155554..1efc659 100644 --- a/jack/tests/com/android/jack/ConditionalTest.java +++ b/jack/tests/com/android/jack/ConditionalTest.java @@ -49,45 +49,6 @@ public class ConditionalTest { ThreadConfig.setConfig(options.getConfig()); } - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("conditional/test001"))); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile2() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("conditional/test002"))); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile3() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("conditional/test003"))); - } - - @Test - public void testCompile4() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("conditional/test004"))); - } - - @Test - public void testCompile5() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("conditional/test005"))); - } - @Test public void testCompile6() throws Exception { Options options = new Options(); diff --git a/jack/tests/com/android/jack/ConstantTest.java b/jack/tests/com/android/jack/ConstantTest.java deleted file mode 100644 index bfb7404..0000000 --- a/jack/tests/com/android/jack/ConstantTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import com.android.jack.backend.dex.DexFileWriter; - -import junit.framework.Assert; - -import org.jf.dexlib.CodeItem; -import org.jf.dexlib.DexFile; -import org.jf.dexlib.Code.Instruction; -import org.jf.dexlib.Code.Opcode; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; - -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; - -public class ConstantTest { - - @Nonnull - private static final File[] BOOTCLASSPATH = TestTools.getDefaultBootclasspath(); - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testClazz() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("constant/clazz"))); - } - - @Test - public void test001() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("constant/test001"))); - } - - @Test - public void test002() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("constant/test002"))); - } - - @Test - public void test003() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("constant/test003"))); - } - - @Test - public void test004() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("constant/test004"))); - } - - @Test - public void test005() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("constant/test005"))); - - File outFolder = TestTools.createTempDir("uselessConstantInstructions", "dex"); - File out = new File(outFolder, DexFileWriter.DEX_FILENAME); - TestTools.compileSourceToDex(new Options(), - TestTools.getJackTestsWithJackFolder("constant/test005"), - TestTools.getClasspathAsString(BOOTCLASSPATH), outFolder, false); - - DexFile dexFile = new DexFile(out); - CodeItem ci = - TestTools.getEncodedMethod(dexFile, "Lcom/android/jack/constant/test005/jack/Constant005;", - "test", "()I").codeItem; - - Assert.assertEquals(7, countOpcode(ci, Opcode.CONST_4)); - } - - @Nonnegative - private int countOpcode(@Nonnull CodeItem codeItem, @Nonnull Opcode opcode) { - int countOpcode = 0; - for (Instruction inst : codeItem.getInstructions()) { - if (inst.opcode == opcode) { - countOpcode++; - } - } - return countOpcode; - } - - @Test - public void test006() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("constant/test006"))); - } - - @Test - public void test007() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("constant/test007"))); - } - - @Test - public void test008() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("constant/test008"))); - } -} diff --git a/jack/tests/com/android/jack/DebugTest.java b/jack/tests/com/android/jack/DebugTest.java deleted file mode 100644 index fccc1c6..0000000 --- a/jack/tests/com/android/jack/DebugTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -public class DebugTest { - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void test001() throws Exception { - TestTools.checkStructure( - null, null, TestTools.getJackTestsWithJackFolder("debug/test001"), true); - } - - @Test - public void test002() throws Exception { - TestTools.checkStructure( - null, null, TestTools.getJackTestsWithJackFolder("debug/test002"), true); - } - - @Test - public void test003_1() throws Exception { - Options compilerArgs = - TestTools.buildCommandLineArgs(TestTools.getJackTestsWithJackFolder("debug/test003")); - compilerArgs.emitLocalDebugInfo = true; - TestTools.runCompilation(compilerArgs); - } - - @Test - public void test003_2() throws Exception { - TestTools.checkStructure( - null, null, TestTools.getJackTestsWithJackFolder("debug/test003"), true); - } - - @Test - public void test004_1() throws Exception { - Options compilerArgs = - TestTools.buildCommandLineArgs(TestTools.getJackTestsWithJackFolder("debug/test004")); - compilerArgs.emitLocalDebugInfo = true; - TestTools.runCompilation(compilerArgs); - } - - @Test - public void test004_2() throws Exception { - TestTools.checkStructure( - null, null, TestTools.getJackTestsWithJackFolder("debug/test004"), true); - } - - @Test - public void test005() throws Exception { - TestTools.checkStructure( - null, null, TestTools.getJackTestsWithJackFolder("debug/test005"), true); - } - - @Test - @Ignore() - public void test006() throws Exception { - TestTools.checkStructure( - null, null, TestTools.getJackTestsWithJackFolder("debug/test006"), true); - } - - @Test - public void test007() throws Exception { - TestTools.checkStructure( - null, null, TestTools.getJackTestsWithJackFolder("debug/test007"), true); - } - - @Test - public void test008() throws Exception { - TestTools.checkStructure( - null, null, TestTools.getJackTestsWithJackFolder("debug/test008"), true); - } - - @Test - public void test009() throws Exception { - TestTools.checkStructure( - null, null, TestTools.getJackTestsWithJackFolder("debug/test009"), true); - } - - @Test - public void test010() throws Exception { - TestTools.checkStructure( - null, null, TestTools.getJackTestsWithJackFolder("debug/test010"), true); - } - - @Test - public void test011() throws Exception { - TestTools.checkStructure( - null, null, TestTools.getJackTestsWithJackFolder("debug/test011"), true); - } - - @Test - public void test012() throws Exception { - TestTools.checkStructure( - null, null, TestTools.getJackTestsWithJackFolder("debug/test012"), true); - } - - @Test - public void test013() throws Exception { - TestTools.checkStructure( - null, null, TestTools.getJackTestsWithJackFolder("debug/test013"), true); - } - - @Test - public void test014() throws Exception { - TestTools.checkStructure( - null, null, TestTools.getJackTestsWithJackFolder("debug/test014"), true); - } - - @Test - @Ignore("Debug comparison fails because of local variable default initialization") - public void test019() throws Exception { - TestTools.checkStructure( - null, null, TestTools.getJackTestsWithJackFolder("debug/test019"), true); - } -} diff --git a/jack/tests/com/android/jack/DxTest.java b/jack/tests/com/android/jack/DxTest.java deleted file mode 100644 index aaa875f..0000000 --- a/jack/tests/com/android/jack/DxTest.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import com.android.jack.backend.dex.DexFileWriter; - -import junit.framework.Assert; - -import org.jf.dexlib.ClassDataItem.EncodedMethod; -import org.jf.dexlib.CodeItem; -import org.jf.dexlib.DexFile; -import org.jf.dexlib.Code.Instruction; -import org.jf.dexlib.Code.Opcode; -import org.jf.dexlib.Code.Analysis.AnalyzedInstruction; -import org.jf.dexlib.Code.Analysis.MethodAnalyzer; -import org.jf.dexlib.Code.Format.Instruction23x; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -import java.io.File; - -import javax.annotation.Nonnull; - -/** - * Junit tests related to dx. - */ -public class DxTest { - - @Nonnull - private static final File[] BOOTCLASSPATH = TestTools.getDefaultBootclasspath(); - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void test() throws Exception { - TestTools.runCompilation(TestTools - .buildCommandLineArgs(TestTools.getJackTestsWithJackFolder("dx/compiler"))); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testDxOptimizer() throws Exception { - TestTools.runCompilation(TestTools - .buildCommandLineArgs(TestTools.getJackTestsWithJackFolder("dx/optimizer"))); - } - - /** - * Verify that generated dex that not contains register overlapping. - */ - @Test - public void testRegisterOverlapping002() throws Exception { - File outFolder = TestTools.createTempDir("registerOverlapping", "dex"); - File out = new File(outFolder, DexFileWriter.DEX_FILENAME); - TestTools.compileSourceToDex(new Options(), - TestTools.getJackTestsWithJackFolder("dx/overlapping"), - TestTools.getClasspathAsString(BOOTCLASSPATH), outFolder, false); - - DexFile dexFile = new DexFile(out); - EncodedMethod em = - TestTools.getEncodedMethod(dexFile, - "Lcom/android/jack/dx/overlapping/jack/Data;", "test002", - "(IJJ)J"); - - checkThatRegistersDoesNotOverlap(em); - } - - /** - * Verify that generated dex that not contains register overlapping. - */ - @Test - public void testRegisterOverlapping001() throws Exception { - File outFolder = TestTools.createTempDir("registerOverlapping", "dex"); - File out = new File(outFolder, DexFileWriter.DEX_FILENAME); - TestTools.compileSourceToDex(new Options(), - TestTools.getJackTestsWithJackFolder("dx/overlapping"), - TestTools.getClasspathAsString(BOOTCLASSPATH), outFolder, false); - - DexFile dexFile = new DexFile(out); - EncodedMethod em = - TestTools.getEncodedMethod(dexFile, - "Lcom/android/jack/dx/overlapping/jack/Data;", "test001", - "(IJJ)J"); - - checkThatRegistersDoesNotOverlap(em); - } - - /** - * Verify that generated dex contains div_int_2addr. - */ - @Test - @Ignore("Dx register allocator use div_int instead of div_int_2addr in some cases.") - public void testRegallocator() throws Exception { - File out = TestTools.createTempFile("core", ".dex"); - TestTools.compileSourceToDex(new Options(), - TestTools.getJackTestsWithJackFolder("dx/regallocator"), - TestTools.getClasspathAsString(BOOTCLASSPATH), out, false); - - DexFile dexFile = new DexFile(out); - - CodeItem ci = - TestTools.getEncodedMethod(dexFile, "Lcom/android/jack/dx/regallocator/jack/Data;", - "compute1", "(I)I").codeItem; - Assert.assertTrue(hasOpcode(ci, Opcode.DIV_INT_2ADDR)); - ci = - TestTools.getEncodedMethod(dexFile, "Lcom/android/jack/dx/regallocator/jack/Data;", - "compute2", "(I)I").codeItem; - Assert.assertTrue(hasOpcode(ci, Opcode.DIV_INT_2ADDR)); - } - - private boolean hasOpcode(@Nonnull CodeItem codeItem, @Nonnull Opcode opcode) { - for (Instruction inst : codeItem.getInstructions()) { - if (inst.opcode == opcode) { - return true; - } - } - return false; - } - - private void checkThatRegistersDoesNotOverlap(@Nonnull EncodedMethod em) { - MethodAnalyzer ma = new MethodAnalyzer(em, false, null); - for (AnalyzedInstruction ai : ma.getInstructions()) { - if (ai.getInstruction() instanceof Instruction23x) { - Instruction23x inst = (Instruction23x) ai.getInstruction(); - // Register overlaps in the following cases - // v0, v1 = ..., v1, v2 - // v0, v1 = v1, v2, ... - // v1, v2 = ..., v0, v1 - // v1, v2 = v0, v1, ... - if (inst.getRegisterA() + 1 == inst.getRegisterC() - || inst.getRegisterA() + 1 == inst.getRegisterB() - || inst.getRegisterA() == inst.getRegisterC() + 1 - || inst.getRegisterA() == inst.getRegisterB() + 1) { - Assert.fail("Register overlapping"); - } - } - } - } -} diff --git a/jack/tests/com/android/jack/EnumTest.java b/jack/tests/com/android/jack/EnumTest.java deleted file mode 100644 index 69da4b4..0000000 --- a/jack/tests/com/android/jack/EnumTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of enums. - */ -public class EnumTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compile from source to dex file. - */ - @Test - public void testCompile001() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("enums/test001"))); - } - /** - * Verifies that the test source can compile from source to dex file. - */ - @Test - public void testCompile002() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("enums/test002"))); - } - /** - * Verifies that the test source can compile from source to dex file. - */ - @Test - public void testCompile003() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("enums/test003"))); - } -} diff --git a/jack/tests/com/android/jack/ErrorTest.java b/jack/tests/com/android/jack/ErrorTest.java deleted file mode 100644 index ad0d879..0000000 --- a/jack/tests/com/android/jack/ErrorTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack; - -import com.android.jack.frontend.FrontendCompilationException; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; - -import javax.annotation.Nonnull; - -/** - * JUnit checking that compilation failed properly. - */ -public class ErrorTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testError001() throws Exception { - checkInternalCompilerException("error/test001"); - } - - @Test - public void testError002() throws Exception { - checkInternalCompilerException("error/test002"); - } - - private void checkInternalCompilerException(@Nonnull String testName) - throws Exception, IOException { - ByteArrayOutputStream baos = null; - PrintStream redirectStream = null; - try { - baos = new ByteArrayOutputStream(); - redirectStream = new PrintStream(baos); - System.setErr(redirectStream); - - TestTools.runCompilation( - TestTools.buildCommandLineArgs(TestTools.getJackTestsWithJackFolder(testName))); - Assert.fail(); - } catch (FrontendCompilationException e) { - if (baos != null && baos.toString().contains("InternalCompilerException")) { - Assert.fail(); - } - } catch (RuntimeException e) { - Assert.fail(); - } finally { - if (redirectStream != null) { - redirectStream.close(); - } - if (baos != null) { - baos.close(); - } - } - } -} diff --git a/jack/tests/com/android/jack/FibonacciThreeAddressTest.java b/jack/tests/com/android/jack/FibonacciThreeAddressTest.java index d765c05..7f188a5 100644 --- a/jack/tests/com/android/jack/FibonacciThreeAddressTest.java +++ b/jack/tests/com/android/jack/FibonacciThreeAddressTest.java @@ -16,14 +16,12 @@ package com.android.jack; -import com.android.jack.backend.dex.DexFileWriter; import com.android.jack.dx.dex.DexOptions; import com.android.jack.dx.dex.file.ClassDefItem; import com.android.jack.dx.dex.file.DexFile; import com.android.jack.ir.ast.JDefinedClassOrInterface; import com.android.jack.ir.ast.JSession; import com.android.jack.scheduling.marker.ClassDefItemMarker; -import com.android.sched.util.file.FileUtils; import junit.framework.Assert; @@ -37,9 +35,7 @@ import java.io.File; */ public class FibonacciThreeAddressTest { - private static final File[] BOOTCLASSPATH = TestTools.getDefaultBootclasspath(); - - private static final String CLASS_BINARY_NAME = "com/android/jack/fibonacci/jack/FibonacciThreeAddress"; + private static final String CLASS_BINARY_NAME = "com/android/jack/fibonacci/test001/jack/FibonacciThreeAddress"; private static final String CLASS_SIGNATURE = "L" + CLASS_BINARY_NAME + ";"; private static final String JAVA_FILENAME = "FibonacciThreeAddress.java"; private static final File JAVA_FILEPATH = TestTools.getJackTestFromBinaryName(CLASS_BINARY_NAME); @@ -89,40 +85,4 @@ public class FibonacciThreeAddressTest { Assert.assertEquals(JAVA_FILENAME, sourceFilename); } - /** - * Compiles FibonacciThreeAddress into a {@code DexFile} and compares it to a dex file created - * using a reference compiler and {@code dx}. - * @throws Exception - */ - @Test - public void testCompareFiboDexFile() throws Exception { - TestTools.checkStructure(BOOTCLASSPATH, null, JAVA_FILEPATH, false /*withDebugInfo*/); - } - - /** - * Verifies that FibonacciThreeAddress can be written to a dex file. - */ - @Test - public void testWriteFiboDexFile() throws Exception { - - File outputDir = FileUtils.getWorkingDirectory(); - Options fiboArgs = TestTools.buildCommandLineArgs(JAVA_FILEPATH); - fiboArgs.setOutputDir(outputDir); - File outputFile = new File(outputDir, DexFileWriter.DEX_FILENAME); - File outputDirectory = outputFile.getParentFile(); - FileUtils.createIfNotExists(outputDirectory); - - Jack.run(fiboArgs); - - Assert.assertTrue(outputFile.exists()); - Assert.assertTrue(outputFile.length() > 0); - } - - /** - * Verifies that FibonacciThreeAddress can compiled from source to dex file. - */ - @Test - public void testCompileFibo() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(JAVA_FILEPATH)); - } } diff --git a/jack/tests/com/android/jack/FieldAccessTest.java b/jack/tests/com/android/jack/FieldAccessTest.java deleted file mode 100644 index 2cabff5..0000000 --- a/jack/tests/com/android/jack/FieldAccessTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of field access. - */ -public class FieldAccessTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that a source containing static field access can compile to dex file. - */ - @Test - public void testStatic() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("field/static001"))); - } - - /** - * Verifies that a source containing static field access can compile to dex file. - */ - @Test - public void testStatic2() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("field/static002"))); - } - - /** - * Verifies that a source containing static field access can compile to dex file. - */ - @Test - public void testInstance() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("field/instance001"))); - } - -} diff --git a/jack/tests/com/android/jack/FieldTest.java b/jack/tests/com/android/jack/FieldTest.java deleted file mode 100644 index 910084b..0000000 --- a/jack/tests/com/android/jack/FieldTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; - -/** - * JUnit test for compilation of fields. - */ -public class FieldTest { - - private static final File[] BOOTCLASSPATH = TestTools.getDefaultBootclasspath(); - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testCompileInstance2() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("field/instance001"))); - } - - @Test - public void testCompileInstance3() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("field/instance002"))); - } - - @Test - public void testCompileInstance4() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("field/instance003"))); - } - - @Test - public void testCompileInstance5() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("field/instance004"))); - } - - @Test - public void testCompileInstance6() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("field/instance005"))); - } - - @Test - public void testCompileStatic() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("field/static003"))); - } - - /** - * Compiles StaticField.java into a {@code DexFile} and compares it to a dex file created - * using a reference compiler and {@code dx}. - */ - @Test - public void testStatic() throws Exception { - TestTools.checkStructure(BOOTCLASSPATH, null, - TestTools.getJackTestsWithJackFolder("field/static003"), false /*withDebugInfo*/); - } - - /** - * Compiles InstanceField.java into a {@code DexFile} and compares it to a dex file created - * using a reference compiler and {@code dx}. - */ - @Test - public void testInstance() throws Exception { - TestTools.checkStructure(BOOTCLASSPATH, null, - TestTools.getJackTestsWithJackFolder("field/instance005"), false /*withDebugInfo*/); - } -} diff --git a/jack/tests/com/android/jack/FileConflictTest.java b/jack/tests/com/android/jack/FileConflictTest.java deleted file mode 100644 index 91f99fa..0000000 --- a/jack/tests/com/android/jack/FileConflictTest.java +++ /dev/null @@ -1,544 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack; - -import com.android.jack.backend.jayce.ImportConflictException; -import com.android.jack.backend.jayce.JayceFileImporter; -import com.android.jack.backend.jayce.ResourceImportConflictException; -import com.android.jack.category.KnownBugs; -import com.android.jack.library.FileType; -import com.android.jack.library.JackLibrary; -import com.android.sched.util.stream.ByteStreamSucker; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -/** - * JUnit tests for resource support. - */ -public class FileConflictTest { - - @Nonnull - private static final String COMMON_PATH_001 = "com/android/jack/fileconflict/test001/jack/"; - @Nonnull - private static final String COMMON_PATH_002 = "com/android/jack/fileconflict/test002/jack/"; - @Nonnull - private static final String JACK_FILE_PATH_1 = - FileType.JAYCE.getPrefix() + "/" + COMMON_PATH_001 + "MyClass.jayce"; - @Nonnull - private static final String JACK_FILE_PATH_2 = - FileType.JAYCE.getPrefix() + "/" + COMMON_PATH_001 + "MyClass2.jayce"; - @Nonnull - private static final String JACK_FILE_PATH_3 = - FileType.JAYCE.getPrefix() + "/" + COMMON_PATH_001 + "MyClass3.jayce"; - @Nonnull - private static final String DEX_FILE_PATH_1 = - FileType.DEX.getPrefix() + "/" + COMMON_PATH_001 + "MyClass.dex"; - @Nonnull - private static final String DEX_FILE_PATH_2 = - FileType.DEX.getPrefix() + "/" + COMMON_PATH_001 + "MyClass2.dex"; - @Nonnull - private static final String DEX_FILE_PATH_3 = - FileType.DEX.getPrefix() + "/" + COMMON_PATH_001 + "MyClass3.dex"; - @Nonnull - private static final String JACK_FILE_PATH_002_1 = - FileType.JAYCE.getPrefix() + "/" + COMMON_PATH_002 + "IrrelevantForTest.jayce"; - @Nonnull - private static final String JACK_FILE_PATH_002_2 = - FileType.JAYCE.getPrefix() + "/" + COMMON_PATH_002 + "IrrelevantForTest2.jayce"; - @Nonnull - private static final String RESOURCE1_SHORTPATH = "Resource1"; - @Nonnull - private static final String RESOURCE2_SHORTPATH = "Resource2"; - @Nonnull - private static final String RESOURCE3_SHORTPATH = "Resource3"; - @Nonnull - private static final String RESOURCE1_LONGPATH = FileType.RSC.getPrefix() + "/" - + RESOURCE1_SHORTPATH; - @Nonnull - private static final String RESOURCE2_LONGPATH = FileType.RSC.getPrefix() + "/" - + RESOURCE2_SHORTPATH; - @Nonnull - private static final String RESOURCE3_LONGPATH = FileType.RSC.getPrefix() + "/" - + RESOURCE3_SHORTPATH; - - @Nonnull - private static final File TEST001_DIR = - TestTools.getJackTestsWithJackFolder("fileconflict/test001"); - - @Nonnull - private static final File TEST002_DIR = - TestTools.getJackTestsWithJackFolder("fileconflict/test002"); - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Test the behavior of Jack when importing 2 Jack folders containing conflicting Jack files, and - * outputting to a Jack folder, with no collision policy specified. - * @throws Exception - */ - @Test - public void test001a() throws Exception { - File jackOutput = TestTools.createTempDir("jackoutput", "dir"); - try { - runTest001(jackOutput, null); - Assert.fail(); - } catch (ImportConflictException e) { - } - } - - /** - * Test the behavior of Jack when importing 2 Jack folders containing conflicting Jack files, and - * outputting to a Jack folder, with the collision policy set to "fail". - * @throws Exception - */ - @Test - public void test001b() throws Exception { - File jackOutput = TestTools.createTempDir("jackoutput", "dir"); - try { - runTest001(jackOutput, "fail"); - Assert.fail(); - } catch (ImportConflictException e) { - } - } - - /** - * Test the behavior of Jack when importing 2 Jack folders containing conflicting Jack files, and - * outputting to a Jack folder, with the collision policy set to "keep-first". - * @throws Exception - */ - @Test - public void test001c() throws Exception { - File jackOutput = TestTools.createTempDir("jackoutput", "dir"); - runTest001(jackOutput, "keep-first"); - File myClass1 = new File(jackOutput, JACK_FILE_PATH_1); - File myClass2 = new File(jackOutput, JACK_FILE_PATH_2); - File myClass3 = new File(jackOutput, JACK_FILE_PATH_3); - Assert.assertTrue(myClass1.exists()); - Assert.assertTrue(myClass2.exists()); - Assert.assertTrue(myClass3.exists()); - } - - /** - * Test the behavior of Jack when importing 2 Jack folders containing conflicting resources, and - * outputting to a Jack folder, with no collision policy specified. - * @throws Exception - */ - @Test - public void test002a() throws Exception { - File jackOutput = TestTools.createTempDir("jackoutput", "dir"); - try { - runTest002(jackOutput, false /* non-zipped */, null); - Assert.fail(); - } catch (ResourceImportConflictException e) { - } - } - - /** - * Test the behavior of Jack when importing 2 Jack folders containing conflicting resources, and - * outputting to a Jack folder, with the collision policy set to "fail". - * @throws Exception - */ - @Test - public void test002b() throws Exception { - File jackOutput = TestTools.createTempDir("jackoutput", "dir"); - try { - runTest002(jackOutput, false /* non-zipped */, "fail"); - Assert.fail(); - } catch (ResourceImportConflictException e) { - } - } - - /** - * Test the behavior of Jack when importing 2 Jack folders containing conflicting resources, and - * outputting to a Jack folder, with the collision policy set to "keep-first". - * @throws Exception - */ - @Test - public void test002c() throws Exception { - File jackOutput = TestTools.createTempDir("jackoutput", "dir"); - runTest002(jackOutput, false /* non-zipped */, "keep-first"); - checkResourceContent(jackOutput, RESOURCE1_LONGPATH, "Res1"); - checkResourceContent(jackOutput, RESOURCE2_LONGPATH, "Res2"); - checkResourceContent(jackOutput, RESOURCE3_LONGPATH, "Res3"); - } - - /** - * Test the behavior of Jack when importing 2 Jack folders containing conflicting resources, and - * outputting to a Jack zip, with no collision policy specified. - * @throws Exception - */ - @Test - public void test002d() throws Exception { - File jackOutput = TestTools.createTempFile("jackoutput", ".zip"); - try { - runTest002(jackOutput, true /* zipped */, null); - Assert.fail(); - } catch (ResourceImportConflictException e) { - } - } - - /** - * Test the behavior of Jack when importing 2 Jack folders containing conflicting resources, and - * outputting to a Jack zip, with the collision policy set to "fail". - * @throws Exception - */ - @Test - public void test002e() throws Exception { - File jackOutput = TestTools.createTempFile("jackoutput", ".zip"); - try { - runTest002(jackOutput, true /* zipped */, "fail"); - Assert.fail(); - } catch (ResourceImportConflictException e) { - } - } - - /** - * Test the behavior of Jack when importing 2 Jack folders containing conflicting resources, and - * outputting to a Jack zip, with the collision policy set to "keep-first". - * @throws Exception - */ - @Test - public void test002f() throws Exception { - File jackOutput = TestTools.createTempFile("jackoutput", ".zip"); - runTest002(jackOutput, true /* zipped */, "keep-first"); - ZipFile zipFile = new ZipFile(jackOutput); - checkResourceContent(zipFile, RESOURCE1_LONGPATH, "Res1"); - checkResourceContent(zipFile, RESOURCE2_LONGPATH, "Res2"); - checkResourceContent(zipFile, RESOURCE3_LONGPATH, "Res3"); - } - - /** - * Test the behavior of Jack when outputting a Jack file to a Jack folder where a Jack file of the - * same name already exists. We expect the previous file to be overridden. - * @throws Exception - */ - @Test - public void test003a() throws Exception { - File jackOutput = TestTools.createTempDir("jackoutput", "dir"); - - // compile source files to a Jack dir - File testSrcDir = TestTools.getJackTestsWithJackFolder("fileconflict/test003"); - File tempJackFolder = TestTools.createTempDir("jack", "dir"); - TestTools.compileSourceToJack(new Options(), testSrcDir, - TestTools.getDefaultBootclasspathString(), tempJackFolder, false /* non-zipped */); - - // get paths for Jack files - String jackFilePath = - FileType.JAYCE.getPrefix() + "/com/android/jack/fileconflict/test003/jack/MyClass.jayce"; - File myClass1 = new File(tempJackFolder, jackFilePath); - - // get paths for Dex files - String dexFilePath = - FileType.DEX.getPrefix() + "/com/android/jack/fileconflict/test003/jack/MyClass.dex"; - File myClass1Dex = new File(tempJackFolder, dexFilePath); - - String libPropName = JackLibrary.LIBRARY_PROPERTIES_VPATH.getPathAsString('/'); - File libProperties = new File(tempJackFolder, libPropName); - - // create Jack dirs to import - File jackImport1 = TestTools.createTempDir("jackimport1", "dir"); - copyFileToDir(libProperties, libPropName, jackImport1); - copyFileToDir(myClass1, jackFilePath, jackImport1); - copyFileToDir(myClass1Dex, dexFilePath, jackImport1); - - // copy Jack file to output dir - copyFileToDir(myClass1, jackFilePath, jackOutput); - copyFileToDir(myClass1Dex, dexFilePath, jackOutput); - - // run Jack on Jack dir - ProguardFlags flags = new ProguardFlags(new File(testSrcDir, "proguard.flags")); - TestTools.shrobJackToJack(new Options(), - jackImport1, - null, - jackOutput, - Collections.singletonList(flags), - false /* non-zipped */); - } - - /** - * Test the behavior of Jack when outputting a resource to a Jack folder where a file of the - * same name already exists. We expect the previous file to be overridden. - * @throws Exception - */ - @Test - @Ignore("Now jack generate library, a previous file can not exists") - public void test003b() throws Exception { - File jackOutput = TestTools.createTempDir("jackoutput", "dir"); - - // compile source files to a Jack dir - File testSrcDir = TestTools.getJackTestsWithJackFolder("fileconflict/test003"); - File tempJackFolder = TestTools.createTempDir("jack", "dir"); - TestTools.compileSourceToJack(new Options(), testSrcDir, - TestTools.getDefaultBootclasspathString(), tempJackFolder, false /* non-zipped */); - - // get paths for Jack files - String jackFilePath = - FileType.JAYCE.getPrefix() + "/com/android/jack/fileconflict/test003/jack/MyClass.jayce"; - File myClass1 = new File(tempJackFolder, jackFilePath); - - String libPropName = JackLibrary.LIBRARY_PROPERTIES_VPATH.getPathAsString('/'); - File libProperties = new File(tempJackFolder, libPropName); - - // create Jack dirs to import - File jackImport1 = TestTools.createTempDir("jackimport1", "dir"); - String resourcePath = "com/android/jack/fileconflict/test003/jack/Resource"; - File resource = new File(testSrcDir, "Resource"); - copyFileToDir(libProperties, libPropName, jackImport1); - copyFileToDir(myClass1, jackFilePath, jackImport1); - copyFileToDir(resource, resourcePath, jackImport1); - - // copy a different resource to output dir with the same name - File resource2 = new File(testSrcDir, "Resource2"); - copyFileToDir(resource2, resourcePath, jackOutput); - - // run Jack on Jack dir - ProguardFlags flags = new ProguardFlags(new File(testSrcDir, "proguard.flags")); - TestTools.shrobJackToJack(new Options(), - jackImport1, - null, - jackOutput, - Collections.singletonList(flags), - false /* non-zipped */); - - checkResourceContent(jackOutput, resourcePath, "Res1"); - } - - /** - * Test the behavior of Jack when renaming a Jack file along with the resource with a matching - * name, and when a resource with the same name (after renaming) already exists. - * @throws Exception - */ - @Test - @Category(KnownBugs.class) - public void test004() throws Exception { - File jackOutput = TestTools.createTempDir("jackoutput", "dir"); - - // compile source files to a Jack dir - File testSrcDir = TestTools.getJackTestsWithJackFolder("fileconflict/test004"); - File tempJackFolder = TestTools.createTempDir("jack", "dir"); - TestTools.compileSourceToJack(new Options(), testSrcDir, - TestTools.getDefaultBootclasspathString(), tempJackFolder, false /* non-zipped */); - - // get paths for Jack files - String jackFilePath = - FileType.JAYCE.getPrefix() + "/com/android/jack/fileconflict/test004/jack/MyClass.jayce"; - File myClass1 = new File(tempJackFolder, jackFilePath); - - String libPropName = JackLibrary.LIBRARY_PROPERTIES_VPATH.getPathAsString('/'); - File libProperties = new File(tempJackFolder, libPropName); - - // create Jack dirs to import - File jackImport1 = TestTools.createTempDir("jackimport1", "dir"); - File resource = new File(testSrcDir, "MyClass.txt"); - copyFileToDir(libProperties, libPropName, jackImport1); - copyFileToDir(myClass1, jackFilePath, jackImport1); - copyFileToDir(resource, "com/android/jack/fileconflict/test004/jack/MyClass.txt", jackImport1); - System.out.println(jackImport1.getAbsolutePath()); - - // copy a different resource to output dir with the same name - File resource2 = new File(testSrcDir, "a.txt"); - copyFileToDir(resource2, "pcz/nbqfcvq/wnpx/svyrpcbsyvph/hrgh004/wnpx/ZmPyngg.txt", jackOutput); - System.out.println(jackOutput.getAbsolutePath()); - Options options = new Options(); - options.setNameProvider("rot13"); - - // run Jack on Jack dir - ProguardFlags flags = new ProguardFlags(new File(testSrcDir, "proguard.flags")); - TestTools.shrobJackToJack(options, - jackImport1, - TestTools.getDefaultBootclasspathString(), - jackOutput, - Collections.singletonList(flags), - false /* non-zipped */); - checkResourceContent(jackOutput, "pcz/nbqfcvq/wnpx/svyrpcbsyvph/hrgh004/wnpx/ZmPyngg.txt", - "MyClass"); - } - - private void runTest001(@Nonnull File jackOutput, @CheckForNull String collisionPolicy) - throws Exception { - // compile source files to a Jack dir - File tempJackFolder = TestTools.createTempDir("jack", "dir"); - TestTools.compileSourceToJack(new Options(), TEST001_DIR, - TestTools.getDefaultBootclasspathString(), tempJackFolder, false /* non-zipped */); - - // get paths for Jack files - File myClass1 = new File(tempJackFolder, JACK_FILE_PATH_1); - File myClass2 = new File(tempJackFolder, JACK_FILE_PATH_2); - File myClass3 = new File(tempJackFolder, JACK_FILE_PATH_3); - - // get paths for dex files - File myClass1Dex = new File(tempJackFolder, DEX_FILE_PATH_1); - File myClass2Dex = new File(tempJackFolder, DEX_FILE_PATH_2); - File myClass3Dex = new File(tempJackFolder, DEX_FILE_PATH_3); - - String libPropName = JackLibrary.LIBRARY_PROPERTIES_VPATH.getPathAsString('/'); - File libProperties = new File(tempJackFolder, libPropName); - - // create Jack dirs to import - File jackImport1 = TestTools.createTempDir("jackimport1", "dir"); - File jackImport2 = TestTools.createTempDir("jackimport2", "dir"); - copyFileToDir(libProperties, libPropName, jackImport1); - copyFileToDir(myClass1, JACK_FILE_PATH_1, jackImport1); - copyFileToDir(myClass1Dex, DEX_FILE_PATH_1, jackImport1); - copyFileToDir(myClass2, JACK_FILE_PATH_2, jackImport1); - copyFileToDir(myClass2Dex, DEX_FILE_PATH_2, jackImport1); - copyFileToDir(libProperties, libPropName, jackImport2); - copyFileToDir(myClass1, JACK_FILE_PATH_1, jackImport2); - copyFileToDir(myClass1Dex, DEX_FILE_PATH_1, jackImport2); - copyFileToDir(myClass3, JACK_FILE_PATH_3, jackImport2); - copyFileToDir(myClass3Dex, DEX_FILE_PATH_3, jackImport2); - - // run Jack on Jack dirs - ProguardFlags flags = new ProguardFlags(new File(TEST001_DIR, "proguard.flags")); - Options options = new Options(); - List<File> jayceImports = new ArrayList<File>(2); - jayceImports.add(jackImport1); - jayceImports.add(jackImport2); - options.setJayceImports(jayceImports); - options.setProguardFlagsFile(Collections.<File>singletonList(flags)); - options.setJayceOutputDir(jackOutput); - if (collisionPolicy != null) { - options.addProperty(JayceFileImporter.COLLISION_POLICY.getName(), collisionPolicy); - } - Jack.run(options); - } - - private void runTest002(@Nonnull File jackOutput, boolean zip, - @CheckForNull String collisionPolicy) throws Exception { - // compile source files to a Jack dir - File jackImport1 = TestTools.createTempDir("jack", "dir"); - Options options = new Options(); - File lib1 = new File(TEST002_DIR, "lib1"); - options.addResource(new File(lib1, "rsc")); - TestTools.compileSourceToJack(options, lib1, TestTools.getDefaultBootclasspathString(), - jackImport1, false /* non-zipped */); - - File jackImport2 = TestTools.createTempDir("jack", "dir"); - options = new Options(); - File lib2 = new File(TEST002_DIR, "lib2"); - options.addResource(new File(lib2, "rsc")); - TestTools.compileSourceToJack(options, lib2, TestTools.getDefaultBootclasspathString(), - jackImport2, false /* non-zipped */); - - // run Jack on Jack dirs - ProguardFlags flags = new ProguardFlags(new File(TEST002_DIR, "proguard.flags")); - options = new Options(); - List<File> jayceImports = new ArrayList<File>(2); - jayceImports.add(jackImport1); - jayceImports.add(jackImport2); - options.setJayceImports(jayceImports); - options.setProguardFlagsFile(Collections.<File>singletonList(flags)); - if (zip) { - options.setJayceOutputZip(jackOutput); - } else { - options.setJayceOutputDir(jackOutput); - } - if (collisionPolicy != null) { - options.addProperty(JayceFileImporter.RESOURCE_COLLISION_POLICY.getName(), collisionPolicy); - } - Jack.run(options); - } - - private void copyFileToDir(@Nonnull File fileToCopy, @Nonnull String relativePath, - @Nonnull File dir) throws IOException { - FileOutputStream fos = null; - FileInputStream fis = null; - try { - fis = new FileInputStream(fileToCopy); - File copiedFile = new File(dir, relativePath); - File parentDir = copiedFile.getParentFile(); - if (!parentDir.exists()) { - boolean res = parentDir.mkdirs(); - if (!res) { - throw new AssertionError(); - } - } - try { - fos = new FileOutputStream(copiedFile); - ByteStreamSucker sucker = new ByteStreamSucker(fis, fos); - sucker.suck(); - } finally { - if (fos != null) { - fos.close(); - } - } - } finally { - if (fis != null) { - fis.close(); - } - } - } - - private void checkResourceContent(@Nonnull File dir, @Nonnull String path, - @Nonnull String expectedContent) throws IOException { - assert dir.isDirectory(); - File file = new File(dir, path); - Assert.assertTrue(file.exists()); - BufferedReader reader = null; - try { - InputStream in = new FileInputStream(file); - reader = new BufferedReader(new InputStreamReader(in)); - String line = reader.readLine(); - Assert.assertEquals(expectedContent, line); - } finally { - if (reader != null) { - reader.close(); - } - } - } - - private void checkResourceContent(@Nonnull ZipFile zipFile, @Nonnull String entryName, - @Nonnull String expectedContent) throws IOException { - ZipEntry entry = zipFile.getEntry(entryName); - Assert.assertNotNull(entry); - BufferedReader reader = null; - try { - InputStream in = zipFile.getInputStream(entry); - reader = new BufferedReader(new InputStreamReader(in)); - String line = reader.readLine(); - Assert.assertEquals(expectedContent, line); - } finally { - if (reader != null) { - reader.close(); - } - } - } -} diff --git a/jack/tests/com/android/jack/FinallyTest.java b/jack/tests/com/android/jack/FinallyTest.java index 900a90b..479adba 100644 --- a/jack/tests/com/android/jack/FinallyTest.java +++ b/jack/tests/com/android/jack/FinallyTest.java @@ -46,50 +46,6 @@ public class FinallyTest { } @Test - public void testCompileBranching() throws Exception { - TestTools.runCompilation( - TestTools.buildCommandLineArgs(new File[] { - new File(PATH, "B.java"), - new File(PATH, "Branching.java")})); - } - - @Test - public void testCompileCatch() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - new File(PATH, "Catch.java"))); - } - - @Test - public void testCompileEmptyBlocks() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - new File(PATH, "EmptyBlocks.java"))); - } - - @Test - public void testCompileNested() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - new File(PATH, "Nested.java"))); - } - - @Test - public void testCompile002() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("tryfinally/finally002"))); - } - - @Test - public void testCompile003() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("tryfinally/finally003"))); - } - - @Test - public void testCompile004() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("tryfinally/finally004"))); - } - - @Test public void testCompile005() throws Exception { String classBinaryName = "com/android/jack/tryfinally/finally005/jack/Finally005"; String methodSignature = "get()V"; diff --git a/jack/tests/com/android/jack/FlowTest.java b/jack/tests/com/android/jack/FlowTest.java deleted file mode 100644 index a757013..0000000 --- a/jack/tests/com/android/jack/FlowTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2013 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of flow tests. - */ -public class FlowTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testCfg001() throws Exception { - TestTools.runCompilation( - TestTools.buildCommandLineArgs(TestTools.getJackTestsWithJackFolder("flow/cfg001"))); - } -} diff --git a/jack/tests/com/android/jack/GenericTest.java b/jack/tests/com/android/jack/GenericTest.java deleted file mode 100644 index 53922f8..0000000 --- a/jack/tests/com/android/jack/GenericTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of generics. - */ -public class GenericTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compile from source to dex file. - */ - @Test - public void testCompileBasic() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("generic/basic"))); - } -} diff --git a/jack/tests/com/android/jack/IfTest.java b/jack/tests/com/android/jack/IfTest.java deleted file mode 100644 index 1839bbf..0000000 --- a/jack/tests/com/android/jack/IfTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of if statements. - */ -public class IfTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testCompileSimple() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("ifstatement/simpleTest"))); - } - - @Test - public void testCompileAdvanced() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("ifstatement/advancedTest"))); - } - - @Test - public void testCompileCfg() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("ifstatement/cfgTest"))); - } - - @Test - public void testFastPath() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("ifstatement/fastpath"))); - } -} diff --git a/jack/tests/com/android/jack/ImplicitCastTest.java b/jack/tests/com/android/jack/ImplicitCastTest.java deleted file mode 100644 index a9d34d0..0000000 --- a/jack/tests/com/android/jack/ImplicitCastTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of static field access. - */ -public class ImplicitCastTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compile from source to dex file. - */ - @Test - public void testCompile001() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("cast/implicit001"))); - } - /** - * Verifies that the test source can compile from source to dex file. - */ - @Test - public void testCompile002() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("cast/implicit002"))); - } - /** - * Verifies that the test source can compile from source to dex file. - */ - @Test - public void testCompile003() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("cast/implicit003"))); - } - /** - * Verifies that the test source can compile from source to dex file. - */ - @Test - public void testCompile004() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("cast/implicit004"))); - } - /** - * Verifies that the test source can compile from source to dex file. - */ - @Test - public void testCompile006() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("cast/implicit006"))); - } -} diff --git a/jack/tests/com/android/jack/ImportTest.java b/jack/tests/com/android/jack/ImportTest.java deleted file mode 100644 index ca93858..0000000 --- a/jack/tests/com/android/jack/ImportTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack; - -import com.android.jack.backend.jayce.ImportConflictException; -import com.android.jack.backend.jayce.JayceFileImporter; -import com.android.jack.backend.jayce.TypeImportConflictException; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; - -public class ImportTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testCompileNonConflictingSourceAndImport() throws Exception { - File jackOut = TestTools.createTempDir("importtest", "dir"); - Options options = - TestTools.buildCommandLineArgs(TestTools.getJackTestsWithJackFolder("fibonacci")); - options.libraryOutDir = jackOut; - TestTools.runCompilation(options); - - Options importOptions = - TestTools.buildCommandLineArgs(TestTools.getJackTestsWithJackFolder("threeaddress")); - importOptions.jayceImport.add(jackOut); - TestTools.runCompilation(importOptions); - } - - @Test - public void testCompileConflictingSourceAndImport() throws Exception { - File jackOut = TestTools.createTempDir("importtest", "dir"); - Options options = - TestTools.buildCommandLineArgs(TestTools.getJackTestsWithJackFolder("fibonacci")); - options.libraryOutDir = jackOut; - TestTools.runCompilation(options); - - Options conflictOptions = - TestTools.buildCommandLineArgs(TestTools.getJackTestsWithJackFolder("fibonacci")); - conflictOptions.jayceImport.add(jackOut); - try { - TestTools.runCompilation(conflictOptions); - Assert.fail(); - } catch (ImportConflictException e) { - // expected - } - } - - @Test - public void testConflictingImport() throws Exception { - String testName = "inner/test015"; - File lib = TestTools.createTempDir("inner15Lib", ""); - TestTools.compileSourceToJack( - new Options(), - TestTools.getJackTestLibFolder(testName), - TestTools.getDefaultBootclasspathString(), - lib, - false); - - Options options = new Options(); - options.addJayceImport(lib); - // import twice the same lib - options.addJayceImport(lib); - - options.addProperty(JayceFileImporter.COLLISION_POLICY.getName(), "keep-first"); - TestTools.compileSourceToDex( - options, - TestTools.getJackTestsWithJackFolder(testName), - TestTools.getDefaultBootclasspathString(), - TestTools.createTempFile("inner15", ".zip"), true); - - } - - @Test - public void testConflictingImportWithFailPolicy1() throws Exception { - String testName = "inner/test015"; - File lib = TestTools.createTempDir("inner15Lib", ""); - TestTools.compileSourceToJack( - new Options(), - TestTools.getJackTestLibFolder(testName), - TestTools.getDefaultBootclasspathString(), - lib, - false); - - Options options = new Options(); - options.addJayceImport(lib); - // import twice the same lib - options.addJayceImport(lib); - - options.addProperty(JayceFileImporter.COLLISION_POLICY.getName(), "fail"); - - try { - TestTools.compileSourceToDex(options, TestTools.getJackTestsWithJackFolder(testName), - TestTools.getDefaultBootclasspathString(), TestTools.createTempFile("inner15", ".zip"), - true); - Assert.fail(); - } catch (TypeImportConflictException e) { - // Exception is ok - } - } - - @Test - public void testConflictingImportWithFailPolicy2() throws Exception { - String testName = "inner/test015"; - File lib1 = TestTools.createTempDir("inner15Lib1", ""); - TestTools.compileSourceToJack( - new Options(), - TestTools.getJackTestLibFolder(testName), - TestTools.getDefaultBootclasspathString(), - lib1, - false); - - File lib2 = TestTools.createTempDir("inner15Lib2", ""); - TestTools.compileSourceToJack( - new Options(), - TestTools.getJackTestLibFolder(testName), - TestTools.getDefaultBootclasspathString(), - lib2, - false); - - Options options = new Options(); - options.addJayceImport(lib1); - // import twice the same lib - options.addJayceImport(lib2); - - options.addProperty(JayceFileImporter.COLLISION_POLICY.getName(), "fail"); - - try { - TestTools.compileSourceToDex(options, TestTools.getJackTestsWithJackFolder(testName), - TestTools.getDefaultBootclasspathString(), TestTools.createTempFile("inner15", ".zip"), - true); - Assert.fail(); - } catch (TypeImportConflictException e) { - // Exception is ok - } - } -} diff --git a/jack/tests/com/android/jack/InnerTest.java b/jack/tests/com/android/jack/InnerTest.java deleted file mode 100644 index 5362c39..0000000 --- a/jack/tests/com/android/jack/InnerTest.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import com.android.jack.category.RedundantTests; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.File; - -public class InnerTest { - - private static final File[] BOOTCLASSPATH = TestTools.getDefaultBootclasspath(); - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testCompile() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test001"))); - } - - @Test - public void testCompile2() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test002"))); - } - - @Test - public void testCompile3() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test003"))); - } - - @Test - public void testCompile4() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test004"))); - } - - @Test - public void testCompile5() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test005"))); - } - - @Test - public void testCompile6() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test006"))); - } - - @Test - public void testCompile7() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test007"))); - } - - @Test - public void testCompile8() throws Exception { - String testName = "inner/test008"; - TestTools.runCompilation(TestTools.buildCommandLineArgs(new File[] { - TestTools.getJackTestsWithJackFolder(testName), - TestTools.getJackTestLibFolder(testName)})); - } - - @Test - public void testCompile9() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test009"))); - } - - @Test - public void testCompile10() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test010"))); - } - - @Test - public void testCompile11() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test011"))); - } - - @Test - public void testCompile12() throws Exception { - String testName = "inner/test012"; - TestTools.runCompilation(TestTools.buildCommandLineArgs(new File[] { - TestTools.getJackTestsWithJackFolder(testName), - TestTools.getJackTestLibFolder(testName)})); - } - - @Test - public void testCompile13() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test013"))); - } - - @Test - public void testCompile14() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test014"))); - } - - @Test - public void testCompile15() throws Exception { - String testName = "inner/test015"; - TestTools.runCompilation(TestTools.buildCommandLineArgs(new File[] { - TestTools.getJackTestsWithJackFolder(testName), - TestTools.getJackTestLibFolder(testName)})); - } - - @Test - public void testCompile16() throws Exception { - String testName = "inner/test016"; - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder(testName))); - } - - @Test - public void testCompile17() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test017"))); - } - - @Test - public void testCompile18() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test018"))); - } - - @Test - public void testCompile19() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test019"))); - } - - @Test - @Category(RedundantTests.class) - public void testCompile20() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test020"))); - } - - @Test - public void testCheckStructure20() throws Exception { - //TODO: find out why debug info check fails - TestTools.checkStructure(BOOTCLASSPATH, null, - TestTools.getJackTestsWithJackFolder("inner/test020"), false /*withDebugInfo*/); - } - - @Test - @Category(RedundantTests.class) - public void testCompile21() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test021"))); - } - - @Test - public void testCheckStructure21() throws Exception { - TestTools.checkStructure(BOOTCLASSPATH, null, - TestTools.getJackTestsWithJackFolder("inner/test021"), false /*withDebugInfo*/); - } - - @Test - public void testCompile22() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test022"))); - } - - @Test - public void testCompile23() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test023"))); - } - - @Test - public void testCompile24() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test024"))); - } - - @Test - public void testCompile25() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("inner/test025"))); - } -} diff --git a/jack/tests/com/android/jack/InvokesTest.java b/jack/tests/com/android/jack/InvokesTest.java deleted file mode 100644 index 1c18e57..0000000 --- a/jack/tests/com/android/jack/InvokesTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; - -/** - * JUnit test for compilation of invoke tests. - */ -public class InvokesTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("invoke/test001"))); - } - - @Test - public void testCompile002() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("invoke/test002"))); - } - - @Test - public void testCompile003() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("invoke/test003"))); - } - - @Test - public void testCompile004() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("invoke/test004"))); - } - - @Test - public void testCompile005() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(new File[] { - TestTools.getJackTestsWithJackFolder("invoke/test005"), - TestTools.getJackTestLibFolder("invoke/test005")})); - } - - @Test - public void testCompile006() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("invoke/test006"))); - } - - @Test - public void testCompile007() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("invoke/test007"))); - } -} diff --git a/jack/tests/com/android/jack/JarjarTest.java b/jack/tests/com/android/jack/JarjarTest.java index df45ada..0ca1b4c 100644 --- a/jack/tests/com/android/jack/JarjarTest.java +++ b/jack/tests/com/android/jack/JarjarTest.java @@ -16,7 +16,6 @@ package com.android.jack; -import com.android.jack.category.RedundantTests; import com.tonicsystems.jarjar.PackageRemapper; import com.tonicsystems.jarjar.PatternElement; import com.tonicsystems.jarjar.Rule; @@ -26,9 +25,7 @@ import junit.framework.Assert; import org.junit.BeforeClass; import org.junit.Test; -import org.junit.experimental.categories.Category; -import java.io.File; import java.util.Collections; import javax.annotation.Nonnull; @@ -51,42 +48,6 @@ public class JarjarTest { } @Test - public void test001() throws Exception { - String testName = "jarjar/test001"; - Options ecjArgs = TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder(testName), - new File(TestTools.getJackTestFolder(testName), "jarjar-rules.txt")); - TestTools.runCompilation(ecjArgs); - } - - @Test - @Category(RedundantTests.class) - public void test003() throws Exception { - String testName = "jarjar/test003"; - Options ecjArgs = TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder(testName), - new File(TestTools.getJackTestFolder(testName), "jarjar-rules.txt")); - TestTools.runCompilation(ecjArgs); - } - - @Test - public void test003_1() throws Exception { - String testName = "jarjar/test003"; - Options options = new Options(); - options.jarjarRulesFile = new File(TestTools.getJackTestFolder(testName), "jarjar-rules.txt"); - File lib = TestTools.createTempFile("jarjarTest003Jack", ".zip"); - TestTools.compileSourceToJack(options, TestTools.getJackTestsWithJackFolder(testName), - TestTools.getDefaultBootclasspathString(), lib, true); - TestTools.compileSourceToJack(new Options(), - new File(TestTools.getJackTestFolder(testName), - "dontcompile/TestWithRelocatedReference.java"), - TestTools.getDefaultBootclasspathString() + File.pathSeparator + lib.getAbsolutePath(), - TestTools.createTempFile("jarjarTest003dx", ".zip"), - true); - - } - - @Test public void testMapValue() { assertUnchangedValue("[^\\s;/@&=,.?:+$]"); assertUnchangedValue("[Ljava/lang/Object;"); diff --git a/jack/tests/com/android/jack/LookupTest.java b/jack/tests/com/android/jack/LookupTest.java deleted file mode 100644 index 283510e..0000000 --- a/jack/tests/com/android/jack/LookupTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack; - -import org.junit.Test; - -import java.io.File; - -public class LookupTest { - - @Test - public void test001() throws Exception { - File lib = TestTools.createTempDir("Lookup001Lib", ""); - TestTools.compileSourceToJack( - new Options(), - TestTools.getJackTestLibFolder("lookup/test001"), - TestTools.getDefaultBootclasspathString(), - lib, - false); - - File libOverride = TestTools.createTempDir("Lookup001LibOverride", ""); - TestTools.compileSourceToJack( - new Options(), - new File(TestTools.getJackTestFolder("lookup/test001"), "liboverride"), - TestTools.getDefaultBootclasspathString(), - libOverride, - false); - - File jacks = TestTools.createTempDir("Lookup001Jacks", ""); - TestTools.compileSourceToJack( - new Options(), - TestTools.getJackTestsWithJackFolder("lookup/test001"), - TestTools.getDefaultBootclasspathString() + File.pathSeparator + lib.getAbsolutePath(), - jacks, - false); - - Options options = new Options(); - options.addJayceImport(jacks); - options.addJayceImport(libOverride); - options.outZip = TestTools.createTempFile("Lookup001", ".zip"); - Jack.run(options); - } - -} diff --git a/jack/tests/com/android/jack/MainTest.java b/jack/tests/com/android/jack/MainTest.java index 625aea3..0750edf 100644 --- a/jack/tests/com/android/jack/MainTest.java +++ b/jack/tests/com/android/jack/MainTest.java @@ -29,7 +29,7 @@ import org.junit.Test; */ public class MainTest { - private static final String CLASS_BINARY_NAME = "com/android/jack/fibonacci/jack/Fibo"; + private static final String CLASS_BINARY_NAME = "com/android/jack/fibonacci/test001/jack/Fibo"; private static final String CLASS_SIGNATURE = "L" + CLASS_BINARY_NAME + ";"; @BeforeClass @@ -39,16 +39,6 @@ public class MainTest { } /** - * Verifies that a call to {link Main#runCompilation(String[])} complete - * without throwing exception. - */ - @Test - public void testRunCompilation() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestFromBinaryName(CLASS_BINARY_NAME))); - } - - /** * Verifies that Fibo can be loaded in J-AST. */ @Test diff --git a/jack/tests/com/android/jack/NoPackageTest.java b/jack/tests/com/android/jack/NoPackageTest.java deleted file mode 100644 index 56ba35e..0000000 --- a/jack/tests/com/android/jack/NoPackageTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; - -public class NoPackageTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void test001() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("nopackage"))); - } - - @Test - public void test001_throughJayce() throws Exception { - File tmpDir = TestTools.createTempDir("NoPackageTest", "dir"); - - String testName = "nopackage"; - String classpath = TestTools.getDefaultBootclasspathString(); - File sourceDir = TestTools.getJackTestsWithJackFolder(testName); - TestTools.compileSourceToJack( - new Options(), sourceDir, classpath, tmpDir, false); - File tmpDexFolder = TestTools.createTempDir("NoPackageTest", "dex"); - TestTools.compileJackToDex(new Options(), tmpDir, tmpDexFolder, false); - } - -} diff --git a/jack/tests/com/android/jack/OpcodesTest.java b/jack/tests/com/android/jack/OpcodesTest.java deleted file mode 100644 index 25ae4c4..0000000 --- a/jack/tests/com/android/jack/OpcodesTest.java +++ /dev/null @@ -1,558 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; -import org.junit.BeforeClass; -import org.junit.Test; -/** - * JUnit test for compilation of arithmetic tests. - */ -public class OpcodesTest { - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testCompile_add_double() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("add_double"))); - } - - @Test - public void testCompile_float_to_long() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("float_to_long"))); - } - - @Test - public void testCompile_array_length() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("array_length"))); - } - - @Test - public void testCompile_sub_double() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("sub_double"))); - } - - @Test - public void testCompile_int_to_short() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("int_to_short"))); - } - - @Test - public void testCompile_aput() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("aput"))); - } - - @Test - public void testCompile_if_gez() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("if_gez"))); - } - - @Test - public void testCompile_check_cast() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("check_cast"))); - } - - @Test - public void testCompile_cmpl_double() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("cmpl_double"))); - } - - @Test - public void testCompile_double_to_int() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("double_to_int"))); - } - - @Test - public void testCompile_int_to_byte() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("int_to_byte"))); - } - - @Test - public void testCompile_shl_int() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("shl_int"))); - } - - @Test - public void testCompile_long_to_double() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("long_to_double"))); - } - - @Test - public void testCompile_if_ge() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("if_ge"))); - } - - @Test - public void testCompile_opc_new() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("opc_new"))); - } - - @Test - public void testCompile_add_float() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("add_float"))); - } - - @Test - public void testCompile_cmp_long() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("cmp_long"))); - } - - @Test - public void testCompile_opc_instanceof() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("opc_instanceof"))); - } - - @Test - public void testCompile_int_to_char() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("int_to_char"))); - } - - @Test - public void testCompile_aget_short() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("aget_short"))); - } - - @Test - public void testCompile_and_int() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("and_int"))); - } - - @Test - public void testCompile_if_eqz() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("if_eqz"))); - } - - @Test - public void testCompile_opc_goto() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("opc_goto"))); - } - - @Test - public void testCompile_if_gtz() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("if_gtz"))); - } - - @Test - public void testCompile_or_int() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("or_int"))); - } - - @Test - public void testCompile_int_to_double() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("int_to_double"))); - } - - @Test - public void testCompile_xor_long() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("xor_long"))); - } - - @Test - public void testCompile_rem_int() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("rem_int"))); - } - - @Test - public void testCompile_opc_throw() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("opc_throw"))); - } - - @Test - public void testCompile_shr_long() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("shr_long"))); - } - - @Test - public void testCompile_cmpg_double() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("cmpg_double"))); - } - - @Test - public void testCompile_mul_double() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("mul_double"))); - } - - @Test - public void testCompile_cmpg_float() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("cmpg_float"))); - } - - @Test - public void testCompile_mul_int() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("mul_int"))); - } - - @Test - public void testCompile_neg_float() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("neg_float"))); - } - - @Test - public void testCompile_div_double() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("div_double"))); - } - - @Test - public void testCompile_monitor_enter() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("monitor_enter"))); - } - - @Test - public void testCompile_and_long() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("and_long"))); - } - - @Test - public void testCompile_if_ltz() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("if_ltz"))); - } - - @Test - public void testCompile_sparse_switch() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("sparse_switch"))); - } - - @Test - public void testCompile_sget() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("sget"))); - } - - @Test - public void testCompile_ushr_long() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("ushr_long"))); - } - - @Test - public void testCompile_const_wide() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("const_wide"))); - } - - @Test - public void testCompile_aget() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("aget"))); - } - - @Test - public void testCompile_iput() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("iput"))); - } - - @Test - public void testCompile_sput() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("sput"))); - } - - @Test - public void testCompile_return_object() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("return_object"))); - } - - @Test - public void testCompile_invoke_virtual() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("invoke_virtual"))); - } - - @Test - public void testCompile_aget_object() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("aget_object"))); - } - - @Test - public void testCompile_neg_double() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("neg_double"))); - } - - @Test - public void testCompile_int_to_float() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("int_to_float"))); - } - - @Test - public void testCompile_invoke_static() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("invoke_static"))); - } - - @Test - public void testCompile_rem_long() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("rem_long"))); - } - - @Test - public void testCompile_aget_wide() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("aget_wide"))); - } - - @Test - public void testCompile_float_to_double() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("float_to_double"))); - } - - @Test - public void testCompile_if_lt() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("if_lt"))); - } - - @Test - public void testCompile_double_to_float() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("double_to_float"))); - } - - @Test - public void testCompile_double_to_long() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("double_to_long"))); - } - - @Test - public void testCompile_return_wide() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("return_wide"))); - } - - @Test - public void testCompile_add_long() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("add_long"))); - } - - @Test - public void testCompile_shl_long() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("shl_long"))); - } - - @Test - public void testCompile_aput_byte() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("aput_byte"))); - } - - @Test - public void testCompile_aget_char() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("aget_char"))); - } - - @Test - public void testCompile_const4_16() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("const4_16"))); - } - - @Test - public void testCompile_sub_int() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("sub_int"))); - } - - @Test - public void testCompile_neg_long() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("neg_long"))); - } - - @Test - public void testCompile_opc_return() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("opc_return"))); - } - - @Test - public void testCompile_sub_long() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("sub_long"))); - } - - @Test - public void testCompile_long_to_float() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("long_to_float"))); - } - - @Test - public void testCompile_if_le() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("if_le"))); - } - - @Test - public void testCompile_aget_byte() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("aget_byte"))); - } - - @Test - public void testCompile_iget() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("iget"))); - } - - @Test - public void testCompile_aput_char() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("aput_char"))); - } - - @Test - public void testCompile_int_to_long() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("int_to_long"))); - } - - @Test - public void testCompile_div_float() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("div_float"))); - } - - @Test - public void testCompile_if_nez() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("if_nez"))); - } - - @Test - public void testCompile_div_int() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("div_int"))); - } - - @Test - public void testCompile_float_to_int() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("float_to_int"))); - } - - @Test - public void testCompile_long_to_int() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("long_to_int"))); - } - - @Test - public void testCompile_cmpl_float() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("cmpl_float"))); - } - - @Test - public void testCompile_shr_int() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("shr_int"))); - } - - @Test - public void testCompile_if_eq() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("if_eq"))); - } - - @Test - public void testCompile_add_int() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("add_int"))); - } - - @Test - public void testCompile_or_long() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("or_long"))); - } - - @Test - public void testCompile_mul_long() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("mul_long"))); - } - - @Test - public void testCompile_if_lez() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("if_lez"))); - } - - @Test - public void testCompile_sub_float() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("sub_float"))); - } - - @Test - public void testCompile_rem_double() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("rem_double"))); - } - - @Test - public void testCompile_neg_int() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("neg_int"))); - } - - @Test - public void testCompile_aput_wide() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("aput_wide"))); - } - - @Test - public void testCompile_div_long() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("div_long"))); - } - - @Test - public void testCompile_xor_int() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("xor_int"))); - } - - @Test - public void testCompile_aput_object() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("aput_object"))); - } - - @Test - public void testCompile_new_array() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("new_array"))); - } - - @Test - public void testCompile_aput_short() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("aput_short"))); - } - - @Test - public void testCompile_invoke_direct() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("invoke_direct"))); - } - - @Test - public void testCompile_invoke_super() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("invoke_super"))); - } - - @Test - public void testCompile_if_ne() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("if_ne"))); - } - - @Test - public void testCompile_rem_float() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("rem_float"))); - } - - @Test - public void testCompile_ushr_int() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("ushr_int"))); - } - - @Test - public void testCompile_invoke_interface() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("invoke_interface"))); - } - - @Test - public void testCompile_mul_float() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("mul_float"))); - } - - @Test - public void testCompile_if_gt() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("if_gt"))); - } - - @Test - public void testCompile_packed_switch() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("packed_switch"))); - } - - @Test - public void testCompile_const_string() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("const_string"))); - } - - @Test - public void testCompile_opc_const() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getOpcodeTestFolder("opc_const"))); - } -} diff --git a/jack/tests/com/android/jack/OrderTest.java b/jack/tests/com/android/jack/OrderTest.java deleted file mode 100644 index ca4c872..0000000 --- a/jack/tests/com/android/jack/OrderTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of evaluation order tests. - */ -public class OrderTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getJackTestsWithJackFolder("order"))); - } -} diff --git a/jack/tests/com/android/jack/ResourceTest.java b/jack/tests/com/android/jack/ResourceTest.java deleted file mode 100644 index b42ae80..0000000 --- a/jack/tests/com/android/jack/ResourceTest.java +++ /dev/null @@ -1,419 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack; - -import com.android.jack.category.KnownBugs; -import com.android.jack.library.FileType; -import com.android.sched.util.stream.ByteStreamSucker; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.StringReader; -import java.util.Collections; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import javax.annotation.Nonnull; - -/** - * JUnit tests for resource support. - */ -public class ResourceTest { - - @Nonnull - private static final String COMMON_PATH = "com/android/jack/resource/test001/jack/"; - @Nonnull - private static final String JACK_FILE_PATH = FileType.JAYCE.getPrefix() + "/" + COMMON_PATH - + "IrrelevantForTest.jayce"; - @Nonnull - private static final String DEX_FILE_PATH = FileType.DEX.getPrefix() + "/" + COMMON_PATH - + "IrrelevantForTest.dex"; - @Nonnull - private static final String RESOURCE1_SHORTPATH = "Resource1"; - @Nonnull - private static final String RESOURCE2_SHORTPATH = "Resource2"; - @Nonnull - private static final String RESOURCE3_SHORTPATH = "pack/Resource3"; - @Nonnull - private static final String RESOURCE4_SHORTPATH = "pack/Resource4"; - @Nonnull - private static final File FILE = - TestTools.getJackTestsWithJackFolder("resource/test001"); - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testJackArchiveToDexDir() throws Exception { - // compile source file to a Jack archive and add resources - File jackAr = createJackArchiveWithResources(); - - // compile Jack archive to a dex dir - File dexDir = TestTools.createTempDir("resourcetestdex", "dir"); - TestTools.compileJackToDex(new Options(), jackAr, dexDir, false /* zipped */); - - // check that resources are contained in dex dir - checkResourceContentFromDir(dexDir, RESOURCE1_SHORTPATH, "Res1", /*isLib*/ false); - checkResourceContentFromDir(dexDir, RESOURCE2_SHORTPATH, "Res2", /*isLib*/ false); - checkResourceContentFromDir(dexDir, RESOURCE3_SHORTPATH, "Res3", /*isLib*/ false); - checkResourceContentFromDir(dexDir, RESOURCE4_SHORTPATH, "Res4", /*isLib*/ false); - } - - @Test - public void testJackArchiveToDexArchive() throws Exception { - // compile source file to a Jack archive and add resources - File jackAr = createJackArchiveWithResources(); - - // compile Jack archive to dex archive - File dexAr = TestTools.createTempFile("resourcetestdex", ".zip"); - TestTools.compileJackToDex(new Options(), jackAr, dexAr, true /* zipped */); - - // check that resources are contained in dex archive - ZipFile zipFile = new ZipFile(dexAr); - checkResourceContentFromZip(zipFile, RESOURCE1_SHORTPATH, "Res1", /*isLib*/ false); - checkResourceContentFromZip(zipFile, RESOURCE2_SHORTPATH, "Res2", /*isLib*/ false); - checkResourceContentFromZip(zipFile, RESOURCE3_SHORTPATH, "Res3", /*isLib*/ false); - checkResourceContentFromZip(zipFile, RESOURCE4_SHORTPATH, "Res4", /*isLib*/ false); - } - - @Test - public void testJackDirToDexArchive() throws Exception { - // compile source file to a Jack dir - File jackFolder = TestTools.createTempDir("tempjack", "dir"); - Options options = new Options(); - options.addResource(new File(FILE, "rsc")); - TestTools.compileSourceToJack(options, FILE, TestTools.getDefaultBootclasspathString(), - jackFolder, false /* non-zipped */); - - // compile Jack dir to dex archive - File dexAr = TestTools.createTempFile("resourcetestdex", ".zip"); - TestTools.compileJackToDex(new Options(), jackFolder, dexAr, true /* zipped */); - - // check that resources are contained in dex archive - ZipFile zipFile = new ZipFile(dexAr); - checkResourceContentFromZip(zipFile, RESOURCE1_SHORTPATH, "Res1", /*isLib*/ false); - checkResourceContentFromZip(zipFile, RESOURCE2_SHORTPATH, "Res2", /*isLib*/ false); - checkResourceContentFromZip(zipFile, RESOURCE3_SHORTPATH, "Res3", /*isLib*/ false); - checkResourceContentFromZip(zipFile, RESOURCE4_SHORTPATH, "Res4", /*isLib*/ false); - } - - @Test - public void testJackArchiveToJackArchive() throws Exception { - // compile source file to a Jack archive and add resources - File jackAr = createJackArchiveWithResources(); - - // run shrobbing from Jack archive to Jack archive - File shrobbedJackAr = TestTools.createTempFile("shrobbedJackAr", ".zip"); - ProguardFlags flags = new ProguardFlags(new File(FILE, "proguard.flags")); - TestTools.shrobJackToJack(new Options(), - jackAr, - null /* classpath */, - shrobbedJackAr, - Collections.singletonList(flags), - true /* zipped */); - - // check that resources are contained in dex archive - ZipFile zipFile = new ZipFile(shrobbedJackAr); - checkResourceContentFromZip(zipFile, RESOURCE1_SHORTPATH, "Res1", /*isLib*/ true); - checkResourceContentFromZip(zipFile, RESOURCE2_SHORTPATH, "Res2", /*isLib*/ true); - checkResourceContentFromZip(zipFile, RESOURCE3_SHORTPATH, "Res3", /*isLib*/ true); - checkResourceContentFromZip(zipFile, RESOURCE4_SHORTPATH, "Res4", /*isLib*/ true); - } - - @Test - public void testJackDirToJackArchive() throws Exception { - // compile source file to a Jack dir - File jackFolder = TestTools.createTempDir("tempjack", "dir"); - Options options = new Options(); - options.addResource(new File(FILE, "rsc")); - TestTools.compileSourceToJack(options, FILE, TestTools.getDefaultBootclasspathString(), - jackFolder, false /* non-zipped */); - - // run shrobbing from Jack dir to Jack archive - File shrobbedJackAr = TestTools.createTempFile("shrobbedJackAr", ".zip"); - ProguardFlags flags = new ProguardFlags(new File(FILE, "proguard.flags")); - TestTools.shrobJackToJack(new Options(), - jackFolder, - null /* classpath */, - shrobbedJackAr, - Collections.singletonList(flags), - true /* zipped */); - - // check that resources are contained in Jack archive - ZipFile zipFile = new ZipFile(shrobbedJackAr); - checkResourceContentFromZip(zipFile, RESOURCE1_SHORTPATH, "Res1", /*isLib*/ true); - checkResourceContentFromZip(zipFile, RESOURCE2_SHORTPATH, "Res2", /*isLib*/ true); - checkResourceContentFromZip(zipFile, RESOURCE3_SHORTPATH, "Res3", /*isLib*/ true); - checkResourceContentFromZip(zipFile, RESOURCE4_SHORTPATH, "Res4", /*isLib*/ true); - } - - @Test - public void testJackArchiveToJackDir() throws Exception { - // compile source file to a Jack archive and add resources - File jackAr = createJackArchiveWithResources(); - - // run shrobbing from Jack archive to Jack dir - File shrobbedJackDir = TestTools.createTempDir("shrobbedJack", "dir"); - ProguardFlags flags = new ProguardFlags(new File(FILE, "proguard.flags")); - TestTools.shrobJackToJack(new Options(), - jackAr, - null /* classpath */, - shrobbedJackDir, - Collections.singletonList(flags), - false /* non-zipped */); - - // check that resources are contained in Jack dir - checkResourceContentFromDir(shrobbedJackDir, RESOURCE1_SHORTPATH, "Res1", /*isLib*/ true); - checkResourceContentFromDir(shrobbedJackDir, RESOURCE2_SHORTPATH, "Res2", /*isLib*/ true); - checkResourceContentFromDir(shrobbedJackDir, RESOURCE3_SHORTPATH, "Res3", /*isLib*/ true); - checkResourceContentFromDir(shrobbedJackDir, RESOURCE4_SHORTPATH, "Res4", /*isLib*/ true); - } - - @Test - public void testJackDirToJackDir() throws Exception { - /// compile source file to a Jack dir - File jackFolder = TestTools.createTempDir("tempjack", "dir"); - Options options = new Options(); - options.addResource(new File(FILE, "rsc")); - TestTools.compileSourceToJack(options, FILE, TestTools.getDefaultBootclasspathString(), - jackFolder, false /* non-zipped */); - - // run shrobbing from Jack dir to Jack dir - File shrobbedJackDir = TestTools.createTempDir("shrobbedJack", "dir"); - ProguardFlags flags = new ProguardFlags(new File(FILE, "proguard.flags")); - TestTools.shrobJackToJack(new Options(), - jackFolder, - null /* classpath */, - shrobbedJackDir, - Collections.singletonList(flags), - false /* non-zipped */); - - // check that resources are contained in Jack dir - checkResourceContentFromDir(shrobbedJackDir, RESOURCE1_SHORTPATH, "Res1", /*isLib*/ true); - checkResourceContentFromDir(shrobbedJackDir, RESOURCE2_SHORTPATH, "Res2", /*isLib*/ true); - checkResourceContentFromDir(shrobbedJackDir, RESOURCE3_SHORTPATH, "Res3", /*isLib*/ true); - checkResourceContentFromDir(shrobbedJackDir, RESOURCE4_SHORTPATH, "Res4", /*isLib*/ true); - } - - @Test - public void testJackDirToDexDir() throws Exception { - // compile source file to a Jack dir - File jackFolder = TestTools.createTempDir("tempjack", "dir"); - Options options = new Options(); - options.addResource(new File(FILE, "rsc")); - TestTools.compileSourceToJack(options, FILE, TestTools.getDefaultBootclasspathString(), - jackFolder, false /* non-zipped */); - - // compile Jack dir to a dex dir - File dexDir = TestTools.createTempDir("resourcetestdex", "dir"); - TestTools.compileJackToDex(new Options(), jackFolder, dexDir, false /* zipped */); - - // check that resources are contained in dex dir - checkResourceContentFromDir(dexDir, RESOURCE1_SHORTPATH, "Res1", /*isLib*/ false); - checkResourceContentFromDir(dexDir, RESOURCE2_SHORTPATH, "Res2", /*isLib*/ false); - checkResourceContentFromDir(dexDir, RESOURCE3_SHORTPATH, "Res3", /*isLib*/ false); - checkResourceContentFromDir(dexDir, RESOURCE4_SHORTPATH, "Res4", /*isLib*/ false); - } - - @Test - @Category(KnownBugs.class) - public void testJackToDexInSameDir() throws Exception { - // compile source file to a Jack dir - File jackFolder = TestTools.createTempDir("tempjack", "dir"); - Options options = new Options(); - options.addResource(new File(FILE, "rsc")); - TestTools.compileSourceToJack(options, FILE, TestTools.getDefaultBootclasspathString(), - jackFolder, false /* non-zipped */); - - // compile Jack dir to same dir - File dexDir = jackFolder; - TestTools.compileJackToDex(new Options(), jackFolder, dexDir, false /* zipped */); - - // check that resources are contained in dex dir - checkResourceContentFromDir(dexDir, RESOURCE1_SHORTPATH, "Res1", /*isLib*/ false); - checkResourceContentFromDir(dexDir, RESOURCE2_SHORTPATH, "Res2", /*isLib*/ false); - checkResourceContentFromDir(dexDir, RESOURCE3_SHORTPATH, "Res3", /*isLib*/ false); - checkResourceContentFromDir(dexDir, RESOURCE4_SHORTPATH, "Res4", /*isLib*/ false); - } - - @Test - @Category(KnownBugs.class) - public void testResourceContentAdaptation() throws Exception { - /// compile source file to a Jack dir - File jackOutputFolder = TestTools.createTempDir("tempjack", "dir"); - String testName = "resource/test003"; - File testFolder = TestTools.getJackTestFolder(testName); - File jackTestFolder = TestTools.getJackTestsWithJackFolder(testName); - TestTools.compileSourceToJack(new Options(), testFolder, TestTools.getDefaultBootclasspathString(), - jackOutputFolder, false /* non-zipped */); - - String resource1LongPath = "com/android/jack/resource/test003/jack/A"; - String resource2LongPath = "com/android/jack/resource/test003/jack/A.txt"; - - // add resources to Jack dir - copyFileToDir(new File(jackTestFolder, "A.txt"), resource1LongPath, jackOutputFolder); - copyFileToDir(new File(jackTestFolder, "A.txt"), resource2LongPath, jackOutputFolder); - - // run shrobbing from Jack dir to Jack dir - Options options = new Options(); - options.setNameProvider("rot13"); - File shrobbedJackDir = TestTools.createTempDir("shrobbedJack", "dir"); - ProguardFlags flags = new ProguardFlags(new File(testFolder, "proguard.flags001")); - TestTools.shrobJackToJack(options, - jackOutputFolder, - TestTools.getDefaultBootclasspathString(), - shrobbedJackDir, - Collections.singletonList(flags), - false /* non-zipped */); - - // check that resources are contained in Jack dir and check their contents - File referenceFileContent = new File(testFolder, "refs/A.txt"); - checkResourceContent(new File(shrobbedJackDir, "pcz/nbqfcvq/wnpx/frgcifpr/hrgh003/wnpx/A"), - referenceFileContent); - checkResourceContent(new File(shrobbedJackDir, "pcz/nbqfcvq/wnpx/frgcifpr/hrgh003/wnpx/N.txt"), - referenceFileContent); - } - - @Nonnull - private File createJackArchiveWithResources() throws Exception { - // compile source file to a Jack file - //File tempJackFolder = TestTools.createTempDir("jack", "dir"); - File jackAr = TestTools.createTempFile("resourcetestjack", ".zip"); - Options options = new Options(); - options.addResource(new File(FILE, "rsc")); - TestTools.compileSourceToJack(options, FILE, TestTools.getDefaultBootclasspathString(), - jackAr, true /* non-zipped */); - - return jackAr; - } - - private void checkResourceContentFromZip(@Nonnull ZipFile zipFile, @Nonnull String entryName, - @Nonnull String expectedContent, boolean isLib) throws IOException { - ZipEntry entry = zipFile.getEntry((isLib ? FileType.RSC.getPrefix() + '/' : "") + entryName); - Assert.assertNotNull(entry); - BufferedReader candidateReader = null; - BufferedReader referenceReader = null; - try { - InputStream in = zipFile.getInputStream(entry); - candidateReader = new BufferedReader(new InputStreamReader(in)); - referenceReader = new BufferedReader(new StringReader(expectedContent)); - compareReadLines(referenceReader, candidateReader); - } finally { - if (candidateReader != null) { - candidateReader.close(); - } - if (referenceReader != null) { - referenceReader.close(); - } - } - } - - private void checkResourceContentFromDir(@Nonnull File dir, @Nonnull String path, - @Nonnull String expectedContent, boolean isLib) throws IOException { - assert dir.isDirectory(); - File file = new File(isLib ? new File(dir, FileType.RSC.getPrefix()) : dir, path); - Assert.assertTrue(file.exists()); - BufferedReader candidateReader = null; - BufferedReader referenceReader = null; - try { - InputStream in = new FileInputStream(file); - candidateReader = new BufferedReader(new InputStreamReader(in)); - referenceReader = new BufferedReader(new StringReader(expectedContent)); - compareReadLines(referenceReader, candidateReader); - } finally { - if (candidateReader != null) { - candidateReader.close(); - } - if (referenceReader != null) { - referenceReader.close(); - } - } - } - - private void checkResourceContent(@Nonnull File candidateFileContent, - @Nonnull File referenceFileContent) throws IOException { - Assert.assertTrue(candidateFileContent.exists()); - BufferedReader candidateReader = null; - BufferedReader referenceReader = null; - try { - candidateReader = new BufferedReader(new InputStreamReader(new FileInputStream(candidateFileContent))); - referenceReader = new BufferedReader(new InputStreamReader(new FileInputStream(referenceFileContent))); - compareReadLines(referenceReader, candidateReader); - } finally { - if (candidateReader != null) { - candidateReader.close(); - } - if (referenceReader != null) { - referenceReader.close(); - } - } - } - - private void compareReadLines(@Nonnull BufferedReader referenceReader, - @Nonnull BufferedReader candidateReader) throws IOException { - String referenceLine = referenceReader.readLine(); - while (referenceLine != null) { - String candidateLine = candidateReader.readLine(); - Assert.assertEquals(referenceLine, candidateLine); - referenceLine = referenceReader.readLine(); - } - Assert.assertNull(candidateReader.readLine()); - } - - private void copyFileToDir(@Nonnull File fileToCopy, @Nonnull String relativePath, - @Nonnull File dir) throws IOException { - FileOutputStream fos = null; - FileInputStream fis = null; - try { - fis = new FileInputStream(fileToCopy); - File copiedFile = new File(dir, relativePath); - File parentDir = copiedFile.getParentFile(); - if (!parentDir.exists()) { - boolean res = parentDir.mkdirs(); - if (!res) { - throw new AssertionError(); - } - } - try { - fos = new FileOutputStream(copiedFile); - ByteStreamSucker sucker = new ByteStreamSucker(fis, fos); - sucker.suck(); - } finally { - if (fos != null) { - fos.close(); - } - } - } finally { - if (fis != null) { - fis.close(); - } - } - } -} diff --git a/jack/tests/com/android/jack/ReturnTest.java b/jack/tests/com/android/jack/ReturnTest.java deleted file mode 100644 index 3916dbb..0000000 --- a/jack/tests/com/android/jack/ReturnTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of return. - */ -public class ReturnTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompileReturnVoid() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("returnstatement/returnvoid"))); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompileReturns() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("returnstatement/returns"))); - } -} diff --git a/jack/tests/com/android/jack/SwitchesTest.java b/jack/tests/com/android/jack/SwitchesTest.java deleted file mode 100644 index 7e92046..0000000 --- a/jack/tests/com/android/jack/SwitchesTest.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import com.android.jack.backend.dex.DexFileWriter; - -import junit.framework.Assert; - -import org.jf.dexlib.ClassDataItem.EncodedMethod; -import org.jf.dexlib.DexFile; -import org.jf.dexlib.Code.Analysis.AnalyzedInstruction; -import org.jf.dexlib.Code.Analysis.MethodAnalyzer; -import org.jf.dexlib.Code.Format.PackedSwitchDataPseudoInstruction; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nonnull; - -/** - * JUnit test for compilation of static field access. - */ -public class SwitchesTest { - - @Nonnull - private static final File[] BOOTCLASSPATH = TestTools.getDefaultBootclasspath(); - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testCompile1() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("switchstatement/test001"))); - } - - @Test - public void testCompile2() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("switchstatement/test002"))); - } - - - @Test - public void testCompile2AsJackThenDex() throws Exception { - File outJackTmp = TestTools.createTempDir("switchstatement2", ".jayce"); - try { - - { - // build as jack - Options options = TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("switchstatement/test002")); - options.setJayceOutputDir(outJackTmp); - TestTools.runCompilation(options); - } - - { - // build dex from jack - - File emptySource = new File("Empty.java"); - if (!emptySource.exists()) { - if (!emptySource.createNewFile()) { - throw new AssertionError("Failed to create " + emptySource.getAbsolutePath()); - } - } - - Options options = TestTools.buildCommandLineArgs(null, null, emptySource); - List<File> l = new ArrayList<File>(); - l.add(outJackTmp); - options.setJayceImports(l); - TestTools.runCompilation(options); - } - } catch (Exception e) { - System.err.println("Not deleting temp files of failed test in " + - outJackTmp.getAbsolutePath()); - throw e; - } - } - - @Test - public void testCompile3() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("switchstatement/test003"))); - } - - @Test - public void testCompile4() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("switchstatement/test004"))); - } - - @Test - public void testCompile7() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("switchstatement/test007"))); - } - - @Test - public void testCompile8() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("switchstatement/test008"))); - } - - /** - * Test allowing to check that 'packed-switch-payload' into generated dex is as small as possible. - */ - @Test - public void testCompile9() throws Exception { - File outFolder = TestTools.createTempDir("packedSwitchPayloadTest", "dex"); - File out = new File(outFolder, DexFileWriter.DEX_FILENAME); - - TestTools.compileSourceToDex(new Options(), - TestTools.getJackTestsWithJackFolder("switchstatement/test009"), - TestTools.getClasspathAsString(BOOTCLASSPATH), outFolder, false); - - DexFile dexFile = new DexFile(out); - EncodedMethod em = - TestTools.getEncodedMethod(dexFile, - "Lcom/android/jack/switchstatement/test009/jack/Switch;", "switch1", - "(Lcom/android/jack/switchstatement/test009/jack/Switch$Num;)Z"); - - MethodAnalyzer ma = new MethodAnalyzer(em, false, null); - boolean packedSwitchDataPseudo = false; - for (AnalyzedInstruction ai : ma.getInstructions()) { - if (ai.getInstruction() instanceof PackedSwitchDataPseudoInstruction) { - packedSwitchDataPseudo = true; - Assert.assertEquals(5, - ((PackedSwitchDataPseudoInstruction) ai.getInstruction()).getTargetCount()); - } - } - - Assert.assertTrue(packedSwitchDataPseudo); - } - - - @Test - public void testCompile10() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("switchstatement/test010"))); - } -} diff --git a/jack/tests/com/android/jack/SynchronizeTest.java b/jack/tests/com/android/jack/SynchronizeTest.java deleted file mode 100644 index 988eec2..0000000 --- a/jack/tests/com/android/jack/SynchronizeTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; - -/** - * JUnit test for compilation of synchronize tests. - */ -public class SynchronizeTest { - private static final File FILE = - TestTools.getJackTestsWithJackFolder("synchronize/test001"); - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(FILE)); - } -} diff --git a/jack/tests/com/android/jack/TestTools.java b/jack/tests/com/android/jack/TestTools.java index dd6393b..6bfe6f1 100644 --- a/jack/tests/com/android/jack/TestTools.java +++ b/jack/tests/com/android/jack/TestTools.java @@ -21,7 +21,6 @@ import com.android.jack.Options.VerbosityLevel; import com.android.jack.backend.dex.DexFileWriter; import com.android.jack.backend.dex.IntermediateDexProduct; import com.android.jack.backend.jayce.JayceFormatProduct; -import com.android.jack.dx.dex.file.DexFile; import com.android.jack.ir.ast.JDefinedClassOrInterface; import com.android.jack.ir.ast.JMethod; import com.android.jack.ir.ast.JSession; @@ -1015,9 +1014,10 @@ public class TestTools { private static void compileWithEcj(Options compilerArgs, File out) { List<String> jackEcjArgs = getRefCompilerArguments(compilerArgs); - String[] args = new String[jackEcjArgs.size() + 4]; + String[] args = new String[jackEcjArgs.size() + 5]; int i = 0; args[i++] = "-noExit"; + args[i++] = "-1.6"; args[i++] = "-preserveAllLocals"; for (String compilerArg : jackEcjArgs) { args[i++] = compilerArg; diff --git a/jack/tests/com/android/jack/ThreeAddressTest.java b/jack/tests/com/android/jack/ThreeAddressTest.java deleted file mode 100644 index 8d10c33..0000000 --- a/jack/tests/com/android/jack/ThreeAddressTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of three address tests. - */ -public class ThreeAddressTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getJackTestsWithJackFolder("threeaddress"))); - } -} diff --git a/jack/tests/com/android/jack/ThrowsTest.java b/jack/tests/com/android/jack/ThrowsTest.java deleted file mode 100644 index c919f69..0000000 --- a/jack/tests/com/android/jack/ThrowsTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of throws. - */ -public class ThrowsTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("throwstatement/test001"))); - } -} diff --git a/jack/tests/com/android/jack/TryCatchTest.java b/jack/tests/com/android/jack/TryCatchTest.java deleted file mode 100644 index 54d3156..0000000 --- a/jack/tests/com/android/jack/TryCatchTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack; - -import junit.framework.Assert; - -import org.jf.dexlib.CodeItem; -import org.jf.dexlib.DexFile; -import org.jf.dexlib.Code.Instruction; -import org.jf.dexlib.Code.Opcode; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -import java.io.File; - -import javax.annotation.Nonnull; - -/** - * JUnit test for compilation of try/catch. - */ -public class TryCatchTest { - - @Nonnull - private static final File[] BOOTCLASSPATH = TestTools.getDefaultBootclasspath(); - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("trycatch/test001"))); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile2() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("trycatch/test002"))); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile3() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("trycatch/test003"))); - } - - @Test - public void testCompile5() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("trycatch/test005"))); - } - - /** - * Verify that generated dex does not contains useless 'mov' instructions. - */ - @Test - @Ignore("Generated dex contains useless 'mov' instructions") - public void uselessMovInstructions() throws Exception { - File out = TestTools.createTempFile("uselessMovInstructions", ".dex"); - TestTools.compileSourceToDex(new Options(), - TestTools.getJackTestsWithJackFolder("trycatch/test004"), - TestTools.getClasspathAsString(BOOTCLASSPATH), out, false); - - DexFile dexFile = new DexFile(out); - CodeItem ci = - TestTools.getEncodedMethod(dexFile, "Lcom/android/jack/trycatch/test004/jack/TryCatch;", - "setIconAndText", "(IIILjava/lang/String;II)V").codeItem; - - Assert.assertFalse(hasOpcode(ci, Opcode.MOVE_OBJECT)); - } - - private boolean hasOpcode(@Nonnull CodeItem codeItem, @Nonnull Opcode opcode) { - for (Instruction inst : codeItem.getInstructions()) { - if (inst.opcode == opcode) { - return true; - } - } - return false; - } -} diff --git a/jack/tests/com/android/jack/TryWithResourcesTest.java b/jack/tests/com/android/jack/TryWithResourcesTest.java deleted file mode 100644 index c340539..0000000 --- a/jack/tests/com/android/jack/TryWithResourcesTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of try-with-resources. - */ -public class TryWithResourcesTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile() throws Exception { - Options options = TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("java7/trywithresources/test001")); - options.addProperty(Options.JAVA_SOURCE_VERSION.getName(), "1.7"); - TestTools.runCompilation(options); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile2() throws Exception { - Options options = TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("java7/trywithresources/test002")); - options.addProperty(Options.JAVA_SOURCE_VERSION.getName(), "1.7"); - TestTools.runCompilation(options); - } -} diff --git a/jack/tests/com/android/jack/Types.java b/jack/tests/com/android/jack/Types.java index 0306835..6e0f6d4 100644 --- a/jack/tests/com/android/jack/Types.java +++ b/jack/tests/com/android/jack/Types.java @@ -510,15 +510,4 @@ public class Types { .getType()); } - @Test - public void test001() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("type/test001"))); - } - - @Test - public void test002() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("type/test002"))); - } } diff --git a/jack/tests/com/android/jack/UnaryTest.java b/jack/tests/com/android/jack/UnaryTest.java index 2b04da4..f72342e 100644 --- a/jack/tests/com/android/jack/UnaryTest.java +++ b/jack/tests/com/android/jack/UnaryTest.java @@ -37,42 +37,6 @@ public class UnaryTest { Main.class.getClassLoader().setDefaultAssertionStatus(true); } - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("unary/test001"))); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile2() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("unary/test002"))); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile3() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("unary/test003"))); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile4() throws Exception { - TestTools.runCompilation(TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("unary/test004"))); - } - @Test public void testCompile5() throws Exception { String classBinaryName = "com/android/jack/unary/test005/jack/UnaryNot"; diff --git a/jack/tests/com/android/jack/analysis/dfa/reachingdefs/ReachingDefsTest.java b/jack/tests/com/android/jack/analysis/dfa/reachingdefs/ReachingDefsTest.java index b1765dd..e2d5aaf 100644 --- a/jack/tests/com/android/jack/analysis/dfa/reachingdefs/ReachingDefsTest.java +++ b/jack/tests/com/android/jack/analysis/dfa/reachingdefs/ReachingDefsTest.java @@ -17,8 +17,6 @@ package com.android.jack.analysis.dfa.reachingdefs; import com.android.jack.Main; -import com.android.jack.Options; -import com.android.jack.TestTools; import com.android.jack.analysis.DefinitionMarker; import com.android.jack.cfg.BasicBlock; import com.android.jack.cfg.ControlFlowGraph; @@ -27,13 +25,11 @@ import com.android.jack.ir.ast.JAsgOperation; import com.android.jack.ir.ast.JIntLiteral; import com.android.jack.ir.ast.JMethod; import com.android.jack.ir.ast.JVariableRef; -import com.android.jack.util.filter.SignatureMethodFilter; import com.android.sched.util.codec.ImplementationName; import junit.framework.Assert; import org.junit.BeforeClass; -import org.junit.Test; import javax.annotation.Nonnull; @@ -78,15 +74,4 @@ public class ReachingDefsTest { } } } - - @Test - public void testDfa001() throws Exception { - Options options = TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("analysis/dfa/reachingdefs/test001")); - options.addProperty(Options.METHOD_FILTER.getName(), "method-with-signature"); - options.addProperty(SignatureMethodFilter.METHOD_SIGNATURE_FILTER.getName(), - "dfaWithSwitch(I)I"); - options.addProperty(ReachingDefinitions.REACHING_DEFS_CHECKER.getName(), "test001Checker"); - TestTools.runCompilation(options); - } } diff --git a/jack/tests/com/android/jack/backend/dex/rop/RopRegisterManagerTest.java b/jack/tests/com/android/jack/backend/dex/rop/RopRegisterManagerTest.java index 6349ff7..05f3bfc 100644 --- a/jack/tests/com/android/jack/backend/dex/rop/RopRegisterManagerTest.java +++ b/jack/tests/com/android/jack/backend/dex/rop/RopRegisterManagerTest.java @@ -16,8 +16,6 @@ package com.android.jack.backend.dex.rop; -import com.android.jack.Options; -import com.android.jack.TestTools; import com.android.jack.ir.ast.JModifier; import com.android.jack.ir.ast.JParameter; import com.android.jack.ir.ast.JParameterRef; @@ -118,10 +116,4 @@ public class RopRegisterManagerTest { rrm.getRegisterSpec(ref); } - @Test - public void ropBuildMethodWithSameReturnReg() throws Exception { - Options compilerArgs = TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("returnstatement/return001")); - TestTools.runCompilation(compilerArgs); - } } diff --git a/jack/tests/com/android/jack/cfg/BuildCfgErrorTest.java b/jack/tests/com/android/jack/cfg/BuildCfgErrorTest.java index 110602f..68817fb 100644 --- a/jack/tests/com/android/jack/cfg/BuildCfgErrorTest.java +++ b/jack/tests/com/android/jack/cfg/BuildCfgErrorTest.java @@ -27,7 +27,7 @@ import org.junit.Test; public class BuildCfgErrorTest { - private static final String CLASS_BINARY_NAME = "com/android/jack/fibonacci/jack/FibonacciThreeAddress"; + private static final String CLASS_BINARY_NAME = "com/android/jack/fibonacci/test001/jack/FibonacciThreeAddress"; @Before public void setUp() throws Exception { diff --git a/jack/tests/com/android/jack/cfg/BuildCfgTest.java b/jack/tests/com/android/jack/cfg/BuildCfgTest.java index 4640658..07415de 100644 --- a/jack/tests/com/android/jack/cfg/BuildCfgTest.java +++ b/jack/tests/com/android/jack/cfg/BuildCfgTest.java @@ -37,7 +37,7 @@ import java.util.List; public class BuildCfgTest { private List<BasicBlock> bbCodeOder; - private static final String CLASS_BINARY_NAME = "com/android/jack/fibonacci/jack/FibonacciThreeAddress"; + private static final String CLASS_BINARY_NAME = "com/android/jack/fibonacci/test001/jack/FibonacciThreeAddress"; @Before public void setUp() throws Exception { diff --git a/jack/tests/com/android/jack/errorhandling/AnnotationProcessorErrorTest.java b/jack/tests/com/android/jack/errorhandling/AnnotationProcessorErrorTest.java deleted file mode 100644 index 5c314df..0000000 --- a/jack/tests/com/android/jack/errorhandling/AnnotationProcessorErrorTest.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.errorhandling; - -import com.google.common.io.Files; - -import com.android.jack.JackUserException; -import com.android.jack.Main; -import com.android.jack.Options; -import com.android.jack.TestTools; -import com.android.jack.errorhandling.annotationprocessor.ResourceAnnotationProcessor; -import com.android.jack.errorhandling.annotationprocessor.ResourceAnnotationTest; -import com.android.jack.errorhandling.annotationprocessor.SourceAnnotationProcessor; -import com.android.jack.errorhandling.annotationprocessor.SourceAnnotationTest; -import com.android.jack.errorhandling.annotationprocessor.SourceErrorAnnotationTest; -import com.android.jack.frontend.FrontendCompilationException; -import com.android.sched.util.file.FileUtils; - -import junit.framework.Assert; - -import org.jf.dexlib.ClassDefItem; -import org.jf.dexlib.DexFile; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; -import java.io.FileReader; -import java.io.LineNumberReader; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nonnull; - -/** - * JUnit test checking Jack behavior when using annotation processor. - */ -public class AnnotationProcessorErrorTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Checks that compilation fails correctly when annotation processor is called without specifying - * output folder. - */ - @Test - public void testAnnotationProcessorError001() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - te.addFile(te.getSourceFolder(),"jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A {} \n"); - - Options options = new Options(); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add("-processor"); - ecjArgs.add(ResourceAnnotationProcessor.class.getName()); - ecjArgs.add(te.getSourceFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setClasspath(TestTools.getDefaultBootclasspathString()); - - try { - te.compile(options); - Assert.fail(); - } catch (JackUserException e) { - // Failure is ok since output for annotation processor is not specify. - Assert.assertTrue(e.getMessage().contains("Unknown location")); - } - } - - /** - * Checks that compilation succeed when running annotation processor to generate resource file. - */ - @Test - public void testAnnotationProcessorError002() throws Exception { - runAnnotProcBuildingResource(new TestingEnvironment()); - } - - /** - * Checks that last compilation failed since the resource created by annotation processor already - * exist. - */ - @Test - public void testAnnotationProcessorError003() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - runAnnotProcBuildingResource(te); - - Options options = new Options(); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add("-d"); - ecjArgs.add(te.getTestingFolder().getAbsolutePath()); - ecjArgs.add("-processor"); - ecjArgs.add(ResourceAnnotationProcessor.class.getName()); - ecjArgs.add(te.getSourceFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setClasspath(TestTools.getDefaultBootclasspathString() + File.pathSeparator - + te.getJackFolder()); - options.setOutputDir(TestTools.createTempDir("annot", "dex")); - - try { - te.startErrRedirection(); - te.compile(options); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Failure is ok since created file already exists - } finally { - Assert.assertTrue(te.endErrRedirection().contains("Resource already created")); - } - } - - /** - * Checks that compilation failed since the source file generated by the annotation processor - * does not compile. - */ - @Test - public void testAnnotationProcessorError004() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - buildAnnotationRequiredByAnnotationProc(te, new Class<?>[] {SourceAnnotationTest.class, - SourceErrorAnnotationTest.class}); - - te.addFile(te.getSourceFolder(), "jack.incremental", "A.java", "package jack.incremental;\n" - + "import " + SourceErrorAnnotationTest.class.getName() + ";\n" - + "@" + SourceErrorAnnotationTest.class.getSimpleName() + "\n" - + "public class A {}\n"); - - Options options = new Options(); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add("-d"); - ecjArgs.add(te.getTestingFolder().getAbsolutePath()); - ecjArgs.add("-processor"); - ecjArgs.add(SourceAnnotationProcessor.class.getName()); - ecjArgs.add(te.getSourceFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setClasspath(TestTools.getDefaultBootclasspathString() + File.pathSeparator - + te.getJackFolder()); - - try { - te.startErrRedirection(); - te.compile(options); - Assert.fail(); - } catch (FrontendCompilationException ex) { - // Failure is ok since source generated by annotation processor does not compile. - } finally { - Assert.assertTrue(te.endErrRedirection().contains("Syntax error on tokens, delete these tokens")); - } - } - - /** - * Checks that compilation succeed to compile source file generated by the annotation processor. - */ - @Test - public void testAnnotationProcessorError005() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - buildAnnotationRequiredByAnnotationProc(te, new Class<?>[] {SourceAnnotationTest.class, - SourceErrorAnnotationTest.class}); - - te.addFile(te.getSourceFolder(), "jack.incremental", "A.java", "package jack.incremental;\n" - + "import " + SourceAnnotationTest.class.getName() + ";\n" - + "@" + SourceAnnotationTest.class.getSimpleName() + "\n" - + "public class A {}\n"); - - Options options = new Options(); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add("-d"); - ecjArgs.add(te.getTestingFolder().getAbsolutePath()); - ecjArgs.add("-processor"); - ecjArgs.add(SourceAnnotationProcessor.class.getName()); - ecjArgs.add(te.getSourceFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setClasspath(TestTools.getDefaultBootclasspathString() + File.pathSeparator - + te.getJackFolder()); - - File dexOutput = new File(te.getTestingFolder(), "classes.dex"); - options.setOutputDir(te.getTestingFolder()); - - te.compile(options); - - DexFile dexFile = new DexFile(dexOutput); - List<String> sourceFileInDex = new ArrayList<String>(); - for (ClassDefItem classDef : dexFile.ClassDefsSection.getItems()) { - sourceFileInDex.add(classDef.getSourceFile().getStringValue()); - } - - Assert.assertTrue(sourceFileInDex.contains("ADuplicated.java")); - Assert.assertTrue(sourceFileInDex.contains("A.java")); - } - - private void runAnnotProcBuildingResource(@Nonnull TestingEnvironment te) throws Exception { - - buildAnnotationRequiredByAnnotationProc(te, new Class<?>[] {ResourceAnnotationTest.class}); - - te.addFile(te.getSourceFolder(), "jack.incremental", "A.java", "package jack.incremental;\n" - + "import " + ResourceAnnotationTest.class.getName() + ";\n" - + "@" + ResourceAnnotationTest.class.getSimpleName() + "\n" - + "public class A {}\n"); - - Options options = new Options(); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add("-d"); - ecjArgs.add(te.getTestingFolder().getAbsolutePath()); - ecjArgs.add("-processor"); - ecjArgs.add(ResourceAnnotationProcessor.class.getName()); - ecjArgs.add(te.getSourceFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setClasspath(TestTools.getDefaultBootclasspathString() + File.pathSeparator - + te.getJackFolder()); - options.setOutputDir(TestTools.createTempDir("annot", "dex")); - - te.compile(options); - - File discoverFile = new File(te.getTestingFolder(), ResourceAnnotationProcessor.FILENAME); - Assert.assertTrue(discoverFile.exists()); - LineNumberReader lnr = new LineNumberReader(new FileReader(discoverFile)); - Assert.assertEquals(ResourceAnnotationTest.class.getName(), lnr.readLine()); - Assert.assertEquals("jack.incremental.A", lnr.readLine()); - Assert.assertNull(lnr.readLine()); - lnr.close(); - } - - private void buildAnnotationRequiredByAnnotationProc(@Nonnull TestingEnvironment te, - @Nonnull Class<?>[] annotationClasses) throws Exception { - File targetAnnotationFileFolder = - new File(te.getSourceFolder(), "com/android/jack/errorhandling/annotationprocessor/"); - if (!targetAnnotationFileFolder.mkdirs()) { - Assert.fail("Fail to create folder " + targetAnnotationFileFolder.getAbsolutePath()); - } - - for (Class<?> annotationClass : annotationClasses) { - Files.copy(new File(TestTools.getAndroidTop() - + "/toolchain/jack/jack/tests/com/android/jack/errorhandling/annotationprocessor/" - + annotationClass.getSimpleName() + ".java"), new File( - targetAnnotationFileFolder, annotationClass.getSimpleName() + ".java")); - } - - // Compile annotation to a jack file - Options options = new Options(); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add(te.getSourceFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setClasspath(TestTools.getDefaultBootclasspathString()); - options.setJayceOutputDir(te.getJackFolder()); - - te.compile(options); - - FileUtils.deleteDir(te.getSourceFolder()); - } -} diff --git a/jack/tests/com/android/jack/errorhandling/CommandLineErrorTest.java b/jack/tests/com/android/jack/errorhandling/CommandLineErrorTest.java deleted file mode 100644 index 871bd4e..0000000 --- a/jack/tests/com/android/jack/errorhandling/CommandLineErrorTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.errorhandling; - -import com.android.jack.IllegalOptionsException; -import com.android.jack.Main; -import com.android.jack.NothingToDoException; -import com.android.jack.Options; -import com.android.jack.frontend.FrontendCompilationException; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * JUnit test checking Jack behavior on exceptions. - */ -public class CommandLineErrorTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Checks that compilation fails correctly when an unsupported options is passed to ecj. - */ - @Test - public void testCommandLineError001() throws Exception { - TestingEnvironment ite = new TestingEnvironment(); - - Options options = new Options(); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add("-unsupported"); - ecjArgs.add(ite.getTestingFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - - try { - ite.startErrRedirection(); - ite.compile(options); - Assert.fail(); - } catch (IllegalOptionsException e) { - // Failure is ok since a bad options is passed to ecj. - } finally { - Assert.assertEquals("", ite.endErrRedirection()); - } - } - - /** - * Checks that compilation fails correctly when no source files are passed to ecj. - */ - @Test - public void testCommandLineError002() throws Exception { - TestingEnvironment ite = new TestingEnvironment(); - - Options options = new Options(); - options.setEcjArguments(new ArrayList<String>()); - - try { - ite.startErrRedirection(); - ite.startOutRedirection(); - ite.compile(options); - Assert.fail(); - } catch (NothingToDoException e) { - // Failure is ok since there is no source files. - } finally { - Assert.assertEquals("", ite.endErrRedirection()); - Assert.assertTrue(ite.endOutRedirection().contains("Usage:")); - } - } - - /** - * Checks that compilation fails correctly when java.lang.Object does not exist on classpath. - */ - @Test - public void testCommandLineError003() throws Exception { - TestingEnvironment ite = new TestingEnvironment(); - - File sourceFile = ite.addFile(ite.getSourceFolder(),"jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A {} \n"); - - Options options = new Options(); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add(sourceFile.getAbsolutePath()); - options.setEcjArguments(ecjArgs); - - try { - ite.startErrRedirection(); - ite.startOutRedirection(); - ite.compile(options); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Failure is ok, since java.lang.Object does not exist. - } finally { - Assert.assertEquals("", ite.endOutRedirection()); - String err = ite.endErrRedirection(); - Assert.assertTrue(err.contains("The type java.lang.Object cannot be found in source files, " - + "imported jack libs or the classpath")); - } - } -} diff --git a/jack/tests/com/android/jack/errorhandling/ConfigErrorTest.java b/jack/tests/com/android/jack/errorhandling/ConfigErrorTest.java deleted file mode 100644 index 86d41d9..0000000 --- a/jack/tests/com/android/jack/errorhandling/ConfigErrorTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.errorhandling; - -import com.android.jack.Options; -import com.android.jack.TestTools; -import com.android.sched.util.config.UnknownPropertyNameException; - -import org.junit.Assert; -import org.junit.Test; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -public class ConfigErrorTest { - - @Test - public void testUnknownProperty001() throws Exception { - TestingEnvironment ite = new TestingEnvironment(); - - File sourceFile = ite.addFile(ite.getSourceFolder(),"jack.config", "A.java", - "package jack.config; \n"+ - "public class A {} \n"); - File outZip = TestTools.createTempFile("out", ".zip"); - - Options options = new Options(); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add(sourceFile.getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setOutputZip(outZip); - options.addProperty("unknown", "true"); - options.setClasspath(TestTools.getDefaultBootclasspathString()); - - try { - ite.startErrRedirection(); - ite.compile(options); - Assert.fail(); - } catch (UnknownPropertyNameException e) { - // Expected since we use an unknown property. - } finally { - Assert.assertEquals("", ite.endErrRedirection()); - } - } - -} diff --git a/jack/tests/com/android/jack/errorhandling/ErrorHandlingAllTests.java b/jack/tests/com/android/jack/errorhandling/ErrorHandlingAllTests.java deleted file mode 100644 index 7b3d9cc..0000000 --- a/jack/tests/com/android/jack/errorhandling/ErrorHandlingAllTests.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ -package com.android.jack.errorhandling; - -import org.junit.experimental.categories.Categories; -import org.junit.runner.RunWith; -import org.junit.runners.Suite.SuiteClasses; - -@RunWith(Categories.class) -@SuiteClasses( -value = {JackFormatErrorTest.class, FileAccessErrorTest.class, - CommandLineErrorTest.class, AnnotationProcessorErrorTest.class, SourceErrorTest.class}) -public class ErrorHandlingAllTests { -}
\ No newline at end of file diff --git a/jack/tests/com/android/jack/errorhandling/FileAccessErrorTest.java b/jack/tests/com/android/jack/errorhandling/FileAccessErrorTest.java deleted file mode 100644 index ecd4d31..0000000 --- a/jack/tests/com/android/jack/errorhandling/FileAccessErrorTest.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.errorhandling; - -import com.android.jack.JackAbortException; -import com.android.jack.JackUserException; -import com.android.jack.Main; -import com.android.jack.Options; -import com.android.jack.TestTools; -import com.android.jack.frontend.FrontendCompilationException; -import com.android.jack.library.LibraryIOException; -import com.android.jack.library.LibraryReadingException; -import com.android.sched.util.config.PropertyIdException; -import com.android.sched.util.file.WrongPermissionException; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * JUnit test checking Jack behavior on file access error. - */ -public class FileAccessErrorTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Checks that compilation fails correctly when folder to generate jack files is not readable. - */ - @Test - public void testFileAccessError001() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - te.addFile(te.getSourceFolder(), "jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A {} \n"); - - Options options = new Options(); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add(te.getTestingFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setClasspath(TestTools.getDefaultBootclasspathString()); - File jackOutputFile = TestTools.createTempDir("ErrorHandlingTest_", "001"); - options.setJayceOutputDir(jackOutputFile); - if (!jackOutputFile.setReadable(false)) { - Assert.fail("Fails to change file permissions of " + jackOutputFile.getAbsolutePath()); - } - - try { - te.compile(options); - Assert.fail(); - } catch (PropertyIdException e) { - // Failure is ok since jack output folder is not readable - } finally { - if (!jackOutputFile.setReadable(true)) { - Assert.fail("Fails to change file permissions of " + jackOutputFile.getAbsolutePath()); - } - } - } - - /** - * Checks that compilation fails correctly when folder containing jack files is not readable. - */ - @Test - public void testFileAccessError002() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - te.addFile(te.getSourceFolder(), "jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A {} \n"); - - Options options = new Options(); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add(te.getTestingFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setClasspath(TestTools.getDefaultBootclasspathString()); - File jackOutputFile = TestTools.createTempDir("ErrorHandlingTest_", "001"); - options.setJayceOutputDir(jackOutputFile); - - te.compile(options); - - te.deleteJavaFile(te.getSourceFolder(), "jack.incremental", "A.java"); - te.addFile(te.getSourceFolder(), "jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B extends A {} \n"); - - options = new Options(); - ecjArgs = new ArrayList<String>(); - ecjArgs.add(te.getTestingFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setClasspath(TestTools.getDefaultBootclasspathString()); - options.addJayceImport(jackOutputFile); - - // Modify read permission of folder containing jack files - if (!jackOutputFile.setReadable(false)) { - Assert.fail("Fails to change file permissions of " + jackOutputFile.getAbsolutePath()); - } - try { - te.startErrRedirection(); - te.compile(options); - Assert.fail(); - } catch (JackAbortException e) { - // Failure is ok since Jack file could not be imported since folder is not readable - Assert.assertTrue(e.getCause() instanceof LibraryReadingException); - Assert.assertTrue(e.getCause().getCause() instanceof WrongPermissionException); - } finally { - Assert.assertTrue("", te.endErrRedirection().contains("is not readable")); - if (!jackOutputFile.setReadable(true)) { - Assert.fail("Fails to change file permissions of " + jackOutputFile.getAbsolutePath()); - } - } - } - - /** - * Checks that compilation fails correctly when source file is not readable. - */ - @Test - public void testFileAccessError003() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - File a = te.addFile(te.getSourceFolder(), "jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A {} \n"); - if (!a.setReadable(false)) { - Assert.fail("Fails to change file permissions of " + a.getAbsolutePath()); - } - - Options options = new Options(); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add(te.getTestingFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setClasspath(TestTools.getDefaultBootclasspathString()); - - try { - te.startErrRedirection(); - te.compile(options); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Failure is ok since source file is not readable - } finally { - if (!a.setReadable(true)) { - Assert.fail("Fails to change file permissions of " + a.getAbsolutePath()); - } - Assert.assertTrue(te.endErrRedirection().contains("Permission denied")); - } - } - - /** - * Checks that compilation fails correctly when jack file is not readable. - */ - @Test - public void testFileAccessError004() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - te.addFile(te.getSourceFolder(), "jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A {} \n"); - - Options options = new Options(); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add(te.getTestingFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setClasspath(TestTools.getDefaultBootclasspathString()); - options.setJayceOutputDir(te.getJackFolder()); - - te.compile(options); - - te.deleteJavaFile(te.getSourceFolder(), "jack.incremental", "A.java"); - - te.addFile(te.getSourceFolder(),"jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B extends A {} \n"); - - options = new Options(); - ecjArgs = new ArrayList<String>(); - ecjArgs.add(te.getTestingFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setClasspath( - TestTools.getDefaultBootclasspathString() + File.pathSeparator + te.getJackFolder()); - - try { - for (File jackFile : te.getJackFiles(te.getJackFolder())) { - if (!jackFile.setReadable(false)) { - Assert.fail("Fails to change file permissions of " + jackFile.getAbsolutePath()); - } - } - te.startErrRedirection(); - te.compile(options); - Assert.fail(); - } catch (JackAbortException e) { - Assert.assertTrue(e.getCause() instanceof LibraryReadingException); - Assert.assertTrue(e.getCause().getCause() instanceof LibraryIOException); - } finally { - String errOutput = te.endErrRedirection(); - Assert.assertTrue(errOutput.contains("is an invalid library")); - Assert.assertTrue(errOutput.contains("is not readable")); - for (File jackFile : te.getJackFiles(te.getJackFolder())) { - if (!jackFile.setReadable(true)) { - Assert.fail("Fails to change file permissions of " + jackFile.getAbsolutePath()); - } - } - } - } - - /** - * Checks that compilation fails correctly when source file does not exist. - */ - @Test - public void testFileAccessError005() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - Options options = new Options(); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add(te.getSourceFolder() + File.separator + "A.java"); - options.setEcjArguments(ecjArgs); - options.setClasspath(TestTools.getDefaultBootclasspathString()); - - try { - te.startErrRedirection(); - te.compile(options); - Assert.fail(); - } catch (JackUserException e) { - // Failure is ok since source file is not readable - Assert.assertTrue(e.getMessage().contains("A.java is missing")); - } - } -} diff --git a/jack/tests/com/android/jack/errorhandling/JackFormatErrorTest.java b/jack/tests/com/android/jack/errorhandling/JackFormatErrorTest.java deleted file mode 100644 index 0cf9495..0000000 --- a/jack/tests/com/android/jack/errorhandling/JackFormatErrorTest.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.errorhandling; - -import com.android.jack.JackAbortException; -import com.android.jack.Main; -import com.android.jack.Options; -import com.android.jack.Options.VerbosityLevel; -import com.android.jack.TestTools; -import com.android.jack.jayce.JayceProperties; -import com.android.jack.library.FileType; -import com.android.jack.library.JackLibrary; -import com.android.jack.library.JackLibraryFactory; -import com.android.jack.library.LibraryFormatException; -import com.android.jack.library.LibraryReadingException; -import com.android.jack.library.v0001.Version; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * JUnit test checking Jack behavior on exceptions. - */ -public class JackFormatErrorTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Checks that compilation fails correctly when jayce file is corrupted. - */ - @Test - public void testJackFormatError001() throws Exception { - TestingEnvironment ite = new TestingEnvironment(); - - ite.addFile(new File(ite.getJackFolder(), FileType.JAYCE.getPrefix()), "jack.incremental", - "A.jayce", "jayce(" + JackLibraryFactory.DEFAULT_MAJOR_VERSION + "." + Version.MINOR - + ")Corrupted"); - ite.addFile(ite.getJackFolder(), "", "jack.properties", - JackLibrary.KEY_LIB_EMITTER + "=unknown\n" - + JackLibrary.KEY_LIB_EMITTER_VERSION + "=0\n" - + JackLibrary.KEY_LIB_MAJOR_VERSION + "=" + Version.MAJOR + "\n" - + JackLibrary.KEY_LIB_MINOR_VERSION + "=" + Version.MINOR + "\n" - + FileType.JAYCE.buildPropertyName(null /*suffix*/) + "=true\n" - + JayceProperties.KEY_JAYCE_MAJOR_VERSION + "=2\n" - + JayceProperties.KEY_JAYCE_MINOR_VERSION + "=14\n"); - - ite.addFile(ite.getSourceFolder(),"jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B extends A {} \n"); - - Options options = new Options(); - options.setVerbosityLevel(VerbosityLevel.DEBUG); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add(ite.getTestingFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setClasspath( - TestTools.getDefaultBootclasspathString() + File.pathSeparator + ite.getJackFolder()); - - try { - ite.startErrRedirection(); - ite.compile(options); - Assert.fail(); - } catch (JackAbortException e) { - // Failure is ok since jack file is corrupted. - Assert.assertTrue(e.getCause() instanceof LibraryReadingException); - Assert.assertTrue(e.getCause().getCause() instanceof LibraryFormatException); - } finally { - Assert.assertTrue(ite.endErrRedirection().contains("is an invalid library")); - Assert.assertTrue(ite.endErrRedirection().contains( - "Unexpected node NForStatement, NDeclaredType was expected")); - } - } - - /** - * Checks that compilation fails correctly when jack file header is corrupted. - */ - @Test - public void testJackFormatError002() throws Exception { - TestingEnvironment ite = new TestingEnvironment(); - - ite.addFile(new File(ite.getJackFolder(), FileType.JAYCE.getPrefix()), "jack.incremental", - "A.jayce", "jayce()"); - ite.addFile(ite.getJackFolder(), "", "jack.properties", - JackLibrary.KEY_LIB_EMITTER + "=unknown\n" - + JackLibrary.KEY_LIB_EMITTER_VERSION + "=0\n" - + JackLibrary.KEY_LIB_MAJOR_VERSION + "=" + Version.MAJOR + "\n" - + JackLibrary.KEY_LIB_MINOR_VERSION + "=" + Version.MINOR + "\n" - + FileType.JAYCE.buildPropertyName(null /*suffix*/) + "=true\n" - + JayceProperties.KEY_JAYCE_MAJOR_VERSION + "=2\n" - + JayceProperties.KEY_JAYCE_MINOR_VERSION + "=14\n"); - - ite.addFile(ite.getSourceFolder(),"jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B extends A {} \n"); - - Options options = new Options(); - options.setVerbosityLevel(VerbosityLevel.DEBUG); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add(ite.getTestingFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setClasspath( - TestTools.getDefaultBootclasspathString() + File.pathSeparator + ite.getJackFolder()); - - try { - ite.startErrRedirection(); - ite.compile(options); - Assert.fail(); - } catch (JackAbortException e) { - // Failure is ok since jack file header is corrupted. - Assert.assertTrue(e.getCause() instanceof LibraryReadingException); - Assert.assertTrue(e.getCause().getCause() instanceof LibraryFormatException); - } finally { - Assert.assertTrue(ite.endErrRedirection().contains("is an invalid library")); - Assert.assertTrue(ite.endErrRedirection().contains("Invalid Jayce header")); - } - } - - /** - * Checks that compilation fails correctly when jack file is not longer supported. - */ - @Test - public void testJackFormatError003() throws Exception { - TestingEnvironment ite = new TestingEnvironment(); - - ite.addFile(new File(ite.getJackFolder(), FileType.JAYCE.getPrefix()), "jack.incremental", - "A.jayce", "jayce()"); - ite.addFile(ite.getJackFolder(), "", "jack.properties", - JackLibrary.KEY_LIB_EMITTER + "=unknown\n" - + JackLibrary.KEY_LIB_EMITTER_VERSION + "=0\n" - + JackLibrary.KEY_LIB_MAJOR_VERSION + "=" + Version.MAJOR + "\n" - + JackLibrary.KEY_LIB_MINOR_VERSION + "=" + Version.MINOR + "\n" - + FileType.JAYCE.buildPropertyName(null /*suffix*/) + "=true\n" - + JayceProperties.KEY_JAYCE_MAJOR_VERSION + "=0\n" - + JayceProperties.KEY_JAYCE_MINOR_VERSION + "=0\n"); - - ite.addFile(ite.getSourceFolder(),"jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B extends A {} \n"); - - Options options = new Options(); - options.setVerbosityLevel(VerbosityLevel.DEBUG); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add(ite.getTestingFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setClasspath( - TestTools.getDefaultBootclasspathString() + File.pathSeparator + ite.getJackFolder()); - - try { - ite.startErrRedirection(); - ite.compile(options); - Assert.fail(); - } catch (JackAbortException e) { - // Failure is ok since jack file header is corrupted. - Assert.assertTrue(e.getCause() instanceof LibraryReadingException); - Assert.assertTrue(e.getCause().getCause() instanceof LibraryFormatException); - } finally { - Assert.assertTrue(ite.endErrRedirection().contains("is an invalid library")); - Assert.assertTrue(ite.endErrRedirection().contains("Jayce version 0 not supported")); - } - } -} diff --git a/jack/tests/com/android/jack/errorhandling/SourceErrorTest.java b/jack/tests/com/android/jack/errorhandling/SourceErrorTest.java deleted file mode 100644 index 165b49d..0000000 --- a/jack/tests/com/android/jack/errorhandling/SourceErrorTest.java +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.errorhandling; - -import com.android.jack.Options; -import com.android.jack.TestTools; -import com.android.jack.frontend.FrontendCompilationException; - -import org.junit.Assert; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nonnull; - -/** - * JUnit test checking Jack behavior with source errors. - */ -public class SourceErrorTest { - - /** - * Checks that compilation fails because of invalid "class" keyword. - * parsingErrorId = syntaxCategory + internalCategory + 204 - */ - @Test - public void testInvalidSource001() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - te.addFile(te.getSourceFolder(), "jack.invalidsource", "A.java", "package jack.invalidsource;\n" - + "public clas A {}\n"); - - try { - te.startOutRedirection(); - te.startErrRedirection(); - te.compile(getOptions(te)); - Assert.fail(); - } catch (FrontendCompilationException ex) { - // Failure is ok since source does not compile. - } finally { - Assert.assertEquals("", te.endOutRedirection()); - Assert.assertTrue( - te.endErrRedirection().contains("Syntax error on token \"clas\", class expected")); - } - } - - /** - * Checks that compilation fails because of invalid "public" keyword. - * parsingErrorId = syntaxCategory + internalCategory + 204 - */ - @Test - public void testInvalidSource002() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - te.addFile(te.getSourceFolder(), "jack.invalidsource", "A.java", "package jack.invalidsource;\n" - + "publi class A {}\n"); - - try { - te.startOutRedirection(); - te.startErrRedirection(); - te.compile(getOptions(te)); - Assert.fail(); - } catch (FrontendCompilationException ex) { - // Failure is ok since source does not compile. - } finally { - Assert.assertEquals("", te.endOutRedirection()); - Assert.assertTrue( - te.endErrRedirection().contains("Syntax error on token \"publi\", public expected")); - } - } - - /** - * Checks that compilation fails because of a class name that does not match the file name. - * publicClassMustMatchFileNameId = typeRelatedCategory + 325 - */ - @Test - public void testInvalidSource003() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - te.addFile(te.getSourceFolder(), "jack.invalidsource", "A.java", "package jack.invalidsource;\n" - + "public class B {}\n"); - - try { - te.startOutRedirection(); - te.startErrRedirection(); - te.compile(getOptions(te)); - Assert.fail(); - } catch (FrontendCompilationException ex) { - // Failure is ok since source does not compile. - } finally { - Assert.assertEquals("", te.endOutRedirection()); - Assert.assertTrue( - te.endErrRedirection().contains("The public type B must be defined in its own file")); - } - } - - /** - * Checks that compilation fails because of an import of a class that is not on classpath. - * importNotFoundId = importRelatedCategory + 390 - */ - @Test - public void testInvalidSource004() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - te.addFile(te.getSourceFolder(), "jack.invalidsource", "A.java", "package jack.invalidsource;\n" - + "import jack.invalidsource.B;\n" - + "public class A {}\n"); - - try { - te.startOutRedirection(); - te.startErrRedirection(); - te.compile(getOptions(te)); - Assert.fail(); - } catch (FrontendCompilationException ex) { - // Failure is ok since source does not compile. - } finally { - Assert.assertEquals("", te.endOutRedirection()); - Assert.assertTrue( - te.endErrRedirection().contains("The import jack.invalidsource.B cannot be resolved")); - } - } - - /** - * Checks that compilation fails because there are too many methods in a single class. - * tooManyMethodsId = internalCategory + 433 - */ - @Test - public void testInvalidSource005() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - int methodCount = 65536; - StringBuilder content = - new StringBuilder("public class A {"); - // -1 due to implicit init method - for (int mthIdx = 0; mthIdx < methodCount - 1; mthIdx++) { - content.append("public void m" + mthIdx + "() {} \n"); - } - content.append("} \n"); - - te.addFile(te.getSourceFolder(), "jack.overflow", "A.java", - "package jack.overflow; \n" + content.toString()); - - try { - te.startErrRedirection(); - te.startOutRedirection(); - te.compile(getOptions(te)); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Failure is ok, since there are too many methods. - } finally { - Assert.assertEquals("", te.endOutRedirection()); - Assert.assertTrue( - te.endErrRedirection().contains("Too many methods for type A. Maximum is 65535")); - } - } - - /** - * Checks that compilation fails because of several source errors. - */ - @Test - public void testInvalidSource006() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - te.addFile(te.getSourceFolder(), "jack.invalidsource", "A.java", "package jack.invalidsource;\n" - + "public class A { private voi m() {} } \n"); - te.addFile(te.getSourceFolder(), "jack.invalidsource", "B.java", "package jack.invalidsource;\n" - + "public class B { private void m(in a) {}; \n private void n(int a) {re}; } \n"); - - try { - te.startOutRedirection(); - te.startErrRedirection(); - te.compile(getOptions(te)); - Assert.fail(); - } catch (FrontendCompilationException ex) { - // Failure is ok since source does not compile. - } finally { - Assert.assertEquals("", te.endOutRedirection()); - String errorString = te.endErrRedirection(); - Assert.assertTrue(errorString.contains("in cannot be resolved to a type")); - Assert.assertTrue(errorString.contains( - "Syntax error, insert \"VariableDeclarators\" to complete LocalVariableDeclaration")); - Assert.assertTrue( - errorString.contains("Syntax error, insert \";\" to complete BlockStatements")); - Assert.assertTrue(errorString.contains("voi cannot be resolved to a type")); - } - } - - /** - * Checks that compilation fails because of a source error, with also some warnings. - */ - @Test - public void testInvalidSource007() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - te.addFile(te.getSourceFolder(), "jack.invalidsource", "A.java", "package jack.invalidsource;\n" - + "public class A { private void m() {} } \n"); - te.addFile(te.getSourceFolder(), "jack.invalidsource", "B.java", "package jack.invalidsource;\n" - + "public class B { private void m(in a) {}; \n private void n(int a) {}; } \n"); - - try { - te.startOutRedirection(); - te.startErrRedirection(); - te.compile(getOptions(te)); - Assert.fail(); - } catch (FrontendCompilationException ex) { - // Failure is ok since source does not compile. - } finally { - Assert.assertEquals("", te.endOutRedirection()); - Assert.assertTrue(te.endErrRedirection().contains("in cannot be resolved to a type")); - Assert.assertTrue(te.endErrRedirection().contains( - "The method n(int) from the type B is never used locally")); - Assert.assertTrue( - te.endErrRedirection().contains("The method m() from the type A is never used locally")); - } - } - - /** - * Checks that compilation succeeds but prints several warnings. - */ - @Test - public void testInvalidSource008() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - te.addFile(te.getSourceFolder(), "jack.invalidsource", "A.java", "package jack.invalidsource;\n" - + "public class A { private void m() {} } \n"); - te.addFile(te.getSourceFolder(), "jack.invalidsource", "B.java", "package jack.invalidsource;\n" - + "public class B { private void m(int a) {}; \n private void n(int a) {}; } \n"); - - try { - te.startOutRedirection(); - te.startErrRedirection(); - te.compile(getOptions(te)); - } finally { - Assert.assertEquals("", te.endOutRedirection()); - Assert.assertTrue(te.endErrRedirection().contains( - "The method m(int) from the type B is never used locally")); - Assert.assertTrue(te.endErrRedirection().contains( - "The method n(int) from the type B is never used locally")); - Assert.assertTrue( - te.endErrRedirection().contains("The method m() from the type A is never used locally")); - } - } - - /** - * Checks that compilation fails because of an invalid type. - * undefinedTypeId = typeRelatedCategory + 2 - */ - @Test - public void testInvalidSource009() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - te.addFile(te.getSourceFolder(), "jack.invalidsource", "A.java", "package jack.invalidsource;\n" - + "public class A { private void m(in a) {}; } \n"); - - try { - te.startOutRedirection(); - te.startErrRedirection(); - te.compile(getOptions(te)); - Assert.fail(); - } catch (FrontendCompilationException ex) { - // Failure is ok since source does not compile. - } finally { - Assert.assertEquals("", te.endOutRedirection()); - Assert.assertTrue( - te.endErrRedirection().contains("in cannot be resolved to a type")); - } - } - - /** - * Checks that compilation fails because of a parsing error. - * parsingErrorInsertToCompleteId = syntaxCategory + internalCategory + 240 - */ - @Test - public void testInvalidSource010() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - te.addFile(te.getSourceFolder(), "jack.invalidsource", "A.java", "package jack.invalidsource;\n" - + "public class A { private void n(int a) {re;} } \n"); - - try { - te.startOutRedirection(); - te.startErrRedirection(); - te.compile(getOptions(te)); - Assert.fail(); - } catch (FrontendCompilationException ex) { - // Failure is ok since source does not compile. - } finally { - Assert.assertEquals("", te.endOutRedirection()); - Assert.assertTrue(te.endErrRedirection().contains( - "Syntax error, insert \"VariableDeclarators\" to complete LocalVariableDeclaration")); - } - } - - /** - * Checks that compilation succeeds but raises a warning because of an unused private method. - * unusedPrivateMethodId = internalCategory + methodRelatedCategory + 118 - */ - @Test - public void testInvalidSource011() throws Exception { - TestingEnvironment te = new TestingEnvironment(); - - te.addFile(te.getSourceFolder(), "jack.invalidsource", "A.java", "package jack.invalidsource;\n" - + "public class A { private void m() {} } \n"); - - try { - te.startOutRedirection(); - te.startErrRedirection(); - te.compile(getOptions(te)); - } finally { - Assert.assertEquals("", te.endOutRedirection()); - Assert.assertTrue( - te.endErrRedirection().contains("The method m() from the type A is never used locally")); - } - } - - @Nonnull - private Options getOptions(@Nonnull TestingEnvironment te) { - Options options = new Options(); - List<String> ecjArgs = new ArrayList<String>(); - ecjArgs.add(te.getSourceFolder().getAbsolutePath()); - options.setEcjArguments(ecjArgs); - options.setClasspath(TestTools.getDefaultBootclasspathString()); - options.setOutputDir(te.getTestingFolder()); - return options; - } - -} diff --git a/jack/tests/com/android/jack/errorhandling/TestingEnvironment.java b/jack/tests/com/android/jack/errorhandling/TestingEnvironment.java deleted file mode 100644 index 36086d4..0000000 --- a/jack/tests/com/android/jack/errorhandling/TestingEnvironment.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.errorhandling; - -import com.android.jack.IllegalOptionsException; -import com.android.jack.Jack; -import com.android.jack.JackUserException; -import com.android.jack.NothingToDoException; -import com.android.jack.Options; -import com.android.jack.TestTools; -import com.android.jack.backend.jayce.JayceFileImporter; -import com.android.jack.util.NamingTools; -import com.android.sched.util.config.ConfigurationException; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileDescriptor; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -public class TestingEnvironment { - - @CheckForNull - ByteArrayOutputStream baosOut = null; - - @CheckForNull - PrintStream outRedirectStream = null; - - @CheckForNull - ByteArrayOutputStream baosErr = null; - - @CheckForNull - PrintStream errRedirectStream = null; - - @Nonnull - private final File testingFolder; - - @Nonnull - private final File sourceFolder; - - @Nonnull - private final File jackFolder; - - public TestingEnvironment() throws IOException { - this.testingFolder = TestTools.createTempDir("ErrorHandlingTest_", ""); - this.sourceFolder = new File(testingFolder, "src"); - if (!this.sourceFolder.mkdirs()) { - throw new IOException("Failed to create folder " + this.sourceFolder.getAbsolutePath()); - } - this.jackFolder = new File(testingFolder, "jack"); - if (!this.jackFolder.mkdirs()) { - throw new IOException("Failed to create folder " + this.jackFolder.getAbsolutePath()); - } - } - - @Nonnull - public File getSourceFolder() { - return sourceFolder; - } - - @Nonnull - public File getJackFolder() { - return jackFolder; - } - - @Nonnull - public File getTestingFolder() { - return testingFolder; - } - - public void compile(@Nonnull Options options) - throws ConfigurationException, - IllegalOptionsException, - NothingToDoException, JackUserException { - Jack.run(options); - } - - @Nonnull - public File addFile(@Nonnull File folder, @Nonnull String packageName, @Nonnull String fileName, - @Nonnull String fileContent) throws IOException { - File packageFolder = new File(folder, packageName.replace('.', File.separatorChar)); - if (!packageFolder.exists() && !packageFolder.mkdirs()) { - throw new IOException("Failed to create folder " + packageFolder.getAbsolutePath()); - } - File javaFile = new File(packageFolder, fileName); - if (javaFile.exists() && !javaFile.delete()) { - throw new IOException("Failed to delete file " + javaFile.getAbsolutePath()); - } - if (!javaFile.createNewFile()) { - throw new IOException("Failed to create file " + javaFile.getAbsolutePath()); - } - FileOutputStream fos = null; - try { - fos = new FileOutputStream(javaFile); - fos.write(fileContent.getBytes()); - } finally { - if (fos != null) { - fos.close(); - } - } - - return javaFile; - } - - public void deleteJavaFile(@Nonnull File folder, @Nonnull String packageName, @Nonnull String fileName) - throws IOException { - File packageFolder = new File(folder, NamingTools.getBinaryName(packageName)); - File javaFile = new File(packageFolder, fileName); - if (!javaFile.delete()) { - throw new IOException("Failed to delete file " + javaFile.getAbsolutePath()); - } - } - - public void startErrRedirection() { - baosErr = new ByteArrayOutputStream(); - errRedirectStream = new PrintStream(baosErr); - System.setErr(errRedirectStream); - } - - @Nonnull - public String endErrRedirection() { - assert baosErr != null; - String err = baosErr.toString(); - assert errRedirectStream != null; - errRedirectStream.close(); - System.setErr(new PrintStream(new FileOutputStream(FileDescriptor.err))); - return err; - } - - public void startOutRedirection() { - baosOut = new ByteArrayOutputStream(); - outRedirectStream = new PrintStream(baosOut); - System.setOut(outRedirectStream); - } - - @Nonnull - public String endOutRedirection() { - assert baosOut != null; - String out = baosOut.toString(); - assert outRedirectStream != null; - outRedirectStream.close(); - System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); - return out; - } - - @Nonnull - public List<File> getJackFiles(@Nonnull File folder) { - assert folder.isDirectory(); - List<File> jackFiles = new ArrayList<File>(); - fillJackFiles(folder, jackFiles); - return jackFiles; - } - - private void fillJackFiles(@Nonnull File file, @Nonnull List<File> jackFiles) { - if (file.isDirectory()) { - for (File subFile : file.listFiles()) { - fillJackFiles(subFile, jackFiles); - } - } else if (file.getName().endsWith(JayceFileImporter.JAYCE_FILE_EXTENSION)) { - jackFiles.add(file); - } - } -} diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest001.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest001.java deleted file mode 100644 index f93cdb5..0000000 --- a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest001.java +++ /dev/null @@ -1,562 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.experimental.incremental; - -import com.android.jack.Main; -import com.android.jack.TestTools; -import com.android.jack.frontend.FrontendCompilationException; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.List; - -/** - * JUnit test checking dependencies between Java files. - */ -public class DependenciesTest001 { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Checks that compilation failed due to deletion of B. - * Compilation must recompile A and failed since B does not longer exists. - */ - @Test - public void testDependency001() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A extends B {} \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B {} \n"); - - ite.incrementalBuildFromFolder(); - - ite.deleteJavaFile("jack.incremental", "B.java"); - - try { - ite.incrementalBuildFromFolder(); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Error is ok - } - } - - /** - * Checks that compilation failed due to deletion of I. - * Compilation must recompile A and failed since I does not longer exists. - */ - @Test - public void testDependency002() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_002")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A implements I {} \n"); - - ite.addJavaFile("jack.incremental", "I.java", - "package jack.incremental; \n"+ - "public interface I {} \n"); - - ite.incrementalBuildFromFolder(); - - ite.deleteJavaFile("jack.incremental", "I.java"); - - try { - ite.incrementalBuildFromFolder(); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Error is ok - } - } - - /** - * Check that only type A is recompiled since it was modified (extends of B removed). - */ - @Test - public void testDependency003() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_003")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A extends B {} \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B {} \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A {} \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(1, fqnOfRebuiltTypes.size()); - Assert.assertEquals("jack.incremental.A", fqnOfRebuiltTypes.get(0)); - } - - /** - * Check that no types are recompiled between two incremental build without modification. - */ - @Test - public void testDependency004() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_004")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A extends B {} \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B {} \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(0, fqnOfRebuiltTypes.size()); - } - - /** - * Check that B and C are recompiled since C is modified. - * B must also be recompiled since it used C. - */ - @Test - public void testDependency005() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_005")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A {} \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public void m(C c) {} } \n"); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C {} \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C { public void m() {} } \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(2, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.C")); - } - - /** - * Check that B and C are recompiled since C is modified. - * B must also be recompiled since it used C. - */ - @Test - public void testDependency006() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_006")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A {} \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public void m() {C c = new C();} } \n"); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C {} \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C { public void m() {} } \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(2, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.C")); - } - - /** - * Check that A, B and C are recompiled since C is modified. - * A, B must be recompiled since they are sub-type of C. - */ - @Test - public void testDependency007() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_007")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A extends B {} \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B extends C {} \n"); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C {} \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C { public void m() {} } \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(3, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.C")); - } - - /** - * Check that compilation of A failed due to a modification into B. - */ - @Test - public void testDependency008() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_008")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { public void test() {new B().m();}} \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public void m(){} } \n"); - - ite.incrementalBuildFromFolder(); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public void m(int i){} } \n"); - - try { - ite.incrementalBuildFromFolder(); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Error is ok - } - } - - /** - * Check that A and B are recompiled. - * A must be recompiled since it used a field of B. - */ - @Test - public void testDependency009() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_009")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { public int getCst() {return B.i;} } \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public static int i; } \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public static int i; public static int j; } \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(2, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - } - - /** - * Check that A and B are recompiled. - * A must be recompiled since it used a method of B. - */ - @Test - public void testDependency010() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_010")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { public void callTest() {B.test();} } \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public static void test(){} } \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public static void test() {} public static void test1() {} } \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(2, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - } - - /** - * Check that A is recompiled and that compilation failed since B does not longer exists. - */ - @Test - public void testDependency011() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_011")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { public boolean callTest(Object o) { return o instanceof B;} } \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B {} \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.deleteJavaFile("jack.incremental", "B.java"); - - try { - ite.incrementalBuildFromFolder(); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Error is ok - } - } - - /** - * Check that A and B are recompiled. - * A must be recompiled since it used a constant from B. - */ - @Test - public void testDependency012() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_012")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { public int getCst() {return B.i;} } \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public static final int i = 10; } \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public static final int i = 12; } \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(2, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - } - - /** - * Check that A and B are recompiled. - * A must be recompiled since it used a constant from B. - */ - @Test - public void testDependency013() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_013")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { public int getCst() {return B.i1 + B.i2;} } \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public static final int i1 = 10; public static final int i2 = 20; } \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public static final int i1 = 20; public static final int i2 = 20; } \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(2, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - } - - /** - * Check that A and B are recompiled. - * A must be recompiled since it used a constant from B. - */ - @Test - public void testDependency014() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_014")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { public int getCst() {return B.b + C.c;} } \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public static final int b = 10; } \n"); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C { public static final int c = 10; } \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C { public static final int c = 20; } \n"); - - ite.incrementalBuildFromFolder(); - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(2, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.C")); - - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public static final int b = 20; } \n"); - - ite.incrementalBuildFromFolder(); - fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(2, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - } - - /** - * Check that second and third compilation failed since I was modified but not B for the second - * compilation and not A for the third. Check that fourth compilation rebuilt A, B, I since I and - * B was modified. - */ - @Test - public void testDependency015() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_015")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A extends B { @Override public void m() {} } \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B implements I { @Override public void m() {} } \n"); - - ite.addJavaFile("jack.incremental", "I.java", - "package jack.incremental; \n"+ - "public interface I { public void m(); } \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "I.java", - "package jack.incremental; \n"+ - "public interface I { public void m(int i); } \n"); - - try { - ite.incrementalBuildFromFolder(); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Error is ok - String err = ite.getStringRepresentingErr(); - Assert.assertTrue( - err.contains("The type B must implement the inherited abstract method I.m(int)")); - Assert.assertTrue( - err.contains("The method m() of type B must override or implement a supertype method")); - } - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B implements I { @Override public void m(int i) {} } \n"); - - try { - ite.incrementalBuildFromFolder(); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Error is ok - Assert.assertTrue(ite.getStringRepresentingErr().contains( - "The method m() of type A must override or implement a supertype method")); - } - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A extends B { @Override public void m(int i) {} } \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(3, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.I")); - } -} diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest002.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest002.java deleted file mode 100644 index 2fca23d..0000000 --- a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest002.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.experimental.incremental; - -import com.android.jack.Main; -import com.android.jack.TestTools; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.List; - -/** - * JUnit test checking dependencies between Java files. - */ -public class DependenciesTest002 { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Check that adding a more precise method is well detected. - */ - @Test - public void testDependency001() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { } \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B extends A { public void call(E e) { System.out.println(\"E\"); } } \n"); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C { public static void main(String[] args) {new B().call(new D()); } } \n"); - - ite.addJavaFile("jack.incremental", "D.java", - "package jack.incremental; \n"+ - "public class D extends E { } \n"); - - ite.addJavaFile("jack.incremental", "E.java", - "package jack.incremental; \n"+ - "public class E { } \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { public void call(D d) { System.out.println(\"D\"); } } \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(3, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.C")); - } -} diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest003.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest003.java deleted file mode 100644 index a18f83f..0000000 --- a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest003.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.experimental.incremental; - -import com.android.jack.Main; -import com.android.jack.TestTools; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.List; - -/** - * JUnit test checking dependencies between Java files. - */ -public class DependenciesTest003 { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Check that file modification implying to transform an interface call to a virtual call is well - * detected. - */ - @Test - public void testDependency001() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { public void test(B b) {b.call1().call2();} } \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public I call1() {return new C();} } \n"); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C implements I { @Override public void call2() { } } \n"); - - ite.addJavaFile("jack.incremental", "I.java", - "package jack.incremental; \n"+ - "public interface I { public void call2(); } \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public C call1() {return new C();} } \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(2, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - } -} diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest004.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest004.java deleted file mode 100644 index dca5066..0000000 --- a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest004.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.experimental.incremental; - -import com.android.jack.Main; -import com.android.jack.TestTools; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.List; - -/** - * JUnit test checking dependencies between Java files. - */ -public class DependenciesTest004 { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Check that changing a class into an interface is well detected. - */ - @Test - public void testDependency001() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { public void test(B b) {b.call1();} } \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public void call1() {} } \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public interface B { public void call1(); } \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(2, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - } -} diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest005.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest005.java deleted file mode 100644 index d9a0dbd..0000000 --- a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest005.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.experimental.incremental; - -import com.android.jack.Main; -import com.android.jack.TestTools; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.List; - -/** - * JUnit test checking dependencies between Java files. - */ -@Ignore("Tree") -public class DependenciesTest005 { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Check that runtime is correct after incremental compilation due to a constant modification. - */ - @Test - public void testDependency001() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { public static void main(String[] args) {" + - "System.out.print(C.str + B.str);} " + - "} \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public static final String str = \"HELLO\"; } \n"); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C { public static final String str = \"STRING:\"; } \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public static final String str = \"INCREMENTAL\"; } \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(2, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - - Assert.assertEquals("STRING:INCREMENTAL", ite.run("jack.incremental.A")); - } - - - /** - * Check that runtime is correct after incremental compilation due to a constant modification. - */ - @Test - public void testDependency002() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_002")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { public static void main(String[] args) {" + - "System.out.print(B.str);} " + - "} \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public static final String str = \"HELLO\" + C.str; } \n"); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C { public static final String str = \" WORLD\"; } \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C { public static final String str = \" EVERYBODY\"; } \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(3, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.C")); - - Assert.assertEquals("HELLO EVERYBODY", ite.run("jack.incremental.A")); - } - - /** - * Check that runtime is correct after incremental compilation due to a constant modification. - */ - @Test - public void testDependency003() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_003")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { " + - " public static final String A = \"A\";" + - " public static final String AB = \"A\" + B.B;"+ - " public static void main(String[] args) { System.out.print(B.BA); } } \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { \n" + - " public static final String B = \"B\"; \n" + - " public static final String BA = \"B\" + A.A; }"); - - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - Assert.assertEquals("BA", ite.run("jack.incremental.A")); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { \n" + - " public static final String B = \"B\"; \n" + - " public static final String BA = \"B\" + A.AB; }"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(2, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - - Assert.assertEquals("BAB", ite.run("jack.incremental.A")); - } - - /** - * Check that runtime is correct after incremental compilation due to a constant modification. - */ - @Test - public void testDependency004() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_004")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { public static void main(String[] args) {" + - "System.out.print(B.str);} " + - "} \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public static final String str = D.str + C.str; } \n"); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C { public static final String str = \"WORLD\" + E.str; } \n"); - - ite.addJavaFile("jack.incremental", "D.java", - "package jack.incremental; \n"+ - "public class D { public static final String str = \"HELLO\" + E.str; } \n"); - - ite.addJavaFile("jack.incremental", "E.java", - "package jack.incremental; \n"+ - "public class E { public static final String str = \"/\"; } \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C { public static final String str = \"EVERYBODY\"; } \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(3, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.C")); - - Assert.assertEquals("HELLO/EVERYBODY", ite.run("jack.incremental.A")); - - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "E.java", - "package jack.incremental; \n"+ - "public class E { public static final String str = \" \"; } \n"); - - ite.incrementalBuildFromFolder(); - - fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(4, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.D")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.E")); - - Assert.assertEquals("HELLO EVERYBODY", ite.run("jack.incremental.A")); - } -} diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest006.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest006.java deleted file mode 100644 index 789966c..0000000 --- a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest006.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.experimental.incremental; - -import com.android.jack.Main; -import com.android.jack.TestTools; -import com.android.jack.frontend.FrontendCompilationException; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.List; - -/** - * JUnit test checking dependencies between Java files. - */ -@Ignore("Tree") -public class DependenciesTest006 { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Check that runtime is correct after class renaming. - */ - @Test - public void testDependency001() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { public static void main(String[] args) {" + - "System.out.print(new B().getString());} " + - "} \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public String getString() { return (\"B\"); } } \n"); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C { } \n"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.deleteJavaFile("jack.incremental", "B.java"); - ite.addJavaFile("jack.incremental", "_B.java", - "package jack.incremental; \n"+ - "public class _B { public String getString() { return (\"_B\"); } } \n"); - - try { - ite.incrementalBuildFromFolder(); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Error is ok - } - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { public static void main(String[] args) {" + - "System.out.print(new _B().getString());} " + - "} \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(2, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental._B")); - - Assert.assertEquals("_B", ite.run("jack.incremental.A")); - } -} diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest007.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest007.java deleted file mode 100644 index e0c6688..0000000 --- a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest007.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.experimental.incremental; - -import com.android.jack.Main; -import com.android.jack.TestTools; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.List; - -/** - * JUnit test checking dependencies between Java files. - */ -@Ignore("Tree") -public class DependenciesTest007 { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Check that runtime is correct after transformation of an interface call to a virtual call. - */ - @Test - public void testDependency001() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n"+ - "public class A { public static void main(String[] args) { new B().call1().call2();} } \n"); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public I call1() {return new C();} } \n"); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n"+ - "public class C implements I { @Override public void call2(){System.out.print(\"C\");}\n"+ - "} \n"); - - ite.addJavaFile("jack.incremental", "I.java", - "package jack.incremental; \n"+ - "public interface I { public void call2(); } \n"); - - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - - ite.addJavaFile("jack.incremental", "B.java", - "package jack.incremental; \n"+ - "public class B { public C call1() {return new C();} } \n"); - - ite.incrementalBuildFromFolder(); - - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(2, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - - Assert.assertEquals("C", ite.run("jack.incremental.A")); - } -} diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest008.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest008.java deleted file mode 100644 index 578ce5c..0000000 --- a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest008.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.experimental.incremental; - -import com.android.jack.Main; -import com.android.jack.TestTools; -import com.android.jack.frontend.FrontendCompilationException; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test checking dependencies between Java files. - */ -public class DependenciesTest008 { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Check that jack files are deleted according to recompiled files. - */ - @Test - public void testDependency001() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n" + - "public class A { \n" + - " public static class B { public void m() {} } \n" + - " public static void main(String[] args) {new B().m();} } \n"); - - ite.incrementalBuildFromFolder(); - Assert.assertEquals(2, ite.getJackFiles().size()); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n" + - "public class A { \n" + - " public static void main(String[] args) {new B().m();} } \n"); - - try { - ite.incrementalBuildFromFolder(); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Error is ok - Assert.assertEquals(0, ite.getJackFiles().size()); - } - } - - /** - * Check that jack files are deleted according to recompiled files. - */ - @Test - public void testDependency002() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_002")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n" + - "public class A { } \n" + - "class B { } \n"); - - ite.incrementalBuildFromFolder(); - Assert.assertEquals(2, ite.getJackFiles().size()); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n" + - "public class A { }\n"); - - ite.incrementalBuildFromFolder(); - Assert.assertEquals(1, ite.getJackFiles().size()); - } - - /** - * Check that jack files are deleted according to recompiled files. - */ - @Test - public void testDependency003() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_003")); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n" + - "public class A { } \n" + - "class B { } \n"); - - ite.addJavaFile("jack.incremental", "C.java", - "package jack.incremental; \n" + - "public class C { public void test() {new B();} } \n"); - - ite.incrementalBuildFromFolder(); - Assert.assertEquals(3, ite.getJackFiles().size()); - - ite.addJavaFile("jack.incremental", "A.java", - "package jack.incremental; \n" + - "public class A { }\n"); - - try { - ite.incrementalBuildFromFolder(); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Error is ok - Assert.assertEquals(0, ite.getJackFiles().size()); - } - } -} diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest009.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest009.java deleted file mode 100644 index a736e41..0000000 --- a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest009.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.experimental.incremental; - -import com.android.jack.Main; -import com.android.jack.TestTools; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.Map; -import java.util.Set; - -/** - * JUnit test checking dependencies between Java files. - */ -public class DependenciesTest009 { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Check that usages does not change during incremental compilation and that dependencies are - * identical. - */ - @Test - public void testDependency001() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n" - + "public class A extends B { }"); - - ite.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n" - + "public class B extends C { }"); - - ite.addJavaFile("jack.incremental", "C.java", "package jack.incremental; \n" - + "public class C { }"); - - ite.incrementalBuildFromFolder(); - - CompilerState csm = new CompilerState(ite.getCompilerStateFolder()); - csm.read(); - Map<String, Set<String>> dependencies1 = csm.computeDependencies(); - - ite.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n" - + "public class A extends B { public int field;}"); - - ite.incrementalBuildFromFolder(); - - csm.read(); - Map<String, Set<String>> dependencies2 = csm.computeDependencies(); - - assert dependencies1.equals(dependencies2); - Assert.assertEquals(dependencies1, dependencies2); - } -} diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest010.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest010.java deleted file mode 100644 index 204d336..0000000 --- a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest010.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.experimental.incremental; - -import com.android.jack.Main; -import com.android.jack.TestTools; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -import java.util.List; - -/** - * JUnit test checking dependencies between Java files. - */ -@Ignore("Tree") -public class DependenciesTest010 { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Check that incremental compilation support switch on constant value. - */ - @Test - public void testDependency001() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n" - + "public class A { " - + "public static void main(String[] args) {" - + " System.out.print(new A().test(2));" - + " }" - + " public int test(int value) {" - + " switch(value) {" - + " case B.val1: return 1;" - + " case B.val2: return 2;" - + " case B.val3: return 3;" - + " }" - + " return 0;" - + " } }"); - - ite.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n" - + "public class B { \n" - + " public static final int val1 = 1;" - + " public static final int val2 = 2;" - + " public static final int val3 = val2 + C.val4;" - + "}"); - - ite.addJavaFile("jack.incremental", "C.java", "package jack.incremental; \n" - + "public class C { \n" - + " public static final int val4 = 1;" - + "}"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - Assert.assertEquals("2", ite.run("jack.incremental.A")); - - ite.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n" - + "public class B { \n" - + " public static final int val1 =11;" - + " public static final int val2 =12;" - + " public static final int val3 =13;" - + "}"); - - ite.incrementalBuildFromFolder(); - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(2, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - Assert.assertEquals("0", ite.run("jack.incremental.A")); - - ite.snapshotJackFilesModificationDate(); - ite.addJavaFile("jack.incremental", "C.java", "package jack.incremental; \n" - + "public class C { \n" - + " public static final int val4 = 0;" - + "}"); - - ite.incrementalBuildFromFolder(); - fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(1, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.C")); - Assert.assertEquals("0", ite.run("jack.incremental.A")); - - ite.snapshotJackFilesModificationDate(); - ite.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n" - + "public class A { " - + "public static void main(String[] args) {" - + " System.out.print(new A().test(12));" - + " }" - + " public int test(int value) {" - + " switch(value) {" - + " case B.val1: return 1;" - + " case B.val2: return 2;" - + " case B.val3: return 3;" - + " }" - + " return 0;" - + " } }"); - - ite.incrementalBuildFromFolder(); - fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(1, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertEquals("2", ite.run("jack.incremental.A")); - } - - - /** - * Check that incremental compilation support switch on enum. - */ - @Test - public void testDependency002() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_002")); - - ite.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n" - + "import jack.incremental.B;" - + "public class A { " - + "public static void main(String[] args) {" - + " System.out.print(new A().test(B.VAL1));" - + " }" - + " public int test(B b) {" - + " switch(b) {" - + " case VAL1: return 1;" - + " case VAL2: return C.val4;" - + " case VAL3: return 3;" - + " }" - + " return 0;" - + " } }"); - - ite.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n" - + "public enum B { \n" - + " VAL1," - + " VAL2," - + " VAL3" - + "}"); - - ite.addJavaFile("jack.incremental", "C.java", "package jack.incremental; \n" - + "public class C { \n" - + " public static final int val4 =2;" - + "}"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - Assert.assertEquals("1", ite.run("jack.incremental.A")); - - ite.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n" - + "public enum B { \n" - + " VAL1," - + " VAL2," - + " VAL3," - + " VAL4" - + "}"); - - ite.incrementalBuildFromFolder(); - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(2, fqnOfRebuiltTypes.size()); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.A")); - Assert.assertTrue(fqnOfRebuiltTypes.contains("jack.incremental.B")); - Assert.assertEquals("1", ite.run("jack.incremental.A")); - } - -} - diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest011.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest011.java deleted file mode 100644 index b00d4b8..0000000 --- a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest011.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.experimental.incremental; - -import com.android.jack.Main; -import com.android.jack.TestTools; -import com.android.jack.frontend.FrontendCompilationException; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.util.List; - -/** - * JUnit test checking dependencies between Java files. - */ -public class DependenciesTest011 { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Check that incremental compilation support throws declaration. - */ - @Test - public void testDependency001() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n" - + "public class A extends Exception { " - + "}"); - - ite.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n" - + "public class B { \n" - + " public void m() throws A { }" - + "}"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - Assert.assertEquals(2, ite.getJackFiles().size()); - - ite.deleteJavaFile("jack.incremental", "A.java"); - - try { - ite.incrementalBuildFromFolder(); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Ok - } - - ite.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n" - + "public class B { \n" - + " public void m() { }" - + "}"); - - ite.incrementalBuildFromFolder(); - List<String> fqnOfRebuiltTypes = ite.getFQNOfRebuiltTypes(); - Assert.assertEquals(1, fqnOfRebuiltTypes.size()); - } -} - diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest012.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest012.java deleted file mode 100644 index 02d7e01..0000000 --- a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest012.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.experimental.incremental; - -import com.android.jack.Main; -import com.android.jack.TestTools; -import com.android.jack.frontend.FrontendCompilationException; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test checking dependencies between Java files. - */ -public class DependenciesTest012 { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Check that incremental compilation support class literal usages. - */ - @Test - public void testDependency001() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n" - + "public class A { \n" - + "public Class getClazz() { " - + " return B.class; " - + "} " - + "}"); - - ite.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n" - + "public class B { \n" - + "}"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - Assert.assertEquals(2, ite.getJackFiles().size()); - - ite.deleteJavaFile("jack.incremental", "B.java"); - - try { - ite.incrementalBuildFromFolder(); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Ok - } - } -} - diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest013.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest013.java deleted file mode 100644 index d69f18f..0000000 --- a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest013.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.experimental.incremental; - -import com.android.jack.Main; -import com.android.jack.TestTools; -import com.android.jack.frontend.FrontendCompilationException; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test checking dependencies between Java files. - */ -public class DependenciesTest013 { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Check that incremental compilation support array creation. - */ - @Test - public void testDependency001() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n" - + "public class A { \n" - + "public int getLength() { " - + " return new B[1].length; " - + "} " - + "}"); - - ite.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n" - + "public class B { \n" - + "}"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - Assert.assertEquals(2, ite.getJackFiles().size()); - - ite.deleteJavaFile("jack.incremental", "B.java"); - - try { - ite.incrementalBuildFromFolder(); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Ok - } finally { - Assert.assertTrue(ite.getStringRepresentingErr().contains("B cannot be resolved to a type")); - } - } - - /** - * Check that incremental compilation support array usages. - */ - @Test - public void testDependency002() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n" - + "public class A { \n" - + "public int getLength() { " - + " return B.array.length; " - + "} " - + "}"); - - ite.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n" - + "public class B { \n" - + "public static C []array; \n" - + "}"); - - ite.addJavaFile("jack.incremental", "C.java", "package jack.incremental; \n" - + "public class C { \n" - + "}"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - Assert.assertEquals(3, ite.getJackFiles().size()); - - ite.deleteJavaFile("jack.incremental", "C.java"); - - try { - ite.incrementalBuildFromFolder(); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Ok - } finally { - Assert.assertTrue(ite.getStringRepresentingErr().contains("C cannot be resolved to a type")); - } - } - - /** - * Check that incremental compilation support array usages. - */ - @Test - public void testDependency003() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n" - + "public class A { \n" - + "public int getLength() { " - + " return B.array.length; " - + "} " - + "}"); - - ite.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n" - + "public class B { \n" - + "public static C [][]array; \n" - + "}"); - - ite.addJavaFile("jack.incremental", "C.java", "package jack.incremental; \n" - + "public class C { \n" - + "}"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - Assert.assertEquals(3, ite.getJackFiles().size()); - - ite.deleteJavaFile("jack.incremental", "C.java"); - - try { - ite.incrementalBuildFromFolder(); - Assert.fail(); - } catch (FrontendCompilationException e) { - // Ok - } finally { - Assert.assertTrue(ite.getStringRepresentingErr().contains("C cannot be resolved to a type")); - } - } -} - diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest014.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest014.java deleted file mode 100644 index c73e9ab..0000000 --- a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest014.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.experimental.incremental; - -import com.android.jack.Main; -import com.android.jack.TestTools; -import com.android.jack.dx.io.DexBuffer; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.FileInputStream; - -/** - * JUnit test checking incremental support when files are deleted. - */ -public class DependenciesTest014 { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Check that incremental compilation works when file without dependency is deleted. - */ - @Test - public void testDependency001() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n" - + "public class A { \n" + "}"); - - ite.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n" - + "public class B { \n" + "}"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - Assert.assertEquals(2, ite.getJackFiles().size()); - - ite.deleteJavaFile("jack.incremental", "B.java"); - ite.incrementalBuildFromFolder(); - DexBuffer db = new DexBuffer(new FileInputStream(ite.getDexFile())); - for (String typeName : db.typeNames()) { - if (typeName.equals("Ljack/incremental/B;")) { - Assert.fail(); - } - } - } - - /** - * Check that incremental compilation works when dependency file is deleted. - */ - @Test - public void testDependency002() throws Exception { - IncrementalTestingEnvironment ite = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001")); - - ite.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n" - + "public class A { \n" + "}"); - - ite.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n" - + "public class B extends C { \n" + "}"); - - ite.addJavaFile("jack.incremental", "C.java", "package jack.incremental; \n" - + "public class C { \n" + "}"); - - ite.incrementalBuildFromFolder(); - ite.snapshotJackFilesModificationDate(); - Assert.assertEquals(3, ite.getJackFiles().size()); - - ite.deleteJavaFile("jack.incremental", "B.java"); - ite.deleteJavaFile("jack.incremental", "C.java"); - ite.incrementalBuildFromFolder(); - DexBuffer db = new DexBuffer(new FileInputStream(ite.getDexFile())); - for (String typeName : db.typeNames()) { - if (typeName.equals("Ljack/incremental/B;") || - typeName.equals("Ljack/incremental/C;")) { - Assert.fail(); - } - } - } -} - diff --git a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest015.java b/jack/tests/com/android/jack/experimental/incremental/DependenciesTest015.java deleted file mode 100644 index acd3cb3..0000000 --- a/jack/tests/com/android/jack/experimental/incremental/DependenciesTest015.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.experimental.incremental; - -import com.android.jack.Main; -import com.android.jack.TestTools; -import com.android.jack.dx.io.DexBuffer; -import com.android.jack.frontend.FrontendCompilationException; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; -import java.io.FileInputStream; -import java.util.Arrays; -import java.util.List; - -/** - * JUnit test checking incremental support. - */ -public class DependenciesTest015 { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Check that incremental compilation works when library on classpath is modified. - */ - @Test - public void testDependency001() throws Exception { - IncrementalTestingEnvironment iteLib = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001_lib")); - - iteLib.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n" - + "public abstract class A { \n" + "public abstract void m(); }"); - - iteLib.incrementalBuildFromFolder(); - iteLib.snapshotJackFilesModificationDate(); - List<File> jackFilesLib = iteLib.getJackFiles(); - Assert.assertEquals(1, jackFilesLib.size()); - - - IncrementalTestingEnvironment iteProg = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001_prog")); - - iteProg.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n" - + "public class B extends A { \n" + " @Override public void m(){} }"); - - iteProg.incrementalBuildFromFolder(new File[]{iteLib.getJackFolder()}); - iteProg.snapshotJackFilesModificationDate(); - Assert.assertEquals(1, iteProg.getJackFiles().size()); - - iteLib.deleteJavaFile("jack.incremental", "A.java"); - iteLib.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n" - + "public abstract class A { \n" + "public abstract int m(); }"); - iteLib.incrementalBuildFromFolder(); - iteLib.snapshotJackFilesModificationDate(); - jackFilesLib = iteLib.getJackFiles(); - Assert.assertEquals(1, jackFilesLib.size()); - - try { - iteProg.incrementalBuildFromFolder(new File[] {iteLib.getJackFolder()}); - Assert.fail(); - } catch (FrontendCompilationException e) { - Assert.assertTrue(iteProg.getStringRepresentingErr().contains( - "The return type is incompatible with A.m()")); - } - } - - /** - * Check that incremental compilation works when library on import options is modified. - */ - @Test - public void testDependency002() throws Exception { - IncrementalTestingEnvironment iteLib = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001_lib")); - - iteLib.addJavaFile("jack.incremental", "A.java", "package jack.incremental; \n" - + "public class A { \n" + "public void m() {} }"); - - iteLib.incrementalBuildFromFolder(); - iteLib.snapshotJackFilesModificationDate(); - List<File> jackFilesLib = iteLib.getJackFiles(); - Assert.assertEquals(1, jackFilesLib.size()); - - - IncrementalTestingEnvironment iteProg = - new IncrementalTestingEnvironment(TestTools.createTempDir("DependenciesTest_", "_001_prog")); - - iteProg.addJavaFile("jack.incremental", "B.java", "package jack.incremental; \n" - + "public class B { \n" + " public void m(){} }"); - - iteProg.incrementalBuildFromFolder(null /*classpath*/, Arrays.asList(iteLib.getJackFolder())); - iteProg.snapshotJackFilesModificationDate(); - Assert.assertEquals(2, iteProg.getJackFiles().size()); - - DexBuffer db = new DexBuffer(new FileInputStream(iteProg.getDexFile())); - Assert.assertTrue(db.typeNames().contains("Ljack/incremental/A;")); - Assert.assertTrue(db.typeNames().contains("Ljack/incremental/B;")); - - iteLib.addJavaFile("jack.incremental", "C.java", "package jack.incremental; \n" - + "public class C { \n" + "public void m() {} }"); - iteLib.incrementalBuildFromFolder(); - iteLib.snapshotJackFilesModificationDate(); - jackFilesLib = iteLib.getJackFiles(); - Assert.assertEquals(2, jackFilesLib.size()); - - - iteProg.incrementalBuildFromFolder(null, Arrays.asList(iteLib.getJackFolder())); - iteProg.snapshotJackFilesModificationDate(); - Assert.assertEquals(3, iteProg.getJackFiles().size()); - - db = new DexBuffer(new FileInputStream(iteProg.getDexFile())); - Assert.assertTrue(db.typeNames().contains("Ljack/incremental/A;")); - Assert.assertTrue(db.typeNames().contains("Ljack/incremental/B;")); - Assert.assertTrue(db.typeNames().contains("Ljack/incremental/C;")); - } -} - diff --git a/jack/tests/com/android/jack/experimental/incremental/DependencyAllTests.java b/jack/tests/com/android/jack/experimental/incremental/DependencyAllTests.java deleted file mode 100644 index e8b42a8..0000000 --- a/jack/tests/com/android/jack/experimental/incremental/DependencyAllTests.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.android.jack.experimental.incremental; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -@RunWith(Suite.class) -@SuiteClasses(value = {DependenciesTest001.class, DependenciesTest002.class, - DependenciesTest003.class, DependenciesTest004.class, DependenciesTest005.class, - DependenciesTest006.class, DependenciesTest007.class, DependenciesTest008.class, - DependenciesTest009.class, DependenciesTest010.class, DependenciesTest011.class, - DependenciesTest012.class, DependenciesTest013.class, DependenciesTest014.class, - DependenciesTest015.class}) -public class DependencyAllTests { -}
\ No newline at end of file diff --git a/jack/tests/com/android/jack/frontend/AllTests.java b/jack/tests/com/android/jack/frontend/AllTests.java index c3041fa..b681ddf 100644 --- a/jack/tests/com/android/jack/frontend/AllTests.java +++ b/jack/tests/com/android/jack/frontend/AllTests.java @@ -25,12 +25,8 @@ import org.junit.runners.Suite.SuiteClasses; TypeModifierTest.class, FieldModifierTest.class, MethodModifierTest.class, - MissingClassTest.class, ClinitTest.class, InitTest.class, - InstanceTest.class, - LabelTest.class, - StringTest.class, GotoTest.class, SwitchTest.class, SynchronizedTest.class}) diff --git a/jack/tests/com/android/jack/frontend/ClinitTest.java b/jack/tests/com/android/jack/frontend/ClinitTest.java index 2203716..f66a8df 100644 --- a/jack/tests/com/android/jack/frontend/ClinitTest.java +++ b/jack/tests/com/android/jack/frontend/ClinitTest.java @@ -17,7 +17,6 @@ package com.android.jack.frontend; import com.android.jack.Main; -import com.android.jack.Options; import com.android.jack.TestTools; import com.android.jack.ir.ast.JAsgOperation; import com.android.jack.ir.ast.JBlock; @@ -66,13 +65,6 @@ public class ClinitTest { } @Test - public void testCompileWithClinit() throws Exception { - Options compilerArgs = TestTools.buildCommandLineArgs( - TestTools.getJackTestFromBinaryName(CLASS_WITH_VARIABLE_INIT_BINARY_NAME)); - TestTools.runCompilation(compilerArgs); - } - - @Test public void searchEmptyStaticInit() throws Exception { JMethod clinit = TestTools.getJMethodWithRejectAllFilter( TestTools.getJackTestFromBinaryName(CLASS_BINARY_NAME), diff --git a/jack/tests/com/android/jack/frontend/InitTest.java b/jack/tests/com/android/jack/frontend/InitTest.java index b32790d..db60fbb 100644 --- a/jack/tests/com/android/jack/frontend/InitTest.java +++ b/jack/tests/com/android/jack/frontend/InitTest.java @@ -16,7 +16,6 @@ package com.android.jack.frontend; -import com.android.jack.Options; import com.android.jack.TestTools; import com.android.jack.ir.ast.JMethod; import com.android.jack.util.NamingTools; @@ -35,7 +34,7 @@ public class InitTest { @Test public void searchInit() throws Exception { - String binaryName = "com/android/jack/fibonacci/jack/Fibo"; + String binaryName = "com/android/jack/fibonacci/test001/jack/Fibo"; JMethod init = TestTools.getJMethodWithRejectAllFilter( TestTools.getJackTestFromBinaryName(binaryName), "L" + binaryName + ";", @@ -44,17 +43,4 @@ public class InitTest { Assert.assertNotNull(init); } - @Test - public void testCompileEmptyConstructor() throws Exception { - Options compilerArgs = TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("init/test001")); - TestTools.runCompilation(compilerArgs); - } - - @Test - public void testVariableInit() throws Exception { - Options compilerArgs = TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("init/test002")); - TestTools.runCompilation(compilerArgs); - } }
\ No newline at end of file diff --git a/jack/tests/com/android/jack/frontend/InstanceTest.java b/jack/tests/com/android/jack/frontend/InstanceTest.java deleted file mode 100644 index 8538d14..0000000 --- a/jack/tests/com/android/jack/frontend/InstanceTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack.frontend; - -import com.android.jack.Options; -import com.android.jack.TestTools; - -import org.junit.Before; -import org.junit.Test; - -public class InstanceTest { - - @Before - public void setUp() throws Exception { - ConstantReuseTest.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testReturnThis() throws Exception { - Options compilerArgs = TestTools.buildCommandLineArgs( - TestTools.getJackTestFromBinaryName("com/android/jack/instance/test001/jack/Instance")); - TestTools.runCompilation(compilerArgs); - } -} diff --git a/jack/tests/com/android/jack/frontend/LabelTest.java b/jack/tests/com/android/jack/frontend/LabelTest.java deleted file mode 100644 index 67b7a59..0000000 --- a/jack/tests/com/android/jack/frontend/LabelTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack.frontend; - -import com.android.jack.Options; -import com.android.jack.TestTools; - -import org.junit.Before; -import org.junit.Test; - -public class LabelTest { - - @Before - public void setUp() throws Exception { - ConstantReuseTest.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void labelMustNotBreakTree() throws Exception { - Options compilerArgs = TestTools.buildCommandLineArgs( - TestTools.getJackTestFromBinaryName("com/android/jack/label/test001/jack/Label")); - TestTools.runCompilation(compilerArgs); - } -} diff --git a/jack/tests/com/android/jack/frontend/MissingClassTest.java b/jack/tests/com/android/jack/frontend/MissingClassTest.java deleted file mode 100644 index 2d697ac..0000000 --- a/jack/tests/com/android/jack/frontend/MissingClassTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.frontend; - -import com.android.jack.Options; -import com.android.jack.TestTools; -import com.android.jack.category.KnownBugs; - -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.File; - -public class MissingClassTest { - - @Test - @Category(KnownBugs.class) - public void test001() throws Exception { - File outJackTmpMissing = TestTools.createTempDir("MissingClassTest001-missing", ".jayce"); - File outJackTmpSuper = TestTools.createTempDir("MissingClassTest001-super", ".jayce"); - File outJackTmpTest = TestTools.createTempDir("MissingClassTest001-test", ".jayce"); - - TestTools.compileSourceToJack(new Options(), - new File(TestTools.getJackTestsWithJackFolder("frontend/test001"), "missing"), - TestTools.getDefaultBootclasspathString(), outJackTmpMissing, false /* zip */); - - TestTools.compileSourceToJack(new Options(), - new File(TestTools.getJackTestsWithJackFolder("frontend/test001"), "sub2"), - TestTools.getDefaultBootclasspathString() + File.pathSeparator - + outJackTmpMissing.getPath(), outJackTmpSuper, false /* zip */); - - TestTools.compileSourceToJack(new Options(), - new File(TestTools.getJackTestsWithJackFolder("frontend/test001"), "test"), - TestTools.getDefaultBootclasspathString() + File.pathSeparator + outJackTmpSuper.getPath(), - outJackTmpTest, false /* zip */); - - } - -} diff --git a/jack/tests/com/android/jack/frontend/StringTest.java b/jack/tests/com/android/jack/frontend/StringTest.java deleted file mode 100644 index cd9e889..0000000 --- a/jack/tests/com/android/jack/frontend/StringTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack.frontend; - -import com.android.jack.Options; -import com.android.jack.TestTools; - -import org.junit.Before; -import org.junit.Test; - -public class StringTest { - - @Before - public void setUp() throws Exception { - StringTest.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testCompileNewString() throws Exception { - Options compilerArgs = TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("string001")); - TestTools.runCompilation(compilerArgs); - } -} diff --git a/jack/tests/com/android/jack/frontend/SwitchTest.java b/jack/tests/com/android/jack/frontend/SwitchTest.java index fd34953..d4598af 100644 --- a/jack/tests/com/android/jack/frontend/SwitchTest.java +++ b/jack/tests/com/android/jack/frontend/SwitchTest.java @@ -46,7 +46,7 @@ public class SwitchTest { @Before public void setUp() throws Exception { - StringTest.class.getClassLoader().setDefaultAssertionStatus(true); + SwitchTest.class.getClassLoader().setDefaultAssertionStatus(true); } @Test diff --git a/jack/tests/com/android/jack/frontend/SynchronizedTest.java b/jack/tests/com/android/jack/frontend/SynchronizedTest.java index 0637072..9d27177 100644 --- a/jack/tests/com/android/jack/frontend/SynchronizedTest.java +++ b/jack/tests/com/android/jack/frontend/SynchronizedTest.java @@ -23,8 +23,8 @@ import com.android.jack.ir.ast.JClassLiteral; import com.android.jack.ir.ast.JLock; import com.android.jack.ir.ast.JMethod; import com.android.jack.ir.ast.JMethodBody; -import com.android.jack.ir.ast.JSession; import com.android.jack.ir.ast.JReturnStatement; +import com.android.jack.ir.ast.JSession; import com.android.jack.ir.ast.JStatement; import com.android.jack.ir.ast.JSynchronizedBlock; import com.android.jack.ir.ast.JUnlock; @@ -54,7 +54,7 @@ public class SynchronizedTest { @Before public void setUp() throws Exception { - StringTest.class.getClassLoader().setDefaultAssertionStatus(true); + SynchronizedTest.class.getClassLoader().setDefaultAssertionStatus(true); } @Test diff --git a/jack/tests/com/android/jack/gwt/BinaryLookup.java b/jack/tests/com/android/jack/gwt/BinaryLookup.java index 8d4c44b..5eda472 100644 --- a/jack/tests/com/android/jack/gwt/BinaryLookup.java +++ b/jack/tests/com/android/jack/gwt/BinaryLookup.java @@ -51,7 +51,7 @@ public class BinaryLookup { Main.class.getClassLoader().setDefaultAssertionStatus(true); Options fiboArgs = TestTools.buildCommandLineArgs( - TestTools.getJackTestFromBinaryName("com/android/jack/fibonacci/jack/Fibo")); + TestTools.getJackTestFromBinaryName("com/android/jack/fibonacci/test001/jack/Fibo")); fiboArgs.addProperty(Options.METHOD_FILTER.getName(), "reject-all-methods"); hooks = new RunnableHooks(); session = TestTools.buildSession(fiboArgs, hooks); diff --git a/jack/tests/com/android/jack/java7/AllTest.java b/jack/tests/com/android/jack/java7/AllTest.java deleted file mode 100644 index a865c94..0000000 --- a/jack/tests/com/android/jack/java7/AllTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.java7; - - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -/** - * JUnit test for compilation of Java 7 features - */ -@RunWith(Suite.class) -@SuiteClasses(value = {SwitchesTest.class, ExceptionsTest.class, BoxingTest.class}) -public class AllTest { -} diff --git a/jack/tests/com/android/jack/java7/BoxingTest.java b/jack/tests/com/android/jack/java7/BoxingTest.java deleted file mode 100644 index 160a17a..0000000 --- a/jack/tests/com/android/jack/java7/BoxingTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.java7; - -import com.android.jack.Main; -import com.android.jack.Options; -import com.android.jack.TestTools; -import com.android.jack.category.KnownBugs; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -/** - * JUnit test for compilation of Java 7 features - */ -public class BoxingTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Category(KnownBugs.class) - @Test - public void java7Boxing001() throws Exception { - Options options = TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("java7/boxing/test001")); - options.addProperty(Options.JAVA_SOURCE_VERSION.getName(), "1.7"); - TestTools.runCompilation(options); - } -} diff --git a/jack/tests/com/android/jack/java7/ExceptionsTest.java b/jack/tests/com/android/jack/java7/ExceptionsTest.java deleted file mode 100644 index 1339bee..0000000 --- a/jack/tests/com/android/jack/java7/ExceptionsTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.java7; - -import com.android.jack.Main; -import com.android.jack.Options; -import com.android.jack.TestTools; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of Java 7 features - */ -public class ExceptionsTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void java7Exception001() throws Exception { - Options options = TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("java7/exceptions/test001")); - options.addProperty(Options.JAVA_SOURCE_VERSION.getName(), "1.7"); - TestTools.runCompilation(options); - } - - @Test - public void java7Exception002() throws Exception { - Options options = TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("java7/exceptions/test002")); - options.addProperty(Options.JAVA_SOURCE_VERSION.getName(), "1.7"); - TestTools.runCompilation(options); - } - - @Test - public void java7Exception003() throws Exception { - Options options = TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("java7/exceptions/test003")); - options.addProperty(Options.JAVA_SOURCE_VERSION.getName(), "1.7"); - TestTools.runCompilation(options); - } - - @Test - public void java7Exception004() throws Exception { - Options options = TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("java7/exceptions/test004")); - options.addProperty(Options.JAVA_SOURCE_VERSION.getName(), "1.7"); - TestTools.runCompilation(options); - } - - @Test - public void java7Exception005() throws Exception { - Options options = TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("java7/exceptions/test005")); - options.addProperty(Options.JAVA_SOURCE_VERSION.getName(), "1.7"); - TestTools.runCompilation(options); - } -} diff --git a/jack/tests/com/android/jack/java7/SwitchesTest.java b/jack/tests/com/android/jack/java7/SwitchesTest.java deleted file mode 100644 index 6474af1..0000000 --- a/jack/tests/com/android/jack/java7/SwitchesTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.java7; - -import com.android.jack.Main; -import com.android.jack.Options; -import com.android.jack.TestTools; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * JUnit test for compilation of Java 7 features - */ -public class SwitchesTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void java7Switches001() throws Exception { - Options options = TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("java7/switches/test001")); - options.addProperty(Options.JAVA_SOURCE_VERSION.getName(), "1.7"); - TestTools.runCompilation(options); - } - - @Test - public void java7Switches002() throws Exception { - Options options = TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("java7/switches/test002")); - options.addProperty(Options.JAVA_SOURCE_VERSION.getName(), "1.7"); - TestTools.runCompilation(options); - } - - @Test - public void java7Switches003() throws Exception { - Options options = TestTools.buildCommandLineArgs(TestTools - .getJackTestsWithJackFolder("java7/switches/test003")); - options.addProperty(Options.JAVA_SOURCE_VERSION.getName(), "1.7"); - TestTools.runCompilation(options); - } - - @Test - public void java7Switches004() throws Exception { - File jackZipFile = TestTools.createTempFile("tmp", ".zip"); - - Options options = new Options(); - options.addProperty(Options.JAVA_SOURCE_VERSION.getName(), "1.7"); - - TestTools.compileSourceToJack(options, - TestTools.getJackTestsWithJackFolder("java7/switches/test001"), - TestTools.getDefaultBootclasspathString(), jackZipFile, true /* zip */ - ); - - options = new Options(); - List<File> imports = new ArrayList<File>(1); - imports.add(jackZipFile); - options.setJayceImports(imports); - File outDexFolder = TestTools.createTempDir("tmp", "dex"); - TestTools.compileJackToDex(options, jackZipFile, outDexFolder, false /* zip */); - } -} diff --git a/jack/tests/com/android/jack/multidex/MultiDexOverflowTests.java b/jack/tests/com/android/jack/multidex/MultiDexOverflowTests.java deleted file mode 100644 index dc599f1..0000000 --- a/jack/tests/com/android/jack/multidex/MultiDexOverflowTests.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.multidex; - -import com.android.jack.JackAbortException; -import com.android.jack.Options; -import com.android.jack.TestTools; -import com.android.jack.backend.dex.DexFileWriter; -import com.android.jack.backend.dex.DexWritingException; -import com.android.jack.backend.dex.MainDexOverflowException; -import com.android.jack.backend.dex.MultiDexLegacy; -import com.android.jack.tools.merger.FieldIdOverflowException; -import com.android.jack.tools.merger.MethodIdOverflowException; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; - -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; - -public class MultiDexOverflowTests { - - @Nonnull - private static File annotations; - @Nonnull - private static final String EXPECTED_MESSAGE = - "Error during the dex writing phase: classes.dex has too many IDs"; - - @BeforeClass - public static void init() throws IOException, Exception { - annotations = MultiDexTests.prepareAnnotations(); - } - - @Test - public void testMinimalMainDexOverflowWithMethods() throws Exception { - File srcFolder = TestTools.createTempDir("src", "dir"); - File outFolder = TestTools.createTempDir("out", "dir"); - - int fileCount = 655; - for (int fileIdx = 0; fileIdx < fileCount; fileIdx++) { - generateJavaFileWithMethods(srcFolder, fileIdx, 100); - } - generateJavaFileWithMethods(srcFolder, fileCount, 36); - - Options options = new Options(); - options.addProperty(MultiDexLegacy.MULTIDEX_LEGACY.getName(), "true"); - options.addProperty(DexFileWriter.DEX_WRITING_POLICY.getName(), "minimal-multidex"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream redirectStream = new PrintStream(baos); - System.setErr(redirectStream); - try { - TestTools.compileSourceToDex(options, srcFolder, TestTools.getClasspathsAsString( - TestTools.getDefaultBootclasspath(), new File[] {annotations}), outFolder, false /* zip */ - ); - Assert.fail(); - } catch (JackAbortException e) { - Throwable cause = e.getCause(); - Assert.assertTrue(cause instanceof DexWritingException); - Assert.assertTrue(cause.getCause() instanceof MainDexOverflowException); - Assert.assertTrue(cause.getCause().getCause() instanceof MethodIdOverflowException); - Assert.assertTrue(baos.toString().contains(EXPECTED_MESSAGE)); - } finally { - redirectStream.close(); - } - } - - @Test - public void testStandardMainDexOverflowWithFields() throws Exception { - File srcFolder = TestTools.createTempDir("src", "dir"); - File outFolder = TestTools.createTempDir("out", "dir"); - - int fileCount = 655; - for (int fileIdx = 0; fileIdx < fileCount; fileIdx++) { - generateJavaFileWithFields(srcFolder, fileIdx, 100); - } - generateJavaFileWithFields(srcFolder, fileCount, 37); - - Options options = new Options(); - options.addProperty(MultiDexLegacy.MULTIDEX_LEGACY.getName(), "true"); - options.addProperty(DexFileWriter.DEX_WRITING_POLICY.getName(), "multidex"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream redirectStream = new PrintStream(baos); - System.setErr(redirectStream); - try { - TestTools.compileSourceToDex(options, srcFolder, TestTools.getClasspathsAsString( - TestTools.getDefaultBootclasspath(), new File[] {annotations}), outFolder, false /* zip */ - ); - Assert.fail(); - } catch (JackAbortException e) { - Throwable cause = e.getCause(); - Assert.assertTrue(cause instanceof DexWritingException); - Assert.assertTrue(cause.getCause() instanceof MainDexOverflowException); - Assert.assertTrue(cause.getCause().getCause() instanceof FieldIdOverflowException); - Assert.assertTrue(baos.toString().contains(EXPECTED_MESSAGE)); - } finally { - redirectStream.close(); - } - } - - private void generateJavaFileWithMethods(@Nonnull File srcFolder, @Nonnegative int fileIdx, - @Nonnegative int methodCount) throws IOException, FileNotFoundException { - File javaFile = new File(srcFolder, "A" + fileIdx + ".java"); - if (!javaFile.createNewFile()) { - throw new IOException("Failed to create file " + javaFile.getAbsolutePath()); - } - FileOutputStream fos = null; - try { - fos = new FileOutputStream(javaFile); - StringBuilder content = new StringBuilder("package jack.merger; \n" - + "@com.android.jack.annotations.ForceInMainDex public class A" + fileIdx + " {\n"); - // -1 due to implicit init method - for (int mthIdx = 0; mthIdx < methodCount - 1; mthIdx++) { - content.append("public void m" + mthIdx + "() {} \n"); - } - content.append("} \n"); - fos.write(content.toString().getBytes()); - } finally { - if (fos != null) { - fos.close(); - } - } - } - - private void generateJavaFileWithFields(@Nonnull File srcFolder, @Nonnegative int fileIdx, - @Nonnegative int fieldCount) throws IOException, FileNotFoundException { - File javaFile = new File(srcFolder, "A" + fileIdx + ".java"); - if (!javaFile.createNewFile()) { - throw new IOException("Failed to create file " + javaFile.getAbsolutePath()); - } - FileOutputStream fos = null; - try { - fos = new FileOutputStream(javaFile); - StringBuilder content = new StringBuilder("package jack.merger; \n" - + "@com.android.jack.annotations.ForceInMainDex public class A" + fileIdx + " {\n"); - for (int fieldIdx = 0; fieldIdx < fieldCount; fieldIdx++) { - content.append("public int f" + fieldIdx + ";\n"); - } - content.append("} \n"); - fos.write(content.toString().getBytes()); - } finally { - if (fos != null) { - fos.close(); - } - } - } - -} diff --git a/jack/tests/com/android/jack/multidex/MultiDexTests.java b/jack/tests/com/android/jack/multidex/MultiDexTests.java deleted file mode 100644 index 9c89ee1..0000000 --- a/jack/tests/com/android/jack/multidex/MultiDexTests.java +++ /dev/null @@ -1,476 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.multidex; - -import com.google.common.io.Files; - -import com.android.jack.Options; -import com.android.jack.TestTools; -import com.android.jack.backend.dex.DexFileWriter; -import com.android.jack.backend.dex.MultiDexLegacy; -import com.android.jack.library.FileType; -import com.android.jack.preprocessor.PreProcessor; -import com.android.jack.shrob.ListingComparator; -import com.android.jack.util.ExecuteFile; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.Properties; - -import javax.annotation.Nonnull; - -public class MultiDexTests { - - private static File annotations; - private static File frameworks; - private static File library; - - @BeforeClass - public static void init() throws IOException, Exception { - annotations = prepareAnnotations(); - - frameworks = prepareFrameworks(); - - library = prepareLibrary(frameworks); - } - - @Test - public void versionedTest001a() throws Exception { - - File testFolder = TestTools.getJackTestsWithJackFolder("multidex/test001"); - File out = TestTools.createTempDir("out", ""); - Options app1Options = createCommonOptionsForMultiDex(new File(testFolder, "config-001.jpp")); - - app1Options.addProperty(DexFileWriter.DEX_WRITING_POLICY.getName(), "multidex"); - - TestTools.compileSourceToDex(app1Options, testFolder, TestTools.getDefaultBootclasspathString() - + File.pathSeparator + annotations.getPath() + File.pathSeparator + frameworks.getPath(), - out, false); - - File outList = getListingOfDex(new File(out, "classes.dex")); - ListingComparator.compare(new File(testFolder, "ref-list-001.txt"), outList); - Assert.assertFalse(new File(out, "classes2.dex").exists()); - return; - } - - @Test - public void versionedTest001b() throws Exception { - - File testFolder = TestTools.getJackTestsWithJackFolder("multidex/test001"); - File out = TestTools.createTempDir("out", ""); - Options app1Options = createCommonOptionsForMultiDex(new File(testFolder, "config-001.jpp")); - - app1Options.addProperty(DexFileWriter.DEX_WRITING_POLICY.getName(), "minimal-multidex"); - - TestTools.compileSourceToDex(app1Options, testFolder, TestTools.getDefaultBootclasspathString() - + File.pathSeparator + annotations.getPath() + File.pathSeparator + frameworks.getPath(), - out, false); - - File outList = getListingOfDex(new File(out, "classes.dex")); - ListingComparator.compare(new File(testFolder, "ref-list-002-1.txt"), outList); - File outList2 = getListingOfDex(new File(out, "classes2.dex")); - ListingComparator.compare(new File(testFolder, "ref-list-002-2.txt"), outList2); - Assert.assertFalse(new File(out, "classes3.dex").exists()); - return; - } - - @Test - public void versionedTest001c() throws Exception { - - File testFolder = TestTools.getJackTestsWithJackFolder("multidex/test001"); - File out = TestTools.createTempDir("out", ""); - Options app1Options = createCommonOptionsForMultiDex(new File(testFolder, "config-003.jpp")); - - app1Options.addProperty(DexFileWriter.DEX_WRITING_POLICY.getName(), "minimal-multidex"); - - TestTools.compileSourceToDex(app1Options, testFolder, TestTools.getDefaultBootclasspathString() - + File.pathSeparator + annotations.getPath() + File.pathSeparator + frameworks.getPath(), - out, false); - - File outList = getListingOfDex(new File(out, "classes.dex")); - ListingComparator.compare(new File(testFolder, "ref-list-003-1.txt"), outList); - File outList2 = getListingOfDex(new File(out, "classes2.dex")); - ListingComparator.compare(new File(testFolder, "ref-list-003-2.txt"), outList2); - Assert.assertFalse(new File(out, "classes3.dex").exists()); - return; - } - - @Test - public void versionedTest001a_withoutAnnotations() throws Exception { - - File testFolder = TestTools.getJackTestsWithJackFolder("multidex/test001"); - File out = TestTools.createTempDir("out", ""); - Options app1Options = createCommonOptionsForMultiDex(new File(testFolder, "config-001.jpp")); - - app1Options.addProperty(DexFileWriter.DEX_WRITING_POLICY.getName(), "multidex"); - - TestTools.compileSourceToDex(app1Options, testFolder, TestTools.getDefaultBootclasspathString() - + File.pathSeparator + frameworks.getPath(), - out, false); - - File outList = getListingOfDex(new File(out, "classes.dex")); - ListingComparator.compare(new File(testFolder, "ref-list-001.txt"), outList); - Assert.assertFalse(new File(out, "classes2.dex").exists()); - return; - } - - @Test - public void versionedTest001b__withoutAnnotations() throws Exception { - - File testFolder = TestTools.getJackTestsWithJackFolder("multidex/test001"); - File out = TestTools.createTempDir("out", ""); - Options app1Options = createCommonOptionsForMultiDex(new File(testFolder, "config-001.jpp")); - - app1Options.addProperty(DexFileWriter.DEX_WRITING_POLICY.getName(), "minimal-multidex"); - - TestTools.compileSourceToDex(app1Options, testFolder, TestTools.getDefaultBootclasspathString() - + File.pathSeparator + frameworks.getPath(), - out, false); - - File outList = getListingOfDex(new File(out, "classes.dex")); - ListingComparator.compare(new File(testFolder, "ref-list-002-1.txt"), outList); - File outList2 = getListingOfDex(new File(out, "classes2.dex")); - ListingComparator.compare(new File(testFolder, "ref-list-002-2.txt"), outList2); - Assert.assertFalse(new File(out, "classes3.dex").exists()); - return; - } - - @Test - public void versionedTest001c_withoutAnnotations() throws Exception { - - File testFolder = TestTools.getJackTestsWithJackFolder("multidex/test001"); - File out = TestTools.createTempDir("out", ""); - Options app1Options = createCommonOptionsForMultiDex(new File(testFolder, "config-003.jpp")); - - app1Options.addProperty(DexFileWriter.DEX_WRITING_POLICY.getName(), "minimal-multidex"); - - TestTools.compileSourceToDex(app1Options, testFolder, TestTools.getDefaultBootclasspathString() - + File.pathSeparator + frameworks.getPath(), - out, false); - - File outList = getListingOfDex(new File(out, "classes.dex")); - ListingComparator.compare(new File(testFolder, "ref-list-003-1.txt"), outList); - File outList2 = getListingOfDex(new File(out, "classes2.dex")); - ListingComparator.compare(new File(testFolder, "ref-list-003-2.txt"), outList2); - Assert.assertFalse(new File(out, "classes3.dex").exists()); - return; - } - - private Options createCommonOptionsForMultiDex(@Nonnull File configFile) { - Options app1Options = new Options(); - app1Options.addProperty(MultiDexLegacy.MULTIDEX_LEGACY.getName(), "true"); - app1Options.addProperty(PreProcessor.ENABLE.getName(), "true"); - app1Options.addProperty(PreProcessor.FILE.getName(), configFile.getAbsolutePath()); - return app1Options; - } - - private File getListingOfDex(@Nonnull File dex) throws IOException, FileNotFoundException { - assert dex.isFile(); - ExecuteFile exec = - new ExecuteFile(new String[]{ - "bash", "-c", "dexdump " - + dex.getAbsolutePath() + - " | grep \" Class descriptor : \" | cut -d\\' -f2 | sed -e 's/$/:/'"}); - - File outList = TestTools.createTempFile("types", ".txt"); - - exec.setOut(outList); - Assert.assertTrue(exec.run()); - return outList; - } - - private int getTypeCountInDex(@Nonnull File dex) throws IOException, FileNotFoundException { - assert dex.isFile(); - ExecuteFile exec = - new ExecuteFile(new String[]{ - "bash", "-c", "dexdump " - + dex.getAbsolutePath() + - " | grep \" Class descriptor : \" | wc -l"}); - - File out = TestTools.createTempFile("typeNumber", ".txt"); - - exec.setOut(out); - Assert.assertTrue(exec.run()); - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(out))); - try { - String readLine = reader.readLine(); - assert readLine != null; - return Integer.parseInt(readLine.trim()); - } finally { - reader.close(); - } - } - - @Nonnull - private static File prepareFrameworks() throws IOException, Exception { - File frameworks = TestTools.createTempDir("frameworks", ""); - TestTools.compileSourceToJack(new Options(), - TestTools.getJackTestFolder("multidex/fakeframeworks"), - TestTools.getDefaultBootclasspathString(), frameworks, false); - return frameworks; - } - - @Nonnull - protected static File prepareAnnotations() throws IOException, Exception { - File annotations = TestTools.createTempDir("multidexAnnotations", ""); - TestTools.compileSourceToJack(new Options(), - TestTools.getFromAndroidTree( - "toolchain/jack/jack-tests/tests/com/android/jack/annotations/"), - TestTools.getDefaultBootclasspathString(), annotations, false); - return annotations; - } - - @Nonnull - private static File prepareLibrary(@Nonnull File frameworks) throws IOException, Exception { - File library = TestTools.createTempDir("multidexLibrary", ""); - TestTools.compileSourceToJack(new Options(), - TestTools.getJackTestFolder("multidex/fakelibrary"), - TestTools.getDefaultBootclasspathString() + File.pathSeparator + frameworks.getPath(), - library, false); - - return library; - } - - private static void setMetaIntoJackProperties(@Nonnull File library) throws IOException { - File jackProperties = new File(library, "jack.properties"); - Properties libraryProperties = new Properties(); - FileInputStream fis = null; - FileOutputStream fos = null; - try { - fis = new FileInputStream(jackProperties); - libraryProperties.load(fis); - } catch (IOException e) { - Assert.fail(); - } finally { - if (fis != null) { - fis.close(); - } - } - try { - fos = new FileOutputStream(jackProperties); - libraryProperties.put(FileType.JPP.buildPropertyName(null /*suffix*/), "true"); - libraryProperties.store(fos, "Library properties"); - } catch (IOException e) { - Assert.fail(); - } finally { - if (fos != null) { - fos.close(); - } - } - } - - @Test - public void legacyAppTest002a() throws Exception { - - File testFolder = TestTools.getJackTestsWithJackFolder("multidex/test002"); - File out = TestTools.createTempDir("out", ""); - Options app1Options = createCommonOptionsForMultiDex( - new File(testFolder,"config-001.jpp")); - app1Options.addProperty(DexFileWriter.DEX_WRITING_POLICY.getName(), "multidex"); - - TestTools.compileSourceToDex(app1Options, testFolder, TestTools.getDefaultBootclasspathString() - + File.pathSeparator + annotations.getPath() + File.pathSeparator + frameworks.getPath() - + File.pathSeparator + library.getPath(), out, false); - - File classesDex = new File(out, "classes.dex"); - Assert.assertTrue(classesDex.exists()); - File classes2Dex = new File(out, "classes2.dex"); - Assert.assertTrue(classes2Dex.exists()); - File classes3Dex = new File(out, "classes3.dex"); - Assert.assertFalse(classes3Dex.exists()); - int totalTypeNumber = getTypeCountInDex(classesDex) + getTypeCountInDex(classes2Dex); - Assert.assertEquals(100, totalTypeNumber); - return; - } - - @Test - public void legacyAppTest002b() throws Exception { - - File testFolder = TestTools.getJackTestsWithJackFolder("multidex/test002"); - File out = TestTools.createTempDir("out", ""); - Options app1Options = createCommonOptionsForMultiDex( - new File(testFolder,"config-001.jpp")); - app1Options.addProperty(DexFileWriter.DEX_WRITING_POLICY.getName(), "minimal-multidex"); - app1Options.addJayceImport(library); - - TestTools.compileSourceToDex(app1Options, testFolder, TestTools.getDefaultBootclasspathString() - + File.pathSeparator + annotations.getPath() + File.pathSeparator + frameworks.getPath(), - out, false); - - File outList = getListingOfDex(new File(out, "classes.dex")); - // The old toolchain is doing a little better than us here it seems to identify when - // InterfaceWithEnum.class instance is used or not. - ListingComparator.compare( - new File(testFolder,"ref-list-002-1.txt"), outList); - File outList2 = getListingOfDex(new File(out, "classes2.dex")); - ListingComparator.compare( - new File(testFolder,"ref-list-002-2.txt"), outList2); - Assert.assertFalse(new File(out, "classes3.dex").exists()); - return; - } - - @Test - public void legacyAppTest002b_auto() throws Exception { - - File testFolder = TestTools.getJackTestsWithJackFolder("multidex/test002"); - File autoLibrary = prepareLibrary(frameworks); - setMetaIntoJackProperties(autoLibrary); - File jackInf = new File(autoLibrary, FileType.JPP.getPrefix()); - Assert.assertTrue(jackInf.mkdir()); - Files.copy(new File(testFolder,"config-001.jpp"), new File(jackInf, "config-001.jpp")); - - File out = TestTools.createTempDir("out", ""); - Options app1Options = new Options(); - app1Options.addProperty(MultiDexLegacy.MULTIDEX_LEGACY.getName(), "true"); - app1Options.addProperty(DexFileWriter.DEX_WRITING_POLICY.getName(), "minimal-multidex"); - app1Options.addJayceImport(autoLibrary); - - TestTools.compileSourceToDex(app1Options, testFolder, TestTools.getDefaultBootclasspathString() - + File.pathSeparator + annotations.getPath() + File.pathSeparator + frameworks.getPath(), - out, false); - - File outList = getListingOfDex(new File(out, "classes.dex")); - // The old toolchain is doing a little better than us here it seems to identify when - // InterfaceWithEnum.class instance is used or not. - ListingComparator.compare( - new File(testFolder,"ref-list-002-1.txt"), outList); - File outList2 = getListingOfDex(new File(out, "classes2.dex")); - ListingComparator.compare( - new File(testFolder,"ref-list-002-2.txt"), outList2); - Assert.assertFalse(new File(out, "classes3.dex").exists()); - return; - } - - @Test - public void legacyAppTest002a_withoutAnnotations() throws Exception { - - File testFolder = TestTools.getJackTestsWithJackFolder("multidex/test002"); - File out = TestTools.createTempDir("out", ""); - Options app1Options = createCommonOptionsForMultiDex( - new File(testFolder,"config-001.jpp")); - app1Options.addProperty(DexFileWriter.DEX_WRITING_POLICY.getName(), "multidex"); - - TestTools.compileSourceToDex(app1Options, testFolder, TestTools.getDefaultBootclasspathString() - + File.pathSeparator + frameworks.getPath() - + File.pathSeparator + library.getPath(), out, false); - - File classesDex = new File(out, "classes.dex"); - Assert.assertTrue(classesDex.exists()); - File classes2Dex = new File(out, "classes2.dex"); - Assert.assertTrue(classes2Dex.exists()); - File classes3Dex = new File(out, "classes3.dex"); - Assert.assertFalse(classes3Dex.exists()); - int totalTypeNumber = getTypeCountInDex(classesDex) + getTypeCountInDex(classes2Dex); - Assert.assertEquals(100, totalTypeNumber); - return; - } - - @Test - public void legacyAppTest002b_withoutAnnotations() throws Exception { - - File testFolder = TestTools.getJackTestsWithJackFolder("multidex/test002"); - File out = TestTools.createTempDir("out", ""); - Options app1Options = createCommonOptionsForMultiDex( - new File(testFolder,"config-001.jpp")); - app1Options.addProperty(DexFileWriter.DEX_WRITING_POLICY.getName(), "minimal-multidex"); - app1Options.addJayceImport(library); - - TestTools.compileSourceToDex(app1Options, testFolder, TestTools.getDefaultBootclasspathString() - + File.pathSeparator + frameworks.getPath(), - out, false); - - File outList = getListingOfDex(new File(out, "classes.dex")); - // The old toolchain is doing a little better than us here it seems to identify when - // InterfaceWithEnum.class instance is used or not. - ListingComparator.compare( - new File(testFolder,"ref-list-002-1.txt"), outList); - File outList2 = getListingOfDex(new File(out, "classes2.dex")); - ListingComparator.compare( - new File(testFolder,"ref-list-002-2.txt"), outList2); - Assert.assertFalse(new File(out, "classes3.dex").exists()); - return; - } - - @Test - public void legacyAppTest002b_auto_withoutAnnotations() throws Exception { - - File testFolder = TestTools.getJackTestsWithJackFolder("multidex/test002"); - File autoLibrary = prepareLibrary(frameworks); - setMetaIntoJackProperties(autoLibrary); - File jackInf = new File(autoLibrary, FileType.JPP.getPrefix()); - Assert.assertTrue(jackInf.mkdir()); - Files.copy(new File(testFolder,"config-001.jpp"), new File(jackInf, "config-001.jpp")); - - File out = TestTools.createTempDir("out", ""); - Options app1Options = new Options(); - app1Options.addProperty(MultiDexLegacy.MULTIDEX_LEGACY.getName(), "true"); - app1Options.addProperty(DexFileWriter.DEX_WRITING_POLICY.getName(), "minimal-multidex"); - app1Options.addJayceImport(autoLibrary); - - TestTools.compileSourceToDex(app1Options, testFolder, TestTools.getDefaultBootclasspathString() - + File.pathSeparator + frameworks.getPath(), - out, false); - - File outList = getListingOfDex(new File(out, "classes.dex")); - // The old toolchain is doing a little better than us here it seems to identify when - // InterfaceWithEnum.class instance is used or not. - ListingComparator.compare( - new File(testFolder,"ref-list-002-1.txt"), outList); - File outList2 = getListingOfDex(new File(out, "classes2.dex")); - ListingComparator.compare( - new File(testFolder,"ref-list-002-2.txt"), outList2); - Assert.assertFalse(new File(out, "classes3.dex").exists()); - return; - } - - /** - * Verifies that classes annotated with runtime visible annotations are put in main dex. - */ - @Test - public void legacyAppTest003() throws Exception { - - File testFolder = TestTools.getJackTestsWithJackFolder("multidex/test003"); - - File out = TestTools.createTempDir("out", ""); - Options appOptions = new Options(); - appOptions.addProperty(MultiDexLegacy.MULTIDEX_LEGACY.getName(), "true"); - appOptions.addProperty(DexFileWriter.DEX_WRITING_POLICY.getName(), "minimal-multidex"); - - TestTools.compileSourceToDex(appOptions, testFolder, TestTools.getDefaultBootclasspathString() - + File.pathSeparator + annotations.getPath() + File.pathSeparator + frameworks.getPath(), - out, false); - - File outList = getListingOfDex(new File(out, "classes.dex")); - ListingComparator.compare( - new File(testFolder,"ref-list-003-1.txt"), outList); - File outList2 = getListingOfDex(new File(out, "classes2.dex")); - ListingComparator.compare( - new File(testFolder,"ref-list-003-2.txt"), outList2); - Assert.assertFalse(new File(out, "classes3.dex").exists()); - return; - } -} diff --git a/jack/tests/com/android/jack/optimizations/UselessVariableCopyTest.java b/jack/tests/com/android/jack/optimizations/UselessVariableCopyTest.java deleted file mode 100644 index 3ba4fe0..0000000 --- a/jack/tests/com/android/jack/optimizations/UselessVariableCopyTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.optimizations; - -import com.android.jack.Options; -import com.android.jack.TestTools; -import com.android.jack.category.KnownBugs; - -import junit.framework.Assert; - -import org.jf.dexlib.CodeItem; -import org.jf.dexlib.DexFile; -import org.jf.dexlib.Code.Instruction; -import org.jf.dexlib.Code.Opcode; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.File; - -import javax.annotation.Nonnull; - -public class UselessVariableCopyTest { - - /** - * Verify that generated dex does not contains useless 'mov' instructions. - */ - @Test - @Category(KnownBugs.class) - public void test001() throws Exception { - File out = TestTools.createTempFile("uselessMovInstructions", ".dex"); - Options options = new Options(); - options.disableDxOptimizations(); - TestTools.compileSourceToDex(options, - TestTools.getJackTestsWithJackFolder("optimizations/uselesscopy/test001"), - TestTools.getClasspathAsString(TestTools.getDefaultBootclasspath()), out, false); - - DexFile dexFile = new DexFile(out); - CodeItem ci = - TestTools.getEncodedMethod(dexFile, - "Lcom/android/jack/optimizations/uselesscopy/test001/jack/Test001;", "test", - "(Ljava/lang/Object;)Z").codeItem; - - Assert.assertFalse(hasOpcode(ci, Opcode.MOVE_OBJECT)); - } - - private boolean hasOpcode(@Nonnull CodeItem codeItem, @Nonnull Opcode opcode) { - for (Instruction inst : codeItem.getInstructions()) { - if (inst.opcode == opcode) { - return true; - } - } - return false; - } - -} diff --git a/jack/tests/com/android/jack/preprocessor/PreProcessorTest.java b/jack/tests/com/android/jack/preprocessor/PreProcessorTest.java index f03e8c4..3a600ec 100644 --- a/jack/tests/com/android/jack/preprocessor/PreProcessorTest.java +++ b/jack/tests/com/android/jack/preprocessor/PreProcessorTest.java @@ -89,59 +89,4 @@ public class PreProcessorTest { hooks.runHooks(); } - - @Test - public void test001_002() throws Exception { - File testDir = TestTools.getJackTestsWithJackFolder("preprocessor/test001"); - Options options = TestTools.buildCommandLineArgs(testDir); - options.addProperty(PreProcessor.ENABLE.getName(), "true"); - options.addProperty(PreProcessor.FILE.getName(), - new File(testDir, "config.jpp").getAbsolutePath()); - TestTools.compileSourceToDex(options, testDir, TestTools.getDefaultBootclasspathString(), - TestTools.createTempFile("annotationAdderTest", ".out.zip"), true); - } - - @Test - public void test001_001() throws Exception { - File testDir = TestTools.getJackTestsWithJackFolder("preprocessor/test001"); - File tempDir = TestTools.createTempDir("preprocessor", "test"); - TestTools.compileSourceToJack(new Options(), testDir, - TestTools.getDefaultBootclasspathString(), tempDir, false); - - Options args = TestTools.buildCommandLineArgs( - new File(testDir, "app1/ApplicationActivity1.java")); - args.setClasspath(tempDir.getPath()); - RunnableHooks hooks = new RunnableHooks(); - JSession session = TestTools.buildSession(args, hooks); - ANTLRFileStream in = new ANTLRFileStream(new File(testDir, "config.jpp").getAbsolutePath()); - PreProcessorLexer lexer = new PreProcessorLexer(in); - CommonTokenStream tokens = new CommonTokenStream(lexer); - PreProcessorParser parser = new PreProcessorParser(tokens); - Collection<Rule> rules = parser.rules(session); - Scope scope = new TypeToEmitScope(session); - for (Rule rule : rules) { - Context context = new Context(); - if (!rule.getSet().eval(scope, context).isEmpty()) { - context.getRequest(session).commit(); - } - } - - JAnnotation installerAnnotation = session.getPhantomLookup().getAnnotation( - "Lcom/android/jack/preprocessor/test001/jack/MultiDexInstaller;"); - JNodeLookup lookup = session.getLookup(); - { - JDefinedClassOrInterface coi = lookup.getClass( - "Lcom/android/jack/preprocessor/test001/jack/app1/ApplicationActivity1;"); - Assert.assertFalse(coi.getAnnotations(installerAnnotation).isEmpty()); - for (JMethod method : coi.getMethods()) { - if (method.getName().equals("noAnnotation")) { - Assert.assertTrue(method.getAnnotations(installerAnnotation).isEmpty()); - } else { - Assert.assertFalse(method.getAnnotations(installerAnnotation).isEmpty()); - } - } - } - - hooks.runHooks(); - } } diff --git a/jack/tests/com/android/jack/shrob/AbstractTest.java b/jack/tests/com/android/jack/shrob/AbstractTest.java deleted file mode 100644 index eb707d0..0000000 --- a/jack/tests/com/android/jack/shrob/AbstractTest.java +++ /dev/null @@ -1,567 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack.shrob; - -import com.android.jack.Main; -import com.android.jack.ProguardFlags; -import com.android.jack.TestTools; -import com.android.jack.category.KnownBugs; -import com.android.jack.category.SlowTests; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -/** - * Abstract class for running shrob tests - */ -public abstract class AbstractTest { - - @Nonnull - static final File[] defaultBootclasspath = TestTools.getDefaultBootclasspath(); - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - protected abstract void runTest( - @CheckForNull File[] bootclasspath, - @CheckForNull File[] classpath, - @Nonnull String testNumber, - @Nonnull String flagNumber, - @Nonnull String mappingNumber) - throws Exception; - - protected ProguardFlags generateApplyMapping(@Nonnull File mappingFile) throws IOException { - File applyMapping = TestTools.createTempFile("mapping.flags", null); - BufferedWriter writer = new BufferedWriter(new FileWriter(applyMapping)); - writer.append("-applymapping "); - writer.append(mappingFile.getAbsolutePath()); - writer.close(); - return new ProguardFlags(applyMapping); - } - - protected ProguardFlags generateInjars(@Nonnull File injar) throws IOException { - File injarFlags = TestTools.createTempFile("injars", ".flags"); - BufferedWriter writer = new BufferedWriter(new FileWriter(injarFlags)); - writer.append("-injars "); - writer.append(injar.getAbsolutePath()); - writer.close(); - return new ProguardFlags(injarFlags); - } - - @Test - public void test1_001() throws Exception { - runTest(defaultBootclasspath, null, "001", "001", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_002() throws Exception { - runTest(defaultBootclasspath, null, "001", "002", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_003() throws Exception { - runTest(defaultBootclasspath, null, "001", "003", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_004() throws Exception { - runTest(defaultBootclasspath, null, "001", "004", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_005() throws Exception { - runTest(defaultBootclasspath, null, "001", "005", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_005_002() throws Exception { - runTest(defaultBootclasspath, null, "001", "005", "002"); - } - - @Test - @Category(SlowTests.class) - public void test1_005_003() throws Exception { - runTest(defaultBootclasspath, null, "001", "005", "003"); - } - - @Test - @Category(SlowTests.class) - public void test1_006() throws Exception { - runTest(defaultBootclasspath, null, "001", "006", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_007() throws Exception { - runTest(defaultBootclasspath, null, "001", "007", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_008() throws Exception { - runTest(defaultBootclasspath, null, "001", "008", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_009() throws Exception { - runTest(defaultBootclasspath, null, "001", "009", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_010() throws Exception { - runTest(defaultBootclasspath, null, "001", "010", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_011() throws Exception { - runTest(defaultBootclasspath, null, "001", "011", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_012() throws Exception { - runTest(defaultBootclasspath, null, "001", "012", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_013() throws Exception { - runTest(defaultBootclasspath, null, "001", "013", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_014() throws Exception { - runTest(defaultBootclasspath, null, "001", "014", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_015() throws Exception { - runTest(defaultBootclasspath, null, "001", "015", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_016() throws Exception { - runTest(defaultBootclasspath, null, "001", "016", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_017() throws Exception { - runTest(defaultBootclasspath, null, "001", "017", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_018() throws Exception { - runTest(defaultBootclasspath, null, "001", "018", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_019() throws Exception { - runTest(defaultBootclasspath, null, "001", "019", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_020() throws Exception { - runTest(defaultBootclasspath, null, "001", "020", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_021() throws Exception { - runTest(defaultBootclasspath, null, "001", "021", ""); - } - - @Test - @Category(SlowTests.class) - public void test1_022() throws Exception { - runTest(defaultBootclasspath, null, "001", "022", ""); - } - - @Test - public void test2_001() throws Exception { - runTest(defaultBootclasspath, null, "002", "001", ""); - } - - @Test - @Category(SlowTests.class) - public void test2_002() throws Exception { - runTest(defaultBootclasspath, null, "002", "002", ""); - } - - @Test - @Category(SlowTests.class) - public void test2_003() throws Exception { - runTest(defaultBootclasspath, null, "002", "003", ""); - } - - @Test - public void test4_001() throws Exception { - runTest(defaultBootclasspath, null, "004", "001", ""); - } - - @Test - @Category(SlowTests.class) - public void test4_002() throws Exception { - runTest(defaultBootclasspath, null, "004", "002", ""); - } - - @Test - @Category(SlowTests.class) - public void test4_003() throws Exception { - runTest(defaultBootclasspath, null, "004", "003", ""); - } - - @Test - public void test5_001() throws Exception { - runTest(defaultBootclasspath, null, "005", "001", ""); - } - - @Test - @Category(SlowTests.class) - public void test5_002() throws Exception { - runTest(defaultBootclasspath, null, "005", "002", ""); - } - - @Test - @Category(SlowTests.class) - public void test5_003() throws Exception { - runTest(defaultBootclasspath, null, "005", "003", ""); - } - - @Test - @Category(SlowTests.class) - public void test5_004() throws Exception { - runTest(defaultBootclasspath, null, "005", "004", ""); - } - - @Test - public void test5_005() throws Exception { - runTest(defaultBootclasspath, null, "005", "005", ""); - } - - @Test - @Category(SlowTests.class) - public void test5_006() throws Exception { - runTest(defaultBootclasspath, null, "005", "006", ""); - } - - @Test - @Category(SlowTests.class) - public void test5_007() throws Exception { - runTest(defaultBootclasspath, null, "005", "007", ""); - } - - @Test - @Category(SlowTests.class) - public void test5_008() throws Exception { - runTest(defaultBootclasspath, null, "005", "008", ""); - } - - @Test - public void test6_001() throws Exception { - runTest(defaultBootclasspath, null, "006", "001", ""); - } - - @Test - @Category(SlowTests.class) - public void test6_002() throws Exception { - runTest(defaultBootclasspath, null, "006", "002", ""); - } - - @Test - @Category(SlowTests.class) - public void test6_003() throws Exception { - runTest(defaultBootclasspath, null, "006", "003", ""); - } - - @Test - @Category(SlowTests.class) - public void test6_004() throws Exception { - runTest(defaultBootclasspath, null, "006", "004", ""); - } - - @Test - @Category(SlowTests.class) - public void test6_005() throws Exception { - runTest(defaultBootclasspath, null, "006", "005", ""); - } - - @Test - @Category(SlowTests.class) - public void test6_006() throws Exception { - runTest(defaultBootclasspath, null, "006", "006", ""); - } - - @Test - public void test7_001() throws Exception { - runTest(defaultBootclasspath, null, "007", "001", ""); - } - - @Test - @Category(SlowTests.class) - public void test7_002() throws Exception { - runTest(defaultBootclasspath, null, "007", "002", ""); - } - - @Test - @Category(SlowTests.class) - public void test7_003() throws Exception { - runTest(defaultBootclasspath, null, "007", "003", ""); - } - - @Test - public void test8_001() throws Exception { - runTest(defaultBootclasspath, null, "008", "001", ""); - } - - @Test - @Category(SlowTests.class) - public void test8_002() throws Exception { - runTest(defaultBootclasspath, null, "008", "002", ""); - } - - @Test - @Category(SlowTests.class) - public void test8_003() throws Exception { - runTest(defaultBootclasspath, null, "008", "003", ""); - } - - @Test - @Category(SlowTests.class) - public void test8_004() throws Exception { - runTest(defaultBootclasspath, null, "008", "004", ""); - } - - @Test - public void test9_001() throws Exception { - runTest(defaultBootclasspath, null, "009", "001", ""); - } - - @Test - @Category(SlowTests.class) - public void test9_002() throws Exception { - runTest(defaultBootclasspath, null, "009", "002", ""); - } - - @Test - @Category(SlowTests.class) - public void test9_003() throws Exception { - runTest(defaultBootclasspath, null, "009", "003", ""); - } - - @Test - public void test10_001() throws Exception { - runTest(defaultBootclasspath, null, "010", "001", ""); - } - - @Test - @Category(SlowTests.class) - public void test10_002() throws Exception { - runTest(defaultBootclasspath, null, "010", "002", ""); - } - - @Test - @Category(SlowTests.class) - public void test10_003() throws Exception { - runTest(defaultBootclasspath, null, "010", "003", ""); - } - - @Test - public void test11_001() throws Exception { - runTest(defaultBootclasspath, null, "011", "001", ""); - } - - @Test - @Category(SlowTests.class) - public void test11_002() throws Exception { - runTest(defaultBootclasspath, null, "011", "002", ""); - } - - @Test - public void test12_001() throws Exception { - runTest(defaultBootclasspath, null, "012", "001", ""); - } - - @Test - public void test13_001() throws Exception { - runTest(defaultBootclasspath, null, "013", "001", ""); - } - - @Test - public void test14_001() throws Exception { - runTest(defaultBootclasspath, null, "014", "001", ""); - } - - @Test - public void test15_001() throws Exception { - runTest(defaultBootclasspath, null, "015", "001", ""); - } - - @Test - public void test16_001() throws Exception { - runTest(defaultBootclasspath, null, "016", "001", ""); - } - - @Test - @Category(SlowTests.class) - public void test16_002() throws Exception { - runTest(defaultBootclasspath, null, "016", "002", ""); - } - - @Test - public void test17_001() throws Exception { - runTest(defaultBootclasspath, null, "017", "001", ""); - } - - @Test - public void test18_001() throws Exception { - runTest(defaultBootclasspath, null, "018", "001", ""); - } - - @Test - public void test19_001() throws Exception { - runTest(defaultBootclasspath, null, "019", "001", ""); - } - - @Test - public void test21_001() throws Exception { - runTest(defaultBootclasspath, null, "021", "001", ""); - } - - @Test - public void test22_001() throws Exception { - runTest(defaultBootclasspath, null, "022", "001", ""); - } - - @Test - public void test23_001() throws Exception { - runTest(defaultBootclasspath, null, "023", "001", ""); - } - - @Test - public void test25_001() throws Exception { - runTest(defaultBootclasspath, null, "025", "001", ""); - } - - @Test - public void test26_001() throws Exception { - runTest(defaultBootclasspath, null, "026", "001", ""); - } - - @Test - public void test29_001() throws Exception { - runTest(defaultBootclasspath, null, "029", "001", ""); - } - - @Test - public void test30_001() throws Exception { - runTest(defaultBootclasspath, null, "030", "001", ""); - } - - @Test - public void test31_001() throws Exception { - runTest(defaultBootclasspath, null, "031", "001", ""); - } - - @Test - public void test31_002() throws Exception { - runTest(defaultBootclasspath, null, "031", "002", ""); - } - - @Test - public void test32_001() throws Exception { - runTest(defaultBootclasspath, null, "032", "001", ""); - } - - @Test - public void test33_001() throws Exception { - runTest(defaultBootclasspath, null, "033", "001", ""); - } - - @Test - @Category(SlowTests.class) - public void test33_002() throws Exception { - runTest(defaultBootclasspath, null, "033", "002", ""); - } - - @Test - public void test34_001() throws Exception { - runTest(defaultBootclasspath, null, "034", "001", ""); - } - - @Test - public void test35_001() throws Exception { - runTest(defaultBootclasspath, null, "035", "001", ""); - } - - @Test - public void test36_001() throws Exception { - runTest(defaultBootclasspath, null, "036", "001", ""); - } - - @Test - public void test37_001() throws Exception { - runTest(defaultBootclasspath, null, "037", "001", ""); - } - - @Test - public void test38_001() throws Exception { - runTest(defaultBootclasspath, null, "038", "001", ""); - } - - @Test - public void test39_001() throws Exception { - runTest(defaultBootclasspath, null, "039", "001", ""); - } - - @Test - @Category(SlowTests.class) - public void test40_001() throws Exception { - runTest(defaultBootclasspath, null, "040", "001", ""); - } - - @Test - @Category(KnownBugs.class) - public void test41_001() throws Exception { - runTest(defaultBootclasspath, null, "041", "001", ""); - } -} diff --git a/jack/tests/com/android/jack/shrob/AllTests.java b/jack/tests/com/android/jack/shrob/AllTests.java index e1a7fc3..2543219 100644 --- a/jack/tests/com/android/jack/shrob/AllTests.java +++ b/jack/tests/com/android/jack/shrob/AllTests.java @@ -23,16 +23,6 @@ import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses(value = { -// AnnotationsTest.class, - ShrinkTest.class, - ShrinkMultiDexTest.class, - ObfuscationWithMappingTest.class, -// ObfuscationWithAttributesTest.class, -// ObfuscationWithDebugInfoTest.class, - ObfuscationWithoutMappingTest.class, - RepackagingTest.class, - FlattenPackageTest.class, - SeedTest.class, TreeTest.class }) public class AllTests { diff --git a/jack/tests/com/android/jack/shrob/AnnotationsTest.java b/jack/tests/com/android/jack/shrob/AnnotationsTest.java deleted file mode 100644 index 1d18afe..0000000 --- a/jack/tests/com/android/jack/shrob/AnnotationsTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack.shrob; - -import com.android.jack.AnnotationTestTools; -import com.android.jack.ProguardFlags; -import com.android.jack.TestTools; - -import java.io.File; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -public class AnnotationsTest extends AbstractTest { - - @Override - protected void runTest( - @CheckForNull File[] bootclasspath, - @CheckForNull File[] classpath, - @Nonnull String testNumber, - @Nonnull String flagNumber, - @Nonnull String mappingNumber) - throws Exception { - String testName = "shrob/test" + testNumber; - File testFolder = TestTools.getJackTestFolder(testName); - ProguardFlags[] proguardflagsFiles = new ProguardFlags[] { - generateApplyMapping(new File(testFolder,"proguard.flags" + flagNumber + ".mapping" + mappingNumber)), -// new ProguardFlags(TestTools.getJackTestFolder("shrob"),"keepDebugInfo.flags"), - new ProguardFlags(TestTools.getJackTestFolder("shrob"),"keepAllAttributes.flags"), - new ProguardFlags(testFolder,"proguard.flags" + flagNumber) - }; - AnnotationTestTools.checkStructure(bootclasspath, classpath, TestTools.getJackTestsWithJackFolder(testName), proguardflagsFiles); - } -} diff --git a/jack/tests/com/android/jack/shrob/FlattenPackageTest.java b/jack/tests/com/android/jack/shrob/FlattenPackageTest.java deleted file mode 100644 index 7b6f0f3..0000000 --- a/jack/tests/com/android/jack/shrob/FlattenPackageTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack.shrob; - -import com.android.jack.Options; -import com.android.jack.TestTools; -import com.android.jack.category.SlowTests; -import com.android.jack.shrob.proguard.GrammarActions; -import com.android.jack.shrob.spec.Flags; - -import org.junit.experimental.categories.Category; - -import java.io.File; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -@Category(SlowTests.class) -public class FlattenPackageTest extends AbstractTest { - - @Override - protected void runTest( - @CheckForNull File[] bootclasspath, - @CheckForNull File[] classpath, - @Nonnull String testNumber, - @Nonnull String flagNumber, - @Nonnull String mappingNumber) - throws Exception { - String testName = "shrob/test" + testNumber; - File testFolder = TestTools.getJackTestFolder(testName); - Flags flags = new Flags(); - GrammarActions.parse("proguard.flags" + flagNumber, testFolder.getAbsolutePath(), flags); - GrammarActions.parse("keepPackageName.flags", - TestTools.getJackTestFolder("shrob").getAbsolutePath(), flags); - flags.setPackageForFlatHierarchy("flatpackage"); - File candidateOutputMapping = TestTools.createTempFile("mapping", ".txt"); - File refFolder = new File(testFolder, "refsFlattenPackage"); - File refOutputMapping = new File(refFolder, "expected-" + flagNumber + ".txt"); - flags.setOutputMapping(candidateOutputMapping); - flags.setPrintMapping(true); - Options jackOptions = new Options(); - jackOptions.setNameProvider("rot13"); - TestTools.runWithFlags(jackOptions, bootclasspath, classpath, - TestTools.getJackTestsWithJackFolder(testName), flags); - ListingComparator.compare(refOutputMapping, candidateOutputMapping); - } -} diff --git a/jack/tests/com/android/jack/shrob/ObfuscationWithAttributesTest.java b/jack/tests/com/android/jack/shrob/ObfuscationWithAttributesTest.java deleted file mode 100644 index dbd494c..0000000 --- a/jack/tests/com/android/jack/shrob/ObfuscationWithAttributesTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack.shrob; - -import com.android.jack.ProguardFlags; -import com.android.jack.TestTools; - -import java.io.File; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -public class ObfuscationWithAttributesTest extends AbstractTest { - - @Override - protected void runTest( - @CheckForNull File[] bootclasspath, - @CheckForNull File[] classpath, - @Nonnull String testNumber, - @Nonnull String flagNumber, - @Nonnull String mappingNumber) - throws Exception { - String testName = "shrob/test" + testNumber; - File testFolder = TestTools.getJackTestFolder(testName); - ProguardFlags[] proguardflagsFiles = new ProguardFlags[] { - generateApplyMapping(new File(testFolder,"proguard.flags" + flagNumber + ".mapping" + mappingNumber)), - new ProguardFlags(TestTools.getJackTestFolder("shrob"),"keepAllAttributes.flags"), - new ProguardFlags(testFolder,"proguard.flags" + flagNumber) - }; - TestTools.checkStructure( - bootclasspath, classpath, TestTools.getJackTestsWithJackFolder(testName), - true /* withDebuginfo */, proguardflagsFiles); - } -} diff --git a/jack/tests/com/android/jack/shrob/ObfuscationWithDebugInfoTest.java b/jack/tests/com/android/jack/shrob/ObfuscationWithDebugInfoTest.java deleted file mode 100644 index 2dba024..0000000 --- a/jack/tests/com/android/jack/shrob/ObfuscationWithDebugInfoTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack.shrob; - -import com.android.jack.ProguardFlags; -import com.android.jack.TestTools; - -import java.io.File; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -public class ObfuscationWithDebugInfoTest extends AbstractTest { - - @Override - protected void runTest( - @CheckForNull File[] bootclasspath, - @CheckForNull File[] classpath, - @Nonnull String testNumber, - @Nonnull String flagNumber, - @Nonnull String mappingNumber) - throws Exception { - String testName = "shrob/test" + testNumber; - File testFolder = TestTools.getJackTestFolder(testName); - ProguardFlags[] proguardflagsFiles = new ProguardFlags[] { - generateApplyMapping(new File(testFolder,"proguard.flags" + flagNumber + ".mapping" + mappingNumber)), - new ProguardFlags(TestTools.getJackTestFolder("shrob"),"keepDebugInfo.flags"), - new ProguardFlags(testFolder,"proguard.flags" + flagNumber) - }; - TestTools.checkStructure(null, null, TestTools.getJackTestsWithJackFolder(testName), - true /* withDebuginfo */, proguardflagsFiles); - } -} diff --git a/jack/tests/com/android/jack/shrob/ObfuscationWithMappingTest.java b/jack/tests/com/android/jack/shrob/ObfuscationWithMappingTest.java deleted file mode 100644 index 57a626a..0000000 --- a/jack/tests/com/android/jack/shrob/ObfuscationWithMappingTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack.shrob; - -import com.android.jack.Options; -import com.android.jack.TestTools; -import com.android.jack.shrob.proguard.GrammarActions; -import com.android.jack.shrob.spec.Flags; - -import org.junit.Test; - -import java.io.File; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -public class ObfuscationWithMappingTest extends AbstractTest { - - @Override - protected void runTest( - @CheckForNull File[] bootclasspath, - @CheckForNull File[] classpath, - @Nonnull String testNumber, - @Nonnull String flagNumber, - @Nonnull String mappingNumber) - throws Exception { - String testName = "shrob/test" + testNumber; - File testFolder = TestTools.getJackTestFolder(testName); - Flags flags = new Flags(); - GrammarActions.parse("proguard.flags" + flagNumber, testFolder.getAbsolutePath(), flags); - File candidateOutputMapping = TestTools.createTempFile("mapping", ".txt"); - File refFolder = new File(testFolder, "refsObfuscationWithMapping"); - File refOutputMapping = new File(refFolder, "expected-" + flagNumber + ".txt"); - flags.setOutputMapping(candidateOutputMapping); - flags.setPrintMapping(true); - File inputMapping = - new File(testFolder, "proguard.flags" + flagNumber + ".mapping" + mappingNumber); - if (inputMapping.exists()) { - flags.setObfuscationMapping(inputMapping); - } - TestTools.runWithFlags(new Options(), - bootclasspath, - classpath, - TestTools.getJackTestsWithJackFolder(testName), - flags); - ListingComparator.compare(refOutputMapping, candidateOutputMapping); - } - - @Override - @Test - public void test33_001() throws Exception { - // Test 33 already has a partial mapping, it can't be used in this test suite. - } - - @Override - @Test - public void test33_002() throws Exception { - // Test 33 already has a partial mapping, it can't be used in this test suite. - } - - @Override - @Test - public void test34_001() throws Exception { - // Test 35 already has a partial mapping, it can't be used in this test suite. - } - - @Override - @Test - public void test35_001() throws Exception { - // Test 34 already has a partial mapping, it can't be used in this test suite. - } -} diff --git a/jack/tests/com/android/jack/shrob/ObfuscationWithoutMappingTest.java b/jack/tests/com/android/jack/shrob/ObfuscationWithoutMappingTest.java deleted file mode 100644 index 36ec621..0000000 --- a/jack/tests/com/android/jack/shrob/ObfuscationWithoutMappingTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack.shrob; - -import com.android.jack.Options; -import com.android.jack.TestTools; -import com.android.jack.category.KnownBugs; -import com.android.jack.shrob.proguard.GrammarActions; -import com.android.jack.shrob.spec.Flags; - -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.File; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -public class ObfuscationWithoutMappingTest extends AbstractTest { - - @Override - protected void runTest( - @CheckForNull File[] bootclasspath, - @CheckForNull File[] classpath, - @Nonnull String testNumber, - @Nonnull String flagNumber, - @Nonnull String mappingNumber) - throws Exception { - String testName = "shrob/test" + testNumber; - File testFolder = TestTools.getJackTestFolder(testName); - Flags flags = new Flags(); - GrammarActions.parse("proguard.flags" + flagNumber, testFolder.getAbsolutePath(), flags); - File refFolder = new File(testFolder, "refsObfuscationWithoutMapping"); - - File candidateOutputMapping = TestTools.createTempFile("mapping", ".txt"); - File refOutputMapping = new File(refFolder, "expected-" + flagNumber + ".txt"); - flags.setOutputMapping(candidateOutputMapping); - flags.setPrintMapping(true); - - Options jackOptions = new Options(); - jackOptions.setNameProvider("rot13"); - TestTools.runWithFlags(jackOptions, bootclasspath, classpath, - TestTools.getJackTestsWithJackFolder(testName), flags); - ListingComparator.compare(refOutputMapping, candidateOutputMapping); - } - - @Override - @Test - @Category(KnownBugs.class) - public void test33_001() throws Exception { - super.test33_001(); - } - - @Override - @Test - @Category(KnownBugs.class) - public void test34_001() throws Exception { - super.test34_001(); - } - - @Override - @Test - @Category(KnownBugs.class) - public void test35_001() throws Exception { - super.test35_001(); - } -} diff --git a/jack/tests/com/android/jack/shrob/RepackagingTest.java b/jack/tests/com/android/jack/shrob/RepackagingTest.java deleted file mode 100644 index 22784f7..0000000 --- a/jack/tests/com/android/jack/shrob/RepackagingTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack.shrob; - -import com.android.jack.Options; -import com.android.jack.TestTools; -import com.android.jack.shrob.proguard.GrammarActions; -import com.android.jack.shrob.spec.Flags; - -import java.io.File; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -public class RepackagingTest extends AbstractTest { - - @Override - protected void runTest( - @CheckForNull File[] bootclasspath, - @CheckForNull File[] classpath, - @Nonnull String testNumber, - @Nonnull String flagNumber, - @Nonnull String mappingNumber) - throws Exception { - String testName = "shrob/test" + testNumber; - File testFolder = TestTools.getJackTestFolder(testName); - Flags flags = new Flags(); - GrammarActions.parse("proguard.flags" + flagNumber, testFolder.getAbsolutePath(), flags); - flags.setPackageForRenamedClasses(""); - File candidateOutputMapping = TestTools.createTempFile("mapping", ".txt"); - File refFolder = new File(testFolder, "refsRepackageClasses"); - File refOutputMapping = new File(refFolder, "expected-" + flagNumber + ".txt"); - flags.setOutputMapping(candidateOutputMapping); - flags.setPrintMapping(true); - Options jackOptions = new Options(); - jackOptions.setNameProvider("rot13"); - TestTools.runWithFlags(jackOptions, bootclasspath, classpath, - TestTools.getJackTestsWithJackFolder(testName), flags); - ListingComparator.compare(refOutputMapping, candidateOutputMapping); - } -} diff --git a/jack/tests/com/android/jack/shrob/SeedTest.java b/jack/tests/com/android/jack/shrob/SeedTest.java deleted file mode 100644 index b27b149..0000000 --- a/jack/tests/com/android/jack/shrob/SeedTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack.shrob; - -import com.android.jack.Options; -import com.android.jack.TestTools; -import com.android.jack.category.SlowTests; -import com.android.jack.shrob.proguard.GrammarActions; -import com.android.jack.shrob.spec.Flags; - -import org.junit.experimental.categories.Category; - -import java.io.File; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -@Category(SlowTests.class) -public class SeedTest extends AbstractTest { - - @Override - protected void runTest( - @CheckForNull File[] bootclasspath, - @CheckForNull File[] classpath, - @Nonnull String testNumber, - @Nonnull String flagNumber, - @Nonnull String mappingNumber) - throws Exception { - String testName = "shrob/test" + testNumber; - File testFolder = TestTools.getJackTestFolder(testName); - Flags flags = new Flags(); - flags.setShrink(false); - flags.setObfuscate(false); - GrammarActions.parse("proguard.flags" + flagNumber, testFolder.getAbsolutePath(), flags); - File refFolder = new File(testFolder, "refsSeed"); - File candidateOutputSeeds = TestTools.createTempFile("seeds", ".txt"); - File refOutputSeeds = new File(refFolder, "expected-" + flagNumber + ".txt"); - flags.setSeedsFile(candidateOutputSeeds); - flags.setPrintSeeds(true); - - Options jackOptions = new Options(); - TestTools.runWithFlags(jackOptions, bootclasspath, classpath, - TestTools.getJackTestsWithJackFolder(testName), flags); - SeedsComparator.compare(refOutputSeeds, candidateOutputSeeds); - } -} diff --git a/jack/tests/com/android/jack/shrob/ShrinkMultiDexTest.java b/jack/tests/com/android/jack/shrob/ShrinkMultiDexTest.java deleted file mode 100644 index 4b2fc57..0000000 --- a/jack/tests/com/android/jack/shrob/ShrinkMultiDexTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack.shrob; - -import com.android.jack.Main; -import com.android.jack.Options; -import com.android.jack.ProguardFlags; -import com.android.jack.TestTools; -import com.android.jack.backend.dex.DexFileWriter; -import com.android.jack.backend.dex.MultiDexLegacy; -import com.android.jack.preprocessor.PreProcessor; - -import org.junit.BeforeClass; - -import java.io.File; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -/** - * Tests for verifying that tracing for MultiDex does not disturb shrinking. - */ -public class ShrinkMultiDexTest extends AbstractTest { - - private static ProguardFlags dontObfuscateFlagFile = - new ProguardFlags(TestTools.getJackTestFolder("shrob"), "dontobfuscate.flags"); - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Override - protected void runTest( - @CheckForNull File[] bootclasspath, - @CheckForNull File[] classpath, - @Nonnull String testNumber, - @Nonnull String flagNumber, - @Nonnull String mappingNumber) - throws Exception { - String testName = "shrob/test" + testNumber; - File testFolder = TestTools.getJackTestFolder(testName); - ProguardFlags[] proguardflagsFiles = new ProguardFlags[] { - dontObfuscateFlagFile, - new ProguardFlags(TestTools.getJackTestFolder("shrob"),"keepAllAttributes.flags"), - new ProguardFlags(testFolder, "proguard.flags" + flagNumber)}; - File refFolder = new File(testFolder, "refsShrinking"); - Options options = new Options(); - options.addProperty(DexFileWriter.DEX_WRITING_POLICY.getName(), "multidex"); - options.addProperty(MultiDexLegacy.MULTIDEX_LEGACY.getName(), "true"); - options.addProperty(PreProcessor.ENABLE.getName(), "true"); - options.addProperty(PreProcessor.FILE.getName(), new File(TestTools.getJackTestFolder("shrob"), - "legacyMainDexClasses.jpp").getAbsolutePath()); - TestTools.checkListingWhenMultiDex(options, - bootclasspath, - classpath, - TestTools.getJackTestsWithJackFolder(testName), - proguardflagsFiles, - new File(refFolder, "expected-" + flagNumber + ".txt")); - } - -} diff --git a/jack/tests/com/android/jack/shrob/ShrinkTest.java b/jack/tests/com/android/jack/shrob/ShrinkTest.java deleted file mode 100644 index a4bebd2..0000000 --- a/jack/tests/com/android/jack/shrob/ShrinkTest.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack.shrob; - -import com.android.jack.Main; -import com.android.jack.Options; -import com.android.jack.ProguardFlags; -import com.android.jack.TestTools; -import com.android.jack.util.TextUtils; - -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; -import java.util.Collections; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -public class ShrinkTest extends AbstractTest { - - private static ProguardFlags dontObfuscateFlagFile = - new ProguardFlags(TestTools.getJackTestFolder("shrob"), "dontobfuscate.flags"); - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Override - protected void runTest( - @CheckForNull File[] bootclasspath, - @CheckForNull File[] classpath, - @Nonnull String testNumber, - @Nonnull String flagNumber, - @Nonnull String mappingNumber) - throws Exception { - String testName = "shrob/test" + testNumber; - File testFolder = TestTools.getJackTestFolder(testName); - ProguardFlags[] proguardflagsFiles = new ProguardFlags[] { - dontObfuscateFlagFile, - new ProguardFlags(TestTools.getJackTestFolder("shrob"),"keepAllAttributes.flags"), - new ProguardFlags(testFolder, "proguard.flags" + flagNumber)}; - File refFolder = new File(testFolder, "refsShrinking"); - TestTools.checkListing(bootclasspath, - classpath, - TestTools.getJackTestsWithJackFolder(testName), - proguardflagsFiles, - new File(refFolder, "expected-" + flagNumber + ".txt")); - } - - @Test - public void test020() throws Exception { - File libOut = TestTools.createTempDir("ShrinkTest", "lib"); - File testOut = null; - File shrinkOut = null; - - try { - Options libOptions = TestTools.buildCommandLineArgs( - TestTools.getJackTestLibFolder("shrob/test020")); - libOptions.setJayceOutputDir(libOut); - TestTools.runCompilation(libOptions); - - testOut = TestTools.createTempDir("ShrinkTest", "test"); - Options testOptions = TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("shrob/test020")); - testOptions.setJayceOutputDir(testOut); - testOptions.setClasspath(libOut.getAbsolutePath()); - TestTools.runCompilation(testOptions); - - Options shrinkOption = new Options(); - shrinkOption.addProguardFlagsFile(dontObfuscateFlagFile); - shrinkOption.addProguardFlagsFile( - new ProguardFlags(TestTools.getJackTestFolder("shrob/test020"),"proguard.flags")); - - shrinkOut = TestTools.createTempDir("ShrinkTest", "shrink"); - shrinkOption.setJayceOutputDir(shrinkOut); - shrinkOption.addJayceImport(testOut); - TestTools.runCompilation(shrinkOption); - } catch (Exception e) { - String message = "Not deleting temp files of failed test ShrinkTest.test20 in:" + - TextUtils.LINE_SEPARATOR + - "- " + libOut.getAbsolutePath(); - if (testOut != null) { - message += TextUtils.LINE_SEPARATOR + "- " + testOut.getAbsolutePath(); - } - if (shrinkOut != null) { - message += TextUtils.LINE_SEPARATOR + "- " + shrinkOut.getAbsolutePath(); - } - System.err.println(); - System.err.println(message); - throw e; - } - } - - @Test - public void test021() throws Exception { - File jackOut = TestTools.createTempDir("ShrinkTest", "jayce"); - File shrinkOut = null; - File dexOut = null; - - try { - Options libOptions = TestTools.buildCommandLineArgs( - TestTools.getJackTestsWithJackFolder("shrob/test021")); - libOptions.setJayceOutputDir(jackOut); - TestTools.runCompilation(libOptions); - - Options shrinkOption = new Options(); - shrinkOption.addProguardFlagsFile(dontObfuscateFlagFile); - shrinkOption.addProguardFlagsFile( - new ProguardFlags(TestTools.getJackTestFolder("shrob/test021"),"proguard.flags001")); - - shrinkOut = TestTools.createTempDir("ShrinkTest", "test"); - shrinkOption.setJayceOutputDir(shrinkOut); - shrinkOption.addJayceImport(jackOut); - TestTools.runCompilation(shrinkOption); - - dexOut = TestTools.createTempDir("ShrinkTest", "dex"); - Options dxOption = new Options(); - dxOption.addJayceImport(shrinkOut); - dxOption.setOutputDir(dexOut); - TestTools.runCompilation(dxOption); - - } catch (Exception e) { - String message = "Not deleting temp files of failed ShrinkTest.test20 in:\n" + - "- " + jackOut.getAbsolutePath(); - if (shrinkOut != null) { - message += "\n- " + shrinkOut.getAbsolutePath(); - } - if (dexOut != null) { - message += "\n- " + dexOut.getAbsolutePath(); - } - System.err.println(); - System.err.println(message); - throw e; - } - } - - /** - * The only purpose of this test is to use jack shrink capabilities and to have no reference to - * java/lang/Class. This test will make Jack fail if java/lang/Class methods like getField and - * getMethod cannot be looked up (i.e. at the time this test is written, if the structure of - * java/lang/Class has not been preloaded). - */ - @Test - public void test028() throws Exception { - File testFolder = TestTools.getJackTestFolder("shrob/test028"); - File jackar = null; - File shrinkedjackar = null; - jackar = TestTools.createTempFile("jackar", ".zip"); - shrinkedjackar = TestTools.createTempFile("shrinkedjackar", ".zip"); - ProguardFlags flags = new ProguardFlags(testFolder, "proguard.flags001"); - String classpath = TestTools.getDefaultBootclasspathString(); - - TestTools.compileSourceToJack(new Options(), testFolder, classpath, jackar, true); - - TestTools.shrobJackToJack(new Options(), - jackar, - classpath, - shrinkedjackar, - Collections.singletonList(flags), - true); - } - - @Test - public void test42_001() throws Exception { - runTest(defaultBootclasspath, null, "042", "001", ""); - } - - @Test - public void test42_002() throws Exception { - runTest(defaultBootclasspath, null, "042", "002", ""); - } - - @Test - public void test42_003() throws Exception { - runTest(defaultBootclasspath, null, "042", "003", ""); - } -} diff --git a/jack/tests/com/android/jack/tools/merger/MergerAllTests.java b/jack/tests/com/android/jack/tools/merger/MergerAllTests.java deleted file mode 100644 index 6d222de..0000000 --- a/jack/tests/com/android/jack/tools/merger/MergerAllTests.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ -package com.android.jack.tools.merger; - -import com.android.jack.tools.merger.test011.MergerTest011; - -import org.junit.experimental.categories.Categories; -import org.junit.runner.RunWith; -import org.junit.runners.Suite.SuiteClasses; - -@RunWith(Categories.class) -@SuiteClasses( -value = {MergerTest011.class}) -public class MergerAllTests { -}
\ No newline at end of file diff --git a/jack/tests/com/android/jack/tools/merger/MergerTestTools.java b/jack/tests/com/android/jack/tools/merger/MergerTestTools.java deleted file mode 100644 index 31c85f7..0000000 --- a/jack/tests/com/android/jack/tools/merger/MergerTestTools.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.tools.merger; - -import com.android.jack.Options; -import com.android.jack.TestTools; -import com.android.jack.backend.dex.DexFileWriter; -import com.android.sched.scheduler.ScheduleInstance; - -import java.io.File; - -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - -public class MergerTestTools { - - @Nonnull - public File buildOneDexPerType(@CheckForNull String classpath, @Nonnull File sourceFolder, - boolean withDebug) throws Exception { - Options options; - File multiDexFolder = TestTools.createTempDir("multi", "dex"); - File multiDex = new File(multiDexFolder, DexFileWriter.DEX_FILENAME); - File multiDexOnTypePerTypeFolder = TestTools.createTempDir("multiOnDexPerType", "dex"); - options = new Options(); - options.addProperty(Options.EMIT_LINE_NUMBER_DEBUG_INFO.getName(), Boolean.toString(withDebug)); - options.addProperty(ScheduleInstance.DEFAULT_RUNNER.getName(), "single-threaded"); - options.addProperty(Options.INTERMEDIATE_DEX_DIR.getName(), multiDexOnTypePerTypeFolder.getAbsolutePath()); - TestTools - .compileSourceToDex(options, sourceFolder, classpath, - multiDexFolder, false /* zip */, null /* jarjarRules */, null /* flagFiles */, - withDebug /* withDebugInfo */); - - return multiDex; - } -} diff --git a/jack/tests/com/android/jack/tools/merger/test011/MergerTest011.java b/jack/tests/com/android/jack/tools/merger/test011/MergerTest011.java deleted file mode 100644 index f11dfc1..0000000 --- a/jack/tests/com/android/jack/tools/merger/test011/MergerTest011.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -package com.android.jack.tools.merger.test011; - -import com.android.jack.JackAbortException; -import com.android.jack.Main; -import com.android.jack.TestTools; -import com.android.jack.backend.dex.DexWritingException; -import com.android.jack.backend.dex.SingleDexOverflowException; -import com.android.jack.category.SlowTests; -import com.android.jack.tools.merger.FieldIdOverflowException; -import com.android.jack.tools.merger.MergerTestTools; -import com.android.jack.tools.merger.MethodIdOverflowException; -import com.android.jack.tools.merger.TypeIdOverflowException; - -import junit.framework.Assert; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; - -import javax.annotation.Nonnegative; -import javax.annotation.Nonnull; - -/** - * JUnit test checking that merging can throw overflow exceptions. - */ -public class MergerTest011 extends MergerTestTools { - - private static final int fileCount = 655; - @Nonnull - private static final String EXPECTED_MESSAGE = - "Error during the dex writing phase: classes.dex has too many IDs. Try using multi-dex"; - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - @Test - public void testMergerWithHighNumberOfMethods() throws Exception { - File srcFolder = TestTools.createTempDir("oneDexPerType", "SrcFolder"); - - // One CstMethodRef is also created for call to object.init() - for (int fileIdx = 0; fileIdx < fileCount; fileIdx++) { - generateJavaFileWithMethods(srcFolder, fileIdx, 100); - } - generateJavaFileWithMethods(srcFolder, fileCount, 36); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream redirectStream = new PrintStream(baos); - System.setErr(redirectStream); - try { - buildOneDexPerType(TestTools.getDefaultBootclasspathString(), srcFolder, false /* withDebug */); - Assert.fail(); - } catch (JackAbortException e) { - Throwable cause = e.getCause(); - Assert.assertTrue(cause instanceof DexWritingException); - Assert.assertTrue(cause.getCause() instanceof SingleDexOverflowException); - Assert.assertTrue(cause.getCause().getCause() instanceof MethodIdOverflowException); - Assert.assertTrue(baos.toString().contains(EXPECTED_MESSAGE)); - } finally { - redirectStream.close(); - } - } - - @Test - public void testMergerWithHighNumberOfFields() throws Exception { - File srcFolder = TestTools.createTempDir("oneDexPerType", "SrcFolder"); - - for (int fileIdx = 0; fileIdx < fileCount; fileIdx++) { - generateJavaFileWithFields(srcFolder, fileIdx, 100); - } - generateJavaFileWithFields(srcFolder, fileCount, 37); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream redirectStream = new PrintStream(baos); - System.setErr(redirectStream); - try { - buildOneDexPerType(TestTools.getDefaultBootclasspathString(), srcFolder, false /* withDebug */); - Assert.fail(); - } catch (JackAbortException e) { - Throwable cause = e.getCause(); - Assert.assertTrue(cause instanceof DexWritingException); - Assert.assertTrue(cause.getCause() instanceof SingleDexOverflowException); - Assert.assertTrue(cause.getCause().getCause() instanceof FieldIdOverflowException); - Assert.assertTrue(baos.toString().contains(EXPECTED_MESSAGE)); - } finally { - redirectStream.close(); - } - } - - @Test - @Category(SlowTests.class) - public void testMergerWithHighNumberOfTypes() throws Exception { - File srcFolder = TestTools.createTempDir("oneDexPerType", "SrcFolder"); - - for (int fileIdx = 0; fileIdx < fileCount; fileIdx++) { - generateJavaFileWithTypes(srcFolder, fileIdx, 100); - } - generateJavaFileWithTypes(srcFolder, fileCount, 36); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream redirectStream = new PrintStream(baos); - System.setErr(redirectStream); - try { - buildOneDexPerType(TestTools.getDefaultBootclasspathString(), srcFolder, false /* withDebug */); - Assert.fail(); - } catch (JackAbortException e) { - Throwable cause = e.getCause(); - Assert.assertTrue(cause instanceof DexWritingException); - Assert.assertTrue(cause.getCause() instanceof SingleDexOverflowException); - Assert.assertTrue(cause.getCause().getCause() instanceof TypeIdOverflowException); - Assert.assertTrue(baos.toString().contains(EXPECTED_MESSAGE)); - } finally { - redirectStream.close(); - } - } - - private void generateJavaFileWithMethods(@Nonnull File srcFolder, @Nonnegative int fileIdx, - @Nonnegative int methodCount) throws IOException, FileNotFoundException { - File javaFile = new File(srcFolder, "A" + fileIdx + ".java"); - if (!javaFile.createNewFile()) { - throw new IOException("Failed to create file " + javaFile.getAbsolutePath()); - } - FileOutputStream fos = null; - try { - fos = new FileOutputStream(javaFile); - StringBuilder content = - new StringBuilder("package jack.merger; \n" + "public class A" + fileIdx+ " {"); - // -1 due to implicit init method - for (int mthIdx = 0; mthIdx < methodCount - 1; mthIdx++) { - content.append("public void m" + mthIdx + "() {}"); - } - content.append("} \n"); - fos.write(content.toString().getBytes()); - } finally { - if (fos != null) { - fos.close(); - } - } - } - - private void generateJavaFileWithFields(@Nonnull File srcFolder, @Nonnegative int fileIdx, - @Nonnegative int fieldCount) throws IOException, FileNotFoundException { - File javaFile = new File(srcFolder, "A" + fileIdx + ".java"); - if (!javaFile.createNewFile()) { - throw new IOException("Failed to create file " + javaFile.getAbsolutePath()); - } - FileOutputStream fos = null; - try { - fos = new FileOutputStream(javaFile); - StringBuilder content = - new StringBuilder("package jack.merger; \n" + "public class A" + fileIdx+ " {"); - for (int fieldIdx = 0; fieldIdx < fieldCount; fieldIdx++) { - content.append("public int f" + fieldIdx + ";"); - } - content.append("} \n"); - fos.write(content.toString().getBytes()); - } finally { - if (fos != null) { - fos.close(); - } - } - } - - private void generateJavaFileWithTypes(@Nonnull File srcFolder, @Nonnegative int fileIdx, - @Nonnegative int typeCount) throws IOException, FileNotFoundException { - File javaFile = new File(srcFolder, "A" + fileIdx + ".java"); - if (!javaFile.createNewFile()) { - throw new IOException("Failed to create file " + javaFile.getAbsolutePath()); - } - FileOutputStream fos = null; - try { - fos = new FileOutputStream(javaFile); - StringBuilder content = - new StringBuilder("package jack.merger; \n" + "public class A" + fileIdx+ " {"); - for (int typeIdx = 0; typeIdx < typeCount; typeIdx++) { - content.append("public class c" + typeIdx + " {}"); - } - content.append("} \n"); - fos.write(content.toString().getBytes()); - } finally { - if (fos != null) { - fos.close(); - } - } - } -} diff --git a/jack/tests/com/android/jack/transformations/cast/UselessCastRemoverTest.java b/jack/tests/com/android/jack/transformations/cast/UselessCastRemoverTest.java index 01cea1a..79651e8 100644 --- a/jack/tests/com/android/jack/transformations/cast/UselessCastRemoverTest.java +++ b/jack/tests/com/android/jack/transformations/cast/UselessCastRemoverTest.java @@ -17,25 +17,17 @@ package com.android.jack.transformations.cast; -import com.android.jack.Options; import com.android.jack.TestTools; -import com.android.jack.backend.dex.DexFileWriter; import com.android.jack.ir.ast.JCastOperation; import com.android.jack.ir.ast.JMethod; import com.android.jack.ir.ast.JVisitor; import junit.framework.Assert; -import org.jf.dexlib.CodeItem; -import org.jf.dexlib.DexFile; -import org.jf.dexlib.Code.Instruction; -import org.jf.dexlib.Code.Opcode; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; -import java.io.File; - import javax.annotation.Nonnull; public class UselessCastRemoverTest { @@ -147,70 +139,6 @@ public class UselessCastRemoverTest { buildMethodAndCheckUselessCastRemover(CAST_USELESS003, "nestedAssign()V", true); } - @Test - public void test001() throws Exception { - File outFolder = TestTools.createTempDir("uselessCastInstructions", "dex"); - File out = new File(outFolder, DexFileWriter.DEX_FILENAME); - - TestTools.compileSourceToDex(new Options(), - TestTools.getJackTestsWithJackFolder("cast/test001"), - TestTools.getClasspathAsString(TestTools.getDefaultBootclasspath()), outFolder, false); - - DexFile dexFile = new DexFile(out); - CodeItem ci = - TestTools.getEncodedMethod(dexFile, - "Lcom/android/jack/cast/test001/jack/Test001;", "get", - "(Lcom/android/jack/cast/test001/jack/Test001;)I").codeItem; - - Assert.assertFalse(hasOpcode(ci, Opcode.CHECK_CAST)); - Assert.assertFalse(hasOpcode(ci, Opcode.CHECK_CAST_JUMBO)); - } - - @Test - public void test002() throws Exception { - File outFolder = TestTools.createTempDir("uselessCastInstructions", "dex"); - File out = new File(outFolder, DexFileWriter.DEX_FILENAME); - TestTools.compileSourceToDex(new Options(), - TestTools.getJackTestsWithJackFolder("cast/test002"), - TestTools.getClasspathAsString(TestTools.getDefaultBootclasspath()), outFolder, false); - - DexFile dexFile = new DexFile(out); - CodeItem ci = - TestTools.getEncodedMethod(dexFile, - "Lcom/android/jack/cast/test002/jack/Test002;", "get", - "(Lcom/android/jack/cast/test002/jack/Test002;)I").codeItem; - - Assert.assertFalse(hasOpcode(ci, Opcode.CHECK_CAST)); - Assert.assertFalse(hasOpcode(ci, Opcode.CHECK_CAST_JUMBO)); - } - - @Test - public void test003() throws Exception { - File outFolder = TestTools.createTempDir("uselessCastInstructions", "dex"); - File out = new File(outFolder, DexFileWriter.DEX_FILENAME); - TestTools.compileSourceToDex(new Options(), - TestTools.getJackTestsWithJackFolder("cast/test003"), - TestTools.getClasspathAsString(TestTools.getDefaultBootclasspath()), outFolder, false); - - DexFile dexFile = new DexFile(out); - CodeItem ci = - TestTools.getEncodedMethod(dexFile, - "Lcom/android/jack/cast/test003/jack/Test003;", "get", - "(Lcom/android/jack/cast/test003/jack/A;)I").codeItem; - - Assert.assertFalse(hasOpcode(ci, Opcode.CHECK_CAST)); - Assert.assertFalse(hasOpcode(ci, Opcode.CHECK_CAST_JUMBO)); - } - - private boolean hasOpcode(@Nonnull CodeItem codeItem, @Nonnull Opcode opcode) { - for (Instruction inst : codeItem.getInstructions()) { - if (inst.opcode == opcode) { - return true; - } - } - return false; - } - private static void buildMethodAndCheckUselessCastRemover(@Nonnull String classBinaryName, @Nonnull String methodSignature, boolean castRemoved) throws Exception { JMethod m = diff --git a/jack/tests/com/android/jack/transformations/flow/AllTests.java b/jack/tests/com/android/jack/transformations/flow/AllTests.java deleted file mode 100644 index 6fa06a6..0000000 --- a/jack/tests/com/android/jack/transformations/flow/AllTests.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ -package com.android.jack.transformations.flow; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -@RunWith(Suite.class) -@SuiteClasses(value = {CompileFlowTest.class}) -public class AllTests { -}
\ No newline at end of file diff --git a/jack/tests/com/android/jack/transformations/flow/CompileFlowTest.java b/jack/tests/com/android/jack/transformations/flow/CompileFlowTest.java deleted file mode 100644 index 81dc1df..0000000 --- a/jack/tests/com/android/jack/transformations/flow/CompileFlowTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2012 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. - */ - -package com.android.jack.transformations.flow; - -import com.android.jack.Main; -import com.android.jack.TestTools; - -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * JUnit test for compilation of arithmetic tests. - */ -public class CompileFlowTest { - - @BeforeClass - public static void setUpClass() { - Main.class.getClassLoader().setDefaultAssertionStatus(true); - } - - /** - * Verifies that the test source can compiled from source to dex file. - */ - @Test - public void testCompile() throws Exception { - // TODO(delphinemartin) find a way to check that the loops have been removed - // and that the generated code is correct - TestTools.runCompilation(TestTools.buildCommandLineArgs(TestTools.getJackTestsWithJackFolder("flow/loop"))); - } -} |