[asterisk-scf-commits] asterisk-scf/release/testsuite.git branch "master" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Mar 31 09:17:40 CDT 2011


branch "master" has been updated
       via  5b052f87cdf9fa43f7b0e6482bfd470f2113350e (commit)
      from  70f1ba315db1415432acef3e82b3bf78b69c5e0b (commit)

Summary of changes:
 bamboo/Makefile                                    |   19 ++
 bamboo/Makefile.mak                                |   13 +
 bamboo/bin/tests.py                                |  262 ++++++++++++++++++++
 bamboo/bin/visual_studio_wrapper.bat               |   39 +++
 .../contrib/init.d/com.atlassian.BambooAgent.plist |   23 ++
 .../contrib/init.d/rc.debian.bamboo-remote-agent   |   28 ++
 .../contrib/init.d/rc.redhat.bamboo-remote-agent   |   24 ++
 7 files changed, 408 insertions(+), 0 deletions(-)
 create mode 100644 bamboo/Makefile
 create mode 100644 bamboo/Makefile.mak
 delete mode 100644 bamboo/README
 create mode 100755 bamboo/bin/tests.py
 create mode 100644 bamboo/bin/visual_studio_wrapper.bat
 create mode 100644 bamboo/contrib/init.d/com.atlassian.BambooAgent.plist
 create mode 100644 bamboo/contrib/init.d/rc.debian.bamboo-remote-agent
 create mode 100644 bamboo/contrib/init.d/rc.redhat.bamboo-remote-agent


- Log -----------------------------------------------------------------
commit 5b052f87cdf9fa43f7b0e6482bfd470f2113350e
Author: Darren Sessions <dsessions at digium.com>
Date:   Thu Mar 31 09:16:51 2011 -0500

    Added new bamboo build scripts, makefiles, and example init scripts.

