Search in sources :

Example 1 with CSearchWaiter

use of com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Implementations.CSearchWaiter in project binnavi by google.

the class CSearchWaiterTest method testSuccess.

@Test
public void testSuccess() throws Exception {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.connect();
    final CSearchWaiter waiter = new CSearchWaiter(debugger, new CAddress(0x300), 0x100, new byte[] { 10 });
    waiter.start();
    new Thread() {

        @Override
        public void run() {
            try {
                waiter.runExpensiveCommand();
            } catch (final Exception e) {
            }
        }
    }.start();
    Thread.sleep(250);
    debugger.connection.m_synchronizer.receivedEvent(new SearchReply(0, 0, new CAddress(0x300)));
    Thread.sleep(250);
    assertFalse(waiter.isAlive());
    assertNotNull(waiter.getReply());
    assertTrue(waiter.getReply().success());
    debugger.close();
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) SearchReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.SearchReply) CSearchWaiter(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Implementations.CSearchWaiter) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 2 with CSearchWaiter

use of com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Implementations.CSearchWaiter in project binnavi by google.

the class CSearchWaiterTest method testDetach.

@Test
public void testDetach() throws Exception {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.connect();
    final CSearchWaiter waiter = new CSearchWaiter(debugger, new CAddress(0x300), 0x100, new byte[] { 10 });
    waiter.start();
    new Thread() {

        @Override
        public void run() {
            try {
                waiter.runExpensiveCommand();
            } catch (final Exception e) {
            }
        }
    }.start();
    Thread.sleep(250);
    debugger.connection.m_synchronizer.receivedEvent(new DetachReply(0, 0));
    Thread.sleep(250);
    assertFalse(waiter.isAlive());
    assertNull(waiter.getReply());
    debugger.close();
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) DetachReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.DetachReply) CSearchWaiter(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Implementations.CSearchWaiter) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 3 with CSearchWaiter

use of com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Implementations.CSearchWaiter in project binnavi by google.

the class CSearchWaiterTest method testCloseRequested.

@Test
public void testCloseRequested() throws Exception {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.connect();
    final CSearchWaiter waiter = new CSearchWaiter(debugger, new CAddress(0x300), 0x100, new byte[] { 10 });
    waiter.start();
    new Thread() {

        @Override
        public void run() {
            try {
                waiter.runExpensiveCommand();
            } catch (final Exception e) {
            }
        }
    }.start();
    Thread.sleep(250);
    waiter.closeRequested();
    Thread.sleep(250);
    debugger.close();
    assertFalse(waiter.isAlive());
    assertNull(waiter.getReply());
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CSearchWaiter(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Implementations.CSearchWaiter) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 4 with CSearchWaiter

use of com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Implementations.CSearchWaiter in project binnavi by google.

the class CSearchWaiterTest method testFailure.

@Test
public void testFailure() throws Exception {
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
    debugger.connect();
    final CSearchWaiter waiter = new CSearchWaiter(debugger, new CAddress(0x300), 0x100, new byte[] { 10 });
    waiter.start();
    new Thread() {

        @Override
        public void run() {
            try {
                waiter.runExpensiveCommand();
            } catch (final Exception e) {
            }
        }
    }.start();
    Thread.sleep(250);
    debugger.connection.m_synchronizer.receivedEvent(new SearchReply(0, 3, null));
    Thread.sleep(250);
    assertFalse(waiter.isAlive());
    assertNotNull(waiter.getReply());
    assertFalse(waiter.getReply().success());
    debugger.close();
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) SearchReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.SearchReply) CSearchWaiter(com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Implementations.CSearchWaiter) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Aggregations

MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)4 CSearchWaiter (com.google.security.zynamics.binnavi.Gui.Debug.MemoryPanel.Implementations.CSearchWaiter)4 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)4 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)4 Test (org.junit.Test)4 SearchReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.SearchReply)2 DetachReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.DetachReply)1