summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Nelson <sam.nelson@ti.com>2018-11-06 16:44:51 -0500
committerSam Nelson <sam.nelson@ti.com>2018-12-20 08:06:16 -0500
commit7bb3739ca734ed9f288780c9c7935debff91b88b (patch)
tree8224f09f7c9b3784425c4b11127277da95ee7e42
parent45e3c2d4d9bdcce7d6f01cde5e54c6bdbd1a143b (diff)
downloadlinuxutils-7bb3739ca734ed9f288780c9c7935debff91b88b.tar.gz
apitest: Update to check for return value for allocPhys
Adds check for return value of zero and exit instead of going ahead with map. Signed-off-by: Sam Nelson <sam.nelson@ti.com>
-rw-r--r--src/cmem/tests/apitest.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/cmem/tests/apitest.c b/src/cmem/tests/apitest.c
index 8f5ef0b..a51a51e 100644
--- a/src/cmem/tests/apitest.c
+++ b/src/cmem/tests/apitest.c
@@ -652,16 +652,20 @@ int testAllocPhys(size_t size)
map_ptr = CMEM_map64(physp, size);
#else
physp = CMEM_allocPhys(size, NULL);
- map_ptr = CMEM_map(physp, size);
+ if (physp == 0) {
+ printf("testAllocPhys: CMEM_allocPhys failed\n");
+ goto cleanup;
+ }
+ map_ptr = CMEM_map(physp, size);
#endif
if (map_ptr == NULL) {
- printf("testAllocPhys: CMEM_map() failed\n");
- ret = 1;
- goto cleanup;
+ printf("testAllocPhys: CMEM_map() failed\n");
+ ret = 1;
+ goto cleanup;
}
else {
- printf("testAllocPhys: mapped physp %#llx to %p\n",
- physp, map_ptr);
+ printf("testAllocPhys: mapped physp %#llx to %p\n",
+ physp, map_ptr);
}
printf(" writing 0xdadaface to *map_ptr\n");
@@ -669,8 +673,8 @@ int testAllocPhys(size_t size)
printf(" *map_ptr = 0x%x\n", *map_ptr);
if (*map_ptr != 0xdadaface) {
- printf("testAllocPhys: failed, read didn't match write\n");
- ret = 1;
+ printf("testAllocPhys: failed, read didn't match write\n");
+ ret = 1;
}
printf(" unmapping %p\n", map_ptr);
@@ -683,9 +687,9 @@ int testAllocPhys(size_t size)
map_ptr = CMEM_map(physp, size * 0x10);
#endif
if (map_ptr != NULL) {
- printf("testAllocPhys: CMEM_map() should've failed but didn't\n");
- CMEM_unmap(map_ptr, size * 0x10);
- ret = 1;
+ printf("testAllocPhys: CMEM_map() should've failed but didn't\n");
+ CMEM_unmap(map_ptr, size * 0x10);
+ ret = 1;
}
cleanup: