[glib/ebassi/aligned-alloc] fixup! Add tests for g_aligned_alloc()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/ebassi/aligned-alloc] fixup! Add tests for g_aligned_alloc()
- Date: Fri, 11 Feb 2022 13:50:21 +0000 (UTC)
commit 9fe578f3caac6083cb047a8ef1f4bd7b3b502d3c
Author: Philip Withnall <pwithnall endlessos org>
Date: Fri Feb 11 13:36:57 2022 +0000
fixup! Add tests for g_aligned_alloc()
glib/tests/utils.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
---
diff --git a/glib/tests/utils.c b/glib/tests/utils.c
index cfc08279f..dcb35f75e 100644
--- a/glib/tests/utils.c
+++ b/glib/tests/utils.c
@@ -920,11 +920,23 @@ aligned_alloc_npot (void)
{
gpointer a;
+ /* Test an alignment that’s not a power of two */
a = g_aligned_alloc (16, sizeof(char), 15);
g_assert_null (a);
exit (0);
}
+static void
+aligned_alloc_nmov (void)
+{
+ gpointer a;
+
+ /* Test an alignment that’s not a multiple of sizeof(void*) */
+ a = g_aligned_alloc (16, sizeof(char), 4);
+ g_assert_null (a);
+ exit (0);
+}
+
static void
test_aligned_mem (void)
{
@@ -951,6 +963,7 @@ test_aligned_mem (void)
} while (0)
CHECK_SUBPROCESS_FAIL (aligned_alloc_npot, "Alignment must be a power of two");
+ CHECK_SUBPROCESS_FAIL (aligned_alloc_nmov, "Alignment must be a multiple of sizeof(void*)");
}
static void
@@ -1156,6 +1169,7 @@ main (int argc,
g_test_add_func ("/utils/misc-mem", test_misc_mem);
g_test_add_func ("/utils/aligned-mem", test_aligned_mem);
g_test_add_func ("/utils/aligned-mem/subprocess/aligned_alloc_npot", aligned_alloc_npot);
+ g_test_add_func ("/utils/aligned-mem/subprocess/aligned_alloc_nmov", aligned_alloc_nmov);
g_test_add_func ("/utils/aligned-mem/alignment", test_aligned_mem_alignment);
g_test_add_func ("/utils/aligned-mem/zeroed", test_aligned_mem_zeroed);
g_test_add_func ("/utils/nullify", test_nullify);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]