MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / test_scan

Function test_scan

libs/qhttpserver/http-parser/test.c:3349–3464  ·  view source on GitHub ↗

SCAN through every possible breaking to make sure the * parser can handle getting the content in any chunks that * might come from the socket */

Source from the content-addressed store, hash-verified

3347 * might come from the socket
3348 */
3349void
3350test_scan (const struct message *r1, const struct message *r2, const struct message *r3)
3351{
3352 char total[80*1024] = "\0";
3353 char buf1[80*1024] = "\0";
3354 char buf2[80*1024] = "\0";
3355 char buf3[80*1024] = "\0";
3356
3357 strcat(total, r1->raw);
3358 strcat(total, r2->raw);
3359 strcat(total, r3->raw);
3360
3361 size_t read;
3362
3363 int total_len = strlen(total);
3364
3365 int total_ops = 2 * (total_len - 1) * (total_len - 2) / 2;
3366 int ops = 0 ;
3367
3368 size_t buf1_len, buf2_len, buf3_len;
3369 int message_count = count_parsed_messages(3, r1, r2, r3);
3370
3371 int i,j,type_both;
3372 for (type_both = 0; type_both < 2; type_both ++ ) {
3373 for (j = 2; j < total_len; j ++ ) {
3374 for (i = 1; i < j; i ++ ) {
3375
3376 if (ops % 1000 == 0) {
3377 printf("\b\b\b\b%3.0f%%", 100 * (float)ops /(float)total_ops);
3378 fflush(stdout);
3379 }
3380 ops += 1;
3381
3382 parser_init(type_both ? HTTP_BOTH : r1->type);
3383
3384 buf1_len = i;
3385 strlncpy(buf1, sizeof(buf1), total, buf1_len);
3386 buf1[buf1_len] = 0;
3387
3388 buf2_len = j - i;
3389 strlncpy(buf2, sizeof(buf1), total+i, buf2_len);
3390 buf2[buf2_len] = 0;
3391
3392 buf3_len = total_len - j;
3393 strlncpy(buf3, sizeof(buf1), total+j, buf3_len);
3394 buf3[buf3_len] = 0;
3395
3396 read = parse(buf1, buf1_len);
3397
3398 if (parser->upgrade) goto test;
3399
3400 if (read != buf1_len) {
3401 print_error(buf1, read);
3402 goto error;
3403 }
3404
3405 read += parse(buf2, buf2_len);
3406

Callers 1

mainFunction · 0.85

Calls 8

count_parsed_messagesFunction · 0.85
parser_initFunction · 0.85
strlncpyFunction · 0.85
parseFunction · 0.85
print_errorFunction · 0.85
upgrade_message_fixFunction · 0.85
message_eqFunction · 0.85
parser_freeFunction · 0.85

Tested by

no test coverage detected