tests: Make g_aligned_alloc tests fail if preconditions aren't checked

Previously, these tests would always pass. If the precondition check
failed (as we want it to), the subprocess would exit unsuccessfully;
but if the precondition check wrongly passed, the subprocess would
continue, allocate a nonzero amount of memory, and fail the
g_assert_null(), resulting in the subprocess exiting unsuccessfully
and the test still passing.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2022-02-15 10:52:59 +00:00
parent d04f3491af
commit 38cdfe3c02

View File

@ -922,7 +922,7 @@ aligned_alloc_nz (void)
/* Test an alignment thats zero */
a = g_aligned_alloc (16, sizeof(char), 0);
g_assert_null (a);
g_aligned_free (a);
exit (0);
}
@ -933,7 +933,7 @@ aligned_alloc_npot (void)
/* Test an alignment thats not a power of two */
a = g_aligned_alloc (16, sizeof(char), 15);
g_assert_null (a);
g_aligned_free (a);
exit (0);
}
@ -944,7 +944,7 @@ aligned_alloc_nmov (void)
/* Test an alignment thats not a multiple of sizeof(void*) */
a = g_aligned_alloc (16, sizeof(char), sizeof(void *) / 2);
g_assert_null (a);
g_aligned_free (a);
exit (0);
}