Skip to content

Commit

Permalink
Dev chris (#2)
Browse files Browse the repository at this point in the history
* Tweak some tests
* added planners that inherit the FSM to update the encoders and take actions based on the state.
* replace gtest with Catch2 because GTEST makes it hard to see stack traces of exceptions thrown at low layers
* Simplify Axis, Start building planner test for ZOnly

* Create cmake-multi-platform.yml
  • Loading branch information
digiexchris authored Feb 27, 2024
1 parent a10b9bd commit e3dbf0a
Show file tree
Hide file tree
Showing 70 changed files with 1,044 additions and 525 deletions.
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"derivitec-ltd.cmake-test-adapter",
"tenninebt.vscode-koverage",
"rherrmannr.code-coverage-lcov",
"SbastienLevy.covertops-cmake-llvm"
"SbastienLevy.covertops-cmake-llvm",
"piotrkosek.vscode-gtest-test-adapter-with-code-lens"
]
}
},
Expand Down
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
root = true

[*]
end_of_line = lf
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
* text=auto eol=lf
73 changes: 73 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CMake on multiple platforms

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
include:
# - os: windows-latest
# c_compiler: cl
# cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang

steps:
- uses: actions/checkout@v3

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ out/
build/
builddir/
.cache/
coverage/
coverage/html
coverage/*.prof*
coverage/*.lcov
Testing/
coverage/lcov.info
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ project ("ELSF")
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)

add_library(${PROJECT_NAME} ${SOURCES})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
# This allows users which use the add_subdirectory or FetchContent
# to use the same target as users which use find_package
add_library(elsf::elsf ALIAS ${PROJECT_NAME})
Expand All @@ -39,7 +39,7 @@ if(BUILD_ESLF_TESTS)
endif()

target_include_directories(${PROJECT_NAME} ${INCLUDE_SPECIFIER} INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

Expand Down
64 changes: 2 additions & 62 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,64 +1,6 @@
{
"version": 3,
"configurePresets": [
{
"name": "windows-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"cacheVariables": {
"CMAKE_C_COMPILER": "C:/Program Files/LLVM/bin/clang.exe",
"CMAKE_CXX_COMPILER": "C:/Program Files/LLVM/bin/clang++.exe",
"CMAKE_CXX_FLAGS": "-O0 -g -fsanitize=address -fno-omit-frame-pointer -static",
"CMAKE_LINKER_FLAGS": "-fno-omit-frame-pointer -fsanitize=address -static"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "x64-debug",
"displayName": "x64 Debug",
"inherits": "windows-base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "x64-debug-test",
"displayName": "x64 Debug Tests Enabled",
"architecture": {
"value": "x64",
"strategy": "external"
},
"inherits": "x64-debug",
"cacheVariables": {
"BUILD_ESLF_TESTS": "ON"
}
},
{
"name": "x64-release",
"displayName": "x64 Release",
"inherits": "x64-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "x64-release-test",
"displayName": "x64 Release TGest",
"inherits": "x64-debug-test",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "clang-base",
"hidden": true,
Expand Down Expand Up @@ -100,18 +42,16 @@
"cacheVariables": {
"BUILD_ESLF_TESTS": "ON",
"CMAKE_CXX_FLAGS": "-O0 -g",
"ENABLE_COVERAGE": "ON",
"EXPOSE_COVERAGE_TARGET": "ON"
//"CMAKE_VERBOSE_MAKEFILE": "ON"
}
},
{
"name": "clang-debug-test-ASAN",
"displayName": "Clang 14.0.0 x86_64-pc-linux-gnu Debug Tests Enabled ASAN Enabled",
"inherits": "clang-debug-test",
"cacheVariables": {
"CMAKE_CXX_FLAGS": "-O0 -g -fsanitize=address -fno-omit-frame-pointer",
"CMAKE_LINKER_FLAGS": "-fno-omit-frame-pointer -fsanitize=address"
"CMAKE_CXX_FLAGS": "-O0 -g -fsanitize=address -fno-omit-frame-pointer -fcxx-exceptions",
"CMAKE_LINKER_FLAGS": "-fno-omit-frame-pointer -fsanitize=address -fcxx-exceptions"
}
}
],
Expand Down
38 changes: 30 additions & 8 deletions ELSF.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@
"runTestCoverage": "npm run test"
},

"cmake.ctestArgs": [
"--output-on-failure",
"--gtest_break_on_failure",
"--gtest_stack_trace_depth=10",
"--gmock_verbose=info"
],
// "cmake.ctestArgs": [
// "--output-on-failure"
// ],
"cmake.allowCommentsInPresetsFile": true,
"cmake.allowUnsupportedPresetsVersions": true,
"C_Cpp.default.compileCommands": "c:\\Users\\chris\\Documents\\repos\\els\\LeadscrewWarrantyVoider\\lib\\ESLF\\build/compile_commands.json",
Expand All @@ -64,6 +61,31 @@
"cmakeExplorer.buildConfig": "ELSFTest",
"covertops-cmake-llvm.additionalCmakeOptions": [
"-DENABLE_COVERAGE=ON"
],
"testMate.cpp.discovery.loadOnStartup": false,
"testMate.cpp.test.parallelExecutionLimit": 4,
"testMate.cpp.test.parallelExecutionOfExecutableLimit": 4,
"testMate.cpp.test.advancedExecutables":
[
{
"pattern": "{build,Build,BUILD,out,Out,OUT}/**/*{test,Test,TEST}*",
"catch2": {
"testGrouping": {
"groupByExecutable": {
"label": "${filename}",
"description": "${relDirpath}/",

"groupBySource": {
"label": "${sourceRelPath[1:]}",
"groupUngroupedTo": "unknown source file"
}

}

}
}

}
]
},
"tasks":
Expand Down Expand Up @@ -99,15 +121,15 @@
"request": "launch",
"name": "Launch LLDB",
"program": "${workspaceFolder}/build/test/elsf_tests",
"args": ["${cmake.testArgs}", "--output-on-failure", "--gtest_break_on_failure", "--gtest_stack_trace_depth=10", "--gmock_verbose=info"],
"args": ["${cmake.testArgs}", ],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Launch -no-break-on-failure",
"program": "${workspaceFolder}/build/test/elsf_tests",
"args": ["${cmake.testArgs}", "--output-on-failure", "--gtest_stack_trace_depth=20", "--gmock_verbose=warn"],
"args": ["${cmake.testArgs}", "--output-on-failure"],
"cwd": "${workspaceFolder}"
}
],
Expand Down
1 change: 0 additions & 1 deletion Testing/Temporary/CTestCostData.txt

