src/server/test/io.c

changeset 513
9a49c245a49c
parent 498
0d80f8a2b29f
equal deleted inserted replaced
511:a5a142fea2ae 513:9a49c245a49c
443 443
444 char *msg = "hello world!"; 444 char *msg = "hello world!";
445 size_t msglen = strlen(msg); 445 size_t msglen = strlen(msg);
446 446
447 st->max_write = 1; // limit the test stream max write size 447 st->max_write = 1; // limit the test stream max write size
448 io_set_max_writes(1);
448 449
449 // only 1 byte of the header is written, 0 bytes of msg 450 // only 1 byte of the header is written, 0 bytes of msg
450 ssize_t w = net_write(http, msg, msglen); 451 ssize_t w = net_write(http, msg, msglen);
451 UCX_TEST_ASSERT(w == 0, "write 1: wrong return value"); 452 UCX_TEST_ASSERT(w == 0, "write 1: wrong return value");
452 UCX_TEST_ASSERT(st->buf->size == 1, "write 1: wrong buf size"); 453 UCX_TEST_ASSERT(st->buf->size == 1, "write 1: wrong buf size");
491 size_t msglen = strlen(msg); 492 size_t msglen = strlen(msg);
492 size_t msglen_orig = msglen; 493 size_t msglen_orig = msglen;
493 494
494 // limit first write to 3 to only write the header 495 // limit first write to 3 to only write the header
495 st->max_write = 3; 496 st->max_write = 3;
497 io_set_max_writes(1);
496 498
497 ssize_t w = net_write(http, msg, msglen); 499 ssize_t w = net_write(http, msg, msglen);
498 500
499 UCX_TEST_ASSERT(w == 0, "write 1: wrong return value"); 501 UCX_TEST_ASSERT(w == 0, "write 1: wrong return value");
500 UCX_TEST_ASSERT(st->buf->size == 3, "write 1: wrong buf size"); 502 UCX_TEST_ASSERT(st->buf->size == 3, "write 1: wrong buf size");
533 Session *sn = testutil_session(); 535 Session *sn = testutil_session();
534 536
535 TestIOStream *st = testutil_iostream(2048, TRUE); 537 TestIOStream *st = testutil_iostream(2048, TRUE);
536 IOStream *http = httpstream_new(sn->pool, (IOStream*)st); 538 IOStream *http = httpstream_new(sn->pool, (IOStream*)st);
537 httpstream_enable_chunked_write(http); 539 httpstream_enable_chunked_write(http);
540 io_set_max_writes(1);
538 541
539 UCX_TEST_BEGIN; 542 UCX_TEST_BEGIN;
540 543
541 memset(st->buf->space, 0, st->buf->capacity); 544 memset(st->buf->space, 0, st->buf->capacity);
542 545
593 Session *sn = testutil_session(); 596 Session *sn = testutil_session();
594 597
595 TestIOStream *st = testutil_iostream(2048, TRUE); 598 TestIOStream *st = testutil_iostream(2048, TRUE);
596 IOStream *http = httpstream_new(sn->pool, (IOStream*)st); 599 IOStream *http = httpstream_new(sn->pool, (IOStream*)st);
597 httpstream_enable_chunked_write(http); 600 httpstream_enable_chunked_write(http);
601 io_set_max_writes(1);
598 602
599 UCX_TEST_BEGIN; 603 UCX_TEST_BEGIN;
600 604
601 memset(st->buf->space, 0, st->buf->capacity); 605 memset(st->buf->space, 0, st->buf->capacity);
602 606
652 Session *sn = testutil_session(); 656 Session *sn = testutil_session();
653 657
654 TestIOStream *st = testutil_iostream(2048, TRUE); 658 TestIOStream *st = testutil_iostream(2048, TRUE);
655 IOStream *http = httpstream_new(sn->pool, (IOStream*)st); 659 IOStream *http = httpstream_new(sn->pool, (IOStream*)st);
656 httpstream_enable_chunked_write(http); 660 httpstream_enable_chunked_write(http);
661 io_set_max_writes(1);
657 662
658 UCX_TEST_BEGIN; 663 UCX_TEST_BEGIN;
659 664
660 memset(st->buf->space, 0, st->buf->capacity); 665 memset(st->buf->space, 0, st->buf->capacity);
661 666
698 Session *sn = testutil_session(); 703 Session *sn = testutil_session();
699 704
700 TestIOStream *st = testutil_iostream(2048, TRUE); 705 TestIOStream *st = testutil_iostream(2048, TRUE);
701 IOStream *http = httpstream_new(sn->pool, (IOStream*)st); 706 IOStream *http = httpstream_new(sn->pool, (IOStream*)st);
702 httpstream_enable_chunked_write(http); 707 httpstream_enable_chunked_write(http);
708 io_set_max_writes(1);
703 709
704 UCX_TEST_BEGIN; 710 UCX_TEST_BEGIN;
705 711
706 // Test: create testdata and write it in varying chunk sizes, but 712 // Test: create testdata and write it in varying chunk sizes, but
707 // limit TestIOStream to 1 to 3 byte writes 713 // limit TestIOStream to 1 to 3 byte writes

mercurial