mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
Merge remote-tracking branch 'origin/GP-2677_Dan_disableTests'
This commit is contained in:
commit
7a476ecc23
8 changed files with 185 additions and 199 deletions
|
@ -78,7 +78,9 @@ ext.addExports([
|
|||
'java.desktop/sun.java2d=ALL-UNNAMED'
|
||||
])
|
||||
|
||||
integrationTest {
|
||||
// The CI system runs these tests as root and pip complains about using venv
|
||||
// Disable them for now
|
||||
/* integrationTest {
|
||||
dependsOn { project(':Debugger-agent-gdb').installPyPackage }
|
||||
dependsOn { project(':Debugger-agent-lldb').installPyPackage }
|
||||
}
|
||||
} */
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import db.Transaction;
|
||||
|
@ -50,6 +51,7 @@ import ghidra.trace.model.target.*;
|
|||
import ghidra.trace.model.time.TraceSnapshot;
|
||||
import ghidra.util.Msg;
|
||||
|
||||
@Ignore("Cannot install python packages in CI")
|
||||
public class GdbCommandsTest extends AbstractGdbTraceRmiTest {
|
||||
|
||||
//@Test
|
||||
|
|
|
@ -37,6 +37,7 @@ import ghidra.trace.model.memory.TraceMemorySpace;
|
|||
import ghidra.trace.model.target.TraceObject;
|
||||
import ghidra.trace.model.time.TraceSnapshot;
|
||||
|
||||
@Ignore("Cannot install python packages in CI")
|
||||
public class GdbHooksTest extends AbstractGdbTraceRmiTest {
|
||||
private static final long RUN_TIMEOUT_MS = 20000;
|
||||
private static final long RETRY_MS = 500;
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.*;
|
|||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import db.Transaction;
|
||||
|
@ -48,6 +49,7 @@ import ghidra.trace.model.modules.TraceModule;
|
|||
import ghidra.trace.model.target.TraceObject;
|
||||
import ghidra.trace.model.target.TraceObjectValue;
|
||||
|
||||
@Ignore("Cannot install python packages in CI")
|
||||
public class GdbMethodsTest extends AbstractGdbTraceRmiTest {
|
||||
|
||||
@Test
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package agent.lldb.rmi;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.*;
|
||||
|
@ -30,7 +30,6 @@ import java.util.stream.Collectors;
|
|||
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import ghidra.app.plugin.core.debug.gui.AbstractGhidraHeadedDebuggerGUITest;
|
||||
import ghidra.app.plugin.core.debug.service.rmi.trace.*;
|
||||
|
|
|
@ -15,32 +15,18 @@
|
|||
*/
|
||||
package agent.lldb.rmi;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import generic.Unique;
|
||||
|
@ -49,28 +35,19 @@ import ghidra.app.plugin.core.debug.service.rmi.trace.TraceRmiHandler;
|
|||
import ghidra.app.plugin.core.debug.utils.ManagedDomainObject;
|
||||
import ghidra.dbg.util.PathPredicates;
|
||||
import ghidra.framework.model.DomainFile;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressRange;
|
||||
import ghidra.program.model.address.AddressRangeImpl;
|
||||
import ghidra.program.model.address.AddressSpace;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.RegisterValue;
|
||||
import ghidra.program.model.listing.CodeUnit;
|
||||
import ghidra.trace.database.ToyDBTraceBuilder;
|
||||
import ghidra.trace.model.ImmutableTraceAddressSnapRange;
|
||||
import ghidra.trace.model.Lifespan;
|
||||
import ghidra.trace.model.Trace;
|
||||
import ghidra.trace.model.TraceAddressSnapRange;
|
||||
import ghidra.trace.model.*;
|
||||
import ghidra.trace.model.breakpoint.TraceBreakpointKind;
|
||||
import ghidra.trace.model.memory.TraceMemoryRegion;
|
||||
import ghidra.trace.model.memory.TraceMemorySpace;
|
||||
import ghidra.trace.model.memory.TraceMemoryState;
|
||||
import ghidra.trace.model.memory.*;
|
||||
import ghidra.trace.model.modules.TraceModule;
|
||||
import ghidra.trace.model.target.TraceObject;
|
||||
import ghidra.trace.model.target.TraceObjectKeyPath;
|
||||
import ghidra.trace.model.target.TraceObjectValue;
|
||||
import ghidra.trace.model.target.*;
|
||||
import ghidra.trace.model.time.TraceSnapshot;
|
||||
import ghidra.util.Msg;
|
||||
|
||||
@Ignore("Cannot install python packages in CI")
|
||||
public class LldbCommandsTest extends AbstractLldbTraceRmiTest {
|
||||
|
||||
//@Test
|
||||
|
@ -153,7 +130,8 @@ public class LldbCommandsTest extends AbstractLldbTraceRmiTest {
|
|||
|
||||
@Test
|
||||
public void testStartTraceCustomize() throws Exception {
|
||||
runThrowError(addr -> """
|
||||
runThrowError(
|
||||
addr -> """
|
||||
script import ghidralldb
|
||||
ghidra_trace_connect %s
|
||||
file bash
|
||||
|
@ -161,7 +139,8 @@ public class LldbCommandsTest extends AbstractLldbTraceRmiTest {
|
|||
script ghidralldb.util.set_convenience_varaible('ghidra-compiler','default')
|
||||
ghidra_trace_start myToy
|
||||
quit
|
||||
""".formatted(addr));
|
||||
"""
|
||||
.formatted(addr));
|
||||
DomainFile dfMyToy = env.getProject().getProjectData().getFile("/New Traces/myToy");
|
||||
assertNotNull(dfMyToy);
|
||||
try (ManagedDomainObject mdo = new ManagedDomainObject(dfMyToy, false, false, monitor)) {
|
||||
|
@ -239,7 +218,8 @@ public class LldbCommandsTest extends AbstractLldbTraceRmiTest {
|
|||
@Test
|
||||
public void testLcsp() throws Exception {
|
||||
// TODO: This test assumes x86-64 on test system
|
||||
String out = runThrowError("""
|
||||
String out = runThrowError(
|
||||
"""
|
||||
script import ghidralldb
|
||||
_mark_ ---Import---
|
||||
ghidra_trace_info_lcsp
|
||||
|
@ -420,7 +400,7 @@ public class LldbCommandsTest extends AbstractLldbTraceRmiTest {
|
|||
String eval = extractOutSection(out, "---Start---");
|
||||
String addrstr = eval.split("=")[1].trim();
|
||||
if (addrstr.contains(" ")) {
|
||||
addrstr= addrstr.substring(0, addrstr.indexOf(" "));
|
||||
addrstr = addrstr.substring(0, addrstr.indexOf(" "));
|
||||
}
|
||||
Address addr = tb.addr(Long.decode(addrstr));
|
||||
|
||||
|
@ -903,7 +883,8 @@ public class LldbCommandsTest extends AbstractLldbTraceRmiTest {
|
|||
""".formatted(addr));
|
||||
try (ManagedDomainObject mdo = openDomainObject("/New Traces/lldb/bash")) {
|
||||
tb = new ToyDBTraceBuilder((Trace) mdo.get());
|
||||
assertEquals("""
|
||||
assertEquals(
|
||||
"""
|
||||
Parent Key Span Value Type
|
||||
Test.Objects[1] vbool [0,+inf) True BOOL
|
||||
Test.Objects[1] vboolarr [0,+inf) [True, False] BOOL_ARR
|
||||
|
@ -919,7 +900,9 @@ public class LldbCommandsTest extends AbstractLldbTraceRmiTest {
|
|||
Test.Objects[1] vshort [0,+inf) 2 SHORT
|
||||
Test.Objects[1] vshortarr [0,+inf) [1, 2, 3] SHORT_ARR
|
||||
Test.Objects[1] vstring [0,+inf) '"Hello"' STRING
|
||||
Test.Objects[1] vaddr [0,+inf) ram:deadbeef ADDRESS""".replaceAll(" ", "").replaceAll("\n", ""),
|
||||
Test.Objects[1] vaddr [0,+inf) ram:deadbeef ADDRESS"""
|
||||
.replaceAll(" ", "")
|
||||
.replaceAll("\n", ""),
|
||||
extractOutSection(out, "---GetValues---").replaceAll(" ", "").replaceAll("\n", ""));
|
||||
}
|
||||
}
|
||||
|
@ -1157,7 +1140,8 @@ public class LldbCommandsTest extends AbstractLldbTraceRmiTest {
|
|||
try (ManagedDomainObject mdo = openDomainObject("/New Traces/lldb/bash")) {
|
||||
tb = new ToyDBTraceBuilder((Trace) mdo.get());
|
||||
// Assumes LLDB on Linux amd64
|
||||
TraceObject env = Objects.requireNonNull(tb.objAny("Processes[].Environment", Lifespan.at(0)));
|
||||
TraceObject env =
|
||||
Objects.requireNonNull(tb.objAny("Processes[].Environment", Lifespan.at(0)));
|
||||
assertEquals("lldb", env.getValue(0, "_debugger").getValue());
|
||||
assertEquals("x86_64", env.getValue(0, "_arch").getValue());
|
||||
assertEquals("linux", env.getValue(0, "_os").getValue());
|
||||
|
|
|
@ -17,10 +17,7 @@ package agent.lldb.rmi;
|
|||
|
||||
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 static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
|
@ -41,6 +38,7 @@ import ghidra.trace.model.memory.TraceMemorySpace;
|
|||
import ghidra.trace.model.target.TraceObject;
|
||||
import ghidra.trace.model.time.TraceSnapshot;
|
||||
|
||||
@Ignore("Cannot install python packages in CI")
|
||||
public class LldbHooksTest extends AbstractLldbTraceRmiTest {
|
||||
private static final long RUN_TIMEOUT_MS = 20000;
|
||||
private static final long RETRY_MS = 500;
|
||||
|
@ -66,7 +64,8 @@ public class LldbHooksTest extends AbstractLldbTraceRmiTest {
|
|||
LldbAndHandler conn = startAndConnectLldb();
|
||||
try {
|
||||
// TODO: Why does using 'set arch' cause a hang at quit?
|
||||
conn.execute("ghidralldb.util.set_convenience_variable('ghidra-language', 'x86:LE:64:default')");
|
||||
conn.execute(
|
||||
"ghidralldb.util.set_convenience_variable('ghidra-language', 'x86:LE:64:default')");
|
||||
conn.execute("ghidra_trace_start");
|
||||
ManagedDomainObject mdo = waitDomainObject("/New Traces/lldb/noname");
|
||||
tb = new ToyDBTraceBuilder((Trace) mdo.get());
|
||||
|
@ -389,20 +388,21 @@ public class LldbHooksTest extends AbstractLldbTraceRmiTest {
|
|||
conn.execute("stepi");
|
||||
|
||||
waitForPass(
|
||||
() -> assertEquals(0, tb.objValues(lastSnap(conn), "Processes[].Breakpoints[]").size()));
|
||||
() -> assertEquals(0,
|
||||
tb.objValues(lastSnap(conn), "Processes[].Breakpoints[]").size()));
|
||||
}
|
||||
}
|
||||
|
||||
private void start(LldbAndTrace conn, String obj) {
|
||||
conn.execute("file "+obj);
|
||||
conn.execute("file " + obj);
|
||||
conn.execute("ghidra_trace_sync_enable");
|
||||
conn.execute("process launch --stop-at-entry");
|
||||
txPut(conn, "processes");
|
||||
}
|
||||
|
||||
private void txPut(LldbAndTrace conn, String obj) {
|
||||
conn.execute("ghidra_trace_txstart 'Tx"+obj+"'");
|
||||
conn.execute("ghidra_trace_put_"+obj);
|
||||
conn.execute("ghidra_trace_txstart 'Tx" + obj + "'");
|
||||
conn.execute("ghidra_trace_put_" + obj);
|
||||
conn.execute("ghidra_trace_txcommit");
|
||||
}
|
||||
|
||||
|
|
|
@ -17,17 +17,11 @@ package agent.lldb.rmi;
|
|||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import generic.Unique;
|
||||
|
@ -37,9 +31,7 @@ import ghidra.app.plugin.core.debug.utils.ManagedDomainObject;
|
|||
import ghidra.dbg.testutil.DummyProc;
|
||||
import ghidra.dbg.util.PathPattern;
|
||||
import ghidra.dbg.util.PathPredicates;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.address.AddressRange;
|
||||
import ghidra.program.model.address.AddressSpace;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.lang.RegisterValue;
|
||||
import ghidra.trace.database.ToyDBTraceBuilder;
|
||||
import ghidra.trace.model.Lifespan;
|
||||
|
@ -51,6 +43,7 @@ import ghidra.trace.model.modules.TraceModule;
|
|||
import ghidra.trace.model.target.TraceObject;
|
||||
import ghidra.trace.model.target.TraceObjectValue;
|
||||
|
||||
@Ignore("Cannot install python packages in CI")
|
||||
public class LldbMethodsTest extends AbstractLldbTraceRmiTest {
|
||||
|
||||
@Test
|
||||
|
@ -59,7 +52,8 @@ public class LldbMethodsTest extends AbstractLldbTraceRmiTest {
|
|||
RemoteMethod execute = conn.getMethod("execute");
|
||||
assertEquals(false,
|
||||
execute.parameters().get("to_string").defaultValue().get(ValueDecoder.DEFAULT));
|
||||
assertEquals("test\n", execute.invoke(Map.of("cmd", "script print('test')", "to_string", true)));
|
||||
assertEquals("test\n",
|
||||
execute.invoke(Map.of("cmd", "script print('test')", "to_string", true)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,7 +141,8 @@ public class LldbMethodsTest extends AbstractLldbTraceRmiTest {
|
|||
tb = new ToyDBTraceBuilder((Trace) mdo.get());
|
||||
waitStopped();
|
||||
|
||||
TraceObject locations = Objects.requireNonNull(tb.objAny("Processes[].Breakpoints"));
|
||||
TraceObject locations =
|
||||
Objects.requireNonNull(tb.objAny("Processes[].Breakpoints"));
|
||||
conn.execute("breakpoint set --name main");
|
||||
conn.execute("breakpoint set -H --name main");
|
||||
refreshProcBreakpoints.invoke(Map.of("node", locations));
|
||||
|
@ -183,7 +178,8 @@ public class LldbMethodsTest extends AbstractLldbTraceRmiTest {
|
|||
tb = new ToyDBTraceBuilder((Trace) mdo.get());
|
||||
waitStopped();
|
||||
|
||||
TraceObject locations = Objects.requireNonNull(tb.objAny("Processes[].Watchpoints"));
|
||||
TraceObject locations =
|
||||
Objects.requireNonNull(tb.objAny("Processes[].Watchpoints"));
|
||||
conn.execute("watchpoint set expression -- `(void(*)())main`");
|
||||
conn.execute("watchpoint set expression -w read -- `(void(*)())main`+-0x20");
|
||||
conn.execute("watchpoint set expression -w read_write -- `(void(*)())main`+0x30");
|
||||
|
@ -212,7 +208,7 @@ public class LldbMethodsTest extends AbstractLldbTraceRmiTest {
|
|||
Set.of(TraceBreakpointKind.READ),
|
||||
"main+0x20");
|
||||
assertWatchLoc(procWatchLocVals.get(2), "[3]", main2, (int) rangeMain1.getLength(),
|
||||
Set.of(TraceBreakpointKind.READ,TraceBreakpointKind.WRITE),
|
||||
Set.of(TraceBreakpointKind.READ, TraceBreakpointKind.WRITE),
|
||||
"main+0x30");
|
||||
}
|
||||
}
|
||||
|
@ -388,13 +384,12 @@ public class LldbMethodsTest extends AbstractLldbTraceRmiTest {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testActivateThread() throws Exception {
|
||||
try (LldbAndHandler conn = startAndConnectLldb()) {
|
||||
// TODO: need to find this file (same issue in LldbHookTests
|
||||
String dproc = DummyProc.which("expCloneExit");
|
||||
conn.execute("file "+dproc);
|
||||
conn.execute("file " + dproc);
|
||||
conn.execute("ghidra_trace_start");
|
||||
txPut(conn, "processes");
|
||||
breakAt(conn, "work");
|
||||
|
@ -487,7 +482,8 @@ public class LldbMethodsTest extends AbstractLldbTraceRmiTest {
|
|||
RemoteMethod attachObj = conn.getMethod("attach_obj");
|
||||
try (ManagedDomainObject mdo = openDomainObject("/New Traces/lldb/noname")) {
|
||||
tb = new ToyDBTraceBuilder((Trace) mdo.get());
|
||||
TraceObject proc = Objects.requireNonNull(tb.objAny("Processes[]", Lifespan.at(0)));
|
||||
TraceObject proc =
|
||||
Objects.requireNonNull(tb.objAny("Processes[]", Lifespan.at(0)));
|
||||
TraceObject target =
|
||||
Objects.requireNonNull(tb.obj("Available[%d]".formatted(dproc.pid)));
|
||||
attachObj.invoke(Map.of("process", proc, "target", target));
|
||||
|
@ -510,7 +506,8 @@ public class LldbMethodsTest extends AbstractLldbTraceRmiTest {
|
|||
RemoteMethod attachPid = conn.getMethod("attach_pid");
|
||||
try (ManagedDomainObject mdo = openDomainObject("/New Traces/lldb/noname")) {
|
||||
tb = new ToyDBTraceBuilder((Trace) mdo.get());
|
||||
TraceObject proc = Objects.requireNonNull(tb.objAny("Processes[]", Lifespan.at(0)));
|
||||
TraceObject proc =
|
||||
Objects.requireNonNull(tb.objAny("Processes[]", Lifespan.at(0)));
|
||||
attachPid.invoke(Map.of("process", proc, "pid", dproc.pid));
|
||||
|
||||
String out = conn.executeCapture("target list");
|
||||
|
@ -730,7 +727,7 @@ public class LldbMethodsTest extends AbstractLldbTraceRmiTest {
|
|||
step_out.invoke(Map.of("thread", thread));
|
||||
|
||||
int finalDepth = getDepth(conn);
|
||||
assertEquals(initDepth-1, finalDepth);
|
||||
assertEquals(initDepth - 1, finalDepth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -758,7 +755,7 @@ public class LldbMethodsTest extends AbstractLldbTraceRmiTest {
|
|||
ret.invoke(Map.of("thread", thread));
|
||||
|
||||
int finalDepth = getDepth(conn);
|
||||
assertEquals(initDepth-1, finalDepth);
|
||||
assertEquals(initDepth - 1, finalDepth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1030,7 +1027,6 @@ public class LldbMethodsTest extends AbstractLldbTraceRmiTest {
|
|||
txPut(conn, "processes");
|
||||
breakAt(conn, "main");
|
||||
|
||||
|
||||
RemoteMethod toggleBreakpointLocation = conn.getMethod("toggle_breakpoint_location");
|
||||
try (ManagedDomainObject mdo = openDomainObject("/New Traces/lldb/bash")) {
|
||||
tb = new ToyDBTraceBuilder((Trace) mdo.get());
|
||||
|
@ -1102,14 +1098,14 @@ public class LldbMethodsTest extends AbstractLldbTraceRmiTest {
|
|||
}
|
||||
|
||||
private void start(LldbAndHandler conn, String obj) {
|
||||
conn.execute("file "+obj);
|
||||
conn.execute("file " + obj);
|
||||
conn.execute("ghidra_trace_start");
|
||||
conn.execute("process launch --stop-at-entry");
|
||||
}
|
||||
|
||||
private void txPut(LldbAndHandler conn, String obj) {
|
||||
conn.execute("ghidra_trace_txstart 'Tx'");
|
||||
conn.execute("ghidra_trace_put_"+obj);
|
||||
conn.execute("ghidra_trace_put_" + obj);
|
||||
conn.execute("ghidra_trace_txcommit");
|
||||
}
|
||||
|
||||
|
@ -1121,7 +1117,7 @@ public class LldbMethodsTest extends AbstractLldbTraceRmiTest {
|
|||
|
||||
private void breakAt(LldbAndHandler conn, String fn) {
|
||||
conn.execute("ghidra_trace_sync_enable");
|
||||
conn.execute("breakpoint set -n "+fn);
|
||||
conn.execute("breakpoint set -n " + fn);
|
||||
conn.execute("run");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue