-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tmf: Unit-test TmfTraceType.selectExperimentType
Add possible test coverage for the recently added selectExperimentType in TmfTraceType. Briefly comment where coverage isn't done. Augment the existing use of TmfExperimentStub for this added purpose. Base this added validateWithTraces method on the recently introduced TmfExperiment one. Introduce TmfExperimentSyslog as a supplemental yet sibling for this same unit testing purpose, just to cover some more. Fix a minor IDE warning (javadoc) and SonarLint issue (return) locally in TmfTraceType while there. Fix such minor warnings also in the hereby touched TraceAndExperimentTypeTest. Change-Id: Ib7d792ee692e785f3b60158758ff1fc38ce7efcd Signed-off-by: Marco Miller <marco.miller@ericsson.com> Reviewed-on: https://git.eclipse.org/r/c/tracecompass/org.eclipse.tracecompass/+/203282 Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org> Tested-by: Patrick Tasse <patrick.tasse@gmail.com> Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
- Loading branch information
1 parent
01d20eb
commit 935bc75
Showing
6 changed files
with
208 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
....core.tests/stubs/org/eclipse/tracecompass/tmf/tests/stubs/trace/TmfExperimentSyslog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 Ericsson | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License 2.0 which | ||
* accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.tracecompass.tmf.tests.stubs.trace; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.core.runtime.Status; | ||
import org.eclipse.tracecompass.internal.tmf.core.Activator; | ||
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; | ||
import org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus; | ||
import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; | ||
import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer; | ||
|
||
/** | ||
* @see TmfExperimentStub | ||
*/ | ||
public class TmfExperimentSyslog extends TmfExperiment { | ||
|
||
/** | ||
* Default constructor. Should not be called directly by the code, but | ||
* needed for the extension point. | ||
* | ||
* Do not call this directly (but do not remove it either!) | ||
*/ | ||
public TmfExperimentSyslog() { | ||
super(); | ||
} | ||
|
||
@Override | ||
protected ITmfTraceIndexer createIndexer(int interval) { | ||
return new TmfIndexerStub(this, interval); | ||
} | ||
|
||
@Override | ||
public TmfIndexerStub getIndexer() { | ||
return (TmfIndexerStub) super.getIndexer(); | ||
} | ||
|
||
/** | ||
* Make this specific stub meant to support traces with at least one | ||
* prefixed with "syslog". | ||
*/ | ||
@Override | ||
public IStatus validateWithTraces(List<ITmfTrace> traces) { | ||
if (getClass() == TmfExperimentSyslog.class) { | ||
int confidence = 0; | ||
for (ITmfTrace trace : traces) { | ||
if (trace.getName().startsWith("syslog")) { | ||
confidence = DEFAULT_GENERIC_EXPERIMENT_CONFIDENCE; | ||
} else if (trace.getName().startsWith("E-")) { | ||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "stubbed error case"); //$NON-NLS-1$ | ||
} | ||
} | ||
return new TraceValidationStatus(confidence, Activator.PLUGIN_ID); | ||
} | ||
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "class extends TmfExperimentSyslog"); //$NON-NLS-1$ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters