diff options
author | Rob Savoye <rob@senecass.com> | 2020-05-18 13:24:55 -0600 |
---|---|---|
committer | Rob Savoye <rob@senecass.com> | 2020-05-18 13:24:55 -0600 |
commit | 3fee8dd10370508f290479a3543d16e35898d163 (patch) | |
tree | 566e424b32355a64a3fd122f9a11728a288074b2 | |
parent | 6b5461887853dd4b174a45c36eee819a730b92ec (diff) | |
download | dejagnu-3fee8dd10370508f290479a3543d16e35898d163.zip dejagnu-3fee8dd10370508f290479a3543d16e35898d163.tar.gz dejagnu-3fee8dd10370508f290479a3543d16e35898d163.tar.bz2 |
fix outfile string conversion
-rw-r--r-- | contrib/database/sum2xml.sh | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/contrib/database/sum2xml.sh b/contrib/database/sum2xml.sh new file mode 100644 index 0000000..c026d53 --- /dev/null +++ b/contrib/database/sum2xml.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +# sum2xml.sh -- convert a .sum file into XML. +# +# Copyright (C) 2016,2019, 2020 Free Software Foundation, Inc. +# +# This file is part of DejaGnu. +# +# DejaGnu is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + + +if test x"$1" = x; then + outfile="/tmp/testrun.xml" + infile="/tmp/testrun.sum" +else + outfile=$(echo $1 | sed -e 's/.sum/.xml'/) + infile=$1 +fi + +# Where to put the output file +if test x"$2" = x; then + outfile="$outfile" +else + outfile="/tmp/$outfile" +fi + +if test ! -e "$infile"; then + echo "ERROR: no input file specified!" + exit +fi + +exit + +# If compressed, uncompress it +type=$(file "$infile") +count=$(echo "$type" | grep -c "XZ compressed data") +if test "$count" -gt 0; then + decomp="xz -d" + comp="xz" +else + count=$(echo "$type" | grep -c "XZ compressed data") + if test "$count" -gt 0; then + decomp="gzip" + comp="gunzip" + fi +fi + +# +cat <<EOF > "$outfile" +<?xml version="1.0"?> +<!DOCTYPE testsuite [ +<!-- testsuite.dtd --> +<!ELEMENT testsuite (test | summary)+> +<!ELEMENT test (input, output, result, name, prms_id )> + <!ELEMENT input (#PCDATA)> + <!ELEMENT output (#PCDATA)> + <!ELEMENT result (#PCDATA)> + <!ELEMENT name (#PCDATA)> + <!ELEMENT prms_id (#PCDATA)> + <!ELEMENT summary (result, description, total)> + <!ELEMENT description (#PCDATA)> + <!ELEMENT total (#PCDATA)> +]> +EOF + +# Write the opening tag for the test results +echo "<testsuite>" >> "$outfile" + +${decomp} "$infile" +infile=$(echo "$infile" | sed -e 's:\.xz::' -e 's:\.gz::') + +while read -r line +do + # ignore blank lines + if test x"${line}" = x; then + continue + fi + # # ignore the test case name + # if test `echo ${line} | grep -c Running` -gt 0; then + # continue + # fi + # ignore the summary, we get this via SQL later + if test "$(echo "$line" | grep -c Summary)" -gt 0; then + break + fi + valid=$(echo "$line" | grep -E -c 'PASS|FAIL|UNTESTED|UNSUPPORTED|UNRESOLVED') + if test "$valid" -eq 0; then + continue + fi + echo -n "." + { echo "<test>"; echo " <input></input>"; echo " <output></output>"; } >> "$outfile" + result=${line/: *//} + echo " <result>${result}</result>" >> "$outfile" + name=${line/^[A-Z]*: /} + { echo " <name>${name}</name>"; echo " <prms_id></prms_id>"; echo "</test>"; } >> "$outfile" +done < "$infile" + +# Write the closing tag for the test results +echo "</testsuite>" >> "$outfile" + +# compress the file again +${comp} "$infile" + |