dimembermatt / Mbed-Shared-Components

Driver API for STM32 Nucleo devices
MIT License
0 stars 3 forks source link

Add support for tests on components that import mbed.h #5

Open dimembermatt opened 4 years ago

dimembermatt commented 4 years ago

Dependency on #4. Currently, if you try to build something like test_Sensor.cpp, with the following command:

g++ -Wall -Wextra -o ${BUILD_ROOT}${FILE} -I ${SRC_ROOT} ${file} ${SRC_ROOT}${DIR}/*.cpp

You'll get an error like this for classes that use mbed.h:

Generating test for ./Sensor/test_Sensor.cpp.
In file included from ../src/./Sensor/Sensor.cpp:13:0:
../src/./Sensor/Sensor.h:15:10: fatal error: mbed.h: No such file or directory
 #include "mbed.h"
          ^~~~~~~~
compilation terminated.
Didn't find an executable.
./Sensor/test_Sensor.cpp test Generated.

Potentially experimenting with the flag -I {MBED_ROOT}. May have to build MBED while we're at it.

dimembermatt commented 4 years ago

While this will allow us to compile files, it won't allow us to run them (probably) since they need to be flashed onto a uC and tested there.

Further consideration is required for going down this route. Does it make sense to add to the script to flash to a connected uC if available and somehow test with that? That might depend on using printf debugging and mbed sterm.

Even before this though, we'll have to figure out how to get mbed to compile specifically the test cases in TESTS/ and put them in the TESTS/BUILD/ folder.