1 /*******************************************************************************
2 * Copyright (c) 2014 École Polytechnique de Montréal
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Mathieu Rail - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.tmf
.tests
.stubs
.analysis
;
15 import java
.util
.Collection
;
16 import java
.util
.HashMap
;
19 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
20 import org
.eclipse
.jdt
.annotation
.NonNull
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.TmfAbstractAnalysisModule
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.TmfAnalysisRequirement
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.analysis
.TmfAnalysisRequirement
.ValuePriorityLevel
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.exceptions
.TmfAnalysisException
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
26 import org
.eclipse
.tracecompass
.tmf
.tests
.stubs
.trace
.TmfTraceStub
;
29 * Analysis type to test requirements acquisition
31 @SuppressWarnings({ "javadoc", "nls" })
32 public class TestRequirementAnalysis
extends TmfAbstractAnalysisModule
{
33 /* Test requirement types */
34 public static final String EVENT_TYPE
= "event";
35 public static final String FIELD_TYPE
= "field";
37 /* A few event names */
38 public static final String EXIT_SYSCALL
= "exit_syscall";
39 public static final String SCHED_SWITCH
= "sched_switch";
40 public static final String SCHED_WAKEUP
= "sched_wakeup";
43 public static final String PID
= "pid";
44 public static final String TID
= "tid";
47 public boolean canExecute(ITmfTrace trace
) {
48 /* This just makes sure the trace is a ctf stub trace */
49 return (TmfTraceStub
.class.isAssignableFrom(trace
.getClass()));
53 protected void canceling() {
58 protected boolean executeAnalysis(final IProgressMonitor monitor
) {
63 public boolean setTrace(ITmfTrace trace
) throws TmfAnalysisException
{
64 return super.setTrace(trace
);
68 public Iterable
<TmfAnalysisRequirement
> getAnalysisRequirements() {
69 Map
<String
, TmfAnalysisRequirement
> requirements
= new HashMap
<>();
71 /* Event type requirement and values */
72 requirements
.put(EVENT_TYPE
, new TmfAnalysisRequirement(EVENT_TYPE
));
73 requirements
.get(EVENT_TYPE
).addValue(EXIT_SYSCALL
, ValuePriorityLevel
.MANDATORY
);
74 requirements
.get(EVENT_TYPE
).addValue(SCHED_SWITCH
, ValuePriorityLevel
.MANDATORY
);
75 requirements
.get(EVENT_TYPE
).addValue(SCHED_WAKEUP
, ValuePriorityLevel
.MANDATORY
);
77 /* Field type requirement and values */
78 requirements
.put(FIELD_TYPE
, new TmfAnalysisRequirement(FIELD_TYPE
));
79 requirements
.get(FIELD_TYPE
).addValue(PID
, ValuePriorityLevel
.MANDATORY
);
80 requirements
.get(FIELD_TYPE
).addValue(TID
, ValuePriorityLevel
.MANDATORY
);
82 @SuppressWarnings("null")
83 @NonNull Collection
<TmfAnalysisRequirement
> values
= requirements
.values();