diff options
author | Joe Simmons-Talbott <josimmon@redhat.com> | 2024-05-14 14:36:50 +0000 |
---|---|---|
committer | Arjun Shankar <arjun@redhat.com> | 2024-06-10 17:10:02 +0200 |
commit | a2da98aa2a13b1bde7fd3a98f31b04ddecfafa8f (patch) | |
tree | cb953aa0ca22e6081fc32aff6cc9f786e4a9438e /malloc/tst-malloc.c | |
parent | 305ee48826961b9b2ad2b2fb36ec19622d8e1d77 (diff) | |
download | glibc-a2da98aa2a13b1bde7fd3a98f31b04ddecfafa8f.zip glibc-a2da98aa2a13b1bde7fd3a98f31b04ddecfafa8f.tar.gz glibc-a2da98aa2a13b1bde7fd3a98f31b04ddecfafa8f.tar.bz2 |
malloc: Improve aligned_alloc and calloc test coverage.
Add a DSO (malloc/tst-aligned_alloc-lib.so) that can be used during
testing to interpose malloc with a call that randomly uses either
aligned_alloc, __libc_malloc, or __libc_calloc in the place of malloc.
Use LD_PRELOAD with the DSO to mirror malloc/tst-malloc.c testing as an
example in malloc/tst-malloc-random.c. Add malloc/tst-aligned-alloc-random.c
as another example that does a number of malloc calls with randomly sized,
but limited to 0xffff, requests.
The intention is to be able to utilize existing malloc testing to ensure
that similar allocation APIs are also exposed to the same rigors.
Reviewed-by: DJ Delorie <dj@redhat.com>
(cherry picked from commit 3395157ff2b0657d70c36169156f67440205c8bf)
Diffstat (limited to 'malloc/tst-malloc.c')
-rw-r--r-- | malloc/tst-malloc.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/malloc/tst-malloc.c b/malloc/tst-malloc.c index a7491d3..f7a6e46 100644 --- a/malloc/tst-malloc.c +++ b/malloc/tst-malloc.c @@ -18,7 +18,9 @@ #include <errno.h> #include <malloc.h> #include <stdio.h> +#include <stdlib.h> #include <libc-diag.h> +#include <time.h> static int errors = 0; @@ -35,6 +37,8 @@ do_test (void) void *p, *q; int save; + srandom (time (NULL)); + errno = 0; DIAG_PUSH_NEEDS_COMMENT; |