Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
KiT-RT
KiT-RT
Commits
5d12f0cb
Commit
5d12f0cb
authored
Mar 24, 2020
by
Jannick Wolters
Browse files
added Catch2 as unit testing framework
parent
64c39c71
Changes
11
Hide whitespace changes
Inline
Side-by-side
.gitmodules
View file @
5d12f0cb
...
...
@@ -7,3 +7,6 @@
[submodule "code/ext/spdlog"]
path = code/ext/spdlog
url = git://github.com/gabime/spdlog.git
[submodule "code/ext/Catch2"]
path = code/ext/Catch2
url = git://github.com/catchorg/Catch2.git
LICEN
C
E.md
→
LICEN
S
E.md
View file @
5d12f0cb
File moved
README.md
View file @
5d12f0cb
...
...
@@ -6,8 +6,10 @@ TBD
### Examples
TBD
---
## Build
###
System
dependencies
###
Required
dependencies
-
Compiler with C++17 support (GCC >= v6, clang >= v3.8)
-
cmake >= v3.5
-
LAPACK
...
...
@@ -25,7 +27,7 @@ git submodule init
git submodule update
```
### Compile
### Compile
the code
**Make**
build system (available on most systems)
```
bash
...
...
@@ -45,7 +47,9 @@ ninja
The resulting executable will automatically be placed in the
`code/bin`
folder.
---
## Run
### Local
Execute the compiled binary and hand over a valid
*TOML*
-styled config file.
...
...
@@ -66,11 +70,29 @@ with `N` equal to the number of shared memory threads and `J` equal to the numbe
### BwUniCluster
TBD
---
## Tests
In order to also compile the unit tests, add
`-DBUILD_TESTING=True`
to the cmake command, e.g.:
```
bash
cmake
-DCMAKE_BUILD_TYPE
=
Release
-DBUILD_TESTING
=
True ../../
```
The resulting
`unit_tests`
executable will also be placed in
`/bin`
.
## Continuous Integration (CI)
TBD
---
## Code structure

<br/><br/>
The diagram can be modified by opening
`doc/uml.zargo`
with
`ArgoUML`
.
---
## Coding style
Please stick to the following coding style for easier code readability:
...
...
code/.gitlab-ci.yml
0 → 100644
View file @
5d12f0cb
image
:
ubuntu:18.04
stages
:
-
build
-
test
build
:
stage
:
build
script
:
-
apt-get update
-
apt-get install -y g++ cmake libopenmpi-dev libblas-dev liblapack-dev git ninja-build
-
git submodule update --init --recursive
-
cd code/build/debug
-
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=True -DCMAKE_EXPORT_COMPILE_COMMANDS=True ../../
-
ninja
test
:
stage
:
test
script
:
-
bin/unit_tests
code/CMakeLists.txt
View file @
5d12f0cb
cmake_minimum_required
(
VERSION 3.5
)
project
(
RTSN
)
project
(
RTSN
LANGUAGES CXX VERSION 0.0.1
)
set
(
CMAKE_CXX_STANDARD 17
)
set
(
CMAKE_CXX_FLAGS_RELEASE
"
${
CMAKE_CXX_FLAGS_RELEASE
}
-O3 -march=native"
)
set
(
CMAKE_CXX_FLAGS_RELWITHDEBINFO
"
${
CMAKE_CXX_FLAGS_RELWITHDEBINFO
}
-O3 -march=native -pg -no-pie"
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
-O0 -Wall -Werror"
)
set
(
CMAKE_RUNTIME_OUTPUT_DIRECTORY
"
${
CMAKE_SOURCE_DIR
}
/bin
/
"
)
set
(
CMAKE_RUNTIME_OUTPUT_DIRECTORY
"
${
CMAKE_SOURCE_DIR
}
/bin"
)
file
(
GLOB_RECURSE SRCS RELATIVE
${
CMAKE_SOURCE_DIR
}
"src/*.cpp"
)
file
(
GLOB_RECURSE SRCS RELATIVE
${
CMAKE_SOURCE_DIR
}
"src/*.cpp"
)
include_directories
(
${
CMAKE_SOURCE_DIR
}
/include
)
add_executable
(
${
CMAKE_PROJECT_NAME
}
${
SRCS
}
)
find_package
(
OpenMP REQUIRED
)
...
...
@@ -23,12 +24,26 @@ include_directories( ${MPI_INCLUDE_PATH} )
find_package
(
LAPACK REQUIRED
)
include_directories
(
${
LAPACK_INCLUDE_DIR
}
)
include_directories
(
${
CMAKE_SOURCE_DIR
}
/../ext/cpptoml/include
)
include_directories
(
${
CMAKE_SOURCE_DIR
}
/../ext/spdlog/include
)
execute_process
(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY
${
CMAKE_SOURCE_DIR
}
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_definitions
(
'-DGIT_HASH=
"
${
GIT_HASH
}
"
'
)
add_definitions
(
'-DGIT_HASH=
"
${
GIT_HASH
}
"
'
)
set
(
CORE_LIBRARIES
${
LAPACK_LIBRARIES
}
${
MPI_LIBRARIES
}
-lstdc++fs
)
target_link_libraries
(
${
CMAKE_PROJECT_NAME
}
${
LAPACK_LIBRARIES
}
${
VTK_LIBRARIES
}
${
MPI_LIBRARIES
}
-lstdc++fs
)
target_link_libraries
(
${
CMAKE_PROJECT_NAME
}
${
CORE_LIBRARIES
}
)
if
(
BUILD_TESTING
)
add_subdirectory
(
${
CMAKE_SOURCE_DIR
}
/ext/Catch2
)
include_directories
(
${
CMAKE_SOURCE_DIR
}
/ext/Catch2/single_include/catch2
)
file
(
GLOB_RECURSE TEST_SRCS RELATIVE
${
CMAKE_SOURCE_DIR
}
"tests/*.cpp"
)
list
(
REMOVE_ITEM SRCS
"src/main.cpp"
)
add_executable
(
unit_tests
${
SRCS
}
${
TEST_SRCS
}
)
target_link_libraries
(
unit_tests
${
CORE_LIBRARIES
}
)
endif
()
Catch2
@
255aa5f2
Subproject commit 255aa5f2afe1a622c97422f65ace6ca915be0d8d
code/include/.gitkeep
0 → 100755
View file @
5d12f0cb
code/include/factorial_example.h
0 → 100644
View file @
5d12f0cb
unsigned
int
Factorial
(
unsigned
int
number
);
code/src/factorial_example.cpp
0 → 100644
View file @
5d12f0cb
#include "factorial_example.h"
unsigned
int
Factorial
(
unsigned
int
number
)
{
return
number
>
1
?
Factorial
(
number
-
1
)
*
number
:
1
;
}
code/tests/factorial_example_test.cpp
0 → 100644
View file @
5d12f0cb
#include "catch.hpp"
#include "factorial_example.h"
TEST_CASE
(
"Factorials are computed"
,
"[factorial]"
)
{
REQUIRE
(
Factorial
(
0
)
==
1
);
REQUIRE
(
Factorial
(
1
)
==
1
);
REQUIRE
(
Factorial
(
2
)
==
2
);
REQUIRE
(
Factorial
(
3
)
==
6
);
REQUIRE
(
Factorial
(
10
)
==
3628800
);
}
code/tests/tests_main.cpp
0 → 100644
View file @
5d12f0cb
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment