summaryrefslogtreecommitdiffstats
path: root/jill/tests/com/android
diff options
context:
space:
mode:
authorYohann Roussel <yroussel@google.com>2014-03-19 17:16:12 +0100
committerYohann Roussel <yroussel@google.com>2014-03-19 18:14:25 +0100
commita219a81483f36c05618e5e6acb792e082af8b847 (patch)
tree7823f5f3112a3740581fec6f476a4e7617eed7ec /jill/tests/com/android
parente991948d20515a04e46524dbe1bf17222e872889 (diff)
downloadtoolchain_jill-a219a81483f36c05618e5e6acb792e082af8b847.zip
toolchain_jill-a219a81483f36c05618e5e6acb792e082af8b847.tar.gz
toolchain_jill-a219a81483f36c05618e5e6acb792e082af8b847.tar.bz2
Update jack initial import.
Change-Id: I19d527fa3919b6eb4276ed3b01155545dfb1ccf6
Diffstat (limited to 'jill/tests/com/android')
-rw-r--r--jill/tests/com/android/jill/AllTests.java47
-rw-r--r--jill/tests/com/android/jill/AnnotationTest.java46
-rw-r--r--jill/tests/com/android/jill/Core.java8
-rw-r--r--jill/tests/com/android/jill/FibonacciThreeAddressTest.java47
-rw-r--r--jill/tests/com/android/jill/FieldTest.java45
-rw-r--r--jill/tests/com/android/jill/InnerTest.java48
-rw-r--r--jill/tests/com/android/jill/JarjarTest.java45
-rw-r--r--jill/tests/com/android/jill/JillTestTools.java132
-rw-r--r--jill/tests/com/android/jill/LongLastingTests.java35
-rw-r--r--jill/tests/com/android/jill/NoClasspathTest.java42
-rw-r--r--jill/tests/com/android/jill/PreSubmitTests.java34
-rw-r--r--jill/tests/com/android/jill/TestTools.java47
-rw-r--r--jill/tests/com/android/jill/compile/androidtree/bouncycastle/BouncycastleCompilationTest.java52
-rw-r--r--jill/tests/com/android/jill/compile/androidtree/core/CoreCompilationTest.java42
-rw-r--r--jill/tests/com/android/jill/compile/androidtree/frameworks/FrameworksBaseCompilationTest.java56
-rw-r--r--jill/tests/com/android/jill/compile/androidtree/services/ServicesCompilationTest.java60
-rw-r--r--jill/tests/com/android/jill/shrob/ShrinkTest.java69
17 files changed, 804 insertions, 51 deletions
diff --git a/jill/tests/com/android/jill/AllTests.java b/jill/tests/com/android/jill/AllTests.java
new file mode 100644
index 0000000..67e8a52
--- /dev/null
+++ b/jill/tests/com/android/jill/AllTests.java
@@ -0,0 +1,47 @@
+/*
+ * 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.jill;
+
+
+import com.android.jill.compile.androidtree.bouncycastle.BouncycastleCompilationTest;
+import com.android.jill.compile.androidtree.core.CoreCompilationTest;
+import com.android.jill.compile.androidtree.frameworks.FrameworksBaseCompilationTest;
+import com.android.jill.compile.androidtree.services.ServicesCompilationTest;
+import com.android.jill.shrob.ShrinkTest;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test suite containing all tests.
+ */
+@RunWith(Suite.class)
+@SuiteClasses(value = {
+ AnnotationTest.class,
+ FibonacciThreeAddressTest.class,
+ FieldTest.class,
+ InnerTest.class,
+ JarjarTest.class,
+ NoClasspathTest.class,
+ BouncycastleCompilationTest.class,
+ CoreCompilationTest.class,
+ FrameworksBaseCompilationTest.class,
+ ServicesCompilationTest.class,
+ ShrinkTest.class})
+public class AllTests {
+}
diff --git a/jill/tests/com/android/jill/AnnotationTest.java b/jill/tests/com/android/jill/AnnotationTest.java
new file mode 100644
index 0000000..d864311
--- /dev/null
+++ b/jill/tests/com/android/jill/AnnotationTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.jill;
+
+import com.android.jack.Main;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+
+/**
+ * JUnit test for compilation of annotation.
+ */
+public class AnnotationTest {
+
+ private static final File[] BOOTCLASSPATH = JillTestTools.getDefaultBootclasspath();
+ private static final File ANNOTATION001_PATH =
+ JillTestTools.getJackTestsWithJackFolder("annotation/test001");
+
+ @BeforeClass
+ public static void setUpClass() {
+ Main.class.getClassLoader().setDefaultAssertionStatus(true);
+ }
+
+ @Test
+ public void test001_3WithJill() throws Exception {
+ JillTestTools.checkStructureWithJill(BOOTCLASSPATH, null,
+ new File(ANNOTATION001_PATH, "Annotation2.java"), false /*withDebugInfo*/);
+ }
+
+}
diff --git a/jill/tests/com/android/jill/Core.java b/jill/tests/com/android/jill/Core.java
index 8abf1c3..fcc77c1 100644
--- a/jill/tests/com/android/jill/Core.java
+++ b/jill/tests/com/android/jill/Core.java
@@ -32,22 +32,22 @@ public class Core {
@Test
public void coreToJayceFromJar() throws Exception {
Options options = new Options();
- options.setBinaryFile(new File(TestTools.getAndroidTop()
+ options.setBinaryFile(new File(JillTestTools.getAndroidTop()
+ "/out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes.jar"));
options.setVerbose(true);
options.container = ContainerType.DIR;
- options.outputDirOrZip = TestTools.createTempDir("core_", "_dir");
+ options.outputDirOrZip = JillTestTools.createTempDir("core_", "_dir");
new Jill(options, "0.1").process(options.getBinaryFile());
}
@Test
public void coreToJayceFromFolder() throws Exception {
Options options = new Options();
- options.setBinaryFile(new File(TestTools.getAndroidTop()
+ options.setBinaryFile(new File(JillTestTools.getAndroidTop()
+ "/out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes/"));
options.setVerbose(true);
options.container = ContainerType.DIR;
- options.outputDirOrZip = TestTools.createTempDir("core_", "_dir");
+ options.outputDirOrZip = JillTestTools.createTempDir("core_", "_dir");
new Jill(options, "0.1").process(options.getBinaryFile());
}
}
diff --git a/jill/tests/com/android/jill/FibonacciThreeAddressTest.java b/jill/tests/com/android/jill/FibonacciThreeAddressTest.java
new file mode 100644
index 0000000..4d2c45a
--- /dev/null
+++ b/jill/tests/com/android/jill/FibonacciThreeAddressTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.jill;
+
+import com.android.jack.Main;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+
+/**
+ * JUnit test for compilation of Fibonacci (three-address style).
+ */
+public class FibonacciThreeAddressTest {
+
+ private static final File[] BOOTCLASSPATH = JillTestTools.getDefaultBootclasspath();
+
+ private static final String CLASS_BINARY_NAME = "com/android/jack/fibonacci/jack/FibonacciThreeAddress";
+ private static final File JAVA_FILEPATH = JillTestTools.getJackTestFromBinaryName(CLASS_BINARY_NAME);
+
+ @BeforeClass
+ public static void setUpClass() {
+ // Enable assertions
+ Main.class.getClassLoader().setDefaultAssertionStatus(true);
+ }
+
+ @Test
+ public void testCompareFiboDexFileWithJill() throws Exception {
+ JillTestTools.checkStructureWithJill(BOOTCLASSPATH, null, JAVA_FILEPATH, false /*withDebugInfo*/);
+ }
+
+}
diff --git a/jill/tests/com/android/jill/FieldTest.java b/jill/tests/com/android/jill/FieldTest.java
new file mode 100644
index 0000000..cc5bf11
--- /dev/null
+++ b/jill/tests/com/android/jill/FieldTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.jill;
+
+import com.android.jack.Main;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * JUnit test for compilation of fields.
+ */
+public class FieldTest {
+
+ @BeforeClass
+ public static void setUpClass() {
+ Main.class.getClassLoader().setDefaultAssertionStatus(true);
+ }
+
+ @Test
+ public void testStaticWithJill() throws Exception {
+ JillTestTools.checkStructureWithJill(null, null,
+ JillTestTools.getJackTestsWithJackFolder("field/static003"), false /*withDebugInfo*/);
+ }
+
+ @Test
+ public void testInstanceWithJill() throws Exception {
+ JillTestTools.checkStructureWithJill(null, null,
+ JillTestTools.getJackTestsWithJackFolder("field/instance005"), false /*withDebugInfo*/);
+ }
+}
diff --git a/jill/tests/com/android/jill/InnerTest.java b/jill/tests/com/android/jill/InnerTest.java
new file mode 100644
index 0000000..9fc4b96
--- /dev/null
+++ b/jill/tests/com/android/jill/InnerTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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.jill;
+
+
+import com.android.jack.Main;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+
+public class InnerTest {
+
+ private static final File[] BOOTCLASSPATH = JillTestTools.getDefaultBootclasspath();
+
+ @BeforeClass
+ public static void setUpClass() {
+ Main.class.getClassLoader().setDefaultAssertionStatus(true);
+ }
+
+ @Test
+ public void testCheckStructure20WithJill() throws Exception {
+ //TODO: find out why debug info check fails
+ JillTestTools.checkStructureWithJill(BOOTCLASSPATH, null,
+ JillTestTools.getJackTestsWithJackFolder("inner/test020"), false /*withDebugInfo*/);
+ }
+
+ @Test
+ public void testCheckStructure21WithJill() throws Exception {
+ JillTestTools.checkStructureWithJill(BOOTCLASSPATH, null,
+ JillTestTools.getJackTestsWithJackFolder("inner/test021"), false /*withDebugInfo*/);
+ }
+}
diff --git a/jill/tests/com/android/jill/JarjarTest.java b/jill/tests/com/android/jill/JarjarTest.java
new file mode 100644
index 0000000..d8a5f69
--- /dev/null
+++ b/jill/tests/com/android/jill/JarjarTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.jill;
+
+import com.android.jack.JarJarRules;
+import com.android.jack.Main;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * JUnit test for compilation of field access.
+ */
+public class JarjarTest {
+
+
+ @BeforeClass
+ public static void setUpClass() {
+ Main.class.getClassLoader().setDefaultAssertionStatus(true);
+ }
+
+ @Test
+ public void testCheckStructure003() throws Exception {
+ JillTestTools.checkStructureWithJill(null,
+ null,
+ JillTestTools.getJackTestsWithJackFolder("jarjar/test003"),
+ false,
+ new JarJarRules(JillTestTools.getJackTestFolder("jarjar/test003"), "jarjar-rules.txt"),
+ null);
+ }
+}
diff --git a/jill/tests/com/android/jill/JillTestTools.java b/jill/tests/com/android/jill/JillTestTools.java
new file mode 100644
index 0000000..44c9ce6
--- /dev/null
+++ b/jill/tests/com/android/jill/JillTestTools.java
@@ -0,0 +1,132 @@
+/*
+ * 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.jill;
+
+import com.android.jack.DexComparator;
+import com.android.jack.JarJarRules;
+import com.android.jack.Options;
+import com.android.jack.ProguardFlags;
+import com.android.jack.TestTools;
+import com.android.jack.util.ExecuteFile;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+
+public class JillTestTools extends TestTools {
+
+ @Nonnull
+ private static final File JILL = getFromAndroidTree("out/host/linux-x86/framework/jill.jar");
+
+ public static void runJill(@Nonnull File inputFile, @Nonnull File outputFile) throws Exception {
+ String[] args = new String[] {"java",
+ "-jar",
+ JILL.getAbsolutePath(),
+ "-o",
+ outputFile.getAbsolutePath(),
+ inputFile.getAbsolutePath()};
+
+ ExecuteFile execFile = new ExecuteFile(args);
+ if (!execFile.run()) {
+ throw new RuntimeException("Call to jill exited with an error");
+ }
+ }
+
+ public static void runJillToZip(@Nonnull File inputFile, @Nonnull File outputFile) throws Exception {
+ String[] args = new String[] {"java",
+ "-jar",
+ JillTestTools.JILL.getAbsolutePath(),
+ "-o",
+ outputFile.getAbsolutePath(),
+ inputFile.getAbsolutePath(),
+ "-v",
+ "-c", "zip"};
+
+ ExecuteFile execFile = new ExecuteFile(args);
+ execFile.setErr(System.err);
+ execFile.setOut(System.out);
+ execFile.setVerbose(true);
+ if (!execFile.run()) {
+ throw new RuntimeException("Call to jill exited with an error");
+ }
+ }
+
+ public static void checkStructureWithJill(@CheckForNull File[] refBootclasspath,
+ @CheckForNull File[] refClasspath,
+ @Nonnull File fileOrSourceList,
+ boolean withDebugInfo) throws Exception {
+ checkStructureWithJill(refBootclasspath,
+ refClasspath,
+ fileOrSourceList,
+ withDebugInfo,
+ null,
+ null);
+ }
+
+ public static void checkStructureWithJill(@CheckForNull File[] bootclasspath,
+ @CheckForNull File[] classpath,
+ @Nonnull File fileOrSourceList,
+ boolean withDebugInfo,
+ @CheckForNull JarJarRules jarjarRules,
+ @CheckForNull ProguardFlags[] proguardFlags) throws Exception {
+
+ Options options = buildCommandLineArgs(bootclasspath, classpath, fileOrSourceList,
+ true /* useOnlyCompatibleOptions */);
+
+ boolean useEcjAsRefCompiler = withDebugInfo;
+
+ // Prepare files and directories
+ File testDir = createTempDir("jillTest", null);
+
+ if (withDebugInfo) {
+ List<String> ecjArguments = new ArrayList<String>(options.getEcjArguments());
+ ecjArguments.add(0, "-g");
+ options.setEcjArguments(ecjArguments);
+ }
+
+ ReferenceCompilerFiles files = createReferenceCompilerFiles(testDir,
+ options,
+ proguardFlags,
+ null,
+ null,
+ withDebugInfo,
+ useEcjAsRefCompiler,
+ jarjarRules);
+
+ File refJar = files.jarFile;
+ File refDex = files.dexFile;
+
+ // Run Jill on generated class file
+ File jackFile = new File(testDir, "test.jack");
+ if (!jackFile.exists() && !jackFile.mkdirs()) {
+ throw new IOException("Could not create directory \"" + testDir.getName() + "\"");
+ }
+ runJill(refJar, jackFile);
+
+ // Run Jack on .jack
+ File jackDex = new File(testDir, "testjack.dex");
+ compileJackToDex(new Options(), jackFile, jackDex, false);
+
+ // Compare Jack Dex file to reference
+ new DexComparator().compare(refDex, jackDex, withDebugInfo, /* strict */false,
+ /* compareDebugInfoBinary */ false, /* compareInstructionNumber */ false, 0f);
+ }
+}
diff --git a/jill/tests/com/android/jill/LongLastingTests.java b/jill/tests/com/android/jill/LongLastingTests.java
new file mode 100644
index 0000000..edcab23
--- /dev/null
+++ b/jill/tests/com/android/jill/LongLastingTests.java
@@ -0,0 +1,35 @@
+/*
+ * 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.jill;
+
+
+import com.android.jack.category.SlowTests;
+
+import org.junit.experimental.categories.Categories;
+import org.junit.experimental.categories.Categories.IncludeCategory;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test suite containing tests that are too time-consuming and cannot be run before submitting each
+ * CL.
+ */
+@RunWith(Categories.class)
+@IncludeCategory(SlowTests.class)
+@SuiteClasses(value = {AllTests.class})
+public class LongLastingTests {
+}
diff --git a/jill/tests/com/android/jill/NoClasspathTest.java b/jill/tests/com/android/jill/NoClasspathTest.java
new file mode 100644
index 0000000..7c9ad61
--- /dev/null
+++ b/jill/tests/com/android/jill/NoClasspathTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.jill;
+
+import com.android.jack.category.SlowTests;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+
+@Category(SlowTests.class)
+public class NoClasspathTest {
+
+ protected static final File FRAMEWORK_JAR = JillTestTools
+ .getFromAndroidTree("/out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/"
+ + "classes.jar");
+
+ @Test
+ public void frameworkFromJill() throws Exception {
+ File frameworkJackZip = JillTestTools.createTempFile("framework", ".zip");
+ JillTestTools.runJillToZip(FRAMEWORK_JAR, frameworkJackZip);
+
+ File frameworkDex = JillTestTools.createTempFile("framework", ".dex");
+ JillTestTools.compileJackToDex(new com.android.jack.Options(), frameworkJackZip, frameworkDex,
+ false);
+ }
+}
diff --git a/jill/tests/com/android/jill/PreSubmitTests.java b/jill/tests/com/android/jill/PreSubmitTests.java
new file mode 100644
index 0000000..0d4afcc
--- /dev/null
+++ b/jill/tests/com/android/jill/PreSubmitTests.java
@@ -0,0 +1,34 @@
+/*
+ * 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.jill;
+
+
+import com.android.jack.category.NonPreSubmitTests;
+
+import org.junit.experimental.categories.Categories;
+import org.junit.experimental.categories.Categories.ExcludeCategory;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test suite to run before submitting a CL.
+ */
+@RunWith(Categories.class)
+@ExcludeCategory(NonPreSubmitTests.class)
+@SuiteClasses(value = {AllTests.class})
+public class PreSubmitTests {
+}
diff --git a/jill/tests/com/android/jill/TestTools.java b/jill/tests/com/android/jill/TestTools.java
deleted file mode 100644
index 815679b..0000000
--- a/jill/tests/com/android/jill/TestTools.java
+++ /dev/null
@@ -1,47 +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.jill;
-
-import java.io.File;
-import java.io.IOException;
-
-import javax.annotation.Nonnull;
-
-public class TestTools {
-
- @Nonnull
- public static String getAndroidTop() {
- String androidTop = System.getenv("ANDROID_BUILD_TOP");
- if (androidTop == null) {
- throw new AssertionError("Failed to locate environment variable ANDROID_BUILD_TOP.");
- }
- return androidTop;
- }
-
- @Nonnull
- public static File createTempDir(@Nonnull String prefix, @Nonnull String suffix)
- throws IOException {
- File tmp = File.createTempFile(prefix, suffix);
- if (!tmp.delete()) {
- throw new IOException("Failed to delete file " + tmp.getAbsolutePath());
- }
- if (!tmp.mkdirs()) {
- throw new IOException("Failed to create folder " + tmp.getAbsolutePath());
- }
- return tmp;
- }
-}
diff --git a/jill/tests/com/android/jill/compile/androidtree/bouncycastle/BouncycastleCompilationTest.java b/jill/tests/com/android/jill/compile/androidtree/bouncycastle/BouncycastleCompilationTest.java
new file mode 100644
index 0000000..e99d8c6
--- /dev/null
+++ b/jill/tests/com/android/jill/compile/androidtree/bouncycastle/BouncycastleCompilationTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.jill.compile.androidtree.bouncycastle;
+
+import com.android.jack.JarJarRules;
+import com.android.jack.ProguardFlags;
+import com.android.jack.category.SlowTests;
+import com.android.jill.JillTestTools;
+
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+
+public class BouncycastleCompilationTest {
+
+ private static final File[] BOOTCLASSPATH = new File[] {
+ JillTestTools.getFromAndroidTree(
+ "out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes.jar")
+ };
+
+ private static final File SOURCELIST = JillTestTools.getTargetLibSourcelist("bouncycastle");
+
+ private static final JarJarRules JARJAR_RULES = new JarJarRules(
+ JillTestTools.getFromAndroidTree("external/bouncycastle/jarjar-rules.txt"));
+
+ @Test
+ @Category(SlowTests.class)
+ public void compareBouncycastleStructureWithJill() throws Exception {
+ JillTestTools.checkStructureWithJill(
+ BOOTCLASSPATH,
+ null,
+ SOURCELIST,
+ false /* compareDebugInfoBinary */,
+ JARJAR_RULES,
+ (ProguardFlags[]) null);
+ }
+}
diff --git a/jill/tests/com/android/jill/compile/androidtree/core/CoreCompilationTest.java b/jill/tests/com/android/jill/compile/androidtree/core/CoreCompilationTest.java
new file mode 100644
index 0000000..5d1b330
--- /dev/null
+++ b/jill/tests/com/android/jill/compile/androidtree/core/CoreCompilationTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.jill.compile.androidtree.core;
+
+import com.android.jack.category.SlowTests;
+import com.android.jill.JillTestTools;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+
+public class CoreCompilationTest {
+
+ private static final File SOURCELIST = JillTestTools.getTargetLibSourcelist("core");
+
+ @BeforeClass
+ public static void setUpClass() {
+ CoreCompilationTest.class.getClassLoader().setDefaultAssertionStatus(true);
+ }
+
+ @Test
+ @Category(SlowTests.class)
+ public void compareLibCoreStructureWithJill() throws Exception {
+ JillTestTools.checkStructureWithJill(null, null, SOURCELIST, false /*withDebugInfo*/);
+ }
+}
diff --git a/jill/tests/com/android/jill/compile/androidtree/frameworks/FrameworksBaseCompilationTest.java b/jill/tests/com/android/jill/compile/androidtree/frameworks/FrameworksBaseCompilationTest.java
new file mode 100644
index 0000000..1a634f8
--- /dev/null
+++ b/jill/tests/com/android/jill/compile/androidtree/frameworks/FrameworksBaseCompilationTest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.jill.compile.androidtree.frameworks;
+
+import com.android.jack.category.SlowTests;
+import com.android.jill.JillTestTools;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+
+public class FrameworksBaseCompilationTest {
+
+ private static final File[] BOOTCLASSPATH = new File[] {
+ JillTestTools.getFromAndroidTree(
+ "out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes.jar")
+ };
+
+ private final static File[] CLASSPATH = new File[] {
+ JillTestTools.getFromAndroidTree(
+ "out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/classes.jar"),
+ JillTestTools.getFromAndroidTree(
+ "out/target/common/obj/JAVA_LIBRARIES/core-junit_intermediates/classes.jar"),
+ JillTestTools.getFromAndroidTree(
+ "out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes.jar")};
+
+ private static final File SOURCELIST = JillTestTools.getTargetLibSourcelist("framework");
+
+ @BeforeClass
+ public static void setUpClass() {
+ FrameworksBaseCompilationTest.class.getClassLoader().setDefaultAssertionStatus(true);
+ }
+
+ @Test
+ @Category(SlowTests.class)
+ public void compareFrameworksStructureWithJill() throws Exception {
+ JillTestTools.checkStructureWithJill(BOOTCLASSPATH, CLASSPATH, SOURCELIST,
+ false /*withDebugInfo*/);
+ }
+}
diff --git a/jill/tests/com/android/jill/compile/androidtree/services/ServicesCompilationTest.java b/jill/tests/com/android/jill/compile/androidtree/services/ServicesCompilationTest.java
new file mode 100644
index 0000000..449d4e5
--- /dev/null
+++ b/jill/tests/com/android/jill/compile/androidtree/services/ServicesCompilationTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.jill.compile.androidtree.services;
+
+import com.android.jack.category.SlowTests;
+import com.android.jill.JillTestTools;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import java.io.File;
+
+public class ServicesCompilationTest {
+
+ private static final File[] BOOTCLASSPATH = new File[] {
+ JillTestTools.getFromAndroidTree(
+ "out/target/common/obj/JAVA_LIBRARIES/core_intermediates/classes.jar")
+ };
+
+ private static final File[] CLASSPATH = new File[] {
+ JillTestTools.getFromAndroidTree(
+ "out/target/common/obj/JAVA_LIBRARIES/android.policy_intermediates/classes.jar"),
+ JillTestTools.getFromAndroidTree(
+ "out/target/common/obj/JAVA_LIBRARIES/core-junit_intermediates/classes.jar"),
+ JillTestTools.getFromAndroidTree(
+ "out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/classes.jar"),
+ JillTestTools.getFromAndroidTree(
+ "out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar"), JillTestTools.getFromAndroidTree("out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/classes.jar")};
+
+ private static final File SOURCELIST = JillTestTools.getTargetLibSourcelist("services");
+
+ @BeforeClass
+ public static void setUpClass() {
+ ServicesCompilationTest.class.getClassLoader().setDefaultAssertionStatus(true);
+ }
+
+ @Test
+ @Category(SlowTests.class)
+ public void compareServicesStructureWithJill() throws Exception {
+ JillTestTools.checkStructureWithJill(BOOTCLASSPATH,
+ CLASSPATH,
+ SOURCELIST,
+ false /* withDebugInfo */);
+ }
+}
diff --git a/jill/tests/com/android/jill/shrob/ShrinkTest.java b/jill/tests/com/android/jill/shrob/ShrinkTest.java
new file mode 100644
index 0000000..1814b33
--- /dev/null
+++ b/jill/tests/com/android/jill/shrob/ShrinkTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.jill.shrob;
+
+import com.android.jack.ProguardFlags;
+import com.android.jill.JillTestTools;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import javax.annotation.Nonnull;
+
+public class ShrinkTest {
+
+ @Nonnull
+ private static final File[] defaultBootclasspath = JillTestTools.getDefaultBootclasspath();
+
+ private static ProguardFlags dontObfuscateFlagFile =
+ new ProguardFlags(JillTestTools.getJackTestFolder("shrob"), "dontobfuscate.flags");
+
+ @BeforeClass
+ public static void setUpClass() {
+ ShrinkTest.class.getClassLoader().setDefaultAssertionStatus(true);
+ }
+
+ protected ProguardFlags generateInjars(@Nonnull File injar) throws IOException {
+ File injarFlags = JillTestTools.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 test27_001() throws Exception {
+ File libzip = JillTestTools.createTempFile("lib", ".zip");
+ JillTestTools.runJillToZip(JillTestTools.getJackTestLibFolder("shrob/test027"), libzip);
+ String testName = "shrob/test027";
+ File testFolder = JillTestTools.getJackTestFolder(testName);
+ File refFolder = new File(testFolder, "refsShrinking");
+ ProguardFlags[] proguardflagsFiles = new ProguardFlags[] {
+ dontObfuscateFlagFile,
+ new ProguardFlags(testFolder, "proguard.flags001"),
+ generateInjars(libzip)};
+ JillTestTools.checkListing(defaultBootclasspath, null,
+ JillTestTools.getJackTestsWithJackFolder(testName), proguardflagsFiles,
+ new File(refFolder, "expected-001.txt"));
+ }
+}