ctf: Succeed at failing on OOME in tests
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Mon, 2 Dec 2013 20:52:26 +0000 (15:52 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Tue, 3 Dec 2013 01:59:15 +0000 (20:59 -0500)
There is a test that fails with an OutOfMemoryError. This catches the
failure and thus makes the test succeed at failing.

Change-Id: If4b1a14bf135da3fae9f356631440acede56673c
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/19001
Tested-by: Hudson CI
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/ctftestsuite/CtfTestSuiteTests.java

index abaecf48746be68743e242a94f8f8fd0e7414c38..f5b988400c9cb229134d347e91034449c014123b 100644 (file)
@@ -132,14 +132,11 @@ public class CtfTestSuiteTests {
                 assertNotNull(reader.getCurrentEventDef());
             }
 
-            if (!fExpectSuccess) {
-                fail("Trace was expected to fail parsing: " + fTracePath);
-            }
+            checkIfWeShoudlSucceed();
         } catch (CTFReaderException e) {
-            if (fExpectSuccess) {
-                fail("Trace was expected to succeed, but failed parsing: " +
-                        fTracePath + " (" + e.getMessage() + ")");
-            }
+            checkIfWeShouldFail(e);
+        } catch (OutOfMemoryError e) {
+            checkIfWeShouldFail(e);
         } finally {
             if (reader != null) {
                 reader.dispose();
@@ -150,4 +147,17 @@ public class CtfTestSuiteTests {
 
         }
     }
+
+    private void checkIfWeShoudlSucceed() {
+        if (!fExpectSuccess) {
+            fail("Trace was expected to fail parsing: " + fTracePath);
+        }
+    }
+
+    private void checkIfWeShouldFail(Throwable e) {
+        if (fExpectSuccess) {
+            fail("Trace was expected to succeed, but failed parsing: " +
+                    fTracePath + " (" + e.getMessage() + ")");
+        }
+    }
 }
This page took 0.025821 seconds and 5 git commands to generate.