mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-17 14:07:34 +08:00
Fix unit tests leaking resources
This was harmless but none the less is not good style and needs fixing.
This commit is contained in:
@@ -272,6 +272,7 @@ test_mount(int argc, char *argv[])
|
||||
px4_close(fd);
|
||||
|
||||
if (ret) {
|
||||
px4_close(cmd_fd);
|
||||
PX4_ERR("UNLINKING FILE FAILED");
|
||||
return 1;
|
||||
}
|
||||
@@ -283,7 +284,7 @@ test_mount(int argc, char *argv[])
|
||||
fsync(fileno(stderr));
|
||||
usleep(20000);
|
||||
|
||||
|
||||
px4_close(cmd_fd);
|
||||
|
||||
/* we always reboot for the next test if we get here */
|
||||
PX4_INFO("Iteration done, rebooting..");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2012, 2013, 2017 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -173,6 +173,8 @@ int test_ppm_loopback(int argc, char *argv[])
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
close(servo_fd);
|
||||
|
||||
warnx("PPM LOOPBACK TEST PASSED SUCCESSFULLY!");
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved.
|
||||
* Copyright (c) 2012, 2013, 2017 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -116,5 +116,6 @@ int test_servo(int argc, char *argv[])
|
||||
printf("Advancing channel 1 to 1800\n");
|
||||
result = ioctl(fd, PWM_SERVO_SET(1), 1800);
|
||||
out:
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
/****************************************************************************
|
||||
* px4/sensors/test_gpio.c
|
||||
*
|
||||
* Copyright (C) 2012 PX4 Development Team. All rights reserved.
|
||||
* Lorenz Meier <lm@inf.ethz.ch>
|
||||
* Copyright (c) 2012, 2017 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -14,7 +12,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
@@ -33,9 +31,11 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
/**
|
||||
* @file test_uart_baudchange.c
|
||||
*
|
||||
* @author Lorenz Meier <lorenz@px4.io>
|
||||
*/
|
||||
|
||||
#include <px4_config.h>
|
||||
#include <px4_defines.h>
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
/****************************************************************************
|
||||
* px4/sensors/test_uart_break.c
|
||||
*
|
||||
* Copyright (C) 2012-2016 PX4 Development Team. All rights reserved.
|
||||
* Lorenz Meier <lm@inf.ethz.ch>
|
||||
* David Sidrane <david_s5@nscdg.com>
|
||||
* Copyright (c) 2012-2017 PX4 Development Team. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -15,7 +12,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
@@ -34,9 +31,12 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
/**
|
||||
* @file test_uart_break.c
|
||||
*
|
||||
* @author Lorenz Meier <lorenz@px4.io>
|
||||
* @author David Sidrane <david_s5@nscdg.com>
|
||||
*/
|
||||
|
||||
#include <px4_config.h>
|
||||
#include <px4_defines.h>
|
||||
@@ -59,40 +59,6 @@
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: test_led
|
||||
****************************************************************************/
|
||||
|
||||
int test_uart_break(int argc, char *argv[])
|
||||
{
|
||||
int uart2_nwrite0 = 0;
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
* @file test_uart_loopback.c
|
||||
* Tests the uart outputs
|
||||
*
|
||||
* @author Lorenz Meier <lorenz@px4.io>
|
||||
*/
|
||||
|
||||
#include <px4_config.h>
|
||||
@@ -75,6 +76,10 @@ int test_uart_loopback(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (uart5 < 0) {
|
||||
if (uart2 > 0) {
|
||||
close(uart2);
|
||||
}
|
||||
|
||||
printf("ERROR opening UART5, aborting..\n");
|
||||
exit(uart5);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user