Search in sources :

Example 6 with LamiTableEntryAspect

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect in project tracecompass by tracecompass.

the class LamiAnalysis method checkMetadata.

/**
 * Verify that this script returns valid metadata.
 *
 * @return True if the command outputs a valid metadata object
 */
@VisibleForTesting
protected boolean checkMetadata() {
    /*
         * The initialize() phase of the analysis will be used to check the
         * script's metadata. Actual runs of the script will use the execute()
         * method.
         */
    List<String> command = ImmutableList.<@NonNull String>builder().addAll(fScriptCommand).add(METADATA_FLAG).build();
    TraceCompassLogUtils.traceInstant(LOGGER, Level.INFO, RUNNING_METADATA_COMMAND, COMMAND, command);
    String output = getOutputFromCommand(command);
    if (output == null || output.isEmpty()) {
        return false;
    }
    try {
        JSONObject obj = new JSONObject(output);
        fAnalysisTitle = obj.getString(LamiStrings.TITLE);
        JSONObject tableClasses = obj.getJSONObject(LamiStrings.TABLE_CLASSES);
        @NonNull String[] tableClassNames = checkNotNullContents(JSONObject.getNames(tableClasses));
        ImmutableMap.Builder<String, LamiTableClass> tablesBuilder = ImmutableMap.builder();
        for (String tableClassName : tableClassNames) {
            JSONObject tableClass = tableClasses.getJSONObject(tableClassName);
            final String tableTitle = checkNotNull(tableClass.getString(LamiStrings.TITLE));
            @NonNull JSONArray columnDescriptions = checkNotNull(tableClass.getJSONArray(LamiStrings.COLUMN_DESCRIPTIONS));
            List<LamiTableEntryAspect> aspects = getAspectsFromColumnDescriptions(columnDescriptions);
            Collection<LamiChartModel> chartModels = getPredefinedCharts().get(tableClassName);
            tablesBuilder.put(tableClassName, new LamiTableClass(tableClassName, tableTitle, aspects, chartModels));
        }
        try {
            fTableClasses = tablesBuilder.build();
        } catch (IllegalArgumentException e) {
            // $NON-NLS-1$
            throw new JSONException("Duplicate table class entry in " + fAnalysisTitle);
        }
    } catch (JSONException e) {
        /* Error in the parsing of the JSON, script is broken? */
        TraceCompassLogUtils.traceInstant(LOGGER, Level.WARNING, ERROR_PARSING_METADATA, e.getMessage());
        return false;
    }
    return true;
}
Also used : LamiTableEntryAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException) NonNullUtils.nullToEmptyString(org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString) ImmutableMap(com.google.common.collect.ImmutableMap) JSONObject(org.json.JSONObject) NonNull(org.eclipse.jdt.annotation.NonNull) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 7 with LamiTableEntryAspect

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect in project tracecompass by tracecompass.

the class LamiTableViewer method createColumns.

// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
private void createColumns() {
    final List<LamiTableEntryAspect> aspects = fPage.getResultTable().getTableClass().getAspects();
    Display.getDefault().asyncExec(() -> {
        for (LamiTableEntryAspect aspect : aspects) {
            createColumn(aspect.getLabel(), new LamiTableColumnLabelProvider(aspect), aspect.getComparator());
        }
    });
}
Also used : LamiTableEntryAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect)

Example 8 with LamiTableEntryAspect

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect in project tracecompass by tracecompass.

the class LamiJsonParserTest method testMetadata.

/**
 * Test the metadata parsing.
 */
