diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-10-31 10:42:51 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2012-10-31 10:42:51 +0100 |
commit | f563a5d7a820424756f358e747238f03e866838a (patch) | |
tree | f78fa474b1933bd395af401a6d745150f4ecd15e /tests/tcg/testthread.c | |
parent | a27365265cc2fed1178bf25a205e8ee02a9c0caf (diff) | |
parent | aee0bf7d8d7564f8f2c40e4501695c492b7dd8d1 (diff) | |
download | qemu-f563a5d7a820424756f358e747238f03e866838a.tar.gz |
Merge remote-tracking branch 'origin/master' into threadpool
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/tcg/testthread.c')
-rw-r--r-- | tests/tcg/testthread.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/tcg/testthread.c b/tests/tcg/testthread.c index 27e4825bc6..2679af119a 100644 --- a/tests/tcg/testthread.c +++ b/tests/tcg/testthread.c @@ -1,3 +1,4 @@ +#include <assert.h> #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -8,6 +9,12 @@ #include <sys/wait.h> #include <sched.h> +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 +22,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 +34,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; |