Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Stephen Warren | 8961b52 | 2016-05-16 17:41:37 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2016, NVIDIA CORPORATION. |
Stephen Warren | 8961b52 | 2016-05-16 17:41:37 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <dm.h> |
Simon Glass | 336d461 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 8 | #include <malloc.h> |
Stephen Warren | 8961b52 | 2016-05-16 17:41:37 -0600 | [diff] [blame] | 9 | #include <dm/test.h> |
| 10 | #include <asm/mbox.h> |
Simon Glass | 0e1fad4 | 2020-07-19 10:15:37 -0600 | [diff] [blame] | 11 | #include <test/test.h> |
Stephen Warren | 8961b52 | 2016-05-16 17:41:37 -0600 | [diff] [blame] | 12 | #include <test/ut.h> |
| 13 | |
| 14 | static int dm_test_mailbox(struct unit_test_state *uts) |
| 15 | { |
| 16 | struct udevice *dev; |
| 17 | uint32_t msg; |
| 18 | |
| 19 | ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "mbox-test", &dev)); |
| 20 | ut_assertok(sandbox_mbox_test_get(dev)); |
| 21 | |
| 22 | ut_asserteq(-ETIMEDOUT, sandbox_mbox_test_recv(dev, &msg)); |
| 23 | ut_assertok(sandbox_mbox_test_send(dev, 0xaaff9955UL)); |
| 24 | ut_assertok(sandbox_mbox_test_recv(dev, &msg)); |
| 25 | ut_asserteq(msg, 0xaaff9955UL ^ SANDBOX_MBOX_PING_XOR); |
| 26 | ut_asserteq(-ETIMEDOUT, sandbox_mbox_test_recv(dev, &msg)); |
| 27 | |
| 28 | ut_assertok(sandbox_mbox_test_free(dev)); |
| 29 | |
| 30 | return 0; |
| 31 | } |
Simon Glass | e180c2b | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 32 | DM_TEST(dm_test_mailbox, UT_TESTF_SCAN_FDT); |