about summary refs log tree commit diff
path: root/string
diff options
context:
space:
mode:
Diffstat (limited to 'string')
-rw-r--r--string/test-memcmp.c265
1 files changed, 261 insertions, 4 deletions
diff --git a/string/test-memcmp.c b/string/test-memcmp.c
index af07a5e599..3040e212ae 100644
--- a/string/test-memcmp.c
+++ b/string/test-memcmp.c
@@ -37,9 +37,9 @@ simple_memcmp (const char *s1, const char *s2, size_t n)
   return ret;
 }
 
-static void
-do_one_test (impl_t *impl, const char *s1, const char *s2, size_t len,
-	     int exp_result)
+static int
+check_result (impl_t *impl, const char *s1, const char *s2, size_t len,
+	      int exp_result)
 {
   int result = CALL (impl, s1, s2, len);
   if ((exp_result == 0 && result != 0)
@@ -49,9 +49,19 @@ do_one_test (impl_t *impl, const char *s1, const char *s2, size_t len,
       error (0, 0, "Wrong result in function %s %d %d", impl->name,
 	     result, exp_result);
       ret = 1;
-      return;
+      return -1;
     }
 
+  return 0;
+}
+
+static void
+do_one_test (impl_t *impl, const char *s1, const char *s2, size_t len,
+	     int exp_result)
+{
+  if (check_result (impl, s1, s2, len, exp_result) < 0)
+    return;
+
   if (HP_TIMING_AVAIL)
     {
       hp_timing_t start __attribute ((unused));
@@ -177,6 +187,251 @@ do_random_tests (void)
     }
 }
 
+static void
+check1 (void)
+{
+  char s1[116], s2[116];
+  int n, exp_result;
+
+  s1[0] = -108;
+  s2[0] = -108;
+  s1[1] = 99;
+  s2[1] = 99;
+  s1[2] = -113;
+  s2[2] = -113;
+  s1[3] = 1;
+  s2[3] = 1;
+  s1[4] = 116;
+  s2[4] = 116;
+  s1[5] = 99;
+  s2[5] = 99;
+  s1[6] = -113;
+  s2[6] = -113;
+  s1[7] = 1;
+  s2[7] = 1;
+  s1[8] = 84;
+  s2[8] = 84;
+  s1[9] = 99;
+  s2[9] = 99;
+  s1[10] = -113;
+  s2[10] = -113;
+  s1[11] = 1;
+  s2[11] = 1;
+  s1[12] = 52;
+  s2[12] = 52;
+  s1[13] = 99;
+  s2[13] = 99;
+  s1[14] = -113;
+  s2[14] = -113;
+  s1[15] = 1;
+  s2[15] = 1;
+  s1[16] = -76;
+  s2[16] = -76;
+  s1[17] = -14;
+  s2[17] = -14;
+  s1[18] = -109;
+  s2[18] = -109;
+  s1[19] = 1;
+  s2[19] = 1;
+  s1[20] = -108;
+  s2[20] = -108;
+  s1[21] = -14;
+  s2[21] = -14;
+  s1[22] = -109;
+  s2[22] = -109;
+  s1[23] = 1;
+  s2[23] = 1;
+  s1[24] = 84;
+  s2[24] = 84;
+  s1[25] = -15;
+  s2[25] = -15;
+  s1[26] = -109;
+  s2[26] = -109;
+  s1[27] = 1;
+  s2[27] = 1;
+  s1[28] = 52;
+  s2[28] = 52;
+  s1[29] = -15;
+  s2[29] = -15;
+  s1[30] = -109;
+  s2[30] = -109;
+  s1[31] = 1;
+  s2[31] = 1;
+  s1[32] = 20;
+  s2[32] = 20;
+  s1[33] = -15;
+  s2[33] = -15;
+  s1[34] = -109;
+  s2[34] = -109;
+  s1[35] = 1;
+  s2[35] = 1;
+  s1[36] = 20;
+  s2[36] = 20;
+  s1[37] = -14;
+  s2[37] = -14;
+  s1[38] = -109;
+  s2[38] = -109;
+  s1[39] = 1;
+  s2[39] = 1;
+  s1[40] = 52;
+  s2[40] = 52;
+  s1[41] = -14;
+  s2[41] = -14;
+  s1[42] = -109;
+  s2[42] = -109;
+  s1[43] = 1;
+  s2[43] = 1;
+  s1[44] = 84;
+  s2[44] = 84;
+  s1[45] = -14;
+  s2[45] = -14;
+  s1[46] = -109;
+  s2[46] = -109;
+  s1[47] = 1;
+  s2[47] = 1;
+  s1[48] = 116;
+  s2[48] = 116;
+  s1[49] = -14;
+  s2[49] = -14;
+  s1[50] = -109;
+  s2[50] = -109;
+  s1[51] = 1;
+  s2[51] = 1;
+  s1[52] = 116;
+  s2[52] = 116;
+  s1[53] = -15;
+  s2[53] = -15;
+  s1[54] = -109;
+  s2[54] = -109;
+  s1[55] = 1;
+  s2[55] = 1;
+  s1[56] = -44;
+  s2[56] = -44;
+  s1[57] = -14;
+  s2[57] = -14;
+  s1[58] = -109;
+  s2[58] = -109;
+  s1[59] = 1;
+  s2[59] = 1;
+  s1[60] = -108;
+  s2[60] = -108;
+  s1[61] = -15;
+  s2[61] = -15;
+  s1[62] = -109;
+  s2[62] = -109;
+  s1[63] = 1;
+  s2[63] = 1;
+  s1[64] = -76;
+  s2[64] = -76;
+  s1[65] = -15;
+  s2[65] = -15;
+  s1[66] = -109;
+  s2[66] = -109;
+  s1[67] = 1;
+  s2[67] = 1;
+  s1[68] = -44;
+  s2[68] = -44;
+  s1[69] = -15;
+  s2[69] = -15;
+  s1[70] = -109;
+  s2[70] = -109;
+  s1[71] = 1;
+  s2[71] = 1;
+  s1[72] = -12;
+  s2[72] = -12;
+  s1[73] = -15;
+  s2[73] = -15;
+  s1[74] = -109;
+  s2[74] = -109;
+  s1[75] = 1;
+  s2[75] = 1;
+  s1[76] = -12;
+  s2[76] = -12;
+  s1[77] = -14;
+  s2[77] = -14;
+  s1[78] = -109;
+  s2[78] = -109;
+  s1[79] = 1;
+  s2[79] = 1;
+  s1[80] = 20;
+  s2[80] = -68;
+  s1[81] = -12;
+  s2[81] = 64;
+  s1[82] = -109;
+  s2[82] = -106;
+  s1[83] = 1;
+  s2[83] = 1;
+  s1[84] = -12;
+  s2[84] = -12;
+  s1[85] = -13;
+  s2[85] = -13;
+  s1[86] = -109;
+  s2[86] = -109;
+  s1[87] = 1;
+  s2[87] = 1;
+  s1[88] = -44;
+  s2[88] = -44;
+  s1[89] = -13;
+  s2[89] = -13;
+  s1[90] = -109;
+  s2[90] = -109;
+  s1[91] = 1;
+  s2[91] = 1;
+  s1[92] = -76;
+  s2[92] = -76;
+  s1[93] = -13;
+  s2[93] = -13;
+  s1[94] = -109;
+  s2[94] = -109;
+  s1[95] = 1;
+  s2[95] = 1;
+  s1[96] = -108;
+  s2[96] = -108;
+  s1[97] = -13;
+  s2[97] = -13;
+  s1[98] = -109;
+  s2[98] = -109;
+  s1[99] = 1;
+  s2[99] = 1;
+  s1[100] = 116;
+  s2[100] = 116;
+  s1[101] = -13;
+  s2[101] = -13;
+  s1[102] = -109;
+  s2[102] = -109;
+  s1[103] = 1;
+  s2[103] = 1;
+  s1[104] = 84;
+  s2[104] = 84;
+  s1[105] = -13;
+  s2[105] = -13;
+  s1[106] = -109;
+  s2[106] = -109;
+  s1[107] = 1;
+  s2[107] = 1;
+  s1[108] = 52;
+  s2[108] = 52;
+  s1[109] = -13;
+  s2[109] = -13;
+  s1[110] = -109;
+  s2[110] = -109;
+  s1[111] = 1;
+  s2[111] = 1;
+  s1[112] = 20;
+  s2[112] = 20;
+  s1[113] = -13;
+  s2[113] = -13;
+  s1[114] = -109;
+  s2[114] = -109;
+  s1[115] = 1;
+  s2[115] = 1;
+
+  n = 116;
+  exp_result = simple_memcmp (s1, s2, n);
+  FOR_EACH_IMPL (impl, 0)
+    check_result (impl, s1, s2, n, exp_result);
+}
+
 int
 test_main (void)
 {
@@ -184,6 +439,8 @@ test_main (void)
 
   test_init ();
 
+  check1 ();
+
   printf ("%23s", "");
   FOR_EACH_IMPL (impl, 0)
     printf ("\t%s", impl->name);