diff options
author | Dave Airlie <airlied@gmail.com> | 2015-03-16 15:36:22 +1000 |
---|---|---|
committer | Dave Airlie <airlied@gmail.com> | 2015-03-17 08:32:39 +1000 |
commit | 54d8c08748822d9a55f1f59a5c64fa660592bdcf (patch) | |
tree | 99ed96088f47ed5a835bf589a676d35b5add9124 /vtest | |
parent | 40c63522337245cb6093e206dcce5cd4afdd87d2 (diff) |
vtest: support forking renderers.
this should allow running piglits in parallel
Diffstat (limited to 'vtest')
-rw-r--r-- | vtest/vtest_renderer.c | 1 | ||||
-rw-r--r-- | vtest/vtest_server.c | 48 |
2 files changed, 31 insertions, 18 deletions
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 <stdio.h> #include <stdbool.h> #include <unistd.h> +#include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> @@ -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); } |