openVibeTests.cmake 9.32 KB
Newer Older
Jussi Lindgren's avatar
tests:  
Jussi Lindgren committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.4)

# REMOVE if all test is passed 
# set(CMAKE_LEGACY_CYGWIN_WIN32 0)  # Remove when CMake >= 2.8.4 is required
#------------------------

# to exec test ctest -S thisfile
# -----------------------------------------------------------  
# -- Get environment
# -----------------------------------------------------------  

## -- Set hostname
## --------------------------
find_program(HOSTNAME_CMD NAMES hostname)
exec_program(${HOSTNAME_CMD} ARGS OUTPUT_VARIABLE HOSTNAME)
16 17 18

# env variables are checked because ubuntu 12.04 ctest doesn't let pass vars from command line it seems?

Jussi Lindgren's avatar
tests:  
Jussi Lindgren committed
19
IF(NOT DEFINED CTEST_SITE)
20 21 22 23 24
	IF(DEFINED ENV{CTEST_SITE})
		SET(CTEST_SITE $ENV{CTEST_SITE})
	ELSE(DEFINED ENV{CTEST_SITE})
		SET(CTEST_SITE                          "${HOSTNAME}")
	ENDIF(DEFINED ENV{CTEST_SITE})
25 26
ENDIF(NOT DEFINED CTEST_SITE)

27 28 29
# SET GIT parameters

IF(NOT DEFINED CTEST_GIT_URL)
30 31 32 33 34
	IF(DEFINED ENV{CTEST_GIT_URL})
		SET(CTEST_GIT_URL $ENV{CTEST_GIT_URL})
	ELSE(DEFINED ENV{CTEST_GIT_URL})
		SET(CTEST_GIT_URL                          "git://scm.gforge.inria.fr/openvibe/openvibe.git")
	ENDIF(DEFINED ENV{CTEST_GIT_URL})
35
ENDIF(NOT DEFINED CTEST_GIT_URL)
36

37
IF(NOT DEFINED CTEST_BRANCH)
38 39 40 41 42
        IF(DEFINED ENV{CTEST_BRANCH})
                SET(CTEST_BRANCH $ENV{CTEST_BRANCH})
        ELSE(DEFINED ENV{CTEST_BRANCH})
                SET(CTEST_BRANCH                          "master")
        ENDIF(DEFINED ENV{CTEST_BRANCH})
43
ENDIF(NOT DEFINED CTEST_BRANCH)
Jussi Lindgren's avatar
tests:  
Jussi Lindgren committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

## -- Set site / build name
## --------------------------

find_program(UNAME NAMES uname)
macro(getuname name flag)
  exec_program("${UNAME}" ARGS "${flag}" OUTPUT_VARIABLE "${name}")
endmacro(getuname)

IF(WIN32)
	SET(distrib "")
	SET(distrib-release "")
ELSE(WIN32)
	find_program(LSB_RELEASE NAMES lsb_release)
	exec_program("${LSB_RELEASE}" ARGS "-si" OUTPUT_VARIABLE "distrib")
	exec_program("${LSB_RELEASE}" ARGS "-sr" OUTPUT_VARIABLE "distrib-release")
ENDIF(WIN32)

getuname(osname -s)
getuname(osrel  -r)
getuname(cpu    -m)

66
set(CTEST_BUILD_NAME                    "${CTEST_BRANCH}_${osname}_${cpu}_${distrib}${distrib-release}")
Jussi Lindgren's avatar
tests:  
Jussi Lindgren committed
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93


# -----------------------------------------------------------  
# -- build specific
# -----------------------------------------------------------  

SET(MODEL Nightly)
IF(${CTEST_SCRIPT_ARG} MATCHES Experimental)
  SET(MODEL Experimental)
ENDIF(${CTEST_SCRIPT_ARG} MATCHES Experimental)
IF(${CTEST_SCRIPT_ARG} MATCHES Continuous)
  SET(MODEL Continuous)
ENDIF(${CTEST_SCRIPT_ARG} MATCHES Continuous)

IF(${MODEL} MATCHES Continuous)
	set(OV_ROOT_DIR              "${CMAKE_CURRENT_SOURCE_DIR}")
ELSE(${MODEL} MATCHES Continuous)
	# create a temporary directory with very short name to host build
	exec_program("mktemp" ARGS "--tmpdir -d ov.XXX" OUTPUT_VARIABLE OV_ROOT_DIR)
ENDIF(${MODEL} MATCHES Continuous)

####

## -- SRC Dir
set(CTEST_SOURCE_DIRECTORY              "${OV_ROOT_DIR}/trunk")

## -- BIN Dir
94
set(CTEST_BINARY_DIRECTORY	              "${OV_ROOT_DIR}/dist") 
Jussi Lindgren's avatar
tests:  
Jussi Lindgren committed
95 96 97 98 99 100 101 102

## -- DashBoard Root
set(CTEST_DASHBOARD_ROOT                "${CMAKE_CURRENT_SOURCE_DIR}")

