vsock/tests: panic if vsock_loopback is not available

test_vsock_thread_backend_vsock() and test_vsock_thread_vsock_backend()
tests use VMADDR_CID_LOCAL which is provided by the `vsock_loopback`
kernel module.

If `vsock_loopback` kernel module is not loaded, these tests will fail
later with unclear messages, so it can be hard to debug.

Let's fail early and print a message with the requirement.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
This commit is contained in:
Stefano Garzarella 2024-12-05 16:47:37 +01:00 committed by Viresh Kumar
parent 9b1cc25dc5
commit 0cd34a69ab
2 changed files with 8 additions and 0 deletions

View File

@ -604,6 +604,10 @@ mod tests {
#[cfg(feature = "backend_vsock")]
#[test]
fn test_vsock_thread_backend_vsock() {
VsockListener::bind_with_cid_port(VMADDR_CID_LOCAL, libc::VMADDR_PORT_ANY).expect(
"This test uses VMADDR_CID_LOCAL, so the vsock_loopback kernel module must be loaded",
);
let _listener = VsockListener::bind_with_cid_port(VMADDR_CID_ANY, VSOCK_PEER_PORT).unwrap();
let backend_info = BackendType::Vsock(VsockProxyInfo {
forward_cid: VMADDR_CID_LOCAL,

View File

@ -1041,6 +1041,10 @@ mod tests {
#[cfg(feature = "backend_vsock")]
#[test]
fn test_vsock_thread_vsock_backend() {
VsockListener::bind_with_cid_port(VMADDR_CID_LOCAL, libc::VMADDR_PORT_ANY).expect(
"This test uses VMADDR_CID_LOCAL, so the vsock_loopback kernel module must be loaded",
);
let groups: Vec<String> = vec![String::from("default")];
let cid_map: Arc<RwLock<CidMap>> = Arc::new(RwLock::new(HashMap::new()));