[asterisk-commits] pabelanger: branch pabelanger/run_tests r373393 - in /team/pabelanger/run_tes...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Sep 22 17:11:45 CDT 2012


Author: pabelanger
Date: Sat Sep 22 17:11:42 2012
New Revision: 373393

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=373393
Log:
Initial commit


Added:
    team/pabelanger/run_tests/run_tests.sh   (with props)
    team/pabelanger/run_tests/tools/
    team/pabelanger/run_tests/tools/pbuilderrc   (with props)

Added: team/pabelanger/run_tests/run_tests.sh
URL: http://svnview.digium.com/svn/asterisk/team/pabelanger/run_tests/run_tests.sh?view=auto&rev=373393
==============================================================================
--- team/pabelanger/run_tests/run_tests.sh (added)
+++ team/pabelanger/run_tests/run_tests.sh Sat Sep 22 17:11:42 2012
@@ -1,0 +1,117 @@
+#!/bin/bash
+# Based on OpenStack Horizon's run_tests.sh script
+# https://github.com/openstack/horizon/blob/master/run_tests.sh
+
+set -o errexit
+
+# ---------------UPDATE ME-------------------------------#
+# Increment me any time the environment should be rebuilt.
+# This includes dependncy changes, directory renames, etc.
+# Simple integer secuence: 1, 2, 3...
+environment_version=1
+#--------------------------------------------------------#
+
+function usage {
+    echo "Usage: $0 [OPTION]..."
+    echo ""
+    exit
+}
+
+root=$HOME
+venv=/var/cache/pbuilder
+
+always_venv=0
+destroy=0
+force=0
+never_venv=0
+
+DISTS="precise lucid"
+ARCHS="i386 amd64"
+
+function process_option {
+    case "$1" in
+        -N|--no-virtual-env) always_venv=0; never_venv=1;;
+        -f|--force) force=1;;
+        -h|--help) usage;; 
+        --destroy-environment) destroy=1;;
+    *) testargs="$testargs $1"
+    esac
+}
+
+function destroy_venv {
+    echo "Removing environment..."
+    rm -rf $venv
+    rm -f .environment_version
+    echo "Environment removed."
+}
+
+function sanity_check {
+    if [ $never_venv -eq 0 ]; then
+        if [ ! -e ${venv} ]; then
+            echo "Virtualenv not found at $venv. Did you install it?"
+	    exit 1
+        fi
+    fi
+}
+
+function install_venv {
+    for dist in ${DISTS}; do
+        for arch in ${ARCHS}; do
+            if ! [ -f ${venv}/${dist}-${arch}-base.tgz ]; then
+                sudo DIST=${dist} ARCH=${arch} pbuilder create --configfile tools/pbuilderrc
+            fi
+        done;
+    done;
+    sanity_check
+    echo $environment_version > .environment_version
+}
+
+function environment_check {
+    echo "Checking environment."
+    if [ -f .environment_version ]; then
+        ENV_VERS=`cat .environment_version`
+	if [ $ENV_VERS -eq $environment_version ]; then
+            if [ -e ${venv} ]; then
+                echo "Environment is up to date."
+		return 0
+            fi
+        fi
+    fi
+
+    if [ $always_venv -eq 0 ]; then
+        if [ ! -e ${venv} ]; then
+            echo -e "Environment not found. Install? (Y/n) \c"
+        else
+            echo -e "Your environment appears to be out of date. Update? (Y/n) \c"
+        fi
+        read update_env
+        if [ "x$update_env" = "xY" -o "x$update_env" = "x" -o "x$update_env" = "xy" ]; then
+            install_venv
+        fi
+    else
+        install_venv
+    fi
+
+}
+
+function run_tests {
+    sanity_check
+}
+
+for arg in "$@"; do
+	process_option $arg
+done
+
+if [ $destroy -eq 1 ]; then
+    destroy_venv
+    exit 0
+fi 
+
+if [ $never_venv -eq 0 ]; then
+    if [ $force -eq 1 ]; then
+        destroy_venv
+    fi
+    environment_check
+fi
+
+run_tests || exit

Propchange: team/pabelanger/run_tests/run_tests.sh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/pabelanger/run_tests/run_tests.sh
------------------------------------------------------------------------------
    svn:executable = *

