forked from ArduPilot/ardupilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unit test for GPIO race condition on Linux
Related to ArduPilot#25007
- Loading branch information
Showing
5 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (C) 2016 Intel Corporation. All rights reserved. | ||
* | ||
* This file is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This file is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
* See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#include <AP_gtest.h> | ||
|
||
#include <pthread.h> | ||
#include <unistd.h> | ||
|
||
#include <AP_HAL/AP_HAL.h> | ||
#include <AP_HAL_Linux/GPIO.h> | ||
|
||
using namespace Linux; | ||
|
||
const AP_HAL::HAL &hal = AP_HAL::get_HAL(); | ||
|
||
#define TEST_PIN 12 | ||
|
||
class TestGpioMode1 { | ||
public: | ||
TestGpioMode1() { } | ||
|
||
bool run() { | ||
hal.gpio->pinMode(TEST_PIN, HAL_GPIO_INPUT); | ||
hal.gpio->pinModeValidate(TEST_PIN, HAL_GPIO_INPUT); | ||
hal.gpio->pinMode(TEST_PIN, HAL_GPIO_OUTPUT); | ||
hal.gpio->pinModeValidate(TEST_PIN, HAL_GPIO_OUTPUT); | ||
return true; | ||
} | ||
|
||
protected: | ||
}; | ||
|
||
TEST(LinuxGpio, override_run) | ||
{ | ||
TestGpioMode1 gpio; | ||
fprintf(stderr,"Initializing HAL\n"); | ||
hal.gpio->init(); | ||
fprintf(stderr,"Launching test run\n"); | ||
while (gpio.run()) { | ||
} | ||
} | ||
|
||
AP_GTEST_MAIN() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
UNRELATED_PIN=13 | ||
while : | ||
do | ||
sudo raspi-gpio set ${UNRELATED_PIN} ip | ||
sudo raspi-gpio set ${UNRELATED_PIN} op | ||
done |