blob: e339b9be73da61a49c74136377b7c9212e66f87a [file] [log] [blame]
Brian Waters13d96012017-12-08 16:53:31 -06001#!/bin/bash -x
2
3# This script will retrieve the list of tests to run from the freediameter website,
4# and execute them one by one.
5
6ROOTDIR=$HOME/fDtests
7if [ ! -d $ROOTDIR ]; then
8 echo "The working directory $ROOTDIR does not exist. Please create it or edit the script."
9 exit 1;
10fi
11
12WORKDIR=$ROOTDIR/data
13
14# The script requires a local.cmake file to exist and define the following:
15# CTEST_SITE=
16# the name of the build slave.
17# Example: SET(CTEST_SITE "Ubuntu-Lucid-64b")
18if [ ! -e $ROOTDIR/local.cmake ]; then
19 echo "Missing $ROOTDIR/local.cmake file, generating one (edit as needed, and run the script again)";
20 echo "SET(CTEST_SITE \""`hostname --fqdn`"\")" > $ROOTDIR/local.cmake
21 exit 1;
22fi
23
24# Now, cleanup any previous built data, but keep the sources (to get the diffs)
25if [ ! -d $WORKDIR ]; then
26 mkdir $WORKDIR
27else
28 rm -rf $WORKDIR/*/build
29fi
30
31echo "Starting Nightly tests, time: "`date`
32
33# Retrieve the default parameters.
34wget "http://www.freediameter.net/hg/freeDiameter/raw-file/tip/CTestConfig.cmake" -O $WORKDIR/1_default.cmake
35if [ ! -e $WORKDIR/1_default.cmake ]; then
36 echo "Error retrieving CTestConfig.cmake file";
37 exit 1;
38fi
39
40# Retrieve the list of build names
41wget "http://www.freediameter.net/hg/freeDiameter/raw-file/tip/contrib/nightly_tests/tests.list" -O $WORKDIR/2_tests.list
42if [ ! -e $WORKDIR/2_tests.list ]; then
43 echo "Error retrieving tests.list file";
44 exit 1;
45fi
46
47# Now, for each test in the list
48for t in $(cat $WORKDIR/2_tests.list | grep -v -e "^#"); do
49 # Create the work environment if needed
50 if [ ! -d $WORKDIR/$t ]; then
51 mkdir $WORKDIR/$t
52 fi
53
54 #### Create the script
55
56 # Project name, nightly time
57 cp $WORKDIR/1_default.cmake $WORKDIR/$t/CTestScript.cmake
58
59 # Create path names, default build configuration, ...
60 cat >> $WORKDIR/$t/CTestScript.cmake << EOF
61 ##########################
62 SET(CTEST_SOURCE_DIRECTORY "$WORKDIR/$t/source")
63 SET(CTEST_BINARY_DIRECTORY "$WORKDIR/$t/build")
64
65 set(CTEST_CMAKE_GENERATOR "Unix Makefiles")
66
67 set(CTEST_BUILD_CONFIGURATION "Profiling")
68 set(WITH_MEMCHECK FALSE)
69 set(WITH_COVERAGE FALSE)
70
71 set(CTEST_BUILD_OPTIONS "")
72 set(CTEST_BUILD_NAME "Unnamed")
73
74 ##########################
75EOF
76
77 wget "http://www.freediameter.net/hg/freeDiameter/raw-file/tip/contrib/nightly_tests/$t.conf" -O $WORKDIR/$t/params.conf
78 if [ ! -e $WORKDIR/$t/params.conf ]; then
79 echo "Error retrieving $t.conf file";
80 continue;
81 fi
82
83 # The retrieved parameters will overwrite the defaults
84 cat $WORKDIR/$t/params.conf >> $WORKDIR/$t/CTestScript.cmake
85
86 # Overwrite with all the local data (site name, ...)
87 echo "######## Local site data: " >> $WORKDIR/$t/CTestScript.cmake
88 cat $ROOTDIR/local.cmake >> $WORKDIR/$t/CTestScript.cmake
89
90 # Now, the remaining of the script
91 cat >> $WORKDIR/$t/CTestScript.cmake << EOF
92 #######################################################################
93
94 # ctest_empty_binary_directory(\${CTEST_BINARY_DIRECTORY})
95
96 find_program(CTEST_HG_COMMAND NAMES hg)
97 find_program(CTEST_COVERAGE_COMMAND NAMES gcov)
98 find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind)
99
100 # set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE \${CTEST_SOURCE_DIRECTORY}/tests/valgrind.supp)
101
102 if(NOT EXISTS "\${CTEST_SOURCE_DIRECTORY}")
103 set(CTEST_CHECKOUT_COMMAND "\${CTEST_HG_COMMAND} clone http://www.freediameter.net/hg/freeDiameter \${CTEST_SOURCE_DIRECTORY}")
104 endif()
105
106 set(CTEST_UPDATE_COMMAND "\${CTEST_HG_COMMAND}")
107
108 set(CTEST_CONFIGURE_COMMAND "\${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE:STRING=\${CTEST_BUILD_CONFIGURATION}")
109 set(CTEST_CONFIGURE_COMMAND "\${CTEST_CONFIGURE_COMMAND} -DBUILD_TESTING:BOOL=ON -DOPT_TEST_ARGUMENTS:STRING=-d \${CTEST_BUILD_OPTIONS}")
110 set(CTEST_CONFIGURE_COMMAND "\${CTEST_CONFIGURE_COMMAND} \\"-G\${CTEST_CMAKE_GENERATOR}\\"")
111 set(CTEST_CONFIGURE_COMMAND "\${CTEST_CONFIGURE_COMMAND} \\"\${CTEST_SOURCE_DIRECTORY}\\"")
112
113 ctest_start("Nightly")
114 ctest_update()
115 ctest_configure()
116 ctest_build()
117 ctest_test()
118 if (WITH_COVERAGE AND CTEST_COVERAGE_COMMAND)
119 ctest_coverage()
120 endif (WITH_COVERAGE AND CTEST_COVERAGE_COMMAND)
121 if (WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND)
122 ctest_memcheck()
123 endif (WITH_MEMCHECK AND CTEST_MEMORYCHECK_COMMAND)
124 ctest_submit()
125EOF
126
127 # OK, now run this test, it will submit its results.
128 ctest -S $WORKDIR/$t/CTestScript.cmake -V
129done
130
131echo "Completed Nightly tests, time: "`date`
132
133