Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add validation tests for binary FTrace parser
This commit adds new unit tests that validate various sample test traces using the new implementation of the binary FTrace parser that parses the binary trace files directly without converting the files to text format. The new tests detect an unhandled NumberFormatException while parsing the trace version. Hence, this commit also includes a patch to handle such exception. Change-Id: Icaaa47d544f1a92cdc2eeabc7cfab3dcd3b51105 Signed-off-by: Hoang Thuan Pham <hoang.pham@calian.ca> Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/190837 Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org> Tested-by: Marco Miller <marco.miller@ericsson.com> Reviewed-by: Marco Miller <marco.miller@ericsson.com> Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
- Loading branch information
1 parent
b912f84
commit d7171d5
Showing
2 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
...ests/src/org/eclipse/tracecompass/incubator/ftrace/core/tests/trace/BinaryFTraceTest.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,72 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 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.incubator.ftrace.core.tests.trace; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.io.IOException; | ||
|
||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.tracecompass.incubator.ftrace.core.tests.shared.FTraceUtils; | ||
import org.eclipse.tracecompass.incubator.internal.ftrace.core.trace.BinaryFTrace; | ||
import org.eclipse.tracecompass.testtraces.ftrace.FtraceTestTrace; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Tests for {@link BinaryFTrace} | ||
* | ||
* @author Hoang Thuan Pham | ||
*/ | ||
public class BinaryFTraceTest { | ||
private static final String NON_EXISTING_PATH = "/wrong/path/no_trace.dat"; | ||
|
||
/** | ||
* Test validation of a valid trace | ||
* | ||
* @throws IOException | ||
* If an error occurred while validating the file | ||
*/ | ||
@Test | ||
public void testValidTrace() throws IOException { | ||
BinaryFTrace ftraceTrace = new BinaryFTrace(); | ||
String validTracePath = FTraceUtils.getTraceAbsolutePath(FtraceTestTrace.TEST_2_6_MULTIPLE_CPUS); | ||
IStatus goodStatus = ftraceTrace.validate(null, validTracePath); | ||
assertEquals(0, goodStatus.getSeverity()); | ||
ftraceTrace.dispose(); | ||
} | ||
|
||
/** | ||
* Test validation of an invalid trace | ||
* | ||
* @throws IOException | ||
* If an error occurred while validating the file | ||
*/ | ||
@Test | ||
public void testInvalidTrace() throws IOException { | ||
BinaryFTrace ftraceTrace = new BinaryFTrace(); | ||
String invalidTracePath = FTraceUtils.getTraceAbsolutePath(FtraceTestTrace.TEST_2_6_INVALID); | ||
IStatus invalidStatus = ftraceTrace.validate(null, invalidTracePath); | ||
assertEquals(0x04, invalidStatus.getSeverity()); | ||
ftraceTrace.dispose(); | ||
} | ||
|
||
/** | ||
* Test validation using file that does not exist | ||
*/ | ||
@Test | ||
public void testValidateFileDoesNotExist() { | ||
BinaryFTrace ftraceTrace = new BinaryFTrace(); | ||
IStatus status = ftraceTrace.validate(null, NON_EXISTING_PATH); | ||
assertEquals(0x04, status.getSeverity()); | ||
ftraceTrace.dispose(); | ||
} | ||
} |
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