35 static int MemcmpTest01 (
void)
44 static int MemcmpTest02 (
void)
46 uint8_t a[] =
"abcdabcdabcdabcd";
47 uint8_t b[] =
"abcdabcdabcdabcd";
53 static int MemcmpTest03 (
void)
55 uint8_t a[] =
"abcdabcd";
56 uint8_t b[] =
"abcdabcd";
62 static int MemcmpTest04 (
void)
73 static int MemcmpTest05 (
void)
75 uint8_t a[] =
"abcdabcdabcdabcd";
76 uint8_t b[] =
"abcDabcdabcdabcd";
82 static int MemcmpTest06 (
void)
84 uint8_t a[] =
"abcdabcd";
85 uint8_t b[] =
"abcDabcd";
91 static int MemcmpTest07 (
void)
94 uint8_t b[] =
"abcde";
100 static int MemcmpTest08 (
void)
102 uint8_t a[] =
"abcdabcdabcdabcd";
103 uint8_t b[] =
"abcdabcdabcdabcde";
109 static int MemcmpTest09 (
void)
111 uint8_t a[] =
"abcdabcd";
112 uint8_t b[] =
"abcdabcde";
118 static int MemcmpTest10 (
void)
120 uint8_t a[] =
"abcd";
121 uint8_t b[] =
"Zbcde";
127 static int MemcmpTest11 (
void)
129 uint8_t a[] =
"abcdabcdabcdabcd";
130 uint8_t b[] =
"Zbcdabcdabcdabcde";
136 static int MemcmpTest12 (
void)
138 uint8_t a[] =
"abcdabcd";
139 uint8_t b[] =
"Zbcdabcde";
145 static int MemcmpTest13 (
void)
147 uint8_t a[] =
"abcdefgh";
148 uint8_t b[] =
"AbCdEfGhIjK";
150 FAIL_IF(SCMemcmpLowercase(a, b,
sizeof(a) - 1) != 0);
156 static int MemcmpTest14 (
void)
159 #define TEST_RUNS 1000000
160 uint64_t ticks_start = 0;
161 uint64_t ticks_end = 0;
162 const char *a[] = {
"0123456789012345",
"abc",
"abcdefghij",
"suricata",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
163 const char *b[] = {
"1234567890123456",
"abc",
"abcdefghik",
"suricatb",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
173 for (i = 0; a[i] != NULL; i++) {
175 size_t alen = strlen(a[i]) - 1;
177 for (j = 0; b[j] != NULL; j++) {
179 size_t blen = strlen(b[j]) - 1;
181 r1 += (memcmp((uint8_t *)a[i], (uint8_t *)b[j], (alen < blen) ? alen : blen) ? 1 : 0);
186 printf(
"memcmp(%d) \t\t\t%"PRIu64
"\n",
TEST_RUNS, ((uint64_t)(ticks_end - ticks_start))/
TEST_RUNS);
187 SCLogInfo(
"ticks passed %"PRIu64, ticks_end - ticks_start);
189 printf(
"r1 %d\n", r1);
195 static int MemcmpTest15 (
void)
198 uint64_t ticks_start = 0;
199 uint64_t ticks_end = 0;
200 const char *a[] = {
"0123456789012345",
"abc",
"abcdefghij",
"suricata",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
201 const char *b[] = {
"1234567890123456",
"abc",
"abcdefghik",
"suricatb",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
211 for (i = 0; a[i] != NULL; i++) {
213 size_t alen = strlen(a[i]) - 1;
215 for (j = 0; b[j] != NULL; j++) {
217 size_t blen = strlen(b[j]) - 1;
219 r2 += MemcmpLowercase((uint8_t *)a[i], (uint8_t *)b[j], (alen < blen) ? alen : blen);
224 printf(
"MemcmpLowercase(%d) \t\t%"PRIu64
"\n",
TEST_RUNS, ((uint64_t)(ticks_end - ticks_start))/
TEST_RUNS);
225 SCLogInfo(
"ticks passed %"PRIu64, ticks_end - ticks_start);
227 printf(
"r2 %d\n", r2);
233 static int MemcmpTest16 (
void)
236 uint64_t ticks_start = 0;
237 uint64_t ticks_end = 0;
238 const char *a[] = {
"0123456789012345",
"abc",
"abcdefghij",
"suricata",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
239 const char *b[] = {
"1234567890123456",
"abc",
"abcdefghik",
"suricatb",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
249 for (i = 0; a[i] != NULL; i++) {
251 size_t alen = strlen(a[i]) - 1;
253 for (j = 0; b[j] != NULL; j++) {
255 size_t blen = strlen(b[j]) - 1;
257 r3 +=
SCMemcmp((uint8_t *)a[i], (uint8_t *)b[j], (alen < blen) ? alen : blen);
262 printf(
"SCMemcmp(%d) \t\t\t%"PRIu64
"\n",
TEST_RUNS, ((uint64_t)(ticks_end - ticks_start))/
TEST_RUNS);
263 SCLogInfo(
"ticks passed %"PRIu64, ticks_end - ticks_start);
265 printf(
"r3 %d\n", r3);
271 static int MemcmpTest17 (
void)
274 uint64_t ticks_start = 0;
275 uint64_t ticks_end = 0;
276 const char *a[] = {
"0123456789012345",
"abc",
"abcdefghij",
"suricata",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
277 const char *b[] = {
"1234567890123456",
"abc",
"abcdefghik",
"suricatb",
"test",
"xyz",
"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr",
"abcdefghijklmnopqrstuvwxyz", NULL };
287 for (i = 0; a[i] != NULL; i++) {
289 size_t alen = strlen(a[i]) - 1;
291 for (j = 0; b[j] != NULL; j++) {
293 size_t blen = strlen(b[j]) - 1;
295 r4 += SCMemcmpLowercase((uint8_t *)a[i], (uint8_t *)b[j], (alen < blen) ? alen : blen);
300 printf(
"SCMemcmpLowercase(%d) \t\t%"PRIu64
"\n",
TEST_RUNS, ((uint64_t)(ticks_end - ticks_start))/
TEST_RUNS);
301 SCLogInfo(
"ticks passed %"PRIu64, ticks_end - ticks_start);
303 printf(
"r4 %d\n", r4);
314 {
"abcdefgh",
"!bcdefgh", 1, },
315 {
"?bcdefgh",
"!bcdefgh", 1, },
316 {
"!bcdefgh",
"abcdefgh", 1, },
317 {
"!bcdefgh",
"?bcdefgh", 1, },
318 {
"zbcdefgh",
"bbcdefgh", 1, },
320 {
"abcdefgh12345678",
"!bcdefgh12345678", 1, },
321 {
"?bcdefgh12345678",
"!bcdefgh12345678", 1, },
322 {
"!bcdefgh12345678",
"abcdefgh12345678", 1, },
323 {
"!bcdefgh12345678",
"?bcdefgh12345678", 1, },
324 {
"bbcdefgh12345678",
"zbcdefgh12345678", 1, },
326 {
"abcdefgh",
"abcdefgh", 0, },
327 {
"abcdefgh",
"Abcdefgh", 0, },
328 {
"abcdefgh12345678",
"Abcdefgh12345678", 0, },
334 static int MemcmpTest18 (
void)
338 while (t && t->
a != NULL) {