src: Fix unit tests failure
This commit is contained in:
parent
bfac015d61
commit
2003be8dc5
|
@ -114,6 +114,9 @@ template <typename Memchunk> struct Memchunks {
|
||||||
Memchunks(Pool<Memchunk> *pool)
|
Memchunks(Pool<Memchunk> *pool)
|
||||||
: pool(pool), head(nullptr), tail(nullptr), len(0) {}
|
: pool(pool), head(nullptr), tail(nullptr), len(0) {}
|
||||||
~Memchunks() {
|
~Memchunks() {
|
||||||
|
if (!pool) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (auto m = head; m;) {
|
for (auto m = head; m;) {
|
||||||
auto next = m->next;
|
auto next = m->next;
|
||||||
pool->recycle(m);
|
pool->recycle(m);
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "util_test.h"
|
#include "util_test.h"
|
||||||
#include "nghttp2_gzip_test.h"
|
#include "nghttp2_gzip_test.h"
|
||||||
#include "ringbuf_test.h"
|
#include "ringbuf_test.h"
|
||||||
|
#include "shrpx_config.h"
|
||||||
|
|
||||||
static int init_suite1(void) { return 0; }
|
static int init_suite1(void) { return 0; }
|
||||||
|
|
||||||
|
@ -52,6 +53,8 @@ int main(int argc, char *argv[]) {
|
||||||
SSL_load_error_strings();
|
SSL_load_error_strings();
|
||||||
SSL_library_init();
|
SSL_library_init();
|
||||||
|
|
||||||
|
shrpx::create_config();
|
||||||
|
|
||||||
// initialize the CUnit test registry
|
// initialize the CUnit test registry
|
||||||
if (CUE_SUCCESS != CU_initialize_registry())
|
if (CUE_SUCCESS != CU_initialize_registry())
|
||||||
return CU_get_error();
|
return CU_get_error();
|
||||||
|
|
|
@ -104,13 +104,14 @@ void downstream_wtimeoutcb(struct ev_loop *loop, ev_timer *w, int revents) {
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
// upstream could be nullptr for unittests
|
||||||
Downstream::Downstream(Upstream *upstream, int32_t stream_id, int32_t priority)
|
Downstream::Downstream(Upstream *upstream, int32_t stream_id, int32_t priority)
|
||||||
: request_buf_(upstream->get_mcpool()),
|
: request_buf_(upstream ? upstream->get_mcpool() : nullptr),
|
||||||
response_buf_(upstream->get_mcpool()), request_bodylen_(0),
|
response_buf_(upstream ? upstream->get_mcpool() : nullptr),
|
||||||
response_bodylen_(0), response_sent_bodylen_(0), upstream_(upstream),
|
request_bodylen_(0), response_bodylen_(0), response_sent_bodylen_(0),
|
||||||
request_headers_sum_(0), response_headers_sum_(0), request_datalen_(0),
|
upstream_(upstream), request_headers_sum_(0), response_headers_sum_(0),
|
||||||
response_datalen_(0), stream_id_(stream_id), priority_(priority),
|
request_datalen_(0), response_datalen_(0), stream_id_(stream_id),
|
||||||
downstream_stream_id_(-1),
|
priority_(priority), downstream_stream_id_(-1),
|
||||||
response_rst_stream_error_code_(NGHTTP2_NO_ERROR),
|
response_rst_stream_error_code_(NGHTTP2_NO_ERROR),
|
||||||
request_state_(INITIAL), request_major_(1), request_minor_(1),
|
request_state_(INITIAL), request_major_(1), request_minor_(1),
|
||||||
response_state_(INITIAL), response_http_status_(0), response_major_(1),
|
response_state_(INITIAL), response_http_status_(0), response_major_(1),
|
||||||
|
@ -141,12 +142,16 @@ Downstream::~Downstream() {
|
||||||
if (LOG_ENABLED(INFO)) {
|
if (LOG_ENABLED(INFO)) {
|
||||||
DLOG(INFO, this) << "Deleting";
|
DLOG(INFO, this) << "Deleting";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check nullptr for unittest
|
||||||
|
if (upstream_) {
|
||||||
auto loop = upstream_->get_client_handler()->get_loop();
|
auto loop = upstream_->get_client_handler()->get_loop();
|
||||||
|
|
||||||
ev_timer_stop(loop, &upstream_rtimer_);
|
ev_timer_stop(loop, &upstream_rtimer_);
|
||||||
ev_timer_stop(loop, &upstream_wtimer_);
|
ev_timer_stop(loop, &upstream_wtimer_);
|
||||||
ev_timer_stop(loop, &downstream_rtimer_);
|
ev_timer_stop(loop, &downstream_rtimer_);
|
||||||
ev_timer_stop(loop, &downstream_wtimer_);
|
ev_timer_stop(loop, &downstream_wtimer_);
|
||||||
|
}
|
||||||
|
|
||||||
if (LOG_ENABLED(INFO)) {
|
if (LOG_ENABLED(INFO)) {
|
||||||
DLOG(INFO, this) << "Deleted";
|
DLOG(INFO, this) << "Deleted";
|
||||||
|
|
Loading…
Reference in New Issue