diff options
Diffstat (limited to 'test/unit-tests.c')
-rw-r--r-- | test/unit-tests.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/test/unit-tests.c b/test/unit-tests.c index 3b1d227..1e245a5 100644 --- a/test/unit-tests.c +++ b/test/unit-tests.c @@ -95,6 +95,7 @@ test_dma_map_without_fd(void **state UNUSED) patch("dma_controller_add_region"); will_return(dma_controller_add_region, 0); + will_return(dma_controller_add_region, 0); expect_value(dma_controller_add_region, dma, vfu_ctx.dma); expect_value(dma_controller_add_region, dma_addr, r.addr); expect_value(dma_controller_add_region, size, r.size); @@ -164,6 +165,7 @@ test_dma_add_regions_mixed(void **state UNUSED) patch("dma_controller_add_region"); /* 1st region */ will_return(dma_controller_add_region, 0); + will_return(dma_controller_add_region, 0); expect_value(dma_controller_add_region, dma, vfu_ctx.dma); expect_value(dma_controller_add_region, dma_addr, r[0].addr); expect_value(dma_controller_add_region, size, r[0].size); @@ -174,6 +176,7 @@ test_dma_add_regions_mixed(void **state UNUSED) expect_check(mock_dma_register, info, check_dma_info, &dma->regions[0].info); /* 2nd region */ + will_return(dma_controller_add_region, 0); will_return(dma_controller_add_region, 1); expect_value(dma_controller_add_region, dma, vfu_ctx.dma); expect_value(dma_controller_add_region, dma_addr, r[1].addr); @@ -231,6 +234,7 @@ test_dma_add_regions_mixed_partial_failure(void **state UNUSED) expect_value(dma_controller_add_region, offset, r[0].offset); expect_value(dma_controller_add_region, prot, r[0].prot); will_return(dma_controller_add_region, 0); + will_return(dma_controller_add_region, 0); /* 2nd region */ expect_value(dma_controller_add_region, dma, vfu_ctx.dma); @@ -240,6 +244,7 @@ test_dma_add_regions_mixed_partial_failure(void **state UNUSED) expect_value(dma_controller_add_region, offset, r[1].offset); expect_value(dma_controller_add_region, prot, r[1].prot); will_return(dma_controller_add_region, 0); + will_return(dma_controller_add_region, 0); /* 3rd region */ expect_value(dma_controller_add_region, dma, vfu_ctx.dma); @@ -248,13 +253,14 @@ test_dma_add_regions_mixed_partial_failure(void **state UNUSED) expect_value(dma_controller_add_region, fd, fds[1]); expect_value(dma_controller_add_region, offset, r[2].offset); expect_value(dma_controller_add_region, prot, r[2].prot); - will_return(dma_controller_add_region, -0x1234); + will_return(dma_controller_add_region, EREMOTEIO); + will_return(dma_controller_add_region, -1); patch("close"); expect_value(close, fd, 0xb); will_return(close, 0); - assert_int_equal(-0x1234, + assert_int_equal(-EREMOTEIO, handle_dma_map_or_unmap(&vfu_ctx, ARRAY_SIZE(r) * sizeof(struct vfio_user_dma_region), true, fds, 2, r)); @@ -280,6 +286,7 @@ test_dma_map_return_value(void **state UNUSED) expect_value(dma_controller_add_region, fd, -1); expect_value(dma_controller_add_region, offset, r.offset); expect_value(dma_controller_add_region, prot, r.prot); + will_return(dma_controller_add_region, 0); will_return(dma_controller_add_region, 2); assert_int_equal(0, @@ -1254,11 +1261,13 @@ test_dma_map_sg(void **state UNUSED) dma->nregions = 1; /* bad region */ - assert_int_equal(-EINVAL, dma_map_sg(dma, &sg, &iovec, 1)); + assert_int_equal(-1, dma_map_sg(dma, &sg, &iovec, 1)); + assert_int_equal(EINVAL, errno); /* w/o fd */ sg.region = 0; - assert_int_equal(-EFAULT, dma_map_sg(dma, &sg, &iovec, 1)); + assert_int_equal(-1, dma_map_sg(dma, &sg, &iovec, 1)); + assert_int_equal(EFAULT, errno); /* w/ fd */ dma->regions[0].info.vaddr = (void *)0xdead0000; |