# -----------------------------------------------------------  
# -- commands
# -----------------------------------------------------------  

103 104 105
find_program(CTEST_GIT_COMMAND NAMES git) 


Jussi Lindgren's avatar
tests:  
Jussi Lindgren committed
106 107
## -- Checkout command
if(NOT EXISTS "${CTEST_SOURCE_DIRECTORY}")
108
	set(CTEST_CHECKOUT_COMMAND     "${CTEST_GIT_COMMAND} clone -b ${CTEST_BRANCH} ${CTEST_GIT_URL} ${CTEST_SOURCE_DIRECTORY}")
Jussi Lindgren's avatar
tests:  
Jussi Lindgren committed
109 110 111
endif(NOT EXISTS "${CTEST_SOURCE_DIRECTORY}")

## -- Update Command
112 113
#set(CTEST_UPDATE_COMMAND               "${CTEST_GIT_COMMAND} pull")
set(CTEST_UPDATE_COMMAND "${CTEST_GIT_COMMAND}")
Jussi Lindgren's avatar
tests:  
Jussi Lindgren committed
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152


SET(NEED_CONFIGURE TRUE) 
IF(WIN32)
	## -- Configure Command
	IF(${MODEL} MATCHES Continuous)
		IF(EXISTS "${CTEST_SOURCE_DIRECTORY}/dependencies/Uninstall.exe")
			SET(NEED_CONFIGURE FALSE) 
		ENDIF(EXISTS "${CTEST_SOURCE_DIRECTORY}/dependencies/Uninstall.exe")
	ENDIF(${MODEL} MATCHES Continuous)
	set(CTEST_CONFIGURE_COMMAND            "${CTEST_SOURCE_DIRECTORY}/scripts/win32-install_dependencies.exe /S")

	## -- Build Command
	set(CTEST_BUILD_COMMAND                "cmd /C \"win32-build.cmd --no-pause\"")
ELSE(WIN32)
	## -- Configure Command
	set(CTEST_CONFIGURE_COMMAND            "${CMAKE_CURRENT_SOURCE_DIR}/InstallDependencies")
	## -- Build Command
	set(CTEST_BUILD_COMMAND                "${CTEST_SOURCE_DIRECTORY}/scripts/linux-build")
ENDIF(WIN32)


# -----------------------------------------------------------  
# -- Configure CTest
# -----------------------------------------------------------  

## set for automatic test, not for in place local test 
SET(TEST_LOCAL FALSE)

## -- CTest Config
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CTestConfig.cmake  ${CTEST_BINARY_DIRECTORY}/CTestConfig.cmake)

## -- CTest Custom
#configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake ${CTEST_BINARY_DIRECTORY}/CTestCustom.cmake)

## -- CTest Testfile
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CTestTestfile.cmake ${CTEST_BINARY_DIRECTORY}/CTestTestfile.cmake)


153
# passthrough an environment variable to binary path to tests
Jussi Lindgren's avatar
tests:  
Jussi Lindgren committed
154
SET(ENV{OV_BINARY_PATH} "${CTEST_SOURCE_DIRECTORY}/dist")
155

Jussi Lindgren's avatar
tests:  
Jussi Lindgren committed
156 157 158
## -- read CTestCustom.cmake file
ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}")

159 160
# this is the folder where test scenarios can be run under
SET(ENV{OV_TEST_DEPLOY_PATH} "${CTEST_SOURCE_DIRECTORY}/local-tmp/test-deploy/")
161 162 163 164 165 166 167 168

MESSAGE("Directories used:")
MESSAGE("-- Set the OV_ROOT_DIR to            ${OV_ROOT_DIR}")
MESSAGE("-- Set the CTEST_SOURCE_DIRECTORY to ${CTEST_SOURCE_DIRECTORY}")
MESSAGE("-- Set the CTEST_BINARY_DIRECTORY to ${CTEST_BINARY_DIRECTORY}")
MESSAGE("-- Set the CTEST_DASHBOARD_ROOT to   ${CTEST_DASHBOARD_ROOT}")
MESSAGE("-- Set the OV_TEST_DEPLOY_PATH to    $ENV{OV_TEST_DEPLOY_PATH}")
MESSAGE("-- Set the OV_BINARY_PATH to         $ENV{OV_BINARY_PATH}")
169

Jussi Lindgren's avatar
tests:  
Jussi Lindgren committed
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
#~ SET(CTEST_PROJECT_NAME "OpenViBe")
#~ # set time for update 
#~ SET(CTEST_NIGHTLY_START_TIME "19:00:00 CEST")
#~ SET(CTEST_DROP_METHOD "http")
#~ SET(CTEST_DROP_SITE "cdash.inria.fr")
#~ SET(CTEST_DROP_LOCATION "/CDash/submit.php?project=OpenViBe")
#~ SET(CTEST_DROP_SITE_CDASH TRUE)
# -----------------------------------------------------------  
# -- Settings
# -----------------------------------------------------------  

