From 59986581557ae2234af12c96fee6eadba01adbb3 Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Thu, 26 Mar 2015 01:14:38 -0500 Subject: [PATCH] wait up to 5 seconds for shell output before checking the result. otherwise, we can jumpt the gun and fail the test randomly --- .../src/test/java/javapayload/stage/ShellTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/java/javapayload/src/test/java/javapayload/stage/ShellTest.java b/java/javapayload/src/test/java/javapayload/stage/ShellTest.java index 4b9c81c7..940a215f 100644 --- a/java/javapayload/src/test/java/javapayload/stage/ShellTest.java +++ b/java/javapayload/src/test/java/javapayload/stage/ShellTest.java @@ -15,6 +15,11 @@ public class ShellTest extends TestCase { DataInputStream in = new DataInputStream(new ByteArrayInputStream(commands.getBytes("ISO-8859-1"))); ByteArrayOutputStream out = new ByteArrayOutputStream(); shell.start(in, out, new String[] {"Payload", "--", "Shell"}); + int timeout = 5000; + while (out.size() == 0 && timeout > 0) { + Thread.sleep(100); + timeout -= 100; + } String shellOutput = new String(out.toByteArray(), "ISO-8859-1"); Assert.assertTrue("MagicToken missing in shell output: "+shellOutput, shellOutput.contains("MagicToken")); Assert.assertEquals(-1, in.read());