mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
stop test from hanging during blocking method call.
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
package ghidra.pty.windows;
|
package ghidra.pty.windows;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.junit.Assume.assumeTrue;
|
import static org.junit.Assume.assumeTrue;
|
||||||
|
|
||||||
@@ -69,16 +70,28 @@ public class ConPtyTest extends AbstractPtyTest {
|
|||||||
|
|
||||||
writer.println("echo test");
|
writer.println("echo test");
|
||||||
writer.flush();
|
writer.flush();
|
||||||
String line;
|
// set up reading cmd output on a thread since "readLine" is blocking
|
||||||
do {
|
Thread t = new Thread(() -> {
|
||||||
line = reader.readLine();
|
String line;
|
||||||
}
|
try {
|
||||||
while (!"test".equals(line));
|
do {
|
||||||
|
line = reader.readLine();
|
||||||
|
}
|
||||||
|
while (!"test".equals(line));
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
t.setDaemon(true);
|
||||||
|
t.start();
|
||||||
|
|
||||||
writer.println("exit 3");
|
writer.println("exit 3");
|
||||||
writer.flush();
|
writer.flush();
|
||||||
|
|
||||||
assertEquals(3, cmd.waitExited());
|
assertEquals(3, cmd.waitExited());
|
||||||
|
assertFalse("Content read successfully from the cmd", t.isAlive());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user