This file was deleted.

3 changes: 0 additions & 3 deletions Testing/Temporary/LastTest.log

This file was deleted.

6 changes: 3 additions & 3 deletions coverage.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/bash
IGNORELIST='.*include/State/MessageBus/(Router\.hpp|Subscription\.hpp)'
IGNORELIST='.*include/Machine/MessageBus/(Router\.hpp|Subscription\.hpp)'
echo "Clearing lconv" &&
rm coverage/*
rm -R coverage/lcov.info coverage/elsf_tests.profdata coverage/elsf_tests.profraw coverage/html
echo "Running tests" &&
LLVM_PROFILE_FILE="coverage/elsf_tests.profraw" ./build/test/elsf_tests &&
LLVM_PROFILE_FILE="coverage/elsf_tests.profraw" ./build/test/elsf_tests --order rand --warn NoAssertions &&
echo "Merging coverage" &&
llvm-profdata merge coverage/elsf_tests.profraw -o coverage/elsf_tests.profdata &&

Expand Down
62 changes: 62 additions & 0 deletions coverage/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
if(${EXPOSE_COVERAGE_TARGET})
# specific flags to build the covered project. Enable source based Coverage
# see:
# https://releases.llvm.org/11.0.0/tools/clang/docs/SourceBasedCodeCoverage.html
# target_compile_options(elsf::elsf PRIVATE
# -fprofile-instr-generate -fcoverage-mapping)
# target_link_options(elsf::elsf PRIVATE
# -fprofile-instr-generate -fcoverage-mapping)

# Useful variables used later, specific to llvm tools path and output
# directory
get_filename_component(llvmBinPath ${CMAKE_CXX_COMPILER} DIRECTORY)
set(llvmProfData ${llvmBinPath}/llvm-profdata)
set(llvmCov ${llvmBinPath}/llvm-cov)

# An internal custom command used as dependency of exposed targets to
# generate coverage data
add_custom_command(OUTPUT default.profdata
DEPENDS .elsf_testsuites.executed
COMMAND ${llvmProfData}
ARGS merge
-sparse
$<TARGET_NAME_IF_EXISTS:elsf_tests>.profraw
-o default.profdata)

# An internal command used as dependency for exposed targets. Ensures that
# test suites have been executed with latest modifications and latest
# coverage data.
add_custom_command(OUTPUT .elsf_testsuites.executed
DEPENDS
elsf::elsf elsf_tests
COMMAND ${CMAKE_COMMAND}
ARGS -E copy $<TARGET_FILE:elsf::elsf> $<TARGET_FILE_DIR:elsf_tests>
COMMAND $<TARGET_FILE:elsf_tests>
COMMAND ${CMAKE_COMMAND}
ARGS -E rename default.profraw $<TARGET_NAME_IF_EXISTS:elsf_tests>.profraw
COMMAND ${CMAKE_COMMAND}
ARGS -E touch .elsf_testsuites.executed
VERBATIM
USES_TERMINAL)

# A target to generate detailed coverage information in json format. To get
# a grab on ow it is structured, see:
# https://stackoverflow.com/questions/56013927/how-to-read-llvm-cov-json-format
# https://llvm.org/doxygen/structllvm_1_1coverage_1_1CoverageSegment.html
# https://llvm.org/doxygen/structllvm_1_1coverage_1_1CounterMappingRegion.html
# https://github.com/llvm/llvm-project/blob/aa4e6a609acdd00e06b54f525054bd5cf3624f0f/llvm/tools/llvm-cov/CoverageExporterJson.cpp#L15
add_custom_target(coverage
DEPENDS coverage.json)

# An internal command used to generate detailed coverage information in a
# file
add_custom_command(OUTPUT coverage.json
DEPENDS default.profdata
COMMAND ${llvmCov}
ARGS export --format=text
--object=$<TARGET_FILE:elsf_tests>
--instr-profile=default.profdata
> coverage.json
VERBATIM
USES_TERMINAL)
endif()
20 changes: 0 additions & 20 deletions include/Device/Axis.hpp

This file was deleted.

Loading

0 comments on commit e3dbf0a

Please sign in to comment.