diff --git a/tools/oneclick/base/modelsim_regression_test_vhdl.py b/tools/oneclick/base/modelsim_regression_test_vhdl.py index ea78eb8e51bedcd136acac370a3d9c318e247e7b..2b1206a086faff6b6e59121045d2d5006463d153 100644 --- a/tools/oneclick/base/modelsim_regression_test_vhdl.py +++ b/tools/oneclick/base/modelsim_regression_test_vhdl.py @@ -217,6 +217,9 @@ if hdl_args.run: logFileNamePath=os.path.join(build_main_dir, build_toolset_dir, build_tool_dir, logFileName) totalNofTb = 0 # total number of tb in regression test totalNofFailed = 0 # total number of tb in regression test that failed + # Keep lists of passed/failed test benches to put in our log file as summary + tbPassed = [] + tbFailed = [] # Open the log file and run the test bench do files with open(logFileNamePath, 'w') as fp: @@ -233,6 +236,7 @@ if hdl_args.run: do_path = os.path.join(mpf_path, do_subdir) test_bench_files = lib_dict['regression_test_vhdl'].split() for tbf in test_bench_files: + thisTbFailed = False tbf_name = os.path.basename(tbf) tb_name = os.path.splitext(tbf_name)[0] doName = tb_name + '.do' @@ -252,7 +256,7 @@ if hdl_args.run: sim_end = subprocess.check_output("egrep '>>> SIMULATION END' %s" % transcriptPathName, shell=True) except subprocess.CalledProcessError: fp.write('Error occured while running vcom or -label for %s\n' % lib_name) - totalNofFailed += 1 + thisTbFailed = True else: # Log the simulation run time fp.write('%s' % sim_end) @@ -262,17 +266,25 @@ if hdl_args.run: if grep_status==0: sim_msg = subprocess.check_output(grep_cmd, shell=True) fp.write('%s\n' % sim_msg) - totalNofFailed += 1 + thisTbFailed = True # Log the simulation Failures if they occured (use subprocess.call-subprocess.check_output to handle exit code > 0) grep_cmd = "egrep 'Failure' %s" % transcriptPathName grep_status = subprocess.call(grep_cmd, shell=True) if grep_status==0: sim_msg = subprocess.check_output(grep_cmd, shell=True) fp.write('%s\n' % sim_msg) - totalNofFailed += 1 + thisTbFailed = True else: fp.write('> Error occured while calling: %s\n' % vsim_cmd) + thisTbFailed = True + + # Check if this test bench failed, update passed/failed TB lists and total failed TB count + if thisTbFailed: totalNofFailed += 1 + tbFailed.append(tb_name) + else: + tbPassed.append(tb_name) + # Maintain count of total number of test benches totalNofTb += nofTb # Measure regression test time for this HDL library @@ -298,7 +310,12 @@ if hdl_args.run: # Log total test time end_time = time.time() run_time = end_time-start_time - fp.write('# Email MESSAGE: Total regression test duration in days,h:m:s = %s\n' % timedelta(seconds=run_time)) + fp.write('# Email MESSAGE: Total regression test duration in days,h:m:s = %s\n\n' % timedelta(seconds=run_time)) + + if totalNofFailed>0: + fp.write('# Email MESSAGE: Failed test benches: %s\n\n' %str(tbFailed)) + if totalNofTb-totalNofFailed>0: + fp.write('# Email MESSAGE: Passed test benches: %s\n\n' %str(tbPassed)) fp.write('# Email LOG: %s\n' % logFileNamePath) @@ -306,4 +323,4 @@ if hdl_args.run: print '\n\ncat %s:\n' % logFileNamePath subprocess.call('cat %s' % logFileNamePath, shell=True) print '\n' - \ No newline at end of file + diff --git a/tools/oneclick/base/modelsim_regression_test_vhdl_cron.sh b/tools/oneclick/base/modelsim_regression_test_vhdl_cron.sh new file mode 100755 index 0000000000000000000000000000000000000000..b2fd3125c426d0ef5e717ca3b091839588edc746 --- /dev/null +++ b/tools/oneclick/base/modelsim_regression_test_vhdl_cron.sh @@ -0,0 +1,52 @@ +############################################################################### +# +# Copyright (C) 2016 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This program 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. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################### +# Author: +# . Daniel van der Schuur +# Purpose: +# . Run modelsim_regression_test_vhdl.py as a Cron job; e-mail result +# Description: +# . Put the following line in Crontab (by running $sudo crontab -e -u [username]) to run every firday (day 5) at 20:00 +# 0 20 * * 5 /home/[username]/SVN/RadioHDL/trunk/tools/oneclick/base/modelsim_regression_test_cron.sh 2>&1 + +LOGFILE=$HOME/modelsim_regression_test_vhdl_cron.log + +############################################################################### +# Delete any previous log files +############################################################################### +rm $LOGFILE + +############################################################################### +# Source environment +# . BEWARE: do not put this (or similar) in your .bashrc: +# . if [ -z "$PS1" ]; then return; fi +# This will stop sourcing of .basrc immediately as a Cron job is not run interactively. +############################################################################### +source $HOME/.bashrc + +############################################################################### +# Perform the regression test and put the output in a log file +############################################################################### +python $RADIOHDL/tools/oneclick/base/modelsim_regression_test_vhdl.py -t unb1 -r > $LOGFILE + +############################################################################### +# Read the log file en send the result email +############################################################################### +. $RADIOHDL/tools/oneclick/base/modelsim_regression_test_vhdl_mail.sh diff --git a/tools/oneclick/base/modelsim_regression_test_vhdl_mail.sh b/tools/oneclick/base/modelsim_regression_test_vhdl_mail.sh new file mode 100755 index 0000000000000000000000000000000000000000..b09af29454f3d5bc3912776b0f831d27d92b8010 --- /dev/null +++ b/tools/oneclick/base/modelsim_regression_test_vhdl_mail.sh @@ -0,0 +1,55 @@ +############################################################################### +# +# Copyright (C) 2016 +# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/> +# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands +# +# This program 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. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################### +# Author: +# . Daniel van der Schuur +# Purpose: +# . e-mail result of VHDL regression test +# Description: +# . This script interprets the log file generated by +# modelsim_regression_test_vhdl.sh + +############################################################################### +# The result of the regression test will be sent to the user executing it +# . assuming this person works at ASTRON +############################################################################### +RECIPIENTS=$USER@astron.nl + +############################################################################### +# Grep the Email strings from the log file +############################################################################### +LOGFILE=$HOME/modelsim_regression_test_vhdl_cron.log +SUBJECT_FULL=$(cat $LOGFILE | grep 'Email SUBJECT') +MESSAGE_FULL=$(cat $LOGFILE | grep 'Email MESSAGE') + +############################################################################### +# Create 3 strings we'll put in the email as subject and message +############################################################################### +# Strip off the Email SUBJECT tag +SUBJECT=[REGTEST]${SUBJECT_FULL##*SUBJECT:} + +# Grep non-duplicate error messages from the log file +LOG=$(cat $LOGFILE | grep Error | sort | uniq) + +############################################################################### +# Send the email by piping the final strings to the mail command +############################################################################### +printf "${MESSAGE_FULL} \n\n ${LOG}" | mail -s "${SUBJECT}" ${RECIPIENTS} -- -f $USER@astron.nl +