X-Git-Url: https://repo.jachan.dev/qemu.git/blobdiff_plain/d06cddf517d2b33389c02971b353d10dd4edda1a..27c7275a56948f48f536e2d1599b22355f5714ac:/tests/tcg/testthread.c diff --git a/tests/tcg/testthread.c b/tests/tcg/testthread.c index 27e4825bc6..810ba5de67 100644 --- a/tests/tcg/testthread.c +++ b/tests/tcg/testthread.c @@ -1,13 +1,19 @@ +#include #include #include #include -#include #include #include #include #include #include +void checked_write(int fd, const void *buf, size_t count) +{ + ssize_t rc = write(fd, buf, count); + assert(rc == count); +} + void *thread1_func(void *arg) { int i; @@ -15,7 +21,7 @@ void *thread1_func(void *arg) for(i=0;i<10;i++) { snprintf(buf, sizeof(buf), "thread1: %d %s\n", i, (char *)arg); - write(1, buf, strlen(buf)); + checked_write(1, buf, strlen(buf)); usleep(100 * 1000); } return NULL; @@ -27,7 +33,7 @@ void *thread2_func(void *arg) char buf[512]; for(i=0;i<20;i++) { snprintf(buf, sizeof(buf), "thread2: %d %s\n", i, (char *)arg); - write(1, buf, strlen(buf)); + checked_write(1, buf, strlen(buf)); usleep(150 * 1000); } return NULL;