
On Thu, 7 Apr 2022 at 08:20, Heinrich Schuchardt xypron.glpk@gmx.de wrote:
On 3/31/22 12:09, Andrew Scull wrote:
The virtio-rng driver is extremely simple, making it suitable for testing more of the virtio uclass logic. Have the sandbox driver bind the virtio-rng driver rather than the virtio-blk driver so it can be used in tests.
test/dm/rng.c assumes that drivers/rng/sandbox_rng.c is providing the only RNG device.
Does test/dm/virtio.c guarantee that no virtio-rng device is bound after the test is run?
My understanding was that dm_test_pre_run() in test/test-main.c reset the driver model for each dm test, which would imply that nothing is bound at the start of the test. Have I understood this correctly?
Best regards
Heinrich
Signed-off-by: Andrew Scull ascull@google.com
drivers/virtio/virtio_sandbox.c | 2 +- test/dm/virtio.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/virtio/virtio_sandbox.c b/drivers/virtio/virtio_sandbox.c index a73b123454..5484ae3a1a 100644 --- a/drivers/virtio/virtio_sandbox.c +++ b/drivers/virtio/virtio_sandbox.c @@ -161,7 +161,7 @@ static int virtio_sandbox_probe(struct udevice *udev)
/* fake some information for testing */ priv->device_features = BIT_ULL(VIRTIO_F_VERSION_1);
uc_priv->device = VIRTIO_ID_BLOCK;
uc_priv->device = VIRTIO_ID_RNG; uc_priv->vendor = ('u' << 24) | ('b' << 16) | ('o' << 8) | 't'; return 0;
diff --git a/test/dm/virtio.c b/test/dm/virtio.c index d054ccfaa4..769945a0d8 100644 --- a/test/dm/virtio.c +++ b/test/dm/virtio.c @@ -25,10 +25,10 @@ static int dm_test_virtio_base(struct unit_test_state *uts) ut_assertok(uclass_first_device(UCLASS_VIRTIO, &bus)); ut_assertnonnull(bus);
/* check the child virtio-blk device is bound */
/* check the child virtio-rng device is bound */ ut_assertok(device_find_first_child(bus, &dev)); ut_assertnonnull(dev);
ut_assertok(strcmp(dev->name, "virtio-blk#0"));
ut_asserteq_str("virtio-rng#0", dev->name); /* check driver status */ ut_assertok(virtio_get_status(dev, &status));
@@ -54,7 +54,7 @@ static int dm_test_virtio_all_ops(struct unit_test_state *uts) ut_assertok(uclass_first_device(UCLASS_VIRTIO, &bus)); ut_assertnonnull(bus);
/* check the child virtio-blk device is bound */
/* check the child virtio-rng device is bound */ ut_assertok(device_find_first_child(bus, &dev)); ut_assertnonnull(dev);
@@ -114,7 +114,7 @@ static int dm_test_virtio_remove(struct unit_test_state *uts) ut_assertok(uclass_first_device(UCLASS_VIRTIO, &bus)); ut_assertnonnull(bus);
/* check the child virtio-blk device is bound */
/* check the child virtio-rng device is bound */ ut_assertok(device_find_first_child(bus, &dev)); ut_assertnonnull(dev);