From 3fee8dd10370508f290479a3543d16e35898d163 Mon Sep 17 00:00:00 2001 From: Rob Savoye Date: Mon, 18 May 2020 13:24:55 -0600 Subject: fix outfile string conversion --- contrib/database/sum2xml.sh | 106 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 contrib/database/sum2xml.sh 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 < "$outfile" + + + + + + + + + + + + +]> +EOF + +# Write the opening tag for the test results +echo "" >> "$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 ""; echo " "; echo " "; } >> "$outfile" + result=${line/: *//} + echo " ${result}" >> "$outfile" + name=${line/^[A-Z]*: /} + { echo " ${name}"; echo " "; echo ""; } >> "$outfile" +done < "$infile" + +# Write the closing tag for the test results +echo "" >> "$outfile" + +# compress the file again +${comp} "$infile" + -- cgit v1.1