Initial commit
Change-Id: I6a4444e3c193dae437cd7929f4c39aba7b749efa
diff --git a/contrib/nightly_tests/README b/contrib/nightly_tests/README
new file mode 100644
index 0000000..67d97e9
--- /dev/null
+++ b/contrib/nightly_tests/README
@@ -0,0 +1,86 @@
+This folder contains information and scripts to run a new test configuration for nightly builds
+and reporting the results to freeDiameter dashboard at:
+ http://www.freediameter.net/CDash/index.php?project=freeDiameter
+
+The information gathered here mostly comes from the following pages:
+ http://www.itk.org/Wiki/CMake_Testing_With_CTest
+ http://www.itk.org/Wiki/CMake_Scripting_Of_CTest
+ http://www.itk.org/Wiki/CTest:Buildserver
+
+=============
+
+INSTRUCTIONS to setup a new build slave for the freeDiameter buildserver:
+-- note: the build slave should have cmake version 2.8 at least so that ctest will update the source tree properly.
+
+1) Install all dependencies for freeDiameter as follow:
+ a) Debian / Ubuntu: See the "prereqs.ubuntu" file
+ $ sudo aptitude install `wget http://www.freediameter.net/hg/freeDiameter/raw-file/tip/contrib/nightly_tests/prereqs.ubuntu -O - | grep -v -e "^#"`
+
+ b) FreeBSD: See the "prereqs.freebsd" file
+ - install base system and ports
+ - install freediameter dependencies as follow:
+ # pkg_add -r -v wget
+ # pkg_add -r -v `wget http://www.freediameter.net/hg/freeDiameter/raw-file/tip/contrib/nightly_tests/prereqs.freebsd -O - | grep -v -e "^#"`
+
+ c) OpenSUSE:
+ $ sudo zypper install `wget http://www.freediameter.net/hg/freeDiameter/raw-file/tip/contrib/nightly_tests/prereqs.opensuse -O - | grep -v -e "^#"`
+
+ d) Fedora:
+ $ sudo yum install wget
+ $ sudo yum install `wget http://www.freediameter.net/hg/freeDiameter/raw-file/tip/contrib/nightly_tests/prereqs.fedora -O - | grep -v -e "^#"`
+
+ You may also have issues with SELinux later, an easy workaround is to disable it (until better solution)
+ # setenforce Permissive
+
+
+2) Create the "test" database for app_acct test (we assume the tests are run as user "test" here)
+ - check INSTALL.FreeBSD file for specific PostgreSQL pre-install instructions.
+ - These are the instructions for Debian/Ubuntu/OpenSUSE, adjust as needed:
+ # su - postgres
+ # createuser --interactive test
+ Shall the new role be a superuser? (y/n) n
+ Shall the new role be allowed to create databases? (y/n) y
+ Shall the new role be allowed to create more new roles? (y/n) n
+ # logout
+ $ whoami
+ test
+ $ createdb test
+ $ psql test
+ psql (8.4.4)
+ Type "help" for help.
+
+ test=>
+ CREATE TABLE incoming_test (
+ recorded_on timestamp with time zone NOT NULL,
+ "Accounting-Record-Type" integer,
+ "Session-Id" bytea,
+ "Accounting-Record-Number" integer,
+ "Route-Record1" bytea,
+ "Route-Record2" bytea,
+ "Route-Record3" bytea,
+ "Route-Record4" bytea );
+ \q
+
+
+3) Create a directory ~/fDtests
+ $ cd
+ $ mkdir fDtests
+ $ cd fDtests
+
+4) Retrieve the runtests.sh script and save in this directory
+ $ wget http://www.freediameter.net/hg/freeDiameter/raw-file/tip/contrib/nightly_tests/runtests.sh
+ $ chmod +x runtests.sh
+
+5) Create a file local.cmake defining the name of the build slave in this directory also.
+ $ echo "SET(CTEST_SITE \""`hostname`"\")" > local.cmake
+
+ For FreeBSD, in addition do:
+ $ echo "set(CTEST_BUILD_OPTIONS \"\${CTEST_BUILD_OPTIONS} -DFLEX_EXECUTABLE:FILEPATH=/usr/local/bin/flex\")" >> local.cmake
+
+6) Run the runtests.sh script once to check it works properly (freeBSD might require: ln -s /usr/local/bin/bash /bin/bash)
+
+7) Set up a crontab to run the script
+ $ wget http://www.freediameter.net/hg/freeDiameter/raw-file/tip/contrib/nightly_tests/cronjob.sh
+ $ chmod +x cronjob.sh
+ $ crontab -l
+0 0 * * * /home/test/fDtests/cronjob.sh > /home/test/fDtests/cronjob.log 2>&1
diff --git a/contrib/nightly_tests/alldefault.conf b/contrib/nightly_tests/alldefault.conf
new file mode 100644
index 0000000..0376918
--- /dev/null
+++ b/contrib/nightly_tests/alldefault.conf
@@ -0,0 +1,2 @@
+
+set(CTEST_BUILD_NAME "Default")
diff --git a/contrib/nightly_tests/allext.conf b/contrib/nightly_tests/allext.conf
new file mode 100644
index 0000000..ba94a09
--- /dev/null
+++ b/contrib/nightly_tests/allext.conf
@@ -0,0 +1,9 @@
+
+# This configuration compiles all the extensions. It also performs a coverage test.
+# For this to pass, you need to setup the pg database for app_acct test.
+
+set(CTEST_BUILD_NAME "All extensions (default)")
+
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DALL_EXTENSIONS:BOOL=ON")
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DTEST_APP_ACCT:BOOL=ON -DTEST_APP_ACCT_CONNINFO:STRING=user=test\\ dbname=test")
+
diff --git a/contrib/nightly_tests/allextdbg.conf b/contrib/nightly_tests/allextdbg.conf
new file mode 100644
index 0000000..60e9df6
--- /dev/null
+++ b/contrib/nightly_tests/allextdbg.conf
@@ -0,0 +1,11 @@
+
+# This configuration compiles all the extensions. It also performs a coverage test.
+# For this to pass, you need to setup the pg database for app_acct test.
+
+set(WITH_COVERAGE TRUE)
+set(CTEST_BUILD_NAME "All extensions (Debug)")
+
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DALL_EXTENSIONS:BOOL=ON")
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DCMAKE_BUILD_TYPE:STRING=Debug")
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DTEST_APP_ACCT:BOOL=ON -DTEST_APP_ACCT_CONNINFO:STRING=user=test\\ dbname=test")
+
diff --git a/contrib/nightly_tests/allextdeb.conf b/contrib/nightly_tests/allextdeb.conf
new file mode 100644
index 0000000..876baaf
--- /dev/null
+++ b/contrib/nightly_tests/allextdeb.conf
@@ -0,0 +1,10 @@
+
+# This configuration compiles all the extensions. It also performs a coverage test.
+# For this to pass, you need to setup the pg database for app_acct test.
+
+set(CTEST_BUILD_NAME "All extensions (DebianPackage)")
+
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DALL_EXTENSIONS:BOOL=ON")
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DCMAKE_BUILD_TYPE:STRING=DebianPackage")
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DTEST_APP_ACCT:BOOL=ON -DTEST_APP_ACCT_CONNINFO:STRING=user=test\\ dbname=test")
+
diff --git a/contrib/nightly_tests/allextmax.conf b/contrib/nightly_tests/allextmax.conf
new file mode 100644
index 0000000..a67468e
--- /dev/null
+++ b/contrib/nightly_tests/allextmax.conf
@@ -0,0 +1,10 @@
+
+# This configuration compiles all the extensions. It also performs a coverage test.
+# For this to pass, you need to setup the pg database for app_acct test.
+
+set(CTEST_BUILD_NAME "All extensions (MaxPerformance)")
+
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DALL_EXTENSIONS:BOOL=ON")
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DCMAKE_BUILD_TYPE:STRING=MaxPerformance")
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DTEST_APP_ACCT:BOOL=ON -DTEST_APP_ACCT_CONNINFO:STRING=user=test\\ dbname=test")
+
diff --git a/contrib/nightly_tests/allextprof.conf b/contrib/nightly_tests/allextprof.conf
new file mode 100644
index 0000000..9d6d66c
--- /dev/null
+++ b/contrib/nightly_tests/allextprof.conf
@@ -0,0 +1,11 @@
+
+# This configuration compiles all the extensions. It also performs a coverage test.
+# For this to pass, you need to setup the pg database for app_acct test.
+
+set(WITH_COVERAGE TRUE)
+set(CTEST_BUILD_NAME "All extensions (Profiling)")
+
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DALL_EXTENSIONS:BOOL=ON")
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DCMAKE_BUILD_TYPE:STRING=Profiling")
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DTEST_APP_ACCT:BOOL=ON -DTEST_APP_ACCT_CONNINFO:STRING=user=test\\ dbname=test")
+
diff --git a/contrib/nightly_tests/allextrel.conf b/contrib/nightly_tests/allextrel.conf
new file mode 100644
index 0000000..60457cb
--- /dev/null
+++ b/contrib/nightly_tests/allextrel.conf
@@ -0,0 +1,10 @@
+
+# This configuration compiles all the extensions. It also performs a coverage test.
+# For this to pass, you need to setup the pg database for app_acct test.
+
+set(CTEST_BUILD_NAME "All extensions (Release)")
+
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DALL_EXTENSIONS:BOOL=ON")
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DCMAKE_BUILD_TYPE:STRING=Release")
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DTEST_APP_ACCT:BOOL=ON -DTEST_APP_ACCT_CONNINFO:STRING=user=test\\ dbname=test")
+
diff --git a/contrib/nightly_tests/allextval.conf b/contrib/nightly_tests/allextval.conf
new file mode 100644
index 0000000..48e32aa
--- /dev/null
+++ b/contrib/nightly_tests/allextval.conf
@@ -0,0 +1,11 @@
+
+# This configuration compiles all the extensions. It also performs a coverage test.
+# For this to pass, you need to setup the pg database for app_acct test.
+
+set(WITH_COVERAGE TRUE)
+set(CTEST_BUILD_NAME "All extensions (DebugValgrind)")
+
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DALL_EXTENSIONS:BOOL=ON")
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DCMAKE_BUILD_TYPE:STRING=DebugValgrind")
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DTEST_APP_ACCT:BOOL=ON -DTEST_APP_ACCT_CONNINFO:STRING=user=test\\ dbname=test")
+
diff --git a/contrib/nightly_tests/cronjob.sh b/contrib/nightly_tests/cronjob.sh
new file mode 100644
index 0000000..de1809f
--- /dev/null
+++ b/contrib/nightly_tests/cronjob.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+# This script will simply retrieve the latest "runtest" script and run it.
+pushd ~/fDtests
+mv -f runtests.sh runtests.sh.prev
+wget "http://www.freediameter.net/hg/freeDiameter/raw-file/tip/contrib/nightly_tests/runtests.sh"
+chmod +x runtests.sh
+popd
+~/fDtests/runtests.sh
diff --git a/contrib/nightly_tests/idnaignore.conf b/contrib/nightly_tests/idnaignore.conf
new file mode 100644
index 0000000..5c344ac
--- /dev/null
+++ b/contrib/nightly_tests/idnaignore.conf
@@ -0,0 +1,4 @@
+
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DDIAMID_IDNA_IGNORE:BOOL=ON")
+
+set(CTEST_BUILD_NAME "IDNA Ignore")
diff --git a/contrib/nightly_tests/idnareject.conf b/contrib/nightly_tests/idnareject.conf
new file mode 100644
index 0000000..dbcbe69
--- /dev/null
+++ b/contrib/nightly_tests/idnareject.conf
@@ -0,0 +1,4 @@
+
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DDIAMID_IDNA_REJECT:BOOL=ON")
+
+set(CTEST_BUILD_NAME "IDNA Reject")
diff --git a/contrib/nightly_tests/nosctp.conf b/contrib/nightly_tests/nosctp.conf
new file mode 100644
index 0000000..f37aa3e
--- /dev/null
+++ b/contrib/nightly_tests/nosctp.conf
@@ -0,0 +1,5 @@
+
+# Remove SCTP support at compilation
+set(CTEST_BUILD_OPTIONS "${CTEST_BUILD_OPTIONS} -DDISABLE_SCTP:BOOL=ON")
+
+set(CTEST_BUILD_NAME "No SCTP")
diff --git a/contrib/nightly_tests/prereqs.fedora b/contrib/nightly_tests/prereqs.fedora
new file mode 100644
index 0000000..9be4305
--- /dev/null
+++ b/contrib/nightly_tests/prereqs.fedora
@@ -0,0 +1,15 @@
+# Fedora packages names of dependencies for nightly tests (using "yum install <packages>"):
+cmake make gcc gcc-c++ flex bison gnutls-devel libgcrypt-devel mercurial
+lksctp-tools-devel kernel-modules-extra
+postgresql-server postgresql-devel
+mysql-server mysql-devel
+libxml2 libxml2-devel libidn-devel
+swig python-devel
+
+# For postgresql server to start automatically, you may have to issue:
+# service postgresql initdb
+# chkconfig --level 345 postgresql on
+
+# To allow SCTP sockets to be bound in SELinux, I don't know the command,
+# so let's disable SELinux for the moment:
+# setenforce Permissive
diff --git a/contrib/nightly_tests/prereqs.freebsd b/contrib/nightly_tests/prereqs.freebsd
new file mode 100644
index 0000000..86a239e
--- /dev/null
+++ b/contrib/nightly_tests/prereqs.freebsd
@@ -0,0 +1,5 @@
+# 1: install base system and ports
+# 2: install wget with command: pkg_add -r -v wget
+# Finally, install the other packages from this file
+# pkg_add -r -F -v `wget http://www.freediameter.net/hg/freeDiameter/raw-file/tip/contrib/nightly_tests/prereqs.freebsd -O - | grep -v -e "^#"`
+bash cmake mercurial flex bison libgcrypt gnutls postgresql84-client postgresql84-server mysql50-client libxml2 swig
diff --git a/contrib/nightly_tests/prereqs.opensuse b/contrib/nightly_tests/prereqs.opensuse
new file mode 100644
index 0000000..2ece2dc
--- /dev/null
+++ b/contrib/nightly_tests/prereqs.opensuse
@@ -0,0 +1,9 @@
+# OpenSUSE packages names of dependencies for nightly tests (using "zypper install <packages>"):
+# zypper install `wget http://www.freediameter.net/hg/freeDiameter/raw-file/tip/contrib/nightly_tests/prereqs.opensuse -O - | grep -v -e "^#"`
+cmake mercurial make gcc gcc-c++ flex bison lksctp-tools-devel libgnutls-devel libgcrypt-devel
+postgresql-server postgresql-devel libmysqlclient-devel libxml2-devel swig python-devel
+
+# Afterwards, you may need to issue the following command so that postgresql starts at boot:
+# insserv postgresql
+# or for open Suse 12.x:
+# systemctl enable postgresql.service
diff --git a/contrib/nightly_tests/prereqs.ubuntu b/contrib/nightly_tests/prereqs.ubuntu
new file mode 100644
index 0000000..02ea907
--- /dev/null
+++ b/contrib/nightly_tests/prereqs.ubuntu
@@ -0,0 +1,3 @@
+# Packages (Ubuntu names)
+cmake mercurial make gcc g++ flex bison binutils libsctp-dev libgnutls-dev valgrind wget libpq-dev postgresql libmysqlclient-dev libxml2-dev libxml2 swig python-dev
+
diff --git a/contrib/nightly_tests/runtests.sh b/contrib/nightly_tests/runtests.sh
new file mode 100644
index 0000000..e339b9b
--- /dev/null
+++ b/contrib/nightly_tests/runtests.sh
@@ -0,0 +1,133 @@
+#!/bin/bash -x
+
+# This script will retrieve the list of tests to run from the freediameter website,
+# and execute them one by one.
+
+ROOTDIR=$HOME/fDtests
+if [ ! -d $ROOTDIR ]; then
+ echo "The working directory $ROOTDIR does not exist. Please create it or edit the script."
+ exit 1;
+fi
+
+WORKDIR=$ROOTDIR/data
+
+# The script requires a local.cmake file to exist and define the following:
+# CTEST_SITE=
+# the name of the build slave.
+# Example: SET(CTEST_SITE "Ubuntu-Lucid-64b")
+if [ ! -e $ROOTDIR/local.cmake ]; then
+ echo "Missing $ROOTDIR/local.cmake file, generating one (edit as needed, and run the script again)";
+ echo "SET(CTEST_SITE \""`hostname --fqdn`"\")" > $ROOTDIR/local.cmake
+ exit 1;
+fi
+
+# Now, cleanup any previous built data, but keep the sources (to get the diffs)
+if [ ! -d $WORKDIR ]; then
+ mkdir $WORKDIR
+else
+ rm -rf $WORKDIR/*/build
+fi
+
+echo "Starting Nightly tests, time: "`date`
+
+# Retrieve the default parameters.
+wget "http://www.freediameter.net/hg/freeDiameter/raw-file/tip/CTestConfig.cmake" -O $WORKDIR/1_default.cmake
+if [ ! -e $WORKDIR/1_default.cmake ]; then
+ echo "Error retrieving CTestConfig.cmake file";
+ exit 1;
+fi
+
+# Retrieve the list of build names
+wget "http://www.freediameter.net/hg/freeDiameter/raw-file/tip/contrib/nightly_tests/tests.list" -O $WORKDIR/2_tests.list
+if [ ! -e $WORKDIR/2_tests.list ]; then
+ echo "Error retrieving tests.list file";
+ exit 1;
+fi
+
+# Now, for each test in the list
+for t in $(cat $WORKDIR/2_tests.list | grep -v -e "^#"); do
+ # Create the work environment if needed
+ if [ ! -d $WORKDIR/$t ]; then
+ mkdir $WORKDIR/$t
+ fi
+
+ #### Create the script
+
+ # Project name, nightly time
+ cp $WORKDIR/1_default.cmake $WORKDIR/$t/CTestScript.cmake
+
+ # Create path names, default build configuration, ...
+ cat >> $WORKDIR/$t/CTestScript.cmake << EOF
+ ##########################
+ SET(CTEST_SOURCE_DIRECTORY "$WORKDIR/$t/source")
+ SET(CTEST_BINARY_DIRECTORY "$WORKDIR/$t/build")
+
+ set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
+
+ set(CTEST_BUILD_CONFIGURATION "Profiling")
+ set(WITH_MEMCHECK FALSE)
+ set(WITH_COVERAGE FALSE)
+
+ set(CTEST_BUILD_OPTIONS "")
+ set(CTEST_BUILD_NAME "Unnamed")
+
+ ##########################
+EOF
+
+ wget "http://www.freediameter.net/hg/freeDiameter/raw-file/tip/contrib/nightly_tests/$t.conf" -O $WORKDIR/$t/params.conf
+ if [ ! -e $WORKDIR/$t/params.conf ]; then
+ echo "Error retrieving $t.conf file";
+ continue;
+ fi
+
+ # The retrieved parameters will overwrite the defaults
+ cat $WORKDIR/$t/params.conf >> $WORKDIR/$t/CTestScript.cmake
+
+ # Overwrite with all the local data (site name, ...)
+ echo "######## Local site data: " >> $WORKDIR/$t/CTestScript.cmake
+ cat $ROOTDIR/local.cmake >> $WORKDIR/$t/CTestScript.cmake
+
+ # Now, the remaining of the script
+ cat >> $WORKDIR/$t/CTestScript.cmake << EOF
+ #######################################################################
+
+ # ctest_empty_binary_directory(\${CTEST_BINARY_DIRECTORY})
+
+ find_program(CTEST_HG_COMMAND NAMES hg)
+ find_program(CTEST_COVERAGE_COMMAND NAMES gcov)
+ find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind)
+
+ # set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE \${CTEST_SOURCE_DIRECTORY}/tests/valgrind.supp)
+
+ if(NOT EXISTS "\${CTEST_SOURCE_DIRECTORY}")
+ set(CTEST_CHECKOUT_COMMAND "\${CTEST_HG_COMMAND} clone http://www.freediameter.net/hg/freeDiameter \${CTEST_SOURCE_DIRECTORY}")
+ endif()
+
+ set(CTEST_UPDATE_COMMAND "\${CTEST_HG_COMMAND}")
+
+ set(CTEST_CONFIGURE_COMMAND "\${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE:STRING=\${CTEST_BUILD_CONFIGURATION}")
+ set(CTEST_CONFIGURE_COMMAND "\${CTEST_CONFIGURE_COMMAND} -DBUILD_TESTING:BOOL=ON -DOPT_TEST_ARGUMENTS:STRING=-d \${CTEST_BUILD_OPTIONS}")
+ set(CTEST_CONFIGURE_COMMAND "\${CTEST_CONFIGURE_COMMAND} \\"-G\${CTEST_CMAKE_GENERATOR}\\"")
+ set(CTEST_CONFIGURE_COMMAND "\${CTEST_CONFIGURE_COMMAND} \\"\${CTEST_SOURCE_DIRECTORY}\\"")
+
+ ctest_start("Nightly")
+ ctest_update()
+ ctest_configure()
+ ctest_build()
+ ctest_test()
+ if (WITH_COVERAGE AND CTEST_COVERAGE_COMMAND)
+ ctest_coverage()
+ endif (WITH_COVERAGE AND CTEST_COVERAGE_COMMAND)
+ if (WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND)
+ ctest_memcheck()
+ endif (WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND)
+ ctest_submit()
+EOF
+
+ # OK, now run this test, it will submit its results.
+ ctest -S $WORKDIR/$t/CTestScript.cmake -V
+done
+
+echo "Completed Nightly tests, time: "`date`
+
+
diff --git a/contrib/nightly_tests/tests.list b/contrib/nightly_tests/tests.list
new file mode 100644
index 0000000..afd2124
--- /dev/null
+++ b/contrib/nightly_tests/tests.list
@@ -0,0 +1,12 @@
+allext
+allextdbg
+allextval
+allextret
+allextprof
+allextmax
+allextdeb
+alldefault
+nosctp
+idnaignore
+idnareject
+#noext