Bug 566336 - [Test] testAppendOutputToFile fails

Avoid a theoretical race condition where a fast terminating process get
not all content to console.

Includes a of-by-one error fix in MockProcess termination calculation.
Before a MockProcess with 0ms runtime was reported as not terminated for
up to 1ms. This can be relevant for the initial termination check in
RuntimeProcess.

This change might also fix random failures for other tests using the
doConsoleOutputTest method.

Change-Id: I76cad5317607b1889513827c8191edefa7637491
Signed-off-by: Paul Pazderski <paul-eclipse@ppazderski.de>
diff --git a/org.eclipse.debug.tests/META-INF/MANIFEST.MF b/org.eclipse.debug.tests/META-INF/MANIFEST.MF
index 2f725b1..3696af5 100644
--- a/org.eclipse.debug.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.debug.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.debug.tests;singleton:=true
-Bundle-Version: 3.11.800.qualifier
+Bundle-Version: 3.11.900.qualifier
 Bundle-Activator: org.eclipse.debug.tests.TestsPlugin
 Bundle-Localization: plugin
 Require-Bundle: org.eclipse.ui;bundle-version="[3.6.0,4.0.0)",
diff --git a/org.eclipse.debug.tests/pom.xml b/org.eclipse.debug.tests/pom.xml
index 7303672..3051467 100644
--- a/org.eclipse.debug.tests/pom.xml
+++ b/org.eclipse.debug.tests/pom.xml
@@ -18,7 +18,7 @@
   </parent>
   <groupId>org.eclipse.debug</groupId>
   <artifactId>org.eclipse.debug.tests</artifactId>
-  <version>3.11.800-SNAPSHOT</version>
+  <version>3.11.900-SNAPSHOT</version>
   <packaging>eclipse-test-plugin</packaging>
   <properties>
     <code.ignoredWarnings>${tests.ignoredWarnings}</code.ignoredWarnings>
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java
index 135b54c..0c56672 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/MockProcess.java
@@ -232,7 +232,7 @@
 	 * @return <code>true</code> if process is terminated
 	 */
 	private boolean isTerminated() {
-		return endTime != RUN_FOREVER && System.currentTimeMillis() > endTime;
+		return endTime != RUN_FOREVER && System.currentTimeMillis() >= endTime;
 	}
 
 	/**
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java
index e6eb8b1..a1c6beb 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/console/ProcessConsoleTests.java
@@ -309,7 +309,7 @@
 	@Test
 	public void testAppendOutputToFile() throws Exception {
 		final String testContent = "Hello World!";
-		final File outFile = createTmpFile("test.out");
+		final File outFile = createTmpFile("test-append.out");
 		Map<String, Object> launchConfigAttributes = new HashMap<>();
 		launchConfigAttributes.put(IDebugUIConstants.ATTR_CAPTURE_IN_FILE, outFile.getCanonicalPath());
 		launchConfigAttributes.put(IDebugUIConstants.ATTR_APPEND_TO_FILE, true);
@@ -367,7 +367,7 @@
 	 * @return the console object after it has finished
 	 */
 	private IOConsole doConsoleOutputTest(byte[] testContent, Map<String, Object> launchConfigAttributes) throws Exception {
-		final MockProcess mockProcess = new MockProcess(new ByteArrayInputStream(testContent), null, 0);
+		final MockProcess mockProcess = new MockProcess(new ByteArrayInputStream(testContent), null, MockProcess.RUN_FOREVER);
 		final IProcess process = mockProcess.toRuntimeProcess("Output Redirect", launchConfigAttributes);
 		final String encoding = launchConfigAttributes != null ? (String) launchConfigAttributes.get(DebugPlugin.ATTR_CONSOLE_ENCODING) : null;
 		final AtomicBoolean consoleFinished = new AtomicBoolean(false);
@@ -381,6 +381,7 @@
 		final IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
 		try {
 			consoleManager.addConsoles(new IConsole[] { console });
+			mockProcess.destroy();
 			waitWhile(c -> !consoleFinished.get(), testTimeout, c -> "Console did not finished.");
 
 			Object value = launchConfigAttributes != null ? launchConfigAttributes.get(IDebugUIConstants.ATTR_CAPTURE_IN_FILE) : null;