From 3acb97477f261bf11c866b5764deabe693607bc3 Mon Sep 17 00:00:00 2001 From: John Levon Date: Mon, 19 Apr 2021 13:10:02 +0100 Subject: vfu_realize_ctx(): fix default PCI config space region (#445) Fix check for an un-configured PCI config space region (the previous method was not accounting for the initialized ->fd). Signed-off-by: John Levon Reviewed-by: Thanos Makatos --- test/unit-tests.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/unit-tests.c b/test/unit-tests.c index 7f03fb7..9aa1106 100644 --- a/test/unit-tests.c +++ b/test/unit-tests.c @@ -737,6 +737,18 @@ test_vfu_ctx_create(void **state UNUSED) will_return(close, 0); vfu_destroy_ctx(vfu_ctx); + + /* Test "bare" vfu_create_ctx(). */ + vfu_ctx = vfu_create_ctx(VFU_TRANS_SOCK, "", LIBVFIO_USER_FLAG_ATTACH_NB, + NULL, VFU_DEV_TYPE_PCI); + assert_non_null(vfu_ctx); + + assert_int_equal(0, vfu_realize_ctx(vfu_ctx)); + + expect_value(close, fd, ((tran_sock_t *)vfu_ctx->tran_data)->fd); + will_return(close, 0); + + vfu_destroy_ctx(vfu_ctx); } bool pci_caps_writing = true; -- cgit v1.1