/**
   * Setup the trace for the tests and return the InputOutputAnalysisModule, not executed.
   *
   * @param fileName The file name of the trace to open
   * @return The input output analysis module
   */
  protected @NonNull InputOutputAnalysisModule setUp(String fileName) {
    TmfXmlKernelTraceStub trace = new TmfXmlKernelTraceStub();
    trace.addEventAspect(KernelTidAspect.INSTANCE);
    trace.setKernelEventLayout(EVENT_LAYOUT);
    IPath filePath = Activator.getAbsoluteFilePath(IO_FILE_PATH + fileName);
    IStatus status = trace.validate(null, filePath.toOSString());
    if (!status.isOK()) {
      fail(status.getException().getMessage());
    }
    try {
      trace.initTrace(null, filePath.toOSString(), TmfEvent.class);
    } catch (TmfTraceException e) {
      fail(e.getMessage());
    }

    deleteSuppFiles(trace);
    ((TmfTrace) trace).traceOpened(new TmfTraceOpenedSignal(this, trace, null));
    fTrace = trace;

    /* Start the kernel analysis module */
    KernelAnalysisModule kernelMod =
        TmfTraceUtils.getAnalysisModuleOfClass(
            trace, KernelAnalysisModule.class, KernelAnalysisModule.ID);
    assertNotNull(kernelMod);
    kernelMod.schedule();
    kernelMod.waitForCompletion();

    InputOutputAnalysisModule module =
        TmfTraceUtils.getAnalysisModuleOfClass(
            trace, InputOutputAnalysisModule.class, InputOutputAnalysisModule.ID);
    assertNotNull(module);
    return module;
  }
 /*
  * Classify sched_switch events for every CPU
  */
 @Override
 protected void eventHandle(ITmfEvent event) {
   ITmfStateSystemBuilder stateSystemBuilder = fStateSystemBuilder;
   if (stateSystemBuilder == null) {
     stateSystemBuilder = (ITmfStateSystemBuilder) getAssignedStateSystem();
     fStateSystemBuilder = stateSystemBuilder;
   }
   if (stateSystemBuilder == null) {
     return;
   }
   if (fCpuAttributeQuark == STARTING_QUARK) {
     fCpuAttributeQuark = stateSystemBuilder.getQuarkAbsoluteAndAdd(Attributes.CPUS);
   }
   if (event.getName().equals(fLayout.eventSchedSwitch())) {
     Object cpuObj =
         TmfTraceUtils.resolveEventAspectOfClassForEvent(
             event.getTrace(), TmfCpuAspect.class, event);
     if (cpuObj == null) {
       /* We couldn't find any CPU information, ignore this event */
       return;
     }
     int cpuQuark =
         stateSystemBuilder.getQuarkRelativeAndAdd(fCpuAttributeQuark, cpuObj.toString());
     try {
       StateSystemBuilderUtils.incrementAttributeInt(
           stateSystemBuilder, event.getTimestamp().getValue(), cpuQuark, 1);
     } catch (StateValueTypeException | AttributeNotFoundException e) {
       Activator.getDefault().logError(NonNullUtils.nullToEmptyString(e.getMessage()), e);
     }
   }
 }
 private @Nullable TmfGraphBuilderModule getGraph() {
   /* The graph module is null, take the first available graph if any */
   TmfGraphBuilderModule module = fGraphModule;
   if (module == null) {
     ITmfTrace trace = getTrace();
     if (trace == null) {
       return fGraphModule;
     }
     for (TmfGraphBuilderModule mod :
         TmfTraceUtils.getAnalysisModulesOfClass(trace, TmfGraphBuilderModule.class)) {
       module = mod;
       break;
     }
     if (module != null) {
       fGraphModule = module;
     }
   }
   return module;
 }
 @Override
 protected @Nullable ISegmentStoreProvider getSegmentStoreProvider(@NonNull ITmfTrace trace) {
   return TmfTraceUtils.getAnalysisModuleOfClass(
       trace, CallGraphAnalysis.class, CallGraphAnalysisUI.ID);
 }