Skip to content

Commit 70912a2

Browse files
committed
add script to run ctest and submit results
1 parent 01783dd commit 70912a2

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

run_ctest.cmake

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# run_ctest.cmake
2+
# `ctest -S run_ctest.cmake`
3+
4+
5+
# find number of processors, for faster builds
6+
# from http://www.kitware.com/blog/home/post/63
7+
if(NOT DEFINED PROCESSOR_COUNT)
8+
# Unknown:
9+
set(PROCESSOR_COUNT 0)
10+
11+
# Linux:
12+
set(cpuinfo_file "/proc/cpuinfo")
13+
if(EXISTS "${cpuinfo_file}")
14+
file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$")
15+
list(LENGTH procs PROCESSOR_COUNT)
16+
endif()
17+
18+
# Mac:
19+
if(APPLE)
20+
find_program(cmd_sys_pro "system_profiler")
21+
if(cmd_sys_pro)
22+
execute_process(COMMAND ${cmd_sys_pro} OUTPUT_VARIABLE info)
23+
string(REGEX REPLACE "^.*Total Number Of Cores: ([0-9]+).*$" "\\1"
24+
PROCESSOR_COUNT "${info}")
25+
endif()
26+
endif()
27+
28+
# Windows:
29+
if(WIN32)
30+
set(PROCESSOR_COUNT "$ENV{NUMBER_OF_PROCESSORS}")
31+
endif()
32+
endif()
33+
34+
set(CTEST_BUILD_FLAGS "-j${PROCESSOR_COUNT}")
35+
36+
######################################################
37+
########### Set these variables ##################
38+
######################################################
39+
set( CTEST_SITE "your name here")
40+
set( CTEST_BUILD_NAME "build type, os, arch")
41+
set( CTEST_COMPILER_NAME "cc version" )
42+
43+
message( FATAL_ERROR "Set the above variables and comment this line out!" )
44+
45+
######################################################
46+
47+
set( CTEST_SOURCE_DIRECTORY . )
48+
set( CTEST_BINARY_DIRECTORY build_ctest )
49+
set( CTEST_CMAKE_GENERATOR "Unix Makefiles" )
50+
set( CTEST_MEMORYCHECK_COMMAND /usr/bin/valgrind )
51+
set( CTEST_SITE "mpictor")
52+
set( CTEST_BUILD_NAME "Debug - Debian wheezy 64-bit")
53+
set( CTEST_COMPILER_NAME "gcc (Debian 4.6.1-4) 4.6.1" )
54+
set( CTEST_INITIAL_CACHE "
55+
SITE:STRING=${CTEST_SITE}
56+
BUILDNAME:STRING=${CTEST_BUILD_NAME}
57+
ENABLE_TESTING:BOOL=ON
58+
CMAKE_BUILD_TYPE:STRING=Debug
59+
")
60+
61+
62+
######################################################
63+
##### To disable a set of tests, comment out the
64+
##### ctest_submit line immediately following the set
65+
##### set you wish to disable. If other tests
66+
##### depend on those tests, they will be executed
67+
##### but not reported.
68+
######################################################
69+
70+
71+
ctest_start(Experimental)
72+
ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
73+
74+
ctest_configure( BUILD "${CTEST_BINARY_DIRECTORY}" APPEND OPTIONS -DENABLE_TESTING=ON )
75+
ctest_submit( PARTS Configure )
76+
ctest_build( BUILD "${CTEST_BINARY_DIRECTORY}" APPEND )
77+
ctest_submit( PARTS Build )
78+
# ctest_memcheck( BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL ${PROCESSOR_COUNT} )
79+
ctest_test( BUILD "${CTEST_BINARY_DIRECTORY}" APPEND PARALLEL_LEVEL ${PROCESSOR_COUNT} INCLUDE_LABEL "schema_gen" )
80+
ctest_submit( PARTS Test )
81+
ctest_test( BUILD "${CTEST_BINARY_DIRECTORY}" APPEND PARALLEL_LEVEL ${PROCESSOR_COUNT} INCLUDE_LABEL "schema_build" )
82+
ctest_submit( PARTS Test )
83+
ctest_test( BUILD "${CTEST_BINARY_DIRECTORY}" APPEND PARALLEL_LEVEL ${PROCESSOR_COUNT} INCLUDE_LABEL "schema_rw" )
84+
ctest_submit( PARTS Test )
85+
86+
# ctest_coverage( )

0 commit comments

Comments
 (0)