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

Function test_message_pause

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

Verify that we can pause parsing at any of the bytes in the * message and still get the result that we're expecting. */

Source from the content-addressed store, hash-verified

3497/* Verify that we can pause parsing at any of the bytes in the
3498 * message and still get the result that we're expecting. */
3499void
3500test_message_pause (const struct message *msg)
3501{
3502 char *buf = (char*) msg->raw;
3503 size_t buflen = strlen(msg->raw);
3504 size_t nread;
3505
3506 parser_init(msg->type);
3507
3508 do {
3509 nread = parse_pause(buf, buflen);
3510
3511 // We can only set the upgrade buffer once we've gotten our message
3512 // completion callback.
3513 if (messages[0].message_complete_cb_called &&
3514 msg->upgrade &&
3515 parser->upgrade) {
3516 messages[0].upgrade = buf + nread;
3517 goto test;
3518 }
3519
3520 if (nread < buflen) {
3521
3522 // Not much do to if we failed a strict-mode check
3523 if (HTTP_PARSER_ERRNO(parser) == HPE_STRICT) {
3524 parser_free();
3525 return;
3526 }
3527
3528 assert (HTTP_PARSER_ERRNO(parser) == HPE_PAUSED);
3529 }
3530
3531 buf += nread;
3532 buflen -= nread;
3533 http_parser_pause(parser, 0);
3534 } while (buflen > 0);
3535
3536 nread = parse_pause(NULL, 0);
3537 assert (nread == 0);
3538
3539test:
3540 if (num_messages != 1) {
3541 printf("\n*** num_messages != 1 after testing '%s' ***\n\n", msg->name);
3542 abort();
3543 }
3544
3545 if(!message_eq(0, msg)) abort();
3546
3547 parser_free();
3548}
3549
3550int
3551main (void)

Callers 1

mainFunction · 0.85

Calls 5

parser_initFunction · 0.85
parse_pauseFunction · 0.85
parser_freeFunction · 0.85
http_parser_pauseFunction · 0.85
message_eqFunction · 0.85

Tested by

no test coverage detected