36 static int MemcmpTest01 (
void)
45 static int MemcmpTest02 (
void)
47 uint8_t a[] =
"abcdabcdabcdabcd";
48 uint8_t b[] =
"abcdabcdabcdabcd";
54 static int MemcmpTest03 (
void)
56 uint8_t a[] =
"abcdabcd";
57 uint8_t b[] =
"abcdabcd";
63 static int MemcmpTest04 (
void)
74 static int MemcmpTest05 (
void)
76 uint8_t a[] =
"abcdabcdabcdabcd";
77 uint8_t b[] =
"abcDabcdabcdabcd";
83 static int MemcmpTest06 (
void)
85 uint8_t a[] =
"abcdabcd";
86 uint8_t b[] =
"abcDabcd";
92 static int MemcmpTest07 (
void)
95 uint8_t b[] =
"abcde";
101 static int MemcmpTest08 (
void)
103 uint8_t a[] =
"abcdabcdabcdabcd";
104 uint8_t b[] =
"abcdabcdabcdabcde";
110 static int MemcmpTest09 (
void)
112 uint8_t a[] =
"abcdabcd";
113 uint8_t b[] =
"abcdabcde";
119 static int MemcmpTest10 (
void)
121 uint8_t a[] =
"abcd";
122 uint8_t b[] =
"Zbcde";
128 static int MemcmpTest11 (
void)
130 uint8_t a[] =
"abcdabcdabcdabcd";
131 uint8_t b[] =
"Zbcdabcdabcdabcde";
137 static int MemcmpTest12 (
void)
139 uint8_t a[] =
"abcdabcd";
140 uint8_t b[] =
"Zbcdabcde";
146 static int MemcmpTest13 (
void)
148 uint8_t a[] =
"abcdefgh";
149 uint8_t b[] =
"AbCdEfGhIjK";
151 FAIL_IF(SCMemcmpLowercase(a, b,
sizeof(a) - 1) != 0);
157 #define TEST_RUNS 1000000
159 static int MemcmpTest14 (
void)
162 uint64_t ticks_start = 0;
163 uint64_t ticks_end = 0;
164 const char *a[] = {
"0123456789012345",
"abc",
"abcdefghij",
"suricata",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
165 const char *b[] = {
"1234567890123456",
"abc",
"abcdefghik",
"suricatb",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
175 for (i = 0; a[i] != NULL; i++) {
177 size_t alen = strlen(a[i]) - 1;
179 for (j = 0; b[j] != NULL; j++) {
181 size_t blen = strlen(b[j]) - 1;
183 r1 += (memcmp((uint8_t *)a[i], (uint8_t *)b[j], (alen < blen) ? alen : blen) ? 1 : 0);
188 printf(
"memcmp(%d) \t\t\t%"PRIu64
"\n",
TEST_RUNS, ((uint64_t)(ticks_end - ticks_start))/
TEST_RUNS);
189 SCLogInfo(
"ticks passed %"PRIu64, ticks_end - ticks_start);
191 printf(
"r1 %d\n", r1);
197 static int MemcmpTest15 (
void)
200 uint64_t ticks_start = 0;
201 uint64_t ticks_end = 0;
202 const char *a[] = {
"0123456789012345",
"abc",
"abcdefghij",
"suricata",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
203 const char *b[] = {
"1234567890123456",
"abc",
"abcdefghik",
"suricatb",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
213 for (i = 0; a[i] != NULL; i++) {
215 size_t alen = strlen(a[i]) - 1;
217 for (j = 0; b[j] != NULL; j++) {
219 size_t blen = strlen(b[j]) - 1;
221 r2 += MemcmpLowercase((uint8_t *)a[i], (uint8_t *)b[j], (alen < blen) ? alen : blen);
226 printf(
"MemcmpLowercase(%d) \t\t%"PRIu64
"\n",
TEST_RUNS, ((uint64_t)(ticks_end - ticks_start))/
TEST_RUNS);
227 SCLogInfo(
"ticks passed %"PRIu64, ticks_end - ticks_start);
229 printf(
"r2 %d\n", r2);
235 static int MemcmpTest16 (
void)
238 uint64_t ticks_start = 0;
239 uint64_t ticks_end = 0;
240 const char *a[] = {
"0123456789012345",
"abc",
"abcdefghij",
"suricata",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
241 const char *b[] = {
"1234567890123456",
"abc",
"abcdefghik",
"suricatb",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
251 for (i = 0; a[i] != NULL; i++) {
253 size_t alen = strlen(a[i]) - 1;
255 for (j = 0; b[j] != NULL; j++) {
257 size_t blen = strlen(b[j]) - 1;
259 r3 +=
SCMemcmp((uint8_t *)a[i], (uint8_t *)b[j], (alen < blen) ? alen : blen);
264 printf(
"SCMemcmp(%d) \t\t\t%"PRIu64
"\n",
TEST_RUNS, ((uint64_t)(ticks_end - ticks_start))/
TEST_RUNS);
265 SCLogInfo(
"ticks passed %"PRIu64, ticks_end - ticks_start);
267 printf(
"r3 %d\n", r3);
273 static int MemcmpTest17 (
void)
276 uint64_t ticks_start = 0;
277 uint64_t ticks_end = 0;
278 const char *a[] = {
"0123456789012345",
"abc",
"abcdefghij",
"suricata",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
279 const char *b[] = {
"1234567890123456",
"abc",
"abcdefghik",
"suricatb",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
289 for (i = 0; a[i] != NULL; i++) {
291 size_t alen = strlen(a[i]) - 1;
293 for (j = 0; b[j] != NULL; j++) {
295 size_t blen = strlen(b[j]) - 1;
297 r4 += SCMemcmpLowercase((uint8_t *)a[i], (uint8_t *)b[j], (alen < blen) ? alen : blen);
302 printf(
"SCMemcmpLowercase(%d) \t\t%"PRIu64
"\n",
TEST_RUNS, ((uint64_t)(ticks_end - ticks_start))/
TEST_RUNS);
303 SCLogInfo(
"ticks passed %"PRIu64, ticks_end - ticks_start);
305 printf(
"r4 %d\n", r4);
316 {
"abcdefgh",
"!bcdefgh", 1, },
317 {
"?bcdefgh",
"!bcdefgh", 1, },
318 {
"!bcdefgh",
"abcdefgh", 1, },
319 {
"!bcdefgh",
"?bcdefgh", 1, },
320 {
"zbcdefgh",
"bbcdefgh", 1, },
322 {
"abcdefgh12345678",
"!bcdefgh12345678", 1, },
323 {
"?bcdefgh12345678",
"!bcdefgh12345678", 1, },
324 {
"!bcdefgh12345678",
"abcdefgh12345678", 1, },
325 {
"!bcdefgh12345678",
"?bcdefgh12345678", 1, },
326 {
"bbcdefgh12345678",
"zbcdefgh12345678", 1, },
328 {
"abcdefgh",
"abcdefgh", 0, },
329 {
"abcdefgh",
"Abcdefgh", 0, },
330 {
"abcdefgh12345678",
"Abcdefgh12345678", 0, },
336 static int MemcmpTest18 (
void)
340 while (t && t->
a != NULL) {