Loading tests/tcg/test-mmap.c +13 −5 Original line number Diff line number Diff line Loading @@ -429,6 +429,12 @@ void check_file_fixed_mmaps(void) fprintf (stderr, " passed\n"); } void checked_write(int fd, const void *buf, size_t count) { ssize_t rc = write(fd, buf, count); fail_unless(rc == count); } int main(int argc, char **argv) { char tempname[] = "/tmp/.cmmapXXXXXX"; Loading @@ -450,13 +456,15 @@ int main(int argc, char **argv) unlink(tempname); /* Fill the file with int's counting from zero and up. */ for (i = 0; i < (pagesize * 4) / sizeof i; i++) write (test_fd, &i, sizeof i); for (i = 0; i < (pagesize * 4) / sizeof i; i++) { checked_write(test_fd, &i, sizeof i); } /* Append a few extra writes to make the file end at non page boundary. */ write (test_fd, &i, sizeof i); i++; write (test_fd, &i, sizeof i); i++; write (test_fd, &i, sizeof i); i++; checked_write(test_fd, &i, sizeof i); i++; checked_write(test_fd, &i, sizeof i); i++; checked_write(test_fd, &i, sizeof i); i++; test_fsize = lseek(test_fd, 0, SEEK_CUR); Loading tests/tcg/testthread.c +9 −2 Original line number Diff line number Diff line #include <assert.h> #include <stdlib.h> #include <stdio.h> #include <string.h> Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading Loading
tests/tcg/test-mmap.c +13 −5 Original line number Diff line number Diff line Loading @@ -429,6 +429,12 @@ void check_file_fixed_mmaps(void) fprintf (stderr, " passed\n"); } void checked_write(int fd, const void *buf, size_t count) { ssize_t rc = write(fd, buf, count); fail_unless(rc == count); } int main(int argc, char **argv) { char tempname[] = "/tmp/.cmmapXXXXXX"; Loading @@ -450,13 +456,15 @@ int main(int argc, char **argv) unlink(tempname); /* Fill the file with int's counting from zero and up. */ for (i = 0; i < (pagesize * 4) / sizeof i; i++) write (test_fd, &i, sizeof i); for (i = 0; i < (pagesize * 4) / sizeof i; i++) { checked_write(test_fd, &i, sizeof i); } /* Append a few extra writes to make the file end at non page boundary. */ write (test_fd, &i, sizeof i); i++; write (test_fd, &i, sizeof i); i++; write (test_fd, &i, sizeof i); i++; checked_write(test_fd, &i, sizeof i); i++; checked_write(test_fd, &i, sizeof i); i++; checked_write(test_fd, &i, sizeof i); i++; test_fsize = lseek(test_fd, 0, SEEK_CUR); Loading
tests/tcg/testthread.c +9 −2 Original line number Diff line number Diff line #include <assert.h> #include <stdlib.h> #include <stdio.h> #include <string.h> Loading @@ -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; Loading @@ -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; Loading @@ -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; Loading