diff --git a/bamboo/Makefile b/bamboo/Makefile
new file mode 100644
index 0000000..aea40b6
--- /dev/null
+++ b/bamboo/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/bamboo/Makefile.mak b/bamboo/Makefile.mak
new file mode 100644
index 0000000..2cd7a70
--- /dev/null
+++ b/bamboo/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/bamboo/README b/bamboo/README
deleted file mode 100644
index e69de29..0000000
diff --git a/bamboo/bin/tests.py b/bamboo/bin/tests.py
new file mode 100755
index 0000000..06d624c
--- /dev/null
+++ b/bamboo/bin/tests.py
@@ -0,0 +1,262 @@
+#!/usr/bin/env python
+'''
+
+ Asterisk SCF build and unit-test engine for Atlassian Bamboo
+
+ 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, sys, time, platform, optparse, subprocess
+from xml.dom.minidom import Document
+
+class test_asterisk_scf:
+    def __init__(self, component):
+        self.component = component
+        self.msbuild_path = "/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe"
+        self.build()
+        self.unit_tests()
+        self.write_results_xml(stdout=True)
+
+    def unit_tests(self):
+        self.total_failures = 0
+        self.total_time = 0
+        self.tests = 0
+        self.passed = False
+        self.did_run = True
+
+        if not os.path.exists("./build/%s/test" % self.component):
+            print "Unable to find the test directory for the '%s' component!" % self.component
+            return
+
+        os.chdir("./build/%s/test" % self.component)
+
+        start_time = time.time()
+
+        cmd = [
+            "%s" % make,
+            "%stest" % mkcmd
+        ]
+
+        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 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":
+            os.system("bash ./cmake/init-cmake.sh --nmake")
+            os.chdir("./pjproject/pjlib/build")
+            os.system("%s pjlib.vcxproj" % self.msbuild_path)
+            os.chdir("../../pjlib-util/build")
+            os.system("%s pjlib_util.vcxproj" % self.msbuild_path)
+            os.chdir("../../pjmedia/build")
+            os.system("%s pjmedia.vcxproj" % self.msbuild_path)
+            os.system("%s pjmedia_audiodev.vcxproj" % self.msbuild_path)
+            os.chdir("../../third_party/build/srtp")
+            os.system("%s libsrtp.vcxproj" % self.msbuild_path)
+            os.chdir("../../../pjnath/build")
+            os.system("%s pjnath.vcxproj" % self.msbuild_path)
+            os.chdir("../../pjsip/build")
+            os.system("%s pjsip_simple.vcxproj" % self.msbuild_path)
+            os.system("%s pjsip_ua.vcxproj" % self.msbuild_path)
+            os.system("%s pjsip_core.vcxproj" % self.msbuild_path)
+            os.system("%s pjsua_lib.vcxproj" % self.msbuild_path)
+            os.chdir("../../../build")
+            os.system("%s %s" % (make, mkcmd))
+            os.chdir("..")
+        else:
+            os.system("./cmake/init-cmake.sh")
+            os.system("cmake --build ./build")
+    
+def test_ice():
+    print "\n\nBuilding Ice\n"
+    os.chdir("./cpp")
+    if plat == "Windows":
+        os.system("%s %s" % (make, mkcmd))
+        os.system("%s %s install" % (make, mkcmd))
+    elif plat == "SunOS":
+        os.system("%s MCPP_HOME=/usr/local EXPAT_HOME=/usr/sfw OPENSSL_HOME=/usr/sfw DB_HOME=/usr/local/BerkeleyDB.4.8" % make)
+        os.system("%s install" % make)
+    else:
+        os.system(make)
+        os.system("%s install" % make)
+    sys.exit(0)
+
+def test_slice_plugins():
+    print "\n\nBuilding Slice Plugins\n"
+    os.system("cmake .")
+    if plat == "Windows":
+        os.system("%s %s" % (make, mkcmd))
+        os.system("%s %s install" % (make, mkcmd))
+    elif plat == "SunOS":
+        os.system("%s MCPP_HOME=/usr/local EXPAT_HOME=/usr/sfw OPENSSL_HOME=/usr/sfw DB_HOME=/usr/local/BerkeleyDB.4.8" % make)
+        os.system("%s install" % make)
+    else:
+        os.system(make)
+        os.system("%s install" % make)
+    sys.exit(0)
+
+def readinfile(file):
+    try:
+        f = open(file, "r")
+    except IOError:
+        errorout("Failed to open 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')
+    if plat == "Windows":
+        os.system("%s %s install" % (make, mkcmd))
+    else:
+        os.system("%s install" % make)
+    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]")
+
+    arch = platform.machine()
+    plat = platform.system()
+    
+    print "\nRunning on %s %s\n" % (plat, arch)
+
+    crev = readinfile(".git/refs/heads/master").rstrip('\n')
+
+    if plat == "Windows":
+        make = '/PROGRA~1/MICROS~1.0/VC/bin/nmake.exe'
+        mkcmd = "-F Makefile.mak "
+        rmdircmd = "rmdir /S /Q"
+    elif plat == "SunOS":
+        make = "/usr/bin/gmake"
+        mkcmd = ""
+        rmdircmd = "rm -rf"
+    else:
+        make = "/usr/bin/make"
+        mkcmd = ""              
+        rmdircmd = "rm -rf"
+
+    print "\n"
+    for param in os.environ.keys():
+        print "%20s %s" % (param, os.environ[param])
+    print "\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:
+        test_asterisk_scf(args[1])
+
+    return 0
+
+if __name__ == "__main__":
+    sys.exit(main() or 1)
+
diff --git a/bamboo/bin/visual_studio_wrapper.bat b/bamboo/bin/visual_studio_wrapper.bat
new file mode 100644
index 0000000..da64ea8
--- /dev/null
+++ b/bamboo/bin/visual_studio_wrapper.bat
@@ -0,0 +1,39 @@
+ 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
+if not "%3" == "" 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%\test.py %2
+
+goto :eof
+
+:usage
+ECHO:
+ECHO Error in script usage. The correct usage is:
+ECHO     %0 [arch] [asterisk scf repo]
+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/bamboo/contrib/init.d/com.atlassian.BambooAgent.plist b/bamboo/contrib/init.d/com.atlassian.BambooAgent.plist
new file mode 100644
index 0000000..8d354d9
--- /dev/null
+++ b/bamboo/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/bamboo/contrib/init.d/rc.debian.bamboo-remote-agent b/bamboo/contrib/init.d/rc.debian.bamboo-remote-agent
new file mode 100644
index 0000000..8f63edb
--- /dev/null
+++ b/bamboo/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/bamboo/contrib/init.d/rc.redhat.bamboo-remote-agent b/bamboo/contrib/init.d/rc.redhat.bamboo-remote-agent
new file mode 100644
index 0000000..d12c579
--- /dev/null
+++ b/bamboo/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/testsuite.git



More information about the asterisk-scf-commits mailing list