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;
}
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());
}
});
}
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());
}
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));
}
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));
}
Aggregations