]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: dm: Add tests for LED boot and activity
authorChristian Marangi <ansuelsmth@gmail.com>
Tue, 1 Oct 2024 12:24:43 +0000 (14:24 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 10 Oct 2024 22:02:20 +0000 (16:02 -0600)
Add tests for LED boot and activity feature and add required property in
sandbox test DTS.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/sandbox/dts/test.dts
test/dm/led.c

index 8412506c17a638135b1011d5e59c3956017b5e96..6706309720deccaa47b62bc023afe1a05e04d482 100644 (file)
                        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";
                };
        };
 
index e1509c397d832a87992b184f51273d0e67acb7ab..884f6410b703fc874dc0bf3a1f6929727a03883b 100644 (file)
@@ -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