[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[DejaGnu] patch for xml capabilities
From: |
Matthew Bemis |
Subject: |
[DejaGnu] patch for xml capabilities |
Date: |
Thu, 25 Apr 2002 14:53:04 -0400 |
Rob,
this is a xml feature I added to dejagnu.
I have a small todo list for this. feature
write some documentation for it.( -x with runtest produces the xml )
add expect output to dejagnu itself in tunit.exp( this is causing a
sticking point for the rest of the logging it doesn't utilize
expect_out(buffer))
add the features that gdb wants.
but this is a start.
let me know if you can add this to dejagnu
I have tested it with the following baselines with no errors on alpha
and intel
basic-gcc_2.95.3 and basic-gcc_3.0.4
thanks
--
Matt Bemis
Alpha Linux Group
University of New Hampshire
diff -urN latest/lib/framework.exp latest-xml/lib/framework.exp
--- latest/lib/framework.exp Sun Feb 18 00:12:07 2001
+++ latest-xml/lib/framework.exp Thu Apr 25 13:49:51 2002
@@ -30,6 +30,32 @@
catch "exec mail -s \"$subject\" $to < $file"
}
}
+#
+# Check for xml output flag or environment variable
+#
+proc check_xml {} {
+ global env
+ set x "RUNTESTFLAGS"
+ return [format "%s" $env($x)]
+}
+
+#
+# Insert DTD for xml format checking
+#
+proc insertdtd {} {
+ xml_output "<!DOCTYPE testsuite \[
+<!-- testsuite.dtd -->
+<!ELEMENT testsuite (test | summary)+>
+<!ELEMENT test (log, result, name, prms_id )>
+ <!ELEMENT log (#PCDATA)>
+ <!ELEMENT result (#PCDATA)>
+ <!ELEMENT name (#PCDATA)>
+ <!ELEMENT prms_id (#PCDATA)>
+ <!ELEMENT summary (result, description, total)>
+ <!ELEMENT description (#PCDATA)>
+ <!ELEMENT total (#PCDATA)>
+\]>"
+}
#
# Open the output logs
@@ -38,12 +64,20 @@
global outdir
global tool
global sum_file
-
+ global xml_file
+ global xml
if { ${tool} == "" } {
set tool testrun
}
catch "exec rm -f $outdir/$tool.sum"
set sum_file [open "$outdir/$tool.sum" w]
+ if { $xml } {
+ catch "exec rm -f $outdir/$tool.xml"
+ set xml_file [open "$outdir/$tool.xml" w]
+ xml_output "<?xml version=\"1.0\"?>"
+ insertdtd
+ xml_output "<testsuite>"
+ }
catch "exec rm -f $outdir/$tool.log"
log_file -a "$outdir/$tool.log"
verbose "Opening log files in $outdir"
@@ -58,7 +92,12 @@
#
proc close_logs { } {
global sum_file
-
+ global xml
+ global xml_file
+ if { $xml } {
+ xml_output "</testsuite>"
+ catch "close $xml_file"
+ }
catch "close $sum_file"
}
@@ -283,6 +322,13 @@
}
}
+proc xml_output { message } {
+ global xml_file
+ if { $xml_file != "" } {
+ puts $xml_file "$message"
+ }
+}
+
#
# Reset a few counters.
#
@@ -336,6 +382,8 @@
proc log_summary { args } {
global tool
global sum_file
+ global xml_file
+ global xml
global exit_status
global mail_logs
global outdir
@@ -392,6 +440,13 @@
set val $test_counts($x,$which);
if { $val > 0 } {
set mess "# of $test_counts($x,name)";
+ if { $xml } {
+ xml_output " <summary>"
+ xml_output " <result>$x</result>"
+ xml_output " <description>$mess</description>"
+ xml_output " <total>$val</total>"
+ xml_output " </summary>"
+ }
if { [string length $mess] < 24 } {
append mess "\t";
}
@@ -405,6 +460,7 @@
#
proc cleanup {} {
global sum_file
+ global xml_file
global exit_status
global done_list
global subdir
@@ -563,6 +619,7 @@
#
proc record_test { type message args } {
global exit_status
+ global xml
global prms_id bug_id
global xfail_flag xfail_prms
global errcnt warncnt
@@ -588,7 +645,21 @@
}
incr_count $type;
-
+ if { $xml } {
+ global errorInfo
+ set error ""
+ if [info exists errorInfo] {
+ set error $errorInfo
+ }
+ global expect_out
+ set output ""
+ xml_output " <test>"
+ xml_output " <log>$output</log>"
+ xml_output " <result>$type</result>"
+ xml_output " <name>$message</name>"
+ xml_output " <prms_id>$prms_id</prms_id>"
+ xml_output " </test>"
+ }
switch $type {
PASS {
if $prms_id {
diff -urN latest/runtest.exp latest-xml/runtest.exp
--- latest/runtest.exp Sun Oct 7 00:10:28 2001
+++ latest-xml/runtest.exp Thu Apr 25 10:02:11 2002
@@ -52,6 +52,8 @@
set xfail_flag 0
set xfail_prms 0
set sum_file "" ;# name of the file that contains the
summary log
+set xml_file "" ;# name of the xml output if requested
+set xml 0 ;# flag for requesting xml
output
set base_dir "" ;# the current working directory
set logname "" ;# the users login name
set prms_id 0 ;# GNATS prms id number
@@ -158,6 +160,8 @@
set newline 0
} elseif { [lindex $args $i] == "-log" } {
set logfile 1
+ } elseif { [lindex $args $i] == "-x" } {
+ set xml 1
} elseif { [string index [lindex $args $i] 0] == "-" } {
clone_output "ERROR: verbose: illegal argument: [lindex
$args $i]"
return
@@ -1157,6 +1161,11 @@
set tool $optarg
verbose "Testing $tool"
continue
+ }
+ "--x*" {
+ set xml 1
+ verbose "XML logging turned on"
+ continue
}
"--he*" { # (--help) help text
diff -urN latest/lib/framework.exp latest-xml/lib/framework.exp
--- latest/lib/framework.exp Sun Feb 18 00:12:07 2001
+++ latest-xml/lib/framework.exp Thu Apr 25 13:49:51 2002
@@ -30,6 +30,32 @@
catch "exec mail -s \"$subject\" $to < $file"
}
}
+#
+# Check for xml output flag or environment variable
+#
+proc check_xml {} {
+ global env
+ set x "RUNTESTFLAGS"
+ return [format "%s" $env($x)]
+}
+
+#
+# Insert DTD for xml format checking
+#
+proc insertdtd {} {
+ xml_output "<!DOCTYPE testsuite \[
+<!-- testsuite.dtd -->
+<!ELEMENT testsuite (test | summary)+>
+<!ELEMENT test (log, result, name, prms_id )>
+ <!ELEMENT log (#PCDATA)>
+ <!ELEMENT result (#PCDATA)>
+ <!ELEMENT name (#PCDATA)>
+ <!ELEMENT prms_id (#PCDATA)>
+ <!ELEMENT summary (result, description, total)>
+ <!ELEMENT description (#PCDATA)>
+ <!ELEMENT total (#PCDATA)>
+\]>"
+}
#
# Open the output logs
@@ -38,12 +64,20 @@
global outdir
global tool
global sum_file
-
+ global xml_file
+ global xml
if { ${tool} == "" } {
set tool testrun
}
catch "exec rm -f $outdir/$tool.sum"
set sum_file [open "$outdir/$tool.sum" w]
+ if { $xml } {
+ catch "exec rm -f $outdir/$tool.xml"
+ set xml_file [open "$outdir/$tool.xml" w]
+ xml_output "<?xml version=\"1.0\"?>"
+ insertdtd
+ xml_output "<testsuite>"
+ }
catch "exec rm -f $outdir/$tool.log"
log_file -a "$outdir/$tool.log"
verbose "Opening log files in $outdir"
@@ -58,7 +92,12 @@
#
proc close_logs { } {
global sum_file
-
+ global xml
+ global xml_file
+ if { $xml } {
+ xml_output "</testsuite>"
+ catch "close $xml_file"
+ }
catch "close $sum_file"
}
@@ -283,6 +322,13 @@
}
}
+proc xml_output { message } {
+ global xml_file
+ if { $xml_file != "" } {
+ puts $xml_file "$message"
+ }
+}
+
#
# Reset a few counters.
#
@@ -336,6 +382,8 @@
proc log_summary { args } {
global tool
global sum_file
+ global xml_file
+ global xml
global exit_status
global mail_logs
global outdir
@@ -392,6 +440,13 @@
set val $test_counts($x,$which);
if { $val > 0 } {
set mess "# of $test_counts($x,name)";
+ if { $xml } {
+ xml_output " <summary>"
+ xml_output " <result>$x</result>"
+ xml_output " <description>$mess</description>"
+ xml_output " <total>$val</total>"
+ xml_output " </summary>"
+ }
if { [string length $mess] < 24 } {
append mess "\t";
}
@@ -405,6 +460,7 @@
#
proc cleanup {} {
global sum_file
+ global xml_file
global exit_status
global done_list
global subdir
@@ -563,6 +619,7 @@
#
proc record_test { type message args } {
global exit_status
+ global xml
global prms_id bug_id
global xfail_flag xfail_prms
global errcnt warncnt
@@ -588,7 +645,21 @@
}
incr_count $type;
-
+ if { $xml } {
+ global errorInfo
+ set error ""
+ if [info exists errorInfo] {
+ set error $errorInfo
+ }
+ global expect_out
+ set output ""
+ xml_output " <test>"
+ xml_output " <log>$output</log>"
+ xml_output " <result>$type</result>"
+ xml_output " <name>$message</name>"
+ xml_output " <prms_id>$prms_id</prms_id>"
+ xml_output " </test>"
+ }
switch $type {
PASS {
if $prms_id {
diff -urN latest/runtest.exp latest-xml/runtest.exp
--- latest/runtest.exp Sun Oct 7 00:10:28 2001
+++ latest-xml/runtest.exp Thu Apr 25 10:02:11 2002
@@ -52,6 +52,8 @@
set xfail_flag 0
set xfail_prms 0
set sum_file "" ;# name of the file that contains the summary
log
+set xml_file "" ;# name of the xml output if requested
+set xml 0 ;# flag for requesting xml output
set base_dir "" ;# the current working directory
set logname "" ;# the users login name
set prms_id 0 ;# GNATS prms id number
@@ -158,6 +160,8 @@
set newline 0
} elseif { [lindex $args $i] == "-log" } {
set logfile 1
+ } elseif { [lindex $args $i] == "-x" } {
+ set xml 1
} elseif { [string index [lindex $args $i] 0] == "-" } {
clone_output "ERROR: verbose: illegal argument: [lindex $args
$i]"
return
@@ -1157,6 +1161,11 @@
set tool $optarg
verbose "Testing $tool"
continue
+ }
+ "--x*" {
+ set xml 1
+ verbose "XML logging turned on"
+ continue
}
"--he*" { # (--help) help text
- [DejaGnu] patch for xml capabilities,
Matthew Bemis <=