From 7ff38e34eaea52b4d1b856efa9de685cbdbd28ba Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Jul 2015 12:44:57 -0700 Subject: Update the unit tests to use the new pointer type. --- indra/llcorehttp/tests/test_httprequest.hpp | 328 +++++++++------------------- 1 file changed, 103 insertions(+), 225 deletions(-) (limited to 'indra/llcorehttp/tests/test_httprequest.hpp') diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp index 43f7e36da5..1f606bd0c1 100755 --- a/indra/llcorehttp/tests/test_httprequest.hpp +++ b/indra/llcorehttp/tests/test_httprequest.hpp @@ -112,7 +112,7 @@ public: if (! mHeadersRequired.empty() || ! mHeadersDisallowed.empty()) { ensure("Response required with header check", response != NULL); - HttpHeaders * header(response->getHeaders()); // Will not hold onto this + HttpHeaders::ptr_t header(response->getHeaders()); // Will not hold onto this ensure("Some quantity of headers returned", header != NULL); if (! mHeadersRequired.empty()) @@ -638,7 +638,7 @@ void HttpRequestTestObjectType::test<7>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * opts = NULL; + HttpOptions::ptr_t opts; try { @@ -653,7 +653,7 @@ void HttpRequestTestObjectType::test<7>() req = new HttpRequest(); ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); - opts = new HttpOptions(); + opts = HttpOptions::ptr_t(new HttpOptions()); opts->setRetries(1); // Don't try for too long - default retries take about 18S // Issue a GET that can't connect @@ -664,7 +664,7 @@ void HttpRequestTestObjectType::test<7>() 0, 0, opts, - NULL, + HttpHeaders::ptr_t(), &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); @@ -705,8 +705,7 @@ void HttpRequestTestObjectType::test<7>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options - opts->release(); - opts = NULL; + opts.reset(); // release the request object delete req; @@ -728,11 +727,7 @@ void HttpRequestTestObjectType::test<7>() catch (...) { stop_thread(req); - if (opts) - { - opts->release(); - opts = NULL; - } + opts.reset(); delete req; HttpRequest::destroyService(); throw; @@ -779,8 +774,8 @@ void HttpRequestTestObjectType::test<8>() HttpHandle handle = req->requestGet(HttpRequest::DEFAULT_POLICY_ID, 0U, url_base, - NULL, - NULL, + HttpOptions::ptr_t(), + HttpHeaders::ptr_t(), &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); @@ -889,8 +884,8 @@ void HttpRequestTestObjectType::test<9>() url_base, 0, 0, - NULL, - NULL, + HttpOptions::ptr_t(), + HttpHeaders::ptr_t(), &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); @@ -1001,9 +996,9 @@ void HttpRequestTestObjectType::test<10>() 0U, url_base, body, - NULL, - NULL, - &handler); + HttpOptions::ptr_t(), + HttpHeaders::ptr_t(), + &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1119,9 +1114,9 @@ void HttpRequestTestObjectType::test<11>() 0U, url_base, body, - NULL, - NULL, - &handler); + HttpOptions::ptr_t(), + HttpHeaders::ptr_t(), + &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1239,9 +1234,9 @@ void HttpRequestTestObjectType::test<12>() url_base, 0, 0, - NULL, - NULL, - &handler); + HttpOptions::ptr_t(), + HttpHeaders::ptr_t(), + &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1332,7 +1327,7 @@ void HttpRequestTestObjectType::test<13>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * opts = NULL; + HttpOptions::ptr_t opts; try { @@ -1350,7 +1345,7 @@ void HttpRequestTestObjectType::test<13>() req = new HttpRequest(); ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); - opts = new HttpOptions(); + opts = HttpOptions::ptr_t(new HttpOptions()); opts->setWantHeaders(true); // Issue a GET that succeeds @@ -1364,13 +1359,12 @@ void HttpRequestTestObjectType::test<13>() 0, 0, opts, - NULL, - &handler); + HttpHeaders::ptr_t(), + &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // release options - opts->release(); - opts = NULL; + opts.reset(); // Run the notification pump. int count(0); @@ -1430,11 +1424,7 @@ void HttpRequestTestObjectType::test<13>() catch (...) { stop_thread(req); - if (opts) - { - opts->release(); - opts = NULL; - } + opts.reset(); delete req; HttpRequest::destroyService(); throw; @@ -1460,7 +1450,7 @@ void HttpRequestTestObjectType::test<14>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * opts = NULL; + HttpOptions::ptr_t opts; try { @@ -1475,7 +1465,7 @@ void HttpRequestTestObjectType::test<14>() req = new HttpRequest(); ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); - opts = new HttpOptions(); + opts = HttpOptions::ptr_t(new HttpOptions); opts->setRetries(0); // Don't retry opts->setTimeout(2); @@ -1487,8 +1477,8 @@ void HttpRequestTestObjectType::test<14>() 0, 0, opts, - NULL, - &handler); + HttpHeaders::ptr_t(), + &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1528,8 +1518,7 @@ void HttpRequestTestObjectType::test<14>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options - opts->release(); - opts = NULL; + opts.reset(); // release the request object delete req; @@ -1552,11 +1541,7 @@ void HttpRequestTestObjectType::test<14>() catch (...) { stop_thread(req); - if (opts) - { - opts->release(); - opts = NULL; - } + opts.reset(); delete req; HttpRequest::destroyService(); throw; @@ -1609,9 +1594,9 @@ void HttpRequestTestObjectType::test<15>() HttpHandle handle = req->requestGet(HttpRequest::DEFAULT_POLICY_ID, 0U, url_base, - NULL, - NULL, - &handler); + HttpOptions::ptr_t(), + HttpHeaders::ptr_t(), + &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1703,8 +1688,8 @@ void HttpRequestTestObjectType::test<16>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * options = NULL; - HttpHeaders * headers = NULL; + HttpOptions::ptr_t options; + HttpHeaders::ptr_t headers; try { @@ -1719,7 +1704,7 @@ void HttpRequestTestObjectType::test<16>() req = new HttpRequest(); // options set - options = new HttpOptions(); + options = HttpOptions::ptr_t(new HttpOptions()); options->setWantHeaders(true); // Issue a GET that *can* connect @@ -1776,7 +1761,7 @@ void HttpRequestTestObjectType::test<16>() 0U, url_base + "reflect/", options, - NULL, + HttpHeaders::ptr_t(), &handler); ensure("Valid handle returned for get request", handle != LLCORE_HTTP_HANDLE_INVALID); @@ -1792,7 +1777,7 @@ void HttpRequestTestObjectType::test<16>() ensure("One handler invocation for request", mHandlerCalls == 1); // Do a texture-style fetch - headers = new HttpHeaders; + headers = HttpHeaders::ptr_t(new HttpHeaders); headers->append("Accept", "image/x-j2c"); mStatus = HttpStatus(200); @@ -1897,17 +1882,8 @@ void HttpRequestTestObjectType::test<16>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options & headers - if (options) - { - options->release(); - } - options = NULL; - - if (headers) - { - headers->release(); - } - headers = NULL; + options.reset(); + headers.reset(); // release the request object delete req; @@ -1919,16 +1895,9 @@ void HttpRequestTestObjectType::test<16>() catch (...) { stop_thread(req); - if (options) - { - options->release(); - options = NULL; - } - if (headers) - { - headers->release(); - headers = NULL; - } + options.reset(); + headers.reset(); + delete req; HttpRequest::destroyService(); throw; @@ -1960,8 +1929,8 @@ void HttpRequestTestObjectType::test<17>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * options = NULL; - HttpHeaders * headers = NULL; + HttpOptions::ptr_t options; + HttpHeaders::ptr_t headers; BufferArray * ba = NULL; try @@ -1977,7 +1946,7 @@ void HttpRequestTestObjectType::test<17>() req = new HttpRequest(); // options set - options = new HttpOptions(); + options = HttpOptions::ptr_t(new HttpOptions()); options->setWantHeaders(true); // And a buffer array @@ -2049,7 +2018,7 @@ void HttpRequestTestObjectType::test<17>() url_base + "reflect/", ba, options, - NULL, + HttpHeaders::ptr_t(), &handler); ensure("Valid handle returned for get request", handle != LLCORE_HTTP_HANDLE_INVALID); ba->release(); @@ -2095,17 +2064,8 @@ void HttpRequestTestObjectType::test<17>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options & headers - if (options) - { - options->release(); - } - options = NULL; - - if (headers) - { - headers->release(); - } - headers = NULL; + options.reset(); + headers.reset(); // release the request object delete req; @@ -2122,17 +2082,10 @@ void HttpRequestTestObjectType::test<17>() ba->release(); ba = NULL; } - if (options) - { - options->release(); - options = NULL; - } - if (headers) - { - headers->release(); - headers = NULL; - } - delete req; + options.reset(); + headers.reset(); + + delete req; HttpRequest::destroyService(); throw; } @@ -2163,8 +2116,8 @@ void HttpRequestTestObjectType::test<18>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * options = NULL; - HttpHeaders * headers = NULL; + HttpOptions::ptr_t options; + HttpHeaders::ptr_t headers; BufferArray * ba = NULL; try @@ -2180,7 +2133,7 @@ void HttpRequestTestObjectType::test<18>() req = new HttpRequest(); // options set - options = new HttpOptions(); + options = HttpOptions::ptr_t(new HttpOptions()); options->setWantHeaders(true); // And a buffer array @@ -2253,7 +2206,7 @@ void HttpRequestTestObjectType::test<18>() url_base + "reflect/", ba, options, - NULL, + HttpHeaders::ptr_t(), &handler); ensure("Valid handle returned for get request", handle != LLCORE_HTTP_HANDLE_INVALID); ba->release(); @@ -2299,17 +2252,8 @@ void HttpRequestTestObjectType::test<18>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options & headers - if (options) - { - options->release(); - } - options = NULL; - - if (headers) - { - headers->release(); - } - headers = NULL; + options.reset(); + headers.reset(); // release the request object delete req; @@ -2326,17 +2270,10 @@ void HttpRequestTestObjectType::test<18>() ba->release(); ba = NULL; } - if (options) - { - options->release(); - options = NULL; - } - if (headers) - { - headers->release(); - headers = NULL; - } - delete req; + options.reset(); + headers.reset(); + + delete req; HttpRequest::destroyService(); throw; } @@ -2367,8 +2304,8 @@ void HttpRequestTestObjectType::test<19>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * options = NULL; - HttpHeaders * headers = NULL; + HttpOptions::ptr_t options; + HttpHeaders::ptr_t headers; try { @@ -2383,11 +2320,11 @@ void HttpRequestTestObjectType::test<19>() req = new HttpRequest(); // options set - options = new HttpOptions(); + options = HttpOptions::ptr_t(new HttpOptions()); options->setWantHeaders(true); // headers - headers = new HttpHeaders; + headers = HttpHeaders::ptr_t(new HttpHeaders); headers->append("Keep-Alive", "120"); headers->append("Accept-encoding", "deflate"); headers->append("Accept", "text/plain"); @@ -2502,17 +2439,8 @@ void HttpRequestTestObjectType::test<19>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options & headers - if (options) - { - options->release(); - } - options = NULL; - - if (headers) - { - headers->release(); - } - headers = NULL; + options.reset(); + headers.reset(); // release the request object delete req; @@ -2524,16 +2452,9 @@ void HttpRequestTestObjectType::test<19>() catch (...) { stop_thread(req); - if (options) - { - options->release(); - options = NULL; - } - if (headers) - { - headers->release(); - headers = NULL; - } + options.reset(); + headers.reset(); + delete req; HttpRequest::destroyService(); throw; @@ -2565,8 +2486,8 @@ void HttpRequestTestObjectType::test<20>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * options = NULL; - HttpHeaders * headers = NULL; + HttpOptions::ptr_t options; + HttpHeaders::ptr_t headers; BufferArray * ba = NULL; try @@ -2582,11 +2503,11 @@ void HttpRequestTestObjectType::test<20>() req = new HttpRequest(); // options set - options = new HttpOptions(); + options = HttpOptions::ptr_t(new HttpOptions()); options->setWantHeaders(true); // headers - headers = new HttpHeaders(); + headers = HttpHeaders::ptr_t(new HttpHeaders()); headers->append("keep-Alive", "120"); headers->append("Accept", "text/html"); headers->append("content-type", "application/llsd+xml"); @@ -2720,17 +2641,8 @@ void HttpRequestTestObjectType::test<20>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options & headers - if (options) - { - options->release(); - } - options = NULL; - - if (headers) - { - headers->release(); - } - headers = NULL; + options.reset(); + headers.reset(); // release the request object delete req; @@ -2747,16 +2659,8 @@ void HttpRequestTestObjectType::test<20>() ba->release(); ba = NULL; } - if (options) - { - options->release(); - options = NULL; - } - if (headers) - { - headers->release(); - headers = NULL; - } + options.reset(); + headers.reset(); delete req; HttpRequest::destroyService(); throw; @@ -2788,8 +2692,8 @@ void HttpRequestTestObjectType::test<21>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * options = NULL; - HttpHeaders * headers = NULL; + HttpOptions::ptr_t options; + HttpHeaders::ptr_t headers; BufferArray * ba = NULL; try @@ -2805,11 +2709,11 @@ void HttpRequestTestObjectType::test<21>() req = new HttpRequest(); // options set - options = new HttpOptions(); + options = HttpOptions::ptr_t(new HttpOptions()); options->setWantHeaders(true); // headers - headers = new HttpHeaders; + headers = HttpHeaders::ptr_t(new HttpHeaders); headers->append("content-type", "text/plain"); headers->append("content-type", "text/html"); headers->append("content-type", "application/llsd+xml"); @@ -2937,17 +2841,8 @@ void HttpRequestTestObjectType::test<21>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options & headers - if (options) - { - options->release(); - } - options = NULL; - - if (headers) - { - headers->release(); - } - headers = NULL; + options.reset(); + headers.reset(); // release the request object delete req; @@ -2964,16 +2859,8 @@ void HttpRequestTestObjectType::test<21>() ba->release(); ba = NULL; } - if (options) - { - options->release(); - options = NULL; - } - if (headers) - { - headers->release(); - headers = NULL; - } + options.reset(); + headers.reset(); delete req; HttpRequest::destroyService(); throw; @@ -3000,13 +2887,13 @@ void HttpRequestTestObjectType::test<22>() mMemTotal = GetMemTotal(); mHandlerCalls = 0; - HttpOptions * options = NULL; + HttpOptions::ptr_t options; HttpRequest * req = NULL; try { // options set - options = new HttpOptions(); + options = HttpOptions::ptr_t(new HttpOptions()); options->setRetries(1); // Partial_File is retryable and can timeout in here // Get singletons created @@ -3035,8 +2922,8 @@ void HttpRequestTestObjectType::test<22>() 0, 25, options, - NULL, - &handler); + HttpHeaders::ptr_t(), + &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); } @@ -3067,7 +2954,7 @@ void HttpRequestTestObjectType::test<22>() 0, 25, options, - NULL, + HttpHeaders::ptr_t(), &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); } @@ -3099,8 +2986,8 @@ void HttpRequestTestObjectType::test<22>() 0, 25, options, - NULL, - &handler); + HttpHeaders::ptr_t(), + &handler); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); } @@ -3144,11 +3031,7 @@ void HttpRequestTestObjectType::test<22>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options - if (options) - { - options->release(); - options = NULL; - } + options.reset(); // release the request object delete req; @@ -3198,7 +3081,7 @@ void HttpRequestTestObjectType::test<23>() mHandlerCalls = 0; HttpRequest * req = NULL; - HttpOptions * opts = NULL; + HttpOptions::ptr_t opts; try { @@ -3213,7 +3096,7 @@ void HttpRequestTestObjectType::test<23>() req = new HttpRequest(); ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); - opts = new HttpOptions(); + opts = HttpOptions::ptr_t(new HttpOptions()); opts->setRetries(1); // Retry once only opts->setUseRetryAfter(true); // Try to parse the retry-after header @@ -3230,8 +3113,8 @@ void HttpRequestTestObjectType::test<23>() 0, 0, opts, - NULL, - &handler); + HttpHeaders::ptr_t(), + &handler); std::ostringstream testtag; testtag << "Valid handle returned for 503 request #" << i; @@ -3277,8 +3160,7 @@ void HttpRequestTestObjectType::test<23>() ensure("Thread actually stopped running", HttpService::isStopped()); // release options - opts->release(); - opts = NULL; + opts.reset(); // release the request object delete req; @@ -3299,11 +3181,7 @@ void HttpRequestTestObjectType::test<23>() catch (...) { stop_thread(req); - if (opts) - { - opts->release(); - opts = NULL; - } + opts.reset(); delete req; HttpRequest::destroyService(); throw; -- cgit v1.2.3 From b30e408a42a95d68dd7d32e4391b59d108d086c4 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 15 Oct 2015 11:03:13 -0700 Subject: MAINT-5732: Update unit tests --- indra/llcorehttp/tests/test_httprequest.hpp | 185 ++++++++++++++++------------ 1 file changed, 106 insertions(+), 79 deletions(-) (limited to 'indra/llcorehttp/tests/test_httprequest.hpp') diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp index 1f606bd0c1..965a94bc38 100755 --- a/indra/llcorehttp/tests/test_httprequest.hpp +++ b/indra/llcorehttp/tests/test_httprequest.hpp @@ -275,6 +275,10 @@ void HttpRequestTestObjectType::test<2>() } } +namespace +{ + void NoOpDeletor(LLCore::HttpHandler *) { } +} template <> template <> void HttpRequestTestObjectType::test<3>() @@ -287,7 +291,8 @@ void HttpRequestTestObjectType::test<3>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); - + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); + // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); mHandlerCalls = 0; @@ -296,9 +301,8 @@ void HttpRequestTestObjectType::test<3>() try { - // Get singletons created - HttpRequest::createService(); + HttpRequest::createService(); // Start threading early so that thread memory is invariant // over the test. @@ -309,7 +313,7 @@ void HttpRequestTestObjectType::test<3>() ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); // Issue a NoOp - HttpHandle handle = req->requestNoOp(&handler); + HttpHandle handle = req->requestNoOp(handlerp); ensure("Valid handle returned for first request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -324,7 +328,7 @@ void HttpRequestTestObjectType::test<3>() ensure("One handler invocation for request", mHandlerCalls == 1); // Okay, request a shutdown of the servicing thread - handle = req->requestStopThread(&handler); + handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -378,7 +382,10 @@ void HttpRequestTestObjectType::test<4>() // references to it after completion of this method. TestHandler2 handler1(this, "handler1"); TestHandler2 handler2(this, "handler2"); - + + LLCore::HttpHandler::ptr_t handler1p(&handler1, NoOpDeletor); + LLCore::HttpHandler::ptr_t handler2p(&handler2, NoOpDeletor); + // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); mHandlerCalls = 0; @@ -388,7 +395,7 @@ void HttpRequestTestObjectType::test<4>() try { - + // Get singletons created HttpRequest::createService(); @@ -402,11 +409,11 @@ void HttpRequestTestObjectType::test<4>() ensure("Memory allocated on construction", mMemTotal < GetMemTotal()); // Issue some NoOps - HttpHandle handle = req1->requestNoOp(&handler1); + HttpHandle handle = req1->requestNoOp(handler1p); ensure("Valid handle returned for first request", handle != LLCORE_HTTP_HANDLE_INVALID); handler1.mExpectHandle = handle; - handle = req2->requestNoOp(&handler2); + handle = req2->requestNoOp(handler2p); ensure("Valid handle returned for first request", handle != LLCORE_HTTP_HANDLE_INVALID); handler2.mExpectHandle = handle; @@ -423,7 +430,7 @@ void HttpRequestTestObjectType::test<4>() ensure("One handler invocation for request", mHandlerCalls == 2); // Okay, request a shutdown of the servicing thread - handle = req2->requestStopThread(&handler2); + handle = req2->requestStopThread(handler2p); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); handler2.mExpectHandle = handle; @@ -482,7 +489,8 @@ void HttpRequestTestObjectType::test<5>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); - + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); + // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); mHandlerCalls = 0; @@ -491,7 +499,6 @@ void HttpRequestTestObjectType::test<5>() try { - // Get singletons created HttpRequest::createService(); @@ -508,7 +515,7 @@ void HttpRequestTestObjectType::test<5>() ensure("Valid handle returned for spin request", handle != LLCORE_HTTP_HANDLE_INVALID); // Issue a NoOp - handle = req->requestNoOp(&handler); + handle = req->requestNoOp(handlerp); ensure("Valid handle returned for no-op request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -567,7 +574,8 @@ void HttpRequestTestObjectType::test<6>() try { - + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); + // Get singletons created HttpRequest::createService(); @@ -584,7 +592,7 @@ void HttpRequestTestObjectType::test<6>() ensure("Valid handle returned for spin request", handle != LLCORE_HTTP_HANDLE_INVALID); // Issue a NoOp - handle = req->requestNoOp(&handler); + handle = req->requestNoOp(handlerp); ensure("Valid handle returned for no-op request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -632,7 +640,9 @@ void HttpRequestTestObjectType::test<7>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); - + + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); + // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); mHandlerCalls = 0; @@ -642,7 +652,7 @@ void HttpRequestTestObjectType::test<7>() try { - // Get singletons created + // Get singletons created HttpRequest::createService(); // Start threading early so that thread memory is invariant @@ -665,7 +675,7 @@ void HttpRequestTestObjectType::test<7>() 0, opts, HttpHeaders::ptr_t(), - &handler); + handlerp); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -681,7 +691,7 @@ void HttpRequestTestObjectType::test<7>() // Okay, request a shutdown of the servicing thread mStatus = HttpStatus(); - handle = req->requestStopThread(&handler); + handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -749,7 +759,8 @@ void HttpRequestTestObjectType::test<8>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); - + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); + // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); mHandlerCalls = 0; @@ -758,7 +769,7 @@ void HttpRequestTestObjectType::test<8>() try { - // Get singletons created + // Get singletons created HttpRequest::createService(); // Start threading early so that thread memory is invariant @@ -776,7 +787,7 @@ void HttpRequestTestObjectType::test<8>() url_base, HttpOptions::ptr_t(), HttpHeaders::ptr_t(), - &handler); + handlerp); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -792,7 +803,7 @@ void HttpRequestTestObjectType::test<8>() // Okay, request a shutdown of the servicing thread mStatus = HttpStatus(); - handle = req->requestStopThread(&handler); + handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -857,7 +868,8 @@ void HttpRequestTestObjectType::test<9>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); - + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); + // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); mHandlerCalls = 0; @@ -866,7 +878,7 @@ void HttpRequestTestObjectType::test<9>() try { - // Get singletons created + // Get singletons created HttpRequest::createService(); // Start threading early so that thread memory is invariant @@ -886,7 +898,7 @@ void HttpRequestTestObjectType::test<9>() 0, HttpOptions::ptr_t(), HttpHeaders::ptr_t(), - &handler); + handlerp); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -902,7 +914,7 @@ void HttpRequestTestObjectType::test<9>() // Okay, request a shutdown of the servicing thread mStatus = HttpStatus(); - handle = req->requestStopThread(&handler); + handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -967,7 +979,8 @@ void HttpRequestTestObjectType::test<10>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); - + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); + // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); mHandlerCalls = 0; @@ -977,7 +990,7 @@ void HttpRequestTestObjectType::test<10>() try { - // Get singletons created + // Get singletons created HttpRequest::createService(); // Start threading early so that thread memory is invariant @@ -998,7 +1011,7 @@ void HttpRequestTestObjectType::test<10>() body, HttpOptions::ptr_t(), HttpHeaders::ptr_t(), - &handler); + handlerp); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1014,7 +1027,7 @@ void HttpRequestTestObjectType::test<10>() // Okay, request a shutdown of the servicing thread mStatus = HttpStatus(); - handle = req->requestStopThread(&handler); + handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -1085,7 +1098,8 @@ void HttpRequestTestObjectType::test<11>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); - + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); + // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); mHandlerCalls = 0; @@ -1095,7 +1109,7 @@ void HttpRequestTestObjectType::test<11>() try { - // Get singletons created + // Get singletons created HttpRequest::createService(); // Start threading early so that thread memory is invariant @@ -1116,7 +1130,7 @@ void HttpRequestTestObjectType::test<11>() body, HttpOptions::ptr_t(), HttpHeaders::ptr_t(), - &handler); + handlerp); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1132,7 +1146,7 @@ void HttpRequestTestObjectType::test<11>() // Okay, request a shutdown of the servicing thread mStatus = HttpStatus(); - handle = req->requestStopThread(&handler); + handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -1204,7 +1218,8 @@ void HttpRequestTestObjectType::test<12>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); - + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); + // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); mHandlerCalls = 0; @@ -1213,7 +1228,7 @@ void HttpRequestTestObjectType::test<12>() try { - // Get singletons created + // Get singletons created HttpRequest::createService(); // Enable tracing @@ -1236,7 +1251,7 @@ void HttpRequestTestObjectType::test<12>() 0, HttpOptions::ptr_t(), HttpHeaders::ptr_t(), - &handler); + handlerp); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1252,7 +1267,7 @@ void HttpRequestTestObjectType::test<12>() // Okay, request a shutdown of the servicing thread mStatus = HttpStatus(); - handle = req->requestStopThread(&handler); + handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -1321,7 +1336,8 @@ void HttpRequestTestObjectType::test<13>() // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); handler.mHeadersRequired.reserve(20); // Avoid memory leak test failure - + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); + // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); mHandlerCalls = 0; @@ -1331,7 +1347,7 @@ void HttpRequestTestObjectType::test<13>() try { - // Get singletons created + // Get singletons created HttpRequest::createService(); // Enable tracing @@ -1360,7 +1376,7 @@ void HttpRequestTestObjectType::test<13>() 0, opts, HttpHeaders::ptr_t(), - &handler); + handlerp); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // release options @@ -1380,7 +1396,7 @@ void HttpRequestTestObjectType::test<13>() // Okay, request a shutdown of the servicing thread mStatus = HttpStatus(); handler.mHeadersRequired.clear(); - handle = req->requestStopThread(&handler); + handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -1443,7 +1459,8 @@ void HttpRequestTestObjectType::test<14>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); - std::string url_base(get_base_url() + "/sleep/"); // path to a 30-second sleep + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); + std::string url_base(get_base_url() + "/sleep/"); // path to a 30-second sleep // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); @@ -1454,7 +1471,7 @@ void HttpRequestTestObjectType::test<14>() try { - // Get singletons created + // Get singletons created HttpRequest::createService(); // Start threading early so that thread memory is invariant @@ -1478,7 +1495,7 @@ void HttpRequestTestObjectType::test<14>() 0, opts, HttpHeaders::ptr_t(), - &handler); + handlerp); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1494,7 +1511,7 @@ void HttpRequestTestObjectType::test<14>() // Okay, request a shutdown of the servicing thread mStatus = HttpStatus(); - handle = req->requestStopThread(&handler); + handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -1563,6 +1580,7 @@ void HttpRequestTestObjectType::test<15>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); // Load and clear the string setting to preload std::string object // for memory return tests. @@ -1577,7 +1595,7 @@ void HttpRequestTestObjectType::test<15>() try { - // Get singletons created + // Get singletons created HttpRequest::createService(); // Start threading early so that thread memory is invariant @@ -1596,7 +1614,7 @@ void HttpRequestTestObjectType::test<15>() url_base, HttpOptions::ptr_t(), HttpHeaders::ptr_t(), - &handler); + handlerp); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1613,7 +1631,7 @@ void HttpRequestTestObjectType::test<15>() // Okay, request a shutdown of the servicing thread mStatus = HttpStatus(); handler.mCheckContentType.clear(); - handle = req->requestStopThread(&handler); + handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -1682,6 +1700,7 @@ void HttpRequestTestObjectType::test<16>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); @@ -1693,7 +1712,7 @@ void HttpRequestTestObjectType::test<16>() try { - // Get singletons created + // Get singletons created HttpRequest::createService(); // Start threading early so that thread memory is invariant @@ -1762,7 +1781,7 @@ void HttpRequestTestObjectType::test<16>() url_base + "reflect/", options, HttpHeaders::ptr_t(), - &handler); + handlerp); ensure("Valid handle returned for get request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1839,7 +1858,7 @@ void HttpRequestTestObjectType::test<16>() 47, options, headers, - &handler); + handlerp); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -1858,7 +1877,7 @@ void HttpRequestTestObjectType::test<16>() mStatus = HttpStatus(); handler.mHeadersRequired.clear(); handler.mHeadersDisallowed.clear(); - handle = req->requestStopThread(&handler); + handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -1923,6 +1942,7 @@ void HttpRequestTestObjectType::test<17>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); @@ -1935,7 +1955,7 @@ void HttpRequestTestObjectType::test<17>() try { - // Get singletons created + // Get singletons created HttpRequest::createService(); // Start threading early so that thread memory is invariant @@ -2019,7 +2039,7 @@ void HttpRequestTestObjectType::test<17>() ba, options, HttpHeaders::ptr_t(), - &handler); + handlerp); ensure("Valid handle returned for get request", handle != LLCORE_HTTP_HANDLE_INVALID); ba->release(); ba = NULL; @@ -2040,7 +2060,7 @@ void HttpRequestTestObjectType::test<17>() mStatus = HttpStatus(); handler.mHeadersRequired.clear(); handler.mHeadersDisallowed.clear(); - handle = req->requestStopThread(&handler); + handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -2110,6 +2130,7 @@ void HttpRequestTestObjectType::test<18>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); @@ -2122,7 +2143,7 @@ void HttpRequestTestObjectType::test<18>() try { - // Get singletons created + // Get singletons created HttpRequest::createService(); // Start threading early so that thread memory is invariant @@ -2207,7 +2228,7 @@ void HttpRequestTestObjectType::test<18>() ba, options, HttpHeaders::ptr_t(), - &handler); + handlerp); ensure("Valid handle returned for get request", handle != LLCORE_HTTP_HANDLE_INVALID); ba->release(); ba = NULL; @@ -2228,7 +2249,7 @@ void HttpRequestTestObjectType::test<18>() mStatus = HttpStatus(); handler.mHeadersRequired.clear(); handler.mHeadersDisallowed.clear(); - handle = req->requestStopThread(&handler); + handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -2298,6 +2319,7 @@ void HttpRequestTestObjectType::test<19>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); @@ -2309,7 +2331,7 @@ void HttpRequestTestObjectType::test<19>() try { - // Get singletons created + // Get singletons created HttpRequest::createService(); // Start threading early so that thread memory is invariant @@ -2397,7 +2419,7 @@ void HttpRequestTestObjectType::test<19>() url_base + "reflect/", options, headers, - &handler); + handlerp); ensure("Valid handle returned for get request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump. @@ -2415,7 +2437,7 @@ void HttpRequestTestObjectType::test<19>() mStatus = HttpStatus(); handler.mHeadersRequired.clear(); handler.mHeadersDisallowed.clear(); - handle = req->requestStopThread(&handler); + handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -2480,6 +2502,7 @@ void HttpRequestTestObjectType::test<20>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); @@ -2492,7 +2515,8 @@ void HttpRequestTestObjectType::test<20>() try { - // Get singletons created + + // Get singletons created HttpRequest::createService(); // Start threading early so that thread memory is invariant @@ -2596,7 +2620,7 @@ void HttpRequestTestObjectType::test<20>() ba, options, headers, - &handler); + handlerp); ensure("Valid handle returned for get request", handle != LLCORE_HTTP_HANDLE_INVALID); ba->release(); ba = NULL; @@ -2617,7 +2641,7 @@ void HttpRequestTestObjectType::test<20>() mStatus = HttpStatus(); handler.mHeadersRequired.clear(); handler.mHeadersDisallowed.clear(); - handle = req->requestStopThread(&handler); + handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -2686,6 +2710,7 @@ void HttpRequestTestObjectType::test<21>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); @@ -2698,7 +2723,7 @@ void HttpRequestTestObjectType::test<21>() try { - // Get singletons created + // Get singletons created HttpRequest::createService(); // Start threading early so that thread memory is invariant @@ -2796,7 +2821,7 @@ void HttpRequestTestObjectType::test<21>() ba, options, headers, - &handler); + handlerp); ensure("Valid handle returned for get request", handle != LLCORE_HTTP_HANDLE_INVALID); ba->release(); ba = NULL; @@ -2817,7 +2842,7 @@ void HttpRequestTestObjectType::test<21>() mStatus = HttpStatus(); handler.mHeadersRequired.clear(); handler.mHeadersDisallowed.clear(); - handle = req->requestStopThread(&handler); + handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -2882,7 +2907,8 @@ void HttpRequestTestObjectType::test<22>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); - + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); + // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); mHandlerCalls = 0; @@ -2892,7 +2918,7 @@ void HttpRequestTestObjectType::test<22>() try { - // options set + // options set options = HttpOptions::ptr_t(new HttpOptions()); options->setRetries(1); // Partial_File is retryable and can timeout in here @@ -2923,7 +2949,7 @@ void HttpRequestTestObjectType::test<22>() 25, options, HttpHeaders::ptr_t(), - &handler); + handlerp); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); } @@ -2955,7 +2981,7 @@ void HttpRequestTestObjectType::test<22>() 25, options, HttpHeaders::ptr_t(), - &handler); + handlerp); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); } @@ -2987,7 +3013,7 @@ void HttpRequestTestObjectType::test<22>() 25, options, HttpHeaders::ptr_t(), - &handler); + handlerp); ensure("Valid handle returned for ranged request", handle != LLCORE_HTTP_HANDLE_INVALID); } @@ -3007,7 +3033,7 @@ void HttpRequestTestObjectType::test<22>() // ====================================== mStatus = HttpStatus(); mHandlerCalls = 0; - HttpHandle handle = req->requestStopThread(&handler); + HttpHandle handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again @@ -3074,7 +3100,8 @@ void HttpRequestTestObjectType::test<23>() // references to it after completion of this method. // Create before memory record as the string copy will bump numbers. TestHandler2 handler(this, "handler"); - std::string url_base(get_base_url() + "/503/"); // path to 503 generators + LLCore::HttpHandler::ptr_t handlerp(&handler, NoOpDeletor); + std::string url_base(get_base_url() + "/503/"); // path to 503 generators // record the total amount of dynamically allocated memory mMemTotal = GetMemTotal(); @@ -3085,7 +3112,7 @@ void HttpRequestTestObjectType::test<23>() try { - // Get singletons created + // Get singletons created HttpRequest::createService(); // Start threading early so that thread memory is invariant @@ -3114,7 +3141,7 @@ void HttpRequestTestObjectType::test<23>() 0, opts, HttpHeaders::ptr_t(), - &handler); + handlerp); std::ostringstream testtag; testtag << "Valid handle returned for 503 request #" << i; @@ -3136,7 +3163,7 @@ void HttpRequestTestObjectType::test<23>() // Okay, request a shutdown of the servicing thread mStatus = HttpStatus(); mHandlerCalls = 0; - HttpHandle handle = req->requestStopThread(&handler); + HttpHandle handle = req->requestStopThread(handlerp); ensure("Valid handle returned for second request", handle != LLCORE_HTTP_HANDLE_INVALID); // Run the notification pump again -- cgit v1.2.3 From 6ff0bff8f0f65a77e66c86077d8d2d6a9f8930c7 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 15 Oct 2015 11:42:43 -0700 Subject: Another fix for unit tests. Missed on Windows. --- indra/llcorehttp/tests/test_httprequest.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcorehttp/tests/test_httprequest.hpp') diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp index 965a94bc38..463e55dd7e 100755 --- a/indra/llcorehttp/tests/test_httprequest.hpp +++ b/indra/llcorehttp/tests/test_httprequest.hpp @@ -247,7 +247,7 @@ void HttpRequestTestObjectType::test<2>() ensure("Memory being used", mMemTotal < GetMemTotal()); // Issue a NoOp - HttpHandle handle = req->requestNoOp(NULL); + HttpHandle handle = req->requestNoOp(LLCore::HttpHandler::ptr_t()); ensure("Request issued", handle != LLCORE_HTTP_HANDLE_INVALID); // release the request object -- cgit v1.2.3