Bin Meng | 1bb290d | 2018-10-15 02:21:26 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com> |
| 4 | */ |
| 5 | |
Bin Meng | 1bb290d | 2018-10-15 02:21:26 -0700 | [diff] [blame] | 6 | #include <dm.h> |
| 7 | #include <virtio_types.h> |
| 8 | #include <virtio.h> |
Bin Meng | 1bb290d | 2018-10-15 02:21:26 -0700 | [diff] [blame] | 9 | #include <dm/device-internal.h> |
Bin Meng | 1bb290d | 2018-10-15 02:21:26 -0700 | [diff] [blame] | 10 | #include <dm/root.h> |
| 11 | #include <dm/test.h> |
Simon Glass | 75c4d41 | 2020-07-19 10:15:37 -0600 | [diff] [blame] | 12 | #include <dm/uclass-internal.h> |
| 13 | #include <test/test.h> |
Bin Meng | 1bb290d | 2018-10-15 02:21:26 -0700 | [diff] [blame] | 14 | #include <test/ut.h> |
| 15 | |
Bin Meng | 1bb290d | 2018-10-15 02:21:26 -0700 | [diff] [blame] | 16 | /* Test of the virtio driver that does not have required driver ops */ |
| 17 | static int dm_test_virtio_missing_ops(struct unit_test_state *uts) |
| 18 | { |
| 19 | struct udevice *bus; |
| 20 | |
| 21 | /* find the virtio device */ |
| 22 | ut_assertok(uclass_find_device(UCLASS_VIRTIO, 1, &bus)); |
| 23 | |
| 24 | /* |
| 25 | * Probe the device should fail with error -ENOENT. |
| 26 | * See ops check in virtio_uclass_pre_probe(). |
| 27 | */ |
| 28 | ut_asserteq(-ENOENT, device_probe(bus)); |
| 29 | |
| 30 | return 0; |
| 31 | } |
Simon Glass | 974dccd | 2020-07-28 19:41:12 -0600 | [diff] [blame] | 32 | DM_TEST(dm_test_virtio_missing_ops, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |