Skip to content

Commit

Permalink
New convencience scripts for testing libraries
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17642 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Oct 10, 2013
1 parent ef3990f commit 0855a8d
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Examples/LibraryTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash -e
# Script to generate detailed test reports in a given directory, with history in another

if test ! "$#" = 6; then
echo "Usage: $0 omhome workdir libraries_dir libdirname library_name library_version"
echo "Example: $0 /path/to/build/ OpenModelica/BuildModelTest/MSL_3.2.1 /var/www/libraries/ MSL_3.2.1 Modelica 3.2.1"
exit 1
fi

OMHOME="$1"
WORKDIR="$2"
WWW="$3"
LIB_DIR="$4"
LIB_NAME="$5"
LIB_VERSION="$6"

TESTMODELS="$OMHOME/share/doc/omc/testmodels/"
HISTORY="$WWW/history"

"$OMHOME/bin/omc" ++v

rm -rf "$WORKDIR"
mkdir -p "$WORKDIR" "$WWW" "$HISTORY"
cd "$WORKDIR"

sed "s/^libraryVersion:=\"default\";/libraryVersion:=\"$LIB_VERSION\";/" "$TESTMODELS/BuildModelRecursive.mos" | sed "s/library:=.*/library:=\$TypeName($LIB_NAME);/" > BuildModelRecursive.mos
"$OMHOME/bin/omc" +g=MetaModelica "$TESTMODELS/BuildModelRecursive.mos"

shopt -s nullglob
rm -f "$WWW"/*.sim "$WWW"/*.err
cp BuildModelRecursive.html *.sim *.err "$WWW"
cp BuildModelRecursive.html "$HISTORY"/`date +${LIB_NAME}-%Y-%m-%d.html`
bash -e "$TESTMODELS/PlotLibraryTrend.sh" "$HISTORY" "$LIB_NAME"
60 changes: 60 additions & 0 deletions Examples/PlotLibraryTrend.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash -e

if test ! "$#" = 2; then
echo "Usage: $0 history_dir libname"
echo "Example: $0 /var/www/libraries/history MSL_3.2.1"
exit 1
fi

HISTORY="$1"
LIB="$2"
test -d "$HISTORY"

FIRST_DATE=`grep -H "Simulation Results:" "$HISTORY/${LIB}"*.html | head -n1 | cut -d: -f1 | grep -o "20[0-9-]*"`
LAST_DATE=`grep -H "Simulation Results:" "$HISTORY/${LIB}"*.html | tail -n1 | cut -d: -f1 | grep -o "20[0-9-]*"`
if test "$FIRST_DATE" = "$LAST_DATE"; then
FIRST_DATE="1970-01-01"
fi
GOAL=`grep -H "Simulation Results:" "$HISTORY/${LIB}"*.html | tail -n1 | grep -o "[0-9][0-9]*/[0-9][0-9]*" | sed s,.*/,,`
CURS=`grep -H "Simulation Results:" "$HISTORY/${LIB}"*.html | tail -n1 | grep -o "[0-9][0-9]*/[0-9][0-9]*" | sed s,/.*,,`
CURC=`grep -H "BuildModel Results:" "$HISTORY/${LIB}"*.html | tail -n1 | grep -o "[0-9][0-9]*/[0-9][0-9]*" | sed s,/.*,,`
cat > "$HISTORY/${LIB}-trend.gnuplot" <<EOF
set term png
set datafile separator ","
set xlabel "Date $FIRST_DATE - $LAST_DATE"
set ylabel "Models"
set xdata time
set timefmt "%Y-%m-%d"
#set xrange ["2012-10-17":"2012-11-22"]
set format x "%m-%d"
set xrange ["$FIRST_DATE":"$LAST_DATE"]
# set yrange [0:$(( (($GOAL+9)/10)*10 ))]
set yrange [0:]
# set ytics 10
# set xtics rotate by -13 font "Helvetica,8"
set title '$LIB Coverage'
set output "${LIB}-trend.png"
goal(x) = $GOAL
currentC(x) = $CURC
currentS(x) = $CURS
set key right bottom Left title 'Legend'
set style line 1 linecolor rgb "red" pt 1 ps 1
set style line 2 linecolor rgb "green" pt 1 ps 1
set style line 3 linecolor rgb "blue" pt 1 ps 1
plot "${LIB}-trend.csv" using 1:2 title 'Target: $GOAL' with lines ls 1, \
"${LIB}-trend.csv" using 1:3 title 'Compile: $CURC' with lines ls 2, \
"${LIB}-trend.csv" using 1:4 title 'Simulate: $CURS' with lines ls 3
EOF
rm -f "$HISTORY/${LIB}"-trend.csv
for f in `grep -H "Simulation Results:" "$HISTORY/${LIB}"*.html | cut -d: -f1` ; do
DATE=`echo "$f" | grep -o "20[0-9-]*"`
BUILD=`grep "BuildModel Results:" "$f" | cut -d: -f2 | cut -d/ -f1 | tr -d \ `
SIM=`grep "Simulation Results:" "$f" | cut -d: -f2`
SIMSUC=`echo "$SIM" | cut -d/ -f1`
TOT=`echo "$SIM" | cut -d/ -f2 | cut -d" " -f1`
REV=`grep -o "[(]r[0-9]*" "$f" | tr -d "("`
echo "$DATE,$TOT,$BUILD,$SIMSUC" >> "$HISTORY/${LIB}-trend.csv"
done
(cd "$HISTORY"; gnuplot "${LIB}-trend.gnuplot")
sed -i s/png/svg/ "$HISTORY/${LIB}-trend.gnuplot"
(cd "$HISTORY"; gnuplot "${LIB}-trend.gnuplot")

0 comments on commit 0855a8d

Please sign in to comment.