Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/gprof
diff options
context:
space:
mode:
authorXavier Raynaud2009-10-09 12:28:30 +0000
committerXavier Raynaud2009-10-09 12:28:30 +0000
commit57bba3b69685045f93554974edbb6f69385b111d (patch)
tree35f1ab0873139d017b198e9cc108b1c2d8d108a4 /gprof
parent2a210efce440dc46caf66483a6f7c11661a9da8e (diff)
downloadorg.eclipse.linuxtools-57bba3b69685045f93554974edbb6f69385b111d.tar.gz
org.eclipse.linuxtools-57bba3b69685045f93554974edbb6f69385b111d.tar.xz
org.eclipse.linuxtools-57bba3b69685045f93554974edbb6f69385b111d.zip
Enhance JUnit test, to be tolerant to binutils output variations
Diffstat (limited to 'gprof')
-rw-r--r--gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testCallgraphTimeView.ref24
-rw-r--r--gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testCallgraphView.ref24
-rw-r--r--gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testFunctionSampleView.ref8
-rw-r--r--gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testFunctionTimeView.ref8
-rw-r--r--gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testSampleView.ref8
-rw-r--r--gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testTimeView.ref8
-rw-r--r--gprof/org.eclipse.linuxtools.gprof.test/src/org/eclipse/linuxtools/gprof/test/STJunitUtils.java70
7 files changed, 105 insertions, 45 deletions
diff --git a/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testCallgraphTimeView.ref b/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testCallgraphTimeView.ref
index 549c72b1dd..e58673b302 100644
--- a/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testCallgraphTimeView.ref
+++ b/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testCallgraphTimeView.ref
@@ -1,8 +1,8 @@
Hierarchy;Name (location);Time;Calls;Time/Call;%Time
+-;Summary;0ns;;;0.0
- +-;A::foocpp::foocpp[in-charge]();0ns;2;0ns;0.0
+ +-;A::foocpp::foocpp();0ns;2;0ns;0.0
| +-;parents;0ns;2;0ns;0.0
- | +-;B::foocpp::foocpp[in-charge]() (foox.cpp:82);0ns;1;0ns;0.0
+ | +-;B::foocpp::foocpp() (foox.cpp:82);0ns;1;0ns;0.0
| +-;main (foox.cpp:110);0ns;1;0ns;0.0
+-;A::foocpp::func_a(int);0ns;2;0ns;0.0
| +-;children;0ns;2;0ns;0.0
@@ -13,13 +13,13 @@ Hierarchy;Name (location);Time;Calls;Time/Call;%Time
+-;A::foocpp::func_f(int);0ns;2;0ns;0.0
| +-;parents;0ns;2;0ns;0.0
| +-;A::foocpp::func_a(int) (foox.cpp:59);0ns;2;0ns;0.0
- +-;A::foocpp::~foocpp [in-charge]();0ns;2;0ns;0.0
+ +-;A::foocpp::~foocpp();0ns;2;0ns;0.0
| +-;parents;0ns;2;0ns;0.0
- | +-;B::foocpp::~foocpp [in-charge]() (foox.cpp:87);0ns;1;0ns;0.0
+ | +-;B::foocpp::~foocpp() (foox.cpp:87);0ns;1;0ns;0.0
| +-;main (foox.cpp:118);0ns;1;0ns;0.0
- +-;B::foocpp::foocpp[in-charge]();0ns;1;0ns;0.0
+ +-;B::foocpp::foocpp();0ns;1;0ns;0.0
| +-;children;0ns;1;0ns;0.0
- | | +-;A::foocpp::foocpp[in-charge]() (foox.cpp:42);0ns;1;0ns;0.0
+ | | +-;A::foocpp::foocpp() (foox.cpp:42);0ns;1;0ns;0.0
| +-;parents;0ns;1;0ns;0.0
| +-;main (foox.cpp:109);0ns;1;0ns;0.0
+-;B::foocpp::func_b(int);0ns;1;0ns;0.0
@@ -27,16 +27,16 @@ Hierarchy;Name (location);Time;Calls;Time/Call;%Time
| | +-;A::foocpp::func_a(int) (foox.cpp:54);0ns;1;0ns;0.0
| +-;parents;0ns;1;0ns;0.0
| +-;main (foox.cpp:115);0ns;1;0ns;0.0
- +-;B::foocpp::~foocpp [in-charge]();0ns;1;0ns;0.0
+ +-;B::foocpp::~foocpp();0ns;1;0ns;0.0
| +-;children;0ns;1;0ns;0.0
- | | +-;A::foocpp::~foocpp [in-charge]() (foox.cpp:44);0ns;1;0ns;0.0
+ | | +-;A::foocpp::~foocpp() (foox.cpp:44);0ns;1;0ns;0.0
| +-;parents;0ns;1;0ns;0.0
| +-;main (foox.cpp:119);0ns;1;0ns;0.0
+-;main;0ns;0;;0.0
+-;children;0ns;6;0ns;0.0
- +-;A::foocpp::foocpp[in-charge]() (foox.cpp:42);0ns;1;0ns;0.0
+ +-;A::foocpp::foocpp() (foox.cpp:42);0ns;1;0ns;0.0
+-;A::foocpp::func_a(int) (foox.cpp:54);0ns;1;0ns;0.0
- +-;A::foocpp::~foocpp [in-charge]() (foox.cpp:44);0ns;1;0ns;0.0
- +-;B::foocpp::foocpp[in-charge]() (foox.cpp:81);0ns;1;0ns;0.0
+ +-;A::foocpp::~foocpp() (foox.cpp:44);0ns;1;0ns;0.0
+ +-;B::foocpp::foocpp() (foox.cpp:81);0ns;1;0ns;0.0
+-;B::foocpp::func_b(int) (foox.cpp:91);0ns;1;0ns;0.0
- +-;B::foocpp::~foocpp [in-charge]() (foox.cpp:86);0ns;1;0ns;0.0
+ +-;B::foocpp::~foocpp() (foox.cpp:86);0ns;1;0ns;0.0
diff --git a/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testCallgraphView.ref b/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testCallgraphView.ref
index 98e450cf7f..731eaf06bf 100644
--- a/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testCallgraphView.ref
+++ b/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testCallgraphView.ref
@@ -1,8 +1,8 @@
Hierarchy;Name (location);Samples;Calls;Time/Call;%Time
+-;Summary;0;;;0.0
- +-;A::foocpp::foocpp[in-charge]();0;2;0ns;0.0
+ +-;A::foocpp::foocpp();0;2;0ns;0.0
| +-;parents;0;2;0ns;0.0
- | +-;B::foocpp::foocpp[in-charge]() (foox.cpp:82);0;1;0ns;0.0
+ | +-;B::foocpp::foocpp() (foox.cpp:82);0;1;0ns;0.0
| +-;main (foox.cpp:110);0;1;0ns;0.0
+-;A::foocpp::func_a(int);0;2;0ns;0.0
| +-;children;0;2;0ns;0.0
@@ -13,13 +13,13 @@ Hierarchy;Name (location);Samples;Calls;Time/Call;%Time
+-;A::foocpp::func_f(int);0;2;0ns;0.0
| +-;parents;0;2;0ns;0.0
| +-;A::foocpp::func_a(int) (foox.cpp:59);0;2;0ns;0.0
- +-;A::foocpp::~foocpp [in-charge]();0;2;0ns;0.0
+ +-;A::foocpp::~foocpp();0;2;0ns;0.0
| +-;parents;0;2;0ns;0.0
- | +-;B::foocpp::~foocpp [in-charge]() (foox.cpp:87);0;1;0ns;0.0
+ | +-;B::foocpp::~foocpp() (foox.cpp:87);0;1;0ns;0.0
| +-;main (foox.cpp:118);0;1;0ns;0.0
- +-;B::foocpp::foocpp[in-charge]();0;1;0ns;0.0
+ +-;B::foocpp::foocpp();0;1;0ns;0.0
| +-;children;0;1;0ns;0.0
- | | +-;A::foocpp::foocpp[in-charge]() (foox.cpp:42);0;1;0ns;0.0
+ | | +-;A::foocpp::foocpp() (foox.cpp:42);0;1;0ns;0.0
| +-;parents;0;1;0ns;0.0
| +-;main (foox.cpp:109);0;1;0ns;0.0
+-;B::foocpp::func_b(int);0;1;0ns;0.0
@@ -27,16 +27,16 @@ Hierarchy;Name (location);Samples;Calls;Time/Call;%Time
| | +-;A::foocpp::func_a(int) (foox.cpp:54);0;1;0ns;0.0
| +-;parents;0;1;0ns;0.0
| +-;main (foox.cpp:115);0;1;0ns;0.0
- +-;B::foocpp::~foocpp [in-charge]();0;1;0ns;0.0
+ +-;B::foocpp::~foocpp();0;1;0ns;0.0
| +-;children;0;1;0ns;0.0
- | | +-;A::foocpp::~foocpp [in-charge]() (foox.cpp:44);0;1;0ns;0.0
+ | | +-;A::foocpp::~foocpp() (foox.cpp:44);0;1;0ns;0.0
| +-;parents;0;1;0ns;0.0
| +-;main (foox.cpp:119);0;1;0ns;0.0
+-;main;0;0;;0.0
+-;children;0;6;0ns;0.0
- +-;A::foocpp::foocpp[in-charge]() (foox.cpp:42);0;1;0ns;0.0
+ +-;A::foocpp::foocpp() (foox.cpp:42);0;1;0ns;0.0
+-;A::foocpp::func_a(int) (foox.cpp:54);0;1;0ns;0.0
- +-;A::foocpp::~foocpp [in-charge]() (foox.cpp:44);0;1;0ns;0.0
- +-;B::foocpp::foocpp[in-charge]() (foox.cpp:81);0;1;0ns;0.0
+ +-;A::foocpp::~foocpp() (foox.cpp:44);0;1;0ns;0.0
+ +-;B::foocpp::foocpp() (foox.cpp:81);0;1;0ns;0.0
+-;B::foocpp::func_b(int) (foox.cpp:91);0;1;0ns;0.0
- +-;B::foocpp::~foocpp [in-charge]() (foox.cpp:86);0;1;0ns;0.0
+ +-;B::foocpp::~foocpp() (foox.cpp:86);0;1;0ns;0.0
diff --git a/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testFunctionSampleView.ref b/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testFunctionSampleView.ref
index 3a1e605f03..d8781b2176 100644
--- a/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testFunctionSampleView.ref
+++ b/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testFunctionSampleView.ref
@@ -1,10 +1,10 @@
Hierarchy;Name (location);Samples;Calls;Time/Call;%Time
+-;Summary;0;;;0.0
- +-;A::foocpp::foocpp[in-charge]();0;2;0ns;0.0
+ +-;A::foocpp::foocpp();0;2;0ns;0.0
+-;A::foocpp::func_a(int);0;2;0ns;0.0
+-;A::foocpp::func_f(int);0;2;0ns;0.0
- +-;A::foocpp::~foocpp [in-charge]();0;2;0ns;0.0
- +-;B::foocpp::foocpp[in-charge]();0;1;0ns;0.0
+ +-;A::foocpp::~foocpp();0;2;0ns;0.0
+ +-;B::foocpp::foocpp();0;1;0ns;0.0
+-;B::foocpp::func_b(int);0;1;0ns;0.0
- +-;B::foocpp::~foocpp [in-charge]();0;1;0ns;0.0
+ +-;B::foocpp::~foocpp();0;1;0ns;0.0
+-;main;0;0;;0.0
diff --git a/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testFunctionTimeView.ref b/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testFunctionTimeView.ref
index 12b785fa54..1445068210 100644
--- a/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testFunctionTimeView.ref
+++ b/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testFunctionTimeView.ref
@@ -1,10 +1,10 @@
Hierarchy;Name (location);Time;Calls;Time/Call;%Time
+-;Summary;0ns;;;0.0
- +-;A::foocpp::foocpp[in-charge]();0ns;2;0ns;0.0
+ +-;A::foocpp::foocpp();0ns;2;0ns;0.0
+-;A::foocpp::func_a(int);0ns;2;0ns;0.0
+-;A::foocpp::func_f(int);0ns;2;0ns;0.0
- +-;A::foocpp::~foocpp [in-charge]();0ns;2;0ns;0.0
- +-;B::foocpp::foocpp[in-charge]();0ns;1;0ns;0.0
+ +-;A::foocpp::~foocpp();0ns;2;0ns;0.0
+ +-;B::foocpp::foocpp();0ns;1;0ns;0.0
+-;B::foocpp::func_b(int);0ns;1;0ns;0.0
- +-;B::foocpp::~foocpp [in-charge]();0ns;1;0ns;0.0
+ +-;B::foocpp::~foocpp();0ns;1;0ns;0.0
+-;main;0ns;0;;0.0
diff --git a/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testSampleView.ref b/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testSampleView.ref
index f430b089d3..92d6dcef41 100644
--- a/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testSampleView.ref
+++ b/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testSampleView.ref
@@ -1,11 +1,11 @@
Hierarchy;Name (location);Samples;Calls;Time/Call;%Time
+-;Summary;0;;;0.0
+-;foox.cpp;0;;;0.0
- +-;A::foocpp::foocpp[in-charge]();0;2;0ns;0.0
+ +-;A::foocpp::foocpp();0;2;0ns;0.0
+-;A::foocpp::func_a(int);0;2;0ns;0.0
+-;A::foocpp::func_f(int);0;2;0ns;0.0
- +-;A::foocpp::~foocpp [in-charge]();0;2;0ns;0.0
- +-;B::foocpp::foocpp[in-charge]();0;1;0ns;0.0
+ +-;A::foocpp::~foocpp();0;2;0ns;0.0
+ +-;B::foocpp::foocpp();0;1;0ns;0.0
+-;B::foocpp::func_b(int);0;1;0ns;0.0
- +-;B::foocpp::~foocpp [in-charge]();0;1;0ns;0.0
+ +-;B::foocpp::~foocpp();0;1;0ns;0.0
+-;main;0;0;;0.0
diff --git a/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testTimeView.ref b/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testTimeView.ref
index ec1388308d..eed6086b75 100644
--- a/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testTimeView.ref
+++ b/gprof/org.eclipse.linuxtools.gprof.test/foocpp_gprof_input/testTimeView.ref
@@ -1,11 +1,11 @@
Hierarchy;Name (location);Time;Calls;Time/Call;%Time
+-;Summary;0ns;;;0.0
+-;foox.cpp;0ns;;;0.0
- +-;A::foocpp::foocpp[in-charge]();0ns;2;0ns;0.0
+ +-;A::foocpp::foocpp();0ns;2;0ns;0.0
+-;A::foocpp::func_a(int);0ns;2;0ns;0.0
+-;A::foocpp::func_f(int);0ns;2;0ns;0.0
- +-;A::foocpp::~foocpp [in-charge]();0ns;2;0ns;0.0
- +-;B::foocpp::foocpp[in-charge]();0ns;1;0ns;0.0
+ +-;A::foocpp::~foocpp();0ns;2;0ns;0.0
+ +-;B::foocpp::foocpp();0ns;1;0ns;0.0
+-;B::foocpp::func_b(int);0ns;1;0ns;0.0
- +-;B::foocpp::~foocpp [in-charge]();0ns;1;0ns;0.0
+ +-;B::foocpp::~foocpp();0ns;1;0ns;0.0
+-;main;0ns;0;;0.0
diff --git a/gprof/org.eclipse.linuxtools.gprof.test/src/org/eclipse/linuxtools/gprof/test/STJunitUtils.java b/gprof/org.eclipse.linuxtools.gprof.test/src/org/eclipse/linuxtools/gprof/test/STJunitUtils.java
index 09d1d392ff..f5768fdb10 100644
--- a/gprof/org.eclipse.linuxtools.gprof.test/src/org/eclipse/linuxtools/gprof/test/STJunitUtils.java
+++ b/gprof/org.eclipse.linuxtools.gprof.test/src/org/eclipse/linuxtools/gprof/test/STJunitUtils.java
@@ -49,7 +49,7 @@ public class STJunitUtils {
STDataViewersCSVExporter exporter = new STDataViewersCSVExporter(view.getSTViewer());
exporter.exportTo(dumpFullFileName, new NullProgressMonitor());
// compare with ref
- compareIgnoreEOL(dumpFullFileName, refFullFileName, true);
+ compareCSVIgnoreEOL(dumpFullFileName, refFullFileName, true);
}
/**
@@ -73,7 +73,7 @@ public class STJunitUtils {
else {
System.out.println(message + "... successful");
}
- // delete dump only for sucessful tests
+ // delete dump only for successful tests
if (equals && deleteDumpFileIfOk)
new File(dumpFile).delete();
}catch (FileNotFoundException _) {
@@ -98,30 +98,90 @@ public class STJunitUtils {
public static boolean compareIgnoreEOL(String dumpFile, String refFile, boolean deleteDumpFileIfOk) {
String message = "Comparing ref file ("+refFile+ ")and dump file (" +
dumpFile+")";
+ boolean equals = false;
+ try {
+ LineNumberReader is1 = new LineNumberReader(new FileReader(dumpFile));
+ LineNumberReader is2 = new LineNumberReader(new FileReader(refFile));
+ do {
+ String line1 = is1.readLine();
+ String line2 = is2.readLine();
+ if (line1 == null) {
+ if (line2 == null) {
+ equals = true;
+ }
+ break;
+ } else if (line2 == null || !line1.equals(line2)) {
+ break;
+ }
+ } while (true);
+
+ if (!equals) {
+ junit.framework.Assert.assertEquals(message + ": not correspond ", true, false);
+ }
+
+ is1.close();
+ is2.close();
+ // delete dump only for successful tests
+ if (equals && deleteDumpFileIfOk) {
+ new File(dumpFile).delete();
+ }
+ }catch (FileNotFoundException _) {
+ message += "... FAILED: One of these files may not exist";
+ junit.framework.Assert.assertNull(message, _);
+ }
+ catch (Exception _) {
+ message += ": exception raised ... FAILED";
+ junit.framework.Assert.assertNull(message, _);
+ }
+ return equals;
+ }
+
+ /**
+ * Utility method to compare exported CSV files
+ * @param dumpFile
+ * @param refFile
+ * @return
+ */
+ public static boolean compareCSVIgnoreEOL(String dumpFile, String refFile, boolean deleteDumpFileIfOk) {
+ String message = "Comparing ref file ("+refFile+ ")and dump file (" +
+ dumpFile+")";
boolean equals = false;
+ String str = "[in-charge]"; // this string can be dumped according to binutils version installed on local machine
+
try {
LineNumberReader is1 = new LineNumberReader(new FileReader(dumpFile));
LineNumberReader is2 = new LineNumberReader(new FileReader(refFile));
do {
String line1 = is1.readLine();
String line2 = is2.readLine();
+ int length = str.length();
if (line1 == null) {
if (line2 == null) {
equals = true;
}
break;
+ } else if (line1.contains(str)){
+ int idx = line1.indexOf("[in-charge]");
+ char c = line1.charAt(idx -1);
+ if (c == ' ' ){
+ idx--;
+ length++;
+ }
+ line1 = line1.substring(0, idx) + line1.substring(idx+length, line1.length());
+ if (!line1.equals(line2))
+ break;
} else if (line2 == null || !line1.equals(line2)) {
break;
- }
+ }
} while (true);
-
+
if (!equals) {
junit.framework.Assert.assertEquals(message + ": not correspond ", true, false);
}
is1.close();
is2.close();
- // delete dump only for sucessful tests
+ // delete dump only for successful tests
if (equals && deleteDumpFileIfOk) {
new File(dumpFile).delete();
}

Back to the top