[asterisk-commits] dsessions: testsuite/bamboo/trunk r1437 - /bamboo/trunk/bin/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Mar 25 14:42:56 CDT 2011
Author: dsessions
Date: Fri Mar 25 14:42:51 2011
New Revision: 1437
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=1437
Log:
Support for unit tests in the Asterisk SCF build plans in Bamboo.
Added:
bamboo/trunk/bin/asterisk_scf_unit_tests.py (with props)
Modified:
bamboo/trunk/bin/build-asterisk-scf-wrapper.bat
bamboo/trunk/bin/build-asterisk-scf-wrapper.sh
bamboo/trunk/bin/build-asterisk-scf.sh
Added: bamboo/trunk/bin/asterisk_scf_unit_tests.py
URL: http://svnview.digium.com/svn/testsuite/bamboo/trunk/bin/asterisk_scf_unit_tests.py?view=auto&rev=1437
==============================================================================
--- bamboo/trunk/bin/asterisk_scf_unit_tests.py (added)
+++ bamboo/trunk/bin/asterisk_scf_unit_tests.py Fri Mar 25 14:42:51 2011
@@ -1,0 +1,118 @@
+#!/usr/bin/python
+
+import os, time, subprocess, sys, optparse
+
+class unittest():
+ def __init__(self):
+ self.total_failures = 0
+ self.total_time = 0
+ self.tests = 0
+
+ def run(self, args):
+
+ self.passed = False
+ self.did_run = True
+
+ try:
+ args[1]
+ self.component = args[1]
+ except:
+
+ return
+
+ if not os.path.exists("./build/%s/test" % self.component):
+ print "Unable to find the test directory for the '%s' self.component!" % self.component
+ return
+
+ os.chdir("./build/%s/test" % self.component)
+
+ try:
+ args[2]
+ make = args[2]
+ except:
+ self.total_failures = 1
+ return
+
+ start_time = time.time()
+
+ cmd = [
+ "%s" % make,
+ "test"
+ ]
+ if os.path.exists(cmd[0]) and os.access(cmd[0], os.X_OK):
+ try:
+ f = open("../../../test_output.txt", "w")
+ except IOError:
+ print "FAILURE: Failed to open file for test output"
+ return
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ try:
+ for l in p.stdout.readlines():
+ f.write(l)
+ print l,
+ except IOError:
+ pass
+ p.wait()
+ f.close()
+ self.passed = p.returncode == 0
+ else:
+ print "FAILED TO EXECUTE %s, it must exist and be executable" % cmd
+
+ self.total_time = time.time() - start_time
+
+ if self.passed == False:
+ self.total_failures == 1
+
+ self.tests = 1
+
+ def write_results_xml(self, stdout=False):
+ try:
+ f = open("../../../test_results.xml", "w")
+ except IOError:
+ print "Failed to open test results output file: "
+ return
+ except:
+ print "Unexpected error: %s" % sys.exc_info()[0]
+ return
+
+ f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
+ f.write('<testsuite errors="0" tests="%s" time="%.2f" failures="%d" '
+ 'name="Asterisk SCF Test-Suite">\n' %
+ (self.tests, self.total_time, self.total_failures))
+ f.write('\t<testcase time="%.2f" name="%s unit tests"' % (self.total_time, self.component))
+ if self.passed is True:
+ f.write('/>\n')
+ else:
+ f.write(">\n\t\t<failure />")
+ f.write("\n\t</testcase>\n")
+ f.write('</testsuite>\n')
+ f.close()
+
+ if stdout is True:
+ try:
+ f = open("../../../test_results.xml", "r")
+ except IOError:
+ print "Failed to open test results output file:"
+ except:
+ print "Unexpected error: %s" % sys.exc_info()[0]
+ else:
+ print f.read()
+ f.close()
+
+def main(argv=None):
+ if argv is None:
+ args = sys.argv
+
+ try:
+ args[1]
+ args[2]
+ except:
+ print "Usage: ./unittests.py [component] [make utility path]\n"
+
+ obj = unittest()
+ obj.run(args)
+ obj.write_results_xml(stdout=True)
+
+if __name__ == "__main__":
+ sys.exit(main() or 0)
Propchange: bamboo/trunk/bin/asterisk_scf_unit_tests.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: bamboo/trunk/bin/asterisk_scf_unit_tests.py
------------------------------------------------------------------------------
svn:executable = *
Propchange: bamboo/trunk/bin/asterisk_scf_unit_tests.py
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: bamboo/trunk/bin/asterisk_scf_unit_tests.py
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: bamboo/trunk/bin/build-asterisk-scf-wrapper.bat
URL: http://svnview.digium.com/svn/testsuite/bamboo/trunk/bin/build-asterisk-scf-wrapper.bat?view=diff&rev=1437&r1=1436&r2=1437
==============================================================================
--- bamboo/trunk/bin/build-asterisk-scf-wrapper.bat (original)
+++ bamboo/trunk/bin/build-asterisk-scf-wrapper.bat Fri Mar 25 14:42:51 2011
@@ -20,7 +20,7 @@
rmdir /S /Q bamboo
bash -c "set -e"
-bash -c "%BINDIR%/build-asterisk-scf.sh %2"
+bash -c "%BINDIR%/build-asterisk-scf.sh %2 %BINDIR% %3"
goto :eof
Modified: bamboo/trunk/bin/build-asterisk-scf-wrapper.sh
URL: http://svnview.digium.com/svn/testsuite/bamboo/trunk/bin/build-asterisk-scf-wrapper.sh?view=diff&rev=1437&r1=1436&r2=1437
==============================================================================
--- bamboo/trunk/bin/build-asterisk-scf-wrapper.sh (original)
+++ bamboo/trunk/bin/build-asterisk-scf-wrapper.sh Fri Mar 25 14:42:51 2011
@@ -12,4 +12,4 @@
set -e
-${BINDIR}/build-asterisk-scf.sh $@
+${BINDIR}/build-asterisk-scf.sh $1 ${BINDIR} $2
Modified: bamboo/trunk/bin/build-asterisk-scf.sh
URL: http://svnview.digium.com/svn/testsuite/bamboo/trunk/bin/build-asterisk-scf.sh?view=diff&rev=1437&r1=1436&r2=1437
==============================================================================
--- bamboo/trunk/bin/build-asterisk-scf.sh (original)
+++ bamboo/trunk/bin/build-asterisk-scf.sh Fri Mar 25 14:42:51 2011
@@ -22,7 +22,7 @@
fi
COMPONENT_REV=`cat .git/refs/heads/master`
-COMPONENT_NAM=$@
+COMPONENT_NAM=$1
#
# Build Ice
@@ -176,3 +176,5 @@
./cmake/init-cmake.sh
cmake --build ./build
fi
+
+$2/asterisk_scf_unit_tests.py $1 $3
More information about the asterisk-commits
mailing list