Move debug test resources into main source set
Bug: b/270105162
Bug: b/167145686
Change-Id: I4c644a24c4c59c396d716c69935fae3b3a7971d7
diff --git a/build.gradle b/build.gradle
index 1f686db..a26a459 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1203,44 +1203,6 @@
dependsOn buildR8ApiUsageSample
}
-task buildDebugTestResourcesJars {
- def resourcesDir = file("src/test/debugTestResources")
- def hostJar = "debug_test_resources.jar"
- task "compile_debugTestResources"(type: JavaCompile) {
- source = fileTree(dir: resourcesDir, include: '**/*.java')
- destinationDir = file("build/test/debugTestResources/classes")
- classpath = sourceSets.main.compileClasspath
- sourceCompatibility = JavaVersion.VERSION_1_7
- targetCompatibility = JavaVersion.VERSION_1_7
- options.compilerArgs += ["-g", "-Xlint:-options"]
- }
- task "jar_debugTestResources"(type: Jar, dependsOn: "compile_debugTestResources") {
- archiveName = hostJar
- destinationDir = file("build/test/")
- from "build/test/debugTestResources/classes"
- include "**/*.class"
- }
- def java8ResourcesDir = file("src/test/debugTestResourcesJava8")
- def java8HostJar = "debug_test_resources_java8.jar"
- task "compile_debugTestResourcesJava8"(type: JavaCompile) {
- source = fileTree(dir: java8ResourcesDir, include: '**/*.java')
- destinationDir = file("build/test/debugTestResourcesJava8/classes")
- classpath = sourceSets.main.compileClasspath
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
- options.compilerArgs += ["-g", "-Xlint:-options"]
- }
- task "jar_debugTestResourcesJava8"(type: Jar, dependsOn: "compile_debugTestResourcesJava8") {
- archiveName = java8HostJar
- destinationDir = file("build/test/")
- from "build/test/debugTestResourcesJava8/classes"
- include "**/*.class"
- }
- dependsOn downloadDeps
- dependsOn jar_debugTestResources
- dependsOn jar_debugTestResourcesJava8
-}
-
// Examples used by tests, where Android specific APIs are used.
task buildExampleAndroidApi(type: JavaCompile) {
source = fileTree(dir: file("src/test/examplesAndroidApi"), include: "**/*.java")
@@ -1591,7 +1553,6 @@
"It is fully supported on Linux and partially supported on Mac OS and Windows")
return;
}
- dependsOn buildDebugTestResourcesJars
dependsOn buildExampleJars
dependsOn buildExampleAndroidNJars
dependsOn buildExampleAndroidOJars
diff --git a/src/test/java/com/android/tools/r8/JvmTestBuilder.java b/src/test/java/com/android/tools/r8/JvmTestBuilder.java
index f615502..f6fcb08 100644
--- a/src/test/java/com/android/tools/r8/JvmTestBuilder.java
+++ b/src/test/java/com/android/tools/r8/JvmTestBuilder.java
@@ -66,7 +66,8 @@
return new JvmTestRunResult(builder.build(), runtime, result, getState());
}
- public CfDebugTestConfig debugConfig(TestRuntime runtime) {
+ @Override
+ public CfDebugTestConfig debugConfig(TestRuntime runtime) throws Exception {
assert runtime.isCf();
return new CfDebugTestConfig(runtime.asCf(), classpath);
}
diff --git a/src/test/java/com/android/tools/r8/TestBuilder.java b/src/test/java/com/android/tools/r8/TestBuilder.java
index 6d1a97d..1105fac 100644
--- a/src/test/java/com/android/tools/r8/TestBuilder.java
+++ b/src/test/java/com/android/tools/r8/TestBuilder.java
@@ -5,6 +5,7 @@
import com.android.tools.r8.ClassFileConsumer.ArchiveConsumer;
import com.android.tools.r8.TestBase.Backend;
+import com.android.tools.r8.debug.DebugTestConfig;
import com.android.tools.r8.errors.Unimplemented;
import com.android.tools.r8.utils.AndroidApiLevel;
import com.android.tools.r8.utils.ListUtils;
@@ -264,4 +265,8 @@
// Default ignored.
return self();
}
+
+ public DebugTestConfig debugConfig(TestRuntime runtime) throws Exception {
+ throw new Unimplemented("Not implemented for this test builder");
+ }
}
diff --git a/src/test/java/com/android/tools/r8/TestCompilerBuilder.java b/src/test/java/com/android/tools/r8/TestCompilerBuilder.java
index 36008e8..bd2e8cd 100644
--- a/src/test/java/com/android/tools/r8/TestCompilerBuilder.java
+++ b/src/test/java/com/android/tools/r8/TestCompilerBuilder.java
@@ -10,6 +10,7 @@
import com.android.tools.r8.TestBase.Backend;
import com.android.tools.r8.benchmarks.BenchmarkResults;
+import com.android.tools.r8.debug.DebugTestConfig;
import com.android.tools.r8.optimize.argumentpropagation.ArgumentPropagatorEventConsumer;
import com.android.tools.r8.optimize.argumentpropagation.codescanner.MethodStateCollectionByReference;
import com.android.tools.r8.testing.AndroidBuildVersion;
@@ -566,6 +567,11 @@
return self();
}
+ @Override
+ public DebugTestConfig debugConfig(TestRuntime runtime) throws Exception {
+ return compile().debugConfig(runtime);
+ }
+
private static Set<String> computeAllGlobalSynthetics(int minApiLevel) {
try {
Set<String> generatedGlobalSynthetics = Sets.newConcurrentHashSet();
diff --git a/src/test/java/com/android/tools/r8/debug/BlockReorderingTest.java b/src/test/java/com/android/tools/r8/debug/BlockReorderingTest.java
index aab70be..0827456 100644
--- a/src/test/java/com/android/tools/r8/debug/BlockReorderingTest.java
+++ b/src/test/java/com/android/tools/r8/debug/BlockReorderingTest.java
@@ -7,6 +7,7 @@
import com.android.tools.r8.TestParameters;
import com.android.tools.r8.TestParametersCollection;
import com.android.tools.r8.ToolHelper.DexVm.Version;
+import com.android.tools.r8.debug.classes.BlockReordering;
import com.android.tools.r8.utils.AndroidApiLevel;
import org.junit.Assume;
import org.junit.Test;
@@ -19,7 +20,7 @@
@RunWith(Parameterized.class)
public class BlockReorderingTest extends DebugTestBase {
- public static final String CLASS = "BlockReordering";
+ public static final String CLASS = typeName(BlockReordering.class);
public static final String FILE = "BlockReordering.java";
@Parameters(name = "{0}")
@@ -31,7 +32,7 @@
public DebugTestConfig getDebugConfig() throws CompilationFailedException {
return testForD8()
- .addProgramFiles(DEBUGGEE_JAR)
+ .addProgramClasses(BlockReordering.class)
.setMinApi(parameters)
.addOptionsModification(options -> options.testing.invertConditionals = true)
.compile()
@@ -53,15 +54,15 @@
CLASS,
breakpoint(CLASS, method),
run(),
- checkLine(FILE, 8),
+ checkLine(FILE, 10),
stepOver(),
- checkLine(FILE, 13),
+ checkLine(FILE, 15),
run(),
- checkLine(FILE, 8),
+ checkLine(FILE, 10),
stepOver(),
- checkLine(FILE, 9),
+ checkLine(FILE, 11),
stepOver(),
- checkLine(FILE, 13),
+ checkLine(FILE, 15),
run());
}
@@ -74,15 +75,15 @@
CLASS,
breakpoint(CLASS, method),
run(),
- checkLine(FILE, 17),
+ checkLine(FILE, 19),
stepOver(),
- checkLine(FILE, 18),
+ checkLine(FILE, 20),
stepOver(),
- checkLine(FILE, 22),
+ checkLine(FILE, 24),
run(),
- checkLine(FILE, 17),
+ checkLine(FILE, 19),
stepOver(),
- checkLine(FILE, 22),
+ checkLine(FILE, 24),
run());
}
@@ -95,21 +96,21 @@
CLASS,
breakpoint(CLASS, method),
run(),
- checkLine(FILE, 26),
+ checkLine(FILE, 28),
stepOver(),
- checkLine(FILE, 35),
+ checkLine(FILE, 37),
run(),
- checkLine(FILE, 26),
+ checkLine(FILE, 28),
stepOver(),
- checkLine(FILE, 30),
+ checkLine(FILE, 32),
stepOver(),
- checkLine(FILE, 35),
+ checkLine(FILE, 37),
run(),
- checkLine(FILE, 26),
+ checkLine(FILE, 28),
stepOver(),
- checkLine(FILE, 31),
+ checkLine(FILE, 33),
stepOver(),
- checkLine(FILE, 35),
+ checkLine(FILE, 37),
run());
}
}
diff --git a/src/test/java/com/android/tools/r8/debug/ContinuousSteppingTest.java b/src/test/java/com/android/tools/r8/debug/ContinuousSteppingTest.java
index 265bb19..d8cb588 100644
--- a/src/test/java/com/android/tools/r8/debug/ContinuousSteppingTest.java
+++ b/src/test/java/com/android/tools/r8/debug/ContinuousSteppingTest.java
@@ -50,8 +50,6 @@
// A list of self-contained jars to process (which do not depend on other jar files).
private static List<Pair<Path, Predicate<Version>>> listOfJars() {
return new ConfigListBuilder()
- .add(DebugTestBase.DEBUGGEE_JAR, ContinuousSteppingTest::allVersions)
- .add(DebugTestBase.DEBUGGEE_JAVA8_JAR, ContinuousSteppingTest::allVersions)
.addAll(
findAllJarsIn(Paths.get(ToolHelper.EXAMPLES_ANDROID_N_BUILD_DIR)),
ContinuousSteppingTest::fromAndroidN)
diff --git a/src/test/java/com/android/tools/r8/debug/D8DebugTestResourcesConfig.java b/src/test/java/com/android/tools/r8/debug/D8DebugTestResourcesConfig.java
deleted file mode 100644
index 2425d7c..0000000
--- a/src/test/java/com/android/tools/r8/debug/D8DebugTestResourcesConfig.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-package com.android.tools.r8.debug;
-
-import com.android.tools.r8.OutputMode;
-import com.android.tools.r8.utils.AndroidApp;
-import java.nio.file.Path;
-import java.util.Collections;
-import org.junit.rules.TemporaryFolder;
-
-// Shared test configuration for D8 compiled resources from the "debugTestResources" target.
-public class D8DebugTestResourcesConfig extends D8DebugTestConfig {
-
- private static AndroidApp compiledResources = null;
-
- private static synchronized AndroidApp getCompiledResources() {
- if (compiledResources == null) {
- compiledResources = d8Compile(Collections.singletonList(DebugTestBase.DEBUGGEE_JAR), null);
- }
- return compiledResources;
- }
-
- public D8DebugTestResourcesConfig(TemporaryFolder temp) {
- try {
- Path path = temp.newFolder().toPath().resolve("d8_debug_test_resources.jar");
- getCompiledResources().writeForTesting(path, OutputMode.DexIndexed);
- addPaths(path);
- } catch (Throwable e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/src/test/java/com/android/tools/r8/debug/DebugArithmeticTest.java b/src/test/java/com/android/tools/r8/debug/DebugArithmeticTest.java
new file mode 100644
index 0000000..701b0cc
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/debug/DebugArithmeticTest.java
@@ -0,0 +1,94 @@
+// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug;
+
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.TestParametersCollection;
+import com.android.tools.r8.debug.classes.Arithmetic;
+import com.android.tools.r8.utils.AndroidApiLevel;
+import org.apache.harmony.jpda.tests.framework.jdwp.Value;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+
+/** Examples of debug test features. */
+@RunWith(Parameterized.class)
+public class DebugArithmeticTest extends DebugTestBase {
+
+ public static final String SOURCE_FILE = "Arithmetic.java";
+ public static final String DEBUGGEE_CLASS = typeName(Arithmetic.class);
+
+ @Parameter() public TestParameters parameters;
+
+ @Parameters(name = "{0}")
+ public static TestParametersCollection data() {
+ return getTestParameters().withDexRuntimes().withApiLevel(AndroidApiLevel.B).build();
+ }
+
+ public DebugTestConfig getConfig() throws Exception {
+ return testForD8(parameters.getBackend())
+ .setMinApi(parameters)
+ .addProgramClasses(Arithmetic.class)
+ .debugConfig(parameters.getRuntime());
+ }
+
+ /**
+ * Simple test that runs the debuggee until it exits.
+ */
+ @Test
+ public void testRun() throws Throwable {
+ runDebugTest(getConfig(), DEBUGGEE_CLASS, run());
+ }
+
+ /**
+ * Tests that we do suspend on breakpoint then continue.
+ */
+ @Test
+ public void testBreakpoint_Hit() throws Throwable {
+ runDebugTest(
+ getConfig(),
+ DEBUGGEE_CLASS,
+ breakpoint(DEBUGGEE_CLASS, "bitwiseInts"),
+ run(),
+ checkLine(SOURCE_FILE, 14),
+ run());
+ }
+
+ /**
+ * Tests that we can check local variables at a suspension point (breakpoint).
+ */
+ @Test
+ public void testLocalsOnBreakpoint() throws Throwable {
+ runDebugTest(
+ getConfig(),
+ DEBUGGEE_CLASS,
+ breakpoint(DEBUGGEE_CLASS, "bitwiseInts"),
+ run(),
+ checkLine(SOURCE_FILE, 14),
+ checkLocal("x", Value.createInt(12345)),
+ checkLocal("y", Value.createInt(54321)),
+ run());
+ }
+
+ /**
+ * Tests that we can check local variables at different suspension points (breakpoint then step).
+ */
+ @Test
+ public void testLocalsOnBreakpointThenStep() throws Throwable {
+ runDebugTest(
+ getConfig(),
+ DEBUGGEE_CLASS,
+ breakpoint(DEBUGGEE_CLASS, "bitwiseInts"),
+ run(),
+ checkLine(SOURCE_FILE, 14),
+ checkLocal("x", Value.createInt(12345)),
+ checkLocal("y", Value.createInt(54321)),
+ stepOver(),
+ checkLocal("x", Value.createInt(12345)),
+ checkLocal("y", Value.createInt(54321)),
+ run());
+ }
+}
diff --git a/src/test/java/com/android/tools/r8/debug/DebugTestBase.java b/src/test/java/com/android/tools/r8/debug/DebugTestBase.java
index b0187f7..e043042 100644
--- a/src/test/java/com/android/tools/r8/debug/DebugTestBase.java
+++ b/src/test/java/com/android/tools/r8/debug/DebugTestBase.java
@@ -28,7 +28,6 @@
import it.unimi.dsi.fastutil.longs.LongSet;
import java.io.File;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
@@ -88,14 +87,6 @@
// Set to true to enable verbose logs
private static final boolean DEBUG_TESTS = false;
- // Build-time compiled debug-test resources for Java SDK < 8. See build.gradle
- public static final Path DEBUGGEE_JAR =
- Paths.get(ToolHelper.BUILD_DIR, "test", "debug_test_resources.jar");
-
- // Build-time compiled debug-test resources for Java SDK 8. See build.gradle
- public static final Path DEBUGGEE_JAVA8_JAR =
- Paths.get(ToolHelper.BUILD_DIR, "test", "debug_test_resources_java8.jar");
-
public static final StepFilter NO_FILTER = new StepFilter.NoStepFilter();
public static final StepFilter INTELLIJ_FILTER = new StepFilter.IntelliJStepFilter();
public static final StepFilter ANDROID_FILTER = new StepFilter.AndroidRuntimeStepFilter();
diff --git a/src/test/java/com/android/tools/r8/debug/DebugTestExamples.java b/src/test/java/com/android/tools/r8/debug/DebugTestExamples.java
deleted file mode 100644
index 92a8408..0000000
--- a/src/test/java/com/android/tools/r8/debug/DebugTestExamples.java
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-package com.android.tools.r8.debug;
-
-import org.apache.harmony.jpda.tests.framework.jdwp.Value;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Examples of debug test features.
- */
-public class DebugTestExamples extends DebugTestBase {
-
- public static final String SOURCE_FILE = "Arithmetic.java";
- public static final String DEBUGGEE_CLASS = "Arithmetic";
-
- private static DebugTestConfig config;
-
- @BeforeClass
- public static void setup() {
- config = new D8DebugTestResourcesConfig(getStaticTemp());
- }
-
- /**
- * Simple test that runs the debuggee until it exits.
- */
- @Test
- public void testRun() throws Throwable {
- runDebugTest(config, DEBUGGEE_CLASS, run());
- }
-
- /**
- * Tests that we do suspend on breakpoint then continue.
- */
- @Test
- public void testBreakpoint_Hit() throws Throwable {
- runDebugTest(
- config,
- DEBUGGEE_CLASS,
- breakpoint(DEBUGGEE_CLASS, "bitwiseInts"),
- run(),
- checkLine(SOURCE_FILE, 12),
- run());
- }
-
- /**
- * Tests that we can check local variables at a suspension point (breakpoint).
- */
- @Test
- public void testLocalsOnBreakpoint() throws Throwable {
- runDebugTest(
- config,
- DEBUGGEE_CLASS,
- breakpoint(DEBUGGEE_CLASS, "bitwiseInts"),
- run(),
- checkLine(SOURCE_FILE, 12),
- checkLocal("x", Value.createInt(12345)),
- checkLocal("y", Value.createInt(54321)),
- run());
- }
-
- /**
- * Tests that we can check local variables at different suspension points (breakpoint then step).
- */
- @Test
- public void testLocalsOnBreakpointThenStep() throws Throwable {
- runDebugTest(
- config,
- DEBUGGEE_CLASS,
- breakpoint(DEBUGGEE_CLASS, "bitwiseInts"),
- run(),
- checkLine(SOURCE_FILE, 12),
- checkLocal("x", Value.createInt(12345)),
- checkLocal("y", Value.createInt(54321)),
- stepOver(),
- checkLocal("x", Value.createInt(12345)),
- checkLocal("y", Value.createInt(54321)),
- run());
- }
-}
diff --git a/src/test/java/com/android/tools/r8/debug/ExceptionTest.java b/src/test/java/com/android/tools/r8/debug/ExceptionTest.java
index 2fbdc29..024745c 100644
--- a/src/test/java/com/android/tools/r8/debug/ExceptionTest.java
+++ b/src/test/java/com/android/tools/r8/debug/ExceptionTest.java
@@ -3,47 +3,73 @@
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.debug;
-import java.nio.file.Path;
-import org.junit.Test;
+import static org.junit.Assume.assumeTrue;
-/**
- * Tests debugging behavior with regards to exception handling
- */
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.TestParametersCollection;
+import com.android.tools.r8.debug.classes.Exceptions;
+import com.android.tools.r8.utils.AndroidApiLevel;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+
+/** Tests debugging behavior with regards to exception handling */
+@RunWith(Parameterized.class)
public class ExceptionTest extends DebugTestBase {
- private static final Path JAR = DebugTestBase.DEBUGGEE_JAR;
+ @Parameter() public TestParameters parameters;
+
+ @Parameters(name = "{0}")
+ public static TestParametersCollection data() {
+ return getTestParameters()
+ .withAllRuntimesAndApiLevels()
+ .withApiLevel(AndroidApiLevel.B)
+ .build();
+ }
+
private static final String SOURCE_FILE = "Exceptions.java";
+ private final String className = typeName(Exceptions.class);
@Test
public void testStepOnCatchCf() throws Throwable {
+ assumeTrue(parameters.isCfRuntime());
// Java jumps to first instruction of the catch handler, matching the source code.
runDebugTest(
- new CfDebugTestConfig(JAR),
- "Exceptions",
- breakpoint("Exceptions", "catchException"),
+ testForJvm(parameters)
+ .addProgramClasses(Exceptions.class)
+ .debugConfig(parameters.getRuntime()),
+ className,
+ breakpoint(className, "catchException"),
run(),
- checkLine(SOURCE_FILE, 9), // line of the method call throwing the exception
+ checkLine(SOURCE_FILE, 11), // line of the method call throwing the exception
stepOver(),
- checkLine(SOURCE_FILE, 11), // first line in the catch handler
+ checkLine(SOURCE_FILE, 13), // first line in the catch handler
checkLocal("e"),
run());
}
@Test
public void testStepOnCatchD8() throws Throwable {
+ assumeTrue(parameters.isDexRuntime());
// ART/Dalvik jumps to 'move-exception' which initializes the local variable with the pending
// exception. Thus it is "attached" to the line declaring the exception in the catch handler.
runDebugTest(
- new D8DebugTestResourcesConfig(temp),
- "Exceptions",
- breakpoint("Exceptions", "catchException"),
+ testForD8(parameters.getBackend())
+ .setMinApi(parameters)
+ .addProgramClasses(Exceptions.class)
+ .compile()
+ .debugConfig(parameters.getRuntime()),
+ className,
+ breakpoint(className, "catchException"),
run(),
- checkLine(SOURCE_FILE, 9), // line of the method call throwing the exception
+ checkLine(SOURCE_FILE, 11), // line of the method call throwing the exception
stepOver(),
- checkLine(SOURCE_FILE, 10), // line of the catch declaration
+ checkLine(SOURCE_FILE, 12), // line of the catch declaration
checkNoLocal("e"),
stepOver(),
- checkLine(SOURCE_FILE, 11), // first line in the catch handler
+ checkLine(SOURCE_FILE, 13), // first line in the catch handler
checkLocal("e"),
run());
}
diff --git a/src/test/java/com/android/tools/r8/debug/FinallyBlockTest.java b/src/test/java/com/android/tools/r8/debug/FinallyBlockTest.java
index 05bff95..f1ce17d 100644
--- a/src/test/java/com/android/tools/r8/debug/FinallyBlockTest.java
+++ b/src/test/java/com/android/tools/r8/debug/FinallyBlockTest.java
@@ -3,87 +3,105 @@
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.debug;
-import com.android.tools.r8.ToolHelper;
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.TestParametersCollection;
import com.android.tools.r8.ToolHelper.DexVm.Version;
+import com.android.tools.r8.debug.classes.FinallyBlock;
+import com.android.tools.r8.utils.AndroidApiLevel;
import org.junit.Assume;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
/** Test single stepping behaviour of synchronized blocks. */
+@RunWith(Parameterized.class)
public class FinallyBlockTest extends DebugTestBase {
- public static final String CLASS = "FinallyBlock";
+ public static final String CLASS = typeName(FinallyBlock.class);
public static final String FILE = "FinallyBlock.java";
+ @Parameter() public TestParameters parameters;
+
+ @Parameters(name = "{0}")
+ public static TestParametersCollection data() {
+ return getTestParameters().withDexRuntimes().withApiLevel(AndroidApiLevel.B).build();
+ }
+
@Test
public void testEmptyBlock() throws Throwable {
Assume.assumeTrue(
"Older runtimes incorrectly step out of function: b/67671565",
- ToolHelper.getDexVm().getVersion().isNewerThan(Version.V6_0_1));
+ parameters.getDexRuntimeVersion().isNewerThan(Version.V6_0_1));
final String method = "finallyBlock";
runDebugTest(
- new D8DebugTestResourcesConfig(temp),
+ testForD8(parameters.getBackend())
+ .addProgramClasses(FinallyBlock.class)
+ .setMinApi(parameters)
+ .debugConfig(parameters.getRuntime()),
CLASS,
breakpoint(CLASS, method),
run(),
- checkLine(FILE, 8),
- stepOver(),
checkLine(FILE, 10),
stepOver(),
- checkLine(FILE, 18),
- stepOver(),
- checkLine(FILE, 19),
+ checkLine(FILE, 12),
stepOver(),
checkLine(FILE, 20),
stepOver(),
- checkLine(FILE, 25), // return in callFinallyBlock
- run(),
- checkLine(FILE, 8),
+ checkLine(FILE, 21),
stepOver(),
+ checkLine(FILE, 22),
+ stepOver(),
+ checkLine(FILE, 27), // return in callFinallyBlock
+ run(),
checkLine(FILE, 10),
stepOver(),
- checkLine(FILE, 11),
+ checkLine(FILE, 12),
stepOver(),
- checkLine(FILE, 13), // catch AE
+ checkLine(FILE, 13),
stepOver(),
- checkLine(FILE, 14),
- stepOver(),
- checkLine(FILE, 18),
- stepOver(),
- checkLine(FILE, 19),
- stepOver(),
- checkLine(FILE, 20),
- stepOver(),
- checkLine(FILE, 25), // return in callFinallyBlock
- run(),
- checkLine(FILE, 8),
- stepOver(),
- checkLine(FILE, 10),
- stepOver(),
- checkLine(FILE, 11),
- stepOver(),
- checkLine(FILE, 15), // catch RE
+ checkLine(FILE, 15), // catch AE
stepOver(),
checkLine(FILE, 16),
stepOver(),
- checkLine(FILE, 18),
+ checkLine(FILE, 20),
stepOver(),
- checkLine(FILE, 19),
+ checkLine(FILE, 21),
+ stepOver(),
+ checkLine(FILE, 22),
+ stepOver(),
+ checkLine(FILE, 27), // return in callFinallyBlock
+ run(),
+ checkLine(FILE, 10),
+ stepOver(),
+ checkLine(FILE, 12),
+ stepOver(),
+ checkLine(FILE, 13),
+ stepOver(),
+ checkLine(FILE, 17), // catch RE
+ stepOver(),
+ checkLine(FILE, 18),
stepOver(),
checkLine(FILE, 20),
stepOver(),
- checkLine(FILE, 25), // return in callFinallyBlock
- run(),
- checkLine(FILE, 8),
+ checkLine(FILE, 21),
stepOver(),
+ checkLine(FILE, 22),
+ stepOver(),
+ checkLine(FILE, 27), // return in callFinallyBlock
+ run(),
checkLine(FILE, 10),
stepOver(),
- checkLine(FILE, 11), // throw without catch
+ checkLine(FILE, 12),
stepOver(),
- checkLine(FILE, 18), // finally
+ checkLine(FILE, 13), // throw without catch
+ stepOver(),
+ checkLine(FILE, 20), // finally
// Don't single step here as some Java compilers generate line entry 19 and some don't.
- breakpoint(CLASS, "callFinallyBlock", 26),
+ breakpoint(CLASS, "callFinallyBlock", 28),
run(),
- checkLine(FILE, 26), // catch in callFinallyBlock
+ checkLine(FILE, 28), // catch in callFinallyBlock
run());
}
}
diff --git a/src/test/java/com/android/tools/r8/debug/InterfaceMethodTest.java b/src/test/java/com/android/tools/r8/debug/InterfaceMethodTest.java
index 3a0a0f6..1c241d9 100644
--- a/src/test/java/com/android/tools/r8/debug/InterfaceMethodTest.java
+++ b/src/test/java/com/android/tools/r8/debug/InterfaceMethodTest.java
@@ -13,8 +13,9 @@
import com.android.tools.r8.TestParametersCollection;
import com.android.tools.r8.ToolHelper.DexVm.Version;
import com.android.tools.r8.debug.DebugTestBase.JUnit3Wrapper.Command;
+import com.android.tools.r8.debug.classes.DebugInterfaceMethod;
+import com.android.tools.r8.debug.classes.InterfaceWithDefaultAndStaticMethods;
import com.android.tools.r8.ir.desugar.itf.InterfaceDesugaringForTesting;
-import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
@@ -26,7 +27,6 @@
@RunWith(Parameterized.class)
public class InterfaceMethodTest extends DebugTestBase {
- private static final Path JAR = DebugTestBase.DEBUGGEE_JAVA8_JAR;
private static final String TEST_SOURCE_FILE = "DebugInterfaceMethod.java";
private static final String INTERFACE_SOURCE_FILE = "InterfaceWithDefaultAndStaticMethods.java";
@@ -36,7 +36,8 @@
}
@Parameter public TestParameters parameters;
- String debuggeeClass = "DebugInterfaceMethod";
+
+ String debuggeeClass = typeName(DebugInterfaceMethod.class);
private boolean supportsDefaultMethods() {
return parameters.isCfRuntime()
@@ -52,7 +53,8 @@
parameters.isDexRuntimeVersion(Version.V13_0_0)
|| parameters.isDexRuntimeVersion(Version.V14_0_0));
testForRuntime(parameters)
- .addProgramFiles(JAR)
+ .addProgramClassesAndInnerClasses(DebugInterfaceMethod.class)
+ .addProgramClasses(InterfaceWithDefaultAndStaticMethods.class)
.run(parameters.getRuntime(), debuggeeClass)
.debugger(this::runDefaultMethod);
}
@@ -66,12 +68,12 @@
final String defaultMethodThisName;
if (supportsDefaultMethods()) {
- defaultMethodContainerClass = "InterfaceWithDefaultAndStaticMethods";
+ defaultMethodContainerClass = typeName(InterfaceWithDefaultAndStaticMethods.class);
defaultMethodName = "doSomething";
defaultMethodThisName = "this";
} else {
defaultMethodContainerClass =
- "InterfaceWithDefaultAndStaticMethods" + getCompanionClassNameSuffix();
+ typeName(InterfaceWithDefaultAndStaticMethods.class) + getCompanionClassNameSuffix();
// IntelliJ's debugger does not know about the companion class. The only way to match it with
// the source file or the desguared interface is to make it an inner class.
assertEquals('$', getCompanionClassNameSuffix().charAt(0));
@@ -83,16 +85,16 @@
commands.add(breakpoint(debuggeeClass, "testDefaultMethod"));
commands.add(run());
commands.add(checkMethod(debuggeeClass, "testDefaultMethod"));
- commands.add(checkLine(TEST_SOURCE_FILE, 20));
+ commands.add(checkLine(TEST_SOURCE_FILE, 22));
// Step into the default method.
commands.add(stepInto(INTELLIJ_FILTER));
- commands.add(checkLine(INTERFACE_SOURCE_FILE, 7));
+ commands.add(checkLine(INTERFACE_SOURCE_FILE, 9));
commands.add(checkMethod(defaultMethodContainerClass, defaultMethodName));
commands.add(checkLocal(defaultMethodThisName));
commands.add(checkLocal(parameterName));
commands.add(stepOver(INTELLIJ_FILTER));
- commands.add(checkLine(INTERFACE_SOURCE_FILE, 8));
+ commands.add(checkLine(INTERFACE_SOURCE_FILE, 10));
commands.add(checkMethod(defaultMethodContainerClass, defaultMethodName));
commands.add(checkLocal(defaultMethodThisName));
commands.add(checkLocal(parameterName));
@@ -106,7 +108,8 @@
@Test
public void testOverrideDefaultMethod() throws Throwable {
testForRuntime(parameters)
- .addProgramFiles(JAR)
+ .addProgramClassesAndInnerClasses(DebugInterfaceMethod.class)
+ .addProgramClasses(InterfaceWithDefaultAndStaticMethods.class)
.run(parameters.getRuntime(), debuggeeClass)
.debugger(this::runOverrideDefaultMethod);
}
@@ -120,9 +123,10 @@
commands.add(run());
commands.add(run() /* resume after 1st breakpoint */);
commands.add(checkMethod(debuggeeClass, "testDefaultMethod"));
- commands.add(checkLine(TEST_SOURCE_FILE, 20));
+ commands.add(checkLine(TEST_SOURCE_FILE, 22));
commands.add(stepInto());
- commands.add(checkMethod("DebugInterfaceMethod$OverrideImpl", "doSomething"));
+ commands.add(
+ checkMethod(typeName(DebugInterfaceMethod.class) + "$OverrideImpl", "doSomething"));
commands.add(checkLocal("this"));
commands.add(checkLocal(parameterName));
commands.add(stepOver());
@@ -137,7 +141,8 @@
@Test
public void testStaticMethod() throws Throwable {
testForRuntime(parameters)
- .addProgramFiles(JAR)
+ .addProgramClassesAndInnerClasses(DebugInterfaceMethod.class)
+ .addProgramClasses(InterfaceWithDefaultAndStaticMethods.class)
.run(parameters.getRuntime(), debuggeeClass)
.debugger(this::runStaticMethod);
}
@@ -148,10 +153,10 @@
final String staticMethodContainerClass;
final String staticMethodName = "printString";
if (supportsDefaultMethods()) {
- staticMethodContainerClass = "InterfaceWithDefaultAndStaticMethods";
+ staticMethodContainerClass = typeName(InterfaceWithDefaultAndStaticMethods.class);
} else {
staticMethodContainerClass =
- "InterfaceWithDefaultAndStaticMethods"
+ typeName(InterfaceWithDefaultAndStaticMethods.class)
+ InterfaceDesugaringForTesting.getCompanionClassNameSuffix();
}
@@ -159,17 +164,17 @@
commands.add(breakpoint(debuggeeClass, "testStaticMethod"));
commands.add(run());
commands.add(checkMethod(debuggeeClass, "testStaticMethod"));
- commands.add(checkLine(TEST_SOURCE_FILE, 24));
+ commands.add(checkLine(TEST_SOURCE_FILE, 26));
// Step into static method.
commands.add(stepInto());
- commands.add(checkLine(INTERFACE_SOURCE_FILE, 12));
+ commands.add(checkLine(INTERFACE_SOURCE_FILE, 14));
commands.add(checkMethod(staticMethodContainerClass, staticMethodName));
commands.add(checkNoLocal("this"));
commands.add(checkNoLocal("-this"));
commands.add(checkLocal(parameterName));
commands.add(stepOver());
- commands.add(checkLine(INTERFACE_SOURCE_FILE, 13));
+ commands.add(checkLine(INTERFACE_SOURCE_FILE, 15));
commands.add(checkLocal(parameterName));
commands.add(run());
diff --git a/src/test/java/com/android/tools/r8/debug/LambdaTest.java b/src/test/java/com/android/tools/r8/debug/LambdaTest.java
index 719e651..cd632c3 100644
--- a/src/test/java/com/android/tools/r8/debug/LambdaTest.java
+++ b/src/test/java/com/android/tools/r8/debug/LambdaTest.java
@@ -4,108 +4,103 @@
package com.android.tools.r8.debug;
-import com.google.common.collect.ImmutableList;
-import java.nio.file.Path;
-import java.util.Collection;
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.TestParametersCollection;
+import com.android.tools.r8.debug.classes.DebugLambda;
+import com.android.tools.r8.utils.AndroidApiLevel;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class LambdaTest extends DebugTestBase {
- private static final Path JAR = DebugTestBase.DEBUGGEE_JAVA8_JAR;
+ private static final String DEBUGGEE_CLASS = typeName(DebugLambda.class);
private static final String SOURCE_FILE = "DebugLambda.java";
+ @Parameter() public TestParameters parameters;
+
@Parameters(name = "{0}")
- public static Collection configs() {
- ImmutableList.Builder<Object[]> builder = ImmutableList.builder();
- DelayedDebugTestConfig cfConfig = temp -> new CfDebugTestConfig(JAR);
- DelayedDebugTestConfig d8Config = temp -> new D8DebugTestConfig().compileAndAdd(temp, JAR);
- builder.add(new Object[]{"CF", cfConfig});
- builder.add(new Object[]{"D8", d8Config});
- return builder.build();
+ public static TestParametersCollection data() {
+ return getTestParameters().withAllRuntimes().withApiLevel(AndroidApiLevel.B).build();
}
- private final DebugTestConfig config;
-
- public LambdaTest(String name, DelayedDebugTestConfig delayedConfig) {
- this.config = delayedConfig.getConfig(getStaticTemp());
+ public DebugTestConfig getConfig() throws Exception {
+ return testForRuntime(parameters)
+ .addProgramClassesAndInnerClasses(DebugLambda.class)
+ .debugConfig(parameters.getRuntime());
}
@Test
public void testLambda_ExpressionOnSameLine() throws Throwable {
- String debuggeeClass = "DebugLambda";
String initialMethodName = "printInt";
runDebugTest(
- config,
- debuggeeClass,
- breakpoint(debuggeeClass, initialMethodName),
+ getConfig(),
+ DEBUGGEE_CLASS,
+ breakpoint(DEBUGGEE_CLASS, initialMethodName),
run(),
- checkMethod(debuggeeClass, initialMethodName),
- checkLine(SOURCE_FILE, 12),
+ checkMethod(DEBUGGEE_CLASS, initialMethodName),
+ checkLine(SOURCE_FILE, 14),
checkLocals("i"),
checkNoLocal("j"),
stepInto(INTELLIJ_FILTER),
- checkLine(SOURCE_FILE, 16),
+ checkLine(SOURCE_FILE, 18),
checkLocals("i", "j"),
run());
}
@Test
public void testLambda_StatementOnNewLine() throws Throwable {
- String debuggeeClass = "DebugLambda";
String initialMethodName = "printInt3";
runDebugTest(
- config,
- debuggeeClass,
- breakpoint(debuggeeClass, initialMethodName),
+ getConfig(),
+ DEBUGGEE_CLASS,
+ breakpoint(DEBUGGEE_CLASS, initialMethodName),
run(),
- checkMethod(debuggeeClass, initialMethodName),
- checkLine(SOURCE_FILE, 32),
+ checkMethod(DEBUGGEE_CLASS, initialMethodName),
+ checkLine(SOURCE_FILE, 34),
checkLocals("i", "a", "b"),
stepInto(INTELLIJ_FILTER),
- checkLine(SOURCE_FILE, 37),
+ checkLine(SOURCE_FILE, 39),
checkLocals("a", "b"),
run());
}
@Test
public void testLambda_StaticMethodReference_Trivial() throws Throwable {
- String debuggeeClass = "DebugLambda";
String initialMethodName = "printInt2";
runDebugTest(
- config,
- debuggeeClass,
- breakpoint(debuggeeClass, initialMethodName),
+ getConfig(),
+ DEBUGGEE_CLASS,
+ breakpoint(DEBUGGEE_CLASS, initialMethodName),
run(),
- checkMethod(debuggeeClass, initialMethodName),
- checkLine(SOURCE_FILE, 20),
+ checkMethod(DEBUGGEE_CLASS, initialMethodName),
+ checkLine(SOURCE_FILE, 22),
stepInto(INTELLIJ_FILTER),
- checkMethod(debuggeeClass, "returnOne"),
- checkLine(SOURCE_FILE, 28),
+ checkMethod(DEBUGGEE_CLASS, "returnOne"),
+ checkLine(SOURCE_FILE, 30),
checkNoLocal(),
run());
}
@Test
public void testLambda_StaticMethodReference_NonTrivial() throws Throwable {
- String debuggeeClass = "DebugLambda";
String initialMethodName = "testLambdaWithMethodReferenceAndConversion";
runDebugTest(
- config,
- debuggeeClass,
- breakpoint(debuggeeClass, initialMethodName),
+ getConfig(),
+ DEBUGGEE_CLASS,
+ breakpoint(DEBUGGEE_CLASS, initialMethodName),
run(),
- checkMethod(debuggeeClass, initialMethodName),
- checkLine(SOURCE_FILE, 46),
+ checkMethod(DEBUGGEE_CLASS, initialMethodName),
+ checkLine(SOURCE_FILE, 48),
stepInto(INTELLIJ_FILTER),
inspect(t -> Assert.assertTrue(t.getMethodName().startsWith("lambda$"))),
stepInto(INTELLIJ_FILTER),
- checkMethod(debuggeeClass, "concatObjects"),
- checkLine(SOURCE_FILE, 57),
+ checkMethod(DEBUGGEE_CLASS, "concatObjects"),
+ checkLine(SOURCE_FILE, 59),
checkLocal("objects"),
run());
}
diff --git a/src/test/java/com/android/tools/r8/debug/LineNumberOptimizationTest.java b/src/test/java/com/android/tools/r8/debug/LineNumberOptimizationTest.java
index 1ed300a..ec4a891 100644
--- a/src/test/java/com/android/tools/r8/debug/LineNumberOptimizationTest.java
+++ b/src/test/java/com/android/tools/r8/debug/LineNumberOptimizationTest.java
@@ -4,12 +4,13 @@
package com.android.tools.r8.debug;
import static com.android.tools.r8.naming.ClassNameMapper.MissingFileAction.MISSING_FILE_IS_EMPTY_MAP;
-import static org.junit.Assume.assumeTrue;
import com.android.tools.r8.CompilationMode;
import com.android.tools.r8.R8TestCompileResult;
import com.android.tools.r8.TestParameters;
import com.android.tools.r8.TestParametersCollection;
+import com.android.tools.r8.debug.classes.LineNumberOptimization1;
+import com.android.tools.r8.debug.classes.LineNumberOptimization2;
import com.android.tools.r8.utils.InternalOptions.LineNumberOptimization;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -20,13 +21,13 @@
public class LineNumberOptimizationTest extends DebugTestBase {
private static final int[] ORIGINAL_LINE_NUMBERS_DEBUG = {
- 20, 7, 8, 28, 29, 9, 21, 12, 13, 22, 16, 17
+ 22, 9, 10, 30, 31, 11, 23, 14, 15, 24, 18, 19
};
- private static final String CLASS1 = "LineNumberOptimization1";
- private static final String CLASS2 = "LineNumberOptimization2";
- private static final String FILE1 = CLASS1 + ".java";
- private static final String FILE2 = CLASS2 + ".java";
+ private static final String CLASS1 = typeName(LineNumberOptimization1.class);
+ private static final String CLASS2 = typeName(LineNumberOptimization2.class);
+ private static final String FILE1 = "LineNumberOptimization1.java";
+ private static final String FILE2 = "LineNumberOptimization2.java";
private static final String MAIN_SIGNATURE = "([Ljava/lang/String;)V";
private final TestParameters parameters;
@@ -48,7 +49,7 @@
R8TestCompileResult result =
testForR8(parameters.getBackend())
- .addProgramFiles(DEBUGGEE_JAR)
+ .addProgramClasses(LineNumberOptimization1.class, LineNumberOptimization2.class)
.setMinApi(parameters)
.setMode(dontOptimizeByEnablingDebug ? CompilationMode.DEBUG : CompilationMode.RELEASE)
.noTreeShaking()
@@ -71,13 +72,6 @@
return config;
}
- private void assumeMappingIsNotToPCs() {
- assumeTrue(
- "Ignoring test when the line number table is removed.",
- parameters.isCfRuntime()
- || parameters.getApiLevel().isLessThan(apiLevelWithPcAsLineNumberSupport()));
- }
-
@Test
public void testNotOptimizedByEnablingDebug() throws Throwable {
testDebug(makeConfig(LineNumberOptimization.OFF, false, true), ORIGINAL_LINE_NUMBERS_DEBUG);
diff --git a/src/test/java/com/android/tools/r8/debug/LocalsTest.java b/src/test/java/com/android/tools/r8/debug/LocalsTest.java
index 35178f8..add47dc 100644
--- a/src/test/java/com/android/tools/r8/debug/LocalsTest.java
+++ b/src/test/java/com/android/tools/r8/debug/LocalsTest.java
@@ -3,11 +3,13 @@
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.debug;
+import com.android.tools.r8.TestParameters;
import com.android.tools.r8.debug.DebugTestBase.JUnit3Wrapper.Command;
import com.android.tools.r8.debug.DebugTestBase.JUnit3Wrapper.FrameInspector;
+import com.android.tools.r8.debug.classes.Locals;
+import com.android.tools.r8.utils.AndroidApiLevel;
+import com.android.tools.r8.utils.BooleanUtils;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -17,6 +19,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
/** Tests local variable information. */
@@ -24,79 +27,95 @@
public class LocalsTest extends DebugTestBase {
public static final String SOURCE_FILE = "Locals.java";
+ public static final String CLASS_NAME = typeName(Locals.class);
- @Parameters(name = "{0}")
- public static Collection<Object[]> configs() {
- DelayedDebugTestConfig d8 = D8DebugTestResourcesConfig::new;
- DelayedDebugTestConfig r8Cf = R8CfDebugTestResourcesConfig::new;
- return Arrays.asList(new Object[] {"D8", d8}, new Object[] {"R8/CF", r8Cf});
+ @Parameter(0)
+ public TestParameters parameters;
+
+ @Parameter(1)
+ public boolean isR8;
+
+ @Parameters(name = "{0}, isR8: {1}")
+ public static List<Object[]> data() {
+ return buildParameters(
+ getTestParameters().withAllRuntimes().withApiLevel(AndroidApiLevel.B).build(),
+ BooleanUtils.values());
}
- private final DebugTestConfig config;
-
- public LocalsTest(String name, DelayedDebugTestConfig config) {
- this.config = config.getConfig(getStaticTemp());
+ public DebugTestConfig getConfig() throws Exception {
+ return isR8
+ ? testForR8(parameters.getBackend())
+ .addProgramClasses(Locals.class)
+ .setMinApi(parameters)
+ .debug()
+ .treeShaking(false)
+ .minification(false)
+ .addKeepAllClassesRule()
+ .debugConfig(parameters.getRuntime())
+ : testForRuntime(parameters)
+ .addProgramClasses(Locals.class)
+ .debugConfig(parameters.getRuntime());
}
@Test
public void testNoLocal() throws Throwable {
- final String className = "Locals";
+ final String className = CLASS_NAME;
final String methodName = "noLocals";
runDebugTest(
- config,
+ getConfig(),
className,
breakpoint(className, methodName),
run(),
checkMethod(className, methodName),
- checkLine(SOURCE_FILE, 8),
+ checkLine(SOURCE_FILE, 10),
checkNoLocal(),
stepOver(),
checkMethod(className, methodName),
- checkLine(SOURCE_FILE, 9),
+ checkLine(SOURCE_FILE, 11),
checkNoLocal(),
run());
}
@Test
public void testUnusedLocal() throws Throwable {
- final String className = "Locals";
+ final String className = CLASS_NAME;
final String methodName = "unusedLocals";
runDebugTest(
- config,
+ getConfig(),
className,
breakpoint(className, methodName),
run(),
checkMethod(className, methodName),
- checkLine(SOURCE_FILE, 12),
+ checkLine(SOURCE_FILE, 14),
checkNoLocal(),
stepOver(),
- checkLine(SOURCE_FILE, 13),
+ checkLine(SOURCE_FILE, 15),
checkLocal("i", Value.createInt(Integer.MAX_VALUE)),
run());
}
@Test
public void testConstantLocal() throws Throwable {
- final String className = "Locals";
+ final String className = CLASS_NAME;
final String methodName = "constantLocals";
Value pValue = Value.createInt(10);
Value cValue = Value.createInt(5);
Value vValue = Value.createInt(pValue.getIntValue() + cValue.getIntValue());
runDebugTest(
- config,
+ getConfig(),
className,
breakpoint(className, methodName),
run(),
checkMethod(className, methodName),
- checkLine(SOURCE_FILE, 17),
+ checkLine(SOURCE_FILE, 19),
checkLocal("p", pValue),
stepOver(),
- checkLine(SOURCE_FILE, 18),
+ checkLine(SOURCE_FILE, 20),
checkLocal("p", pValue),
checkLocal("c", cValue),
stepOver(),
- checkLine(SOURCE_FILE, 19),
+ checkLine(SOURCE_FILE, 21),
checkLocal("p", pValue),
checkLocal("c", cValue),
checkLocal("v", vValue),
@@ -105,7 +124,7 @@
@Test
public void testConstantLocalWithUpdate() throws Throwable {
- final String className = "Locals";
+ final String className = CLASS_NAME;
final String methodName = "constantLocals";
Value pValue = Value.createInt(10);
Value cValue = Value.createInt(5);
@@ -113,21 +132,21 @@
Value vValue = Value.createInt(pValue.getIntValue() + newValue.getIntValue());
runDebugTest(
- config,
+ getConfig(),
className,
breakpoint(className, methodName),
run(),
checkMethod(className, methodName),
- checkLine(SOURCE_FILE, 17),
+ checkLine(SOURCE_FILE, 19),
checkLocal("p", pValue),
stepOver(),
- checkLine(SOURCE_FILE, 18),
+ checkLine(SOURCE_FILE, 20),
checkLocal("p", pValue),
checkLocal("c", cValue),
setLocal("c", newValue),
checkLocal("c", newValue), // we should see the updated value
stepOver(),
- checkLine(SOURCE_FILE, 19),
+ checkLine(SOURCE_FILE, 21),
checkLocal("p", pValue),
checkLocal("c", newValue),
checkLocal("v", vValue),
@@ -136,24 +155,24 @@
@Test
public void testZeroLocals() throws Throwable {
- final String className = "Locals";
+ final String className = CLASS_NAME;
final String methodName = "zeroLocals";
final Value newValueForI = Value.createInt(10);
runDebugTest(
- config,
+ getConfig(),
className,
breakpoint(className, methodName),
run(),
checkMethod(className, methodName),
- checkLine(SOURCE_FILE, 23),
+ checkLine(SOURCE_FILE, 25),
checkNoLocal(),
stepOver(),
checkMethod(className, methodName),
- checkLine(SOURCE_FILE, 24),
+ checkLine(SOURCE_FILE, 26),
checkLocal("i", Value.createInt(0)),
setLocal("i", newValueForI),
stepOver(),
- checkLine(SOURCE_FILE, 25),
+ checkLine(SOURCE_FILE, 27),
checkLocal("i", newValueForI),
checkLocal("f", Value.createFloat(0)),
run());
@@ -161,25 +180,25 @@
@Test
public void testNoFlowOptimization() throws Throwable {
- final String className = "Locals";
+ final String className = CLASS_NAME;
final String methodName = "noFlowOptimization";
final Value oldValueForI = Value.createInt(0);
final Value newValueForI = Value.createInt(10);
runDebugTest(
- config,
+ getConfig(),
className,
breakpoint(className, methodName),
run(),
checkMethod(className, methodName),
- checkLine(SOURCE_FILE, 29),
+ checkLine(SOURCE_FILE, 31),
checkNoLocal(),
stepOver(),
checkMethod(className, methodName),
- checkLine(SOURCE_FILE, 30),
+ checkLine(SOURCE_FILE, 32),
checkLocal("i", oldValueForI),
setLocal("i", newValueForI),
stepOver(),
- checkLine(SOURCE_FILE, 33),
+ checkLine(SOURCE_FILE, 35),
checkLocal("i", newValueForI),
run());
}
@@ -187,45 +206,47 @@
@Test
public void testInvokeRange() throws Throwable {
runDebugTest(
- config,
- "Locals",
- breakpoint("Locals", "invokeRange"),
+ getConfig(),
+ CLASS_NAME,
+ breakpoint(CLASS_NAME, "invokeRange"),
run(),
- inspect(state -> {
- // 1st breakpoint
- Assert.assertEquals("invokeRange", state.getMethodName());
- Assert.assertEquals(58, state.getLineNumber());
- state.checkLocal("a", Value.createInt(12));
- state.checkLocal("b", Value.createInt(11));
- state.checkLocal("c", Value.createInt(10));
- state.checkLocal("d", Value.createInt(9));
- state.checkLocal("e", Value.createInt(8));
- state.checkLocal("f", Value.createInt(7));
- state.checkLocal("g", Value.createInt(0));
+ inspect(
+ state -> {
+ // 1st breakpoint
+ Assert.assertEquals("invokeRange", state.getMethodName());
+ Assert.assertEquals(60, state.getLineNumber());
+ state.checkLocal("a", Value.createInt(12));
+ state.checkLocal("b", Value.createInt(11));
+ state.checkLocal("c", Value.createInt(10));
+ state.checkLocal("d", Value.createInt(9));
+ state.checkLocal("e", Value.createInt(8));
+ state.checkLocal("f", Value.createInt(7));
+ state.checkLocal("g", Value.createInt(0));
- FrameInspector outerFrame = state.getFrame(1);
- for (int i = 1; i < 12; ++i) {
- outerFrame.checkLocal("i" + i, Value.createInt(i));
- }
- }),
+ FrameInspector outerFrame = state.getFrame(1);
+ for (int i = 1; i < 12; ++i) {
+ outerFrame.checkLocal("i" + i, Value.createInt(i));
+ }
+ }),
run(),
- inspect(state -> {
- // 2nd breakpoint
- Assert.assertEquals("invokeRange", state.getMethodName());
- Assert.assertEquals(58, state.getLineNumber());
- state.checkLocal("a", Value.createInt(6));
- state.checkLocal("b", Value.createInt(5));
- state.checkLocal("c", Value.createInt(4));
- state.checkLocal("d", Value.createInt(3));
- state.checkLocal("e", Value.createInt(2));
- state.checkLocal("f", Value.createInt(1));
- state.checkLocal("g", Value.createInt(57));
+ inspect(
+ state -> {
+ // 2nd breakpoint
+ Assert.assertEquals("invokeRange", state.getMethodName());
+ Assert.assertEquals(60, state.getLineNumber());
+ state.checkLocal("a", Value.createInt(6));
+ state.checkLocal("b", Value.createInt(5));
+ state.checkLocal("c", Value.createInt(4));
+ state.checkLocal("d", Value.createInt(3));
+ state.checkLocal("e", Value.createInt(2));
+ state.checkLocal("f", Value.createInt(1));
+ state.checkLocal("g", Value.createInt(57));
- FrameInspector outerFrame = state.getFrame(1);
- for (int i = 1; i < 12; ++i) {
- outerFrame.checkLocal("i" + i, Value.createInt(i));
- }
- }),
+ FrameInspector outerFrame = state.getFrame(1);
+ for (int i = 1; i < 12; ++i) {
+ outerFrame.checkLocal("i" + i, Value.createInt(i));
+ }
+ }),
run(),
// TODO(shertz) maybe we should duplicate invokeRange to avoid this extra 'skip'.
// Skip last breakpoint
@@ -235,43 +256,46 @@
@Test
public void testInvokeRange2() throws Throwable {
runDebugTest(
- config,
- "Locals",
- breakpoint("Locals", "reverseRange"),
+ getConfig(),
+ CLASS_NAME,
+ breakpoint(CLASS_NAME, "reverseRange"),
run(),
- inspect(state -> {
- Assert.assertEquals("reverseRange", state.getMethodName());
- Assert.assertEquals(54, state.getLineNumber());
- state.checkLocal("a", Value.createInt(1));
- state.checkLocal("b", Value.createInt(2));
- state.checkLocal("c", Value.createInt(3));
- state.checkLocal("d", Value.createInt(4));
- state.checkLocal("e", Value.createInt(5));
- state.checkLocal("f", Value.createInt(6));
- state.checkLocal("g", Value.createInt(7));
- }),
+ inspect(
+ state -> {
+ Assert.assertEquals("reverseRange", state.getMethodName());
+ Assert.assertEquals(56, state.getLineNumber());
+ state.checkLocal("a", Value.createInt(1));
+ state.checkLocal("b", Value.createInt(2));
+ state.checkLocal("c", Value.createInt(3));
+ state.checkLocal("d", Value.createInt(4));
+ state.checkLocal("e", Value.createInt(5));
+ state.checkLocal("f", Value.createInt(6));
+ state.checkLocal("g", Value.createInt(7));
+ }),
stepInto(),
- inspect(state -> {
- Assert.assertEquals("invokeRange", state.getMethodName());
- Assert.assertEquals(58, state.getLineNumber());
- state.checkLocal("a", Value.createInt(7));
- state.checkLocal("b", Value.createInt(6));
- state.checkLocal("c", Value.createInt(5));
- state.checkLocal("d", Value.createInt(4));
- state.checkLocal("e", Value.createInt(3));
- state.checkLocal("f", Value.createInt(2));
- state.checkLocal("g", Value.createInt(1));
- }),
- inspect(state -> {
- FrameInspector outerFrame = state.getFrame(1);
- outerFrame.checkLocal("a", Value.createInt(1));
- outerFrame.checkLocal("b", Value.createInt(2));
- outerFrame.checkLocal("c", Value.createInt(3));
- outerFrame.checkLocal("d", Value.createInt(4));
- outerFrame.checkLocal("e", Value.createInt(5));
- outerFrame.checkLocal("f", Value.createInt(6));
- outerFrame.checkLocal("g", Value.createInt(7));
- }),
+ inspect(
+ state -> {
+ Assert.assertEquals("invokeRange", state.getMethodName());
+ Assert.assertEquals(60, state.getLineNumber());
+ state.checkLocal("a", Value.createInt(7));
+ state.checkLocal("b", Value.createInt(6));
+ state.checkLocal("c", Value.createInt(5));
+ state.checkLocal("d", Value.createInt(4));
+ state.checkLocal("e", Value.createInt(3));
+ state.checkLocal("f", Value.createInt(2));
+ state.checkLocal("g", Value.createInt(1));
+ }),
+ inspect(
+ state -> {
+ FrameInspector outerFrame = state.getFrame(1);
+ outerFrame.checkLocal("a", Value.createInt(1));
+ outerFrame.checkLocal("b", Value.createInt(2));
+ outerFrame.checkLocal("c", Value.createInt(3));
+ outerFrame.checkLocal("d", Value.createInt(4));
+ outerFrame.checkLocal("e", Value.createInt(5));
+ outerFrame.checkLocal("f", Value.createInt(6));
+ outerFrame.checkLocal("g", Value.createInt(7));
+ }),
run());
}
@@ -281,9 +305,9 @@
final int maxIndex = 16;
Map<String, Value> arrayLocals = new HashMap<>();
runDebugTest(
- config,
- "Locals",
- breakpoint("Locals", "breakpoint"),
+ getConfig(),
+ CLASS_NAME,
+ breakpoint(CLASS_NAME, "breakpoint"),
run(),
inspect(
state -> {
@@ -310,7 +334,7 @@
inspect(
state -> {
Assert.assertEquals("Locals.java", state.getSourceFile());
- Assert.assertEquals(107, state.getLineNumber());
+ Assert.assertEquals(109, state.getLineNumber());
// Verify that all arrays have the same value.
arrayLocals.forEach(state::checkLocal);
}),
@@ -323,7 +347,7 @@
final int lineNumber = state.getLineNumber();
arrayLocals.forEach(state::checkLocal);
// Stop when we reach the expected line.
- return lineNumber == 125 && sourceFile.equals("Locals.java");
+ return lineNumber == 127 && sourceFile.equals("Locals.java");
}),
run());
}
@@ -334,31 +358,32 @@
final long expectedValueOfL = (long) initialValueOfX * 2;
final int expectedValueOfX = (int) expectedValueOfL / initialValueOfX;
runDebugTest(
- config,
- "Locals",
- breakpoint("Locals", "invokerangeLong"),
+ getConfig(),
+ CLASS_NAME,
+ breakpoint(CLASS_NAME, "invokerangeLong"),
run(),
- inspect(state -> {
- FrameInspector outerFrame = state.getFrame(1);
- Map<String, Value> values = outerFrame.getLocalValues();
- Assert.assertTrue("No variable 'x'", values.containsKey("x"));
- Assert.assertTrue("No variable 'obj'", values.containsKey("obj"));
- Assert.assertTrue("No variable 'l'", values.containsKey("l"));
+ inspect(
+ state -> {
+ FrameInspector outerFrame = state.getFrame(1);
+ Map<String, Value> values = outerFrame.getLocalValues();
+ Assert.assertTrue("No variable 'x'", values.containsKey("x"));
+ Assert.assertTrue("No variable 'obj'", values.containsKey("obj"));
+ Assert.assertTrue("No variable 'l'", values.containsKey("l"));
- // 'x' is an int
- Value valueOfX = values.get("x");
- Assert.assertEquals(Tag.INT_TAG, valueOfX.getTag());
- Assert.assertEquals(Value.createInt(expectedValueOfX), valueOfX);
+ // 'x' is an int
+ Value valueOfX = values.get("x");
+ Assert.assertEquals(Tag.INT_TAG, valueOfX.getTag());
+ Assert.assertEquals(Value.createInt(expectedValueOfX), valueOfX);
- // 'obj' is an Object (Integer).
- Value valueOfObj = values.get("obj");
- Assert.assertEquals(Tag.OBJECT_TAG, valueOfObj.getTag());
+ // 'obj' is an Object (Integer).
+ Value valueOfObj = values.get("obj");
+ Assert.assertEquals(Tag.OBJECT_TAG, valueOfObj.getTag());
- // 'l' is a long.
- Value valueOfL = values.get("l");
- Assert.assertEquals(Tag.LONG_TAG, valueOfL.getTag());
- Assert.assertEquals(Value.createLong(expectedValueOfL), valueOfL);
- }),
+ // 'l' is a long.
+ Value valueOfL = values.get("l");
+ Assert.assertEquals(Tag.LONG_TAG, valueOfL.getTag());
+ Assert.assertEquals(Value.createLong(expectedValueOfL), valueOfL);
+ }),
run());
}
@@ -367,9 +392,9 @@
final int initialValueOfX = 21;
final long expectedValueOfL = (long) initialValueOfX * 2;
runDebugTest(
- config,
- "Locals",
- breakpoint("Locals", "foo"),
+ getConfig(),
+ CLASS_NAME,
+ breakpoint(CLASS_NAME, "foo"),
run(),
// Initialize obj to 42 using original value of x.
stepOver(),
@@ -377,20 +402,20 @@
checkLocal("x", Value.createInt(initialValueOfX)),
setLocal("x", Value.createInt(0)),
// Single step until the catch handler triggers.
- checkLine(SOURCE_FILE, 166),
- stepOver(),
checkLine(SOURCE_FILE, 168),
stepOver(),
- checkLine(SOURCE_FILE, 169),
+ checkLine(SOURCE_FILE, 170),
+ stepOver(),
+ checkLine(SOURCE_FILE, 171),
stepOver(),
// At the catch handler, inspect the initial state of locals.
- checkLine(SOURCE_FILE, 172),
+ checkLine(SOURCE_FILE, 174),
checkLocal("x", Value.createInt(0)),
getLocal("obj", value -> Assert.assertEquals(Tag.OBJECT_TAG, value.getTag())),
checkLocal("l", Value.createLong(expectedValueOfL)),
// Step onto first line of catch handler and inspect again, including the exception local.
stepOver(),
- checkLine(SOURCE_FILE, 173),
+ checkLine(SOURCE_FILE, 175),
getLocal("e", value -> Assert.assertEquals(Tag.OBJECT_TAG, value.getTag())),
checkLocal("x", Value.createInt(0)),
getLocal("obj", value -> Assert.assertEquals(Tag.OBJECT_TAG, value.getTag())),
@@ -401,9 +426,9 @@
@Test
public void testStepEmptyForLoopBody1() throws Throwable {
runDebugTest(
- config,
- "Locals",
- breakpoint("Locals", "stepEmptyForLoopBody1"),
+ getConfig(),
+ CLASS_NAME,
+ breakpoint(CLASS_NAME, "stepEmptyForLoopBody1"),
run(),
checkLocal("n", Value.createInt(3)),
checkNoLocal("i"),
@@ -416,9 +441,9 @@
@Test
public void testStepEmptyForLoopBody2() throws Throwable {
runDebugTest(
- config,
- "Locals",
- breakpoint("Locals", "stepEmptyForLoopBody2"),
+ getConfig(),
+ CLASS_NAME,
+ breakpoint(CLASS_NAME, "stepEmptyForLoopBody2"),
run(),
checkLocal("n", Value.createInt(3)),
checkNoLocal("i"),
@@ -430,18 +455,18 @@
@Test
public void testStepNonEmptyForLoopBody() throws Throwable {
- final int LOOP_HEADER_LINE = 207;
- final int LOOP_BODY_LINE = 208;
- final int RETURN_LINE = 209;
+ final int LOOP_HEADER_LINE = 209;
+ final int LOOP_BODY_LINE = 210;
+ final int RETURN_LINE = 211;
final Value N = Value.createInt(3);
final Value I0 = Value.createInt(0);
final Value I1 = Value.createInt(1);
final Value I2 = Value.createInt(2);
final Value I3 = Value.createInt(3);
runDebugTest(
- config,
- "Locals",
- breakpoint("Locals", "stepNonEmptyForLoopBody"),
+ getConfig(),
+ CLASS_NAME,
+ breakpoint(CLASS_NAME, "stepNonEmptyForLoopBody"),
run(),
checkLine(SOURCE_FILE, LOOP_HEADER_LINE),
checkLocal("n", N),
@@ -480,24 +505,24 @@
@Test
public void tempInCase() throws Throwable {
runDebugTest(
- config,
- "Locals",
- breakpoint("Locals", "tempInCase"),
+ getConfig(),
+ CLASS_NAME,
+ breakpoint(CLASS_NAME, "tempInCase"),
run(),
- checkLine(SOURCE_FILE, 215),
+ checkLine(SOURCE_FILE, 217),
checkLocal("x", Value.createInt(42)),
stepOver(),
- checkLine(SOURCE_FILE, 216),
+ checkLine(SOURCE_FILE, 218),
checkLocal("res", Value.createInt(0)),
checkNoLocal("i"),
stepOver(),
- checkLine(SOURCE_FILE, 217),
+ checkLine(SOURCE_FILE, 219),
stepOver(),
- checkLine(SOURCE_FILE, 218),
+ checkLine(SOURCE_FILE, 220),
checkLocal("rem", Value.createInt(42)),
setLocal("rem", Value.createInt(1)),
stepOver(),
- checkLine(SOURCE_FILE, 220),
+ checkLine(SOURCE_FILE, 222),
checkLocal("res", Value.createInt(0)),
run());
}
@@ -505,21 +530,21 @@
@Test
public void localSwap() throws Throwable {
runDebugTest(
- config,
- "Locals",
- breakpoint("Locals", "localSwap"),
+ getConfig(),
+ CLASS_NAME,
+ breakpoint(CLASS_NAME, "localSwap"),
run(),
- checkLine(SOURCE_FILE, 238),
- stepOver(),
checkLine(SOURCE_FILE, 240),
stepOver(),
- checkLine(SOURCE_FILE, 241),
+ checkLine(SOURCE_FILE, 242),
+ stepOver(),
+ checkLine(SOURCE_FILE, 243),
checkLocal("x", Value.createInt(1)),
checkLocal("y", Value.createInt(2)),
checkLocal("t", Value.createInt(1)),
stepOver(),
stepOver(),
- checkLine(SOURCE_FILE, 244),
+ checkLine(SOURCE_FILE, 246),
checkLocal("x", Value.createInt(2)),
checkLocal("y", Value.createInt(1)),
checkNoLocal("t"),
@@ -529,13 +554,13 @@
@Test
public void argumentLiveAtReturn() throws Throwable {
runDebugTest(
- config,
- "Locals",
- breakpoint("Locals", "argumentLiveAtReturn"),
+ getConfig(),
+ CLASS_NAME,
+ breakpoint(CLASS_NAME, "argumentLiveAtReturn"),
run(),
- checkLine(SOURCE_FILE, 248),
+ checkLine(SOURCE_FILE, 250),
stepOver(),
- checkLine(SOURCE_FILE, 262),
+ checkLine(SOURCE_FILE, 264),
checkLocal("x", Value.createInt(-1)),
checkNoLocal("t"),
run());
@@ -544,21 +569,21 @@
@Test
public void switchRewriteToIfs() throws Throwable {
runDebugTest(
- config,
- "Locals",
- breakpoint("Locals", "switchRewriteToIfs"),
+ getConfig(),
+ CLASS_NAME,
+ breakpoint(CLASS_NAME, "switchRewriteToIfs"),
run(),
- checkLine(SOURCE_FILE, 267),
+ checkLine(SOURCE_FILE, 269),
stepOver(),
- checkLine(SOURCE_FILE, 268),
+ checkLine(SOURCE_FILE, 270),
checkLocal("x", Value.createInt(1)),
checkLocal("t", Value.createInt(2)),
stepOver(),
- checkLine(SOURCE_FILE, 269),
+ checkLine(SOURCE_FILE, 271),
checkLocal("x", Value.createInt(2)),
checkLocal("t", Value.createInt(2)),
stepOver(),
- checkLine(SOURCE_FILE, 271),
+ checkLine(SOURCE_FILE, 273),
checkLocal("x", Value.createInt(4)),
checkNoLocal("t"),
run());
@@ -567,21 +592,21 @@
@Test
public void switchRewriteToSwitches() throws Throwable {
runDebugTest(
- config,
- "Locals",
- breakpoint("Locals", "switchRewriteToSwitches"),
+ getConfig(),
+ CLASS_NAME,
+ breakpoint(CLASS_NAME, "switchRewriteToSwitches"),
run(),
- checkLine(SOURCE_FILE, 282),
+ checkLine(SOURCE_FILE, 284),
stepOver(),
- checkLine(SOURCE_FILE, 283),
+ checkLine(SOURCE_FILE, 285),
checkLocal("x", Value.createInt(1)),
checkLocal("t", Value.createInt(2)),
stepOver(),
- checkLine(SOURCE_FILE, 284),
+ checkLine(SOURCE_FILE, 286),
checkLocal("x", Value.createInt(2)),
checkLocal("t", Value.createInt(2)),
stepOver(),
- checkLine(SOURCE_FILE, 286),
+ checkLine(SOURCE_FILE, 288),
checkLocal("x", Value.createInt(4)),
checkNoLocal("t"),
run());
@@ -590,83 +615,83 @@
@Test
public void regression65039701() throws Throwable {
runDebugTest(
- config,
- "Locals",
- breakpoint("Locals", "regression65039701"),
+ getConfig(),
+ CLASS_NAME,
+ breakpoint(CLASS_NAME, "regression65039701"),
run(),
- checkLine(SOURCE_FILE, 304),
+ checkLine(SOURCE_FILE, 306),
checkLocal("createIntNotLong", Value.createBoolean(true)),
stepOver(),
- checkLine(SOURCE_FILE, 305),
+ checkLine(SOURCE_FILE, 307),
checkLocal("a"),
stepOver(),
- checkLine(SOURCE_FILE, 306),
- stepOver(),
checkLine(SOURCE_FILE, 308),
+ stepOver(),
+ checkLine(SOURCE_FILE, 310),
run());
}
@Test
public void regression65066975() throws Throwable {
runDebugTest(
- config,
- "Locals",
- breakpoint("Locals", "regression65066975"),
+ getConfig(),
+ CLASS_NAME,
+ breakpoint(CLASS_NAME, "regression65066975"),
run(),
- checkLine(SOURCE_FILE, 312),
+ checkLine(SOURCE_FILE, 314),
checkLocal("bit", Value.createBoolean(false)),
stepOver(),
- checkLine(SOURCE_FILE, 313),
- stepOver(),
- checkLine(SOURCE_FILE, 316),
+ checkLine(SOURCE_FILE, 315),
stepOver(),
checkLine(SOURCE_FILE, 318),
stepOver(),
- checkLine(SOURCE_FILE, 319),
+ checkLine(SOURCE_FILE, 320),
+ stepOver(),
+ checkLine(SOURCE_FILE, 321),
run());
}
@Test
public void testLocalConstantBis() throws Throwable {
- final String className = "Locals";
+ final String className = CLASS_NAME;
final String methodName = "localConstantBis";
runDebugTest(
- config,
+ getConfig(),
className,
breakpoint(className, methodName),
run(),
- checkLine(SOURCE_FILE, 332),
+ checkLine(SOURCE_FILE, 334),
checkNoLocal("result"),
stepOver(),
- checkLine(SOURCE_FILE, 333),
+ checkLine(SOURCE_FILE, 335),
checkLocal("result", Value.createInt(0)),
stepOver(),
- checkLine(SOURCE_FILE, 334),
+ checkLine(SOURCE_FILE, 336),
checkLocal("result", Value.createInt(0)),
stepOver(),
- checkLine(SOURCE_FILE, 338),
+ checkLine(SOURCE_FILE, 340),
checkLocal("result", Value.createInt(1)),
run());
}
@Test
public void testLocalConstant() throws Throwable {
- final String className = "Locals";
+ final String className = CLASS_NAME;
final String methodName = "localConstant";
runDebugTest(
- config,
+ getConfig(),
className,
breakpoint(className, methodName),
run(),
- checkLine(SOURCE_FILE, 322),
- checkNoLocal("result1"),
- checkNoLocal("result2"),
- stepOver(),
- checkLine(SOURCE_FILE, 323),
- checkNoLocal("result1"),
- checkNoLocal("result2"),
- stepOver(),
checkLine(SOURCE_FILE, 324),
+ checkNoLocal("result1"),
+ checkNoLocal("result2"),
+ stepOver(),
+ checkLine(SOURCE_FILE, 325),
+ checkNoLocal("result1"),
+ checkNoLocal("result2"),
+ stepOver(),
+ checkLine(SOURCE_FILE, 326),
checkLocal("result1"),
checkNoLocal("result2"),
run());
@@ -674,39 +699,39 @@
@Test
public void testLocalTriggeringCSE() throws Throwable {
- final String className = "Locals";
+ final String className = CLASS_NAME;
final String methodName = "localTriggeringCSE";
runDebugTest(
- config,
+ getConfig(),
className,
breakpoint(className, methodName),
run(),
- checkLine(SOURCE_FILE, 342),
+ checkLine(SOURCE_FILE, 344),
checkNoLocal("a"),
checkNoLocal("b"),
checkNoLocal("c"),
checkNoLocal("d"),
stepOver(),
- checkLine(SOURCE_FILE, 343),
+ checkLine(SOURCE_FILE, 345),
checkLocal("a", Value.createInt(1)),
checkNoLocal("b"),
checkNoLocal("c"),
checkNoLocal("d"),
stepOver(),
- checkLine(SOURCE_FILE, 344),
+ checkLine(SOURCE_FILE, 346),
checkLocal("a", Value.createInt(1)),
checkLocal("b", Value.createInt(3)),
checkNoLocal("c"),
checkNoLocal("d"),
stepOver(),
- checkLine(SOURCE_FILE, 345),
+ checkLine(SOURCE_FILE, 347),
checkLocal("a", Value.createInt(1)),
checkLocal("b", Value.createInt(3)),
checkLocal("c", Value.createInt(4)),
checkNoLocal("d"),
setLocal("a", Value.createInt(2)),
stepOver(),
- checkLine(SOURCE_FILE, 346),
+ checkLine(SOURCE_FILE, 348),
checkLocal("a", Value.createInt(2)),
checkLocal("b", Value.createInt(3)),
checkLocal("c", Value.createInt(4)),
@@ -720,29 +745,29 @@
*/
@Test
public void testLocalUsedBy2AddrInstruction() throws Throwable {
- final String className = "Locals";
+ final String className = CLASS_NAME;
final String methodName = "intAddition";
runDebugTest(
- config,
+ getConfig(),
className,
breakpoint(className, methodName),
run(),
- checkLine(SOURCE_FILE, 350),
+ checkLine(SOURCE_FILE, 352),
checkLocal("a", Value.createInt(1)),
checkLocal("b", Value.createInt(2)),
checkLocal("c", Value.createInt(6)),
stepOver(),
- checkLine(SOURCE_FILE, 351),
+ checkLine(SOURCE_FILE, 353),
checkLocal("a", Value.createInt(3)),
checkLocal("b", Value.createInt(2)),
checkLocal("c", Value.createInt(6)),
stepOver(),
- checkLine(SOURCE_FILE, 352),
+ checkLine(SOURCE_FILE, 354),
checkLocal("a", Value.createInt(3)),
checkLocal("b", Value.createInt(8)),
checkLocal("c", Value.createInt(6)),
stepOver(),
- checkLine(SOURCE_FILE, 353),
+ checkLine(SOURCE_FILE, 355),
checkLocal("a", Value.createInt(3)),
checkLocal("b", Value.createInt(8)),
checkLocal("c", Value.createInt(11)),
@@ -751,34 +776,34 @@
@Test
public void testLocalVisibilityIntoLoop() throws Throwable {
- final String className = "Locals";
+ final String className = CLASS_NAME;
final String methodName = "localVisibilityIntoLoop";
List<Command> commands = new ArrayList<>();
- commands.add(breakpoint(className, methodName, 358));
+ commands.add(breakpoint(className, methodName, 360));
commands.add(run());
commands.add(checkMethod(className, methodName));
- commands.add(checkLine(SOURCE_FILE, 358));
+ commands.add(checkLine(SOURCE_FILE, 360));
commands.add(stepOver());
- commands.add(checkLine(SOURCE_FILE, 359));
+ commands.add(checkLine(SOURCE_FILE, 361));
commands.add(checkNoLocal("Ai"));
commands.add(checkNoLocal("Bi"));
commands.add(checkNoLocal("i"));
commands.add(stepOver());
commands.add(checkMethod(className, methodName));
- commands.add(checkLine(SOURCE_FILE, 360));
+ commands.add(checkLine(SOURCE_FILE, 362));
commands.add(checkNoLocal("Ai"));
commands.add(checkNoLocal("Bi"));
commands.add(checkLocal("i", Value.createInt(0)));
commands.add(stepOver());
commands.add(checkMethod(className, methodName));
- commands.add(checkLine(SOURCE_FILE, 361));
+ commands.add(checkLine(SOURCE_FILE, 363));
commands.add(checkNoLocal("Ai"));
commands.add(checkLocal("Bi"));
commands.add(checkLocal("i", Value.createInt(0)));
commands.add(stepOver());
commands.add(checkMethod(className, methodName));
- commands.add(checkLine(SOURCE_FILE, 362));
+ commands.add(checkLine(SOURCE_FILE, 364));
commands.add(checkLocal("Ai"));
commands.add(checkLocal("Bi"));
commands.add(checkLocal("i", Value.createInt(0)));
@@ -786,12 +811,12 @@
commands.add(stepOver());
commands.add(stepOver());
commands.add(checkMethod(className, methodName));
- commands.add(checkLine(SOURCE_FILE, 359));
+ commands.add(checkLine(SOURCE_FILE, 361));
commands.add(checkNoLocal("Ai"));
commands.add(checkNoLocal("Bi"));
commands.add(checkLocal("i", Value.createInt(0)));
commands.add(run());
- runDebugTest(config, className, commands);
+ runDebugTest(getConfig(), className, commands);
}
}
diff --git a/src/test/java/com/android/tools/r8/debug/MultipleReturnsTest.java b/src/test/java/com/android/tools/r8/debug/MultipleReturnsTest.java
index 81d29eb..8e51746 100644
--- a/src/test/java/com/android/tools/r8/debug/MultipleReturnsTest.java
+++ b/src/test/java/com/android/tools/r8/debug/MultipleReturnsTest.java
@@ -3,27 +3,45 @@
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.debug;
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.TestParametersCollection;
+import com.android.tools.r8.debug.classes.MultipleReturns;
+import com.android.tools.r8.utils.AndroidApiLevel;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
-/**
- * Tests debugging of method with multiple return statements.
- */
+/** Tests debugging of method with multiple return statements. */
+@RunWith(Parameterized.class)
public class MultipleReturnsTest extends DebugTestBase {
public static final String SOURCE_FILE = "MultipleReturns.java";
+ public static final String CLASS_NAME = typeName(MultipleReturns.class);
+
+ @Parameter() public TestParameters parameters;
+
+ @Parameters(name = "{0}")
+ public static TestParametersCollection data() {
+ return getTestParameters().withDexRuntimes().withApiLevel(AndroidApiLevel.B).build();
+ }
@Test
public void testMultipleReturns() throws Throwable {
runDebugTest(
- new D8DebugTestResourcesConfig(temp),
- "MultipleReturns",
- breakpoint("MultipleReturns", "multipleReturns"),
+ testForD8(parameters.getBackend())
+ .setMinApi(parameters)
+ .addProgramClasses(MultipleReturns.class)
+ .debugConfig(parameters.getRuntime()),
+ CLASS_NAME,
+ breakpoint(CLASS_NAME, "multipleReturns"),
run(),
stepOver(),
- checkLine(SOURCE_FILE, 16), // this should be the 1st return statement
+ checkLine(SOURCE_FILE, 18), // this should be the 1st return statement
run(),
stepOver(),
- checkLine(SOURCE_FILE, 18), // this should be the 2nd return statement
+ checkLine(SOURCE_FILE, 20), // this should be the 2nd return statement
run());
}
}
diff --git a/src/test/java/com/android/tools/r8/debug/R8CfDebugTestResourcesConfig.java b/src/test/java/com/android/tools/r8/debug/R8CfDebugTestResourcesConfig.java
deleted file mode 100644
index e278ac0..0000000
--- a/src/test/java/com/android/tools/r8/debug/R8CfDebugTestResourcesConfig.java
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (c) 2018, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-package com.android.tools.r8.debug;
-
-import com.android.tools.r8.CompilationMode;
-import com.android.tools.r8.OutputMode;
-import com.android.tools.r8.R8;
-import com.android.tools.r8.R8Command;
-import com.android.tools.r8.ToolHelper;
-import com.android.tools.r8.origin.Origin;
-import com.android.tools.r8.utils.AndroidApp;
-import com.android.tools.r8.utils.AndroidAppConsumers;
-import com.google.common.collect.ImmutableList;
-import java.nio.file.Path;
-import org.junit.rules.TemporaryFolder;
-
-// Shared test configuration for R8/CF compiled resources from the "debugTestResources" target.
-public class R8CfDebugTestResourcesConfig extends CfDebugTestConfig {
-
- private static AndroidApp compiledResources = null;
-
- private static synchronized AndroidApp getCompiledResources() throws Throwable {
- if (compiledResources == null) {
- AndroidAppConsumers sink = new AndroidAppConsumers();
- R8.run(
- R8Command.builder()
- .setDisableTreeShaking(true)
- .setDisableMinification(true)
- .setMode(CompilationMode.DEBUG)
- .addProgramFiles(DebugTestBase.DEBUGGEE_JAR)
- .setProgramConsumer(sink.wrapClassFileConsumer(null))
- .addLibraryFiles(ToolHelper.getJava8RuntimeJar())
- .setDisableTreeShaking(true)
- .setDisableMinification(true)
- .addProguardConfiguration(ImmutableList.of("-keepattributes *"), Origin.unknown())
- .build());
- compiledResources = sink.build();
- }
- return compiledResources;
- }
-
- public R8CfDebugTestResourcesConfig(TemporaryFolder temp) {
- try {
- Path path = temp.newFolder().toPath().resolve("r8_cf_debug_test_resources.jar");
- getCompiledResources().writeForTesting(path, OutputMode.ClassFile);
- addPaths(path);
- } catch (Throwable e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/src/test/java/com/android/tools/r8/debug/SharedCodeTest.java b/src/test/java/com/android/tools/r8/debug/SharedCodeTest.java
index 089eb56..91f2487 100644
--- a/src/test/java/com/android/tools/r8/debug/SharedCodeTest.java
+++ b/src/test/java/com/android/tools/r8/debug/SharedCodeTest.java
@@ -4,34 +4,53 @@
package com.android.tools.r8.debug;
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.TestParametersCollection;
+import com.android.tools.r8.debug.classes.SharedCode;
+import com.android.tools.r8.utils.AndroidApiLevel;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+@RunWith(Parameterized.class)
public class SharedCodeTest extends DebugTestBase {
- public static final String CLASS = "SharedCode";
+ public static final String CLASS = typeName(SharedCode.class);
public static final String FILE = "SharedCode.java";
+ @Parameter() public TestParameters parameters;
+
+ @Parameters(name = "{0}")
+ public static TestParametersCollection data() {
+ return getTestParameters().withDexRuntimes().withApiLevel(AndroidApiLevel.B).build();
+ }
+
@Test
public void testSharedIf() throws Throwable {
final String methodName = "sharedIf";
runDebugTest(
- new D8DebugTestResourcesConfig(temp),
+ testForD8(parameters.getBackend())
+ .addProgramClasses(SharedCode.class)
+ .setMinApi(parameters)
+ .debugConfig(parameters.getRuntime()),
CLASS,
breakpoint(CLASS, methodName),
run(),
checkMethod(CLASS, methodName),
- checkLine(FILE, 8),
- stepOver(),
- checkLine(FILE, 9),
- stepOver(),
- checkLine(FILE, 13),
- run(),
- checkMethod(CLASS, methodName),
- checkLine(FILE, 8),
+ checkLine(FILE, 10),
stepOver(),
checkLine(FILE, 11),
stepOver(),
+ checkLine(FILE, 15),
+ run(),
+ checkMethod(CLASS, methodName),
+ checkLine(FILE, 10),
+ stepOver(),
checkLine(FILE, 13),
+ stepOver(),
+ checkLine(FILE, 15),
run());
}
diff --git a/src/test/java/com/android/tools/r8/debug/SynchronizedBlockTest.java b/src/test/java/com/android/tools/r8/debug/SynchronizedBlockTest.java
index 0c3f81d..6aafde3 100644
--- a/src/test/java/com/android/tools/r8/debug/SynchronizedBlockTest.java
+++ b/src/test/java/com/android/tools/r8/debug/SynchronizedBlockTest.java
@@ -5,64 +5,77 @@
import static org.hamcrest.core.IsNot.not;
+import com.android.tools.r8.TestParameters;
import com.android.tools.r8.ToolHelper;
import com.android.tools.r8.ToolHelper.DexVm;
-import com.google.common.collect.ImmutableList;
-import java.util.Collection;
+import com.android.tools.r8.debug.classes.SynchronizedBlock;
+import com.android.tools.r8.utils.AndroidApiLevel;
+import com.android.tools.r8.utils.BooleanUtils;
+import java.util.List;
import org.junit.Assume;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
/** Test single stepping behaviour of synchronized blocks. */
@RunWith(Parameterized.class)
public class SynchronizedBlockTest extends DebugTestBase {
- public static final String CLASS = "SynchronizedBlock";
+ public static final String CLASS = typeName(SynchronizedBlock.class);
public static final String FILE = "SynchronizedBlock.java";
- private final String name;
- private final DebugTestConfig config;
+ @Parameter(0)
+ public TestParameters parameters;
- @Parameterized.Parameters(name = "{0}")
- public static Collection<Object[]> setup() {
- DelayedDebugTestConfig cf =
- temp -> new CfDebugTestConfig().addPaths(DebugTestBase.DEBUGGEE_JAR);
- DelayedDebugTestConfig r8cf = R8CfDebugTestResourcesConfig::new;
- DelayedDebugTestConfig d8 = D8DebugTestResourcesConfig::new;
- return ImmutableList.of(
- new Object[] {"CF", cf},
- new Object[] {"D8", d8},
- new Object[] {"R8/CF", r8cf});
+ @Parameter(1)
+ public boolean isR8;
+
+ @Parameters(name = "{0}, R8: {1}")
+ public static List<Object[]> data() {
+ return buildParameters(
+ getTestParameters().withAllRuntimesAndApiLevels().withApiLevel(AndroidApiLevel.B).build(),
+ BooleanUtils.values());
}
- public SynchronizedBlockTest(String name, DelayedDebugTestConfig config) {
- this.name = name;
- this.config = config.getConfig(getStaticTemp());
+ public DebugTestConfig getConfig() throws Exception {
+ return isR8
+ ? testForR8(parameters.getBackend())
+ .addProgramClasses(SynchronizedBlock.class)
+ .setMinApi(parameters)
+ .debug()
+ .treeShaking(false)
+ .minification(false)
+ .addKeepAllClassesRule()
+ .debugConfig(parameters.getRuntime())
+ : testForRuntime(parameters)
+ .addProgramClasses(SynchronizedBlock.class)
+ .debugConfig(parameters.getRuntime());
}
@Test
public void testEmptyBlock() throws Throwable {
final String method = "emptyBlock";
runDebugTest(
- config,
+ getConfig(),
CLASS,
breakpoint(CLASS, method),
run(),
- checkLine(FILE, 8),
- checkLocal("obj"),
- stepOver(),
- checkLine(FILE, 9),
- checkLocal("obj"),
- checkLocal("x"),
- stepOver(),
checkLine(FILE, 10),
checkLocal("obj"),
- checkLocal("x"),
stepOver(),
checkLine(FILE, 11),
checkLocal("obj"),
checkLocal("x"),
+ stepOver(),
+ checkLine(FILE, 12),
+ checkLocal("obj"),
+ checkLocal("x"),
+ stepOver(),
+ checkLine(FILE, 13),
+ checkLocal("obj"),
+ checkLocal("x"),
checkLocal("y"),
run());
}
@@ -71,20 +84,12 @@
public void testNonThrowingBlock() throws Throwable {
final String method = "nonThrowingBlock";
runDebugTest(
- config,
+ getConfig(),
CLASS,
breakpoint(CLASS, method),
run(),
- checkLine(FILE, 15),
- checkLocal("obj"),
- stepOver(),
- checkLine(FILE, 16),
- checkLocal("obj"),
- checkLocal("x"),
- stepOver(),
checkLine(FILE, 17),
checkLocal("obj"),
- checkLocal("x"),
stepOver(),
checkLine(FILE, 18),
checkLocal("obj"),
@@ -97,6 +102,14 @@
checkLine(FILE, 20),
checkLocal("obj"),
checkLocal("x"),
+ stepOver(),
+ checkLine(FILE, 21),
+ checkLocal("obj"),
+ checkLocal("x"),
+ stepOver(),
+ checkLine(FILE, 22),
+ checkLocal("obj"),
+ checkLocal("x"),
checkLocal("y"),
run());
}
@@ -105,33 +118,34 @@
public void testThrowingBlock() throws Throwable {
Assume.assumeThat(
"Connection timeout on 6.0.1 runtime. b/67671771",
- ToolHelper.getDexVm().getVersion(), not(DexVm.ART_6_0_1_TARGET.getVersion()));
+ ToolHelper.getDexVm().getVersion(),
+ not(DexVm.ART_6_0_1_TARGET.getVersion()));
final String method = "throwingBlock";
runDebugTest(
- config,
+ getConfig(),
CLASS,
breakpoint(CLASS, method),
run(),
- checkLine(FILE, 25),
+ checkLine(FILE, 27),
checkLocal("obj"),
checkNoLocal("x"),
stepOver(),
- checkLine(FILE, 26),
+ checkLine(FILE, 28),
checkLocal("obj"),
checkLocal("x"),
checkNoLocal("y"),
stepOver(),
- checkLine(FILE, 27),
+ checkLine(FILE, 29),
checkLocal("obj"),
checkLocal("x"),
checkNoLocal("y"),
stepOver(),
- checkLine(FILE, 28), // synchronized block end
+ checkLine(FILE, 30), // synchronized block end
checkLocal("obj"),
checkLocal("x"),
checkNoLocal("y"),
stepOver(),
- checkLine(FILE, 31), // catch handler
+ checkLine(FILE, 33), // catch handler
checkLocal("obj"),
checkNoLocal("x"),
checkNoLocal("y"),
@@ -143,23 +157,13 @@
public void testNestedNonThrowingBlock() throws Throwable {
final String method = "nestedNonThrowingBlock";
runDebugTest(
- config,
+ getConfig(),
CLASS,
breakpoint(CLASS, method),
run(),
- checkLine(FILE, 35),
- checkLocal("obj1"),
- checkLocal("obj2"),
- stepOver(),
- checkLine(FILE, 36),
- checkLocal("obj1"),
- checkLocal("obj2"),
- checkLocal("x"),
- stepOver(),
checkLine(FILE, 37),
checkLocal("obj1"),
checkLocal("obj2"),
- checkLocal("x"),
stepOver(),
checkLine(FILE, 38),
checkLocal("obj1"),
@@ -190,6 +194,16 @@
checkLocal("obj1"),
checkLocal("obj2"),
checkLocal("x"),
+ stepOver(),
+ checkLine(FILE, 44),
+ checkLocal("obj1"),
+ checkLocal("obj2"),
+ checkLocal("x"),
+ stepOver(),
+ checkLine(FILE, 45),
+ checkLocal("obj1"),
+ checkLocal("obj2"),
+ checkLocal("x"),
checkLocal("y"),
run());
}
@@ -198,23 +212,13 @@
public void testNestedThrowingBlock() throws Throwable {
final String method = "nestedThrowingBlock";
runDebugTest(
- config,
+ getConfig(),
CLASS,
breakpoint(CLASS, method),
run(),
- checkLine(FILE, 48),
- checkLocal("obj1"),
- checkLocal("obj2"),
- stepOver(),
- checkLine(FILE, 49),
- checkLocal("obj1"),
- checkLocal("obj2"),
- checkLocal("x"),
- stepOver(),
checkLine(FILE, 50),
checkLocal("obj1"),
checkLocal("obj2"),
- checkLocal("x"),
stepOver(),
checkLine(FILE, 51),
checkLocal("obj1"),
@@ -226,17 +230,27 @@
checkLocal("obj2"),
checkLocal("x"),
stepOver(),
- checkLine(FILE, 53), // inner synchronize block end
+ checkLine(FILE, 53),
checkLocal("obj1"),
checkLocal("obj2"),
checkLocal("x"),
stepOver(),
- checkLine(FILE, 54), // outer synchronize block end
+ checkLine(FILE, 54),
checkLocal("obj1"),
checkLocal("obj2"),
checkLocal("x"),
stepOver(),
- checkLine(FILE, 57), // catch handler
+ checkLine(FILE, 55), // inner synchronize block end
+ checkLocal("obj1"),
+ checkLocal("obj2"),
+ checkLocal("x"),
+ stepOver(),
+ checkLine(FILE, 56), // outer synchronize block end
+ checkLocal("obj1"),
+ checkLocal("obj2"),
+ checkLocal("x"),
+ stepOver(),
+ checkLine(FILE, 59), // catch handler
checkLocal("obj1"),
checkLocal("obj2"),
checkNoLocal("x"),
diff --git a/src/test/java/com/android/tools/r8/debug/SyntheticMethodTest.java b/src/test/java/com/android/tools/r8/debug/SyntheticMethodTest.java
index 0872225..1a592ca 100644
--- a/src/test/java/com/android/tools/r8/debug/SyntheticMethodTest.java
+++ b/src/test/java/com/android/tools/r8/debug/SyntheticMethodTest.java
@@ -4,19 +4,35 @@
package com.android.tools.r8.debug;
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.TestParametersCollection;
import com.android.tools.r8.debug.DebugTestBase.JUnit3Wrapper.Command;
+import com.android.tools.r8.debug.classes.Bridges;
+import com.android.tools.r8.debug.classes.InnerAccessors;
+import com.android.tools.r8.utils.AndroidApiLevel;
import java.util.ArrayList;
import java.util.List;
-import org.junit.BeforeClass;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+@RunWith(Parameterized.class)
public class SyntheticMethodTest extends DebugTestBase {
- private static DebugTestConfig config;
+ @Parameter() public TestParameters parameters;
- @BeforeClass
- public static void setup() {
- config = new D8DebugTestResourcesConfig(getStaticTemp());
+ @Parameters(name = "{0}")
+ public static TestParametersCollection data() {
+ return getTestParameters().withDexRuntimes().withApiLevel(AndroidApiLevel.B).build();
+ }
+
+ public DebugTestConfig getConfig() throws Exception {
+ return testForD8(parameters.getBackend())
+ .addProgramClassesAndInnerClasses(Bridges.class, InnerAccessors.class)
+ .setMinApi(parameters)
+ .debugConfig(parameters.getRuntime());
}
@Test
@@ -41,39 +57,39 @@
private void debugInnerAccessors(StepFilter stepFilter) throws Throwable {
final String sourceFile = "InnerAccessors.java";
- String debuggeeClass = "InnerAccessors";
+ String debuggeeClass = typeName(InnerAccessors.class);
List<Command> commands = new ArrayList<>();
- commands.add(breakpoint("InnerAccessors$Inner", "callPrivateMethodInOuterClass"));
+ commands.add(
+ breakpoint(typeName(InnerAccessors.class) + "$Inner", "callPrivateMethodInOuterClass"));
commands.add(run());
- commands.add(checkLine(sourceFile, 13));
+ commands.add(checkLine(sourceFile, 15));
commands.add(stepInto(stepFilter)); // skip synthetic accessor
if (stepFilter == NO_FILTER) {
commands.add(stepInto(stepFilter));
}
commands.add(checkMethod(debuggeeClass, "privateMethod"));
- commands.add(checkLine(sourceFile, 8));
+ commands.add(checkLine(sourceFile, 10));
commands.add(run());
- runDebugTest(config, debuggeeClass, commands);
+ runDebugTest(getConfig(), debuggeeClass, commands);
}
private void debugGenericBridges(StepFilter stepFilter) throws Throwable {
final String sourceFile = "Bridges.java";
- String debuggeeClass = "Bridges";
+ String debuggeeClass = typeName(Bridges.class);
List<Command> commands = new ArrayList<>();
commands.add(breakpoint(debuggeeClass, "testGenericBridge"));
commands.add(run());
- commands.add(checkLine(sourceFile, 21));
+ commands.add(checkLine(sourceFile, 23));
commands.add(stepInto(stepFilter)); // skip synthetic accessor
- String implementationClassName = "Bridges$StringImpl";
+ String implementationClassName = debuggeeClass + "$StringImpl";
String methodName = "get";
if (stepFilter == NO_FILTER) {
commands.add(checkMethod(implementationClassName, methodName, "(Ljava/lang/Object;)V"));
commands.add(stepInto(stepFilter));
}
commands.add(checkMethod(implementationClassName, methodName, "(Ljava/lang/String;)V"));
- commands.add(checkLine(sourceFile, 16));
+ commands.add(checkLine(sourceFile, 18));
commands.add(run());
- runDebugTest(config, debuggeeClass, commands);
+ runDebugTest(getConfig(), debuggeeClass, commands);
}
-
}
diff --git a/src/test/debugTestResources/Arithmetic.java b/src/test/java/com/android/tools/r8/debug/classes/Arithmetic.java
similarity index 91%
rename from src/test/debugTestResources/Arithmetic.java
rename to src/test/java/com/android/tools/r8/debug/classes/Arithmetic.java
index 29ec2f2..ccccbcf 100644
--- a/src/test/debugTestResources/Arithmetic.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/Arithmetic.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
public class Arithmetic {
public static void main(String[] args) {
diff --git a/src/test/debugTestResources/BlockReordering.java b/src/test/java/com/android/tools/r8/debug/classes/BlockReordering.java
similarity index 96%
rename from src/test/debugTestResources/BlockReordering.java
rename to src/test/java/com/android/tools/r8/debug/classes/BlockReordering.java
index ebc6610..ca581a0 100644
--- a/src/test/debugTestResources/BlockReordering.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/BlockReordering.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
public class BlockReordering {
public static int conditionalReturn(boolean test) {
diff --git a/src/test/debugTestResources/Bridges.java b/src/test/java/com/android/tools/r8/debug/classes/Bridges.java
similarity index 92%
rename from src/test/debugTestResources/Bridges.java
rename to src/test/java/com/android/tools/r8/debug/classes/Bridges.java
index e1a4380..e4a07c4 100644
--- a/src/test/debugTestResources/Bridges.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/Bridges.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
public class Bridges {
interface GenericInterface<T> {
diff --git a/src/test/debugTestResourcesJava8/DebugInterfaceMethod.java b/src/test/java/com/android/tools/r8/debug/classes/DebugInterfaceMethod.java
similarity index 95%
rename from src/test/debugTestResourcesJava8/DebugInterfaceMethod.java
rename to src/test/java/com/android/tools/r8/debug/classes/DebugInterfaceMethod.java
index f951357..4cc691b 100644
--- a/src/test/debugTestResourcesJava8/DebugInterfaceMethod.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/DebugInterfaceMethod.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
public class DebugInterfaceMethod {
static class DefaultImpl implements InterfaceWithDefaultAndStaticMethods {
diff --git a/src/test/debugTestResourcesJava8/DebugLambda.java b/src/test/java/com/android/tools/r8/debug/classes/DebugLambda.java
similarity index 96%
rename from src/test/debugTestResourcesJava8/DebugLambda.java
rename to src/test/java/com/android/tools/r8/debug/classes/DebugLambda.java
index 007cd0c..2d8d2ad 100644
--- a/src/test/debugTestResourcesJava8/DebugLambda.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/DebugLambda.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
public class DebugLambda {
interface I {
diff --git a/src/test/debugTestResources/Exceptions.java b/src/test/java/com/android/tools/r8/debug/classes/Exceptions.java
similarity index 92%
rename from src/test/debugTestResources/Exceptions.java
rename to src/test/java/com/android/tools/r8/debug/classes/Exceptions.java
index a056c13..3a8d97a 100644
--- a/src/test/debugTestResources/Exceptions.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/Exceptions.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
public class Exceptions {
private static void catchException() {
diff --git a/src/test/debugTestResources/FinallyBlock.java b/src/test/java/com/android/tools/r8/debug/classes/FinallyBlock.java
similarity index 95%
rename from src/test/debugTestResources/FinallyBlock.java
rename to src/test/java/com/android/tools/r8/debug/classes/FinallyBlock.java
index 4b30391..14c3108 100644
--- a/src/test/debugTestResources/FinallyBlock.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/FinallyBlock.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
public class FinallyBlock {
public static int finallyBlock(Throwable obj) throws Throwable {
diff --git a/src/test/debugTestResources/Inlining1.java b/src/test/java/com/android/tools/r8/debug/classes/Inlining1.java
similarity index 95%
rename from src/test/debugTestResources/Inlining1.java
rename to src/test/java/com/android/tools/r8/debug/classes/Inlining1.java
index e9fa2cb..3f7a448 100644
--- a/src/test/debugTestResources/Inlining1.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/Inlining1.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
public class Inlining1 {
private static void inlineThisFromSameFile() {
System.out.println("inlineThisFromSameFile");
diff --git a/src/test/debugTestResources/Inlining2.java b/src/test/java/com/android/tools/r8/debug/classes/Inlining2.java
similarity index 92%
rename from src/test/debugTestResources/Inlining2.java
rename to src/test/java/com/android/tools/r8/debug/classes/Inlining2.java
index a570ba3..055fbd4 100644
--- a/src/test/debugTestResources/Inlining2.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/Inlining2.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
//
//
//
diff --git a/src/test/debugTestResources/Inlining3.java b/src/test/java/com/android/tools/r8/debug/classes/Inlining3.java
similarity index 88%
rename from src/test/debugTestResources/Inlining3.java
rename to src/test/java/com/android/tools/r8/debug/classes/Inlining3.java
index dcb965e..f0bbb85 100644
--- a/src/test/debugTestResources/Inlining3.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/Inlining3.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
public class Inlining3 {
public static void differentFileMultilevelInliningLevel2() {
System.out.println("differentFileMultilevelInliningLevel2");
diff --git a/src/test/debugTestResources/InnerAccessors.java b/src/test/java/com/android/tools/r8/debug/classes/InnerAccessors.java
similarity index 91%
rename from src/test/debugTestResources/InnerAccessors.java
rename to src/test/java/com/android/tools/r8/debug/classes/InnerAccessors.java
index 8507e79..373e716 100644
--- a/src/test/debugTestResources/InnerAccessors.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/InnerAccessors.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
public class InnerAccessors {
private static void privateMethod() {
diff --git a/src/test/debugTestResourcesJava8/InterfaceWithDefaultAndStaticMethods.java b/src/test/java/com/android/tools/r8/debug/classes/InterfaceWithDefaultAndStaticMethods.java
similarity index 80%
rename from src/test/debugTestResourcesJava8/InterfaceWithDefaultAndStaticMethods.java
rename to src/test/java/com/android/tools/r8/debug/classes/InterfaceWithDefaultAndStaticMethods.java
index 05f48ab..9eb1578 100644
--- a/src/test/debugTestResourcesJava8/InterfaceWithDefaultAndStaticMethods.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/InterfaceWithDefaultAndStaticMethods.java
@@ -2,7 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-interface InterfaceWithDefaultAndStaticMethods {
+package com.android.tools.r8.debug.classes;
+
+public interface InterfaceWithDefaultAndStaticMethods {
default void doSomething(String msg) {
String name = getClass().getName();
System.out.println(name + ": " + msg);
diff --git a/src/test/debugTestResources/LineNumberOptimization1.java b/src/test/java/com/android/tools/r8/debug/classes/LineNumberOptimization1.java
similarity index 94%
rename from src/test/debugTestResources/LineNumberOptimization1.java
rename to src/test/java/com/android/tools/r8/debug/classes/LineNumberOptimization1.java
index a97fc6d..1cab995 100644
--- a/src/test/debugTestResources/LineNumberOptimization1.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/LineNumberOptimization1.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
public class LineNumberOptimization1 {
private static void callThisFromSameFile() {
System.out.println("callThisFromSameFile");
diff --git a/src/test/debugTestResources/LineNumberOptimization2.java b/src/test/java/com/android/tools/r8/debug/classes/LineNumberOptimization2.java
similarity index 89%
rename from src/test/debugTestResources/LineNumberOptimization2.java
rename to src/test/java/com/android/tools/r8/debug/classes/LineNumberOptimization2.java
index 0f07ae9..f5963ad 100644
--- a/src/test/debugTestResources/LineNumberOptimization2.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/LineNumberOptimization2.java
@@ -1,7 +1,9 @@
// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-//
+
+package com.android.tools.r8.debug.classes;
+
//
//
//
diff --git a/src/test/debugTestResources/Locals.java b/src/test/java/com/android/tools/r8/debug/classes/Locals.java
similarity index 99%
rename from src/test/debugTestResources/Locals.java
rename to src/test/java/com/android/tools/r8/debug/classes/Locals.java
index e32f2ca..60dd2a2 100644
--- a/src/test/debugTestResources/Locals.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/Locals.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
public class Locals {
private static void noLocals() {
diff --git a/src/test/debugTestResources/Minified.java b/src/test/java/com/android/tools/r8/debug/classes/Minified.java
similarity index 92%
rename from src/test/debugTestResources/Minified.java
rename to src/test/java/com/android/tools/r8/debug/classes/Minified.java
index af90776..6a378c9 100644
--- a/src/test/debugTestResources/Minified.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/Minified.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
public class Minified {
private static class Inner {
public static int innerTest() {
diff --git a/src/test/debugTestResources/MultipleReturns.java b/src/test/java/com/android/tools/r8/debug/classes/MultipleReturns.java
similarity index 93%
rename from src/test/debugTestResources/MultipleReturns.java
rename to src/test/java/com/android/tools/r8/debug/classes/MultipleReturns.java
index 7d6dc80..8c2eeb1 100644
--- a/src/test/debugTestResources/MultipleReturns.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/MultipleReturns.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
public class MultipleReturns {
public static void main(String[] args) {
diff --git a/src/test/debugTestResources/SharedCode.java b/src/test/java/com/android/tools/r8/debug/classes/SharedCode.java
similarity index 92%
rename from src/test/debugTestResources/SharedCode.java
rename to src/test/java/com/android/tools/r8/debug/classes/SharedCode.java
index f88fdbd..7fe6c80 100644
--- a/src/test/debugTestResources/SharedCode.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/SharedCode.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
public class SharedCode {
public static int sharedIf(int x) {
diff --git a/src/test/debugTestResources/SynchronizedBlock.java b/src/test/java/com/android/tools/r8/debug/classes/SynchronizedBlock.java
similarity index 97%
rename from src/test/debugTestResources/SynchronizedBlock.java
rename to src/test/java/com/android/tools/r8/debug/classes/SynchronizedBlock.java
index e1cd8c2..c71068b 100644
--- a/src/test/debugTestResources/SynchronizedBlock.java
+++ b/src/test/java/com/android/tools/r8/debug/classes/SynchronizedBlock.java
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+package com.android.tools.r8.debug.classes;
+
public class SynchronizedBlock {
public static int emptyBlock(Object obj) {
diff --git a/src/test/java/com/android/tools/r8/naming/RenameSourceFileDebugTest.java b/src/test/java/com/android/tools/r8/naming/RenameSourceFileDebugTest.java
index 07fe82a..dd432d3 100644
--- a/src/test/java/com/android/tools/r8/naming/RenameSourceFileDebugTest.java
+++ b/src/test/java/com/android/tools/r8/naming/RenameSourceFileDebugTest.java
@@ -13,6 +13,8 @@
import com.android.tools.r8.debug.DebugTestBase;
import com.android.tools.r8.debug.DebugTestConfig;
import com.android.tools.r8.debug.DexDebugTestConfig;
+import com.android.tools.r8.debug.classes.Locals;
+import com.android.tools.r8.debug.classes.MultipleReturns;
import com.android.tools.r8.debug.classinit.ClassInitializationTest;
import com.android.tools.r8.debug.classinit.ClassInitializerEmpty;
import com.android.tools.r8.shaking.ProguardKeepRule;
@@ -34,7 +36,7 @@
private static final String TEST_FILE = "TestFile.java";
- private static Map<Backend, DebugTestConfig> configs = new HashMap<>();
+ private static final Map<Backend, DebugTestConfig> configs = new HashMap<>();
@BeforeClass
public static void initDebuggeePath() throws Exception {
@@ -51,8 +53,10 @@
pgConfig.addKeepAttributePatterns(
ImmutableList.of("SourceFile", "LineNumberTable"));
})
- .addProgramFiles(DEBUGGEE_JAR)
- .addProgramFiles(ToolHelper.getClassFileForTestClass(ClassInitializerEmpty.class))
+ .addProgramFiles(
+ ToolHelper.getClassFileForTestClass(ClassInitializerEmpty.class),
+ ToolHelper.getClassFileForTestClass(Locals.class),
+ ToolHelper.getClassFileForTestClass(MultipleReturns.class))
.setMode(CompilationMode.DEBUG)
.setProguardMapOutputPath(proguardMapPath);
DebugTestConfig config;
@@ -103,7 +107,7 @@
*/
@Test
public void testNoLocal() throws Throwable {
- final String className = "Locals";
+ final String className = typeName(Locals.class);
final String methodName = "noLocals";
runDebugTest(
configs.get(backend),
@@ -111,11 +115,11 @@
breakpoint(className, methodName),
run(),
checkMethod(className, methodName),
- checkLine(TEST_FILE, 8),
+ checkLine(TEST_FILE, 10),
checkNoLocal(),
stepOver(),
checkMethod(className, methodName),
- checkLine(TEST_FILE, 9),
+ checkLine(TEST_FILE, 11),
checkNoLocal(),
run());
}
@@ -123,16 +127,17 @@
/** replica of {@link com.android.tools.r8.debug.MultipleReturnsTest#testMultipleReturns} */
@Test
public void testMultipleReturns() throws Throwable {
+ final String className = typeName(MultipleReturns.class);
runDebugTest(
configs.get(backend),
- "MultipleReturns",
- breakpoint("MultipleReturns", "multipleReturns"),
+ className,
+ breakpoint(className, "multipleReturns"),
run(),
stepOver(),
- checkLine(TEST_FILE, 16), // this should be the 1st return statement
+ checkLine(TEST_FILE, 18), // this should be the 1st return statement
run(),
stepOver(),
- checkLine(TEST_FILE, 18), // this should be the 2nd return statement
+ checkLine(TEST_FILE, 20), // this should be the 2nd return statement
run());
}
}