Ghidra is a software reverse engineering (SRE) framework
GP-0: second pass at cleaning up Frida tests
d-millardf1c6f307efb
diff --git a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/invm/InVmFridaModelHost.java b/Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/invm/InVmFridaModelHost.javasimilarity index 100%rename from Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/invm/InVmFridaModelHost.javarename to Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/invm/InVmFridaModelHost.javadiff --git a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/invm/InVmModelForFridaFactoryTest.java b/Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/invm/InVmModelForFridaFactoryTest.javasimilarity index 100%rename from Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/invm/InVmModelForFridaFactoryTest.javarename to Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/invm/InVmModelForFridaFactoryTest.javadiff --git a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/invm/InVmModelForFridaInterpreterTest.java b/Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/invm/InVmModelForFridaInterpreterTest.javasimilarity index 100%rename from Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/invm/InVmModelForFridaInterpreterTest.javarename to Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/invm/InVmModelForFridaInterpreterTest.javadiff --git a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/invm/InVmModelForFridaMethodsTest.java b/Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/invm/InVmModelForFridaMethodsTest.javasimilarity index 100%rename from Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/invm/InVmModelForFridaMethodsTest.javarename to Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/invm/InVmModelForFridaMethodsTest.javadiff --git a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/invm/InVmModelForFridaRootAttacherTest.java b/Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/invm/InVmModelForFridaRootAttacherTest.javasimilarity index 100%rename from Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/invm/InVmModelForFridaRootAttacherTest.javarename to Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/invm/InVmModelForFridaRootAttacherTest.javadiff --git a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/invm/InVmModelForFridaRootLauncherTest.java b/Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/invm/InVmModelForFridaRootLauncherTest.javasimilarity index 100%rename from Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/invm/InVmModelForFridaRootLauncherTest.javarename to Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/invm/InVmModelForFridaRootLauncherTest.javadiff --git a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/invm/InVmModelForFridaScenarioStackTest.java b/Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/invm/InVmModelForFridaScenarioStackTest.javasimilarity index 100%rename from Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/invm/InVmModelForFridaScenarioStackTest.javarename to Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/invm/InVmModelForFridaScenarioStackTest.javadiff --git a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/invm/InVmModelForFridaX64RegistersTest.java b/Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/invm/InVmModelForFridaX64RegistersTest.javasimilarity index 100%rename from Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/invm/InVmModelForFridaX64RegistersTest.javarename to Ghidra/Debug/Debugger-agent-frida/src/main/java/agent/frida/model/invm/InVmModelForFridaX64RegistersTest.javadiff --git a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaActivationTest.java b/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaActivationTest.javaindex 58580cc0f8..ea472fbefd 100644--- a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaActivationTest.java+++ b/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaActivationTest.java@@ -43,17 +43,19 @@ import ghidra.dbg.util.PathPattern;* result in the containing thread or frame becoming active instead. Or, activating a thread may* result in its innermost frame becoming active as well.*/-public abstract class AbstractModelForFridaActivationTest extends AbstractDebuggerModelActivationTest {+public abstract class AbstractModelForFridaActivationTest+ extends AbstractDebuggerModelActivationTest {@Override@Ignore@Testpublic void testDefaultFocusIsAsExpected() throws Throwable {+ // Disabled as of 220609List<String> expectedDefaultFocus = getExpectedDefaultActivePath();assumeNotNull(expectedDefaultFocus);m.build();- PathPattern pathPattern = new PathPattern(expectedDefaultFocus);+ PathPattern pathPattern = new PathPattern(expectedDefaultFocus);Set<TargetObject> activatable = getActivatableThings();// The default must be one of the activatable objectsTargetObject obj = Unique.assertOne(activatable.stream()@@ -69,6 +71,7 @@ public abstract class AbstractModelForFridaActivationTest extends AbstractDebugg@Ignore@Testpublic void testActivateEachOnce() throws Throwable {+ // Disabled as of 220609m.build();TargetActiveScope activeScope = findActiveScope();@@ -87,6 +90,7 @@ public abstract class AbstractModelForFridaActivationTest extends AbstractDebugg@Ignore@Testpublic void testActivateEachTwice() throws Throwable {+ // Disabled as of 220609m.build();TargetActiveScope activeScope = findActiveScope();@@ -109,6 +113,7 @@ public abstract class AbstractModelForFridaActivationTest extends AbstractDebugg@Ignore@Testpublic void testActivateEachViaInterpreter() throws Throwable {+ // Disabled as of 220609assumeTrue(m.hasInterpreter());m.build();diff --git a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaFactoryTest.java b/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaFactoryTest.javaindex 4ac0c52009..8ebd64ea87 100644--- a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaFactoryTest.java+++ b/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaFactoryTest.java@@ -17,6 +17,9 @@ package agent.frida.model;import java.util.Map;+import org.junit.Ignore;+import org.junit.Test;+import ghidra.dbg.test.AbstractDebuggerModelFactoryTest;public abstract class AbstractModelForFridaFactoryTest extends AbstractDebuggerModelFactoryTest {@@ -24,4 +27,47 @@ public abstract class AbstractModelForFridaFactoryTest extends AbstractDebuggerMprotected Map<String, Object> getFailingFactoryOptions() {return Map.ofEntries();}++ @Override+ @Ignore+ @Test+ public void testBuildAndClose() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testBuildFailingOptionsErr() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testPing() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testWaitRootAccess() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testHasNonEnumerableRootSchema() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testNonExistentPathGivesNull() throws Throwable {+ // Disabled as of 220609+ }+}diff --git a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaInterpreterTest.java b/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaInterpreterTest.javaindex ae3b286bff..bad76c2ab2 100644--- a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaInterpreterTest.java+++ b/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaInterpreterTest.java@@ -17,6 +17,9 @@ package agent.frida.model;import java.util.List;+import org.junit.Ignore;+import org.junit.Test;+import ghidra.dbg.target.TargetProcess;import ghidra.dbg.test.*;import ghidra.dbg.util.PathUtils;@@ -81,4 +84,18 @@ public abstract class AbstractModelForFridaInterpreterTestreturn FridaLinuxSpecimen.PRINT;}+ @Override+ @Ignore+ @Test+ public void testExecute() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testExecuteCapture() throws Throwable {+ // Disabled as of 220609+ }+}diff --git a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaMethodsTest.java b/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaMethodsTest.javaindex 798367f849..b46371c964 100644--- a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaMethodsTest.java+++ b/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaMethodsTest.java@@ -97,6 +97,7 @@ public abstract class AbstractModelForFridaMethodsTest extends AbstractDebuggerMList.of(AssertionError.class));}+ @Overrideprotected void runTestKill(DebuggerTestSpecimen specimen) throws Throwable {TargetProcess process = retryForProcessRunning(specimen, this);TargetKillable killable = m.suitable(TargetKillable.class, process.getPath());@@ -110,8 +111,10 @@ public abstract class AbstractModelForFridaMethodsTest extends AbstractDebuggerMrunTestResumeTerminates(specimen);}+ @Ignore@Testpublic void testLaunchResumeKill() throws Throwable {+ // Disabled as of 220609assumeTrue(m.hasKillableProcesses());m.build();@@ -126,6 +129,7 @@ public abstract class AbstractModelForFridaMethodsTest extends AbstractDebuggerM@Ignore@Testpublic void testScan() throws Throwable {+ // Disabled as of 220609assumeTrue(m.hasKillableProcesses());m.build();@@ -192,8 +196,10 @@ public abstract class AbstractModelForFridaMethodsTest extends AbstractDebuggerMrunTestKill(specimen);}+ @Ignore@Testpublic void testInterceptor() throws Throwable {+ // Disabled as of 220609assumeTrue(m.hasKillableProcesses());m.build();@@ -222,8 +228,10 @@ public abstract class AbstractModelForFridaMethodsTest extends AbstractDebuggerMrunTestKill(specimen);}+ @Ignore@Testpublic void testStalker() throws Throwable {+ // Disabled as of 220609assumeTrue(m.hasKillableProcesses());m.build();diff --git a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaRootAttacherTest.java b/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaRootAttacherTest.javaindex c2c48af353..253c4d260c 100644--- a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaRootAttacherTest.java+++ b/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaRootAttacherTest.java@@ -15,22 +15,18 @@*/package agent.frida.model;-import static org.junit.Assert.assertFalse;-import static org.junit.Assert.assertTrue;+import static org.junit.Assert.*;import java.util.List;import java.util.concurrent.TimeUnit;-import org.junit.After;-import org.junit.Ignore;-import org.junit.Test;+import org.junit.*;import agent.frida.model.iface1.FridaModelTargetKillable;import ghidra.dbg.DebugModelConventions;-import ghidra.dbg.target.TargetEnvironment;-import ghidra.dbg.target.TargetKillable;+import ghidra.dbg.error.DebuggerIllegalArgumentException;+import ghidra.dbg.target.*;import ghidra.dbg.target.TargetMethod.TargetParameterMap;-import ghidra.dbg.target.TargetProcess;import ghidra.dbg.test.AbstractDebuggerModelAttacherTest;import ghidra.dbg.util.PathUtils;import ghidra.util.Msg;@@ -68,6 +64,7 @@ public abstract class AbstractModelForFridaRootAttacherTest@Ignore@Afterpublic void tearDownDebuggerModelTest() throws Throwable {+ // Disabled as of 220609/*** NB. Model has to be closed before dummy. If dummy is suspended by a debugger, terminating* it, even forcibly, may fail.@@ -84,16 +81,18 @@ public abstract class AbstractModelForFridaRootAttacherTest}}+ @Override@Ignore@Testpublic void testAttachByPidThenResumeInterrupt() throws Throwable {}+ @Override@Ignore@Testpublic void testAttachByPidThenKill() throws Throwable {}-+@Overrideprotected void runTestKill(DebuggerTestSpecimen specimen)throws Throwable {@@ -105,4 +104,61 @@ public abstract class AbstractModelForFridaRootAttacherTestretryVoid(() -> assertFalse(DebugModelConventions.isProcessAlive(process)),List.of(AssertionError.class));}++ @Override+ @Ignore+ @Test+ public void testAttacherIsWhereExpected() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testAttachableContainerIsWhereExpected() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testListAttachable() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testAttachByPid() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testAttachByObj() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test(expected = DebuggerIllegalArgumentException.class)+ public void testAttachByObjBogusThrowsException() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testAttachByPidThenDetach() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testAttachShowsInProcessContainer() throws Throwable {+ // Disabled as of 220609+ }+}diff --git a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaRootLauncherTest.java b/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaRootLauncherTest.javaindex 207066aa65..e24606daa6 100644--- a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaRootLauncherTest.java+++ b/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaRootLauncherTest.java@@ -15,21 +15,19 @@*/package agent.frida.model;-import static org.junit.Assert.assertEquals;-import static org.junit.Assert.assertTrue;+import static org.junit.Assert.*;import java.util.List;import java.util.Map;+import org.junit.Ignore;+import org.junit.Test;+import ghidra.dbg.DebugModelConventions.AsyncState;-import ghidra.dbg.target.TargetDetachable;-import ghidra.dbg.target.TargetEnvironment;-import ghidra.dbg.target.TargetExecutionStateful;+import ghidra.dbg.target.*;import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;import ghidra.dbg.target.TargetMethod.ParameterDescription;import ghidra.dbg.target.TargetMethod.TargetParameterMap;-import ghidra.dbg.target.TargetProcess;-import ghidra.dbg.target.TargetResumable;import ghidra.dbg.test.AbstractDebuggerModelLauncherTest;import ghidra.dbg.util.PathUtils;@@ -60,6 +58,7 @@ public abstract class AbstractModelForFridaRootLauncherTestassertTrue(environment.getDebugger().toLowerCase().contains("frida"));}+ @Overrideprotected void runTestDetach(DebuggerTestSpecimen specimen)throws Throwable {TargetProcess process = retryForProcessRunning(specimen, this);@@ -67,7 +66,8 @@ public abstract class AbstractModelForFridaRootLauncherTestwaitAcc(detachable);waitOn(detachable.detach());}-++ @Overrideprotected void runTestResumeTerminates(DebuggerTestSpecimen specimen) throws Throwable {TargetProcess process = retryForProcessRunning(specimen, this);TargetResumable resumable = m.suitable(TargetResumable.class, process.getPath());@@ -78,4 +78,53 @@ public abstract class AbstractModelForFridaRootLauncherTestwaitOn(resumable.resume());}+ @Override+ @Ignore+ @Test+ public void testLauncherIsWhereExpected() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testLaunchParameters() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testLaunch() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testLaunchThenDetach() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testLaunchThenKill() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testLaunchThenResume() throws Throwable {+ // Disabled as of 220609+ }++ @Override+ @Ignore+ @Test+ public void testLaunchShowsInProcessContainer() throws Throwable {+ // Disabled as of 220609+ }+}diff --git a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaX64RegistersTest.java b/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaX64RegistersTest.javaindex d65418f0c9..0cf7af739e 100644--- a/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaX64RegistersTest.java+++ b/Ghidra/Debug/Debugger-agent-frida/src/test/java/agent/frida/model/AbstractModelForFridaX64RegistersTest.java@@ -61,22 +61,23 @@ public abstract class AbstractModelForFridaX64RegistersTestpublic DebuggerTestSpecimen getLaunchSpecimen() {return FridaLinuxSpecimen.SPIN_STRIPPED;}-+@Overrideprotected TargetObject maybeSubstituteThread(TargetObject target) throws Throwable {FridaModelTargetProcess fproc = (FridaModelTargetProcess) target;waitOn(fproc.resume());- FridaModelTargetThreadContainerImpl threads = (FridaModelTargetThreadContainerImpl) fproc.getCachedAttribute("Threads");+ FridaModelTargetThreadContainerImpl threads =+ (FridaModelTargetThreadContainerImpl) fproc.getCachedAttribute("Threads");waitOn(threads.fetchElements());TargetThread thread = findAnyThread(target.getPath());return thread == null ? target : thread;}-@Override@Ignore@Testpublic void testRegistersHaveExpectedSizes() throws Throwable {+ // Disabled as of 220609m.build();TargetObject target = maybeSubstituteThread(obtainTarget());@@ -98,6 +99,7 @@ public abstract class AbstractModelForFridaX64RegistersTest@Ignore@Testpublic void testRegisterBankIsWhereExpected() throws Throwable {+ // Disabled as of 220609m.build();TargetObject target = maybeSubstituteThread(obtainTarget());@@ -116,6 +118,7 @@ public abstract class AbstractModelForFridaX64RegistersTest@Ignore@Testpublic void testReadRegisters() throws Throwable {+ // Disabled as of 220609m.build();TargetObject target = maybeSubstituteThread(obtainTarget());@@ -172,5 +175,5 @@ public abstract class AbstractModelForFridaX64RegistersTestassertEquals("Not all registers were read, or extras were read", write.keySet(),read.keySet());}-+}