From: Christian Marangi Date: Tue, 1 Oct 2024 12:24:43 +0000 (+0200) Subject: test: dm: Add tests for LED boot and activity X-Git-Url: http://git.dujemihanovic.xyz/img/static/git-favicon.png?a=commitdiff_plain;h=9046279d92bb0d964cc3ae366985dec680b9224c;p=u-boot.git test: dm: Add tests for LED boot and activity Add tests for LED boot and activity feature and add required property in sandbox test DTS. Signed-off-by: Christian Marangi Reviewed-by: Simon Glass --- diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 8412506c17..6706309720 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -101,6 +101,8 @@ bootscr-ram-offset = /bits/ 64 <0x12345678>; bootscr-flash-offset = /bits/ 64 <0>; bootscr-flash-size = /bits/ 64 <0x2000>; + boot-led = "sandbox:green"; + activity-led = "sandbox:red"; }; }; diff --git a/test/dm/led.c b/test/dm/led.c index e1509c397d..884f6410b7 100644 --- a/test/dm/led.c +++ b/test/dm/led.c @@ -137,3 +137,75 @@ static int dm_test_led_blink(struct unit_test_state *uts) } DM_TEST(dm_test_led_blink, UTF_SCAN_PDATA | UTF_SCAN_FDT); #endif + +/* Test LED boot */ +#ifdef CONFIG_LED_BOOT +static int dm_test_led_boot(struct unit_test_state *uts) +{ + struct udevice *dev + + /* options/u-boot/boot-led is set to "sandbox:green" */ + ut_assertok(led_get_by_label("sandbox:green", &dev)); + ut_asserteq(LEDST_OFF, led_get_state(dev)); + ut_assertok(led_boot_on()); + ut_asserteq(LEDST_ON, led_get_state(dev)); + ut_assertok(led_boot_off()); + ut_asserteq(LEDST_OFF, led_get_state(dev)); + + return 0; +} + +/* Test LED boot blink fallback */ +#ifndef CONFIG_LED_BLINK +static int dm_test_led_boot(struct unit_test_state *uts) +{ + struct udevice *dev + + /* options/u-boot/boot-led is set to "sandbox:green" */ + ut_assertok(led_get_by_label("sandbox:green", &dev)); + ut_asserteq(LEDST_OFF, led_get_state(dev)); + ut_assertok(led_boot_blink()); + ut_asserteq(LEDST_ON, led_get_state(dev)); + ut_assertok(led_boot_off()); + ut_asserteq(LEDST_OFF, led_get_state(dev)); + + return 0; +} +#endif +#endif + +/* Test LED activity */ +#ifdef CONFIG_LED_ACTIVITY +static int dm_test_led_boot(struct unit_test_state *uts) +{ + struct udevice *dev + + /* options/u-boot/activity-led is set to "sandbox:red" */ + ut_assertok(led_get_by_label("sandbox:red", &dev)); + ut_asserteq(LEDST_OFF, led_get_state(dev)); + ut_assertok(led_activity_on()); + ut_asserteq(LEDST_ON, led_get_state(dev)); + ut_assertok(led_activity_off()); + ut_asserteq(LEDST_OFF, led_get_state(dev)); + + return 0; +} + +/* Test LED activity blink fallback */ +#ifndef CONFIG_LED_BLINK +static int dm_test_led_boot(struct unit_test_state *uts) +{ + struct udevice *dev + + /* options/u-boot/activity-led is set to "sandbox:red" */ + ut_assertok(led_get_by_label("sandbox:red", &dev)); + ut_asserteq(LEDST_OFF, led_get_state(dev)); + ut_assertok(led_activity_blink()); + ut_asserteq(LEDST_ON, led_get_state(dev)); + ut_assertok(led_activity_off()); + ut_asserteq(LEDST_OFF, led_get_state(dev)); + + return 0; +} +#endif +#endif