From 54d8c08748822d9a55f1f59a5c64fa660592bdcf Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 16 Mar 2015 15:36:22 +1000 Subject: vtest: support forking renderers. this should allow running piglits in parallel --- vtest/vtest_renderer.c | 1 + vtest/vtest_server.c | 48 ++++++++++++++++++++++++++++++------------------ 2 files changed, 31 insertions(+), 18 deletions(-) (limited to 'vtest') diff --git a/vtest/vtest_renderer.c b/vtest/vtest_renderer.c index a8a5184..41836b8 100644 --- a/vtest/vtest_renderer.c +++ b/vtest/vtest_renderer.c @@ -243,6 +243,7 @@ int vtest_transfer_put(uint32_t length_dw) uint32_t data_size; void *ptr; struct iovec iovec; + ret = vtest_block_read(renderer.remote_fd, thdr_buf, VCMD_TRANSFER_HDR_SIZE * 4); if (ret != VCMD_TRANSFER_HDR_SIZE * 4) return ret; diff --git a/vtest/vtest_server.c b/vtest/vtest_server.c index af36272..0a2ee9a 100644 --- a/vtest/vtest_server.c +++ b/vtest/vtest_server.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -71,32 +72,26 @@ int wait_for_socket_read(int sock) if (ret < 0) return ret; - if (FD_ISSET(sock, &read_fds)) { + if (FD_ISSET(sock, &read_fds)) { return 0; } return -1; } -int main(void) +int run_renderer(int new_fd) { - int sock, new_fd, ret; + int ret; uint32_t header[VTEST_HDR_SIZE]; - static int fence_id = 1; bool do_fence; - sock = vtest_open_socket("/tmp/.virgl_test"); -restart: - new_fd = wait_for_socket_accept(sock); - vtest_create_renderer(new_fd); again: ret = wait_for_socket_read(new_fd); if (ret < 0) - goto err; + goto fail; ret = vtest_block_read(new_fd, &header, sizeof(header)); if (ret == 8) { - fprintf(stderr, "got length: %d cmd: %d\n", header[0], header[1]); vtest_poll(); do_fence = false; switch (header[1]) { @@ -127,10 +122,7 @@ again: } if (ret < 0) { - fprintf(stderr, "socket failed - relistening\n"); - close(new_fd); - vtest_destroy_renderer(); - goto restart; + goto fail; } if (do_fence) @@ -138,12 +130,32 @@ again: goto again; } if (ret <= 0) { - fprintf(stderr, "socket failed - relistening\n"); + goto fail; + } +fail: + fprintf(stderr, "socket failed - closing renderer\n"); + vtest_destroy_renderer(); + close(new_fd); + exit(0); +} + +int main(void) +{ + int sock, new_fd, ret; + pid_t pid; + sock = vtest_open_socket("/tmp/.virgl_test"); +restart: + new_fd = wait_for_socket_accept(sock); + + /* fork a renderer process */ + switch ((pid = fork())) { + case 0: + run_renderer(new_fd); + break; + case -1: + default: close(new_fd); - vtest_destroy_renderer(); goto restart; } -err: - close(new_fd); close(sock); } -- cgit v1.2.3