From 234e4c9f6939b0ed6bcf1769030912f0ea05bd0e Mon Sep 17 00:00:00 2001 From: Bernardo Damele Date: Sat, 26 Jan 2013 16:11:09 +0000 Subject: [PATCH] consolidated into one script --- extra/shutils/regressiontest.py | 16 ++++++++++++--- extra/shutils/regressiontest_cronjob.sh | 27 ------------------------- 2 files changed, 13 insertions(+), 30 deletions(-) delete mode 100755 extra/shutils/regressiontest_cronjob.sh diff --git a/extra/shutils/regressiontest.py b/extra/shutils/regressiontest.py index 06cc37c5a..70ab59d18 100644 --- a/extra/shutils/regressiontest.py +++ b/extra/shutils/regressiontest.py @@ -4,6 +4,7 @@ # See the file 'doc/COPYING' for copying permission import codecs +import inspect import os import re import smtplib @@ -14,7 +15,7 @@ import time from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText -sys.path.append("../../") +sys.path.append(os.path.normpath("%s/../../" % os.path.dirname(inspect.getfile(inspect.currentframe())))) from lib.core.revision import getRevisionNumber @@ -64,7 +65,7 @@ def main(): test_counts = [] attachments = {} - command_line = "cd %s && python sqlmap.py --live-test" % SQLMAP_HOME + command_line = "python /opt/sqlmap/sqlmap.py --live-test" % SQLMAP_HOME proc = subprocess.Popen(command_line, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) proc.wait() @@ -138,4 +139,13 @@ def main(): send_email(msg) if __name__ == "__main__": - main() + log_fd = open("/tmp/regressiontest.txt", "ab") + log_fd.write("Regression test started at %s\n" % TIME) + + try: + main() + except Exception, e: + log_fd.write("An exception has occurred:\n%s" % str(traceback.format_exc())) + + log_fd.write("\nRegression test finished at %s\n\n" % TIME) + log_fd.close() diff --git a/extra/shutils/regressiontest_cronjob.sh b/extra/shutils/regressiontest_cronjob.sh deleted file mode 100755 index 44661a852..000000000 --- a/extra/shutils/regressiontest_cronjob.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2006-2013 sqlmap developers (http://sqlmap.org/) -# See the file 'doc/COPYING' for copying permission - -SQLMAP_HOME="/opt/sqlmap" -REGRESSION_SCRIPT="${SQLMAP_HOME}/extra/shutils" - -FROM="regressiontest@sqlmap.org" -TO="bernardo.damele@gmail.com, miroslav.stampar@gmail.com" -SUBJECT="Automated regression test failed on $(date)" - -cd $SQLMAP_HOME -git pull -rm -f output 2>/dev/null - -cd $REGRESSION_SCRIPT -echo "Regression test started at $(date)" 1>/tmp/regressiontest.log 2>&1 -python regressiontest.py 1>>/tmp/regressiontest.log 2>&1 - -if [ $? -ne 0 ] -then - echo "Regression test finished at $(date)" 1>>/tmp/regressiontest.log 2>&1 - cat /tmp/regressiontest.log | mailx -s "${SUBJECT}" -aFrom:${FROM} ${TO} -else - echo "Regression test finished at $(date)" 1>>/tmp/regressiontest.log 2>&1 -fi