forked from Archive/PX4-Autopilot
move mixer_test and conversion_test to gtest
This commit is contained in:
parent
e672fdbbd6
commit
3efb1be48e
|
@ -11,16 +11,35 @@ include_directories(${CMAKE_SOURCE_DIR}/../src/modules)
|
|||
include_directories(${CMAKE_SOURCE_DIR}/../src/lib)
|
||||
|
||||
add_definitions(-D__EXPORT=)
|
||||
set(CMAKE_C_FLAGS "-std=c99")
|
||||
set(CMAKE_CXX_FLAGS "-std=c++11 -Wno-write-strings")
|
||||
|
||||
function(add_gtest)
|
||||
foreach(test_name ${ARGN})
|
||||
target_link_libraries(${test_name} gtest_main)
|
||||
add_test(${test_name}Test ${test_name})
|
||||
add_test(${test_name} ${test_name})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
|
||||
# add each test
|
||||
# todo: add mixer_test sbus2_test st24_test sf0x_test
|
||||
# todo: add sbus2_test st24_test sf0x_test
|
||||
add_executable(autodeclination_test autodeclination_test.cpp ${CMAKE_SOURCE_DIR}/../src/lib/geo_lookup/geo_mag_declination.c)
|
||||
add_gtest(autodeclination_test)
|
||||
|
||||
|
||||
# mixer_test
|
||||
add_executable(mixer_test mixer_test.cpp hrt.cpp
|
||||
${CMAKE_SOURCE_DIR}/../src/modules/systemlib/mixer/mixer.cpp
|
||||
${CMAKE_SOURCE_DIR}/../src/modules/systemlib/mixer/mixer_group.cpp
|
||||
${CMAKE_SOURCE_DIR}/../src/modules/systemlib/mixer/mixer_load.c
|
||||
${CMAKE_SOURCE_DIR}/../src/modules/systemlib/mixer/mixer_multirotor.cpp
|
||||
${CMAKE_SOURCE_DIR}/../src/modules/systemlib/mixer/mixer_simple.cpp
|
||||
${CMAKE_SOURCE_DIR}/../src/modules/systemlib/pwm_limit/pwm_limit.c
|
||||
${CMAKE_SOURCE_DIR}/../src/systemcmds/tests/test_mixer.cpp)
|
||||
add_gtest(mixer_test)
|
||||
|
||||
# conversion_test
|
||||
add_executable(conversion_test conversion_test.cpp
|
||||
${CMAKE_SOURCE_DIR}/../src/systemcmds/tests/test_conv.cpp)
|
||||
add_gtest(conversion_test)
|
||||
|
|
|
@ -40,18 +40,7 @@ gtest_main.a: gtest-all.o gtest_main.o
|
|||
$(AR) $(ARFLAGS) $@ $^
|
||||
|
||||
|
||||
all: mixer_test sbus2_test st24_test sf0x_test
|
||||
|
||||
MIXER_FILES=../src/systemcmds/tests/test_mixer.cpp \
|
||||
../src/systemcmds/tests/test_conv.cpp \
|
||||
../src/modules/systemlib/mixer/mixer_simple.cpp \
|
||||
../src/modules/systemlib/mixer/mixer_multirotor.cpp \
|
||||
../src/modules/systemlib/mixer/mixer.cpp \
|
||||
../src/modules/systemlib/mixer/mixer_group.cpp \
|
||||
../src/modules/systemlib/mixer/mixer_load.c \
|
||||
../src/modules/systemlib/pwm_limit/pwm_limit.c \
|
||||
hrt.cpp \
|
||||
mixer_test.cpp
|
||||
all: sbus2_test st24_test sf0x_test
|
||||
|
||||
SBUS2_FILES=../src/modules/px4iofirmware/sbus.c \
|
||||
hrt.cpp \
|
||||
|
@ -66,9 +55,6 @@ SF0X_FILES= \
|
|||
sf0x_test.cpp \
|
||||
../src/drivers/sf0x/sf0x_parser.cpp
|
||||
|
||||
mixer_test: $(MIXER_FILES)
|
||||
$(CC) -o mixer_test $(MIXER_FILES) $(CFLAGS)
|
||||
|
||||
sbus2_test: $(SBUS2_FILES)
|
||||
$(CC) -o sbus2_test $(SBUS2_FILES) $(CFLAGS)
|
||||
|
||||
|
@ -82,12 +68,11 @@ cmake_gtests:
|
|||
mkdir -p build
|
||||
cd build && CC=gcc cmake .. && $(MAKE) && $(MAKE) test
|
||||
|
||||
unittests: clean mixer_test sbus2_test sf0x_test st24_test cmake_gtests
|
||||
./mixer_test
|
||||
unittests: clean sbus2_test sf0x_test st24_test cmake_gtests
|
||||
./sbus2_test
|
||||
./sf0x_test
|
||||
./st24_test
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf gtest.a gtest_main.a *.o $(ODIR)/*.o *~ core $(INCDIR)/*~ sample_unittest mixer_test sbus2_test st24_test sf0x_test build
|
||||
rm -rf gtest.a gtest_main.a *.o $(ODIR)/*.o *~ core $(INCDIR)/*~ sample_unittest sbus2_test st24_test sf0x_test build
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#include <systemlib/mixer/mixer.h>
|
||||
#include <systemlib/err.h>
|
||||
#include "../../src/systemcmds/tests/tests.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(ConversionTest, FMU_quad_w) {
|
||||
ASSERT_EQ(test_conv(0, NULL), 0) << "Conversion test failed";
|
||||
}
|
|
@ -2,18 +2,15 @@
|
|||
#include <systemlib/err.h>
|
||||
#include "../../src/systemcmds/tests/tests.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
int ret;
|
||||
|
||||
warnx("Host execution started");
|
||||
|
||||
char* args[] = {argv[0], "../ROMFS/px4fmu_common/mixers/IO_pass.mix",
|
||||
"../ROMFS/px4fmu_common/mixers/FMU_quad_w.mix"};
|
||||
|
||||
if (ret = test_mixer(3, args));
|
||||
|
||||
test_conv(1, args);
|
||||
|
||||
return 0;
|
||||
TEST(MixerTest, IO_pass) {
|
||||
char* args[] = {"mixer", "../../ROMFS/px4fmu_common/mixers/IO_pass.mix"};
|
||||
ASSERT_EQ(test_mixer(2, args), 0) << "IO_pass.mix failed";
|
||||
}
|
||||
|
||||
TEST(MixerTest, FMU_quad_w) {
|
||||
char* args[] = {"mixer", "../../ROMFS/px4fmu_common/mixers/FMU_quad_w.mix"};
|
||||
ASSERT_EQ(test_mixer(2, args), 0) << "FMU_quad_w.mix failed";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue