diff options
author | dmitry pervushin <dpervushin@gmail.com> | 2013-03-05 14:39:02 +0800 |
---|---|---|
committer | dmitry pervushin <dpervushin@gmail.com> | 2013-03-05 14:39:02 +0800 |
commit | 8020c6f237d9c8919661175009d603adb5430489 (patch) | |
tree | 251071e5af465f9d73e0fc227835f4f7e629e0a7 /ashmemtest-basic | |
parent | 69ced41d78cabe393d2faddd6a2c1c120df698bd (diff) | |
download | linaro-android-kernel-test-8020c6f237d9c8919661175009d603adb5430489.tar.gz |
If purge ioctl purged more pages than expected, treat this as warning but not error
Diffstat (limited to 'ashmemtest-basic')
-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"); |