From da2084d2e92f4c3519381aadd849c33c329859d3 Mon Sep 17 00:00:00 2001 From: Stefano Garzarella Date: Thu, 5 Dec 2024 14:33:13 +0100 Subject: [PATCH] vsock/readme: add testing section Add a new section to explain some requirements to run tests, e.g. `vsock_loopback` kernel module is required if `backend_vsock` feature is enabled (true by default) when running tests. Signed-off-by: Stefano Garzarella --- vhost-device-vsock/README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/vhost-device-vsock/README.md b/vhost-device-vsock/README.md index 8c8b915..a8abfab 100644 --- a/vhost-device-vsock/README.md +++ b/vhost-device-vsock/README.md @@ -241,6 +241,40 @@ application running on the host. Assuming the applications listening on port 900 now run the applications that connect to port 9001 and 9002 (you need to modify the CID they connect to be the host CID i.e. 1) on the host machine. +## Testing + +This crate contains several tests that can be run with `cargo test`. + +If `backend_vsock` feature is enabled (true by default), some of the tests use +the AF_VSOCK loopback address [CID = 1] to run the tests, so you must have +loaded the kernel module that handles it (`modprobe vsock_loopback`). + +Otherwise you may experience the following failures: +``` +... +test thread_backend::tests::test_vsock_thread_backend_vsock ... FAILED +... +test vhu_vsock_thread::tests::test_vsock_thread_vsock_backend ... FAILED + +failures: + + +---- thread_backend::tests::test_vsock_thread_backend_vsock stdout ---- +thread 'thread_backend::tests::test_vsock_thread_backend_vsock' panicked at vhost-device-vsock/src/thread_backend.rs:607:84: +This test uses VMADDR_CID_LOCAL, so the vsock_loopback kernel module must be loaded: Os { code: 99, kind: AddrNotAvailable, message: "Cannot assign requested address" } + +---- vhu_vsock_thread::tests::test_vsock_thread_vsock_backend stdout ---- +thread 'vhu_vsock_thread::tests::test_vsock_thread_vsock_backend' panicked at vhost-device-vsock/src/vhu_vsock_thread.rs:1044:84: +This test uses VMADDR_CID_LOCAL, so the vsock_loopback kernel module must be loaded: Os { code: 99, kind: AddrNotAvailable, message: "Cannot assign requested address" } + +failures: + thread_backend::tests::test_vsock_thread_backend_vsock + vhu_vsock_thread::tests::test_vsock_thread_vsock_backend +``` + +With the `vsock_loopback` kernel module loaded in your system, all the tests +should pass. + ## License This project is licensed under either of