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 static int MemcmpTest14 (
void)
160 #define TEST_RUNS 1000000
161 uint64_t ticks_start = 0;
162 uint64_t ticks_end = 0;
163 const char *a[] = {
"0123456789012345",
"abc",
"abcdefghij",
"suricata",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
164 const char *b[] = {
"1234567890123456",
"abc",
"abcdefghik",
"suricatb",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
174 for (i = 0; a[i] != NULL; i++) {
176 size_t alen = strlen(a[i]) - 1;
178 for (j = 0; b[j] != NULL; j++) {
180 size_t blen = strlen(b[j]) - 1;
182 r1 += (memcmp((uint8_t *)a[i], (uint8_t *)b[j], (alen < blen) ? alen : blen) ? 1 : 0);
187 printf(
"memcmp(%d) \t\t\t%"PRIu64
"\n",
TEST_RUNS, ((uint64_t)(ticks_end - ticks_start))/
TEST_RUNS);
188 SCLogInfo(
"ticks passed %"PRIu64, ticks_end - ticks_start);
190 printf(
"r1 %d\n", r1);
196 static int MemcmpTest15 (
void)
199 uint64_t ticks_start = 0;
200 uint64_t ticks_end = 0;
201 const char *a[] = {
"0123456789012345",
"abc",
"abcdefghij",
"suricata",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
202 const char *b[] = {
"1234567890123456",
"abc",
"abcdefghik",
"suricatb",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
212 for (i = 0; a[i] != NULL; i++) {
214 size_t alen = strlen(a[i]) - 1;
216 for (j = 0; b[j] != NULL; j++) {
218 size_t blen = strlen(b[j]) - 1;
220 r2 += MemcmpLowercase((uint8_t *)a[i], (uint8_t *)b[j], (alen < blen) ? alen : blen);
225 printf(
"MemcmpLowercase(%d) \t\t%"PRIu64
"\n",
TEST_RUNS, ((uint64_t)(ticks_end - ticks_start))/
TEST_RUNS);
226 SCLogInfo(
"ticks passed %"PRIu64, ticks_end - ticks_start);
228 printf(
"r2 %d\n", r2);
234 static int MemcmpTest16 (
void)
237 uint64_t ticks_start = 0;
238 uint64_t ticks_end = 0;
239 const char *a[] = {
"0123456789012345",
"abc",
"abcdefghij",
"suricata",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
240 const char *b[] = {
"1234567890123456",
"abc",
"abcdefghik",
"suricatb",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
250 for (i = 0; a[i] != NULL; i++) {
252 size_t alen = strlen(a[i]) - 1;
254 for (j = 0; b[j] != NULL; j++) {
256 size_t blen = strlen(b[j]) - 1;
258 r3 +=
SCMemcmp((uint8_t *)a[i], (uint8_t *)b[j], (alen < blen) ? alen : blen);
263 printf(
"SCMemcmp(%d) \t\t\t%"PRIu64
"\n",
TEST_RUNS, ((uint64_t)(ticks_end - ticks_start))/
TEST_RUNS);
264 SCLogInfo(
"ticks passed %"PRIu64, ticks_end - ticks_start);
266 printf(
"r3 %d\n", r3);
272 static int MemcmpTest17 (
void)
275 uint64_t ticks_start = 0;
276 uint64_t ticks_end = 0;
277 const char *a[] = {
"0123456789012345",
"abc",
"abcdefghij",
"suricata",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
278 const char *b[] = {
"1234567890123456",
"abc",
"abcdefghik",
"suricatb",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
288 for (i = 0; a[i] != NULL; i++) {
290 size_t alen = strlen(a[i]) - 1;
292 for (j = 0; b[j] != NULL; j++) {
294 size_t blen = strlen(b[j]) - 1;
296 r4 += SCMemcmpLowercase((uint8_t *)a[i], (uint8_t *)b[j], (alen < blen) ? alen : blen);
301 printf(
"SCMemcmpLowercase(%d) \t\t%"PRIu64
"\n",
TEST_RUNS, ((uint64_t)(ticks_end - ticks_start))/
TEST_RUNS);
302 SCLogInfo(
"ticks passed %"PRIu64, ticks_end - ticks_start);
304 printf(
"r4 %d\n", r4);
315 {
"abcdefgh",
"!bcdefgh", 1, },
316 {
"?bcdefgh",
"!bcdefgh", 1, },
317 {
"!bcdefgh",
"abcdefgh", 1, },
318 {
"!bcdefgh",
"?bcdefgh", 1, },
319 {
"zbcdefgh",
"bbcdefgh", 1, },
321 {
"abcdefgh12345678",
"!bcdefgh12345678", 1, },
322 {
"?bcdefgh12345678",
"!bcdefgh12345678", 1, },
323 {
"!bcdefgh12345678",
"abcdefgh12345678", 1, },
324 {
"!bcdefgh12345678",
"?bcdefgh12345678", 1, },
325 {
"bbcdefgh12345678",
"zbcdefgh12345678", 1, },
327 {
"abcdefgh",
"abcdefgh", 0, },
328 {
"abcdefgh",
"Abcdefgh", 0, },
329 {
"abcdefgh12345678",
"Abcdefgh12345678", 0, },
335 static int MemcmpTest18 (
void)
339 while (t && t->
a != NULL) {