vtest: support forking renderers.

this should allow running piglits in parallel
macos/master
Dave Airlie 10 years ago
parent 40c6352233
commit 54d8c08748
  1. 1
      vtest/vtest_renderer.c
  2. 46
      vtest/vtest_server.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;

@ -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>
@ -77,26 +78,20 @@ int wait_for_socket_read(int sock)
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);
}

Loading…
Cancel
Save