Search in sources :

Example 26 with TmfAnalysisException

use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.

the class AnalysisModuleTest method testWaitForCompletionCancelled.

/**
 * Test suite for {@link TmfAbstractAnalysisModule#waitForCompletion} with
 * cancellation
 */
@Test
public void testWaitForCompletionCancelled() {
    TestAnalysis module = setUpAnalysis();
    try {
        /* Set a stub trace for analysis */
        ITmfTrace trace = TmfTestTrace.A_TEST_10K.getTrace();
        try {
            assertTrue(module.setTrace(trace));
        } catch (TmfAnalysisException e) {
            fail(e.getMessage());
        }
        module.setParameter(TestAnalysis.PARAM_TEST, 0);
        IStatus status = module.schedule();
        assertEquals(Status.OK_STATUS, status);
        boolean completed = module.waitForCompletion();
        assertFalse(completed);
        assertEquals(0, module.getAnalysisOutput());
    } finally {
        module.dispose();
    }
}
Also used : TestAnalysis(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IStatus(org.eclipse.core.runtime.IStatus) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) Test(org.junit.Test)

Example 27 with TmfAnalysisException

use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.

the class AnalysisModuleTest method testSetWrongTrace.

/**
 * Test the {@link TmfAbstractAnalysisModule#setTrace(ITmfTrace)} method
 * with wrong trace
 */
@Test
public void testSetWrongTrace() {
    IAnalysisModule module = new TestAnalysis2();
    module.setName(MODULE_GENERIC_NAME);
    module.setId(MODULE_GENERIC_ID);
    assertEquals(MODULE_GENERIC_ID, module.getId());
    assertEquals(MODULE_GENERIC_NAME, module.getName());
    try {
        assertFalse(module.setTrace(TmfTestTrace.A_TEST_10K.getTrace()));
    } catch (TmfAnalysisException e) {
        fail();
    }
    module.dispose();
}
Also used : TestAnalysis2(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis2) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) Test(org.junit.Test)

Example 28 with TmfAnalysisException

use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.

the class AnalysisModuleTest method testWaitForCompletionSuccess.

/**
 * Test suite for analysis module
 * {@link TmfAbstractAnalysisModule#waitForCompletion} with successful
 * execution
 */
@Test
public void testWaitForCompletionSuccess() {
    TestAnalysis module = setUpAnalysis();
    IStatus status = module.schedule();
    assertEquals(IStatus.ERROR, status.getSeverity());
    /* Set a stub trace for analysis */
    try {
        assertTrue(module.setTrace(TmfTestTrace.A_TEST_10K.getTrace()));
    } catch (TmfAnalysisException e) {
        fail(e.getMessage());
    }
    /* Default execution, with output 1 */
    module.setParameter(TestAnalysis.PARAM_TEST, 1);
    status = module.schedule();
    assertEquals(Status.OK_STATUS, status);
    boolean completed = module.waitForCompletion();
    assertTrue(completed);
    assertEquals(1, module.getAnalysisOutput());
    module.dispose();
}
Also used : TestAnalysis(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis) IStatus(org.eclipse.core.runtime.IStatus) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) Test(org.junit.Test)

Example 29 with TmfAnalysisException

use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.

the class AnalysisModuleTest method testCancel.

/**
 * Test suite for the {@link TmfAbstractAnalysisModule#cancel()} method
 */
@Test
public void testCancel() {
    TestAnalysis module = setUpAnalysis();
    module.setParameter(TestAnalysis.PARAM_TEST, 999);
    try {
        assertTrue(module.setTrace(TmfTestTrace.A_TEST_10K.getTrace()));
    } catch (TmfAnalysisException e) {
        fail(e.getMessage());
    }
    IStatus schedule = module.schedule();
    assertEquals(Status.OK_STATUS, schedule);
    /* Give the job a chance to start */
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        fail(e.getMessage());
    }
    module.cancel();
    assertFalse(module.waitForCompletion());
    assertEquals(-1, module.getAnalysisOutput());
    module.dispose();
}
Also used : TestAnalysis(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis) IStatus(org.eclipse.core.runtime.IStatus) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) Test(org.junit.Test)

Example 30 with TmfAnalysisException

use of org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException in project tracecompass by tracecompass.

the class AnalysisModuleTest method testParameterChanged.

/**
 * Test suite for the {@link IAnalysisModule#notifyParameterChanged(String)}
 * method
 */
@Test
public void testParameterChanged() {
    TestAnalysis module = setUpAnalysis();
    try {
        assertTrue(module.setTrace(TmfTestTrace.A_TEST_10K.getTrace()));
    } catch (TmfAnalysisException e) {
        fail(e.getMessage());
    }
    /* Check exception if no wrong parameter name */
    Exception exception = null;
    try {
        module.notifyParameterChanged("aaa");
    } catch (RuntimeException e) {
        exception = e;
    }
    assertNotNull(exception);
    /*
         * Cannot test anymore of this method, need a parameter provider to do
         * this
         */
    module.dispose();
}
Also used : TestAnalysis(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) Test(org.junit.Test)

Aggregations

TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)44 Test (org.junit.Test)21 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)15 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)14 TestAnalysis (org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis)9 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)8 TmfTraceException (org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)8 File (java.io.File)7 LttngKernelTrace (org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace)6 IStatus (org.eclipse.core.runtime.IStatus)5 Performance (org.eclipse.test.performance.Performance)5 PerformanceMeter (org.eclipse.test.performance.PerformanceMeter)5 BeforeClass (org.junit.BeforeClass)5 CtfTmfTrace (org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace)4 Nullable (org.eclipse.jdt.annotation.Nullable)3 DataDrivenAnalysisModule (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule)3 XmlUtilsTest (org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest)3 IAnalysisModuleHelper (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2