From b52cb92c3326241db722a728e49bd7de0f53f2ac Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 6 Mar 2014 13:20:46 -0500 Subject: [PATCH 01/43] added dashboard configuration --- src/CMakeLists.txt | 4 ++-- src/CTestConfig.cmake | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 src/CTestConfig.cmake diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 40b76a08be..c0a2563784 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -220,8 +220,8 @@ endif() # Regression tests #=============================================================================== -# This allows mpi test to work -enable_testing() +# This allows for dashboard configuration +include(CTest) # Get a list of all the tests to run file(GLOB_RECURSE TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../tests/test_*.py) diff --git a/src/CTestConfig.cmake b/src/CTestConfig.cmake new file mode 100644 index 0000000000..fa3c21d29a --- /dev/null +++ b/src/CTestConfig.cmake @@ -0,0 +1,13 @@ +## This file should be placed in the root directory of your project. +## Then modify the CMakeLists.txt file in the root directory of your +## project to incorporate the testing dashboard. +## # The following are required to uses Dart and the Cdash dashboard +## ENABLE_TESTING() +## INCLUDE(CTest) +set(CTEST_PROJECT_NAME "OpenMC") +set(CTEST_NIGHTLY_START_TIME "05:00:00 UTC") + +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "neutronbalance.mit.edu") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=OpenMC") +set(CTEST_DROP_SITE_CDASH TRUE) From 19f04b56d0fbac0fd9dbdffca6c2a8667ca3a566 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 6 Mar 2014 14:19:40 -0500 Subject: [PATCH 02/43] added nightly test script for CDash integration --- tests/run_nightly_tests.py | 133 +++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100755 tests/run_nightly_tests.py diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py new file mode 100755 index 0000000000..94f458e17c --- /dev/null +++ b/tests/run_nightly_tests.py @@ -0,0 +1,133 @@ +#!/usr/bin/env python + +from __future__ import print_function + +import os +import sys +import shutil +from subprocess import call +from collections import OrderedDict + +# Compiler paths +FC_DEFAULT='gfortran' +MPI_DIR='/opt/mpich/3.0.4-gnu' +HDF5_DIR='/opt/hdf5/1.8.12-gnu' +PHDF5_DIR='/opt/phdf5/1.8.12-gnu' +PETSC_DIR='/opt/petsc/3.4.3-gnu' + +# CTest script template +ctest_str = """set (CTEST_SOURCE_DIRECTORY "{source_dir}") +set (CTEST_BINARY_DIRECTORY "{build_dir}") + +set(CTEST_SITE "{host_name}") +set (CTEST_BUILD_NAME "{build_name}") +set (CTEST_CMAKE_GENERATOR "Unix Makefiles") +set (CTEST_BUILD_OPTIONS "{build_opts}") + +set(CTEST_CONFIGURE_COMMAND "${{CMAKE_COMMAND}} -H${{CTEST_SOURCE_DIRECTORY}} -B${{CTEST_BINARY_DIRECTORY}} ${{CTEST_BUILD_OPTIONS}}") +set(CTEST_MEMORYCHECK_COMMAND "/usr/bin/valgrind") +set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes --track-origins=yes") + +ctest_start("Nightly") +ctest_configure() +ctest_build() +ctest_test() +ctest_submit()""" + +# Define test data structure +tests = OrderedDict() + +class Test(object): + def __init__(self, name, debug=False, optimize=False, mpi=False, openmp=False, + hdf5=False, petsc=False, valgrind=False): + self.name = name + self.debug = debug + self.optimize = optimize + self.mpi = mpi + self.openmp = openmp + self.hdf5 = hdf5 + self.petsc = petsc + self.valgrind = valgrind + + def get_build_name(self): + self.build_name = self.name + return self.build_name + + def get_build_opts(self): + build_str = "" + if self.debug: + build_str += "-Ddebug=ON " + if self.optimize: + build_str += "-Doptimize=ON " + if self.openmp: + build_str += "-Dopenmp=ON " + if self.petsc: + build_str += "-Dpetsc=ON " + self.build_opts = build_str + return self.build_opts + + def run_ctest(self, ctest_vars): + with open('ctestscript.run', 'w') as fh: + fh.write(ctest_str.format(**ctest_vars)) + +def add_test(name, debug=False, optimize=False, mpi=False, openmp=False,\ + hdf5=False, petsc=False, valgrind=False): + tests.update({name:Test(name, debug, optimize, mpi, openmp, hdf5, petsc, valgrind)}) + +# List of tests +#add_test('basic-normal') +add_test('basic-debug', debug=True) +#add_test('basic-optimize', optimize=True) +#add_test('omp-normal', openmp=True) +#add_test('omp-debug', openmp=True, debug=True) +#add_test('omp-optimize', openmp=True, optimize=True) +#add_test('hdf5-normal', hdf5=True) +#add_test('hdf5-debug', hdf5=True, debug=True) +#add_test('hdf5-optimize', hdf5=True, optimize=True) +#add_test('omp-hdf5-normal', openmp=True, hdf5=True) +#add_test('omp-hdf5-debug', openmp=True, hdf5=True, debug=True) +#add_test('omp-hdf5-optimize', openmp=True, hdf5=True, optimize=True) +#add_test('mpi-normal', mpi=True) +#add_test('mpi-debug', mpi=True, debug=True) +#add_test('mpi-optimize', mpi=True, optimize=True) +#add_test('mpi-omp-normal', mpi=True, openmp=True) +#add_test('mpi-omp-debug', mpi=True, openmp=True, debug=True) +#add_test('mpi-omp-optimize', mpi=True, openmp=True, optimize=True) +#add_test('phdf5-normal', mpi=True, hdf5=True) +#add_test('phdf5-debug', mpi=True, hdf5=True, debug=True) +#add_test('phdf5-optimize', mpi=True, hdf5=True, optimize=True) +#add_test('phdf5-omp-normal', mpi=True, hdf5=True, openmp=True) +#add_test('phdf5-omp-debug', mpi=True, hdf5=True, openmp=True, debug=True) +#add_test('phdf5-omp-optimize', mpi=True, hdf5=True, openmp=True, optimize=True) +#add_test('petsc-normal', petsc=True, mpi=True) +#add_test('petsc-debug', petsc=True, mpi=True, debug=True) +#add_test('petsc-optimize', petsc=True, mpi=True, optimize=True) +#add_test('phdf5-petsc-normal', mpi=True, hdf5=True, petsc=True) +#add_test('phdf5-petsc-debug', mpi=True, hdf5=True, petsc=True, debug=True) +#add_test('phdf5-petsc-optimize', mpi=True, hdf5=True, petsc=True, optimize=True) +#add_test('omp-phdf5-petsc-normal', openmp=True, mpi=True, hdf5=True, petsc=True) +#add_test('omp-phdf5-petsc-debug', openmp=True, mpi=True, hdf5=True, petsc=True, debug=True) +#add_test('omp-phdf5-petsc-optimize', openmp=True, mpi=True, hdf5=True, petsc=True, optimize=True) + +# Setup CTest vars +pwd = os.environ['PWD'] +ctest_vars = { +'source_dir' : pwd + '/../src', +'build_dir' : pwd + '/build', +'host_name' : 'bryan laptop' +} + +# Begin testing +call(['rm', '-rf', 'build']) +for key in iter(tests): + test = tests[key] + + # Set test specific CTest vars + ctest_vars.update({'build_name' : test.get_build_name()}) + ctest_vars.update({'build_opts' : test.get_build_opts()}) + + # Run test + test.run_ctest(ctest_vars) + + # Clear build directory + call(['rm', '-rf', 'build']) From 7c34f5c109cb404706e6a709dd2e5946b336ac11 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 6 Mar 2014 14:23:19 -0500 Subject: [PATCH 03/43] only run test basic for now --- tests/run_nightly_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 94f458e17c..25725c09ad 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -31,7 +31,7 @@ set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--tool=memcheck --leak-check=yes --show-r ctest_start("Nightly") ctest_configure() ctest_build() -ctest_test() +ctest_test(INCLUDE test_basic) ctest_submit()""" # Define test data structure From 160569cced5be73befe00c3752590bde5e8c8b49 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 6 Mar 2014 14:30:51 -0500 Subject: [PATCH 04/43] ctest script executed from python script --- tests/run_nightly_tests.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 25725c09ad..44e62b14ba 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -66,10 +66,13 @@ class Test(object): self.build_opts = build_str return self.build_opts - def run_ctest(self, ctest_vars): + def create_ctest_script(self, ctest_vars): with open('ctestscript.run', 'w') as fh: fh.write(ctest_str.format(**ctest_vars)) + def run_ctest(self): + call(['ctest', '-S', 'ctestscript.run','-V']) + def add_test(name, debug=False, optimize=False, mpi=False, openmp=False,\ hdf5=False, petsc=False, valgrind=False): tests.update({name:Test(name, debug, optimize, mpi, openmp, hdf5, petsc, valgrind)}) @@ -126,8 +129,11 @@ for key in iter(tests): ctest_vars.update({'build_name' : test.get_build_name()}) ctest_vars.update({'build_opts' : test.get_build_opts()}) + # Create ctest script + test.create_ctest_script(ctest_vars) + # Run test - test.run_ctest(ctest_vars) + test.run_ctest() # Clear build directory call(['rm', '-rf', 'build']) From c074268ba1aaf551addbfb9c8b743c70d39fa014 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 6 Mar 2014 15:23:18 -0500 Subject: [PATCH 05/43] implemented valgrind test option --- src/CMakeLists.txt | 35 +++++++++++++++++++++++------------ tests/run_nightly_tests.py | 12 ++++++++++-- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c0a2563784..21609a4d9a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -241,22 +241,33 @@ foreach(test ${TESTS}) get_filename_component(TEST_NAME ${test} NAME) get_filename_component(TEST_PATH ${test} PATH) - # Check serial/parallel - if (${MPI_ENABLED}) + if(NOT $ENV{MEM_CHECK}) - # Preform a parallel test - add_test(NAME ${TEST_NAME} - WORKING_DIRECTORY ${TEST_PATH} - COMMAND ${PYTHON_EXECUTABLE} ${TEST_NAME} --exe $ - --mpi_exec $ENV{MPI_DIR}/bin/mpiexec) + # Check serial/parallel + if (${MPI_ENABLED}) - else(${MPI_ENABLED}) + # Preform a parallel test + add_test(NAME ${TEST_NAME} + WORKING_DIRECTORY ${TEST_PATH} + COMMAND ${PYTHON_EXECUTABLE} ${TEST_NAME} --exe $ + --mpi_exec $ENV{MPI_DIR}/bin/mpiexec) - # Perform a serial test - add_test(NAME ${TEST_NAME} + else(${MPI_ENABLED}) + + # Perform a serial test + add_test(NAME ${TEST_NAME} + WORKING_DIRECTORY ${TEST_PATH} + COMMAND ${PYTHON_EXECUTABLE} ${TEST_NAME} --exe $) + + endif(${MPI_ENABLED}) + + else(NOT $ENV{MEM_CHECK}) + + # Perform serial valgrind test + add_test(NAME ${TEST_NAME} WORKING_DIRECTORY ${TEST_PATH} - COMMAND ${PYTHON_EXECUTABLE} ${TEST_NAME} --exe $) + COMMAND $ ${TEST_PATH}) - endif(${MPI_ENABLED}) + endif(NOT $ENV{MEM_CHECK}) endforeach(test) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 44e62b14ba..51d3ce8562 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -28,10 +28,16 @@ set(CTEST_CONFIGURE_COMMAND "${{CMAKE_COMMAND}} -H${{CTEST_SOURCE_DIRECTORY}} -B set(CTEST_MEMORYCHECK_COMMAND "/usr/bin/valgrind") set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes --track-origins=yes") +set(MEM_CHECK {mem_check}) +set(ENV{{MEM_CHECK}} ${{MEM_CHECK}}) + ctest_start("Nightly") ctest_configure() ctest_build() ctest_test(INCLUDE test_basic) +if(MEM_CHECK) +ctest_memcheck(INCLUDE test_basic) +endif(MEM_CHECK) ctest_submit()""" # Define test data structure @@ -78,8 +84,8 @@ def add_test(name, debug=False, optimize=False, mpi=False, openmp=False,\ tests.update({name:Test(name, debug, optimize, mpi, openmp, hdf5, petsc, valgrind)}) # List of tests -#add_test('basic-normal') -add_test('basic-debug', debug=True) +add_test('basic-normal') +#add_test('basic-debug', debug=True) #add_test('basic-optimize', optimize=True) #add_test('omp-normal', openmp=True) #add_test('omp-debug', openmp=True, debug=True) @@ -111,6 +117,7 @@ add_test('basic-debug', debug=True) #add_test('omp-phdf5-petsc-normal', openmp=True, mpi=True, hdf5=True, petsc=True) #add_test('omp-phdf5-petsc-debug', openmp=True, mpi=True, hdf5=True, petsc=True, debug=True) #add_test('omp-phdf5-petsc-optimize', openmp=True, mpi=True, hdf5=True, petsc=True, optimize=True) +add_test('basic-debug_valgrind', debug=True, valgrind=True) # Setup CTest vars pwd = os.environ['PWD'] @@ -128,6 +135,7 @@ for key in iter(tests): # Set test specific CTest vars ctest_vars.update({'build_name' : test.get_build_name()}) ctest_vars.update({'build_opts' : test.get_build_opts()}) + ctest_vars.update({'mem_check' : test.valgrind}) # Create ctest script test.create_ctest_script(ctest_vars) From c5dfca63eed9520ab5ec57d45b42d21d6c1aa210 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 6 Mar 2014 16:46:19 -0500 Subject: [PATCH 06/43] added coverage options with gcov --- src/CMakeLists.txt | 11 ++++++++--- tests/run_nightly_tests.py | 27 +++++++++++++++++++-------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 21609a4d9a..11f48f1f38 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,6 +17,7 @@ option(petsc "Enable PETSC for use in CMFD acceleration" OFF) option(debug "Compile with debug flags" OFF) option(optimize "Turn on all compiler optimization flags" OFF) option(verbose "Create verbose Makefiles" OFF) +option(coverage "Compile with flags" OFF) if (verbose) set(CMAKE_VERBOSE_MAKEFILE on) @@ -62,6 +63,10 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") set(f90flags "-fopenmp ${f90flags}") set(ldflags "-fopenmp ${ldflags}") endif() + if(coverage) + set(f90flags "-coverage ${f90flags}") + set(ldflags "-coverage ${ldflags}") + endif() elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") # Intel Fortran compiler options @@ -241,7 +246,7 @@ foreach(test ${TESTS}) get_filename_component(TEST_NAME ${test} NAME) get_filename_component(TEST_PATH ${test} PATH) - if(NOT $ENV{MEM_CHECK}) + if(NOT $ENV{MEM_CHECK} AND NOT $ENV{COVERAGE}) # Check serial/parallel if (${MPI_ENABLED}) @@ -261,13 +266,13 @@ foreach(test ${TESTS}) endif(${MPI_ENABLED}) - else(NOT $ENV{MEM_CHECK}) + else(NOT $ENV{MEM_CHECK} AND NOT $ENV{COVERAGE}) # Perform serial valgrind test add_test(NAME ${TEST_NAME} WORKING_DIRECTORY ${TEST_PATH} COMMAND $ ${TEST_PATH}) - endif(NOT $ENV{MEM_CHECK}) + endif(NOT $ENV{MEM_CHECK} AND NOT $ENV{COVERAGE}) endforeach(test) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 51d3ce8562..8a1bc4e1d8 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -27,17 +27,23 @@ set (CTEST_BUILD_OPTIONS "{build_opts}") set(CTEST_CONFIGURE_COMMAND "${{CMAKE_COMMAND}} -H${{CTEST_SOURCE_DIRECTORY}} -B${{CTEST_BINARY_DIRECTORY}} ${{CTEST_BUILD_OPTIONS}}") set(CTEST_MEMORYCHECK_COMMAND "/usr/bin/valgrind") set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes --track-origins=yes") - set(MEM_CHECK {mem_check}) set(ENV{{MEM_CHECK}} ${{MEM_CHECK}}) +set(CTEST_COVERAGE_COMMAND "/usr/bin/gcov") +set(COVERAGE {coverage}) +set(ENV{{COVERAGE}} ${{COVERAGE}}) + ctest_start("Nightly") ctest_configure() ctest_build() -ctest_test(INCLUDE test_basic) +ctest_test() if(MEM_CHECK) ctest_memcheck(INCLUDE test_basic) endif(MEM_CHECK) +if(COVERAGE) +ctest_coverage() +endif(COVERAGE) ctest_submit()""" # Define test data structure @@ -45,7 +51,7 @@ tests = OrderedDict() class Test(object): def __init__(self, name, debug=False, optimize=False, mpi=False, openmp=False, - hdf5=False, petsc=False, valgrind=False): + hdf5=False, petsc=False, valgrind=False, coverage=False): self.name = name self.debug = debug self.optimize = optimize @@ -54,6 +60,7 @@ class Test(object): self.hdf5 = hdf5 self.petsc = petsc self.valgrind = valgrind + self.coverage = coverage def get_build_name(self): self.build_name = self.name @@ -69,6 +76,8 @@ class Test(object): build_str += "-Dopenmp=ON " if self.petsc: build_str += "-Dpetsc=ON " + if self.coverage: + build_str += "-Dcoverage=ON " self.build_opts = build_str return self.build_opts @@ -80,11 +89,11 @@ class Test(object): call(['ctest', '-S', 'ctestscript.run','-V']) def add_test(name, debug=False, optimize=False, mpi=False, openmp=False,\ - hdf5=False, petsc=False, valgrind=False): - tests.update({name:Test(name, debug, optimize, mpi, openmp, hdf5, petsc, valgrind)}) + hdf5=False, petsc=False, valgrind=False, coverage=False): + tests.update({name:Test(name, debug, optimize, mpi, openmp, hdf5, petsc, valgrind, coverage)}) # List of tests -add_test('basic-normal') +#add_test('basic-normal') #add_test('basic-debug', debug=True) #add_test('basic-optimize', optimize=True) #add_test('omp-normal', openmp=True) @@ -117,7 +126,8 @@ add_test('basic-normal') #add_test('omp-phdf5-petsc-normal', openmp=True, mpi=True, hdf5=True, petsc=True) #add_test('omp-phdf5-petsc-debug', openmp=True, mpi=True, hdf5=True, petsc=True, debug=True) #add_test('omp-phdf5-petsc-optimize', openmp=True, mpi=True, hdf5=True, petsc=True, optimize=True) -add_test('basic-debug_valgrind', debug=True, valgrind=True) +#add_test('basic-debug_valgrind', debug=True, valgrind=True) +add_test('basic-normal_coverage', coverage=True) # Setup CTest vars pwd = os.environ['PWD'] @@ -136,6 +146,7 @@ for key in iter(tests): ctest_vars.update({'build_name' : test.get_build_name()}) ctest_vars.update({'build_opts' : test.get_build_opts()}) ctest_vars.update({'mem_check' : test.valgrind}) + ctest_vars.update({'coverage' : test.coverage}) # Create ctest script test.create_ctest_script(ctest_vars) @@ -144,4 +155,4 @@ for key in iter(tests): test.run_ctest() # Clear build directory - call(['rm', '-rf', 'build']) +# call(['rm', '-rf', 'build']) From 5391e922a51d6e4e82000b46ff5fd67146042206 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 6 Mar 2014 17:02:31 -0500 Subject: [PATCH 07/43] added compiler options --- tests/run_nightly_tests.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 8a1bc4e1d8..318f07233b 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -62,6 +62,17 @@ class Test(object): self.valgrind = valgrind self.coverage = coverage + # Check for MPI/HDF5 + if self.mpi and not self.hdf5: + self.fc = MPI_DIR+'/bin/mpif90' + elif not self.mpi and self.hdf5: + self.fc = HDF5_DIR+'/bin/h5fc' + elif self.mpi and self.hdf5: + self.fc = PHDF5_DIR+'/bin/h5pfc' + else: + self.fc = FC_DEFAULT + os.environ['FC'] = self.fc + def get_build_name(self): self.build_name = self.name return self.build_name From 529d89b1291aa47e83f81f22e12d9279f51b0c44 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Tue, 11 Mar 2014 19:01:04 -0400 Subject: [PATCH 08/43] cdash nightly run script active --- tests/run_nightly_tests.py | 105 ++++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 42 deletions(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 318f07233b..ab5d4d586c 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -7,6 +7,7 @@ import sys import shutil from subprocess import call from collections import OrderedDict +from optparse import OptionParser # Compiler paths FC_DEFAULT='gfortran' @@ -15,6 +16,14 @@ HDF5_DIR='/opt/hdf5/1.8.12-gnu' PHDF5_DIR='/opt/phdf5/1.8.12-gnu' PETSC_DIR='/opt/petsc/3.4.3-gnu' +# Command line parsing +parser = OptionParser() +parser.add_option("-b", "--branch", dest="branch", default="", + help="branch name for build") +parser.add_option("-D", "--dashboard", dest="dash", default="Experimental", + help="Dash name -- Experimental, Nightly, Continuous") +(options, args) = parser.parse_args() + # CTest script template ctest_str = """set (CTEST_SOURCE_DIRECTORY "{source_dir}") set (CTEST_BINARY_DIRECTORY "{build_dir}") @@ -26,7 +35,7 @@ set (CTEST_BUILD_OPTIONS "{build_opts}") set(CTEST_CONFIGURE_COMMAND "${{CMAKE_COMMAND}} -H${{CTEST_SOURCE_DIRECTORY}} -B${{CTEST_BINARY_DIRECTORY}} ${{CTEST_BUILD_OPTIONS}}") set(CTEST_MEMORYCHECK_COMMAND "/usr/bin/valgrind") -set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes --track-origins=yes") +set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes") set(MEM_CHECK {mem_check}) set(ENV{{MEM_CHECK}} ${{MEM_CHECK}}) @@ -34,12 +43,14 @@ set(CTEST_COVERAGE_COMMAND "/usr/bin/gcov") set(COVERAGE {coverage}) set(ENV{{COVERAGE}} ${{COVERAGE}}) -ctest_start("Nightly") +ctest_start("{dashboard}") ctest_configure() ctest_build() -ctest_test() if(MEM_CHECK) -ctest_memcheck(INCLUDE test_basic) +ctest_test(START 1 END 67 STRIDE 5 PARALLEL_LEVEL 4) +ctest_memcheck(START 1 END 67 STRIDE 5) +else(MEM_CHECK) +ctest_test(PARALLEL_LEVEL 4) endif(MEM_CHECK) if(COVERAGE) ctest_coverage() @@ -71,10 +82,9 @@ class Test(object): self.fc = PHDF5_DIR+'/bin/h5pfc' else: self.fc = FC_DEFAULT - os.environ['FC'] = self.fc def get_build_name(self): - self.build_name = self.name + self.build_name = options.branch + '_' + self.name return self.build_name def get_build_opts(self): @@ -97,6 +107,11 @@ class Test(object): fh.write(ctest_str.format(**ctest_vars)) def run_ctest(self): + os.environ['FC'] = self.fc + if self.petsc: + os.environ['PETSC_DIR'] = PETSC_DIR + if self.mpi: + os.environ['MPI_DIR'] = MPI_DIR call(['ctest', '-S', 'ctestscript.run','-V']) def add_test(name, debug=False, optimize=False, mpi=False, openmp=False,\ @@ -104,48 +119,54 @@ def add_test(name, debug=False, optimize=False, mpi=False, openmp=False,\ tests.update({name:Test(name, debug, optimize, mpi, openmp, hdf5, petsc, valgrind, coverage)}) # List of tests -#add_test('basic-normal') -#add_test('basic-debug', debug=True) -#add_test('basic-optimize', optimize=True) -#add_test('omp-normal', openmp=True) -#add_test('omp-debug', openmp=True, debug=True) -#add_test('omp-optimize', openmp=True, optimize=True) -#add_test('hdf5-normal', hdf5=True) -#add_test('hdf5-debug', hdf5=True, debug=True) -#add_test('hdf5-optimize', hdf5=True, optimize=True) -#add_test('omp-hdf5-normal', openmp=True, hdf5=True) -#add_test('omp-hdf5-debug', openmp=True, hdf5=True, debug=True) -#add_test('omp-hdf5-optimize', openmp=True, hdf5=True, optimize=True) -#add_test('mpi-normal', mpi=True) -#add_test('mpi-debug', mpi=True, debug=True) -#add_test('mpi-optimize', mpi=True, optimize=True) -#add_test('mpi-omp-normal', mpi=True, openmp=True) -#add_test('mpi-omp-debug', mpi=True, openmp=True, debug=True) -#add_test('mpi-omp-optimize', mpi=True, openmp=True, optimize=True) -#add_test('phdf5-normal', mpi=True, hdf5=True) -#add_test('phdf5-debug', mpi=True, hdf5=True, debug=True) -#add_test('phdf5-optimize', mpi=True, hdf5=True, optimize=True) -#add_test('phdf5-omp-normal', mpi=True, hdf5=True, openmp=True) -#add_test('phdf5-omp-debug', mpi=True, hdf5=True, openmp=True, debug=True) -#add_test('phdf5-omp-optimize', mpi=True, hdf5=True, openmp=True, optimize=True) -#add_test('petsc-normal', petsc=True, mpi=True) -#add_test('petsc-debug', petsc=True, mpi=True, debug=True) -#add_test('petsc-optimize', petsc=True, mpi=True, optimize=True) -#add_test('phdf5-petsc-normal', mpi=True, hdf5=True, petsc=True) -#add_test('phdf5-petsc-debug', mpi=True, hdf5=True, petsc=True, debug=True) -#add_test('phdf5-petsc-optimize', mpi=True, hdf5=True, petsc=True, optimize=True) -#add_test('omp-phdf5-petsc-normal', openmp=True, mpi=True, hdf5=True, petsc=True) -#add_test('omp-phdf5-petsc-debug', openmp=True, mpi=True, hdf5=True, petsc=True, debug=True) -#add_test('omp-phdf5-petsc-optimize', openmp=True, mpi=True, hdf5=True, petsc=True, optimize=True) -#add_test('basic-debug_valgrind', debug=True, valgrind=True) +add_test('basic-normal') +add_test('basic-debug', debug=True) +add_test('basic-optimize', optimize=True) +add_test('omp-normal', openmp=True) +add_test('omp-debug', openmp=True, debug=True) +add_test('omp-optimize', openmp=True, optimize=True) +add_test('hdf5-normal', hdf5=True) +add_test('hdf5-debug', hdf5=True, debug=True) +add_test('hdf5-optimize', hdf5=True, optimize=True) +add_test('omp-hdf5-normal', openmp=True, hdf5=True) +add_test('omp-hdf5-debug', openmp=True, hdf5=True, debug=True) +add_test('omp-hdf5-optimize', openmp=True, hdf5=True, optimize=True) +add_test('mpi-normal', mpi=True) +add_test('mpi-debug', mpi=True, debug=True) +add_test('mpi-optimize', mpi=True, optimize=True) +add_test('mpi-omp-normal', mpi=True, openmp=True) +add_test('mpi-omp-debug', mpi=True, openmp=True, debug=True) +add_test('mpi-omp-optimize', mpi=True, openmp=True, optimize=True) +add_test('phdf5-normal', mpi=True, hdf5=True) +add_test('phdf5-debug', mpi=True, hdf5=True, debug=True) +add_test('phdf5-optimize', mpi=True, hdf5=True, optimize=True) +add_test('phdf5-omp-normal', mpi=True, hdf5=True, openmp=True) +add_test('phdf5-omp-debug', mpi=True, hdf5=True, openmp=True, debug=True) +add_test('phdf5-omp-optimize', mpi=True, hdf5=True, openmp=True, optimize=True) +add_test('petsc-normal', petsc=True, mpi=True) +add_test('petsc-debug', petsc=True, mpi=True, debug=True) +add_test('petsc-optimize', petsc=True, mpi=True, optimize=True) +add_test('phdf5-petsc-normal', mpi=True, hdf5=True, petsc=True) +add_test('phdf5-petsc-debug', mpi=True, hdf5=True, petsc=True, debug=True) +add_test('phdf5-petsc-optimize', mpi=True, hdf5=True, petsc=True, optimize=True) +add_test('omp-phdf5-petsc-normal', openmp=True, mpi=True, hdf5=True, petsc=True) +add_test('omp-phdf5-petsc-debug', openmp=True, mpi=True, hdf5=True, petsc=True, debug=True) +add_test('omp-phdf5-petsc-optimize', openmp=True, mpi=True, hdf5=True, petsc=True, optimize=True) +add_test('basic-debug_valgrind', debug=True, valgrind=True) +add_test('hdf5-debug_valgrind', hdf5=True, debug=True, valgrind=True) +add_test('petsc-debug_valgrind', petsc=True, debug=True, valgrind=True) add_test('basic-normal_coverage', coverage=True) +add_test('hdf5-normal_coverage', hdf5=True, coverage=True) +add_test('mpi-normal_coverage', mpi=True, coverage=True) +add_test('petsc-normal_coverage', petsc=True, mpi=True, coverage=True) # Setup CTest vars pwd = os.environ['PWD'] ctest_vars = { 'source_dir' : pwd + '/../src', 'build_dir' : pwd + '/build', -'host_name' : 'bryan laptop' +'host_name' : 'neutronbalance', +'dashboard' : options.dash } # Begin testing @@ -166,4 +187,4 @@ for key in iter(tests): test.run_ctest() # Clear build directory -# call(['rm', '-rf', 'build']) + call(['rm', '-rf', 'build']) From 7de662d92096e9852de1af389a3e23c2fa0b088c Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Tue, 11 Mar 2014 19:09:11 -0400 Subject: [PATCH 09/43] Updated run nightly tests with cleanup script --- src/CTestConfig.cmake | 2 +- tests/run_nightly_tests.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/CTestConfig.cmake b/src/CTestConfig.cmake index fa3c21d29a..f8aa74b7d4 100644 --- a/src/CTestConfig.cmake +++ b/src/CTestConfig.cmake @@ -5,7 +5,7 @@ ## ENABLE_TESTING() ## INCLUDE(CTest) set(CTEST_PROJECT_NAME "OpenMC") -set(CTEST_NIGHTLY_START_TIME "05:00:00 UTC") +set(CTEST_NIGHTLY_START_TIME "03:00:00 UTC") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "neutronbalance.mit.edu") diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index ab5d4d586c..8682209924 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -171,6 +171,8 @@ ctest_vars = { # Begin testing call(['rm', '-rf', 'build']) +call(['rm', '-rf', 'ctestscript.run']) +call(['./cleanup']) for key in iter(tests): test = tests[key] @@ -188,3 +190,5 @@ for key in iter(tests): # Clear build directory call(['rm', '-rf', 'build']) + call(['rm', '-rf', 'ctestscript.run']) + call(['./cleanup']) From f31051c63e2b837b85a82e9d12956bbb71d664f3 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Wed, 12 Mar 2014 09:59:41 -0400 Subject: [PATCH 10/43] CTest now updates from github repo --- tests/run_nightly_tests.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 8682209924..4162545b12 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -33,6 +33,8 @@ set (CTEST_BUILD_NAME "{build_name}") set (CTEST_CMAKE_GENERATOR "Unix Makefiles") set (CTEST_BUILD_OPTIONS "{build_opts}") +set(CTEST_UPDATE_COMMAND "git") + set(CTEST_CONFIGURE_COMMAND "${{CMAKE_COMMAND}} -H${{CTEST_SOURCE_DIRECTORY}} -B${{CTEST_BINARY_DIRECTORY}} ${{CTEST_BUILD_OPTIONS}}") set(CTEST_MEMORYCHECK_COMMAND "/usr/bin/valgrind") set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes") @@ -45,6 +47,7 @@ set(ENV{{COVERAGE}} ${{COVERAGE}}) ctest_start("{dashboard}") ctest_configure() +ctest_update() ctest_build() if(MEM_CHECK) ctest_test(START 1 END 67 STRIDE 5 PARALLEL_LEVEL 4) From b9f96e6fa2533a3b2b5483a234c983e73763c0e9 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Wed, 12 Mar 2014 14:50:50 -0400 Subject: [PATCH 11/43] MEM_CHECK and COVERAGE env vars are now checked before using --- src/CMakeLists.txt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a57fdaa4d3..8da7f0a2dc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -236,6 +236,18 @@ if (NOT ${PETSC_ENABLED}) endforeach(cmfd_test) endif(NOT ${PETSC_ENABLED}) +# Check for MEM_CHECK and COVERAGE variables +if (DEFINED $ENV{MEM_CHECK}) + set(MEM_CHECK $ENV{MEM_CHECK}) +else(DEFINED $ENV{MEM_CHECK}) + set(MEM_CHECK FALSE) +endif(DEFINED $ENV{MEM_CHECK}) +if (DEFINED $ENV{COVERAGE}) + set(COVERAGE $ENV{COVERAGE}) +else(DEFINED $ENV{COVERAGE}) + set(COVERAGE FALSE) +endif(DEFINED $ENV{COVERAGE}) + # Loop through all the tests foreach(test ${TESTS}) @@ -243,7 +255,7 @@ foreach(test ${TESTS}) get_filename_component(TEST_NAME ${test} NAME) get_filename_component(TEST_PATH ${test} PATH) - if(NOT $ENV{MEM_CHECK} AND NOT $ENV{COVERAGE}) + if(NOT ${MEM_CHECK} AND NOT ${COVERAGE}) # Check serial/parallel if (${MPI_ENABLED}) @@ -263,13 +275,13 @@ foreach(test ${TESTS}) endif(${MPI_ENABLED}) - else(NOT $ENV{MEM_CHECK} AND NOT $ENV{COVERAGE}) + else(NOT ${MEM_CHECK} AND NOT ${COVERAGE}) # Perform serial valgrind test add_test(NAME ${TEST_NAME} WORKING_DIRECTORY ${TEST_PATH} COMMAND $ ${TEST_PATH}) - endif(NOT $ENV{MEM_CHECK} AND NOT $ENV{COVERAGE}) + endif(NOT ${MEM_CHECK} AND NOT ${COVERAGE}) endforeach(test) From b9063468636841838ef51a9cbe7e5ea81aeeeb83 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Wed, 12 Mar 2014 16:43:59 -0400 Subject: [PATCH 12/43] fixed checking environmental vars for valgrind or coverage runs --- src/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8da7f0a2dc..0b33a9ce0f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -237,16 +237,16 @@ if (NOT ${PETSC_ENABLED}) endif(NOT ${PETSC_ENABLED}) # Check for MEM_CHECK and COVERAGE variables -if (DEFINED $ENV{MEM_CHECK}) +if (DEFINED ENV{MEM_CHECK}) set(MEM_CHECK $ENV{MEM_CHECK}) -else(DEFINED $ENV{MEM_CHECK}) +else(DEFINED ENV{MEM_CHECK}) set(MEM_CHECK FALSE) -endif(DEFINED $ENV{MEM_CHECK}) -if (DEFINED $ENV{COVERAGE}) +endif(DEFINED ENV{MEM_CHECK}) +if (DEFINED ENV{COVERAGE}) set(COVERAGE $ENV{COVERAGE}) -else(DEFINED $ENV{COVERAGE}) +else(DEFINED ENV{COVERAGE}) set(COVERAGE FALSE) -endif(DEFINED $ENV{COVERAGE}) +endif(DEFINED ENV{COVERAGE}) # Loop through all the tests foreach(test ${TESTS}) From 3a91c11c6b6009167b3f2a46a41db37ba7e767ef Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Wed, 12 Mar 2014 16:44:56 -0400 Subject: [PATCH 13/43] specified tests to be executed for memcheck --- tests/run_nightly_tests.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 4162545b12..59dfa321cc 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -45,13 +45,15 @@ set(CTEST_COVERAGE_COMMAND "/usr/bin/gcov") set(COVERAGE {coverage}) set(ENV{{COVERAGE}} ${{COVERAGE}}) +set(INCLUDED_TESTS "basic|cmfd_feed|confidence_intervals|density_atombcm|eigenvalue_genperbatch|energy_grid|entropy|filter_cell|lattice_multiple|output|reflective_plane|rotation|salphabeta_multiple|score_absorption|seed|source_energy_mono|sourcepoint_batch|statepoint_interval|survival_biasing|tally_assumesep|translation|uniform_fs|universe|void") + ctest_start("{dashboard}") ctest_configure() ctest_update() ctest_build() if(MEM_CHECK) -ctest_test(START 1 END 67 STRIDE 5 PARALLEL_LEVEL 4) -ctest_memcheck(START 1 END 67 STRIDE 5) +ctest_test(INCLUDE ${{INCLUDED_TESTS}} PARALLEL_LEVEL 4) +ctest_memcheck(INCLUDE ${{INCLUDED_TESTS}}) else(MEM_CHECK) ctest_test(PARALLEL_LEVEL 4) endif(MEM_CHECK) From e09530a8778f7fadf3c6288ced8ba096e41d1899 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 13 Mar 2014 09:52:35 -0400 Subject: [PATCH 14/43] petsc valgrind test needs mpi true --- tests/run_nightly_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 59dfa321cc..f5ca64adc9 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -159,7 +159,7 @@ add_test('omp-phdf5-petsc-debug', openmp=True, mpi=True, hdf5=True, petsc=True, add_test('omp-phdf5-petsc-optimize', openmp=True, mpi=True, hdf5=True, petsc=True, optimize=True) add_test('basic-debug_valgrind', debug=True, valgrind=True) add_test('hdf5-debug_valgrind', hdf5=True, debug=True, valgrind=True) -add_test('petsc-debug_valgrind', petsc=True, debug=True, valgrind=True) +add_test('petsc-debug_valgrind', petsc=True, mpi=True, debug=True, valgrind=True) add_test('basic-normal_coverage', coverage=True) add_test('hdf5-normal_coverage', hdf5=True, coverage=True) add_test('mpi-normal_coverage', mpi=True, coverage=True) From 85804eca295172f9002e9f725fa81fccc447347d Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Tue, 1 Apr 2014 17:38:20 -0400 Subject: [PATCH 15/43] coverage tests are performed in debug mode --- tests/run_nightly_tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index f5ca64adc9..fdeeb26972 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -160,10 +160,10 @@ add_test('omp-phdf5-petsc-optimize', openmp=True, mpi=True, hdf5=True, petsc=Tru add_test('basic-debug_valgrind', debug=True, valgrind=True) add_test('hdf5-debug_valgrind', hdf5=True, debug=True, valgrind=True) add_test('petsc-debug_valgrind', petsc=True, mpi=True, debug=True, valgrind=True) -add_test('basic-normal_coverage', coverage=True) -add_test('hdf5-normal_coverage', hdf5=True, coverage=True) -add_test('mpi-normal_coverage', mpi=True, coverage=True) -add_test('petsc-normal_coverage', petsc=True, mpi=True, coverage=True) +add_test('basic-debug_coverage', debug=True, coverage=True) +add_test('hdf5-debug_coverage', debug=True, hdf5=True, coverage=True) +add_test('mpi-debug_coverage', debug=True, mpi=True, coverage=True) +add_test('petsc-debug_coverage', debug=True, petsc=True, mpi=True, coverage=True) # Setup CTest vars pwd = os.environ['PWD'] From 5c284be28bdda20dd1bf28feb47221435697d8b6 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Wed, 2 Apr 2014 08:31:16 -0400 Subject: [PATCH 16/43] raised limit of output data to show on CDash --- src/CTestConfig.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CTestConfig.cmake b/src/CTestConfig.cmake index f8aa74b7d4..6ae35bae56 100644 --- a/src/CTestConfig.cmake +++ b/src/CTestConfig.cmake @@ -11,3 +11,5 @@ set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "neutronbalance.mit.edu") set(CTEST_DROP_LOCATION "/CDash/submit.php?project=OpenMC") set(CTEST_DROP_SITE_CDASH TRUE) +SET(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE "20000") +SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE "20000") From e215dc2107fac4d344257e585c5f8c1861026ec2 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Wed, 2 Apr 2014 16:01:56 -0400 Subject: [PATCH 17/43] added special case for plot tests and restart tests --- src/CMakeLists.txt | 72 +++++++++++++++++++++++++++++++++++--- tests/run_nightly_tests.py | 2 +- 2 files changed, 69 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0b33a9ce0f..45e98f7beb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,6 +28,7 @@ endif() #=============================================================================== set(MPI_ENABLED FALSE) +set(HDF5_ENABLED FALSE) if($ENV{FC} MATCHES "mpi.*") message("-- Detected MPI wrapper: $ENV{FC}") add_definitions(-DMPI) @@ -35,10 +36,12 @@ if($ENV{FC} MATCHES "mpi.*") elseif($ENV{FC} MATCHES "h5fc$") message("-- Detected HDF5 wrapper: $ENV{FC}") add_definitions(-DHDF5) + set(HDF5_ENABLED TRUE) elseif($ENV{FC} MATCHES "h5pfc$") message("-- Detected parallel HDF5 wrapper: $ENV{FC}") add_definitions(-DMPI -DHDF5) set(MPI_ENABLED TRUE) + set(HDF5_ENABLED TRUE) endif() #=============================================================================== @@ -255,6 +258,7 @@ foreach(test ${TESTS}) get_filename_component(TEST_NAME ${test} NAME) get_filename_component(TEST_PATH ${test} PATH) + # Check for running standard tests (no valgrind, no gcov) if(NOT ${MEM_CHECK} AND NOT ${COVERAGE}) # Check serial/parallel @@ -275,12 +279,72 @@ foreach(test ${TESTS}) endif(${MPI_ENABLED}) + # Handle special case for valgrind and gcov (run openmc directly, no python) else(NOT ${MEM_CHECK} AND NOT ${COVERAGE}) - # Perform serial valgrind test - add_test(NAME ${TEST_NAME} - WORKING_DIRECTORY ${TEST_PATH} - COMMAND $ ${TEST_PATH}) + # If a plot test is encountered, run with "-p" + if (${test} MATCHES "test_plot") + + # Perform serial valgrind and coverage test with plot flag + add_test(NAME ${TEST_NAME} + WORKING_DIRECTORY ${TEST_PATH} + COMMAND $ -p ${TEST_PATH}) + + # If a restart test is encounted, need to run with -r and restart file(s) + elseif(${test} MATCHES "restart") + + # Set restart file names + if (${HDF5_ENABLED}) + + # Handle restart tests separately + if(${test} MATCHES "test_statepoint_restart") + set(RESTART_FILE statepoint.7.h5) + elseif(${test} MATCHES "test_sourcepoint_restart") + set(RESTART_FILE statepoint.7.h5 sourcepoint.7.h5) + elseif(${test} MATCHES "test_particle_restart") + set(RESTART_FILE particle_10_394.h5) + else(${test} MATCHES "test_statepoint_restart") + message(FATAL_ERROR "Restart test ${test} not recognized") + endif(${test} MATCHES "test_statepoint_restart") + + else(${HDF5_ENABLED}) + + # Handle restart tests separately + if(${test} MATCHES "test_statepoint_restart") + set(RESTART_FILE statepoint.7.binary) + elseif(${test} MATCHES "test_sourcepoint_restart") + set(RESTART_FILE statepoint.7.binary source.7.binary) + elseif(${test} MATCHES "test_particle_restart") + set(RESTART_FILE particle_10_394.binary) + else(${test} MATCHES "test_statepoint_restart") + message(FATAL_ERROR "Restart test ${test} not recognized") + endif(${test} MATCHES "test_statepoint_restart") + + endif(${HDF5_ENABLED}) + + # Perform serial valgrind and coverage test + add_test(NAME ${TEST_NAME} + WORKING_DIRECTORY ${TEST_PATH} + COMMAND $ ${TEST_PATH}) + + # Perform serial valgrind and coverage restart test + add_test(NAME ${TEST_NAME}_restart + WORKING_DIRECTORY ${TEST_PATH} + COMMAND $ -r ${RESTART_FILE} ${TEST_PATH}) + + # Set test dependency + set_tests_properties(${TEST_NAME}_restart PROPERTIES DEPENDS ${TEST_NAME}) + + + # Handle standard tests for valgrind and gcov + else(${test} MATCHES "test_plot") + + # Perform serial valgrind and coverage test + add_test(NAME ${TEST_NAME} + WORKING_DIRECTORY ${TEST_PATH} + COMMAND $ ${TEST_PATH}) + + endif(${test} MATCHES "test_plot") endif(NOT ${MEM_CHECK} AND NOT ${COVERAGE}) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index fdeeb26972..bd6f5a779c 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -45,7 +45,7 @@ set(CTEST_COVERAGE_COMMAND "/usr/bin/gcov") set(COVERAGE {coverage}) set(ENV{{COVERAGE}} ${{COVERAGE}}) -set(INCLUDED_TESTS "basic|cmfd_feed|confidence_intervals|density_atombcm|eigenvalue_genperbatch|energy_grid|entropy|filter_cell|lattice_multiple|output|reflective_plane|rotation|salphabeta_multiple|score_absorption|seed|source_energy_mono|sourcepoint_batch|statepoint_interval|survival_biasing|tally_assumesep|translation|uniform_fs|universe|void") +set(INCLUDED_TESTS "basic|cmfd_feed|confidence_intervals|density_atombcm|eigenvalue_genperbatch|energy_grid|entropy|filter_cell|lattice_multiple|output|plot_background|reflective_plane|rotation|salphabeta_multiple|score_absorption|seed|source_energy_mono|sourcepoint_batch|statepoint_interval|survival_biasing|tally_assumesep|translation|uniform_fs|universe|void") ctest_start("{dashboard}") ctest_configure() From 284ff606c9096856ce8236689d0d4ef1a5fbfd80 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 3 Apr 2014 08:20:31 -0400 Subject: [PATCH 18/43] added ppm files for cleanup --- tests/cleanup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cleanup b/tests/cleanup index 288c81025b..7b81d2d9dd 100755 --- a/tests/cleanup +++ b/tests/cleanup @@ -7,4 +7,4 @@ # deleting left over binary files. This will # cause an assertion error in some of the # tests. -find . \( -name "*.binary" -o -name "*.h5" \) -exec rm -f {} \; +find . \( -name "*.binary" -o -name "*.h5" -o -name "*.ppm" \) -exec rm -f {} \; From bfd13779939a6ae7444382c204c0604eb80606c1 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 3 Apr 2014 08:21:20 -0400 Subject: [PATCH 19/43] changed sourcepoint to source --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 45e98f7beb..93832e8c69 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -300,7 +300,7 @@ foreach(test ${TESTS}) if(${test} MATCHES "test_statepoint_restart") set(RESTART_FILE statepoint.7.h5) elseif(${test} MATCHES "test_sourcepoint_restart") - set(RESTART_FILE statepoint.7.h5 sourcepoint.7.h5) + set(RESTART_FILE statepoint.7.h5 source.7.h5) elseif(${test} MATCHES "test_particle_restart") set(RESTART_FILE particle_10_394.h5) else(${test} MATCHES "test_statepoint_restart") From 2f9c6a8ae82eccc41667806784fcf7cb40345df4 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 3 Apr 2014 22:16:20 -0400 Subject: [PATCH 20/43] added more command line control --- tests/run_nightly_tests.py | 78 ++++++++++++++++++++++++++++++++------ 1 file changed, 67 insertions(+), 11 deletions(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index bd6f5a779c..0f84a535c9 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -3,8 +3,8 @@ from __future__ import print_function import os -import sys import shutil +import re from subprocess import call from collections import OrderedDict from optparse import OptionParser @@ -18,6 +18,20 @@ PETSC_DIR='/opt/petsc/3.4.3-gnu' # Command line parsing parser = OptionParser() +parser.add_option('-j', '--parallel', dest='n_procs', default='1', + help="Number of parallel jobs.") +parser.add_option('-R', '--tests-regex', dest='regex_tests', + help="Run tests matching regular expression. \ + Test names are the directories present in tests folder.\ + This uses standard regex syntax to select tests.") +parser.add_option('-C', '--build-config', dest='build_config', + help="Build configurations matching regular expression. \ + Specific build configurations can be printed out with \ + optional argument -p, --print. This uses standard \ + regex syntax to select build configurations.") +parser.add_option('-p', '--print', action="store_true", + dest="print_build_configs", default=False, + help="Print out build configurations.") parser.add_option("-b", "--branch", dest="branch", default="", help="branch name for build") parser.add_option("-D", "--dashboard", dest="dash", default="Experimental", @@ -45,17 +59,15 @@ set(CTEST_COVERAGE_COMMAND "/usr/bin/gcov") set(COVERAGE {coverage}) set(ENV{{COVERAGE}} ${{COVERAGE}}) -set(INCLUDED_TESTS "basic|cmfd_feed|confidence_intervals|density_atombcm|eigenvalue_genperbatch|energy_grid|entropy|filter_cell|lattice_multiple|output|plot_background|reflective_plane|rotation|salphabeta_multiple|score_absorption|seed|source_energy_mono|sourcepoint_batch|statepoint_interval|survival_biasing|tally_assumesep|translation|uniform_fs|universe|void") - ctest_start("{dashboard}") ctest_configure() ctest_update() ctest_build() if(MEM_CHECK) -ctest_test(INCLUDE ${{INCLUDED_TESTS}} PARALLEL_LEVEL 4) -ctest_memcheck(INCLUDE ${{INCLUDED_TESTS}}) +ctest_test({tests} PARALLEL_LEVEL {n_procs}) +ctest_memcheck({tests}) else(MEM_CHECK) -ctest_test(PARALLEL_LEVEL 4) +ctest_test({tests} PARALLEL_LEVEL {n_procs}) endif(MEM_CHECK) if(COVERAGE) ctest_coverage() @@ -165,18 +177,48 @@ add_test('hdf5-debug_coverage', debug=True, hdf5=True, coverage=True) add_test('mpi-debug_coverage', debug=True, mpi=True, coverage=True) add_test('petsc-debug_coverage', debug=True, petsc=True, mpi=True, coverage=True) +# Check to see if we are to just print build configuratinos +if options.print_build_configs: + for key in tests: + print('Configuration Name: {0}'.format(key)) + print(' Debug Flags:..........{0}'.format(tests[key].debug)) + print(' Optimization Flags:...{0}'.format(tests[key].optimize)) + print(' HDF5 Active:..........{0}'.format(tests[key].hdf5)) + print(' MPI Active:...........{0}'.format(tests[key].mpi)) + print(' OpenMP Active:........{0}'.format(tests[key].openmp)) + print(' PETSc Active:.........{0}'.format(tests[key].petsc)) + print(' Valgrind Test:........{0}'.format(tests[key].valgrind)) + print(' Coverage Test:........{0}\n'.format(tests[key].coverage)) + exit() + +# Delete items of dictionary that don't match regular expression +if options.build_config is not None: + for key in tests: + if not re.search(options.build_config, key): + del tests[key] + # Setup CTest vars pwd = os.environ['PWD'] ctest_vars = { 'source_dir' : pwd + '/../src', 'build_dir' : pwd + '/build', 'host_name' : 'neutronbalance', -'dashboard' : options.dash +'dashboard' : options.dash, +'n_procs' : options.n_procs } +# Set up default valgrind tests +# Currently takes too long to run all the tests with valgrind +valgrind_default_tests = "basic|cmfd_feed|confidence_intervals| \ + density_atombcm|eigenvalue_genperbatch|energy_grid|entropy| \ + filter_cell|lattice_multiple|output|plot_background|reflective_plane| \ + rotation|salphabeta_multiple|score_absorption|seed|source_energy_mono| \ + sourcepoint_batch|statepoint_interval|survival_biasing| \ + tally_assumesep|translation|uniform_fs|universe|void" + # Begin testing -call(['rm', '-rf', 'build']) -call(['rm', '-rf', 'ctestscript.run']) +shutils.rmtree('build', ignore_errors=True) +os.remove('ctestscript.run') call(['./cleanup']) for key in iter(tests): test = tests[key] @@ -187,6 +229,20 @@ for key in iter(tests): ctest_vars.update({'mem_check' : test.valgrind}) ctest_vars.update({'coverage' : test.coverage}) + # Check for user custom tests + # INCLUDE is a CTest command that allows for a subset + # of tests to be executed. + if options.regex_tests is None: + ctest_vars.update({'tests' : ''}) + + # No user tests, use default valgrind tests + if test.valgrind: + ctest_vars.update({'tests' : 'INCLUDE {0}'. + format(valgrind_default_tests)}) + else: + ctest_vars.update({'tests' : 'INCLUDE {0}'. + format(options.regex_tests)}) + # Create ctest script test.create_ctest_script(ctest_vars) @@ -194,6 +250,6 @@ for key in iter(tests): test.run_ctest() # Clear build directory - call(['rm', '-rf', 'build']) - call(['rm', '-rf', 'ctestscript.run']) + shutils.rmtree('build', ignore_errors=True) + os.remove('ctestscript.run') call(['./cleanup']) From a8e046e896100aac1d17fddef790ce0273b81a39 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 3 Apr 2014 22:17:05 -0400 Subject: [PATCH 21/43] changed shutils to shutil --- tests/run_nightly_tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 0f84a535c9..91dbdabfd4 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -217,7 +217,7 @@ valgrind_default_tests = "basic|cmfd_feed|confidence_intervals| \ tally_assumesep|translation|uniform_fs|universe|void" # Begin testing -shutils.rmtree('build', ignore_errors=True) +shutil.rmtree('build', ignore_errors=True) os.remove('ctestscript.run') call(['./cleanup']) for key in iter(tests): @@ -250,6 +250,6 @@ for key in iter(tests): test.run_ctest() # Clear build directory - shutils.rmtree('build', ignore_errors=True) + shutil.rmtree('build', ignore_errors=True) os.remove('ctestscript.run') call(['./cleanup']) From a786082f7650ff9c2b010ad66212c40086afe3d4 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 3 Apr 2014 22:20:44 -0400 Subject: [PATCH 22/43] dont need to remove ctest script at the beginning --- tests/run_nightly_tests.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 91dbdabfd4..4170521ae7 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -218,7 +218,6 @@ valgrind_default_tests = "basic|cmfd_feed|confidence_intervals| \ # Begin testing shutil.rmtree('build', ignore_errors=True) -os.remove('ctestscript.run') call(['./cleanup']) for key in iter(tests): test = tests[key] From 0538a48fd0653631f6de8d8a16ef4f18c60d0d96 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 3 Apr 2014 22:22:09 -0400 Subject: [PATCH 23/43] removed spaces in valgrind default tests --- tests/run_nightly_tests.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 4170521ae7..50ee0e75bc 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -210,11 +210,11 @@ ctest_vars = { # Set up default valgrind tests # Currently takes too long to run all the tests with valgrind valgrind_default_tests = "basic|cmfd_feed|confidence_intervals| \ - density_atombcm|eigenvalue_genperbatch|energy_grid|entropy| \ - filter_cell|lattice_multiple|output|plot_background|reflective_plane| \ - rotation|salphabeta_multiple|score_absorption|seed|source_energy_mono| \ - sourcepoint_batch|statepoint_interval|survival_biasing| \ - tally_assumesep|translation|uniform_fs|universe|void" +density_atombcm|eigenvalue_genperbatch|energy_grid|entropy| \ +filter_cell|lattice_multiple|output|plot_background|reflective_plane| \ +rotation|salphabeta_multiple|score_absorption|seed|source_energy_mono| \ +sourcepoint_batch|statepoint_interval|survival_biasing| \ +tally_assumesep|translation|uniform_fs|universe|void" # Begin testing shutil.rmtree('build', ignore_errors=True) From 67a4092495536d09b6d688a242a89e86cfba4395 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 3 Apr 2014 22:23:28 -0400 Subject: [PATCH 24/43] removed more spaces in valgrind default tests --- tests/run_nightly_tests.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 50ee0e75bc..f9d376da54 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -209,11 +209,11 @@ ctest_vars = { # Set up default valgrind tests # Currently takes too long to run all the tests with valgrind -valgrind_default_tests = "basic|cmfd_feed|confidence_intervals| \ -density_atombcm|eigenvalue_genperbatch|energy_grid|entropy| \ -filter_cell|lattice_multiple|output|plot_background|reflective_plane| \ -rotation|salphabeta_multiple|score_absorption|seed|source_energy_mono| \ -sourcepoint_batch|statepoint_interval|survival_biasing| \ +valgrind_default_tests = "basic|cmfd_feed|confidence_intervals|\ +density_atombcm|eigenvalue_genperbatch|energy_grid|entropy|\ +filter_cell|lattice_multiple|output|plot_background|reflective_plane|\ +rotation|salphabeta_multiple|score_absorption|seed|source_energy_mono|\ +sourcepoint_batch|statepoint_interval|survival_biasing|\ tally_assumesep|translation|uniform_fs|universe|void" # Begin testing From 3fd2b1269510f4d50e0e9acb9c68cb5f1ac28080 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 3 Apr 2014 22:24:55 -0400 Subject: [PATCH 25/43] removed redundant ctest call --- tests/run_nightly_tests.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index f9d376da54..b401271a04 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -63,11 +63,9 @@ ctest_start("{dashboard}") ctest_configure() ctest_update() ctest_build() +ctest_test({tests} PARALLEL_LEVEL {n_procs}) if(MEM_CHECK) -ctest_test({tests} PARALLEL_LEVEL {n_procs}) ctest_memcheck({tests}) -else(MEM_CHECK) -ctest_test({tests} PARALLEL_LEVEL {n_procs}) endif(MEM_CHECK) if(COVERAGE) ctest_coverage() From ee7e099ef5c6a837a8985ef4e974e37994451c2b Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 3 Apr 2014 22:38:11 -0400 Subject: [PATCH 26/43] added default option to not submit tests to CDash server --- tests/run_nightly_tests.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index b401271a04..597c0e9da3 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -34,7 +34,7 @@ parser.add_option('-p', '--print', action="store_true", help="Print out build configurations.") parser.add_option("-b", "--branch", dest="branch", default="", help="branch name for build") -parser.add_option("-D", "--dashboard", dest="dash", default="Experimental", +parser.add_option("-D", "--dashboard", dest="dash", help="Dash name -- Experimental, Nightly, Continuous") (options, args) = parser.parse_args() @@ -70,7 +70,7 @@ endif(MEM_CHECK) if(COVERAGE) ctest_coverage() endif(COVERAGE) -ctest_submit()""" +{submit}""" # Define test data structure tests = OrderedDict() @@ -195,13 +195,22 @@ if options.build_config is not None: if not re.search(options.build_config, key): del tests[key] +# Check for dashboard and determine whether to push results to server +if options.dash is None: + dash = 'Experimental' + submit = '' +else + dash = options.dash + submit = 'ctest_submit()' + # Setup CTest vars pwd = os.environ['PWD'] ctest_vars = { 'source_dir' : pwd + '/../src', 'build_dir' : pwd + '/build', 'host_name' : 'neutronbalance', -'dashboard' : options.dash, +'dashboard' : dash, +'submit' : submit, 'n_procs' : options.n_procs } From f6ffb8e42f0bb8ac36525a76cbbab3765d545f4a Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 3 Apr 2014 22:38:50 -0400 Subject: [PATCH 27/43] fixed python syntax --- tests/run_nightly_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 597c0e9da3..c78c6763fa 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -199,7 +199,7 @@ if options.build_config is not None: if options.dash is None: dash = 'Experimental' submit = '' -else +else: dash = options.dash submit = 'ctest_submit()' From a1de0675feb1b9a5e6bf26e4a2d6cd242349c3a4 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Tue, 8 Apr 2014 14:33:12 -0400 Subject: [PATCH 28/43] added environ vars --- tests/run_nightly_tests.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index c78c6763fa..c025dd5e18 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -9,13 +9,6 @@ from subprocess import call from collections import OrderedDict from optparse import OptionParser -# Compiler paths -FC_DEFAULT='gfortran' -MPI_DIR='/opt/mpich/3.0.4-gnu' -HDF5_DIR='/opt/hdf5/1.8.12-gnu' -PHDF5_DIR='/opt/phdf5/1.8.12-gnu' -PETSC_DIR='/opt/petsc/3.4.3-gnu' - # Command line parsing parser = OptionParser() parser.add_option('-j', '--parallel', dest='n_procs', default='1', @@ -38,6 +31,27 @@ parser.add_option("-D", "--dashboard", dest="dash", help="Dash name -- Experimental, Nightly, Continuous") (options, args) = parser.parse_args() +# Compiler paths +FC_DEFAULT='gfortran' +MPI_DIR='/opt/mpich/3.0.4-gnu' +HDF5_DIR='/opt/hdf5/1.8.12-gnu' +PHDF5_DIR='/opt/phdf5/1.8.12-gnu' +PETSC_DIR='/opt/petsc/3.4.3-gnu' + +# Override default compiler paths if environmental vars are found +if os.environ.has_key('FC'): + FC = os.environ['FC'] + if FC is not 'gfortran': + print('NOTE: Test suite only verifed for gfortran compiler.') +if os.environ.has_key('MPI_DIR'): + MPI_DIR = os.environ['MPI_DIR'] +if os.environ.has_key('HDF5_DIR'): + HDF5_DIR = os.environ['HDF5_DIR'] +if os.environ.has_key('PHDF5_DIR'): + PHDF5_DIR = os.environ['PHDF5_DIR'] +if os.environ.has_key('PETSC_DIR'): + PETSC_DIR = os.environ['PETSC_DIR'] + # CTest script template ctest_str = """set (CTEST_SOURCE_DIRECTORY "{source_dir}") set (CTEST_BINARY_DIRECTORY "{build_dir}") From 549a05f62ee382858bb6a066c97decfdfa007edd Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Tue, 8 Apr 2014 14:40:25 -0400 Subject: [PATCH 29/43] added option for updating repo --- tests/run_nightly_tests.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index c025dd5e18..dcd4636a8b 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -29,6 +29,9 @@ parser.add_option("-b", "--branch", dest="branch", default="", help="branch name for build") parser.add_option("-D", "--dashboard", dest="dash", help="Dash name -- Experimental, Nightly, Continuous") +parser.add_option("-u", "--update", action="store_true", dest="update", + help="Allow CTest to update repo. (WARNING: may overwrite\ + changes that were not pushed.") (options, args) = parser.parse_args() # Compiler paths @@ -75,7 +78,7 @@ set(ENV{{COVERAGE}} ${{COVERAGE}}) ctest_start("{dashboard}") ctest_configure() -ctest_update() +{update} ctest_build() ctest_test({tests} PARALLEL_LEVEL {n_procs}) if(MEM_CHECK) @@ -217,6 +220,12 @@ else: dash = options.dash submit = 'ctest_submit()' +# Check for update command +if options.update: + update = 'ctest_update()' +else: + update = '' + # Setup CTest vars pwd = os.environ['PWD'] ctest_vars = { @@ -225,6 +234,7 @@ ctest_vars = { 'host_name' : 'neutronbalance', 'dashboard' : dash, 'submit' : submit, +'update' : update, 'n_procs' : options.n_procs } From 66107d89a02e9ded934cbd0208bac11545214358 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Tue, 8 Apr 2014 14:56:06 -0400 Subject: [PATCH 30/43] changed FC_DEFAULT to FC --- tests/run_nightly_tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index dcd4636a8b..2a27732eb4 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -35,7 +35,7 @@ parser.add_option("-u", "--update", action="store_true", dest="update", (options, args) = parser.parse_args() # Compiler paths -FC_DEFAULT='gfortran' +FC='gfortran' MPI_DIR='/opt/mpich/3.0.4-gnu' HDF5_DIR='/opt/hdf5/1.8.12-gnu' PHDF5_DIR='/opt/phdf5/1.8.12-gnu' @@ -113,7 +113,7 @@ class Test(object): elif self.mpi and self.hdf5: self.fc = PHDF5_DIR+'/bin/h5pfc' else: - self.fc = FC_DEFAULT + self.fc = FC def get_build_name(self): self.build_name = options.branch + '_' + self.name From 3e060d5793fd459cd9dd8a9ecc244463fcb850f2 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Tue, 8 Apr 2014 15:26:22 -0400 Subject: [PATCH 31/43] always save log file --- tests/run_nightly_tests.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 2a27732eb4..6121856425 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -5,6 +5,7 @@ from __future__ import print_function import os import shutil import re +import glob from subprocess import call from collections import OrderedDict from optparse import OptionParser @@ -279,6 +280,10 @@ for key in iter(tests): # Run test test.run_ctest() + # Copy over log file + logfile = glob.glob('build/Testing/Temporary/LastTest*.log') + shutil.copy(logfile[0], 'LastTest_{0}.log'.format(test.name)) + # Clear build directory shutil.rmtree('build', ignore_errors=True) os.remove('ctestscript.run') From 0ac10fbc1e9275a48304f64c3bb3adba4d02e876 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Tue, 8 Apr 2014 15:30:16 -0400 Subject: [PATCH 32/43] added better regex for log file --- tests/run_nightly_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 6121856425..7fe8b8199f 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -281,7 +281,7 @@ for key in iter(tests): test.run_ctest() # Copy over log file - logfile = glob.glob('build/Testing/Temporary/LastTest*.log') + logfile = glob.glob('build/Testing/Temporary/LastTest_*.log') shutil.copy(logfile[0], 'LastTest_{0}.log'.format(test.name)) # Clear build directory From b7dcf9f1b3ebc7829b8314f89ad0559d4fcda0f6 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Tue, 8 Apr 2014 15:44:26 -0400 Subject: [PATCH 33/43] keep timestamp on logfile name --- tests/run_nightly_tests.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 7fe8b8199f..bff745b815 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -282,7 +282,10 @@ for key in iter(tests): # Copy over log file logfile = glob.glob('build/Testing/Temporary/LastTest_*.log') - shutil.copy(logfile[0], 'LastTest_{0}.log'.format(test.name)) + logfilename = os.path.split(logfile[0])[1] + logfilename = os.path.splitext(logfilename)[0] + logfilename = logfilename + '_{0}.log'.format(test.name) + shutil.copy(logfile[0], logfilename) # Clear build directory shutil.rmtree('build', ignore_errors=True) From e57453c0988fcda992acde10638f182f71dce65e Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 10 Apr 2014 16:35:10 -0400 Subject: [PATCH 34/43] hostname now set by socket --- tests/run_nightly_tests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index bff745b815..661104c352 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -6,6 +6,7 @@ import os import shutil import re import glob +import socket from subprocess import call from collections import OrderedDict from optparse import OptionParser @@ -232,7 +233,7 @@ pwd = os.environ['PWD'] ctest_vars = { 'source_dir' : pwd + '/../src', 'build_dir' : pwd + '/build', -'host_name' : 'neutronbalance', +'host_name' : socket.gethostname(), 'dashboard' : dash, 'submit' : submit, 'update' : update, From f02f077d6341307f7d52b06cd056b9c7e823f1ed Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Fri, 25 Apr 2014 10:04:08 -0400 Subject: [PATCH 35/43] changed restart particles in CMakeLists --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 82da9e878a..d1e88abb42 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -310,7 +310,7 @@ foreach(test ${TESTS}) elseif(${test} MATCHES "test_sourcepoint_restart") set(RESTART_FILE statepoint.7.h5 source.7.h5) elseif(${test} MATCHES "test_particle_restart") - set(RESTART_FILE particle_10_394.h5) + set(RESTART_FILE particle_12_192.h5) else(${test} MATCHES "test_statepoint_restart") message(FATAL_ERROR "Restart test ${test} not recognized") endif(${test} MATCHES "test_statepoint_restart") @@ -323,7 +323,7 @@ foreach(test ${TESTS}) elseif(${test} MATCHES "test_sourcepoint_restart") set(RESTART_FILE statepoint.7.binary source.7.binary) elseif(${test} MATCHES "test_particle_restart") - set(RESTART_FILE particle_10_394.binary) + set(RESTART_FILE particle_12_192.binary) else(${test} MATCHES "test_statepoint_restart") message(FATAL_ERROR "Restart test ${test} not recognized") endif(${test} MATCHES "test_statepoint_restart") From a83d50c8496ae1d4c6142fa66d2aea1e091a4222 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Mon, 28 Apr 2014 23:15:54 -0400 Subject: [PATCH 36/43] merged run_tests into run_nightly tests --- tests/run_nightly_tests.py | 162 +++++++++++++++++++++++++++++++++++-- 1 file changed, 154 insertions(+), 8 deletions(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index 661104c352..cf8e3cf228 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -3,6 +3,7 @@ from __future__ import print_function import os +import sys import shutil import re import glob @@ -34,6 +35,9 @@ parser.add_option("-D", "--dashboard", dest="dash", parser.add_option("-u", "--update", action="store_true", dest="update", help="Allow CTest to update repo. (WARNING: may overwrite\ changes that were not pushed.") +parser.add_option("-s", "--script", action="store_true", dest="script", + help="Activate CTest scripting mode for coverage, valgrind\ + and dashboard capability.") (options, args) = parser.parse_args() # Compiler paths @@ -43,6 +47,9 @@ HDF5_DIR='/opt/hdf5/1.8.12-gnu' PHDF5_DIR='/opt/phdf5/1.8.12-gnu' PETSC_DIR='/opt/petsc/3.4.3-gnu' +# Script mode for extra capability +script_mode = False + # Override default compiler paths if environmental vars are found if os.environ.has_key('FC'): FC = os.environ['FC'] @@ -106,6 +113,9 @@ class Test(object): self.petsc = petsc self.valgrind = valgrind self.coverage = coverage + self.success = True + self.msg = None + self.cmake = ['cmake', '-H../src', '-Bbuild'] # Check for MPI/HDF5 if self.mpi and not self.hdf5: @@ -140,13 +150,79 @@ class Test(object): with open('ctestscript.run', 'w') as fh: fh.write(ctest_str.format(**ctest_vars)) - def run_ctest(self): + def run_ctest_script(self): os.environ['FC'] = self.fc if self.petsc: os.environ['PETSC_DIR'] = PETSC_DIR if self.mpi: os.environ['MPI_DIR'] = MPI_DIR - call(['ctest', '-S', 'ctestscript.run','-V']) + rc = call(['ctest', '-S', 'ctestscript.run','-V']) + if rc != 0: + self.success = False + self.msg = 'Failed on ctest script.' + + def run_cmake(self): + os.environ['FC'] = self.fc + build_opts = self.build_opts.split() + self.cmake += build_opts + rc = call(self.cmake) + if rc != 0: + self.success = False + self.msg = 'Failed on cmake.' + + def run_make(self): + if not self.success: + return + + # Default make string + make_list = ['make','-s'] + + # Check for parallel + if options.n_procs is not None: + make_list.append('-j') + make_list.append(options.n_procs) + + # Run make + rc = call(make_list) + if rc != 0: + self.success = False + self.msg = 'Failed on make.' + + def run_ctests(self): + if not self.success: + return + + # Default ctest string + ctest_list = ['ctest'] + + # Check for parallel + if options.n_procs is not None: + ctest_list.append('-j') + ctest_list.append(options.n_procs) + + # Check for subset of tests + if options.regex_tests is not None: + ctest_list.append('-R') + ctest_list.append(options.regex_tests) + + # Run ctests + rc = call(ctest_list) + if rc != 0: + self.success = False + self.msg = 'Failed on testing.' + + # Checks to see if file exists in PWD or PATH + def check_compiler(self): + result = False + if os.path.isfile(self.fc): + result = True + for path in os.environ["PATH"].split(":"): + if os.path.isfile(os.path.join(path, self.fc)): + result = True + if not result: + raise Exception("Compiler path '{0}' does not exist." + .format(self.fc)+ + "Please set appropriate environmental variable(s).") def add_test(name, debug=False, optimize=False, mpi=False, openmp=False,\ hdf5=False, petsc=False, valgrind=False, coverage=False): @@ -228,6 +304,12 @@ if options.update: else: update = '' +# Check for CTest scipts mode +if not options.dash is None or options.script: + script_mode = True +else: + script_mode = False + # Setup CTest vars pwd = os.environ['PWD'] ctest_vars = { @@ -255,6 +337,23 @@ call(['./cleanup']) for key in iter(tests): test = tests[key] + # No valgrind or coverage if not in CTest script mode + if not script_mode: + if test.valgrind: + continue + if test.coverage: + continue + + # Extra display if not in script mode + if not script_mode: + print('-'*(len(key) + 6)) + print(key + ' tests') + print('-'*(len(key) + 6)) + sys.stdout.flush() + + # Verify fortran compiler exists + test.check_compiler() + # Set test specific CTest vars ctest_vars.update({'build_name' : test.get_build_name()}) ctest_vars.update({'build_opts' : test.get_build_opts()}) @@ -275,14 +374,37 @@ for key in iter(tests): ctest_vars.update({'tests' : 'INCLUDE {0}'. format(options.regex_tests)}) - # Create ctest script - test.create_ctest_script(ctest_vars) + # Script mode + if script_mode: - # Run test - test.run_ctest() + # Create ctest script + test.create_ctest_script(ctest_vars) + + # Run test + test.run_ctest_script() + + else: + + # Run CMAKE to configure build + test.run_cmake() + + # Go into build directory + os.chdir('build') + + # Build OpenMC + test.run_make() + + # Run tests + test.run_ctests() + + # Leave build directory + os.chdir('..') # Copy over log file - logfile = glob.glob('build/Testing/Temporary/LastTest_*.log') + if script_mode: + logfile = glob.glob('build/Testing/Temporary/LastTest_*.log') + else: + logfile = glob.glob('build/Testing/Temporary/LastTest.log') logfilename = os.path.split(logfile[0])[1] logfilename = os.path.splitext(logfilename)[0] logfilename = logfilename + '_{0}.log'.format(test.name) @@ -290,5 +412,29 @@ for key in iter(tests): # Clear build directory shutil.rmtree('build', ignore_errors=True) - os.remove('ctestscript.run') + if script_mode: + os.remove('ctestscript.run') call(['./cleanup']) + +# Print out summary of results +print('\n' + '='*54) +print('Summary of Compilation Option Testing:\n') + +if sys.stdout.isatty(): + OK = '\033[92m' + FAIL = '\033[91m' + ENDC = '\033[0m' + BOLD = '\033[1m' +else: + OK = '' + FAIL = '' + ENDC = '' + BOLD = '' + +for test in tests: + print(test + '.'*(50 - len(test)), end='') + if tests[test].success: + print(BOLD + OK + '[OK]' + ENDC) + else: + print(BOLD + FAIL + '[FAILED]' + ENDC) + print(' '*len(test)+tests[test].msg) From 265c25574625a3fdc9a3189a82ce1f8900de43bc Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Tue, 29 Apr 2014 10:40:40 -0400 Subject: [PATCH 37/43] added more comments, only copy logfile if found, remove gfortran warning --- tests/run_nightly_tests.py | 53 ++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py index cf8e3cf228..4d2e0876b3 100755 --- a/tests/run_nightly_tests.py +++ b/tests/run_nightly_tests.py @@ -53,8 +53,6 @@ script_mode = False # Override default compiler paths if environmental vars are found if os.environ.has_key('FC'): FC = os.environ['FC'] - if FC is not 'gfortran': - print('NOTE: Test suite only verifed for gfortran compiler.') if os.environ.has_key('MPI_DIR'): MPI_DIR = os.environ['MPI_DIR'] if os.environ.has_key('HDF5_DIR'): @@ -127,10 +125,13 @@ class Test(object): else: self.fc = FC + # Sets the build name that will show up on the CDash def get_build_name(self): self.build_name = options.branch + '_' + self.name return self.build_name + # Sets up build options for various tests. It is used both + # in script and non-script modes def get_build_opts(self): build_str = "" if self.debug: @@ -146,10 +147,12 @@ class Test(object): self.build_opts = build_str return self.build_opts + # Write out the ctest script to tests directory def create_ctest_script(self, ctest_vars): with open('ctestscript.run', 'w') as fh: fh.write(ctest_str.format(**ctest_vars)) + # Runs the ctest script which performs all the cmake/ctest/cdash def run_ctest_script(self): os.environ['FC'] = self.fc if self.petsc: @@ -161,6 +164,7 @@ class Test(object): self.success = False self.msg = 'Failed on ctest script.' + # Runs cmake when in non-script mode def run_cmake(self): os.environ['FC'] = self.fc build_opts = self.build_opts.split() @@ -170,6 +174,7 @@ class Test(object): self.success = False self.msg = 'Failed on cmake.' + # Runs make when in non-script mode def run_make(self): if not self.success: return @@ -188,6 +193,7 @@ class Test(object): self.success = False self.msg = 'Failed on make.' + # Runs ctest when in non-script mode def run_ctests(self): if not self.success: return @@ -224,11 +230,14 @@ class Test(object): .format(self.fc)+ "Please set appropriate environmental variable(s).") +# Simple function to add a test to the global tests dictionary def add_test(name, debug=False, optimize=False, mpi=False, openmp=False,\ hdf5=False, petsc=False, valgrind=False, coverage=False): - tests.update({name:Test(name, debug, optimize, mpi, openmp, hdf5, petsc, valgrind, coverage)}) + tests.update({name:Test(name, debug, optimize, mpi, openmp, hdf5, petsc, + valgrind, coverage)}) -# List of tests +# List of all tests that may be run. User can add -C to command line to specify +# a subset of these configurations add_test('basic-normal') add_test('basic-debug', debug=True) add_test('basic-optimize', optimize=True) @@ -270,7 +279,7 @@ add_test('hdf5-debug_coverage', debug=True, hdf5=True, coverage=True) add_test('mpi-debug_coverage', debug=True, mpi=True, coverage=True) add_test('petsc-debug_coverage', debug=True, petsc=True, mpi=True, coverage=True) -# Check to see if we are to just print build configuratinos +# Check to see if we should just print build configuration information to user if options.print_build_configs: for key in tests: print('Configuration Name: {0}'.format(key)) @@ -291,6 +300,10 @@ if options.build_config is not None: del tests[key] # Check for dashboard and determine whether to push results to server +# Note that there are only 3 basic dashboards: +# Experimental, Nightly, Continuous. On the CDash end, these can be +# reorganized into groups when a hostname, dashboard and build name +# are matched. if options.dash is None: dash = 'Experimental' submit = '' @@ -298,19 +311,22 @@ else: dash = options.dash submit = 'ctest_submit()' -# Check for update command +# Check for update command, which will run git fetch/merge and will delete +# any changes to repo that were not pushed to remote origin if options.update: update = 'ctest_update()' else: update = '' # Check for CTest scipts mode +# Sets up whether we should use just the basic ctest command or use +# CTest scripting to perform tests. if not options.dash is None or options.script: script_mode = True else: script_mode = False -# Setup CTest vars +# Setup CTest script vars. Not used in non-script mode pwd = os.environ['PWD'] ctest_vars = { 'source_dir' : pwd + '/../src', @@ -322,8 +338,9 @@ ctest_vars = { 'n_procs' : options.n_procs } -# Set up default valgrind tests +# Set up default valgrind tests (subset of all tests) # Currently takes too long to run all the tests with valgrind +# Only used in script mode valgrind_default_tests = "basic|cmfd_feed|confidence_intervals|\ density_atombcm|eigenvalue_genperbatch|energy_grid|entropy|\ filter_cell|lattice_multiple|output|plot_background|reflective_plane|\ @@ -333,7 +350,7 @@ tally_assumesep|translation|uniform_fs|universe|void" # Begin testing shutil.rmtree('build', ignore_errors=True) -call(['./cleanup']) +call(['./cleanup']) # removes all binary and hdf5 output files from tests for key in iter(tests): test = tests[key] @@ -354,7 +371,7 @@ for key in iter(tests): # Verify fortran compiler exists test.check_compiler() - # Set test specific CTest vars + # Set test specific CTest script vars. Not used in non-script mode ctest_vars.update({'build_name' : test.get_build_name()}) ctest_vars.update({'build_opts' : test.get_build_opts()}) ctest_vars.update({'mem_check' : test.valgrind}) @@ -362,7 +379,7 @@ for key in iter(tests): # Check for user custom tests # INCLUDE is a CTest command that allows for a subset - # of tests to be executed. + # of tests to be executed. Only used in script mode. if options.regex_tests is None: ctest_vars.update({'tests' : ''}) @@ -374,7 +391,8 @@ for key in iter(tests): ctest_vars.update({'tests' : 'INCLUDE {0}'. format(options.regex_tests)}) - # Script mode + # Main part of code that does the ctest execution. + # It is broken up by two modes, script and non-script if script_mode: # Create ctest script @@ -405,12 +423,13 @@ for key in iter(tests): logfile = glob.glob('build/Testing/Temporary/LastTest_*.log') else: logfile = glob.glob('build/Testing/Temporary/LastTest.log') - logfilename = os.path.split(logfile[0])[1] - logfilename = os.path.splitext(logfilename)[0] - logfilename = logfilename + '_{0}.log'.format(test.name) - shutil.copy(logfile[0], logfilename) + if len(logfile) > 0: + logfilename = os.path.split(logfile[0])[1] + logfilename = os.path.splitext(logfilename)[0] + logfilename = logfilename + '_{0}.log'.format(test.name) + shutil.copy(logfile[0], logfilename) - # Clear build directory + # Clear build directory and remove binary and hdf5 files shutil.rmtree('build', ignore_errors=True) if script_mode: os.remove('ctestscript.run') From 96cda14fb9acf8f1f9e393a8264a8bbdc64d6137 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Tue, 29 Apr 2014 10:41:32 -0400 Subject: [PATCH 38/43] merged run nightly tests and run tests into one common script --- tests/run_nightly_tests.py | 459 ------------------------------------- tests/run_tests.py | 318 +++++++++++++++++++------ 2 files changed, 254 insertions(+), 523 deletions(-) delete mode 100755 tests/run_nightly_tests.py diff --git a/tests/run_nightly_tests.py b/tests/run_nightly_tests.py deleted file mode 100755 index 4d2e0876b3..0000000000 --- a/tests/run_nightly_tests.py +++ /dev/null @@ -1,459 +0,0 @@ -#!/usr/bin/env python - -from __future__ import print_function - -import os -import sys -import shutil -import re -import glob -import socket -from subprocess import call -from collections import OrderedDict -from optparse import OptionParser - -# Command line parsing -parser = OptionParser() -parser.add_option('-j', '--parallel', dest='n_procs', default='1', - help="Number of parallel jobs.") -parser.add_option('-R', '--tests-regex', dest='regex_tests', - help="Run tests matching regular expression. \ - Test names are the directories present in tests folder.\ - This uses standard regex syntax to select tests.") -parser.add_option('-C', '--build-config', dest='build_config', - help="Build configurations matching regular expression. \ - Specific build configurations can be printed out with \ - optional argument -p, --print. This uses standard \ - regex syntax to select build configurations.") -parser.add_option('-p', '--print', action="store_true", - dest="print_build_configs", default=False, - help="Print out build configurations.") -parser.add_option("-b", "--branch", dest="branch", default="", - help="branch name for build") -parser.add_option("-D", "--dashboard", dest="dash", - help="Dash name -- Experimental, Nightly, Continuous") -parser.add_option("-u", "--update", action="store_true", dest="update", - help="Allow CTest to update repo. (WARNING: may overwrite\ - changes that were not pushed.") -parser.add_option("-s", "--script", action="store_true", dest="script", - help="Activate CTest scripting mode for coverage, valgrind\ - and dashboard capability.") -(options, args) = parser.parse_args() - -# Compiler paths -FC='gfortran' -MPI_DIR='/opt/mpich/3.0.4-gnu' -HDF5_DIR='/opt/hdf5/1.8.12-gnu' -PHDF5_DIR='/opt/phdf5/1.8.12-gnu' -PETSC_DIR='/opt/petsc/3.4.3-gnu' - -# Script mode for extra capability -script_mode = False - -# Override default compiler paths if environmental vars are found -if os.environ.has_key('FC'): - FC = os.environ['FC'] -if os.environ.has_key('MPI_DIR'): - MPI_DIR = os.environ['MPI_DIR'] -if os.environ.has_key('HDF5_DIR'): - HDF5_DIR = os.environ['HDF5_DIR'] -if os.environ.has_key('PHDF5_DIR'): - PHDF5_DIR = os.environ['PHDF5_DIR'] -if os.environ.has_key('PETSC_DIR'): - PETSC_DIR = os.environ['PETSC_DIR'] - -# CTest script template -ctest_str = """set (CTEST_SOURCE_DIRECTORY "{source_dir}") -set (CTEST_BINARY_DIRECTORY "{build_dir}") - -set(CTEST_SITE "{host_name}") -set (CTEST_BUILD_NAME "{build_name}") -set (CTEST_CMAKE_GENERATOR "Unix Makefiles") -set (CTEST_BUILD_OPTIONS "{build_opts}") - -set(CTEST_UPDATE_COMMAND "git") - -set(CTEST_CONFIGURE_COMMAND "${{CMAKE_COMMAND}} -H${{CTEST_SOURCE_DIRECTORY}} -B${{CTEST_BINARY_DIRECTORY}} ${{CTEST_BUILD_OPTIONS}}") -set(CTEST_MEMORYCHECK_COMMAND "/usr/bin/valgrind") -set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes") -set(MEM_CHECK {mem_check}) -set(ENV{{MEM_CHECK}} ${{MEM_CHECK}}) - -set(CTEST_COVERAGE_COMMAND "/usr/bin/gcov") -set(COVERAGE {coverage}) -set(ENV{{COVERAGE}} ${{COVERAGE}}) - -ctest_start("{dashboard}") -ctest_configure() -{update} -ctest_build() -ctest_test({tests} PARALLEL_LEVEL {n_procs}) -if(MEM_CHECK) -ctest_memcheck({tests}) -endif(MEM_CHECK) -if(COVERAGE) -ctest_coverage() -endif(COVERAGE) -{submit}""" - -# Define test data structure -tests = OrderedDict() - -class Test(object): - def __init__(self, name, debug=False, optimize=False, mpi=False, openmp=False, - hdf5=False, petsc=False, valgrind=False, coverage=False): - self.name = name - self.debug = debug - self.optimize = optimize - self.mpi = mpi - self.openmp = openmp - self.hdf5 = hdf5 - self.petsc = petsc - self.valgrind = valgrind - self.coverage = coverage - self.success = True - self.msg = None - self.cmake = ['cmake', '-H../src', '-Bbuild'] - - # Check for MPI/HDF5 - if self.mpi and not self.hdf5: - self.fc = MPI_DIR+'/bin/mpif90' - elif not self.mpi and self.hdf5: - self.fc = HDF5_DIR+'/bin/h5fc' - elif self.mpi and self.hdf5: - self.fc = PHDF5_DIR+'/bin/h5pfc' - else: - self.fc = FC - - # Sets the build name that will show up on the CDash - def get_build_name(self): - self.build_name = options.branch + '_' + self.name - return self.build_name - - # Sets up build options for various tests. It is used both - # in script and non-script modes - def get_build_opts(self): - build_str = "" - if self.debug: - build_str += "-Ddebug=ON " - if self.optimize: - build_str += "-Doptimize=ON " - if self.openmp: - build_str += "-Dopenmp=ON " - if self.petsc: - build_str += "-Dpetsc=ON " - if self.coverage: - build_str += "-Dcoverage=ON " - self.build_opts = build_str - return self.build_opts - - # Write out the ctest script to tests directory - def create_ctest_script(self, ctest_vars): - with open('ctestscript.run', 'w') as fh: - fh.write(ctest_str.format(**ctest_vars)) - - # Runs the ctest script which performs all the cmake/ctest/cdash - def run_ctest_script(self): - os.environ['FC'] = self.fc - if self.petsc: - os.environ['PETSC_DIR'] = PETSC_DIR - if self.mpi: - os.environ['MPI_DIR'] = MPI_DIR - rc = call(['ctest', '-S', 'ctestscript.run','-V']) - if rc != 0: - self.success = False - self.msg = 'Failed on ctest script.' - - # Runs cmake when in non-script mode - def run_cmake(self): - os.environ['FC'] = self.fc - build_opts = self.build_opts.split() - self.cmake += build_opts - rc = call(self.cmake) - if rc != 0: - self.success = False - self.msg = 'Failed on cmake.' - - # Runs make when in non-script mode - def run_make(self): - if not self.success: - return - - # Default make string - make_list = ['make','-s'] - - # Check for parallel - if options.n_procs is not None: - make_list.append('-j') - make_list.append(options.n_procs) - - # Run make - rc = call(make_list) - if rc != 0: - self.success = False - self.msg = 'Failed on make.' - - # Runs ctest when in non-script mode - def run_ctests(self): - if not self.success: - return - - # Default ctest string - ctest_list = ['ctest'] - - # Check for parallel - if options.n_procs is not None: - ctest_list.append('-j') - ctest_list.append(options.n_procs) - - # Check for subset of tests - if options.regex_tests is not None: - ctest_list.append('-R') - ctest_list.append(options.regex_tests) - - # Run ctests - rc = call(ctest_list) - if rc != 0: - self.success = False - self.msg = 'Failed on testing.' - - # Checks to see if file exists in PWD or PATH - def check_compiler(self): - result = False - if os.path.isfile(self.fc): - result = True - for path in os.environ["PATH"].split(":"): - if os.path.isfile(os.path.join(path, self.fc)): - result = True - if not result: - raise Exception("Compiler path '{0}' does not exist." - .format(self.fc)+ - "Please set appropriate environmental variable(s).") - -# Simple function to add a test to the global tests dictionary -def add_test(name, debug=False, optimize=False, mpi=False, openmp=False,\ - hdf5=False, petsc=False, valgrind=False, coverage=False): - tests.update({name:Test(name, debug, optimize, mpi, openmp, hdf5, petsc, - valgrind, coverage)}) - -# List of all tests that may be run. User can add -C to command line to specify -# a subset of these configurations -add_test('basic-normal') -add_test('basic-debug', debug=True) -add_test('basic-optimize', optimize=True) -add_test('omp-normal', openmp=True) -add_test('omp-debug', openmp=True, debug=True) -add_test('omp-optimize', openmp=True, optimize=True) -add_test('hdf5-normal', hdf5=True) -add_test('hdf5-debug', hdf5=True, debug=True) -add_test('hdf5-optimize', hdf5=True, optimize=True) -add_test('omp-hdf5-normal', openmp=True, hdf5=True) -add_test('omp-hdf5-debug', openmp=True, hdf5=True, debug=True) -add_test('omp-hdf5-optimize', openmp=True, hdf5=True, optimize=True) -add_test('mpi-normal', mpi=True) -add_test('mpi-debug', mpi=True, debug=True) -add_test('mpi-optimize', mpi=True, optimize=True) -add_test('mpi-omp-normal', mpi=True, openmp=True) -add_test('mpi-omp-debug', mpi=True, openmp=True, debug=True) -add_test('mpi-omp-optimize', mpi=True, openmp=True, optimize=True) -add_test('phdf5-normal', mpi=True, hdf5=True) -add_test('phdf5-debug', mpi=True, hdf5=True, debug=True) -add_test('phdf5-optimize', mpi=True, hdf5=True, optimize=True) -add_test('phdf5-omp-normal', mpi=True, hdf5=True, openmp=True) -add_test('phdf5-omp-debug', mpi=True, hdf5=True, openmp=True, debug=True) -add_test('phdf5-omp-optimize', mpi=True, hdf5=True, openmp=True, optimize=True) -add_test('petsc-normal', petsc=True, mpi=True) -add_test('petsc-debug', petsc=True, mpi=True, debug=True) -add_test('petsc-optimize', petsc=True, mpi=True, optimize=True) -add_test('phdf5-petsc-normal', mpi=True, hdf5=True, petsc=True) -add_test('phdf5-petsc-debug', mpi=True, hdf5=True, petsc=True, debug=True) -add_test('phdf5-petsc-optimize', mpi=True, hdf5=True, petsc=True, optimize=True) -add_test('omp-phdf5-petsc-normal', openmp=True, mpi=True, hdf5=True, petsc=True) -add_test('omp-phdf5-petsc-debug', openmp=True, mpi=True, hdf5=True, petsc=True, debug=True) -add_test('omp-phdf5-petsc-optimize', openmp=True, mpi=True, hdf5=True, petsc=True, optimize=True) -add_test('basic-debug_valgrind', debug=True, valgrind=True) -add_test('hdf5-debug_valgrind', hdf5=True, debug=True, valgrind=True) -add_test('petsc-debug_valgrind', petsc=True, mpi=True, debug=True, valgrind=True) -add_test('basic-debug_coverage', debug=True, coverage=True) -add_test('hdf5-debug_coverage', debug=True, hdf5=True, coverage=True) -add_test('mpi-debug_coverage', debug=True, mpi=True, coverage=True) -add_test('petsc-debug_coverage', debug=True, petsc=True, mpi=True, coverage=True) - -# Check to see if we should just print build configuration information to user -if options.print_build_configs: - for key in tests: - print('Configuration Name: {0}'.format(key)) - print(' Debug Flags:..........{0}'.format(tests[key].debug)) - print(' Optimization Flags:...{0}'.format(tests[key].optimize)) - print(' HDF5 Active:..........{0}'.format(tests[key].hdf5)) - print(' MPI Active:...........{0}'.format(tests[key].mpi)) - print(' OpenMP Active:........{0}'.format(tests[key].openmp)) - print(' PETSc Active:.........{0}'.format(tests[key].petsc)) - print(' Valgrind Test:........{0}'.format(tests[key].valgrind)) - print(' Coverage Test:........{0}\n'.format(tests[key].coverage)) - exit() - -# Delete items of dictionary that don't match regular expression -if options.build_config is not None: - for key in tests: - if not re.search(options.build_config, key): - del tests[key] - -# Check for dashboard and determine whether to push results to server -# Note that there are only 3 basic dashboards: -# Experimental, Nightly, Continuous. On the CDash end, these can be -# reorganized into groups when a hostname, dashboard and build name -# are matched. -if options.dash is None: - dash = 'Experimental' - submit = '' -else: - dash = options.dash - submit = 'ctest_submit()' - -# Check for update command, which will run git fetch/merge and will delete -# any changes to repo that were not pushed to remote origin -if options.update: - update = 'ctest_update()' -else: - update = '' - -# Check for CTest scipts mode -# Sets up whether we should use just the basic ctest command or use -# CTest scripting to perform tests. -if not options.dash is None or options.script: - script_mode = True -else: - script_mode = False - -# Setup CTest script vars. Not used in non-script mode -pwd = os.environ['PWD'] -ctest_vars = { -'source_dir' : pwd + '/../src', -'build_dir' : pwd + '/build', -'host_name' : socket.gethostname(), -'dashboard' : dash, -'submit' : submit, -'update' : update, -'n_procs' : options.n_procs -} - -# Set up default valgrind tests (subset of all tests) -# Currently takes too long to run all the tests with valgrind -# Only used in script mode -valgrind_default_tests = "basic|cmfd_feed|confidence_intervals|\ -density_atombcm|eigenvalue_genperbatch|energy_grid|entropy|\ -filter_cell|lattice_multiple|output|plot_background|reflective_plane|\ -rotation|salphabeta_multiple|score_absorption|seed|source_energy_mono|\ -sourcepoint_batch|statepoint_interval|survival_biasing|\ -tally_assumesep|translation|uniform_fs|universe|void" - -# Begin testing -shutil.rmtree('build', ignore_errors=True) -call(['./cleanup']) # removes all binary and hdf5 output files from tests -for key in iter(tests): - test = tests[key] - - # No valgrind or coverage if not in CTest script mode - if not script_mode: - if test.valgrind: - continue - if test.coverage: - continue - - # Extra display if not in script mode - if not script_mode: - print('-'*(len(key) + 6)) - print(key + ' tests') - print('-'*(len(key) + 6)) - sys.stdout.flush() - - # Verify fortran compiler exists - test.check_compiler() - - # Set test specific CTest script vars. Not used in non-script mode - ctest_vars.update({'build_name' : test.get_build_name()}) - ctest_vars.update({'build_opts' : test.get_build_opts()}) - ctest_vars.update({'mem_check' : test.valgrind}) - ctest_vars.update({'coverage' : test.coverage}) - - # Check for user custom tests - # INCLUDE is a CTest command that allows for a subset - # of tests to be executed. Only used in script mode. - if options.regex_tests is None: - ctest_vars.update({'tests' : ''}) - - # No user tests, use default valgrind tests - if test.valgrind: - ctest_vars.update({'tests' : 'INCLUDE {0}'. - format(valgrind_default_tests)}) - else: - ctest_vars.update({'tests' : 'INCLUDE {0}'. - format(options.regex_tests)}) - - # Main part of code that does the ctest execution. - # It is broken up by two modes, script and non-script - if script_mode: - - # Create ctest script - test.create_ctest_script(ctest_vars) - - # Run test - test.run_ctest_script() - - else: - - # Run CMAKE to configure build - test.run_cmake() - - # Go into build directory - os.chdir('build') - - # Build OpenMC - test.run_make() - - # Run tests - test.run_ctests() - - # Leave build directory - os.chdir('..') - - # Copy over log file - if script_mode: - logfile = glob.glob('build/Testing/Temporary/LastTest_*.log') - else: - logfile = glob.glob('build/Testing/Temporary/LastTest.log') - if len(logfile) > 0: - logfilename = os.path.split(logfile[0])[1] - logfilename = os.path.splitext(logfilename)[0] - logfilename = logfilename + '_{0}.log'.format(test.name) - shutil.copy(logfile[0], logfilename) - - # Clear build directory and remove binary and hdf5 files - shutil.rmtree('build', ignore_errors=True) - if script_mode: - os.remove('ctestscript.run') - call(['./cleanup']) - -# Print out summary of results -print('\n' + '='*54) -print('Summary of Compilation Option Testing:\n') - -if sys.stdout.isatty(): - OK = '\033[92m' - FAIL = '\033[91m' - ENDC = '\033[0m' - BOLD = '\033[1m' -else: - OK = '' - FAIL = '' - ENDC = '' - BOLD = '' - -for test in tests: - print(test + '.'*(50 - len(test)), end='') - if tests[test].success: - print(BOLD + OK + '[OK]' + ENDC) - else: - print(BOLD + FAIL + '[FAILED]' + ENDC) - print(' '*len(test)+tests[test].msg) diff --git a/tests/run_tests.py b/tests/run_tests.py index ce67f3ab7a..4d2e0876b3 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -3,15 +3,18 @@ from __future__ import print_function import os +import sys import shutil import re -import sys +import glob +import socket from subprocess import call from collections import OrderedDict from optparse import OptionParser +# Command line parsing parser = OptionParser() -parser.add_option('-j', '--parallel', dest='n_procs', +parser.add_option('-j', '--parallel', dest='n_procs', default='1', help="Number of parallel jobs.") parser.add_option('-R', '--tests-regex', dest='regex_tests', help="Run tests matching regular expression. \ @@ -25,48 +28,92 @@ parser.add_option('-C', '--build-config', dest='build_config', parser.add_option('-p', '--print', action="store_true", dest="print_build_configs", default=False, help="Print out build configurations.") -(opts, args) = parser.parse_args() +parser.add_option("-b", "--branch", dest="branch", default="", + help="branch name for build") +parser.add_option("-D", "--dashboard", dest="dash", + help="Dash name -- Experimental, Nightly, Continuous") +parser.add_option("-u", "--update", action="store_true", dest="update", + help="Allow CTest to update repo. (WARNING: may overwrite\ + changes that were not pushed.") +parser.add_option("-s", "--script", action="store_true", dest="script", + help="Activate CTest scripting mode for coverage, valgrind\ + and dashboard capability.") +(options, args) = parser.parse_args() -# Default compiler paths +# Compiler paths FC='gfortran' -MPI_DIR='/opt/mpich/3.1-gnu' +MPI_DIR='/opt/mpich/3.0.4-gnu' HDF5_DIR='/opt/hdf5/1.8.12-gnu' PHDF5_DIR='/opt/phdf5/1.8.12-gnu' -PETSC_DIR='/opt/petsc/3.4.4-gnu' +PETSC_DIR='/opt/petsc/3.4.3-gnu' + +# Script mode for extra capability +script_mode = False # Override default compiler paths if environmental vars are found -if 'FC' in os.environ: +if os.environ.has_key('FC'): FC = os.environ['FC'] - if FC is not 'gfortran': - print('NOTE: Test suite only verifed for gfortran compiler.') -if 'MPI_DIR' in os.environ: +if os.environ.has_key('MPI_DIR'): MPI_DIR = os.environ['MPI_DIR'] -if 'HDF5_DIR' in os.environ: +if os.environ.has_key('HDF5_DIR'): HDF5_DIR = os.environ['HDF5_DIR'] -if 'PHDF5_DIR' in os.environ: +if os.environ.has_key('PHDF5_DIR'): PHDF5_DIR = os.environ['PHDF5_DIR'] -if 'PETSC_DIR' in os.environ: +if os.environ.has_key('PETSC_DIR'): PETSC_DIR = os.environ['PETSC_DIR'] +# CTest script template +ctest_str = """set (CTEST_SOURCE_DIRECTORY "{source_dir}") +set (CTEST_BINARY_DIRECTORY "{build_dir}") + +set(CTEST_SITE "{host_name}") +set (CTEST_BUILD_NAME "{build_name}") +set (CTEST_CMAKE_GENERATOR "Unix Makefiles") +set (CTEST_BUILD_OPTIONS "{build_opts}") + +set(CTEST_UPDATE_COMMAND "git") + +set(CTEST_CONFIGURE_COMMAND "${{CMAKE_COMMAND}} -H${{CTEST_SOURCE_DIRECTORY}} -B${{CTEST_BINARY_DIRECTORY}} ${{CTEST_BUILD_OPTIONS}}") +set(CTEST_MEMORYCHECK_COMMAND "/usr/bin/valgrind") +set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes") +set(MEM_CHECK {mem_check}) +set(ENV{{MEM_CHECK}} ${{MEM_CHECK}}) + +set(CTEST_COVERAGE_COMMAND "/usr/bin/gcov") +set(COVERAGE {coverage}) +set(ENV{{COVERAGE}} ${{COVERAGE}}) + +ctest_start("{dashboard}") +ctest_configure() +{update} +ctest_build() +ctest_test({tests} PARALLEL_LEVEL {n_procs}) +if(MEM_CHECK) +ctest_memcheck({tests}) +endif(MEM_CHECK) +if(COVERAGE) +ctest_coverage() +endif(COVERAGE) +{submit}""" + # Define test data structure tests = OrderedDict() class Test(object): - def __init__(self, debug=False, optimize=False, mpi=False, openmp=False, - hdf5=False, petsc=False): + def __init__(self, name, debug=False, optimize=False, mpi=False, openmp=False, + hdf5=False, petsc=False, valgrind=False, coverage=False): + self.name = name self.debug = debug self.optimize = optimize self.mpi = mpi self.openmp = openmp self.hdf5 = hdf5 self.petsc = petsc + self.valgrind = valgrind + self.coverage = coverage self.success = True self.msg = None - self.setup_cmake() - - def setup_cmake(self): - # Default cmake - self.cmake = ['cmake','-H../src','-Bbuild'] + self.cmake = ['cmake', '-H../src', '-Bbuild'] # Check for MPI/HDF5 if self.mpi and not self.hdf5: @@ -78,26 +125,56 @@ class Test(object): else: self.fc = FC - # Set rest of options + # Sets the build name that will show up on the CDash + def get_build_name(self): + self.build_name = options.branch + '_' + self.name + return self.build_name + + # Sets up build options for various tests. It is used both + # in script and non-script modes + def get_build_opts(self): + build_str = "" if self.debug: - self.cmake.append('-Ddebug=on') + build_str += "-Ddebug=ON " if self.optimize: - self.cmake.append('-Doptimize=on') + build_str += "-Doptimize=ON " if self.openmp: - self.cmake.append('-Dopenmp=on') + build_str += "-Dopenmp=ON " + if self.petsc: + build_str += "-Dpetsc=ON " + if self.coverage: + build_str += "-Dcoverage=ON " + self.build_opts = build_str + return self.build_opts + + # Write out the ctest script to tests directory + def create_ctest_script(self, ctest_vars): + with open('ctestscript.run', 'w') as fh: + fh.write(ctest_str.format(**ctest_vars)) + + # Runs the ctest script which performs all the cmake/ctest/cdash + def run_ctest_script(self): + os.environ['FC'] = self.fc if self.petsc: - self.cmake.append('-Dpetsc=on') os.environ['PETSC_DIR'] = PETSC_DIR if self.mpi: os.environ['MPI_DIR'] = MPI_DIR + rc = call(['ctest', '-S', 'ctestscript.run','-V']) + if rc != 0: + self.success = False + self.msg = 'Failed on ctest script.' + # Runs cmake when in non-script mode def run_cmake(self): os.environ['FC'] = self.fc + build_opts = self.build_opts.split() + self.cmake += build_opts rc = call(self.cmake) if rc != 0: self.success = False self.msg = 'Failed on cmake.' + # Runs make when in non-script mode def run_make(self): if not self.success: return @@ -106,9 +183,9 @@ class Test(object): make_list = ['make','-s'] # Check for parallel - if opts.n_procs is not None: + if options.n_procs is not None: make_list.append('-j') - make_list.append(opts.n_procs) + make_list.append(options.n_procs) # Run make rc = call(make_list) @@ -116,6 +193,7 @@ class Test(object): self.success = False self.msg = 'Failed on make.' + # Runs ctest when in non-script mode def run_ctests(self): if not self.success: return @@ -124,14 +202,14 @@ class Test(object): ctest_list = ['ctest'] # Check for parallel - if opts.n_procs is not None: + if options.n_procs is not None: ctest_list.append('-j') - ctest_list.append(opts.n_procs) + ctest_list.append(options.n_procs) # Check for subset of tests - if opts.regex_tests is not None: + if options.regex_tests is not None: ctest_list.append('-R') - ctest_list.append(opts.regex_tests) + ctest_list.append(options.regex_tests) # Run ctests rc = call(ctest_list) @@ -152,11 +230,14 @@ class Test(object): .format(self.fc)+ "Please set appropriate environmental variable(s).") +# Simple function to add a test to the global tests dictionary def add_test(name, debug=False, optimize=False, mpi=False, openmp=False,\ - hdf5=False, petsc=False): - tests.update({name:Test(debug, optimize, mpi, openmp, hdf5, petsc)}) + hdf5=False, petsc=False, valgrind=False, coverage=False): + tests.update({name:Test(name, debug, optimize, mpi, openmp, hdf5, petsc, + valgrind, coverage)}) -# List of tests +# List of all tests that may be run. User can add -C to command line to specify +# a subset of these configurations add_test('basic-normal') add_test('basic-debug', debug=True) add_test('basic-optimize', optimize=True) @@ -188,13 +269,18 @@ add_test('phdf5-petsc-normal', mpi=True, hdf5=True, petsc=True) add_test('phdf5-petsc-debug', mpi=True, hdf5=True, petsc=True, debug=True) add_test('phdf5-petsc-optimize', mpi=True, hdf5=True, petsc=True, optimize=True) add_test('omp-phdf5-petsc-normal', openmp=True, mpi=True, hdf5=True, petsc=True) -add_test('omp-phdf5-petsc-debug', openmp=True, mpi=True, hdf5=True, petsc=True, - debug=True) -add_test('omp-phdf5-petsc-optimize', openmp=True, mpi=True, hdf5=True, petsc=True, - optimize=True) +add_test('omp-phdf5-petsc-debug', openmp=True, mpi=True, hdf5=True, petsc=True, debug=True) +add_test('omp-phdf5-petsc-optimize', openmp=True, mpi=True, hdf5=True, petsc=True, optimize=True) +add_test('basic-debug_valgrind', debug=True, valgrind=True) +add_test('hdf5-debug_valgrind', hdf5=True, debug=True, valgrind=True) +add_test('petsc-debug_valgrind', petsc=True, mpi=True, debug=True, valgrind=True) +add_test('basic-debug_coverage', debug=True, coverage=True) +add_test('hdf5-debug_coverage', debug=True, hdf5=True, coverage=True) +add_test('mpi-debug_coverage', debug=True, mpi=True, coverage=True) +add_test('petsc-debug_coverage', debug=True, petsc=True, mpi=True, coverage=True) -# Check to see if we are to just print build configuratinos -if opts.print_build_configs: +# Check to see if we should just print build configuration information to user +if options.print_build_configs: for key in tests: print('Configuration Name: {0}'.format(key)) print(' Debug Flags:..........{0}'.format(tests[key].debug)) @@ -202,48 +288,152 @@ if opts.print_build_configs: print(' HDF5 Active:..........{0}'.format(tests[key].hdf5)) print(' MPI Active:...........{0}'.format(tests[key].mpi)) print(' OpenMP Active:........{0}'.format(tests[key].openmp)) - print(' PETSc Active:.........{0}\n'.format(tests[key].petsc)) + print(' PETSc Active:.........{0}'.format(tests[key].petsc)) + print(' Valgrind Test:........{0}'.format(tests[key].valgrind)) + print(' Coverage Test:........{0}\n'.format(tests[key].coverage)) exit() # Delete items of dictionary that don't match regular expression -if opts.build_config is not None: +if options.build_config is not None: for key in tests: - if not re.search(opts.build_config, key): + if not re.search(options.build_config, key): del tests[key] +# Check for dashboard and determine whether to push results to server +# Note that there are only 3 basic dashboards: +# Experimental, Nightly, Continuous. On the CDash end, these can be +# reorganized into groups when a hostname, dashboard and build name +# are matched. +if options.dash is None: + dash = 'Experimental' + submit = '' +else: + dash = options.dash + submit = 'ctest_submit()' + +# Check for update command, which will run git fetch/merge and will delete +# any changes to repo that were not pushed to remote origin +if options.update: + update = 'ctest_update()' +else: + update = '' + +# Check for CTest scipts mode +# Sets up whether we should use just the basic ctest command or use +# CTest scripting to perform tests. +if not options.dash is None or options.script: + script_mode = True +else: + script_mode = False + +# Setup CTest script vars. Not used in non-script mode +pwd = os.environ['PWD'] +ctest_vars = { +'source_dir' : pwd + '/../src', +'build_dir' : pwd + '/build', +'host_name' : socket.gethostname(), +'dashboard' : dash, +'submit' : submit, +'update' : update, +'n_procs' : options.n_procs +} + +# Set up default valgrind tests (subset of all tests) +# Currently takes too long to run all the tests with valgrind +# Only used in script mode +valgrind_default_tests = "basic|cmfd_feed|confidence_intervals|\ +density_atombcm|eigenvalue_genperbatch|energy_grid|entropy|\ +filter_cell|lattice_multiple|output|plot_background|reflective_plane|\ +rotation|salphabeta_multiple|score_absorption|seed|source_energy_mono|\ +sourcepoint_batch|statepoint_interval|survival_biasing|\ +tally_assumesep|translation|uniform_fs|universe|void" + # Begin testing shutil.rmtree('build', ignore_errors=True) -for test in tests: - print('-'*(len(test) + 6)) - print(test + ' tests') - print('-'*(len(test) + 6)) - sys.stdout.flush() +call(['./cleanup']) # removes all binary and hdf5 output files from tests +for key in iter(tests): + test = tests[key] + + # No valgrind or coverage if not in CTest script mode + if not script_mode: + if test.valgrind: + continue + if test.coverage: + continue + + # Extra display if not in script mode + if not script_mode: + print('-'*(len(key) + 6)) + print(key + ' tests') + print('-'*(len(key) + 6)) + sys.stdout.flush() # Verify fortran compiler exists - tests[test].check_compiler() + test.check_compiler() - # Run CMAKE to configure build - tests[test].run_cmake() + # Set test specific CTest script vars. Not used in non-script mode + ctest_vars.update({'build_name' : test.get_build_name()}) + ctest_vars.update({'build_opts' : test.get_build_opts()}) + ctest_vars.update({'mem_check' : test.valgrind}) + ctest_vars.update({'coverage' : test.coverage}) - # Go into build directory - os.chdir('build') + # Check for user custom tests + # INCLUDE is a CTest command that allows for a subset + # of tests to be executed. Only used in script mode. + if options.regex_tests is None: + ctest_vars.update({'tests' : ''}) - # Build OpenMC - tests[test].run_make() + # No user tests, use default valgrind tests + if test.valgrind: + ctest_vars.update({'tests' : 'INCLUDE {0}'. + format(valgrind_default_tests)}) + else: + ctest_vars.update({'tests' : 'INCLUDE {0}'. + format(options.regex_tests)}) - # Run tests - tests[test].run_ctests() + # Main part of code that does the ctest execution. + # It is broken up by two modes, script and non-script + if script_mode: - # Leave build directory - os.chdir('..') + # Create ctest script + test.create_ctest_script(ctest_vars) - # Copy test log file if failed - if tests[test].msg == 'Failed on testing.': - shutil.copy('build/Testing/Temporary/LastTest.log', - 'LastTest_{0}.log'.format(test)) + # Run test + test.run_ctest_script() - # Clean up build + else: + + # Run CMAKE to configure build + test.run_cmake() + + # Go into build directory + os.chdir('build') + + # Build OpenMC + test.run_make() + + # Run tests + test.run_ctests() + + # Leave build directory + os.chdir('..') + + # Copy over log file + if script_mode: + logfile = glob.glob('build/Testing/Temporary/LastTest_*.log') + else: + logfile = glob.glob('build/Testing/Temporary/LastTest.log') + if len(logfile) > 0: + logfilename = os.path.split(logfile[0])[1] + logfilename = os.path.splitext(logfilename)[0] + logfilename = logfilename + '_{0}.log'.format(test.name) + shutil.copy(logfile[0], logfilename) + + # Clear build directory and remove binary and hdf5 files shutil.rmtree('build', ignore_errors=True) + if script_mode: + os.remove('ctestscript.run') + call(['./cleanup']) # Print out summary of results print('\n' + '='*54) From 85f76c6a67f69ebe766a26a8febb2e49d8619ffc Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Tue, 29 Apr 2014 10:48:41 -0400 Subject: [PATCH 39/43] updated some python syntax --- tests/run_tests.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/run_tests.py b/tests/run_tests.py index 4d2e0876b3..8d7c517d2a 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -40,26 +40,26 @@ parser.add_option("-s", "--script", action="store_true", dest="script", and dashboard capability.") (options, args) = parser.parse_args() -# Compiler paths +# Default compiler paths FC='gfortran' -MPI_DIR='/opt/mpich/3.0.4-gnu' +MPI_DIR='/opt/mpich/3.1-gnu' HDF5_DIR='/opt/hdf5/1.8.12-gnu' PHDF5_DIR='/opt/phdf5/1.8.12-gnu' -PETSC_DIR='/opt/petsc/3.4.3-gnu' +PETSC_DIR='/opt/petsc/3.4.4-gnu' # Script mode for extra capability script_mode = False # Override default compiler paths if environmental vars are found -if os.environ.has_key('FC'): +if 'FC' in os.environ: FC = os.environ['FC'] -if os.environ.has_key('MPI_DIR'): +if 'MPI_DIR' in os.environ: MPI_DIR = os.environ['MPI_DIR'] -if os.environ.has_key('HDF5_DIR'): +if 'HDF5_DIR' in os.environ: HDF5_DIR = os.environ['HDF5_DIR'] -if os.environ.has_key('PHDF5_DIR'): +if 'PHDF5_DIR' in os.environ: PHDF5_DIR = os.environ['PHDF5_DIR'] -if os.environ.has_key('PETSC_DIR'): +if 'PETSC_DIR' in os.environ: PETSC_DIR = os.environ['PETSC_DIR'] # CTest script template From 4759892dcbcbc8fede7b88c954a5348673208557 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 1 May 2014 11:33:57 -0400 Subject: [PATCH 40/43] updated cdash drop site information --- src/CTestConfig.cmake | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/CTestConfig.cmake b/src/CTestConfig.cmake index 6ae35bae56..77b7cec250 100644 --- a/src/CTestConfig.cmake +++ b/src/CTestConfig.cmake @@ -4,12 +4,22 @@ ## # The following are required to uses Dart and the Cdash dashboard ## ENABLE_TESTING() ## INCLUDE(CTest) + +# Generic information about CDASH site set(CTEST_PROJECT_NAME "OpenMC") set(CTEST_NIGHTLY_START_TIME "03:00:00 UTC") - set(CTEST_DROP_METHOD "http") -set(CTEST_DROP_SITE "neutronbalance.mit.edu") -set(CTEST_DROP_LOCATION "/CDash/submit.php?project=OpenMC") +set(CTEST_DROP_SITE "54.83.201.173") +set(CTEST_DROP_LOCATION "/cdash/submit.php?project=OpenMC") set(CTEST_DROP_SITE_CDASH TRUE) -SET(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE "20000") -SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE "20000") + +# Set file size larger to see more output +set(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE "20000") +set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE "20000") + +# User/password to CDASH site +# Please contact Nick Horelik or +# Bryan Herman if you want to push +# test suite information to our CDASH site. +set(CTEST_DROP_SITE_USER "") +set(CTEST_DROP_SITE_PASSWORD "") From 336744a6c40c25c2492eb5321fc02a0aa6405233 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Thu, 1 May 2014 14:56:52 -0400 Subject: [PATCH 41/43] added subproject capability --- tests/run_tests.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/tests/run_tests.py b/tests/run_tests.py index 8d7c517d2a..20161978b0 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -25,11 +25,11 @@ parser.add_option('-C', '--build-config', dest='build_config', Specific build configurations can be printed out with \ optional argument -p, --print. This uses standard \ regex syntax to select build configurations.") -parser.add_option('-p', '--print', action="store_true", - dest="print_build_configs", default=False, - help="Print out build configurations.") -parser.add_option("-b", "--branch", dest="branch", default="", - help="branch name for build") +parser.add_option('-l', '--list', action="store_true", + dest="list_build_configs", default=False, + help="List out build configurations.") +parser.add_option("-p", "--project", dest="project", default="", + help="project name for build") parser.add_option("-D", "--dashboard", dest="dash", help="Dash name -- Experimental, Nightly, Continuous") parser.add_option("-u", "--update", action="store_true", dest="update", @@ -83,6 +83,8 @@ set(CTEST_COVERAGE_COMMAND "/usr/bin/gcov") set(COVERAGE {coverage}) set(ENV{{COVERAGE}} ${{COVERAGE}}) +{subproject} + ctest_start("{dashboard}") ctest_configure() {update} @@ -127,7 +129,7 @@ class Test(object): # Sets the build name that will show up on the CDash def get_build_name(self): - self.build_name = options.branch + '_' + self.name + self.build_name = options.project + '_' + self.name return self.build_name # Sets up build options for various tests. It is used both @@ -280,7 +282,7 @@ add_test('mpi-debug_coverage', debug=True, mpi=True, coverage=True) add_test('petsc-debug_coverage', debug=True, petsc=True, mpi=True, coverage=True) # Check to see if we should just print build configuration information to user -if options.print_build_configs: +if options.list_build_configs: for key in tests: print('Configuration Name: {0}'.format(key)) print(' Debug Flags:..........{0}'.format(tests[key].debug)) @@ -338,6 +340,15 @@ ctest_vars = { 'n_procs' : options.n_procs } +# Check project name +subprop = """set_property(GLOBAL PROPERTY SubProject {0})""" +if options.project == "" : + ctest_vars.update({'subproject':''}) +elif options.project == 'develop': + ctest_vars.update({'subproject':''}) +else: + ctest_vars.update({'subproject':subprop.format(options.project)}) + # Set up default valgrind tests (subset of all tests) # Currently takes too long to run all the tests with valgrind # Only used in script mode From c9a21b29141869fc14c99b5a739bf32aacdd4a87 Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Mon, 5 May 2014 17:43:02 -0400 Subject: [PATCH 42/43] check compiler doesnt kill script --- tests/run_tests.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/run_tests.py b/tests/run_tests.py index 20161978b0..84587e5721 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -227,10 +227,11 @@ class Test(object): for path in os.environ["PATH"].split(":"): if os.path.isfile(os.path.join(path, self.fc)): result = True - if not result: - raise Exception("Compiler path '{0}' does not exist." - .format(self.fc)+ - "Please set appropriate environmental variable(s).") + if not result: + self.msg = 'Compiler not found: {0}'.\ + format((os.path.join(path, self.fc))) + self.success = False + return self.success # Simple function to add a test to the global tests dictionary def add_test(name, debug=False, optimize=False, mpi=False, openmp=False,\ @@ -380,7 +381,8 @@ for key in iter(tests): sys.stdout.flush() # Verify fortran compiler exists - test.check_compiler() + if not test.check_compiler(): + continue # Set test specific CTest script vars. Not used in non-script mode ctest_vars.update({'build_name' : test.get_build_name()}) From 39ad55a2449124ac6feb942eb32959ae26fc2f3b Mon Sep 17 00:00:00 2001 From: Bryan Herman Date: Mon, 5 May 2014 18:09:12 -0400 Subject: [PATCH 43/43] exit script if no tests to run, check script mode for valgrind and coverage before test loop --- tests/run_tests.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/tests/run_tests.py b/tests/run_tests.py index 84587e5721..f534c79333 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -115,6 +115,7 @@ class Test(object): self.coverage = coverage self.success = True self.msg = None + self.skipped = False self.cmake = ['cmake', '-H../src', '-Bbuild'] # Check for MPI/HDF5 @@ -231,7 +232,6 @@ class Test(object): self.msg = 'Compiler not found: {0}'.\ format((os.path.join(path, self.fc))) self.success = False - return self.success # Simple function to add a test to the global tests dictionary def add_test(name, debug=False, optimize=False, mpi=False, openmp=False,\ @@ -360,19 +360,23 @@ rotation|salphabeta_multiple|score_absorption|seed|source_energy_mono|\ sourcepoint_batch|statepoint_interval|survival_biasing|\ tally_assumesep|translation|uniform_fs|universe|void" +# Delete items of dictionary if valgrind or coverage and not in script mode +if not script_mode: + for key in tests: + if re.search('valgrind|coverage', key): + del tests[key] + +# Check if tests empty +if len(tests.keys()) == 0: + print('No tests to run.') + exit() + # Begin testing shutil.rmtree('build', ignore_errors=True) call(['./cleanup']) # removes all binary and hdf5 output files from tests for key in iter(tests): test = tests[key] - # No valgrind or coverage if not in CTest script mode - if not script_mode: - if test.valgrind: - continue - if test.coverage: - continue - # Extra display if not in script mode if not script_mode: print('-'*(len(key) + 6)) @@ -381,7 +385,8 @@ for key in iter(tests): sys.stdout.flush() # Verify fortran compiler exists - if not test.check_compiler(): + test.check_compiler() + if not test.success: continue # Set test specific CTest script vars. Not used in non-script mode