Regression test for breakpoint issue.
The issue does not occur on ToT due to better debug position pruning, so this is
just the regression test for cherry-picking.
R=mkrogh
Bug: 122450679
Change-Id: I223289627683aff49883337ff3ce9677086a3fcb
diff --git a/src/test/java/com/android/tools/r8/debug/BreakOnIfTest.java b/src/test/java/com/android/tools/r8/debug/BreakOnIfTest.java
new file mode 100644
index 0000000..43338ee
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/debug/BreakOnIfTest.java
@@ -0,0 +1,14 @@
+// Copyright (c) 2019, 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;
+
+public class BreakOnIfTest {
+
+ public static void main(String[] args) {
+ if (args == null) {
+ System.out.println("args null");
+ }
+ System.out.println("after if");
+ }
+}
diff --git a/src/test/java/com/android/tools/r8/debug/BreakOnIfTestRunner.java b/src/test/java/com/android/tools/r8/debug/BreakOnIfTestRunner.java
new file mode 100644
index 0000000..e61d6f8
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/debug/BreakOnIfTestRunner.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2019, 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.ToolHelper;
+import com.google.common.collect.ImmutableList;
+import java.util.Collection;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class BreakOnIfTestRunner extends DebugTestBase {
+
+ private static final Class CLASS = BreakOnIfTest.class;
+ private static final String FILE = CLASS.getSimpleName() + ".java";
+ private static final String NAME = CLASS.getCanonicalName();
+
+ private final DebugTestConfig config;
+
+ @Parameterized.Parameters(name = "{0}")
+ public static Collection<Object[]> setup() {
+ DelayedDebugTestConfig cf =
+ temp -> new CfDebugTestConfig().addPaths(ToolHelper.getClassPathForTests());
+ DelayedDebugTestConfig d8 =
+ temp -> new D8DebugTestConfig().compileAndAddClasses(temp, CLASS);
+ return ImmutableList.of(new Object[]{"CF", cf}, new Object[]{"D8", d8});
+ }
+
+ public BreakOnIfTestRunner(String name, DelayedDebugTestConfig config) {
+ this.config = config.getConfig(temp);
+ }
+
+ @Test
+ public void test() throws Throwable {
+ runDebugTest(
+ config,
+ NAME,
+ breakpoint(NAME, "main", 9),
+ run(),
+ checkLine(FILE, 9),
+ stepOver(),
+ checkLine(FILE, 12),
+ run());
+ }
+}