summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorCamilo Bernal2013-01-03 15:09:36 (EST)
committer Alexander Kurtakov2013-01-07 12:35:37 (EST)
commita5c4686c77de264ae98f9be19de48aa74942721e (patch)
tree78b0986f874e97407399df8815e20f02de8f4812
parent16edc98e51a9687cd05a3e0c6049bd383b53d06c (diff)
downloadorg.eclipse.linuxtools-a5c4686c77de264ae98f9be19de48aa74942721e.zip
org.eclipse.linuxtools-a5c4686c77de264ae98f9be19de48aa74942721e.tar.gz
org.eclipse.linuxtools-a5c4686c77de264ae98f9be19de48aa74942721e.tar.bz2
Add tests for annotation functionality in PerfCore.refs/changes/34/9434/2
Added tests for parseAnnotation and getAnnotateString. Change-Id: I162abd5d2d58a0adf0070c7395e23e60bea0a276 Reviewed-on: https://git.eclipse.org/r/9434 Tested-by: Hudson CI Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> IP-Clean: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/resources/perf-annotation-data39
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java95
2 files changed, 134 insertions, 0 deletions
diff --git a/perf/org.eclipse.linuxtools.perf.tests/resources/perf-annotation-data b/perf/org.eclipse.linuxtools.perf.tests/resources/perf-annotation-data
new file mode 100644
index 0000000..56c9320
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf.tests/resources/perf-annotation-data
@@ -0,0 +1,39 @@
+
+Sorted summary for file ./fibonacci
+----------------------------------------------
+
+ 42.59 /home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp:10
+ 7.41 /home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp:13
+ 7.41 /home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp:15
+ 5.56 /home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp:11
+ 5.56 /home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp:13
+ 5.56 /home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp:15
+ 3.70 /home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp:8
+ 3.70 /home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp:8
+ 3.70 /home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp:8
+ 3.70 /home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp:8
+ 3.70 /home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp:13
+ 1.85 /home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp:10
+ 1.85 /home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp:13
+ 1.85 /home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp:13
+ 1.85 /home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp:15
+ Percent | Source code & Disassembly of /home/user/workspace/fibonacci/Debug/fibonacci
+------------------------------------------------
+ :
+ :
+ :
+ : Disassembly of section .text:
+ :
+ : 00000000004008bc <fib(unsigned long)>:
+ : using namespace std;
+ :
+ : long fib(unsigned long n);
+ : long sqr(unsigned long n);
+ :
+ : long fib(unsigned long n) {
+ /home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp:8
+ 3.70 : 4008bc: push %rbp
+ 0.00 : 4008bd: mov %rsp,%rbp
+ 3.70 : 4008c0: push %rbx
+ 3.70 : 4008c1: sub $0x18,%rsp
+ 3.70 : 4008c5: mov %rdi,-0x18(%rbp)
diff --git a/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java b/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java
index f05c76d..db674f5 100644
--- a/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java
+++ b/perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java
@@ -21,6 +21,8 @@ import java.util.List;
import java.util.Stack;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
@@ -242,6 +244,99 @@ public class ModelTest extends AbstractTest {
}
}
+ public void testParseAnnotation() {
+ BufferedReader input = null;
+
+ try {
+ input = new BufferedReader(new FileReader(
+ "resources/perf-annotation-data"));
+ } catch (FileNotFoundException e) {
+ fail();
+ }
+
+ // Set up arguments for the annotation parser.
+ IPath workingDir = Path.fromOSString("/working/directory/");
+ PMCommand cmd = new PMCommand("testCommand");
+ PMDso dso = new PMDso("testDso", false);
+ PMFile tmpFile = new PMFile(PerfPlugin.STRINGS_UnfiledSymbols);
+ PMSymbol sym = new PMSymbol("testSym", 0, 0);
+
+ // Set children and respective parents.
+ cmd.addChild(dso);
+ dso.addChild(tmpFile);
+ tmpFile.addChild(sym);
+
+ dso.setParent(cmd);
+ tmpFile.setParent(dso);
+ sym.setParent(tmpFile);
+
+ PerfCore.parseAnnotation(null, input, workingDir, dso, sym);
+
+ // Expected results data.
+ String expectedDsoPath = "/working/directory/fibonacci";
+ String expectedFilePath = "/home/user/workspace/fibonacci/Debug/../src/fibonacci.cpp";
+
+ assertTrue(expectedDsoPath.equals(dso.getPath()));
+ assertTrue(dso.getChildren().length == 2);
+
+ for (TreeParent dsoChild : dso.getChildren()) {
+ String filePath = ((PMFile) dsoChild).getPath();
+
+ if (PerfPlugin.STRINGS_UnfiledSymbols.equals(filePath)) {
+ assertFalse(dsoChild.hasChildren());
+ } else {
+ assertTrue(expectedFilePath.equals(filePath));
+ assertTrue(dsoChild.hasChildren());
+ assertTrue(dsoChild.getChildren().length == 1);
+
+ TreeParent curSym = dsoChild.getChildren()[0];
+ assertTrue(curSym.hasChildren());
+ assertTrue(curSym.getChildren().length == 5);
+
+ float percentCount = 0;
+ for (TreeParent symChild : curSym.getChildren()) {
+ percentCount += symChild.getPercent();
+ }
+
+ assertTrue(Math.ceil(percentCount) == 100.0);
+
+ }
+ }
+ }
+
+ public void testAnnotateString(){
+ ILaunchConfigurationWorkingCopy tempConfig = null;
+ try {
+ tempConfig = config.copy("test-config");
+ tempConfig.setAttribute(PerfPlugin.ATTR_Kernel_Location,
+ "/boot/kernel");
+ tempConfig.setAttribute(PerfPlugin.ATTR_ModuleSymbols, true);
+ } catch (CoreException e) {
+ fail();
+ }
+
+ String[] annotateString = PerfCore.getAnnotateString(tempConfig, "dso",
+ "symbol", "resources/defaultevent-data/perf.data", false);
+
+ String[] expectedString = new String[] { PerfPlugin.PERF_COMMAND,
+ "annotate",
+ "-d",
+ "dso",
+ "-s",
+ "symbol",
+ "-l",
+ "-P",
+ "--vmlinux",
+ "/boot/kernel",
+ "-m",
+ "-i",
+ "resources/defaultevent-data/perf.data" };
+
+ for (int i = 0; i < annotateString.length; i++) {
+ assertTrue(annotateString[i].equals(expectedString[i]));
+ }
+ }
+
public void testRecordString() {
ILaunchConfigurationWorkingCopy tempConfig = null;
try {