diff options
author | John Levon <john.levon@nutanix.com> | 2020-12-16 11:47:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-16 11:47:10 +0000 |
commit | 0502943fb1ce6f24aff1f3086e55f7ceff86bd68 (patch) | |
tree | 0d696236cea9e2b09636b886469f4974850be082 /test | |
parent | a543685d9606554feeaac00067c93f3e749faf23 (diff) | |
download | libvfio-user-0502943fb1ce6f24aff1f3086e55f7ceff86bd68.zip libvfio-user-0502943fb1ce6f24aff1f3086e55f7ceff86bd68.tar.gz libvfio-user-0502943fb1ce6f24aff1f3086e55f7ceff86bd68.tar.bz2 |
fix clang build (#210)
Also add clang to pull request build checks.
Signed-off-by: John Levon <john.levon@nutanix.com>
Reviewed-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/unit-tests.c | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/test/unit-tests.c b/test/unit-tests.c index c3de8e9..7de11ac 100644 --- a/test/unit-tests.c +++ b/test/unit-tests.c @@ -278,6 +278,30 @@ test_dma_controller_remove_region_no_fd(void **state __attribute__((unused))) assert_int_equal(0, dma_controller_remove_region(dma, r.dma_addr, r.size, NULL, NULL)); } +static int fds[] = { 0xab, 0xcd }; + +static int +set_fds(const long unsigned int value, const long unsigned int data) +{ + assert(value != 0); + if ((void*)data == &get_next_command) { + memcpy((int*)value, fds, ARRAY_SIZE(fds) * sizeof(int)); + } else if ((void*)data == &exec_command) { + ((int*)value)[0] = -1; + } + return 1; +} + +static int +set_nr_fds(const long unsigned int value, + const long unsigned int data __attribute__((unused))) +{ + int *nr_fds = (int*)value; + assert(nr_fds != NULL); + *nr_fds = ARRAY_SIZE(fds); + return 1; +} + /* * Tests that if if exec_command fails then process_request frees passed file * descriptors. @@ -285,27 +309,6 @@ test_dma_controller_remove_region_no_fd(void **state __attribute__((unused))) static void test_process_command_free_passed_fds(void **state __attribute__((unused))) { - int fds[] = {0xab, 0xcd}; - int set_fds(const long unsigned int value, - const long unsigned int data) - { - assert(value != 0); - if ((void*)data == &get_next_command) { - memcpy((int*)value, fds, ARRAY_SIZE(fds) * sizeof(int)); - } else if ((void*)data == &exec_command) { - ((int*)value)[0] = -1; - } - return 1; - } - int set_nr_fds(const long unsigned int value, - const long unsigned int data __attribute__((unused))) - { - int *nr_fds = (int*)value; - assert(nr_fds != NULL); - *nr_fds = ARRAY_SIZE(fds); - return 1; - } - vfu_ctx_t vfu_ctx = { .conn_fd = 0xcafebabe, .migration = (struct migration*)0x8badf00d @@ -375,16 +378,17 @@ test_realize_ctx(void **state __attribute__((unused))) assert_null(vfu_ctx.pci.caps); } -static void -test_attach_ctx(void **state __attribute__((unused))) +static int +dummy_attach(vfu_ctx_t *vfu_ctx) { - int dummy_attach(vfu_ctx_t *vfu_ctx) - { - assert(vfu_ctx != NULL); + assert(vfu_ctx != NULL); - return 222; - } + return 222; +} +static void +test_attach_ctx(void **state __attribute__((unused))) +{ struct transport_ops transport_ops = { .attach = &dummy_attach, }; |