@Test
public void testMetadata() {
    LamiAnalysisStub analysis = new LamiAnalysisStub("Stub analysis", "test-metadata.json", "test-results.json");
    LamiTmfTraceStub trace = fTrace;
    assertNotNull(trace);
    assertTrue(analysis.canExecute(trace));
    assertEquals("LAMI test", analysis.getAnalysisTitle());
    Map<String, LamiTableClass> tableModels = analysis.getTableClasses();
    /* Table models tests */
    assertNotNull(tableModels);
    assertFalse(tableModels.isEmpty());
    assertEquals(3, tableModels.size());
    /* Table class tests */
    LamiTableClass perSyscallClass = tableModels.get("per-syscall");
    assertNotNull(perSyscallClass);
    LamiTableClass perProcessClass = tableModels.get("per-proc");
    assertNotNull(perProcessClass);
    LamiTableClass perInterruptClass = tableModels.get("per-irq");
    assertNotNull(perInterruptClass);
    assertEquals("Per-syscall stuff", perSyscallClass.getTableTitle());
    assertEquals("Per-process stuff", perProcessClass.getTableTitle());
    assertEquals("Per-interrupt stuff", perInterruptClass.getTableTitle());
    /* Aspects tests */
    List<LamiTableEntryAspect> aspects = perSyscallClass.getAspects();
    assertFalse(aspects.isEmpty());
    assertEquals(8, aspects.size());
    assertEquals("System call", aspects.get(0).getLabel());
    assertEquals("Duration (ns)", aspects.get(1).getLabel());
    assertEquals("Size (bytes)", aspects.get(2).getLabel());
    assertEquals("Bitrate (bps)", aspects.get(3).getLabel());
    assertEquals("Time range (begin)", aspects.get(4).getLabel());
    assertEquals("Time range (end)", aspects.get(5).getLabel());
    assertEquals("Time range (duration) (ns)", aspects.get(6).getLabel());
    // Empty aspect to fix SWT display bug
    assertEquals("", aspects.get(7).getLabel());
}
Also used : LamiTableEntryAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect) LamiAnalysisStub(org.eclipse.tracecompass.analysis.lami.core.tests.shared.analysis.LamiAnalysisStub) LamiTableClass(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableClass) Test(org.junit.Test)

Example 9 with LamiTableEntryAspect

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect in project tracecompass by tracecompass.

the class LamiAspectTest method lamiDurationAspectTest.

/**
 * Test the duration aspect
 *
 * @throws JSONException
 *             won't happen
 */
@Test
public void lamiDurationAspectTest() throws JSONException {
    LamiTableEntryAspect aspect = new LamiDurationAspect(ASPECT_NAME, 3);
    LamiTableEntry entry1 = createLamiData(1);
    LamiTableEntry entry2 = createLamiData(2);
    assertEquals(ASPECT_NAME + " (ns)", aspect.getLabel());
    assertEquals(ASPECT_NAME, aspect.getName());
    assertEquals(0, aspect.getComparator().compare(entry1, entry2));
    assertEquals("1", aspect.resolveString(entry1));
    assertNull(aspect.resolveNumber(entry1));
}
Also used : LamiTableEntryAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect) LamiTableEntry(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry) LamiDurationAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiDurationAspect) Test(org.junit.Test)

Example 10 with LamiTableEntryAspect

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect in project tracecompass by tracecompass.

the class LamiAspectTest method lamiIRQNameAspectTest.

/**
 * Test the irq name aspect
 *
 * @throws JSONException
 *             won't happen
 */
@Test
public void lamiIRQNameAspectTest() throws JSONException {
    LamiTableEntryAspect aspect = new LamiIRQNameAspect(ASPECT_NAME, 3);
    LamiTableEntry entry1 = createLamiData(1);
    LamiTableEntry entry2 = createLamiData(2);
    assertEquals(ASPECT_NAME + " (name)", aspect.getLabel());
    assertEquals(ASPECT_NAME + " (name)", aspect.getName());
    assertEquals(-1, aspect.getComparator().compare(entry1, entry2));
    assertEquals("1", aspect.resolveString(entry1));
    assertNull(aspect.resolveNumber(entry1));
}
Also used : LamiTableEntryAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect) LamiIRQNameAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiIRQNameAspect) LamiTableEntry(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry) Test(org.junit.Test)

Aggregations

LamiTableEntryAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect)20 Test (org.junit.Test)16 LamiTableEntry (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry)15 NonNullUtils.nullToEmptyString (org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString)3 LamiProcessTIDAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiProcessTIDAspect)3 LamiTimeRangeEndAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTimeRangeEndAspect)3 LamiTimestampAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTimestampAspect)3 LamiAnalysisStub (org.eclipse.tracecompass.analysis.lami.core.tests.shared.analysis.LamiAnalysisStub)2 LamiDurationAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiDurationAspect)2 LamiGenericAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiGenericAspect)2 LamiIRQNameAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiIRQNameAspect)2 LamiIRQNumberAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiIRQNumberAspect)2 LamiMixedAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiMixedAspect)2 LamiProcessNameAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiProcessNameAspect)2 LamiProcessPIDAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiProcessPIDAspect)2 LamiTimeRangeBeginAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTimeRangeBeginAspect)2 LamiTimeRangeDurationAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTimeRangeDurationAspect)2 LamiTableClass (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableClass)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1