summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorCamilo Bernal2012-12-28 17:29:21 (EST)
committer Roland Grunberg2013-01-02 16:35:55 (EST)
commit6b19fbd7695ae430db3dcd23110a19dc4e53b22e (patch)
treec91ca3f3b77b4c5fdb610cb183c2e7ab5b43c460
parent8fed7f98276560655938868d934cb9c329b57969 (diff)
downloadorg.eclipse.linuxtools-6b19fbd7695ae430db3dcd23110a19dc4e53b22e.zip
org.eclipse.linuxtools-6b19fbd7695ae430db3dcd23110a19dc4e53b22e.tar.gz
org.eclipse.linuxtools-6b19fbd7695ae430db3dcd23110a19dc4e53b22e.tar.bz2
Add tests for uncovered PerfCore functionality.refs/changes/98/9398/4
Tests cover parsing of event categories and creation of recording and reporting strings. Pregenerated data file has been added to avoid machine dependent test results. Change-Id: I51538dc84b36d5c7bea0929019434c0ca59047d6 Reviewed-on: https://git.eclipse.org/r/9398 Reviewed-by: Roland Grunberg <rgrunber@redhat.com> IP-Clean: Roland Grunberg <rgrunber@redhat.com> Tested-by: Roland Grunberg <rgrunber@redhat.com>
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/build.properties5
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/resources/simple-perf-event-list19
-rw-r--r--perf/org.eclipse.linuxtools.perf.tests/src/org/eclipse/linuxtools/internal/perf/tests/ModelTest.java110
3 files changed, 132 insertions, 2 deletions
diff --git a/perf/org.eclipse.linuxtools.perf.tests/build.properties b/perf/org.eclipse.linuxtools.perf.tests/build.properties
index ec30c07..6183937 100644
--- a/perf/org.eclipse.linuxtools.perf.tests/build.properties
+++ b/perf/org.eclipse.linuxtools.perf.tests/build.properties
@@ -1,5 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
- about.html,\
- .
+ about.html,\
+ .,\
+ resources/
diff --git a/perf/org.eclipse.linuxtools.perf.tests/resources/simple-perf-event-list b/perf/org.eclipse.linuxtools.perf.tests/resources/simple-perf-event-list
new file mode 100644
index 0000000..6bbdcf0
--- /dev/null
+++ b/perf/org.eclipse.linuxtools.perf.tests/resources/simple-perf-event-list
@@ -0,0 +1,19 @@
+
+List of pre-defined events (to be used in -e):
+ cpu-cycles OR cycles [Hardware event]
+ stalled-cycles-frontend OR idle-cycles-frontend [Hardware event]
+
+ cpu-clock [Software event]
+ task-clock [Software event]
+
+ L1-dcache-loads [Hardware cache event]
+ L1-dcache-load-misses [Hardware cache event]
+
+ rNNN [Raw hardware event descriptor]
+ cpu/t1=v1[,t2=v2,t3 ...]/modifier [Raw hardware event descriptor]
+ (see 'perf list --help' on how to encode it)
+
+ mem:<addr>[:access] [Hardware breakpoint]
+
+ mac80211:drv_return_void [Tracepoint event]
+ mac80211:drv_return_int [Tracepoint event]
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 eb4a75f..f05c76d 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
@@ -11,13 +11,16 @@
package org.eclipse.linuxtools.internal.perf.tests;
import java.io.BufferedReader;
+import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.Stack;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
@@ -208,6 +211,113 @@ public class ModelTest extends AbstractTest {
checkCommadLabels(cmdLabels, cmd);
}
+ public void testParseEventList() {
+ BufferedReader input = null;
+ try {
+ input = new BufferedReader(new FileReader("resources/simple-perf-event-list"));
+ } catch (FileNotFoundException e) {
+ fail();
+ }
+
+ HashMap<String, ArrayList<String>> eventList = PerfCore.parseEventList(input);
+ for(String key : eventList.keySet()){
+ if ("Raw hardware event descriptor".equals(key)) {
+ assertTrue(eventList.get(key).contains("rNNN"));
+ assertTrue(eventList.get(key).contains("cpu/t1=v1"));
+ } else if ("Hardware breakpoint".equals(key)) {
+ assertTrue(eventList.get(key).contains("mem:<addr>"));
+ } else if ("Software event".equals(key)) {
+ assertTrue(eventList.get(key).contains("cpu-clock"));
+ assertTrue(eventList.get(key).contains("task-clock"));
+ } else if ("Hardware cache event".equals(key)) {
+ assertTrue(eventList.get(key).contains("L1-dcache-loads"));
+ assertTrue(eventList.get(key).contains("L1-dcache-load-misses"));
+ } else if ("Tracepoint event".equals(key)) {
+ assertTrue(eventList.get(key).contains("mac80211:drv_return_void"));
+ assertTrue(eventList.get(key).contains("mac80211:drv_return_int"));
+ } else if ("Hardware event".equals(key)) {
+ assertTrue(eventList.get(key).contains("cpu-cycles"));
+ assertTrue(eventList.get(key).contains("stalled-cycles-frontend"));
+ }
+ }
+ }
+
+ public void testRecordString() {
+ ILaunchConfigurationWorkingCopy tempConfig = null;
+ try {
+ tempConfig = config.copy("test-config");
+ tempConfig.setAttribute(PerfPlugin.ATTR_Record_Realtime, true);
+ tempConfig.setAttribute(PerfPlugin.ATTR_Record_Verbose, true);
+ tempConfig.setAttribute(PerfPlugin.ATTR_Multiplex, true);
+
+ ArrayList<String> selectedEvents = new ArrayList<String>();
+ selectedEvents.add("cpu-cycles");
+ selectedEvents.add("cache-misses");
+ selectedEvents.add("cpu-clock");
+ tempConfig.setAttribute(PerfPlugin.ATTR_SelectedEvents, selectedEvents);
+
+ tempConfig.setAttribute(PerfPlugin.ATTR_DefaultEvent, false);
+
+ } catch (CoreException e) {
+ fail();
+ }
+
+ String[] recordString = PerfCore.getRecordString(tempConfig);
+ assertNotNull(recordString);
+
+ String[] expectedString = { PerfPlugin.PERF_COMMAND,
+ "record",
+ "-f",
+ "-r",
+ "-v",
+ "-M",
+ "-e",
+ "cpu-cycles",
+ "-e",
+ "cache-misses",
+ "-e",
+ "cpu-clock" };
+ assertTrue(recordString.length == expectedString.length);
+
+ for (int i = 0; i < recordString.length; i++) {
+ assertTrue(recordString[i].equals(expectedString[i]));
+ }
+ }
+
+ public void testReportString(){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[] reportString = PerfCore.getReportString(tempConfig,
+ "resources/defaultevent-data/perf.data");
+ assertNotNull(reportString);
+
+ String[] expectedString = { PerfPlugin.PERF_COMMAND,
+ "report",
+ "--sort",
+ "comm,dso,sym",
+ "-n",
+ "-t",
+ "" + (char) 1,
+ "--vmlinux",
+ "/boot/kernel",
+ "-m",
+ "-i",
+ "resources/defaultevent-data/perf.data" };
+ assertTrue(reportString.length == expectedString.length);
+
+ for (int i = 0; i < reportString.length; i++) {
+ assertTrue(reportString[i].equals(expectedString[i]));
+ }
+
+ }
+
/**
* @param root some element that will serve as the root
* @param sum the expected sum of the percentages of this root's