forked from Archive/PX4-Autopilot
fix param_test
This commit is contained in:
parent
008354f935
commit
d85e7732b4
|
@ -90,12 +90,11 @@
|
|||
extern struct param_info_s param_array[];
|
||||
extern struct param_info_s *param_info_base;
|
||||
extern struct param_info_s *param_info_limit;
|
||||
#define param_info_count (param_info_limit - param_info_base)
|
||||
#else
|
||||
// FIXME - start and end are reversed
|
||||
static const struct param_info_s *param_info_base = (const struct param_info_s *) &px4_parameters;
|
||||
#endif
|
||||
|
||||
#define param_info_count px4_parameters.param_count
|
||||
#endif /* _UNIT_TEST */
|
||||
|
||||
/**
|
||||
* Storage for modified parameters.
|
||||
|
|
|
@ -86,11 +86,11 @@
|
|||
extern struct param_info_s param_array[];
|
||||
extern struct param_info_s *param_info_base;
|
||||
extern struct param_info_s *param_info_limit;
|
||||
#define param_info_count (param_info_limit - param_info_base)
|
||||
#else
|
||||
static struct param_info_s *param_info_base = (struct param_info_s *) &px4_parameters;
|
||||
#endif
|
||||
|
||||
#define param_info_count px4_parameters.param_count
|
||||
#endif /* _UNIT_TEST */
|
||||
|
||||
/**
|
||||
* Storage for modified parameters.
|
||||
|
|
|
@ -1,195 +1,179 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
include( CMakeForceCompiler )
|
||||
#set( CMAKE_SYSTEM_NAME px4_posix_clang )
|
||||
CMAKE_FORCE_C_COMPILER( clang Clang )
|
||||
CMAKE_FORCE_CXX_COMPILER( clang++ Clang )
|
||||
#set( CMAKE_C_COMPILER /opt/clang-3.4.2/bin/clang )
|
||||
#set( CMAKE_CXX_COMPILER /opt/clang-3.4.2/bin/clang++ )
|
||||
#set( CMAKE_FIND_ROOT_PATH /opt/clang-3.4.2/ )
|
||||
#set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM_NEVER )
|
||||
#set( CMAKE_FIND_ROOT_PATH_MODE_LIBARARY_ONLY )
|
||||
#set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE_ONLY )
|
||||
include(CMakeForceCompiler)
|
||||
CMAKE_FORCE_C_COMPILER(clang Clang)
|
||||
CMAKE_FORCE_CXX_COMPILER(clang++ Clang)
|
||||
|
||||
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
|
||||
add_compile_options(-Qunused-arguments)
|
||||
add_compile_options(-Qunused-arguments )
|
||||
endif()
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
add_compile_options(-Qunused-arguments)
|
||||
add_compile_options(-Qunused-arguments)
|
||||
endif()
|
||||
|
||||
project(unittests)
|
||||
enable_testing()
|
||||
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
||||
|
||||
if(COMPILER_SUPPORTS_CXX11)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-exceptions -fno-rtti -fno-threadsafe-statics -D__CUSTOM_FILE_IO__ -D__PX4_UNIT_TESTS -g -Wall -Werror")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-exceptions -fno-rtti -fno-threadsafe-statics -D__CUSTOM_FILE_IO__ -D__PX4_UNIT_TESTS -g -Wall -Werror")
|
||||
elseif(COMPILER_SUPPORTS_CXX0X)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -fno-exceptions -fno-rtti -fno-threadsafe-statics -D__CUSTOM_FILE_IO__ -D__PX4_UNIT_TESTS -g -Wall -Werror")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -fno-exceptions -fno-rtti -fno-threadsafe-statics -D__CUSTOM_FILE_IO__ -D__PX4_UNIT_TESTS -g -Wall -Werror")
|
||||
else()
|
||||
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
|
||||
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
|
||||
endif()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -g")
|
||||
|
||||
#set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem" )
|
||||
#set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem" )
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g3 -fsanitize=address -fno-omit-frame-pointer")
|
||||
|
||||
set(GTEST_DIR googletest)
|
||||
set(GTEST_DIR ${CMAKE_SOURCE_DIR}/googletest)
|
||||
add_subdirectory(${GTEST_DIR})
|
||||
include_directories(${GTEST_DIR}/include)
|
||||
|
||||
set(PX_SRC ${CMAKE_SOURCE_DIR}/../src)
|
||||
include_directories(${CMAKE_SOURCE_DIR})
|
||||
include_directories(${PX_SRC})
|
||||
include_directories(${PX_SRC}/modules)
|
||||
include_directories(${PX_SRC}/modules/uORB)
|
||||
include_directories(${PX_SRC}/lib)
|
||||
include_directories(${PX_SRC}/drivers)
|
||||
include_directories(${PX_SRC}/lib/DriverFramework/framework/include)
|
||||
include_directories(${PX_SRC}/../build_posix_sitl_default/src/modules)
|
||||
include_directories(${PX_SRC}/../build_posix_sitl_default/src/modules/uORB)
|
||||
include_directories(${PX_SRC}/../build_posix_sitl_default/src)
|
||||
include_directories(${PX_SRC}/../build_posix_sitl_default/src/modules/param)
|
||||
include_directories(${PX_SRC}/platforms)
|
||||
include_directories(${PX_SRC}/platforms/posix/include)
|
||||
include_directories(${PX_SRC}/platforms/posix/px4_layer)
|
||||
include_directories(${PX_SRC}/drivers/device)
|
||||
set(PX4_SRC ${CMAKE_SOURCE_DIR}/../src)
|
||||
set(PX4_SITL_BUILD ${PX4_SRC}/../build_posix_sitl_test)
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR})
|
||||
include_directories(${PX4_SITL_BUILD}/src)
|
||||
include_directories(${PX4_SITL_BUILD}/src/modules)
|
||||
include_directories(${PX4_SITL_BUILD}/src/modules/param)
|
||||
include_directories(${PX4_SITL_BUILD}/src/modules/uORB)
|
||||
include_directories(${PX4_SRC})
|
||||
include_directories(${PX4_SRC}/drivers)
|
||||
include_directories(${PX4_SRC}/drivers/device)
|
||||
include_directories(${PX4_SRC}/lib)
|
||||
include_directories(${PX4_SRC}/lib/DriverFramework/framework/include)
|
||||
include_directories(${PX4_SRC}/modules)
|
||||
include_directories(${PX4_SRC}/modules/uORB)
|
||||
include_directories(${PX4_SRC}/platforms)
|
||||
include_directories(${PX4_SRC}/platforms/posix/include)
|
||||
include_directories(${PX4_SRC}/platforms/posix/px4_layer)
|
||||
|
||||
add_definitions(-D__EXPORT=)
|
||||
add_definitions(-D__PX4_TESTS)
|
||||
add_definitions(-Dnoreturn_function=)
|
||||
add_definitions(-Dmain_t=int)
|
||||
add_definitions(-DERROR=-1)
|
||||
add_definitions(-DOK=0)
|
||||
add_definitions(-D_UNIT_TEST=)
|
||||
add_definitions(-D__PX4_POSIX)
|
||||
add_definitions(-D__PX4_TESTS)
|
||||
add_definitions(-D_UNIT_TEST=)
|
||||
add_definitions(-DERROR=-1)
|
||||
add_definitions(-Dmain_t=int)
|
||||
add_definitions(-Dnoreturn_function=)
|
||||
add_definitions(-DOK=0)
|
||||
|
||||
# check
|
||||
add_custom_target(unittests COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure)
|
||||
add_custom_target(check
|
||||
COMMAND ${CMAKE_CTEST_COMMAND} -j2 --output-on-failure
|
||||
WORKING_DIR ${CMAKE_BINARY_DIR}
|
||||
USES_TERMINAL)
|
||||
|
||||
function(add_gtest)
|
||||
foreach(test_name ${ARGN})
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
target_link_libraries(${test_name} gtest_main pthread )
|
||||
add_definitions(-D__PX4_DARWIN)
|
||||
else()
|
||||
target_link_libraries(${test_name} gtest_main pthread rt )
|
||||
add_definitions(-D__PX4_LINUX)
|
||||
endif()
|
||||
add_test(NAME ${test_name} COMMAND ${test_name} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
add_dependencies(unittests ${test_name})
|
||||
endforeach()
|
||||
foreach(test_name ${ARGN})
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
target_link_libraries(${test_name} gtest_main pthread px4_platform)
|
||||
add_definitions(-D__PX4_DARWIN)
|
||||
else()
|
||||
target_link_libraries(${test_name} gtest_main pthread rt px4_platform)
|
||||
add_definitions(-D__PX4_LINUX)
|
||||
endif()
|
||||
add_test(NAME ${test_name} COMMAND ${test_name} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||
add_dependencies(check ${test_name})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
add_library( px4_platform
|
||||
# ${PX_SRC}/platforms/common/px4_getopt.c
|
||||
${PX_SRC}/platforms/posix/px4_layer/px4_log.c
|
||||
${PX_SRC}/platforms/posix/px4_layer/px4_posix_impl.cpp
|
||||
${PX_SRC}/platforms/posix/px4_layer/px4_posix_tasks.cpp
|
||||
${PX_SRC}/platforms/posix/work_queue/work_lock.c
|
||||
${PX_SRC}/platforms/posix/work_queue/hrt_queue.c
|
||||
${PX_SRC}/platforms/posix/work_queue/work_queue.c
|
||||
${PX_SRC}/platforms/posix/work_queue/queue.c
|
||||
${PX_SRC}/platforms/posix/work_queue/work_cancel.c
|
||||
${PX_SRC}/platforms/posix/work_queue/hrt_work_cancel.c
|
||||
${PX_SRC}/platforms/posix/work_queue/hrt_thread.c
|
||||
${PX_SRC}/platforms/posix/work_queue/work_thread.c
|
||||
${PX_SRC}/platforms/posix/work_queue/dq_rem.c
|
||||
${PX_SRC}/platforms/posix/work_queue/sq_addlast.c
|
||||
${PX_SRC}/platforms/posix/work_queue/sq_addafter.c
|
||||
${PX_SRC}/platforms/posix/work_queue/dq_remfirst.c
|
||||
${PX_SRC}/platforms/posix/work_queue/sq_remfirst.c
|
||||
${PX_SRC}/platforms/posix/work_queue/dq_addlast.c
|
||||
${PX_SRC}/platforms/posix/px4_layer/lib_crc32.c
|
||||
${PX_SRC}/platforms/posix/px4_layer/drv_hrt.c
|
||||
${PX_SRC}/platforms/posix/px4_layer/px4_sem.cpp
|
||||
${PX_SRC}/drivers/device/device_posix.cpp
|
||||
${PX_SRC}/drivers/device/vdev.cpp
|
||||
${PX_SRC}/drivers/device/vfile.cpp
|
||||
${PX_SRC}/drivers/device/vdev_posix.cpp
|
||||
${PX_SRC}/drivers/device/i2c_posix.cpp
|
||||
${PX_SRC}/drivers/device/sim.cpp
|
||||
${PX_SRC}/drivers/device/ringbuffer.cpp
|
||||
${PX_SRC}/../build_posix_sitl_default/src/modules/param/px4_parameters.c
|
||||
)
|
||||
|
||||
#target_include_directories( px4_platform PUBLIC ${PX_SRC}/platforms )
|
||||
|
||||
|
||||
add_library(px4_platform
|
||||
${PX4_SITL_BUILD}/src/modules/param/px4_parameters.c
|
||||
${PX4_SRC}/drivers/device/device_posix.cpp
|
||||
${PX4_SRC}/drivers/device/i2c_posix.cpp
|
||||
${PX4_SRC}/drivers/device/ringbuffer.cpp
|
||||
${PX4_SRC}/drivers/device/sim.cpp
|
||||
${PX4_SRC}/drivers/device/vdev.cpp
|
||||
${PX4_SRC}/drivers/device/vdev_posix.cpp
|
||||
${PX4_SRC}/drivers/device/vfile.cpp
|
||||
${PX4_SRC}/platforms/posix/px4_layer/drv_hrt.c
|
||||
${PX4_SRC}/platforms/posix/px4_layer/lib_crc32.c
|
||||
${PX4_SRC}/platforms/posix/px4_layer/px4_log.c
|
||||
${PX4_SRC}/platforms/posix/px4_layer/px4_log.c
|
||||
${PX4_SRC}/platforms/posix/px4_layer/px4_posix_impl.cpp
|
||||
${PX4_SRC}/platforms/posix/px4_layer/px4_posix_tasks.cpp
|
||||
${PX4_SRC}/platforms/posix/px4_layer/px4_sem.cpp
|
||||
${PX4_SRC}/platforms/posix/px4_layer/shmem_posix.c
|
||||
${PX4_SRC}/platforms/posix/work_queue/dq_addlast.c
|
||||
${PX4_SRC}/platforms/posix/work_queue/dq_rem.c
|
||||
${PX4_SRC}/platforms/posix/work_queue/dq_remfirst.c
|
||||
${PX4_SRC}/platforms/posix/work_queue/hrt_queue.c
|
||||
${PX4_SRC}/platforms/posix/work_queue/hrt_thread.c
|
||||
${PX4_SRC}/platforms/posix/work_queue/hrt_work_cancel.c
|
||||
${PX4_SRC}/platforms/posix/work_queue/queue.c
|
||||
${PX4_SRC}/platforms/posix/work_queue/sq_addafter.c
|
||||
${PX4_SRC}/platforms/posix/work_queue/sq_addlast.c
|
||||
${PX4_SRC}/platforms/posix/work_queue/sq_remfirst.c
|
||||
${PX4_SRC}/platforms/posix/work_queue/work_cancel.c
|
||||
${PX4_SRC}/platforms/posix/work_queue/work_lock.c
|
||||
${PX4_SRC}/platforms/posix/work_queue/work_queue.c
|
||||
${PX4_SRC}/platforms/posix/work_queue/work_thread.c
|
||||
)
|
||||
target_include_directories(px4_platform PUBLIC ${PX4_SRC}/platforms)
|
||||
|
||||
# add each test
|
||||
add_executable(autodeclination_test autodeclination_test.cpp ${PX_SRC}/lib/geo_lookup/geo_mag_declination.c)
|
||||
|
||||
#######################################################################
|
||||
# TESTS
|
||||
#######################################################################
|
||||
# add_executable(example_test example_test.cpp)
|
||||
# add_gtest(example_test)
|
||||
|
||||
|
||||
# autodeclination_test
|
||||
add_executable(autodeclination_test autodeclination_test.cpp ${PX4_SRC}/lib/geo_lookup/geo_mag_declination.c)
|
||||
add_gtest(autodeclination_test)
|
||||
|
||||
# mixer_test
|
||||
add_custom_command(OUTPUT ${PX_SRC}/modules/systemlib/mixer/mixer_multirotor.generated.h
|
||||
COMMAND ${PX_SRC}/modules/systemlib/mixer/multi_tables.py > ${PX_SRC}/modules/systemlib/mixer/mixer_multirotor.generated.h)
|
||||
add_custom_command(OUTPUT ${PX4_SRC}/modules/systemlib/mixer/mixer_multirotor.generated.h
|
||||
COMMAND ${PX4_SRC}/modules/systemlib/mixer/multi_tables.py > ${PX4_SRC}/modules/systemlib/mixer/mixer_multirotor.generated.h)
|
||||
add_executable(mixer_test mixer_test.cpp hrt.cpp
|
||||
${PX_SRC}/modules/systemlib/mixer/mixer.cpp
|
||||
${PX_SRC}/modules/systemlib/mixer/mixer_group.cpp
|
||||
${PX_SRC}/modules/systemlib/mixer/mixer_load.c
|
||||
${PX_SRC}/modules/systemlib/mixer/mixer_multirotor.cpp
|
||||
${PX_SRC}/modules/systemlib/mixer/mixer_multirotor.generated.h
|
||||
${PX_SRC}/modules/systemlib/mixer/mixer_simple.cpp
|
||||
${PX_SRC}/modules/systemlib/pwm_limit/pwm_limit.c
|
||||
${PX_SRC}/systemcmds/tests/test_mixer.cpp)
|
||||
target_link_libraries( mixer_test px4_platform )
|
||||
|
||||
|
||||
${PX4_SRC}/modules/systemlib/mixer/mixer.cpp
|
||||
${PX4_SRC}/modules/systemlib/mixer/mixer_group.cpp
|
||||
${PX4_SRC}/modules/systemlib/mixer/mixer_load.c
|
||||
${PX4_SRC}/modules/systemlib/mixer/mixer_multirotor.cpp
|
||||
${PX4_SRC}/modules/systemlib/mixer/mixer_multirotor.generated.h
|
||||
${PX4_SRC}/modules/systemlib/mixer/mixer_simple.cpp
|
||||
${PX4_SRC}/modules/systemlib/pwm_limit/pwm_limit.c
|
||||
${PX4_SRC}/systemcmds/tests/test_mixer.cpp)
|
||||
add_gtest(mixer_test)
|
||||
|
||||
# conversion_test
|
||||
add_executable(conversion_test conversion_test.cpp ${PX_SRC}/systemcmds/tests/test_conv.cpp)
|
||||
target_link_libraries( conversion_test px4_platform )
|
||||
add_executable(conversion_test conversion_test.cpp ${PX4_SRC}/systemcmds/tests/test_conv.cpp)
|
||||
add_gtest(conversion_test)
|
||||
|
||||
# sbus2_test
|
||||
add_executable(sbus2_test sbus2_test.cpp hrt.cpp
|
||||
${PX_SRC}/lib/rc/sbus.c)
|
||||
target_link_libraries( sbus2_test px4_platform )
|
||||
${PX4_SRC}/lib/rc/sbus.c)
|
||||
add_gtest(sbus2_test)
|
||||
|
||||
# DSM test
|
||||
add_executable(dsm_test dsm_test.cpp hrt.cpp
|
||||
${PX_SRC}/lib/rc/dsm.c)
|
||||
target_link_libraries( dsm_test px4_platform )
|
||||
${PX4_SRC}/lib/rc/dsm.c)
|
||||
add_gtest(dsm_test)
|
||||
|
||||
# st24_test
|
||||
add_executable(rc_input_test st24_test.cpp hrt.cpp ${PX_SRC}/lib/rc/st24.c sumd_test.cpp ${PX_SRC}/lib/rc/sumd.c)
|
||||
target_link_libraries(rc_input_test px4_platform)
|
||||
add_executable(rc_input_test st24_test.cpp hrt.cpp sumd_test.cpp
|
||||
${PX4_SRC}/lib/rc/st24.c
|
||||
${PX4_SRC}/lib/rc/sumd.c)
|
||||
add_gtest(rc_input_test)
|
||||
|
||||
# sf0x_test
|
||||
add_executable(sf0x_test sf0x_test.cpp ${PX_SRC}/drivers/sf0x/sf0x_parser.cpp)
|
||||
target_link_libraries( sf0x_test px4_platform )
|
||||
add_executable(sf0x_test sf0x_test.cpp
|
||||
${PX4_SRC}/drivers/sf0x/sf0x_parser.cpp)
|
||||
add_gtest(sf0x_test)
|
||||
|
||||
# param_test
|
||||
#add_executable(param_test param_test.cpp
|
||||
# hrt.cpp
|
||||
# uorb_stub.cpp
|
||||
# ${PX_SRC}/modules/systemlib/param/param.c
|
||||
# ${PX_SRC}/modules/systemlib/bson/tinybson.c
|
||||
# )
|
||||
#target_link_libraries( param_test px4_platform )
|
||||
|
||||
#add_gtest(param_test)
|
||||
add_executable(param_test param_test.cpp hrt.cpp uorb_stub.cpp
|
||||
${PX4_SRC}/modules/systemlib/bson/tinybson.c
|
||||
${PX4_SRC}/modules/systemlib/param/param.c)
|
||||
add_gtest(param_test)
|
||||
|
||||
# uorb test
|
||||
#add_executable(uorb_tests uorb_unittests/uORBCommunicator_gtests.cpp
|
||||
# uorb_unittests/uORBCommunicatorMock.cpp
|
||||
# uorb_unittests/uORBCommunicatorMockLoopback.cpp
|
||||
# ${PX_SRC}/modules/uORB/uORBDevices_posix.cpp
|
||||
# ${PX_SRC}/modules/uORB/uORBManager_posix.cpp
|
||||
# ${PX_SRC}/modules/uORB/objects_common.cpp
|
||||
# ${PX_SRC}/modules/uORB/uORBUtils.cpp
|
||||
# ${PX_SRC}/modules/uORB/uORB.cpp
|
||||
# )
|
||||
#target_link_libraries( uorb_tests px4_platform )
|
||||
|
||||
#add_gtest(uorb_tests)
|
||||
# param_shmem_test
|
||||
#add_executable(param_shmem_test param_test.cpp hrt.cpp uorb_stub.cpp
|
||||
# ${PX4_SRC}/modules/systemlib/bson/tinybson.c
|
||||
# ${PX4_SRC}/modules/systemlib/param/param_shmem.c)
|
||||
#add_gtest(param_shmem_test)
|
||||
|
|
|
@ -10,6 +10,8 @@ struct param_info_s param_array[256];
|
|||
struct param_info_s *param_info_base;
|
||||
struct param_info_s *param_info_limit;
|
||||
|
||||
#define param_info_count 4
|
||||
|
||||
/*
|
||||
* Adds test parameters
|
||||
*/
|
||||
|
@ -44,8 +46,10 @@ void _add_parameters()
|
|||
param_array[2] = rc_x;
|
||||
param_array[3] = rc2_x;
|
||||
param_info_base = (struct param_info_s *) ¶m_array[0];
|
||||
param_info_limit = (struct param_info_s *) ¶m_array[4]; // needs to point at the end of the data,
|
||||
// therefore number of params + 1
|
||||
// needs to point at the end of the data,
|
||||
// therefore number of params + 1
|
||||
param_info_limit = (struct param_info_s *) ¶m_array[4];
|
||||
|
||||
}
|
||||
|
||||
void _assert_parameter_int_value(param_t param, int32_t expected)
|
||||
|
@ -149,4 +153,4 @@ TEST(ParamTest, ResetAllExcludesWildcard)
|
|||
_assert_parameter_int_value((param_t)1, 4);
|
||||
_assert_parameter_int_value((param_t)2, 50);
|
||||
_assert_parameter_int_value((param_t)3, 50);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue