diff options
author | ivmai <ivmai> | 2011-06-03 13:25:31 +0000 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2011-07-25 16:03:26 +0400 |
commit | d13bfe0bee0d7f9c32c6f9af926ad5d829e6362d (patch) | |
tree | 9c5401be6455c14c758d05f225d013ba006012ab | |
parent | 2e595ad73f53910e4c6da969cab898b2a649d437 (diff) | |
download | libatomic_ops-d13bfe0bee0d7f9c32c6f9af926ad5d829e6362d.tar.gz |
2011-06-03 Ivan Maidanski <ivmai@mail.ru>
* tests/test_malloc.c (run_one_test): Test AO_malloc() result
(if out of memory then print the message and abort).
* tests/test_stack.c (add_elements): Ditto.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | tests/test_malloc.c | 6 | ||||
-rw-r--r-- | tests/test_stack.c | 5 |
3 files changed, 17 insertions, 0 deletions
@@ -1,5 +1,11 @@ 2011-06-03 Ivan Maidanski <ivmai@mail.ru> + * tests/test_malloc.c (run_one_test): Test AO_malloc() result + (if out of memory then print the message and abort). + * tests/test_stack.c (add_elements): Ditto. + +2011-06-03 Ivan Maidanski <ivmai@mail.ru> + * src/atomic_ops/generalize.h (AO_HAVE_or_full): Add missing definition. * src/atomic_ops/sysdeps/ordered_except_wr.h (AO_HAVE_nop_write): diff --git a/tests/test_malloc.c b/tests/test_malloc.c index f7df342..4bf6e6c 100644 --- a/tests/test_malloc.c +++ b/tests/test_malloc.c @@ -150,6 +150,12 @@ void * run_one_test(void * arg) { } else { p[0] = p[LARGE_OBJ_SIZE/2] = p[LARGE_OBJ_SIZE-1] = 'a'; q = AO_malloc(LARGE_OBJ_SIZE); + if (q == 0) + { + fprintf(stderr, "Out of memory\n"); + /* Normal for more than about 10 threads without mmap? */ + abort(); + } q[0] = q[LARGE_OBJ_SIZE/2] = q[LARGE_OBJ_SIZE-1] = 'b'; if (p[0] != 'a' || p[LARGE_OBJ_SIZE/2] != 'a' || p[LARGE_OBJ_SIZE-1] != 'a') { diff --git a/tests/test_stack.c b/tests/test_stack.c index a190a78..a51d244 100644 --- a/tests/test_stack.c +++ b/tests/test_stack.c @@ -54,6 +54,11 @@ void add_elements(int n) if (n == 0) return; add_elements(n-1); le = malloc(sizeof(list_element)); + if (le == 0) + { + fprintf(stderr, "Out of memory\n"); + abort(); + } le -> data = n; AO_stack_push(&the_list, (AO_t *)le); } |