tests: kconfig: functions: add tests for dt_compat_enabled_num
Add tests for the dt_compat_enabled_num Kconfig helper function. Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
parent
08175f816a
commit
5ca8be264d
@ -113,4 +113,22 @@ config KCONFIG_MAX_10_3_2
|
|||||||
int
|
int
|
||||||
default $(max, 0xa, 3, 0b10)
|
default $(max, 0xa, 3, 0b10)
|
||||||
|
|
||||||
|
DT_COMPAT_VND_GPIO := vnd,gpio
|
||||||
|
|
||||||
|
config KCONFIG_VND_GPIO_ENABLED_NUM_4
|
||||||
|
int
|
||||||
|
default $(dt_compat_enabled_num,$(DT_COMPAT_VND_GPIO))
|
||||||
|
|
||||||
|
DT_COMPAT_VND_CAN_CONTROLLER := vnd,can-controller
|
||||||
|
|
||||||
|
config KCONFIG_VND_CAN_CONTROLLER_ENABLED_NUM_2
|
||||||
|
int
|
||||||
|
default $(dt_compat_enabled_num,$(DT_COMPAT_VND_CAN_CONTROLLER))
|
||||||
|
|
||||||
|
DT_COMPAT_VND_PWM := vnd,pwm
|
||||||
|
|
||||||
|
config KCONFIG_VND_PWM_ENABLED_NUM_0
|
||||||
|
int
|
||||||
|
default $(dt_compat_enabled_num,$(DT_COMPAT_VND_PWM))
|
||||||
|
|
||||||
source "Kconfig.zephyr"
|
source "Kconfig.zephyr"
|
||||||
|
|||||||
62
tests/kconfig/functions/app.overlay
Normal file
62
tests/kconfig/functions/app.overlay
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2025 Vestas Wind Systems A/S
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/ {
|
||||||
|
test {
|
||||||
|
#address-cells = <1>;
|
||||||
|
#size-cells = <1>;
|
||||||
|
|
||||||
|
test_gpio_0: gpio@1000 {
|
||||||
|
compatible = "vnd,gpio";
|
||||||
|
reg = <0x1000 0x1000>;
|
||||||
|
gpio-controller;
|
||||||
|
#gpio-cells = <2>;
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
||||||
|
test_gpio_1: gpio@2000 {
|
||||||
|
compatible = "vnd,gpio";
|
||||||
|
reg = <0x2000 0x1000>;
|
||||||
|
gpio-controller;
|
||||||
|
#gpio-cells = <2>;
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
||||||
|
test_gpio_2: gpio@3000 {
|
||||||
|
compatible = "vnd,gpio";
|
||||||
|
reg = <0x3000 0x1000>;
|
||||||
|
gpio-controller;
|
||||||
|
#gpio-cells = <2>;
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
||||||
|
test_gpio_3: gpio@4000 {
|
||||||
|
compatible = "vnd,gpio";
|
||||||
|
reg = <0x4000 0x1000>;
|
||||||
|
gpio-controller;
|
||||||
|
#gpio-cells = <2>;
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
||||||
|
test_can_0: gpio@5000 {
|
||||||
|
compatible = "vnd,can-controller";
|
||||||
|
reg = <0x5000 0x1000>;
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
||||||
|
test_can_1: gpio@6000 {
|
||||||
|
compatible = "vnd,can-controller";
|
||||||
|
reg = <0x6000 0x1000>;
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
||||||
|
test_can_2: gpio@7000 {
|
||||||
|
compatible = "vnd,can-controller";
|
||||||
|
reg = <0x7000 0x1000>;
|
||||||
|
status = "disabled";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -45,4 +45,11 @@ ZTEST(test_kconfig_functions, test_min_max)
|
|||||||
zassert_equal(CONFIG_KCONFIG_MAX_10_3_2, MAX(MAX(10, 3), 2));
|
zassert_equal(CONFIG_KCONFIG_MAX_10_3_2, MAX(MAX(10, 3), 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZTEST(test_kconfig_functions, test_dt_num_compat_enabled)
|
||||||
|
{
|
||||||
|
zassert_equal(CONFIG_KCONFIG_VND_GPIO_ENABLED_NUM_4, 4);
|
||||||
|
zassert_equal(CONFIG_KCONFIG_VND_CAN_CONTROLLER_ENABLED_NUM_2, 2);
|
||||||
|
zassert_equal(CONFIG_KCONFIG_VND_PWM_ENABLED_NUM_0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
ZTEST_SUITE(test_kconfig_functions, NULL, NULL, NULL, NULL, NULL);
|
ZTEST_SUITE(test_kconfig_functions, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user