#!/bin/sh
# NAME
# make-html-reports.sh
#
# SYNOPSIS
# make-html-reports.sh [-q] [ -R "
}
end_table(){
echo "
"
}
row(){
echo ""
}
end_row(){
echo " "
}
c_column(){
cat <
EOF if [ -r $conf_dir/configurations/$1 ] then cat -E $conf_dir/configurations/$1 | sed 's/\$/
/g' else cat <EOF } time_spec(){ # $1 - secs _ts_tmp=$1 _ts_s=`expr $_ts_tmp % 60` _ts_tmp=`expr $_ts_tmp / 60` _ts_m=`expr $_ts_tmp % 60` _ts_tmp=`expr $_ts_tmp / 60` _ts_h=$_ts_tmp if [ $_ts_h -gt 0 ] then ret="${_ts_h}h" fi [ $_ts_m -gt 0 ] || [ $_ts_h -gt 0 ] && ret="$ret${_ts_m}m" ret="$ret${_ts_s}s" echo $ret } log_spec(){ _ff_=$src_dir/log/$report_date/$1.$2/test.$3.out if [ -r $_ff_ ] && [ -s $_ff_ ] then _f2_=$dst_dir/log.$report_date.$1.$2.$3.out.gz if [ -r $_f2_ ] then rm $_f2_ fi cp $_ff_ $dst_dir/log.$report_date.$1.$2.$3.out gzip $dst_dir/log.$report_date.$1.$2.$3.out rm -f $dst_dir/log.$report_date.$1.$2.$3.out echo "Log file" else echo "-" fi } err_spec(){ _ff_=$src_dir/log/$report_date/$1.$2/test.$3.err.tar if [ -r $_ff_ ] && [ -s $_ff_ ] then cp $_ff_ $dst_dir/err.$report_date.$1.$2.$3.err.tar gzip $dst_dir/err.$report_date.$1.$2.$3.err.tar rm -f $dst_dir/err.$report_date.$1.$2.$3.err.tar echo "Error tarball" else echo "-" fi } command_spec(){ echo $* | sed 's/;/
/g' } ### Main html_summary_file=$dst_dir/summary.$report_date.html trace "Creating summary" ( eval `grep "TOTAL" $summary_file | awk -F";" '{ printf("test_file=\"%s\"; elapsed=\"%s\"; started=\"%s\"; stopped=\"%s\"", $2, $3, $4, $5); }'` header "Autotest summary $report_date" heading 1 "Autotest summary $report_date" table row ; column `bold test file: `; column $test_file ; end_row row ; column `bold Started:` ; column "$started "; end_row row ; column `bold Stopped:` ; column "$stopped "; end_row row ; column `bold Elapsed:` ; column "`time_spec $elapsed secs`" ; end_row end_table hr table "border=1" row c_column `bold Report` c_column `bold Tag` c_column `bold Version` c_column `bold Distr-Config` c_column `bold Db-Config` c_column `bold Type` c_column `bold Test file` c_column `bold Make` c_column `bold Config` c_column `bold Test time` c_column `bold Passed` c_column `bold Failed` end_row grep -v "^#" $summary_file | grep -v TOTAL | sed 's/;/ /g' | \ while read tag version config template type test_file make_res make_time conf_res conf_time test_time passed failed do row if [ -r $src_dir/reports/report.$tag.$version.$config.$template.$type.$test_file.$report_date ] then column "report" else column "-" fi column $tag column $version column $config column $template column $type column $test_file column "$make_res(`time_spec $make_time`)" column "$conf_res(`time_spec $conf_time`)" c_column "`time_spec $test_time`" c_column `bold $passed` c_column `bold $failed` end_row done end_table footer ) > $html_summary_file for i in $src_dir/reports/report.*.$report_date do f=`basename $i` trace "Creating report: $f" eval `echo $f | awk -F"." '{printf("tag=%s;version=%s;config=%s;template=%s;type=%s;test_file=%s", $2, $3, $4, $5, $6, $7);}'` ( header "Autotest report $report_date" heading 1 "Autotest report $report_date" table #"border=1" row ; column `bold Tag:`; column $tag ; end_row row ; column `bold Version:` ; column $version ; end_row row ; column `bold Configuration:` ; column `config_spec $config`; end_row row ; column `bold Template:` ; column `config_spec $template`; end_row row ; column `bold Type:` ; column $type ; end_row row ; column `bold Test file:` ; column $test_file; end_row end_table hr table "border=1" row c_column `bold Test case` c_column `bold Result` c_column `bold Test time` c_column `bold Logfile` c_column `bold Error tarfile` end_row grep -v "^#" $i | sed 's/;/ /g' | \ while read test_no test_res test_time cmd do row column "`command_spec $cmd`" case "$test_res" in 0) column "PASSED";; 1001) column "API error";; 1002) column "Max time expired";; 1003) column "Mgm port busy";; *) column "Unknown: $test_res";; esac column "`time_spec $test_time`" column "`log_spec $tag $version $test_no`" column "`err_spec $tag $version $test_no`" end_row done end_table # Last on page we include spec # of used machines and template for config # for future reference hr table "border=1" row; column `bold Configuration:` $config; end_row row; column `config_spec_include $config`; end_row end_table hr table "border=1" row; column `bold Template:` $template; end_row row; column `config_spec_include $template`; end_row end_table footer ) > $dst_dir/$f.html done # Re creating index trace "Recreating index" ( header "Autotest super-duper index" heading 1 "Autotest super-duper index " hr for i in `ls $dst_dir/summary.*.html | sort -r -n` do f=`basename $i` cat <$f EOF done footer ) > $dst_dir/index.html exit 0