看到 cleanfight 下面有 test/unit, 估计是做单元测试用的
一个make (Ubuntu下面) 都编译了,再到 cleanflight/obj/test 生成了很多可执行文件
原来 cleanflight的单元测试不是是stm32上跑了,而是在pc上跑,主要测试函数的功能
找个源元件,原来是用gtest写的,下面就在 cleanflight目录下做 gtest的试验
1)编写一个文件叫 1.c
======= 1.c ============
#include "gtest/gtest.h"
TEST (SquareRootTest, PositiveNos) {
EXPECT_EQ (18.0, 18.0);
}
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
g++ -isystem ./lib/test/gtest/inc 1.c ./obj/test/gtest-all.o -o 1 -lpthread
3)运行得到结果
$ ./1
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from SquareRootTest
[ RUN ] SquareRootTest.PositiveNos
[ OK ] Squar