diff mbox series

[v2,10/10] test: dm: rtc: add tests of rtc shell command

Message ID 20200519220117.24448-11-rasmus.villemoes@prevas.dk
State Superseded
Delegated to: Tom Rini
Headers show
Series new rtc methods, rtc command, and tests | expand

Commit Message

Rasmus Villemoes May 19, 2020, 10:01 p.m. UTC
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
 test/dm/rtc.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)

Comments

Simon Glass May 31, 2020, 2:07 p.m. UTC | #1
On Tue, 19 May 2020 at 16:01, Rasmus Villemoes
<rasmus.villemoes@prevas.dk> wrote:
>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> ---
>  test/dm/rtc.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 61 insertions(+)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

But please add a commit message.
Rasmus Villemoes June 2, 2020, 9:15 a.m. UTC | #2
On 31/05/2020 16.07, Simon Glass wrote:
> On Tue, 19 May 2020 at 16:01, Rasmus Villemoes
> <rasmus.villemoes@prevas.dk> wrote:
>>
>> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
>> ---
>>  test/dm/rtc.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 61 insertions(+)
>>
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> But please add a commit message.

Not sure there's anything more to say than $subject, but sure, I can
repeat that in the body.

Thanks,
Rasmus
diff mbox series

Patch

diff --git a/test/dm/rtc.c b/test/dm/rtc.c
index 5301805d19..d1d8ff0375 100644
--- a/test/dm/rtc.c
+++ b/test/dm/rtc.c
@@ -5,6 +5,7 @@ 
  */
 
 #include <common.h>
+#include <console.h>
 #include <dm.h>
 #include <i2c.h>
 #include <rtc.h>
@@ -174,6 +175,66 @@  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("48: 0xaa");
+	ut_assert_nextline("49: 0xbb");
+	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("48: 0xcc");
+	ut_assert_nextline("49: 0xdd");
+	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("48: 0xaa");
+	ut_assert_nextline("49: 0xbb");
+	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)
 {