vtest: Better error reporting

Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Jakob Bornecrantz 6 years ago committed by Dave Airlie
parent 9b3bab8331
commit fdcb5b588c
  1. 43
      vtest/vtest_renderer.c

@ -67,6 +67,16 @@ struct virgl_box {
uint32_t w, h, d; uint32_t w, h, d;
}; };
static int
__failed_call(const char* func, const char *called, int ret)
{
fprintf(stderr, "%s called %s which failed (%d)\n", func, called, ret);
return ret;
}
#define report_failed_call(called, ret) \
__failed_call(__FUNCTION__, called, ret)
static unsigned static unsigned
hash_func(void *key) hash_func(void *key)
{ {
@ -552,14 +562,16 @@ int vtest_transfer_get2(void)
struct iovec *iovec; struct iovec *iovec;
ret = vtest_block_read(renderer.in_fd, thdr_buf, sizeof(thdr_buf)); ret = vtest_block_read(renderer.in_fd, thdr_buf, sizeof(thdr_buf));
if (ret != sizeof(thdr_buf)) if (ret != sizeof(thdr_buf)) {
return ret; return ret;
}
DECODE_TRANSFER2; DECODE_TRANSFER2;
iovec = util_hash_table_get(renderer.iovec_hash, intptr_to_pointer(handle)); iovec = util_hash_table_get(renderer.iovec_hash, intptr_to_pointer(handle));
if (!iovec) if (!iovec) {
return -ESRCH; return report_failed_call("util_hash_table_get", -ESRCH);
}
ret = virgl_renderer_transfer_read_iov(handle, ret = virgl_renderer_transfer_read_iov(handle,
ctx_id, ctx_id,
@ -569,12 +581,17 @@ int vtest_transfer_get2(void)
&box, &box,
offset, offset,
NULL, 0); NULL, 0);
if (ret) if (ret) {
fprintf(stderr," transfer read failed %d\n", ret); return report_failed_call("virgl_renderer_transfer_read_iov", ret);
}
ret = vtest_block_write(renderer.out_fd, ret = vtest_block_write(renderer.out_fd,
iovec->iov_base + offset, iovec->iov_base + offset,
data_size); data_size);
if (ret < 0) {
return report_failed_call("vtest_block_write", ret);
}
return ret < 0 ? ret : 0; return ret < 0 ? ret : 0;
} }
@ -596,12 +613,14 @@ int vtest_transfer_put2(void)
DECODE_TRANSFER2; DECODE_TRANSFER2;
iovec = util_hash_table_get(renderer.iovec_hash, intptr_to_pointer(handle)); iovec = util_hash_table_get(renderer.iovec_hash, intptr_to_pointer(handle));
if (!iovec) if (!iovec) {
return -ESRCH; return report_failed_call("util_hash_table_get", -ESRCH);
}
ret = vtest_block_read(renderer.in_fd, iovec->iov_base + offset, data_size); ret = vtest_block_read(renderer.in_fd, iovec->iov_base + offset, data_size);
if (ret < 0) if (ret < 0) {
return ret; return report_failed_call("vtest_block_read", ret);
}
ret = virgl_renderer_transfer_write_iov(handle, ret = virgl_renderer_transfer_write_iov(handle,
ctx_id, ctx_id,
@ -611,8 +630,10 @@ int vtest_transfer_put2(void)
&box, &box,
offset, offset,
NULL, 0); NULL, 0);
if (ret) if (ret) {
fprintf(stderr," transfer write failed %d\n", ret); return report_failed_call("virgl_renderer_transfer_write_iov", ret);
}
return 0; return 0;
} }

Loading…
Cancel
Save