test/func/malloc: posix_memalign vs. size_t

posix_memalign requires that the alignment parameter be a multiple of
sizeof(uintptr_t), but the test begins with alignments as small as
sizeof(size_t).  While those are very likely the same value out in the
wild right now, they're not on CHERI.

Begin the test loop at sizeof(uintptr_t) and add a test that a request
for a reasonable amount of memory but with an alignment of
sizeof(uintptr_t)/2 fails with EINVAL.
This commit is contained in:
Nathaniel Filardo
2019-05-13 12:50:31 +01:00
parent 44f80c00fc
commit 0b47145526

View File

@@ -106,8 +106,9 @@ int main(int argc, char** argv)
test_posix_memalign(0, 0, EINVAL, true);
test_posix_memalign((size_t)-1, 0, EINVAL, true);
test_posix_memalign(OS_PAGE_SIZE, sizeof(uintptr_t) / 2, EINVAL, true);
for (size_t align = sizeof(size_t); align <= SUPERSLAB_SIZE; align <<= 1)
for (size_t align = sizeof(uintptr_t); align <= SUPERSLAB_SIZE; align <<= 1)
{
for (snmalloc::sizeclass_t sc = 0; sc < NUM_SIZECLASSES; sc++)
{