]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - string/test-strcmp.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / string / test-strcmp.c
index 000c51091c6c22678c80023aa60afb110dd41f37..8d4772a6585ce7a723f04d1337624e49f3154466 100644 (file)
@@ -1,5 +1,5 @@
 /* Test and measure strcmp and wcscmp functions.
-   Copyright (C) 1999-2012 Free Software Foundation, Inc.
+   Copyright (C) 1999-2016 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Jakub Jelinek <jakub@redhat.com>, 1999.
    Added wcscmp support by Liubov Dmitrieva <liubov.dmitrieva@gmail.com>, 2011.
    <http://www.gnu.org/licenses/>.  */
 
 #define TEST_MAIN
+#ifdef WIDE
+# define TEST_NAME "wcscmp"
+#else
+# define TEST_NAME "strcmp"
+#endif
 #include "test-string.h"
 
 #ifdef WIDE
@@ -156,24 +161,6 @@ do_one_test (impl_t *impl,
 {
   if (check_result (impl, s1, s2, exp_result) < 0)
     return;
-
-  if (HP_TIMING_AVAIL)
-    {
-      hp_timing_t start __attribute ((unused));
-      hp_timing_t stop __attribute ((unused));
-      hp_timing_t best_time = ~ (hp_timing_t) 0;
-      size_t i;
-
-      for (i = 0; i < 32; ++i)
-       {
-         HP_TIMING_NOW (start);
-         CALL (impl, s1, s2);
-         HP_TIMING_NOW (stop);
-         HP_TIMING_BEST (best_time, start, stop);
-       }
-
-      printf ("\t%zd", (size_t) best_time);
-    }
 }
 
 static void
@@ -209,14 +196,8 @@ do_test (size_t align1, size_t align2, size_t len, int max_char,
   s2[len + 1] = 24 + exp_result;
   s2[len - 1] -= exp_result;
 
-  if (HP_TIMING_AVAIL)
-    printf ("Length %4zd, alignment %2zd/%2zd:", len, align1, align2);
-
   FOR_EACH_IMPL (impl, 0)
     do_one_test (impl, s1, s2, exp_result);
-
-  if (HP_TIMING_AVAIL)
-    putchar ('\n');
 }
 
 static void
@@ -348,6 +329,34 @@ check (void)
                FOR_EACH_IMPL (impl, 0)
                check_result (impl, s1 + i1, s2 + i2, exp_result);
       }
+
+  /* Test cases where there are multiple zero bytes after the first.  */
+
+  for (size_t i = 0; i < 16 + 1; i++)
+    {
+      s1[i] = 0x00;
+      s2[i] = 0x00;
+    }
+
+  for (size_t i = 0; i < 16; i++)
+    {
+      int exp_result;
+
+      for (int val = 0x01; val < 0x100; val++)
+       {
+         for (size_t j = 0; j < i; j++)
+           {
+             s1[j] = val;
+             s2[j] = val;
+           }
+
+         s2[i] = val;
+
+         exp_result = SIMPLE_STRCMP (s1, s2);
+         FOR_EACH_IMPL (impl, 0)
+           check_result (impl, s1, s2, exp_result);
+       }
+    }
 }