]> Savannah Git Hosting - gnulib.git/commitdiff
rawmemchr tests: Add test case for last commit.
authorBruno Haible <bruno@clisp.org>
Sat, 11 Nov 2023 10:44:47 +0000 (11:44 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 11 Nov 2023 10:44:47 +0000 (11:44 +0100)
* tests/test-rawmemchr.c (main): Add test case for aligned oversized
read.

ChangeLog
tests/test-rawmemchr.c

index 83c1b520b9b7ccbfc7727567cede22db60ac7a2d..3ed337f6913d66ffeff7ac3ccf46423a8f23ea5e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-11-11  Bruno Haible  <bruno@clisp.org>
+
+       rawmemchr tests: Add test case for last commit.
+       * tests/test-rawmemchr.c (main): Add test case for aligned oversized
+       read.
+
 2023-11-11  Paul Eggert  <eggert@cs.ucla.edu>
 
        rawmemchr: port better to CHERI
index c2f6416e2619159c89d5d1c94cbdcc2671e31301..e32ff739a4d422f23b26e1fd2a89851c31931333 100644 (file)
@@ -88,5 +88,18 @@ main (void)
 
   free (input);
 
+  /* Test aligned oversized reads, which are allowed on most architectures
+     but not on CHERI.  */
+  {
+    input = malloc (5);
+    memcpy (input, "abcde", 5);
+    ASSERT (RAWMEMCHR (input, 'e') == input + 4);
+    ASSERT (RAWMEMCHR (input + 1, 'e') == input + 4);
+    ASSERT (RAWMEMCHR (input + 2, 'e') == input + 4);
+    ASSERT (RAWMEMCHR (input + 3, 'e') == input + 4);
+    ASSERT (RAWMEMCHR (input + 4, 'e') == input + 4);
+    free (input);
+  }
+
   return 0;
 }