## -- Process timeout in seconds
set(CTEST_TIMEOUT           "7200")

## -- Set output to english
set(ENV{LC_MESSAGES}      "en_EN" )




# -----------------------------------------------------------  
# -- Run CTest
# -----------------------------------------------------------  

## -- Start
message(" -- Start dashboard ${MODEL} - ${CTEST_BUILD_NAME} --")
ctest_start(${MODEL} TRACK ${MODEL})

## Test if another continuous test is not finished 
IF(${MODEL} MATCHES Continuous)
	IF(NOT EXISTS "lock")
		FILE(WRITE "lock" "remove if needed")
	ELSE(NOT EXISTS "lock")
		RETURN()
	ENDIF(NOT EXISTS "lock")
ENDIF(${MODEL} MATCHES Continuous)

207
## -- 'CLEAN UP' leftover processes, a hack
208 209 210 211 212 213
## this may not be safe unless we know that no concurrent test runs are performed - do we?
#IF(UNIX)
#    message(" -- Terminating any leftover designers ${MODEL} - ${CTEST_BUILD_NAME} --")
#	find_program(KILLALL NAMES killall)
#	exec_program("${KILLALL}" ARGS "-KILL openvibe-designer" OUTPUT_VARIABLE "KILLALL_RESULT")
#ENDIF(UNIX)
214

Jussi Lindgren's avatar
tests:  
Jussi Lindgren committed
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
set(ALL_OK TRUE)
## -- Update
IF(ALL_OK)
	message(" -- Update ${MODEL} - ${CTEST_BUILD_NAME} --")
	ctest_update( SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res)
	IF(res EQUAL -1) 
		message(SEND_ERROR "  Update failed.")
		set(ALL_OK FALSE)
	ENDIF(res EQUAL -1)
	##  run build and test for continuous integration model only if there was a new update
	IF(res EQUAL 0 AND ${MODEL} MATCHES Continuous)
		# unlock before exit
		FILE(REMOVE "lock")
		RETURN()
	ENDIF(res EQUAL 0 AND ${MODEL} MATCHES Continuous)
ENDIF(ALL_OK)


## -- Configure	
IF(ALL_OK)
	IF(NEED_CONFIGURE)  
		message(" -- Configure ${MODEL} - ${CTEST_BUILD_NAME} --")
		ctest_configure(BUILD  "${CTEST_SOURCE_DIRECTORY}/scripts" SOURCE "${CTEST_SOURCE_DIRECTORY}/scripts" RETURN_VALUE res)
		IF( NOT (res EQUAL 0)) 
			message(SEND_ERROR "  Configure failed.")
			set(ALL_OK FALSE)	
		ENDIF( NOT (res EQUAL 0))
	ENDIF(NEED_CONFIGURE)  
ENDIF(ALL_OK)
	
## -- BUILD
IF(ALL_OK)
	message(" -- Build ${MODEL} - ${CTEST_BUILD_NAME} --")
	ctest_build(BUILD  "${CTEST_SOURCE_DIRECTORY}/scripts" SOURCE "${CTEST_SOURCE_DIRECTORY}/scripts" RETURN_VALUE res)
	IF( NOT (res EQUAL 0)) 
		message(SEND_ERROR "  Build failed.")
		set(ALL_OK FALSE)
	ENDIF( NOT (res EQUAL 0))
ENDIF(ALL_OK)

## -- TEST
IF(ALL_OK)
	message(" -- Test ${MODEL} - ${CTEST_BUILD_NAME} --")
	set( ENV{CTEST_BINARY_DIRECTORY}    "${CTEST_BINARY_DIRECTORY}" )
	ctest_test(BUILD  "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
	message(STATUS "  INFO : ctest_test(...) returned '${res}'")
ENDIF(ALL_OK)

## -- SUBMIT
message(" -- Submit ${MODEL} - ${CTEST_BUILD_NAME} --")

ctest_submit(                                              RETURN_VALUE res)
message(STATUS "  INFO : submit(...) returned '${res}'")

message(" -- Finished ${MODEL}  - ${CTEST_BUILD_NAME} --")

271 272 273 274 275 276
# IF(${MODEL} MATCHES Nightly)
# 	message(" -- clean ${MODEL}  - ${CTEST_BUILD_NAME} --")
# 	ctest_empty_binary_directory(${CTEST_SOURCE_DIRECTORY})
#	ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
#   exec_program("rm" ARGS "-rf ${CTEST_SOURCE_DIRECTORY}" OUTPUT_VARIABLE "cleanScript")
# ENDIF(${MODEL} MATCHES Nightly)
Jussi Lindgren's avatar
tests:  
Jussi Lindgren committed
277 278 279 280 281

## unlock if continous build
IF(${MODEL} MATCHES Continuous)
	FILE(REMOVE "lock")
ENDIF(${MODEL} MATCHES Continuous)