]> sourceware.org Git - valgrind.git/commitdiff
Linux regtest: Update aligned_alloc test for GNU libc 2.38
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 10 Sep 2023 15:53:05 +0000 (15:53 +0000)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 10 Sep 2023 15:53:05 +0000 (15:53 +0000)
memcheck/tests/linux/Makefile.am
memcheck/tests/linux/aligned_alloc.c
memcheck/tests/linux/aligned_alloc.stderr.exp-glibc238 [new file with mode: 0644]

index 3e805bcf786d220c1ce4911ed934447b128867c9..53c266e48fc8c5e2e87fe9fada33050b107c7d25 100644 (file)
@@ -6,6 +6,7 @@ dist_noinst_SCRIPTS = filter_stderr
 EXTRA_DIST = \
        aligned_alloc.vgtest aligned_alloc.stderr.exp \
                aligned_alloc.stderr.exp-musl \
+               aligned_alloc.stderr.exp-glibc238 \
        brk.stderr.exp brk.vgtest \
        capget.vgtest capget.stderr.exp capget.stderr.exp2 capget.stderr.exp3 \
        debuginfod-check.stderr.exp debuginfod-check.vgtest.in \
index efe4672efc44114db29ea50f37e239c0a31cd82a..a4bb995f7cac3c99b46c115c3f43d915f3d6ceda 100644 (file)
@@ -5,9 +5,25 @@
 
 int main(void)
 {
-#if defined(MUSL_LIBC)
+#if defined (HAVE_GNU_LIBC_C17_ALIGNED_ALLOC)
    char* p = NULL;
 
+   // zero size
+   p = aligned_alloc(0, 8);
+   assert(p == NULL);
+
+   // non multiple of alignment
+   p = aligned_alloc(8, 25);
+   assert(p && ((size_t)p % 8U == 0U));
+   free(p);
+
+   // align not power of 2
+   p = aligned_alloc(40, 160);
+   assert(p == NULL);
+   errno = 0;
+#endif
+#if defined(MUSL_LIBC)
+   char* p = NULL;
 
    // zero size
    p = aligned_alloc(0, 8);
diff --git a/memcheck/tests/linux/aligned_alloc.stderr.exp-glibc238 b/memcheck/tests/linux/aligned_alloc.stderr.exp-glibc238
new file mode 100644 (file)
index 0000000..35e0eff
--- /dev/null
@@ -0,0 +1,8 @@
+Invalid size value: 25 alignment value: 8 (size should be a multiple of alignment)
+   at 0x........: aligned_alloc (vg_replace_malloc.c:...)
+   by 0x........: main (aligned_alloc.c:16)
+
+Invalid alignment value: 40 (should be a power of 2)
+   at 0x........: aligned_alloc (vg_replace_malloc.c:...)
+   by 0x........: main (aligned_alloc.c:21)
+
This page took 0.033874 seconds and 5 git commands to generate.