aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Elliston <bje@gnu.org>2008-04-07 14:48:21 +1000
committerBen Elliston <bje@gnu.org>2008-04-07 14:49:27 +1000
commit7cd597d12ffd161206a468963fb791ffa833086e (patch)
tree0848199f286311055864ea8b82634e34a6ad7b78
parent7366d4887cca6839218272fc298cd1a1fb708b39 (diff)
downloaddejagnu-origin/master.zip
dejagnu-origin/master.tar.gz
dejagnu-origin/master.tar.bz2
Make the testsuite work better.origin/masterorigin/HEAD
* Makefile.am (RUNTESTDEFAULTFLAGS): Add RUNTEST=$(RUNTEST). * Makefile.in: Regenerate. * dejagnu.exp (host_execute): Improve regexp matching. * testsuite/libdejagnu/unit.cc: C++ fixes.
-rw-r--r--ChangeLog7
-rw-r--r--Makefile.am2
-rw-r--r--Makefile.in2
-rwxr-xr-xlib/dejagnu.exp18
-rw-r--r--testsuite/libdejagnu/unit.cc46
5 files changed, 48 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index b3365d4..784e6c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2008-04-06 Daniel Jacobowitz <drow@false.org>
+ * Makefile.am (RUNTESTDEFAULTFLAGS): Add RUNTEST=$(RUNTEST).
+ * Makefile.in: Regenerate.
+ * dejagnu.exp (host_execute): Improve regexp matching.
+ * testsuite/libdejagnu/unit.cc: C++ fixes.
+
+2008-04-06 Daniel Jacobowitz <drow@false.org>
+
* lib/utils.exp (diff): Open both files as binary.
2008-04-06 Daniel Jacobowitz <dan@codesourcery.com>
diff --git a/Makefile.am b/Makefile.am
index 0e51659..c027bcd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -195,7 +195,7 @@ TESTSUITE_FILES = \
testsuite/libdejagnu/tunit.exp
RUNTEST = ${top_srcdir}/runtest
-RUNTESTDEFAULTFLAGS = --srcdir $(srcdir)/testsuite
+RUNTESTDEFAULTFLAGS = --srcdir $(srcdir)/testsuite RUNTEST=$(RUNTEST)
AM_CXXFLAGS = -I$(top_srcdir) -g
check_PROGRAMS = unit
diff --git a/Makefile.in b/Makefile.in
index 2956ee8..2ff7f25 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -396,7 +396,7 @@ TESTSUITE_FILES = \
testsuite/libdejagnu/tunit.exp
RUNTEST = ${top_srcdir}/runtest
-RUNTESTDEFAULTFLAGS = --srcdir $(srcdir)/testsuite
+RUNTESTDEFAULTFLAGS = --srcdir $(srcdir)/testsuite RUNTEST=$(RUNTEST)
AM_CXXFLAGS = -I$(top_srcdir) -g
unit_SOURCES = testsuite/libdejagnu/unit.cc
diff --git a/lib/dejagnu.exp b/lib/dejagnu.exp
index a293f2f..a764aa5 100755
--- a/lib/dejagnu.exp
+++ b/lib/dejagnu.exp
@@ -133,49 +133,50 @@ proc host_execute {args} {
# test case.
# spawn -noecho -open [open "|./${executable}" "r"]
spawn -noecho "./${executable}" ${params}
+ set prefix "\[^\r\n\]*"
expect {
- -re "\[0-9\]\[0-9\]:..:..:${text}\r\n" {
+ -re "^$prefix\[0-9\]\[0-9\]:..:..:${text}*\r\n" {
regsub "\[\n\r\t\]*NOTE: $text\r\n" $expect_out(0,string) "" output
verbose "$output" 3
set timetol 0
exp_continue
}
- -re "NOTE:${text}*" {
+ -re "^$prefix\tNOTE:${text}*" {
regsub "\[\n\r\t\]*NOTE: $text\r\n" $expect_out(0,string) "" output
set output [string range $output 6 end]
verbose "$output" 2
set timetol 0
exp_continue
}
- -re "PASSED:${text}*" {
+ -re "^$prefix\tPASSED:${text}*" {
regsub "\[\n\r\t\]*PASSED: $text\r\n" $expect_out(0,string) "" output
set output [string range $output 8 end]
pass "$output"
set timetol 0
exp_continue
}
- -re "FAILED:${text}*" {
+ -re "^$prefix\tFAILED:${text}*" {
regsub "\[\n\r\t\]*FAILED: $text\r\n" $expect_out(0,string) "" output
set output [string range $output 8 end]
fail "$output"
set timetol 0
exp_continue
}
- -re "UNTESTED:${text}*" {
+ -re "^$prefix\tUNTESTED:${text}*" {
regsub "\[\n\r\t\]*TESTED: $text\r\n" $expect_out(0,string) "" output
set output [string range $output 8 end]
untested "$output"
set timetol 0
exp_continue
}
- -re "UNRESOLVED:${text}*" {
+ -re "^$prefix\tUNRESOLVED:${text}*" {
regsub "\[\n\r\t\]*UNRESOLVED: $text\r\n" $expect_out(0,string) "" output
set output [string range $output 8 end]
unresolved "$output"
set timetol 0
exp_continue
}
- -re "Totals" {
+ -re "^Totals" {
verbose "All done" 2
}
eof {
@@ -193,6 +194,9 @@ proc host_execute {args} {
return "Timed out executing test case"
}
}
+ -re "^$prefix\r\n" {
+ exp_continue
+ }
}
# force a close of the executable to be safe.
diff --git a/testsuite/libdejagnu/unit.cc b/testsuite/libdejagnu/unit.cc
index d6e08a9..841d6f0 100644
--- a/testsuite/libdejagnu/unit.cc
+++ b/testsuite/libdejagnu/unit.cc
@@ -22,6 +22,7 @@
#include <regex.h>
#include <string>
#include <fstream>
+#include <sstream>
#include <set>
#include <dejagnu.h>
@@ -56,17 +57,14 @@ main (int argc, char *argv[])
{
regex_t regex_pat;
outstate = os1;
+ stringstream strbuf;
+ streambuf *pbuf;
// Replace the output buffer for cout, so we can examine it to see
// what was displayed. Otherwise, there is no way we can test the
// logging functions completely.
- char buf[5120];
-#ifdef __STDC_HOSTED__
- cout.rdbuf ()->pubsetbuf (buf, 5120);
-#else
- cout.rdbuf ()->setbuf (buf, 5120);
-#endif
-
+ pbuf = cout.rdbuf ();
+
testClass1.tname = "testType1";
testClass1.tnum = 1;
testClass2.tname = "testType2";
@@ -75,50 +73,63 @@ main (int argc, char *argv[])
testClass3.tnum = 3;
// Test the pass message.
+ cout.rdbuf (strbuf.rdbuf ());
+ strbuf.str ("");
test.pass ("bogus pass message for testing");
outstate = os2;
- if (strncmp (buf, "\tPAS: bogus pass message", 22) == 0)
+ cout.rdbuf (pbuf);
+ if (strncmp (strbuf.str().c_str(), "\tPAS: bogus pass message", 22) == 0)
runtest.pass ("Pass message");
else
runtest.fail ("Pass message");
// Test the fail message.
+ cout.rdbuf (strbuf.rdbuf ());
+ strbuf.str ("");
outstate = os1;
test.fail ("bogus fail message for testing");
- cout.flush ();
+ cout.rdbuf (pbuf);
outstate = os2;
- if (strncmp (buf, "\tFAI: bogus fail message", 22) == 0)
+ if (strncmp (strbuf.str().c_str(), "\tFAI: bogus fail message", 22) == 0)
runtest.pass ("Fail message");
else
runtest.fail ("Fail message");
// Test the untested message.
+ cout.rdbuf (strbuf.rdbuf ());
+ strbuf.str ("");
outstate = os1;
test.untested ("bogus untested message for testing");
- cout.flush ();
+ cout.rdbuf (pbuf);
outstate = os2;
- if (strncmp (buf, "\tUNT: bogus untested message", 21) == 0) {
+ if (strncmp (strbuf.str().c_str(), "\tUNT: bogus untested message", 21) == 0) {
runtest.pass ("Untested message");
} else {
runtest.fail ("Untested message");
}
// Test the unresolved message.
+ cout.rdbuf (strbuf.rdbuf ());
+ strbuf.str ("");
outstate = os1;
test.unresolved ("bogus unresolved message for testing");
- cout.flush ();
+ cout.rdbuf (pbuf);
outstate = os2;
- if (strncmp (buf, "\tUNR: bogus unresolved message", 21) == 0)
+ if (strncmp (strbuf.str().c_str(), "\tUNR: bogus unresolved message", 21) == 0)
runtest.pass ("Unresolved message");
else
runtest.fail ("Unresolved message");
// Make sure we got everything in the totals.
+ cout.rdbuf (strbuf.rdbuf ());
+ strbuf.str ("");
regcomp (&regex_pat,
- "\r\n\t#passed.*#failed.*#untested.*#unresolved",
- REG_NOSUB | REG_NEWLINE);
+ "\t#passed.*#real failed.*#untested.*#unresolved",
+ REG_NOSUB);
- if (regexec (&regex_pat, buf, 0, (regmatch_t *) 0, 0))
+ test.totals ();
+ cout.rdbuf (pbuf);
+ if (regexec (&regex_pat, strbuf.str().c_str(), 0, (regmatch_t *) 0, 0) == 0)
runtest.pass ("Totals message");
else
runtest.fail ("Totals message");
@@ -126,4 +137,3 @@ main (int argc, char *argv[])
return 0;
}
-