diff options
Diffstat (limited to 'ashmemtest-basic/ashmemtest.c')
-rw-r--r-- | ashmemtest-basic/ashmemtest.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ashmemtest-basic/ashmemtest.c b/ashmemtest-basic/ashmemtest.c index 8d1be39..f86a50f 100644 --- a/ashmemtest-basic/ashmemtest.c +++ b/ashmemtest-basic/ashmemtest.c @@ -462,7 +462,8 @@ void ashmem_purge (void) { void *mem; struct ashmem_pin pin; - int i, fd, ret, size = pagesize * 16; + const int count = 16; + int i, fd, ret, size = pagesize * count; testno++; strcpy(testname, __func__); @@ -473,20 +474,23 @@ void ashmem_purge (void) if (mem == MAP_FAILED) fatal (errno, "can't map ashmem region"); /* unpin all odd pages */ - for (i = 1; i < 16; i += 2) { + for (i = 1; i < count; i += 2) { pin.offset = i * pagesize; pin.len = pagesize; ret = ioctl (fd, ASHMEM_UNPIN, &pin); if (ret < 0) - fatal (errno, "can't unpin page %d of 16", i); + fatal (errno, "can't unpin page %d of %d", i, count); } /* purge should release 8 pages */ ret = ioctl (fd, ASHMEM_PURGE_ALL_CACHES); - if (ret != 8) { + if (ret != count / 2) { if (ret < 0) fatal (errno, "can't purge caches"); + else if (ret < count / 2) + fatal (0, "purge %d pages, but expect %d", ret, count / 2); else - fatal (0, "purge %d pages, but expect 8", ret); + printf("%d [%s]: warning: purged more pages (%d) than expected (%d), probably somebody else does the same....", + testno, __func__, ret, count / 2); } if (munmap (mem, size)) fatal (errno, "can't unmap ashmem region"); |