[asterisk-scf-commits] asterisk-scf/release/bamboo.git branch "master" created.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue May 31 12:18:41 CDT 2011
branch "master" has been created
at 607fe41466a01fe819a8b710511ea48f04895202 (commit)
- Log -----------------------------------------------------------------
commit 607fe41466a01fe819a8b710511ea48f04895202
Author: Darren Sessions <dsessions at digium.com>
Date: Tue May 31 12:15:52 2011 -0500
Moving the bamboo build agent scripts from release/testsuite to release/bamboo.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..aea40b6
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,19 @@
+INSTALL=install
+
+BINDIR=/opt/bamboo
+
+all:
+ @echo "***********************************************************"
+ @echo "***"
+ @echo "** Run \"make install\" to install build scripts."
+ @echo "**"
+ @echo "***********************************************************"
+
+install:
+ @test -d $(BINDIR) || \
+ mkdir -p $(BINDIR)
+ @for f in bin/*; do \
+ test -f $$f && \
+ chmod 755 $$f && \
+ cp -p $$f $(BINDIR); \
+ done
diff --git a/Makefile.mak b/Makefile.mak
new file mode 100644
index 0000000..2cd7a70
--- /dev/null
+++ b/Makefile.mak
@@ -0,0 +1,13 @@
+INSTALL=copy
+
+BINDIR=C:\bamboo
+
+all:
+ @echo "************************************************************"
+ @echo "***"
+ @echo "*** Run \"make install\" to install build scripts."
+ @echo "***"
+ @echo "************************************************************"
+
+install:
+ for %n in (bin\*.*) do $(INSTALL) %n $(BINDIR)
diff --git a/bin/boost_to_junit.xsl b/bin/boost_to_junit.xsl
new file mode 100644
index 0000000..6e77b2d
--- /dev/null
+++ b/bin/boost_to_junit.xsl
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Boost.Test XML to J-Unit XML
+ XSL Transformation Stylesheet
+
+ Asterisk SCF Test-Suite
+ Copyright (C) 2011, Digium, Inc.
+
+ Darren Sessions <dsessions at digium.com>
+
+ This program is free software, distributed under the terms of
+ the GNU General Public License Version 2.
+
+-->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:template match="TestResult">
+ <xsl:call-template name="testSuite" />
+ </xsl:template>
+
+ <xsl:template name="testSuite">
+ <xsl:for-each select="TestSuite">
+ <testsuite>
+ <xsl:attribute name="skipped">
+ <xsl:value-of select="@test_cases_skipped"/>
+ </xsl:attribute>
+ <xsl:attribute name="not-run">
+ <xsl:value-of select="@test_cases_skipped"/>
+ </xsl:attribute>
+ <xsl:attribute name="failures">
+ <xsl:value-of select="@test_cases_failed"/>
+ </xsl:attribute>
+ <xsl:attribute name="expected_failures">
+ <xsl:value-of select="@test_cases_expected_failures"/>
+ </xsl:attribute>
+ <xsl:attribute name="errors">
+ <xsl:value-of select="@test_cases_failed + @test_cases_aborted"/>
+ </xsl:attribute>
+ <xsl:attribute name="tests">
+ <xsl:value-of select="@test_cases_passed + @test_cases_failed + @test_cases_expected_failures + @test_cases_skipped + @test_cases_aborted"/>
+ </xsl:attribute>
+ <xsl:call-template name="testAttributes" />
+ <xsl:call-template name="testSuite" />
+ <xsl:for-each select="TestCase">
+ <testcase>
+ <xsl:call-template name="testAttributes" />
+ <xsl:call-template name="testCaseElements" />
+ </testcase>
+ </xsl:for-each>
+ </testsuite>
+ </xsl:for-each>
+ </xsl:template>
+
+ <xsl:template name="testAttributes">
+ <xsl:attribute name="name">
+ <xsl:value-of select="@name"/>
+ </xsl:attribute>
+ <xsl:attribute name="success">
+ <xsl:choose>
+ <xsl:when test="@result = 'passed'">True</xsl:when>
+ <xsl:when test="@result != 'passed'">False</xsl:when>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:attribute name="executed">True</xsl:attribute>
+ <xsl:attribute name="time">0</xsl:attribute>
+ <xsl:attribute name="expected_failures">0</xsl:attribute>
+ <xsl:attribute name="asserts">
+ <xsl:value-of select="@assertions_failed + @assertions_passed"/>
+ </xsl:attribute>
+ </xsl:template>
+
+ <xsl:template name="testCaseElements">
+ <xsl:if test="@result != 'passed'">
+ <failure type="A failure type was not reported." message="No message was reported."/>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:output method="xml" indent="yes"/>
+</xsl:stylesheet>
diff --git a/bin/tests.py b/bin/tests.py
new file mode 100644
index 0000000..f0124f6
--- /dev/null
+++ b/bin/tests.py
@@ -0,0 +1,290 @@
+#!/usr/bin/env python
+'''
+
+ Build and unit-test engine for Atlassian Bamboo
+
+ Asterisk SCF Test-Suite
+ Copyright (C) 2011, Digium, Inc.
+
+ Darren Sessions <dsessions at digium.com>
+
+ This program is free software, distributed under the terms of
+ the GNU General Public License Version 2.
+
+'''
+
+import os
+import re
+import sys
+import time
+import platform
+import optparse
+import subprocess
+
+from xml.dom.minidom import Document
+
+class test_asterisk_scf:
+ def __init__(self, component, unittests=None):
+ self._component = component
+ self._unittests = unittests
+ self._msbuild_path = "/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe"
+ self.__build()
+
+ if self._unittests:
+ self.__unit_tests(component)
+ self.__write_results_xml(component)
+ self.__convert_boost_to_junit()
+
+ def __convert_boost_to_junit(self):
+ os.chdir("../test_results")
+ tree = os.walk(".")
+ for root, dirs, files in tree:
+ if len(files)>0:
+ for f in files:
+ if re.match(r"^(?!converted).*result.xml", f):
+ os.system("%s /opt/bamboo/boost_to_junit.xsl %s >> ../converted_%s" % (which("xsltproc"), f, f))
+ os.remove(f)
+
+ def __unit_tests(self, component):
+ self.total_failures = 0
+ self.total_time = 0
+ self.tests = 0
+ self.passed = 1
+ self.did_run = True
+
+ if not os.path.exists("./build/%s" % component):
+ print "Unable to find the test directory for the '%s' component!" % component
+ return
+
+ os.chdir("./build/%s" % component)
+ start_time = time.time()
+ self.passed = uni_make(None, None, 'test')
+ self.total_time = time.time() - start_time
+
+ if self.passed != 0:
+ self.total_failures = 1
+ self.tests = 1
+
+ def __write_results_xml(self, component):
+ try:
+ f = open("../%s_master_unit_test_results.xml" % component, "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, component))
+ if self.passed == 0:
+ f.write('/>\n')
+ else:
+ f.write(">\n\t\t<failure />")
+ f.write("\n\t</testcase>\n")
+ f.write('</testsuite>\n')
+ f.close()
+
+ try:
+ f = open("../%s_master_unit_test_results.xml" % component, "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 __build(self):
+ if os.path.exists("./gitall"):
+ errorout("'gitall' already exists!")
+
+ os.system("git clone git://git.asterisk.org/asterisk-scf/integration/gitall")
+ os.chdir("./gitall")
+ os.system("bash ./gitall-asterisk-scf.sh")
+
+ if self._component == "gitall":
+ cloned_rev = readinfile(".git/refs/heads/master").rstrip('\n')
+ else:
+ cloned_rev = readinfile("%s/.git/refs/heads/master" % self._component).rstrip('\n')
+
+ print "\n\nTest build initiated for: %s" % self._component
+ print "-----------------\nBamboo revision = %s\nCloned revision = %s\n-----------------\n" % (crev, cloned_rev)
+
+ if crev != cloned_rev:
+ print "Reverting to %s" % crev
+ if self._component != "gitall":
+ os.chdir("./%s" % self._component)
+ os.system("git checkout %s" % crev)
+ os.chdir("..")
+
+ if plat == "Windows":
+ system_call(["/cygwin/bin/bash.exe","./cmake/init-cmake.sh","--nmake"])
+ os.chdir("./pjproject/pjlib/build")
+ system_call(["%s" % self._msbuild_path, "pjlib.vcxproj"])
+ os.chdir("../../pjlib-util/build")
+ system_call(["%s" % self._msbuild_path, "pjlib_util.vcxproj"])
+ os.chdir("../../pjmedia/build")
+ system_call(["%s" % self._msbuild_path, "pjmedia.vcxproj"])
+ system_call(["%s" % self._msbuild_path, "pjmedia_audiodev.vcxproj"])
+ os.chdir("../../third_party/build/srtp")
+ system_call(["%s" % self._msbuild_path, "libsrtp.vcxproj"])
+ os.chdir("../../../pjnath/build")
+ system_call(["%s" % self._msbuild_path, "pjnath.vcxproj"])
+ os.chdir("../../pjsip/build")
+ system_call(["%s" % self._msbuild_path, "pjsip_simple.vcxproj"])
+ system_call(["%s" % self._msbuild_path, "pjsip_ua.vcxproj"])
+ system_call(["%s" % self._msbuild_path, "pjsip_core.vcxproj"])
+ system_call(["%s" % self._msbuild_path, "pjsua_lib.vcxproj"])
+ os.chdir("../../../build")
+ uni_make(None, None, None)
+ os.chdir("..")
+ sys.exit(0)
+ else:
+ system_call(["/bin/bash","./cmake/init-cmake.sh"])
+ system_call(["/usr/bin/cmake","--build","./build"])
+
+def system_call(cmd):
+ if os.path.exists(cmd[0]) and os.access(cmd[0], os.X_OK):
+ p = subprocess.Popen(cmd)
+ p.wait()
+ if p.returncode != 0:
+ errorout("Error detected during system call! '%s' returned with exit code: %d" % (cmd[0], p.returncode))
+ return p.returncode
+ else:
+ errorout("FAILED TO EXECUTE %s, it must exist and be executable" % cmd)
+
+def which(app):
+ def if_exists(file_path):
+ return os.path.exists(file_path) and os.access(file_path, os.X_OK)
+
+ file_path, file_name = os.path.split(app)
+ if file_path:
+ if if_exists(app):
+ return app
+ else:
+ for path in os.environ["PATH"].split(os.pathsep):
+ prog = os.path.join(path, app)
+ if if_exists(prog):
+ return prog
+ return
+
+def test_ice():
+ print "\n\nBuilding Ice\n"
+ os.chdir("./cpp")
+ uni_make(1, 1, 'install')
+ sys.exit(0)
+
+def test_slice_plugins():
+ print "\n\nBuilding Slice Plugins\n"
+ os.system("cmake .")
+ uni_make(None, None, 'install')
+ sys.exit(0)
+
+def uni_make(makefile=None,makeargs=None,makesubtype=None):
+ sc = []
+ if plat == "Windows":
+ if makefile:
+ sc = ["%s" % make,"-F","Makefile.mak"]
+ else:
+ sc = ["%s" % make]
+ rc = system_call(sc)
+ elif plat == "SunOS":
+ if makeargs:
+ sc = ["%s" % make,"MCPP_HOME=/usr/local EXPAT_HOME=/usr/sfw OPENSSL_HOME=/usr/sfw DB_HOME=/usr/local/BerkeleyDB.4.8"]
+ else:
+ sc = ["%s" % make]
+ rc = system_call(sc)
+ else:
+ sc = ["%s" % make]
+ rc = system_call(sc)
+ if makesubtype and rc == 0:
+ sc.append(makesubtype)
+ rc = system_call(sc)
+ return rc
+
+def readinfile(file):
+ try:
+ f = open(file, "r")
+ except IOError:
+ errorout("Failed to open file: %s" % file)
+ except:
+ errorout("Unexpected error: %s" % sys.exc_info()[0])
+ else:
+ rc = f.read()
+ f.close()
+ return rc
+
+def errorout(msg):
+ dash = ""
+ while len(dash) < len(msg):
+ dash = dash + "!"
+ print dash + "\n" + msg + "\n" + dash + "\n"
+ sys.exit(1)
+
+def update_build_env():
+ os.chdir('bamboo')
+ uni_make(1, None, 'install')
+ return
+
+def main(argv=None):
+ global plat
+ global arch
+ global make
+ global mkcmd
+ global crev
+
+ if argv is None:
+ args = sys.argv
+
+ try:
+ args[1]
+ except:
+ errorout("Usage: ./tests.py [component] [unittests]")
+
+ try:
+ args[2]
+ unittests = 'unittests'
+ except:
+ unittests = ''
+
+ arch = platform.machine()
+ plat = platform.system()
+
+ if plat == "Windows":
+ make = '/PROGRA~1/MICROS~1.0/VC/bin/nmake.exe'
+ rmdircmd = "rmdir /S /Q"
+ elif plat == "SunOS":
+ make = "/usr/bin/gmake"
+ rmdircmd = "rm -rf"
+ else:
+ make = "/usr/bin/make"
+ rmdircmd = "rm -rf"
+
+ print "-------------------------------------------------------------------------\n"
+ print "-------------------------------------------------------------------------\n\n"
+ print "Running on %s %s\n" % (plat, arch)
+ print "\n"
+ for param in os.environ.keys():
+ print "%20s %s" % (param, os.environ[param])
+ print "\n"
+ print "-------------------------------------------------------------------------\n"
+ print "-------------------------------------------------------------------------\n\n"
+
+ if args[1] == "ice":
+ test_ice()
+ elif args[1] == "slice-plugins":
+ test_slice_plugins()
+ elif args[1] == "update_build_env":
+ update_build_env()
+ else:
+ crev = readinfile(".git/refs/heads/master").rstrip('\n')
+ test_asterisk_scf(args[1], unittests)
+
+ return 0
+
+if __name__ == "__main__":
+ sys.exit(main() or 0)
diff --git a/bin/visual_studio_wrapper.bat b/bin/visual_studio_wrapper.bat
new file mode 100644
index 0000000..78fb10d
--- /dev/null
+++ b/bin/visual_studio_wrapper.bat
@@ -0,0 +1,38 @@
+ at ECHO off
+REM
+REM Asterisk SCF build and unit-test engine for Atlassian Bamboo
+REM
+REM Copyright (C) 2011, Digium, Inc.
+REM
+REM Darren Sessions <dsessions at digium.com>
+REM
+REM This program is free software, distributed under the terms of
+REM the GNU General Public License Version 2.
+REM
+
+if "%1" == "" goto usage
+if "%2" == "" goto usage
+
+ at call "C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" %1
+
+SET BINDIR=C:\bamboo
+SET CPP_COMPILER=VC100_EXPRESS
+
+%BINDIR%\tests.py %2 %3
+
+goto :eof
+
+:usage
+ECHO:
+ECHO Error in script usage. The correct usage is:
+ECHO %0 [arch] [asterisk scf repo] (unittests)
+ECHO:
+ECHO where [arch] is: x86 ^| amd64
+ECHO and
+ECHO where [asterisk scf repo] is an Asterisk SCF git repository.
+ECHO:
+ECHO For example:
+ECHO %0 x86 sip
+
+goto :eof
+
diff --git a/contrib/init.d/com.atlassian.BambooAgent.plist b/contrib/init.d/com.atlassian.BambooAgent.plist
new file mode 100644
index 0000000..8d354d9
--- /dev/null
+++ b/contrib/init.d/com.atlassian.BambooAgent.plist
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>Disabled</key>
+ <false/>
+ <key>Label</key>
+ <string>com.atlassian.BambooAgent</string>
+ <key>ProgramArguments</key>
+ <array>
+ <string>/var/root/bin/bamboo-agent.sh</string>
+ <string>start</string>
+ </array>
+ <key>ServiceDescription</key>
+ <string>Atlassian Bamboo build agent</string>
+ <key>UserName</key>
+ <string>root</string>
+ <key>GroupName</key>
+ <string>admin</string>
+ <key>OnDemand</key>
+ <false/>
+ </dict>
+</plist>
diff --git a/contrib/init.d/rc.debian.bamboo-remote-agent b/contrib/init.d/rc.debian.bamboo-remote-agent
new file mode 100644
index 0000000..8f63edb
--- /dev/null
+++ b/contrib/init.d/rc.debian.bamboo-remote-agent
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+### BEGIN INIT INFO
+# Provides: bamboo-remote-agent
+# Required-Start: $local_fs $remote_fs $network $syslog
+# Required-Stop: $local_fs $remote_fs $network $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Bamboo Remote Agent
+### END INIT INFO
+
+case $1 in
+ start)
+ /srv/bamboo/bin/bamboo-agent.sh start
+ ;;
+ stop)
+ /srv/bamboo/bin/bamboo-agent.sh stop
+ ;;
+ restart)
+ /srv/bamboo/bin/bamboo-agent.sh restart
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/contrib/init.d/rc.redhat.bamboo-remote-agent b/contrib/init.d/rc.redhat.bamboo-remote-agent
new file mode 100644
index 0000000..d12c579
--- /dev/null
+++ b/contrib/init.d/rc.redhat.bamboo-remote-agent
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# bamboo-remote-agent: Start/stop Bamboo remote agent
+#
+# chkconfig: 2345 90 60
+# description: Bamboo Remote Agent
+
+case "$1" in
+ start)
+ /srv/bamboo/bin/bamboo-agent.sh start
+ ;;
+ stop)
+ /srv/bamboo/bin/bamboo-agent.sh stop
+ ;;
+ restart)
+ /srv/bamboo/bin/bamboo-agent.sh restart
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|restart}"
+ exit 1
+ ;;
+esac
+
+exit 0
-----------------------------------------------------------------------
--
asterisk-scf/release/bamboo.git
More information about the asterisk-scf-commits
mailing list