vtest: add vtest_resource_busy_wait_nop for fuzzer

Let VTEST_FUZZER_FENCES control whether VCMD_RESOURCE_BUSY_WAIT waits or
not.  Fences are always created.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
macos/master
Chia-I Wu 4 years ago
parent 6543354118
commit a3e1ce9a91
  1. 1
      vtest/vtest.h
  2. 12
      vtest/vtest_fuzzer.c
  3. 24
      vtest/vtest_renderer.c

@ -74,6 +74,7 @@ int vtest_block_read(struct vtest_input *input, void *buf, int size);
int vtest_buf_read(struct vtest_input *input, void *buf, int size);
int vtest_resource_busy_wait(uint32_t length_dw);
int vtest_resource_busy_wait_nop(uint32_t length_dw);
int vtest_renderer_create_fence(void);
int vtest_poll(void);

@ -68,7 +68,7 @@ const char* __lsan_default_suppressions() {
typedef int (*vtest_cmd_fptr_t)(uint32_t);
static const vtest_cmd_fptr_t vtest_commands[] = {
static vtest_cmd_fptr_t vtest_commands[] = {
NULL /* CMD ids starts at 1 */,
vtest_send_caps,
vtest_create_resource,
@ -76,7 +76,7 @@ static const vtest_cmd_fptr_t vtest_commands[] = {
vtest_transfer_get_nop,
vtest_transfer_put_nop,
vtest_submit_cmd,
vtest_resource_busy_wait,
NULL, /* VCMD_RESOURCE_BUSY_WAIT is determined by VTEST_FUZZER_FENCES */
NULL, /* VCMD_CREATE_RENDERER is a specific case */
vtest_send_caps2,
vtest_ping_protocol_version,
@ -87,12 +87,15 @@ static const vtest_cmd_fptr_t vtest_commands[] = {
};
static void vtest_fuzzer_run_renderer(int out_fd, struct vtest_input *input,
int ctx_flags, bool create_fences)
int ctx_flags, bool wait_fences)
{
struct vtest_context *context = NULL;
int ret;
uint32_t header[VTEST_HDR_SIZE];
vtest_commands[VCMD_RESOURCE_BUSY_WAIT] = wait_fences ?
vtest_resource_busy_wait : vtest_resource_busy_wait_nop;
do {
ret = input->read(input, &header, sizeof(header));
if (ret < 0 || (size_t)ret < sizeof(header)) {
@ -135,8 +138,7 @@ static void vtest_fuzzer_run_renderer(int out_fd, struct vtest_input *input,
}
/* GL draws are fenced, while possible fence creations are too */
if (create_fences &&
(header[1] == VCMD_SUBMIT_CMD || header[1] == VCMD_RESOURCE_CREATE ||
if ((header[1] == VCMD_SUBMIT_CMD || header[1] == VCMD_RESOURCE_CREATE ||
header[1] == VCMD_RESOURCE_CREATE2))
vtest_renderer_create_fence();
} while (1);

@ -1414,6 +1414,30 @@ int vtest_resource_busy_wait(UNUSED uint32_t length_dw)
return 0;
}
int vtest_resource_busy_wait_nop(UNUSED uint32_t length_dw)
{
struct vtest_context *ctx = vtest_get_current_context();
uint32_t bw_buf[VCMD_BUSY_WAIT_SIZE];
uint32_t reply_buf[VTEST_HDR_SIZE + 1];
int ret;
ret = ctx->input->read(ctx->input, &bw_buf, sizeof(bw_buf));
if (ret != sizeof(bw_buf)) {
return -1;
}
reply_buf[VTEST_CMD_LEN] = 1;
reply_buf[VTEST_CMD_ID] = VCMD_RESOURCE_BUSY_WAIT;
reply_buf[VTEST_CMD_DATA_START] = 0;
ret = vtest_block_write(ctx->out_fd, reply_buf, sizeof(reply_buf));
if (ret < 0) {
return ret;
}
return 0;
}
int vtest_renderer_create_fence(void)
{
struct vtest_context *ctx = vtest_get_current_context();

Loading…
Cancel
Save