aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Levon <john.levon@nutanix.com>2021-03-23 15:30:25 +0000
committerGitHub <noreply@github.com>2021-03-23 15:30:25 +0000
commit9ed4c9e8c86ec04cbae067db18e1d31dd5f2ca79 (patch)
tree3179a0a18319c3e863bd01c334de8a8fc7c68ab2 /test
parent8ba55dfb9bb54b773513e78d87d9ebe078384573 (diff)
downloadlibvfio-user-9ed4c9e8c86ec04cbae067db18e1d31dd5f2ca79.zip
libvfio-user-9ed4c9e8c86ec04cbae067db18e1d31dd5f2ca79.tar.gz
libvfio-user-9ed4c9e8c86ec04cbae067db18e1d31dd5f2ca79.tar.bz2
add -Wmissing-declarations (#399)
This is used by SPDK, and it's generally useful. This also uncovered some issues in the test mocking. Signed-off-by: John Levon <john.levon@nutanix.com> Reviewed-by: Swapnil Ingle <swapnil.ingle@nutanix.com>
Diffstat (limited to 'test')
-rw-r--r--test/mocks.c18
-rw-r--r--test/mocks.h48
-rw-r--r--test/unit-tests.c5
3 files changed, 14 insertions, 57 deletions
diff --git a/test/mocks.c b/test/mocks.c
index df10147..daeeb81 100644
--- a/test/mocks.c
+++ b/test/mocks.c
@@ -40,6 +40,7 @@
#include "dma.h"
#include "migration.h"
#include "../lib/private.h"
+#include "../lib/tran_sock.h"
struct function
{
@@ -126,9 +127,10 @@ __wrap_get_next_command(vfu_ctx_t *vfu_ctx, struct vfio_user_header *hdr,
int
__wrap_exec_command(vfu_ctx_t *vfu_ctx, struct vfio_user_header *hdr,
- size_t size, int *fds, size_t *nr_fds, size_t **fds_out,
- int *nr_fds_out, struct iovec *_iovecs, struct iovec **iovecs,
- size_t *nr_iovecs, bool *free_iovec_data)
+ size_t size, int *fds, size_t nr_fds, int **fds_out,
+ size_t *nr_fds_out, struct iovec *_iovecs,
+ struct iovec **iovecs, size_t *nr_iovecs,
+ bool *free_iovec_data)
{
if (!is_patched(exec_command)) {
return __real_exec_command(vfu_ctx, hdr, size, fds, nr_fds, fds_out,
@@ -234,16 +236,6 @@ __wrap_cmd_allowed_when_stopped_and_copying(uint16_t cmd)
}
bool
-__wrap_cmd_allowed_when_stopped(struct migration *migration)
-{
- if (!is_patched(device_is_stopped)) {
- return __real_device_is_stopped(migration);
- }
- check_expected(migration);
- return mock();
-}
-
-bool
__wrap_should_exec_command(vfu_ctx_t *vfu_ctx, uint16_t cmd)
{
if (!is_patched(should_exec_command)) {
diff --git a/test/mocks.h b/test/mocks.h
index 1bc6983..b005af6 100644
--- a/test/mocks.h
+++ b/test/mocks.h
@@ -29,6 +29,8 @@
*/
#include <stdbool.h>
+#include <sys/socket.h>
+
#include "private.h"
void unpatch_all(void);
@@ -37,51 +39,13 @@ void patch(void *fn);
bool is_patched(void *fn);
-bool
-__real_cmd_allowed_when_stopped_and_copying(u_int16_t cmd);
-
-int
-handle_dirty_pages(vfu_ctx_t *vfu_ctx, uint32_t size,
- struct iovec **iovecs, size_t *nr_iovecs,
- struct vfio_iommu_type1_dirty_bitmap *dirty_bitmap);
-
-int
-__real_handle_dirty_pages(vfu_ctx_t *vfu_ctx, uint32_t size,
- struct iovec **iovecs, size_t *nr_iovecs,
- struct vfio_iommu_type1_dirty_bitmap *dirty_bitmap);
-
-int
-__real_dma_controller_add_region(dma_controller_t *dma, dma_addr_t dma_addr,
- size_t size, int fd, off_t offset,
- uint32_t prot);
+MOCKED(int, close, int fd);
-int
-__real_dma_controller_remove_region(dma_controller_t *dma,
- dma_addr_t dma_addr, size_t size,
- vfu_unmap_dma_cb_t *unmap_dma, void *data);
-
-bool
-__real_device_is_stopped(struct migration *migr);
-
-int
-__real_exec_command(vfu_ctx_t *vfu_ctx, struct vfio_user_header *hdr,
- size_t size, int *fds, size_t *nr_fds, size_t **fds_out,
- int *nr_fds_out, struct iovec *_iovecs, struct iovec **iovecs,
- size_t *nr_iovecs, bool *free_iovec_data);
-int
-__real_close(int fd);
-
-void
-__real_free(void *ptr);
-
-int
-__real_process_request(vfu_ctx_t *vfu_ctx);
+MOCKED(void, free, void *);
-bool
-__real_device_is_stopped_and_copying(struct migration *migration);
+MOCKED(int, bind, int sockfd, const struct sockaddr *addr, socklen_t addrlen);
-bool
-__real_should_exec_command(vfu_ctx_t *vfu_ctx, uint16_t cmd);
+MOCKED(int, listen, int sockfd, int backlog);
int
mock_unmap_dma(vfu_ctx_t *vfu_ctx, uint64_t iova, uint64_t len);
diff --git a/test/unit-tests.c b/test/unit-tests.c
index 929b83a..4d07c64 100644
--- a/test/unit-tests.c
+++ b/test/unit-tests.c
@@ -1600,8 +1600,9 @@ test_should_exec_command(UNUSED void **state)
assert_true(should_exec_command(&vfu_ctx, 0xbeef));
}
-int recv_body(UNUSED vfu_ctx_t *vfu_ctx, UNUSED const struct vfio_user_header *hdr,
- UNUSED void **datap)
+static int
+recv_body(UNUSED vfu_ctx_t *vfu_ctx, UNUSED const struct vfio_user_header *hdr,
+ UNUSED void **datap)
{
/* hack to avoid having to refactor the rest of exec_command */
return -1;