ctf: Move CTF-testsuite tests to a separate file
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Sun, 17 Nov 2013 18:28:14 +0000 (13:28 -0500)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Mon, 18 Nov 2013 21:45:04 +0000 (16:45 -0500)
Change-Id: I0ebbe99f577430c16388ee6619d7a4d3a98044ae
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/18478
Tested-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
org.eclipse.linuxtools.ctf.core.tests/META-INF/MANIFEST.MF
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/AllCtfCoreTests.java
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/ctftestsuite/CtfTestSuiteTest.java [new file with mode: 0644]
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/ctftestsuite/TestAll.java [new file with mode: 0644]
org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/trace/CTFTraceTest.java

index e478054115fe47be72bb1f0a90294113878e62c2..c4f571e94e62c5a6494636f31e95ebb84343db0f 100644 (file)
@@ -12,6 +12,7 @@ Require-Bundle: org.junit;bundle-version="4.0.0",
  org.eclipse.core.runtime;bundle-version="3.8.0",
  org.eclipse.linuxtools.ctf.core;bundle-version="3.0.0"
 Export-Package: org.eclipse.linuxtools.ctf.core.tests;x-friends:="org.eclipse.linuxtools.lttng.alltests",
+ org.eclipse.linuxtools.ctf.core.tests.ctftestsuite;x-internal:=true,
  org.eclipse.linuxtools.ctf.core.tests.event;x-internal:=true,
  org.eclipse.linuxtools.ctf.core.tests.headless;x-internal:=true,
  org.eclipse.linuxtools.ctf.core.tests.io;x-internal:=true,
index 83a31536cbe426c2115f8c3301dc50c6d23d708c..b4867d9eba771b5a82a0d3a8fe6fc3a689c3fde4 100644 (file)
@@ -25,6 +25,7 @@ import org.junit.runners.Suite;
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
     CtfCorePluginTest.class,
+    org.eclipse.linuxtools.ctf.core.tests.ctftestsuite.TestAll.class,
     org.eclipse.linuxtools.ctf.core.tests.event.TestAll.class,
     org.eclipse.linuxtools.ctf.core.tests.io.TestAll.class,
     org.eclipse.linuxtools.ctf.core.tests.trace.TestAll.class,
diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/ctftestsuite/CtfTestSuiteTest.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/ctftestsuite/CtfTestSuiteTest.java
new file mode 100644 (file)
index 0000000..e9b0760
--- /dev/null
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Alexandre Montplaisir - Moved out of CTFTestTrace
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.ctf.core.tests.ctftestsuite;
+
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import java.io.File;
+
+import org.eclipse.linuxtools.ctf.core.trace.CTFReaderException;
+import org.eclipse.linuxtools.ctf.core.trace.CTFTrace;
+import org.junit.Test;
+
+/**
+ * Test class running the CTF Test Suite
+ * (from https://github.com/efficios/ctf-testsuite).
+ *
+ * @author Matthew Khouzam
+ */
+public class CtfTestSuiteTest {
+
+    private static final String TRACES_DIRECTORY = "../org.eclipse.linuxtools.ctf.core.tests/traces";
+    private static final String METADATA_FILENAME = "metadata";
+
+    private static final String CTF_VERSION_NUMBER = "1.8";
+    private static final String CTF_SUITE_TEST_DIRECTORY = "ctf-testsuite/tests/" + CTF_VERSION_NUMBER;
+
+    /**
+     * Open traces in specified directories and expect them to fail
+     *
+     * @throws CTFReaderException not expected
+     */
+    @Test
+    public void testFailedParse() throws CTFReaderException {
+        parseTracesInDirectory(getTestTracesSubDirectory(CTF_SUITE_TEST_DIRECTORY + "/fail"), true);
+    }
+
+    /**
+     * Open traces in specified directories and expect them to succeed
+     *
+     * @throws CTFReaderException not expected
+     */
+    @Test
+    public void testSuccessfulParse() throws CTFReaderException {
+        parseTracesInDirectory(getTestTracesSubDirectory("kernel"), false);
+        parseTracesInDirectory(getTestTracesSubDirectory("trace2"), false);
+        parseTracesInDirectory(getTestTracesSubDirectory(CTF_SUITE_TEST_DIRECTORY + "/pass"), false);
+    }
+
+
+    /**
+     * Get the File object for the subDir in the traces directory. If the sub directory doesn't exist, the test is skipped.
+     */
+    private static File getTestTracesSubDirectory(String subDir) {
+        File file = new File(TRACES_DIRECTORY + "/" + subDir);
+        assumeTrue(file.isDirectory());
+        return file;
+    }
+
+    /**
+     * Parse the traces in given directory recursively
+     *
+     * @param directory The directory to search in
+     * @param expectException Whether or not traces in this directory are expected to throw an exception when parsed
+     * @throws CTFReaderException
+     */
+    void parseTracesInDirectory(File directory, boolean expectException) throws CTFReaderException {
+        for (File file : directory.listFiles()) {
+            if (file.getName().equals(METADATA_FILENAME)) {
+                try {
+                    new CTFTrace(directory);
+                    if (expectException) {
+                        fail("Trace was expected to fail parsing: " + directory);
+                    }
+                } catch (RuntimeException e) {
+                    if (!expectException) {
+                        throw new CTFReaderException("Failed parsing " + directory, e);
+                    }
+                } catch (CTFReaderException e) {
+                    if (!expectException) {
+                        throw new CTFReaderException("Failed parsing " + directory, e);
+                    }
+                }
+                return;
+            }
+
+            if (file.isDirectory()) {
+                parseTracesInDirectory(file, expectException);
+            }
+        }
+    }
+}
diff --git a/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/ctftestsuite/TestAll.java b/org.eclipse.linuxtools.ctf.core.tests/src/org/eclipse/linuxtools/ctf/core/tests/ctftestsuite/TestAll.java
new file mode 100644 (file)
index 0000000..032f532
--- /dev/null
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Alexandre Montplaisir - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.ctf.core.tests.ctftestsuite;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * The class <code>TestAll</code> builds a suite that can be used to run all of
+ * the tests within its package as well as within any subpackages of its
+ * package.
+ *
+ * @author ematkho
+ * @version $Revision: 1.0 $
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+    CtfTestSuiteTest.class
+})
+public class TestAll {
+
+}
index 0fd73cb3ed458b77cbc711b051f3456d4fd0a9a3..aebf35ea245572621617dc5607d8de04ac10dd9d 100644 (file)
@@ -45,15 +45,8 @@ import org.junit.Test;
  */
 public class CTFTraceTest {
 
-    private static final String TRACES_DIRECTORY = "../org.eclipse.linuxtools.ctf.core.tests/traces";
-
-    private static final String METADATA_FILENAME = "metadata";
-
     private static final CtfTestTrace testTrace = CtfTestTrace.KERNEL;
 
-    private static final String CTF_VERSION_NUMBER = "1.8";
-    private static final String CTF_SUITE_TEST_DIRECTORY = "ctf-testsuite/tests/" + CTF_VERSION_NUMBER;
-
     private CTFTrace fixture;
 
     /**
@@ -401,70 +394,6 @@ public class CTFTraceTest {
         assertNotNull(result);
     }
 
-    /**
-     * Open traces in specified directories and expect them to fail
-     *
-     * @throws CTFReaderException not expected
-     */
-    @Test
-    public void testFailedParse() throws CTFReaderException {
-        parseTracesInDirectory(getTestTracesSubDirectory(CTF_SUITE_TEST_DIRECTORY + "/fail"), true);
-    }
-
-    /**
-     * Open traces in specified directories and expect them to succeed
-     *
-     * @throws CTFReaderException not expected
-     */
-    @Test
-    public void testSuccessfulParse() throws CTFReaderException {
-        parseTracesInDirectory(getTestTracesSubDirectory("kernel"), false);
-        parseTracesInDirectory(getTestTracesSubDirectory("trace2"), false);
-        parseTracesInDirectory(getTestTracesSubDirectory(CTF_SUITE_TEST_DIRECTORY + "/pass"), false);
-    }
-
-    /**
-     * Get the File object for the subDir in the traces directory. If the sub directory doesn't exist, the test is skipped.
-     */
-    private static File getTestTracesSubDirectory(String subDir) {
-        File file = new File(TRACES_DIRECTORY + "/" + subDir);
-        assumeTrue(file.isDirectory());
-        return file;
-    }
-
-    /**
-     * Parse the traces in given directory recursively
-     *
-     * @param directory The directory to search in
-     * @param expectException Whether or not traces in this directory are expected to throw an exception when parsed
-     * @throws CTFReaderException
-     */
-    void parseTracesInDirectory(File directory, boolean expectException) throws CTFReaderException {
-        for (File file : directory.listFiles()) {
-            if (file.getName().equals(METADATA_FILENAME)) {
-                try {
-                    new CTFTrace(directory);
-                    if (expectException) {
-                        fail("Trace was expected to fail parsing: " + directory);
-                    }
-                } catch (RuntimeException e) {
-                    if (!expectException) {
-                        throw new CTFReaderException("Failed parsing " + directory, e);
-                    }
-                } catch (CTFReaderException e) {
-                    if (!expectException) {
-                        throw new CTFReaderException("Failed parsing " + directory, e);
-                    }
-                }
-                return;
-            }
-
-            if (file.isDirectory()) {
-                parseTracesInDirectory(file, expectException);
-            }
-        }
-    }
-
     /**
      * Test for getCallsite(eventName, ip)
      * @throws CTFReaderException not expected
This page took 0.027939 seconds and 5 git commands to generate.