]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: dm: rtc: add tests of rtc shell command
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Mon, 6 Jul 2020 20:01:20 +0000 (22:01 +0200)
committerHeiko Schocher <hs@denx.de>
Thu, 9 Jul 2020 04:02:45 +0000 (06:02 +0200)
Add tests of the "list", "read" and "write" subcommands of the rtc
shell command.

Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
test/dm/rtc.c

index ff1bc7b7f66d3c217700803df01adca746c8ecf1..dd037a6e17abad1b1ab3bf156b5900f05ed28f7e 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <console.h>
 #include <dm.h>
 #include <i2c.h>
 #include <log.h>
@@ -175,6 +176,63 @@ static int dm_test_rtc_read_write(struct unit_test_state *uts)
 }
 DM_TEST(dm_test_rtc_read_write, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
 
+/* Test 'rtc list' command */
+static int dm_test_rtc_cmd_list(struct unit_test_state *uts)
+{
+       console_record_reset();
+
+       run_command("rtc list", 0);
+       ut_assert_nextline("RTC #0 - rtc@43");
+       ut_assert_nextline("RTC #1 - rtc@61");
+       ut_assert_console_end();
+
+       return 0;
+}
+DM_TEST(dm_test_rtc_cmd_list, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test 'rtc read' and 'rtc write' commands */
+static int dm_test_rtc_cmd_rw(struct unit_test_state *uts)
+{
+       console_record_reset();
+
+       run_command("rtc dev 0", 0);
+       ut_assert_nextline("RTC #0 - rtc@43");
+       ut_assert_console_end();
+
+       run_command("rtc write 0x30 aabb", 0);
+       ut_assert_console_end();
+
+       run_command("rtc read 0x30 2", 0);
+       ut_assert_nextline("00000030: aa bb                                              ..");
+       ut_assert_console_end();
+
+       run_command("rtc dev 1", 0);
+       ut_assert_nextline("RTC #1 - rtc@61");
+       ut_assert_console_end();
+
+       run_command("rtc write 0x30 ccdd", 0);
+       ut_assert_console_end();
+
+       run_command("rtc read 0x30 2", 0);
+       ut_assert_nextline("00000030: cc dd                                              ..");
+       ut_assert_console_end();
+
+       /*
+        * Switch back to device #0, check that its aux registers
+        * still have the same values.
+        */
+       run_command("rtc dev 0", 0);
+       ut_assert_nextline("RTC #0 - rtc@43");
+       ut_assert_console_end();
+
+       run_command("rtc read 0x30 2", 0);
+       ut_assert_nextline("00000030: aa bb                                              ..");
+       ut_assert_console_end();
+
+       return 0;
+}
+DM_TEST(dm_test_rtc_cmd_rw, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
 /* Reset the time */
 static int dm_test_rtc_reset(struct unit_test_state *uts)
 {