mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 02:33:34 +08:00
add simple posix tests to SITL
This commit is contained in:
committed by
Nuno Marques
parent
5eb3e695bb
commit
af9690cf08
@@ -40,7 +40,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
endif()
|
||||
|
||||
foreach(test_name ${tests})
|
||||
configure_file(${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/test_template.in ${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/test_${test_name}_generated)
|
||||
configure_file(${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/tests_template.in ${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/tests_${test_name}_generated)
|
||||
|
||||
add_test(NAME ${test_name}
|
||||
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh
|
||||
@@ -48,7 +48,7 @@ foreach(test_name ${tests})
|
||||
posix-configs/SITL/init/test
|
||||
none
|
||||
none
|
||||
test_${test_name}_generated
|
||||
tests_${test_name}_generated
|
||||
${PX4_SOURCE_DIR}
|
||||
${PX4_BINARY_DIR}
|
||||
WORKING_DIRECTORY ${SITL_WORKING_DIR})
|
||||
@@ -57,6 +57,33 @@ foreach(test_name ${tests})
|
||||
set_tests_properties(${test_name} PROPERTIES PASS_REGULAR_EXPRESSION "${test_name} PASSED")
|
||||
endforeach()
|
||||
|
||||
# run arbitrary commands
|
||||
set(test_cmds
|
||||
hello
|
||||
hrt_test
|
||||
muorb_test
|
||||
vcdev_test
|
||||
wqueue_test
|
||||
)
|
||||
|
||||
foreach(cmd_name ${test_cmds})
|
||||
configure_file(${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/cmd_template.in ${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/cmd_${cmd_name}_generated)
|
||||
|
||||
add_test(NAME posix_${cmd_name}
|
||||
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh
|
||||
$<TARGET_FILE:px4>
|
||||
posix-configs/SITL/init/test
|
||||
none
|
||||
none
|
||||
cmd_${cmd_name}_generated
|
||||
${PX4_SOURCE_DIR}
|
||||
${PX4_BINARY_DIR}
|
||||
WORKING_DIRECTORY ${SITL_WORKING_DIR})
|
||||
|
||||
set_tests_properties(posix_${cmd_name} PROPERTIES PASS_REGULAR_EXPRESSION "Shutting down")
|
||||
endforeach()
|
||||
|
||||
|
||||
add_custom_target(test_results
|
||||
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -T Test
|
||||
DEPENDS px4
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
* @author Mark Charlebois <mcharleb@gmail.com>
|
||||
*/
|
||||
#include "hello_example.h"
|
||||
|
||||
#include <px4_log.h>
|
||||
#include <px4_app.h>
|
||||
#include <px4_tasks.h>
|
||||
#include <stdio.h>
|
||||
@@ -46,7 +48,7 @@
|
||||
|
||||
#define SCHED_DEFAULT SCHED_FIFO
|
||||
#define SCHED_PRIORITY_MAX sched_get_priority_max(SCHED_FIFO)
|
||||
#define SCHED_PRIORITY_DEFAULT sched_get_priority_max(SCHED_FIFO)
|
||||
//#define SCHED_PRIORITY_DEFAULT sched_get_priority_max(SCHED_FIFO)
|
||||
|
||||
static int daemon_task; /* Handle of deamon task / thread */
|
||||
|
||||
@@ -74,7 +76,7 @@ int hello_main(int argc, char *argv[])
|
||||
SCHED_PRIORITY_MAX - 5,
|
||||
2000,
|
||||
PX4_MAIN,
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)NULL);
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)nullptr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
############################################################################
|
||||
px4_add_module(
|
||||
MODULE platforms__posix__tests__hrt_test
|
||||
MAIN hrttest
|
||||
MAIN hrt_test
|
||||
SRCS
|
||||
hrt_test_main.cpp
|
||||
hrt_test_start_posix.cpp
|
||||
|
||||
@@ -59,7 +59,7 @@ static void timer_expired(void *arg)
|
||||
|
||||
if (i < 5) {
|
||||
i++;
|
||||
hrt_call_after(&t1, update_interval, timer_expired, (void *)0);
|
||||
hrt_call_after(&t1, update_interval, timer_expired, (void *)nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ int HRTTest::main()
|
||||
|
||||
PX4_INFO("HRT_CALL %d\n", hrt_called(&t1));
|
||||
|
||||
hrt_call_after(&t1, update_interval, timer_expired, (void *)0);
|
||||
hrt_call_after(&t1, update_interval, timer_expired, (void *)nullptr);
|
||||
sleep(2);
|
||||
PX4_INFO("HRT_CALL - %d\n", hrt_called(&t1));
|
||||
hrt_cancel(&t1);
|
||||
|
||||
@@ -46,11 +46,11 @@
|
||||
|
||||
static int daemon_task; /* Handle of deamon task / thread */
|
||||
|
||||
extern "C" __EXPORT int hrttest_main(int argc, char *argv[]);
|
||||
int hrttest_main(int argc, char *argv[])
|
||||
extern "C" __EXPORT int hrt_test_main(int argc, char *argv[]);
|
||||
int hrt_test_main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 2) {
|
||||
PX4_WARN("usage: hrttest_main {start|stop|status}\n");
|
||||
PX4_WARN("usage: hrt_test_main {start|stop|status}\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ int hrttest_main(int argc, char *argv[])
|
||||
SCHED_PRIORITY_MAX - 5,
|
||||
2000,
|
||||
PX4_MAIN,
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)NULL);
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)nullptr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -60,14 +60,14 @@ int MuorbTestExample::DefaultTest()
|
||||
int i = 0;
|
||||
orb_advert_t pub_id = orb_advertise(ORB_ID(esc_status), & m_esc_status);
|
||||
|
||||
if (pub_id == 0) {
|
||||
if (pub_id == nullptr) {
|
||||
PX4_ERR("error publishing esc_status");
|
||||
return -1;
|
||||
}
|
||||
|
||||
orb_advert_t pub_id_vc = orb_advertise(ORB_ID(vehicle_command), & m_vc);
|
||||
|
||||
if (pub_id_vc == 0) {
|
||||
if (pub_id_vc == nullptr) {
|
||||
PX4_ERR("error publishing vehicle_command");
|
||||
return -1;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ int MuorbTestExample::PingPongTest()
|
||||
int i = 0;
|
||||
orb_advert_t pub_id_vc = orb_advertise(ORB_ID(vehicle_command), & m_vc);
|
||||
|
||||
if (pub_id_vc == 0) {
|
||||
if (pub_id_vc == nullptr) {
|
||||
PX4_ERR("error publishing vehicle_command");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
############################################################################
|
||||
px4_add_module(
|
||||
MODULE platforms__posix__tests__vcdev_test
|
||||
MAIN vcdevtest
|
||||
MAIN vcdev_test
|
||||
SRCS
|
||||
vcdevtest_main.cpp
|
||||
vcdevtest_start_posix.cpp
|
||||
|
||||
@@ -66,7 +66,7 @@ static int writer_main(int argc, char *argv[])
|
||||
return -px4_errno;
|
||||
}
|
||||
|
||||
int ret;
|
||||
int ret = 0;
|
||||
int i = 0;
|
||||
|
||||
while (!g_exit) {
|
||||
@@ -188,7 +188,7 @@ VCDevExample::~VCDevExample()
|
||||
{
|
||||
if (_node) {
|
||||
delete _node;
|
||||
_node = 0;
|
||||
_node = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ int VCDevExample::main()
|
||||
|
||||
_node = new VCDevNode();
|
||||
|
||||
if (_node == 0) {
|
||||
if (_node == nullptr) {
|
||||
PX4_INFO("Failed to allocate VCDevNode");
|
||||
return -ENOMEM;
|
||||
}
|
||||
@@ -289,7 +289,7 @@ int VCDevExample::main()
|
||||
return -px4_errno;
|
||||
}
|
||||
|
||||
void *p = 0;
|
||||
void *p = nullptr;
|
||||
int ret = px4_ioctl(fd, DIOC_GETPRIV, (unsigned long)&p);
|
||||
|
||||
if (ret < 0) {
|
||||
@@ -318,7 +318,7 @@ int VCDevExample::main()
|
||||
SCHED_PRIORITY_MAX - 6,
|
||||
2000,
|
||||
writer_main,
|
||||
(char *const *)NULL);
|
||||
(char *const *)nullptr);
|
||||
|
||||
ret = 0;
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ static int daemon_task; /* Handle of deamon task / thread */
|
||||
|
||||
//using namespace px4;
|
||||
|
||||
extern "C" __EXPORT int vcdevtest_main(int argc, char *argv[]);
|
||||
int vcdevtest_main(int argc, char *argv[])
|
||||
extern "C" __EXPORT int vcdev_test_main(int argc, char *argv[]);
|
||||
int vcdev_test_main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
if (argc < 2) {
|
||||
@@ -69,7 +69,7 @@ int vcdevtest_main(int argc, char *argv[])
|
||||
SCHED_PRIORITY_MAX - 5,
|
||||
2000,
|
||||
PX4_MAIN,
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)NULL);
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)nullptr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ int wqueue_test_main(int argc, char *argv[])
|
||||
SCHED_PRIORITY_MAX - 5,
|
||||
2000,
|
||||
PX4_MAIN,
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)NULL);
|
||||
(argv) ? (char *const *)&argv[2] : (char *const *)nullptr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -96,10 +96,9 @@ const struct {
|
||||
{"mavlink", mavlink_tests_main, 0},
|
||||
{"mc_pos_control", mc_pos_control_tests_main, 0},
|
||||
{"sf0x", sf0x_tests_main, 0},
|
||||
#ifndef __PX4_DARWIN
|
||||
{"uorb", uorb_tests_main, 0},
|
||||
{"hysteresis", test_hysteresis, 0},
|
||||
#endif /* __PX4_DARWIN */
|
||||
|
||||
{"mixer", test_mixer, OPT_NOJIGTEST},
|
||||
{"autodeclination", test_autodeclination, 0},
|
||||
{"bson", test_bson, 0},
|
||||
|
||||
Reference in New Issue
Block a user