Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ladislas/feature/mock mbed digitalout #264

Merged
merged 2 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion mbed_app.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
"sd.SPI_MISO": "SD_SPI_MISO",
"sd.SPI_MOSI": "SD_SPI_MOSI",
"sd.SPI_CLK": "SD_SPI_SCK",
"target.printf_lib": "std"
"target.printf_lib": "std",
"target.features_add": [
"EXPERIMENTAL_API"
]
},
"LEKA_DISCO": {
"target_name": "\"LEKA_DISCO\""
Expand Down
1 change: 1 addition & 0 deletions tests/unit/mbed-os/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ add_library(mbed-os INTERFACE)
target_include_directories(mbed-os
INTERFACE
${UNITTESTS_DIR}/mbed-os
${UNITTESTS_DIR}/mbed-os/mocks
${UNITTESTS_DIR}/mbed-os/stubs
${UNITTESTS_DIR}/mbed-os/include

Expand Down
1 change: 1 addition & 0 deletions tests/unit/mbed-os/include/mbed_target_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@
#define __CORTEX_M7 1
#define __FPU_PRESENT 1
#define __MBED_CMSIS_RTOS_CM 1
#define FEATURE_EXPERIMENTAL_API 1
26 changes: 26 additions & 0 deletions tests/unit/mbed-os/mocks/mock_DigitalOut.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Leka - LekaOS
// Copyright 2021 APF France handicap
// SPDX-License-Identifier: Apache-2.0

#ifndef _LEKA_OS_MBED_MOCK_DIGITAL_OUT_H_
#define _LEKA_OS_MBED_MOCK_DIGITAL_OUT_H_

#include "PinNames.h"

#include "drivers/interfaces/InterfaceDigitalOut.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mbed-os en 6.11, sinon l'erreur suivante survient:

fatal error: 'drivers/interfaces/InterfaceDigitalOut.h' file not found
#include "drivers/interfaces/InterfaceDigitalOut.h"


#include "gmock/gmock.h"

namespace mbed::mock {

class DigitalOut : public mbed::interface::DigitalOut
{
public:
MOCK_METHOD(void, write, (int value), (override));
MOCK_METHOD(int, read, (), (override));
MOCK_METHOD(int, is_connected, (), (override));
};

} // namespace mbed::mock

#endif // _LEKA_OS_MBED_MOCK_DIGITAL_OUT_H_
10 changes: 10 additions & 0 deletions tests/unit/mbed-os/stubs/stub_gpio_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@ void gpio_write(gpio_t *gpio, int value)
{
return;
}

auto gpio_read(gpio_t *obj) -> int
{
return 0;
}

auto gpio_is_connected(const gpio_t *obj) -> int
{
return 1;
}