Blame contrib/mysql/make-datafile.sh

Packit 62fe53
#!/bin/bash
Packit 62fe53
Packit 62fe53
# make-datafile.sh -- export data from MySQL testing database.
Packit 62fe53
#
Packit 62fe53
# Copyright (C) 2016 Free Software Foundation, Inc.
Packit 62fe53
#
Packit 62fe53
# This file is part of DejaGnu.
Packit 62fe53
#
Packit 62fe53
# DejaGnu is free software; you can redistribute it and/or modify it
Packit 62fe53
# under the terms of the GNU General Public License as published by
Packit 62fe53
# the Free Software Foundation; either version 3 of the License, or
Packit 62fe53
# (at your option) any later version.
Packit 62fe53
Packit 62fe53
# This script executes a series of SQL calls to our testing database,
Packit 62fe53
# and makes a data file for gnuplot.
Packit 62fe53
Packit 62fe53
if test $# -eq 0; then
Packit 62fe53
  echo "ERROR: no testrun numbers specified!"
Packit 62fe53
  exit
Packit 62fe53
fi
Packit 62fe53
Packit 62fe53
# These are required to access the database
Packit 62fe53
user="USER"
Packit 62fe53
passwd="PASSWD"
Packit 62fe53
outfile="testrun.data"
Packit 62fe53
Packit 62fe53
# Check the environment for the database access information
Packit 62fe53
if test x"${CBUILD_DBUSER}" != x; then
Packit 62fe53
    user="${CBUILD_DBUSER}"
Packit 62fe53
fi
Packit 62fe53
if test x"${CBUILD_DBPASSWD}" != x; then
Packit 62fe53
    passwd="${CBUILD_DBPASSWD}"
Packit 62fe53
fi
Packit 62fe53
Packit 62fe53
# Create the output file
Packit 62fe53
rm -f ${outfile}
Packit 62fe53
Packit 62fe53
# Add a header to make the file human readable
Packit 62fe53
echo "# date tool version arch total PASS FAIL UNSUPPORTED UNTESTED UNRESOLVED XPASS XFAIL" > ${outfile}
Packit 62fe53
Packit 62fe53
machines=$(mysql -u"$user" -p"$passwd" --local -e "SELECT DISTINCT(build_machine) FROM dejagnu.testruns" | sed -e 's/build_machine//' | tr '\n' ' ')
Packit 62fe53
echo "Build machines are: ${machines}"
Packit 62fe53
Packit 62fe53
tools="gcc g++ gfortran libstdc++ objc"
Packit 62fe53
echo "Tools are: ${tools}"
Packit 62fe53
Packit 62fe53
for testrun in "$@"; do
Packit 62fe53
  # Get the build info
Packit 62fe53
  binfo=$(mysql -u"$user" -p"$passwd" --local -e "SELECT tool,arch,date,version,branch,build_machine FROM dejagnu.testruns WHERE testrun=${testrun}" | tail -1)
Packit 62fe53
 
Packit 62fe53
  # Get rid of the embedded newlines
Packit 62fe53
  binfo=$(echo "$binfo" | tr -d '\n')
Packit 62fe53
Packit 62fe53
  # Split the query result into fields
Packit 62fe53
  tool=$(echo "$binfo" | cut -d ' ' -f 1)
Packit 62fe53
  arch=$(echo "$binfo" | cut -d ' ' -f 2)
Packit 62fe53
  date=$(echo "$binfo" | cut -d ' ' -f 3)
Packit 62fe53
  version=$(echo "$binfo" | cut -d ' ' -f 5)
Packit 62fe53
  build_machine=$(echo "$binfo" | cut -d ' ' -f 7)
Packit 62fe53
 
Packit 62fe53
  # Get the test counts
Packit 62fe53
#  total=`mysql -u"$user" -p${passwd} -e "SELECT count(*) FROM dejagnu.test WHERE result!=''" | tail -1`
Packit 62fe53
  passes=$(mysql -u"$user" -p"$passwd" --local -e "SELECT count(*) FROM dejagnu.test WHERE testrun=${testrun} AND result='PASS'" | tail -1)
Packit 62fe53
  fails=$(mysql -u"$user" -p"$passwd" --local -e "SELECT count(*) FROM dejagnu.test WHERE testrun=${testrun} AND result='FAIL'" | tail -1)
Packit 62fe53
  xpasses=$(mysql -u"$user" -p"$passwd" --local -e "SELECT count(*) FROM dejagnu.test WHERE testrun=${testrun} AND result='XPASS'" | tail -1)
Packit 62fe53
  xfails=$(mysql -u"$user" -p"$passwd" --local -e "SELECT count(*) FROM dejagnu.test WHERE testrun=${testrun} AND result='XFAIL'" | tail -1)
Packit 62fe53
  untested=$(mysql -u"$user" -p"$passwd" --local -e "SELECT count(*) FROM dejagnu.test WHERE testrun=${testrun} AND result='UNTESTED'" | tail -1)
Packit 62fe53
  unsupported=$(mysql -u"$user" -p"$passwd" --local -e "SELECT count(*) FROM dejagnu.test WHERE testrun=${testrun} AND result='UNSUPPORTED'" | tail -1)
