Skip to content

Commit

Permalink
Added testing framework
Browse files Browse the repository at this point in the history
  • Loading branch information
ashtuchkin committed Feb 27, 2017
1 parent bd8a36a commit 106e6e0
Show file tree
Hide file tree
Showing 19 changed files with 11,316 additions and 36 deletions.
32 changes: 32 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Based on http:https://stackoverflow.com/a/41916657, https://github.com/Microsoft/GSL/blob/master/.travis.yml
branches:
only:
- master

dist: trusty
sudo: required
language: cpp
compiler: gcc
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-6
- g++-6
- gcc-6-multilib
- g++-6-multilib
- gcc-multilib
- cmake

install:
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 50
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 50
- gcc --version && g++ --version && cmake --version

before_script:
- mkdir build && cd build
- cmake -DTEST_MODE=TRUE .. && cmake --build .

script:
- ctest --output-on-failure
67 changes: 51 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,35 +1,70 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.2)

set(CMAKE_TOOLCHAIN_FILE "teensy-arm.toolchain.cmake")
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
#set(CMAKE_VERBOSE_MAKEFILE TRUE)

project(vive-diy-position-sensor)
set(CMAKE_CXX_STANDARD 14)

set(SOURCE_FILES
src/main.cpp
src/settings.cpp

src/cycle_phase_classifier.cpp
src/data_frame_decoder.cpp
src/debug_node.cpp
src/formatters.cpp
src/geometry.cpp
src/input.cpp
src/mavlink.cpp
src/pulse_processor.cpp
src/primitives/string_utils.cpp
)

set(PLATFORM_SPECIFIC_SOURCE_FILES
src/main.cpp
src/settings.cpp
src/debug_node.cpp
src/input_cmp.cpp
src/led_state.cpp
src/mavlink.cpp
src/outputs.cpp
src/platform.cpp
src/pulse_processor.cpp
src/vive_sensors_pipeline.cpp

src/primitives/timestamp.cpp
src/primitives/string_utils.cpp
)

add_executable(vive-diy-position-sensor "${SOURCE_FILES}")
add_firmware_targets(vive-diy-position-sensor)
set(TEST_SOURCE_FILES
test/main_test.cpp
test/platform_mocks.cpp
test/test_pulse_processor.cpp
)

if (NOT TEST_MODE)
set(CMAKE_TOOLCHAIN_FILE "teensy-arm.toolchain.cmake")

project(vive-diy-position-sensor)

add_executable(vive-diy-position-sensor "${SOURCE_FILES}" "${PLATFORM_SPECIFIC_SOURCE_FILES}")
add_firmware_targets(vive-diy-position-sensor)

import_cmsis_dsp_library(vive-diy-position-sensor)
import_arduino_library(vive-diy-position-sensor mavlink_v2)

else()
project(vive-diy-position-sensor)
include(CTest)

# Compile 32 bit code
add_compile_options("-m32")
link_libraries("-m32")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options("-Wno-deprecated-register" "-Wno-unknown-attributes")
endif()

# Compile CMSIS as a library.
set(CMSIS_ROOT "${CMAKE_SOURCE_DIR}/libs/CMSIS/CMSIS" CACHE PATH "Path to the CMSIS root directory")
file(GLOB_RECURSE CMSIS_CORE_FILES "${CMSIS_ROOT}/DSP_Lib/Source/*_f32.c")
add_library(CMSIS "${CMSIS_CORE_FILES}" "${CMSIS_ROOT}/DSP_Lib/Source/CommonTables/arm_common_tables.c")
target_compile_definitions(CMSIS PUBLIC "-DARM_MATH_CM4")
link_libraries(CMSIS)

import_cmsis_dsp_library(vive-diy-position-sensor)
import_arduino_library(vive-diy-position-sensor mavlink_v2)
# We have only one test executable
add_definitions("-DNEW_H") # Don't include new.h header as it defines non-standard operator new().
include_directories("libs/Catch" "libs/CMSIS/CMSIS/Include" "libs/cores/teensy3" "libs/mavlink_v2" "src")
add_executable(main-test "${TEST_SOURCE_FILES}" "${SOURCE_FILES}")
add_test(main-test main-test)
endif()
3 changes: 0 additions & 3 deletions build/.gitignore

This file was deleted.

26 changes: 26 additions & 0 deletions cmake-variants.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"buildType": {
"default$": "debug",
"description$": "the build type to use",
"debug": {
"oneWordSummary$": "Debug",
"description$": "Enable optimizations, include debug info",
"buildType": "Debug"
},
"release": {
"oneWordSummary$": "Release",
"description$": "Enable optimizations, omit debug info",
"buildType": "Release"
},
"test": {
"oneWordSummary$": "Test",
"description$": "Test the project",
"buildType": "Debug",
"settings": {
"TEST_MODE": "TRUE",
"CMAKE_C_COMPILER": "/usr/local/bin/gcc-6",
"CMAKE_CXX_COMPILER": "/usr/local/bin/g++-6"
}
}
}
}
Loading

0 comments on commit 106e6e0

Please sign in to comment.