From 85e83038613a2b292c3022b922425f3d54be4d56 Mon Sep 17 00:00:00 2001 From: Nathan Olff Date: Tue, 15 Oct 2024 15:20:13 +0200 Subject: [PATCH] tests: drivers: test fake-pwm on native_sim for pwm_api test create native_sim overlay to use fake pwm for test of pwm_api Signed-off-by: Nathan Olff --- .../pwm/pwm_api/boards/native_sim.overlay | 18 ++++++++++++++++++ tests/drivers/pwm/pwm_api/src/test_pwm.c | 5 +++++ tests/drivers/pwm/pwm_api/testcase.yaml | 5 +++++ 3 files changed, 28 insertions(+) create mode 100644 tests/drivers/pwm/pwm_api/boards/native_sim.overlay diff --git a/tests/drivers/pwm/pwm_api/boards/native_sim.overlay b/tests/drivers/pwm/pwm_api/boards/native_sim.overlay new file mode 100644 index 00000000000000..f5b77cacfdf24e --- /dev/null +++ b/tests/drivers/pwm/pwm_api/boards/native_sim.overlay @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2024 Kickmaker + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/{ + pwm0: pwm0 { + compatible = "zephyr,fake-pwm"; + status = "okay"; + #pwm-cells = <2>; + frequency = <10000000>; + }; + + aliases { + pwm-0 = &pwm0; + }; +}; diff --git a/tests/drivers/pwm/pwm_api/src/test_pwm.c b/tests/drivers/pwm/pwm_api/src/test_pwm.c index 839faec9b910fb..a697c2b6aff69e 100644 --- a/tests/drivers/pwm/pwm_api/src/test_pwm.c +++ b/tests/drivers/pwm/pwm_api/src/test_pwm.c @@ -79,6 +79,11 @@ #define DEFAULT_PULSE_NSEC 1000000 #endif +#if DT_HAS_COMPAT_STATUS_OKAY(zephyr_fake_pwm) +#include +DEFINE_FFF_GLOBALS; +#endif + #if defined CONFIG_BOARD_SAM_E70_XPLAINED #define DEFAULT_PWM_PORT 2 /* PWM on EXT2 connector, pin 8 */ #elif defined CONFIG_PWM_NRFX diff --git a/tests/drivers/pwm/pwm_api/testcase.yaml b/tests/drivers/pwm/pwm_api/testcase.yaml index 191a2b86be8784..5aecec06aebc1e 100644 --- a/tests/drivers/pwm/pwm_api/testcase.yaml +++ b/tests/drivers/pwm/pwm_api/testcase.yaml @@ -30,3 +30,8 @@ tests: platform_allow: - frdm_mcxn947/mcxn947/cpu0 - frdm_mcxn947/mcxn947/cpu0/qspi + drivers.pwm.native_sim: + platform_allow: + - native_sim + integration_platforms: + - native_sim