Propchange: team/pabelanger/run_tests/run_tests.sh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/pabelanger/run_tests/run_tests.sh
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/pabelanger/run_tests/tools/pbuilderrc
URL: http://svnview.digium.com/svn/asterisk/team/pabelanger/run_tests/tools/pbuilderrc?view=auto&rev=373393
==============================================================================
--- team/pabelanger/run_tests/tools/pbuilderrc (added)
+++ team/pabelanger/run_tests/tools/pbuilderrc Sat Sep 22 17:11:42 2012
@@ -1,0 +1,93 @@
+PBUILDER_DIR=/var/cache/pbuilder
+mkdir -p ${PBUILDER_DIR}/ccache
+mkdir -p ${PBUILDER_DIR}/hook.d
+
+export CCACHE_DIR="${PBUILDER_DIR}/ccache"
+export PATH="/usr/lib/ccache:${PATH}"
+EXTRAPACKAGES="ccache"
+BINDMOUNTS="${CCACHE_DIR} ${PWD}"
+ 
+# Codenames for Debian suites according to their alias. Update these when
+# needed.
+UNSTABLE_CODENAME="sid"
+TESTING_CODENAME="wheezy"
+STABLE_CODENAME="squeeze"
+OLDSTABLE_CODENAME="lenny"
+STABLE_BACKPORTS_SUITE="$STABLE_CODENAME-backports"
+  
+# List of Debian suites.
+DEBIAN_SUITES=($UNSTABLE_CODENAME $TESTING_CODENAME $STABLE_CODENAME $OLDSTABLE_CODENAME
+    "unstable" "testing" "stable" "oldstable")
+  
+# List of Ubuntu suites. Update these when needed.
+UBUNTU_SUITES=("precise" "oneiric" "natty" "maverick" "lucid")
+  
+# Mirrors to use. Update these to your preferred mirror.
+DEBIAN_MIRROR="ftp.us.debian.org"
+UBUNTU_MIRROR="mirrors.kernel.org"
+  
+# Optionally use the changelog of a package to determine the suite to use if
+# none set.
+if [ -z "${DIST}" ] && [ -r "debian/changelog" ]; then
+    DIST=$(dpkg-parsechangelog | awk '/^Distribution: / {print $2}')
+    # Use the unstable suite for certain suite values.
+    if $(echo "experimental UNRELEASED" | grep -q $DIST); then
+        DIST="$UNSTABLE_CODENAME"
+    fi
+fi
+  
+# Optionally set a default distribution if none is used. Note that you can set
+# your own default (i.e. ${DIST:="unstable"}).
+: ${DIST:="$(lsb_release --short --codename)"}
+  
+# Optionally change Debian release states in $DIST to their names.
+case "$DIST" in
+    unstable)
+        DIST="$UNSTABLE_CODENAME"
+        ;;
+    testing)
+        DIST="$TESTING_CODENAME"
+        ;;
+    stable)
+        DIST="$STABLE_CODENAME"
+        ;;
+    oldstable)
+        DIST="$OLDSTABLE_CODENAME"
+        ;;
+esac
+  
+# Optionally set the architecture to the host architecture if none set. Note
+# that you can set your own default (i.e. ${ARCH:="i386"}).
+: ${ARCH:="$(dpkg --print-architecture)"}
+  
+NAME="$DIST"
+if [ -n "${ARCH}" ]; then
+    NAME="$NAME-$ARCH"
+    DEBOOTSTRAPOPTS=("--arch" "$ARCH" "${DEBOOTSTRAPOPTS[@]}")
+fi
+ 
+DEBBUILDOPTS="-b"
+if [ "${ARCH}" == "i386" ]; then
+    DEBBUILDOPTS="-B"
+fi
+ 
+BASETGZ="${PBUILDER_DIR}/$NAME-base.tgz"
+DISTRIBUTION="$DIST"
+BUILDRESULT="${PBUILDER_DIR}/$NAME/result/"
+APTCACHE="${PBUILDER_DIR}/$NAME/aptcache/"
+BUILDPLACE="${PBUILDER_DIR}/build/"
+  
+if $(echo ${DEBIAN_SUITES[@]} | grep -q $DIST); then
+    # Debian configuration
+    MIRRORSITE="http://$DEBIAN_MIRROR/debian/"
+    COMPONENTS="main contrib non-free"
+    DEBOOTSTRAPOPTS=("${DEBOOTSTRAPOPTS[@]}" "--keyring=/usr/share/keyrings/debian-archive-keyring.gpg")
+elif $(echo ${UBUNTU_SUITES[@]} | grep -q $DIST); then
+    # Ubuntu configuration
+    MIRRORSITE="http://$UBUNTU_MIRROR/ubuntu/"
+    COMPONENTS="main universe"
+    DEBOOTSTRAPOPTS=("${DEBOOTSTRAPOPTS[@]}" "--keyring=/usr/share/keyrings/ubuntu-archive-keyring.gpg")
+else
+    echo "Unknown distribution: $DIST"
+    exit 1
+fi

Propchange: team/pabelanger/run_tests/tools/pbuilderrc
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/pabelanger/run_tests/tools/pbuilderrc
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/pabelanger/run_tests/tools/pbuilderrc
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the asterisk-commits mailing list