Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Troy Houchin authored and Troy Houchin committed Jun 7, 2018
1 parent 34d3543 commit 0a5b485
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 2 deletions.
Binary file added .DS_Store
Binary file not shown.
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: cpp
os: linux
before_install:
- test -n $CC && unset CC
- test -n $CXX && unset CXX
install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install cmake3 mpich2 liblapack-dev libboost-filesystem-dev libboost-system-dev python-numpy clang-3.9 ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo pip install pyamg ; fi
before_script:
- mkdir build
- cd build
- cmake -DENABLE_UNIT_TESTS=yes -DCMAKE_CXX_COMPILER=clang++-3.9 ..
script: make && make test
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

include(cxx11)
include(cxx_config)
include(testing)

enable_language(C CXX Fortran)

find_package(MPI REQUIRED)
find_package(PETSc REQUIRED)

include_directories(${MPI_INCLUDE_PATH} ${PETSC_INCLUDES} src)
Expand Down
80 changes: 80 additions & 0 deletions cmake/testing.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
if (ENABLE_UNIT_TESTS)
enable_testing()
find_package(GTest QUIET)
if (GTEST_FOUND)
include_directories(${GTEST_INCLUDE_DIRS})
else()
# Download and unpack googletest at configure time
configure_file(cmake/testing.in googletest-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download )
if(result)
message(FATAL_ERROR "Build step for googletest failed: ${result}")
endif()

# Prevent overriding the parent project's compiler/linker
# settings on Windows
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)

# Add googletest directly to our build. This defines
# the gtest and gtest_main targets.
add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
${CMAKE_BINARY_DIR}/googletest-build
EXCLUDE_FROM_ALL)

# The gtest/gtest_main targets carry header search path
# dependencies automatically when using CMake 2.8.11 or
# later. Otherwise we have to add them here ourselves.
if (CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories("${gtest_SOURCE_DIR}/include")
endif()

set(GTEST_BOTH_LIBRARIES gtest gtest_main)
endif()
endif()


function(add_par_unit target sources)
set(src ${ARGV})
list(REMOVE_AT src 0)
add_executable(${target} ${src})
target_link_libraries(${target} ${GTEST_BOTH_LIBRARIES} ${stella-deps} stella)
set_target_properties(${target}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test)
endfunction(add_par_unit)


function(set_par_sizes target sizes)
set(comm_sizes ${ARGV})
list(REMOVE_AT comm_sizes 0)
foreach(commsize ${comm_sizes})
set(test_parameters -np ${commsize} "${CMAKE_BINARY_DIR}/test/${target}")
add_test(NAME ${target}-${commsize} COMMAND "mpiexec" ${test_parameters} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endforeach()
endfunction()


function(add_unit target sources)
set(src ${ARGV})
list(REMOVE_AT src 0)
add_executable(${target} ${src})
target_link_libraries(${target} ${GTEST_BOTH_LIBRARIES} ${stella-deps} stella)
set_target_properties(${target}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test)
if(ENABLE_JENKINS_OUTPUT)
add_test(${target} ${CMAKE_BINARY_DIR}/test/${target}
--gtest_output=xml:${CMAKE_BINARY_DIR}/test/${target}.xml
--gtest_color=yes)
else()
add_test(NAME ${target} COMMAND ${CMAKE_BINARY_DIR}/test/${target} WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endif()
endfunction(add_unit)
15 changes: 15 additions & 0 deletions cmake/testing.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 2.8.2)

project(googletest-download NONE)

include(ExternalProject)
ExternalProject_Add(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG master
SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src"
BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
2 changes: 1 addition & 1 deletion src/stella_grid.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,6 @@ PetscErrorCode stella_grid_setup(stella_grid *grid, DM *dm, MPI_Comm *comm, int
} else {
SETERRQ1(PETSC_COMM_WORLD, PETSC_ERR_SUP, "Unsupported dimmension: %d", nd);
}

DMSetUp(*dm);
return 0;
}
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
add_par_unit(test-models-2d ${CMAKE_CURRENT_SOURCE_DIR}/test_models.cc ${CMAKE_CURRENT_SOURCE_DIR}/../mpi_main.cc)
target_link_libraries(test-models-2d stella)
set_par_sizes(test-models-2d 1 3 4 8)

add_par_unit(test-models_3-3d ${CMAKE_CURRENT_SOURCE_DIR}/test_models_3.cc ${CMAKE_CURRENT_SOURCE_DIR}/../mpi_main.cc)
target_link_libraries(test-models_3-3d stella)
set_par_sizes(test-models_3-3d 4)

0 comments on commit 0a5b485

Please sign in to comment.