[glib/wip/smcv/aligned-alloc-tests: 2/3] tests: Make g_aligned_alloc tests fail if preconditions aren't checked




commit 38cdfe3c0233384d38556fff7bb1d5cd4cbe414b
Author: Simon McVittie <smcv collabora com>
Date:   Tue Feb 15 10:52:59 2022 +0000

    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>

 glib/tests/utils.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/glib/tests/utils.c b/glib/tests/utils.c
index 53fdbce9d..e712062f4 100644
--- a/glib/tests/utils.c
+++ b/glib/tests/utils.c
@@ -922,7 +922,7 @@ aligned_alloc_nz (void)
 
   /* Test an alignment that’s 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 that’s 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 that’s 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);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]