mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-30 00:15:53 +08:00
GP-6709: De-lint GDB tests.
This commit is contained in:
+6
-2
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
package agent.gdb.rmi;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.*;
|
||||
@@ -329,7 +330,10 @@ public abstract class AbstractGdbTraceRmiTest extends AbstractGhidraHeadedDebugg
|
||||
* compiled from source on a rather un-modern distro.
|
||||
*/
|
||||
Msg.warn(this, "gdb hung on quit. Sending SIGCONT.");
|
||||
Runtime.getRuntime().exec("kill -SIGCONT %d".formatted(exec.gdb.pid()));
|
||||
String kill = DummyProc.which("kill");
|
||||
new ProcessBuilder(kill, "-SIGCONT", "%d".formatted(exec.gdb.pid()))
|
||||
.start()
|
||||
.waitFor();
|
||||
asyncQuit.get(QUIT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-6
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package agent.gdb.rmi;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assume.*;
|
||||
import static org.junit.Assume.assumeFalse;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.*;
|
||||
@@ -247,13 +248,11 @@ public class GdbCommandsTest extends AbstractGdbTraceRmiTest {
|
||||
quit
|
||||
""".formatted(PREAMBLE, target));
|
||||
String importSection = extractOutSection(out, "---Import---");
|
||||
assertTrue(importSection.contains(
|
||||
"""
|
||||
assertTrue(importSection.contains("""
|
||||
Selected Ghidra language: x86:LE:32:default
|
||||
Selected Ghidra compiler: %s""".formatted(PLAT.cSpec())));
|
||||
String fileSection = extractOutSection(out, "---File---");
|
||||
assertTrue(fileSection.contains(
|
||||
"""
|
||||
assertTrue(fileSection.contains("""
|
||||
Selected Ghidra language: %s
|
||||
Selected Ghidra compiler: %s""".formatted(PLAT.lang(), PLAT.cSpec())));
|
||||
assertEquals("""
|
||||
@@ -820,7 +819,6 @@ public class GdbCommandsTest extends AbstractGdbTraceRmiTest {
|
||||
|
||||
@Test
|
||||
public void testGetObj() throws Exception {
|
||||
String target = which("expPrint");
|
||||
String out = runThrowError(addr -> """
|
||||
%s
|
||||
ghidra trace connect %s
|
||||
|
||||
+7
-5
@@ -16,7 +16,7 @@
|
||||
package agent.gdb.rmi;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
@@ -31,8 +31,7 @@ import db.Transaction;
|
||||
import generic.jar.ResourceFile;
|
||||
import ghidra.app.plugin.core.debug.gui.action.BySectionAutoMapSpec;
|
||||
import ghidra.app.plugin.core.debug.gui.tracermi.launcher.AbstractTraceRmiLaunchOffer.EarlyTerminationException;
|
||||
import ghidra.app.util.importer.AutoImporter;
|
||||
import ghidra.app.util.importer.MessageLog;
|
||||
import ghidra.app.util.importer.*;
|
||||
import ghidra.debug.api.action.AutoMapSpec;
|
||||
import ghidra.debug.api.tracermi.TraceRmiLaunchOffer.LaunchResult;
|
||||
import ghidra.framework.Application;
|
||||
@@ -83,8 +82,11 @@ public class GdbConnectorsTest extends AbstractRmiConnectorsTest {
|
||||
@Test
|
||||
public void testGdbQemuUser() throws Exception {
|
||||
PathIsFile image = createArmElfImage();
|
||||
program = AutoImporter.importByUsingBestGuess(image.path().toFile(), null, "/", this,
|
||||
new MessageLog(), monitor).getPrimaryDomainObject();
|
||||
program = ProgramLoader.builder()
|
||||
.source(image.path().toFile())
|
||||
.monitor(monitor)
|
||||
.load()
|
||||
.getPrimaryDomainObject(this);
|
||||
programManager.openProgram(program);
|
||||
try (LaunchResult result = doLaunch("gdb + qemu", Map.ofEntries(
|
||||
Map.entry("arg:1", image),
|
||||
|
||||
+7
-2
@@ -15,8 +15,11 @@
|
||||
*/
|
||||
package agent.gdb.rmi;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
@@ -364,6 +367,8 @@ public class GdbHooksTest extends AbstractGdbTraceRmiTest {
|
||||
* <p>
|
||||
* Technically, this probably doesn't hit on_free_objfile, but all three just call
|
||||
* modules_changed, so I'm not concerned.
|
||||
*
|
||||
* @throws Exception because
|
||||
*/
|
||||
@Test
|
||||
public void testOnEventsObjfiles() throws Exception {
|
||||
|
||||
+3
-3
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package agent.gdb.rmi;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assume.*;
|
||||
import static org.junit.Assume.assumeFalse;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.*;
|
||||
@@ -52,13 +53,12 @@ import ghidra.trace.model.target.TraceObject;
|
||||
import ghidra.trace.model.target.TraceObjectValue;
|
||||
import ghidra.trace.model.target.path.PathFilter;
|
||||
import ghidra.trace.model.target.path.PathPattern;
|
||||
import ghidra.util.exception.TimeoutException;
|
||||
|
||||
@Category(NightlyCategory.class) // this may actually be an @PortSensitive test
|
||||
public class GdbMethodsTest extends AbstractGdbTraceRmiTest {
|
||||
|
||||
private final static long CAPTURE_PC_TIMEOUT_MILLIS = 3000;
|
||||
|
||||
|
||||
@Test
|
||||
public void testExecuteCapture() throws Exception {
|
||||
try (GdbAndConnection conn = startAndConnectGdb()) {
|
||||
|
||||
Reference in New Issue
Block a user