Packit 62fe53
  unresolved=$(mysql -u"$user" -p"$passwd" --local -e "SELECT count(*) FROM dejagnu.test WHERE testrun=${testrun} AND result='UNRESOLVED'" | tail -1)
Packit 62fe53
  # total=$(mysql -u"$user" -p"$passwd" -e "SELECT count(*) FROM dejagnu.test WHERE testrun=${testrun} AND result!=''" | tail -1)
Packit 62fe53
  # passes=$(mysql -u"$user" -p"$passwd" --local -e "SELECT count(*) FROM dejagnu.test WHERE testrun=${testrun} AND result='PASS'" | tail -1)
Packit 62fe53
  # fails=$(mysql -u"$user" -p"$passwd" --local -e "SELECT count(*) FROM dejagnu.test WHERE testrun=${testrun} AND result='FAIL'" | tail -1)
Packit 62fe53
  # xpasses=$(mysql -u"$user" -p"$passwd" --local -e "SELECT count(*) FROM dejagnu.test WHERE testrun=${testrun} AND result='XPASS'" | tail -1)
Packit 62fe53
  # xfails=$(mysql -u"$user" -p"$passwd" --local -e "SELECT count(*) FROM dejagnu.test WHERE testrun=${testrun} AND result='XFAIL'" | tail -1)
Packit 62fe53
  # untested=$(mysql -u"$user" -p"$passwd" --local -e "SELECT count(*) FROM dejagnu.test WHERE testrun=${testrun} AND result='UNTESTED'" | tail -1)
Packit 62fe53
  # unsupported=$(mysql -u"$user" -p"$passwd" --local -e "SELECT count(*) FROM dejagnu.test WHERE testrun=${testrun} AND result='UNSUPPORTED'" | tail -1)
Packit 62fe53
  # unresolved=$(mysql -u"$user" -p"$passwd" --local -e "SELECT count(*) FROM dejagnu.test WHERE testrun=${testrun} AND result='UNRESOLVED'" | tail -1)
Packit 62fe53
Packit 62fe53
  # Write the data line
Packit 62fe53
  all_passes=$((passes+ xfails))
Packit 62fe53
  all_failures=$((fails + xpasses + untested + unresolved + unsupported))
Packit 62fe53
  all_tests=$((all_passes + all_failures))
Packit 62fe53
Packit 62fe53
  echo "${date} ${tool} ${version} ${arch} ${all_tests} ${passes} ${fails} ${xpasses} ${xfails} ${untested} ${unresolved} ${unsupported} ${build_machine}" >> ${outfile}
Packit 62fe53
done
Packit 62fe53
Packit 62fe53
# Extract the list of architectures supported for these results
Packit 62fe53
arches=$(grep -v '#' testrun.data | cut -d ' ' -f 13 | sort | uniq | tr '\n' ' ')
Packit 62fe53
echo "Architectures for this set of results: ${arches}"
Packit 62fe53
Packit 62fe53
# Make a separate data file for each architecture so gnuplot can keep them organized
Packit 62fe53
for i in ${arches}; do
Packit 62fe53
    if test "$i" = '.'; then
Packit 62fe53
	continue
Packit 62fe53
    fi
Packit 62fe53
    # filter out bogus test results to avoid weird spikes in the data
Packit 62fe53
    if test "$passes" -eq 0 -a "$fails" -eq 0; then
Packit 62fe53
	continue
Packit 62fe53
    fi
Packit 62fe53
    rm -f "$i".data
Packit 62fe53
    grep "$i" testrun.data | sort  -V -k 3 | uniq -u > "$i".data
Packit 62fe53
done
Packit 62fe53
Packit 62fe53
rm testrun.data
Packit 62fe53
Packit 62fe53
files=$(find . -maxdepth 1 -name '*.data' | tr '\n' ' ')
Packit 62fe53
# Get all the versions in the files, we'll pad rows so all the rows match
Packit 62fe53
versions=$(cut -d ' ' -f 3 $files | sort -V | uniq | tr '\n' ' ')
Packit 62fe53
Packit 62fe53
for i in ${files}; do
Packit 62fe53
   for j in ${versions}; do
Packit 62fe53
	cnt=$(grep -c "$j" "$i")
Packit 62fe53
	if test "$cnt" -eq 0; then
Packit 62fe53
	    echo "Adding $j to $i"
Packit 62fe53
	    machine=$(echo "$i" | cut -d '.' -f 1)
Packit 62fe53
	    echo "${date} ${tool} $j ${arch} 0 0 0 0 0 0 0 0 $machine" >> "$i"
Packit 62fe53
	fi
Packit 62fe53
   done
Packit 62fe53
done
Packit 62fe53
Packit 62fe53
# Re-sort based on the versions we just added as padding so the rows line up
Packit 62fe53
for j in ${files}; do
Packit 62fe53
    mv "$j" tmp.data
Packit 62fe53
    sort  -V -k 3 < tmp.data > "$j"
Packit 62fe53
    rm tmp.data
Packit 62fe53
done