proj: switching to Linux
This commit is contained in:
@@ -11,11 +11,11 @@
|
||||
|
||||
#include "Processor.hpp"
|
||||
#include "PwmExpanderPca9685.hpp"
|
||||
#include "StepperDrv8833.hpp"
|
||||
#include "Task.hpp"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "stepperDrv.hpp"
|
||||
#include "stepperMotor.hpp"
|
||||
#include "watchFace.hpp"
|
||||
#include <array>
|
||||
@@ -181,6 +181,10 @@ constexpr bool DoFullTurns = false;
|
||||
constexpr bool DoTurnSteps = false;
|
||||
constexpr bool DoTurnProfiles = true;
|
||||
|
||||
void AllmostDone(uint8_t newIdx) {
|
||||
ESP_LOGW(TAG, "Done callback");
|
||||
}
|
||||
|
||||
void testMovementTask() {
|
||||
esp_log_level_set(TAG, ESP_LOG_DEBUG);
|
||||
esp_log_level_set("STP", ESP_LOG_DEBUG);
|
||||
@@ -207,7 +211,7 @@ void testMovementTask() {
|
||||
OutputPort motorSleep(GPIO_NUM_15, GpioPort::Logic::Inverted);
|
||||
StepperMotor stepper(stepperCfg, stepperDriver, initSens);
|
||||
|
||||
WatchMotor watch(stepper, motorSleep);
|
||||
WatchMotor watch(stepper, motorSleep, AllmostDone);
|
||||
|
||||
///
|
||||
/// Full Turns with full steps
|
||||
@@ -273,14 +277,14 @@ void testMovementTask() {
|
||||
ESP_LOGI(TAG, "Move to each index multiple times");
|
||||
illum.flashAll(BLUE);
|
||||
for (size_t i = 1; i <= 2 * 3; i++) {
|
||||
watch.moveTo(3 * i);
|
||||
watch.moveTo(3 * i, 0, 0, 1, 1);
|
||||
ESP_LOGD(TAG, "Position is %3d / %.2f", stepper.getQuanted(), stepper.getScaledPos() * 6);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Move to each index multiple times");
|
||||
illum.flashAll(BLUE);
|
||||
for (size_t i = 1; i <= 6 * 3; i++) {
|
||||
watch.moveTo(i);
|
||||
watch.moveTo(i, 0, 0, 1, 1);
|
||||
ESP_LOGD(TAG, "Position is %3d / %.2f", stepper.getQuanted(), stepper.getScaledPos() * 6);
|
||||
}
|
||||
}
|
||||
@@ -290,14 +294,28 @@ void testMovementTask() {
|
||||
///
|
||||
if constexpr (DoTurnProfiles) {
|
||||
for (size_t i = ProfileGenerator::Smooth; i < ProfileGenerator::NumProfiles; i++) {
|
||||
// for (size_t i = ProfileGenerator::JumpIn; i < ProfileGenerator::NumProfiles; i++) { // If only part is needed
|
||||
// for (size_t i = ProfileGenerator::JumpIn; i < ProfileGenerator::NumProfiles; i++) { // If only part is needed
|
||||
ESP_LOGI(TAG, "Running Profile %d ", i);
|
||||
ESP_LOGD(TAG, "Fist Position is %3d / %.2f / Micro %d", stepper.getQuanted(), stepper.getScaledPos() * 6, stepper.getSubPos());
|
||||
fos::Task::delayMs(1000);
|
||||
illum.flashAll(BLUE);
|
||||
int steps[3]{4, 2, 0};
|
||||
for (size_t j = 0; j < 3; j++) {
|
||||
watch.moveTo(steps[j], i);
|
||||
watch.moveTo(steps[j], i, 0, 1, 1);
|
||||
ESP_LOGI(TAG, "Last position is %3d / %.2f", stepper.getQuanted(), stepper.getScaledPos() * 6);
|
||||
fos::Task::delayMs(1000);
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = ProfileGenerator::Smooth; i < ProfileGenerator::NumProfiles; i++) {
|
||||
// for (size_t i = ProfileGenerator::JumpIn; i < ProfileGenerator::NumProfiles; i++) { // If only part is needed
|
||||
ESP_LOGI(TAG, "Running Profile %d ", i);
|
||||
ESP_LOGD(TAG, "Fist Position is %3d / %.2f / Micro %d", stepper.getQuanted(), stepper.getScaledPos() * 6, stepper.getSubPos());
|
||||
fos::Task::delayMs(1000);
|
||||
illum.flashAll(BLUE);
|
||||
int steps[3]{4, 2, 0};
|
||||
for (size_t j = 0; j < 3; j++) {
|
||||
watch.moveTo(steps[j], i, 0, 3, 3);
|
||||
ESP_LOGI(TAG, "Last position is %3d / %.2f", stepper.getQuanted(), stepper.getScaledPos() * 6);
|
||||
fos::Task::delayMs(1000);
|
||||
}
|
||||
|
||||
@@ -1,26 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include(../../core/test/unitOnHost/test_core.cmake)
|
||||
|
||||
set(DEF_UTESTDIR "uTest")
|
||||
set(DEF_SRCDIR "src")
|
||||
set(DEF_INCLUDEDIR "include")
|
||||
|
||||
# use just host compilers for this one
|
||||
set(CMAKE_C_COMPILER "gcc")
|
||||
set(CMAKE_CXX_COMPILER "g++")
|
||||
set(CMAKE_GENERATOR "Ninja")
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
|
||||
set(CMAKE_VERBOSE_MAKEFILE TRUE)
|
||||
|
||||
include(test_core.cmake)
|
||||
UnitTestSetup()
|
||||
enable_testing()
|
||||
|
||||
project(UnitTests)
|
||||
|
||||
find_package(doctest REQUIRED PATHS "/mingw64/lib/cmake")
|
||||
# target_link_libraries(${PROJECT_NAME} PRIVATE doctest::doctest)
|
||||
|
||||
addSubDirs_ofRoot("${CMAKE_CURRENT_LIST_DIR}/../../components")
|
||||
|
||||
|
||||
|
||||
addSubDirs_ofRoot("${CMAKE_CURRENT_LIST_DIR}/../../core/components")
|
||||
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/../../core/test/unitOnHost/hwMock" hwMock)
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
# Unit Testing - Software
|
||||
|
||||
In contrast to *test*-directory this module demonstrates how unit tests can also be run on host.
|
||||
These unit tests aim to test freestanding software modules with more convenient methods and tools
|
||||
|
||||
## Setup
|
||||
|
||||
make sure you have following packages installed on your host syste
|
||||
- gnu compiler
|
||||
- cmake
|
||||
- generator
|
||||
- doctest-dev
|
||||
|
||||
## Build and test code
|
||||
|
||||
* Start some terminal in *uTest*-directory that has access to all needed tools (i.e. on windows a mingw environment or WSL)
|
||||
|
||||
Run following commands
|
||||
```sh
|
||||
# run cmake configuration
|
||||
cmake -S . -B build
|
||||
# run cmake build
|
||||
cmake --build build
|
||||
# run tests
|
||||
./build/<testprog>
|
||||
# run all tests with
|
||||
cd build && ctest
|
||||
```
|
||||
@@ -1,43 +0,0 @@
|
||||
function(addSubDirs_ofRoot anchorPath)
|
||||
message("scanning: ${anchorPath}")
|
||||
file(GLOB targetModules RELATIVE "${anchorPath}" "${anchorPath}/*")
|
||||
foreach(module ${targetModules})
|
||||
message("checking: ${module}")
|
||||
get_filename_component(moduleName ${module} NAME)
|
||||
set(modulePath "${anchorPath}/${moduleName}")
|
||||
if (NOT IS_DIRECTORY "${modulePath}")
|
||||
# skip files
|
||||
continue()
|
||||
endif()
|
||||
if (${moduleName} MATCHES "^_.*")
|
||||
# skip ignored component
|
||||
continue()
|
||||
endif()
|
||||
|
||||
if(EXISTS "${modulePath}/${DEF_UTESTDIR}")
|
||||
message("Found unit-test: ${moduleName}")
|
||||
add_subdirectory("${modulePath}/${DEF_UTESTDIR}" ${moduleName})
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
macro(unitTestsFrame)
|
||||
if (CMAKE_TESTING_ENABLED)
|
||||
# get_filename_component(moduleName "${CMAKE_CURRENT_LIST_DIR}/.." NAME)
|
||||
file(GLOB_RECURSE targetSources "../${DEF_SRCDIR}/*.cpp" "../${DEF_SRCDIR}/*.c")
|
||||
add_library(${moduleName} ${targetSources})
|
||||
target_include_directories(${moduleName} PUBLIC "../${DEF_INCLUDEDIR}")
|
||||
|
||||
set(moduleTestName "${moduleName}Test")
|
||||
file(GLOB_RECURSE testSource "*.cpp")
|
||||
add_executable(${moduleTestName} ${testSource})
|
||||
target_link_libraries(${moduleTestName} PRIVATE ${moduleName} doctest::doctest)
|
||||
target_include_directories(${moduleTestName} PRIVATE "../${DEF_SRCDIR}")
|
||||
|
||||
add_test (TEST-${moduleName} ${moduleTestName})
|
||||
|
||||
# gtest_discover_tests(${moduleTestName}
|
||||
# PROPERTIES TIMEOUT 30 LABELS ${moduleName} LABELS "all"
|
||||
# )
|
||||
endif()
|
||||
endmacro()
|
||||
Reference in New Issue
Block a user