nxt_http_parse_test.c (1214:c3666b232602) nxt_http_parse_test.c (1459:358b957ca294)
1
2/*
3 * Copyright (C) NGINX, Inc.
4 * Copyright (C) Valentin V. Bartenev
5 */
6
7#include <nxt_main.h>
8#include "nxt_tests.h"

--- 496 unchanged lines hidden (view full) ---

505 "X-Forwarded-For: 192.0.2.0, 198.51.100.0, 203.0.113.0\r\n"
506 "\r\n"
507);
508
509
510nxt_int_t
511nxt_http_parse_test(nxt_thread_t *thr)
512{
1
2/*
3 * Copyright (C) NGINX, Inc.
4 * Copyright (C) Valentin V. Bartenev
5 */
6
7#include <nxt_main.h>
8#include "nxt_tests.h"

--- 496 unchanged lines hidden (view full) ---

505 "X-Forwarded-For: 192.0.2.0, 198.51.100.0, 203.0.113.0\r\n"
506 "\r\n"
507);
508
509
510nxt_int_t
511nxt_http_parse_test(nxt_thread_t *thr)
512{
513 nxt_mp_t *mp, *mp_temp;
513 nxt_mp_t *mp_temp;
514 nxt_int_t rc;
515 nxt_uint_t i, colls, lvl_colls;
516 nxt_lvlhsh_t hash;
517 nxt_http_request_parse_t rp;
518 nxt_http_parse_test_case_t *test;
519
520 nxt_thread_time_update(thr);
521
514 nxt_int_t rc;
515 nxt_uint_t i, colls, lvl_colls;
516 nxt_lvlhsh_t hash;
517 nxt_http_request_parse_t rp;
518 nxt_http_parse_test_case_t *test;
519
520 nxt_thread_time_update(thr);
521
522 mp = nxt_mp_create(1024, 128, 256, 32);
523 if (mp == NULL) {
524 return NXT_ERROR;
525 }
526
527 rc = nxt_http_fields_hash(&nxt_http_test_fields_hash, mp,
522 rc = nxt_http_fields_hash(&nxt_http_test_fields_hash,
528 nxt_http_test_fields,
529 nxt_nitems(nxt_http_test_fields));
530 if (rc != NXT_OK) {
531 return NXT_ERROR;
532 }
533
534 for (i = 0; i < nxt_nitems(nxt_http_test_cases); i++) {
535 test = &nxt_http_test_cases[i];

--- 28 unchanged lines hidden (view full) ---

564
565 nxt_mp_destroy(mp_temp);
566 }
567
568 nxt_log_error(NXT_LOG_NOTICE, thr->log, "http parse test passed");
569
570 nxt_memzero(&hash, sizeof(nxt_lvlhsh_t));
571
523 nxt_http_test_fields,
524 nxt_nitems(nxt_http_test_fields));
525 if (rc != NXT_OK) {
526 return NXT_ERROR;
527 }
528
529 for (i = 0; i < nxt_nitems(nxt_http_test_cases); i++) {
530 test = &nxt_http_test_cases[i];

--- 28 unchanged lines hidden (view full) ---

559
560 nxt_mp_destroy(mp_temp);
561 }
562
563 nxt_log_error(NXT_LOG_NOTICE, thr->log, "http parse test passed");
564
565 nxt_memzero(&hash, sizeof(nxt_lvlhsh_t));
566
572 colls = nxt_http_fields_hash_collisions(&hash, mp,
567 colls = nxt_http_fields_hash_collisions(&hash,
573 nxt_http_test_bench_fields,
574 nxt_nitems(nxt_http_test_bench_fields),
575 0);
576
577 nxt_memzero(&hash, sizeof(nxt_lvlhsh_t));
578
568 nxt_http_test_bench_fields,
569 nxt_nitems(nxt_http_test_bench_fields),
570 0);
571
572 nxt_memzero(&hash, sizeof(nxt_lvlhsh_t));
573
579 lvl_colls = nxt_http_fields_hash_collisions(&hash, mp,
574 lvl_colls = nxt_http_fields_hash_collisions(&hash,
580 nxt_http_test_bench_fields,
581 nxt_nitems(nxt_http_test_bench_fields),
582 1);
583
584 nxt_log_error(NXT_LOG_NOTICE, thr->log,
585 "http parse test hash collisions %ui out of %uz, level: %ui",
586 colls, nxt_nitems(nxt_http_test_bench_fields), lvl_colls);
587
588 nxt_memzero(&hash, sizeof(nxt_lvlhsh_t));
589
575 nxt_http_test_bench_fields,
576 nxt_nitems(nxt_http_test_bench_fields),
577 1);
578
579 nxt_log_error(NXT_LOG_NOTICE, thr->log,
580 "http parse test hash collisions %ui out of %uz, level: %ui",
581 colls, nxt_nitems(nxt_http_test_bench_fields), lvl_colls);
582
583 nxt_memzero(&hash, sizeof(nxt_lvlhsh_t));
584
590 rc = nxt_http_fields_hash(&hash, mp, nxt_http_test_bench_fields,
585 rc = nxt_http_fields_hash(&hash, nxt_http_test_bench_fields,
591 nxt_nitems(nxt_http_test_bench_fields));
592 if (rc != NXT_OK) {
593 return NXT_ERROR;
594 }
595
596 if (nxt_http_parse_test_bench(thr, &nxt_http_test_simple_request,
597 &hash, "simple", 1000000)
598 != NXT_OK)
599 {
600 return NXT_ERROR;
601 }
602
603 if (nxt_http_parse_test_bench(thr, &nxt_http_test_big_request,
604 &hash, "big", 100000)
605 != NXT_OK)
606 {
607 return NXT_ERROR;
608 }
609
586 nxt_nitems(nxt_http_test_bench_fields));
587 if (rc != NXT_OK) {
588 return NXT_ERROR;
589 }
590
591 if (nxt_http_parse_test_bench(thr, &nxt_http_test_simple_request,
592 &hash, "simple", 1000000)
593 != NXT_OK)
594 {
595 return NXT_ERROR;
596 }
597
598 if (nxt_http_parse_test_bench(thr, &nxt_http_test_big_request,
599 &hash, "big", 100000)
600 != NXT_OK)
601 {
602 return NXT_ERROR;
603 }
604
610 nxt_mp_destroy(mp);
611
612 return NXT_OK;
613}
614
615
616static nxt_int_t
617nxt_http_parse_test_run(nxt_http_request_parse_t *rp, nxt_str_t *request)
618{
619 nxt_int_t rc;

--- 183 unchanged lines hidden ---
605 return NXT_OK;
606}
607
608
609static nxt_int_t
610nxt_http_parse_test_run(nxt_http_request_parse_t *rp, nxt_str_t *request)
611{
612 nxt_int_t rc;

--- 183 unchanged lines hidden ---