From 747784a9b1abb3ea85abb9fcc05981992be6f485 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 21 Dec 2012 08:52:39 -0500 Subject: MAINT-2168: fail with real message if required var PORT not set. llhttpclient_test.cpp is only supposed to be run by test_llsdmessage_peer.py, as specified in llmessage/CMakeLists.txt. test_llsdmessage_peer.py sets the environment variable PORT before running INTEGRATION_TEST_llhttpclient. While it's not yet clear under what circumstances INTEGRATION_TEST_llhttpclient could find PORT not set (getenv() returning NULL), it's obvious that in that case, the previous code might well crash. Make it at least fail with an explanatory message rather than a mysterious large negative integer. In theory, occurrences of that message could help us solve the underlying issue. --- indra/llmessage/tests/llhttpclient_test.cpp | 36 +++++++++++++++++------------ 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/indra/llmessage/tests/llhttpclient_test.cpp b/indra/llmessage/tests/llhttpclient_test.cpp index a2be307cc8..7c3def6024 100644 --- a/indra/llmessage/tests/llhttpclient_test.cpp +++ b/indra/llmessage/tests/llhttpclient_test.cpp @@ -48,7 +48,7 @@ namespace tut { LLSD storage; - + class LLSDStorageNode : public LLHTTPNode { public: @@ -82,8 +82,13 @@ namespace tut { public: HTTPClientTestData(): - local_server(STRINGIZE("http://127.0.0.1:" << getenv("PORT") << "/")) + PORT(getenv("PORT")), + // Turning NULL PORT into empty string doesn't make things work; + // that's just to keep this initializer from blowing up. We test + // PORT separately in the constructor body. + local_server(STRINGIZE("http://127.0.0.1:" << (PORT? PORT : "") << "/")) { + ensure("Set environment variable PORT to local test server port", PORT); apr_pool_create(&mPool, NULL); LLCurl::initClass(false); mServerPump = new LLPumpIO(mPool); @@ -91,7 +96,7 @@ namespace tut LLHTTPClient::setPump(*mClientPump); } - + ~HTTPClientTestData() { delete mServerPump; @@ -107,7 +112,7 @@ namespace tut LLHTTPStandardServices::useServices(); LLHTTPRegistrar::buildAllServices(root); } - + void runThePump(float timeout = 100.0f) { LLTimer timer; @@ -134,6 +139,7 @@ namespace tut mServerPump = NULL; } + const char* const PORT; const std::string local_server; private: @@ -148,11 +154,11 @@ namespace tut { std::string msg = llformat("error() called when not expected, status %d", - mStatus); + mStatus); fail(msg); } } - + void ensureStatusError() { if (!mSawError) @@ -160,7 +166,7 @@ namespace tut fail("error() wasn't called"); } } - + LLSD getResult() { return mResult; @@ -169,7 +175,7 @@ namespace tut { return mHeader; } - + protected: bool mSawError; U32 mStatus; @@ -187,18 +193,18 @@ namespace tut : mClient(client) { } - + public: static Result* build(HTTPClientTestData& client) { return new Result(client); } - + ~Result() { mClient.mResultDeleted = true; } - + virtual void error(U32 status, const std::string& reason) { mClient.mSawError = true; @@ -216,7 +222,7 @@ namespace tut const LLSD& content) { LLHTTPClient::Responder::completed(status, reason, content); - + mClient.mSawCompleted = true; } @@ -244,12 +250,12 @@ namespace tut mResult.clear(); mHeader.clear(); mResultDeleted = false; - + return Result::build(*this); } }; - - + + typedef test_group HTTPClientTestGroup; typedef HTTPClientTestGroup::object HTTPClientTestObject; HTTPClientTestGroup httpClientTestGroup("http_client"); -- cgit v1.2.3 From 144fcf62fb01c4f98ee6abb587f9a487d5683257 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 21 Dec 2012 09:01:09 -0500 Subject: MAINT-2168: Backed out changeset 797318b62275, pushed to wrong repo This changeset was prematurely pushed to the wrong repository. Back it out to propagate it the right way. --- indra/llmessage/tests/llhttpclient_test.cpp | 36 ++++++++++++----------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/indra/llmessage/tests/llhttpclient_test.cpp b/indra/llmessage/tests/llhttpclient_test.cpp index 7c3def6024..a2be307cc8 100644 --- a/indra/llmessage/tests/llhttpclient_test.cpp +++ b/indra/llmessage/tests/llhttpclient_test.cpp @@ -48,7 +48,7 @@ namespace tut { LLSD storage; - + class LLSDStorageNode : public LLHTTPNode { public: @@ -82,13 +82,8 @@ namespace tut { public: HTTPClientTestData(): - PORT(getenv("PORT")), - // Turning NULL PORT into empty string doesn't make things work; - // that's just to keep this initializer from blowing up. We test - // PORT separately in the constructor body. - local_server(STRINGIZE("http://127.0.0.1:" << (PORT? PORT : "") << "/")) + local_server(STRINGIZE("http://127.0.0.1:" << getenv("PORT") << "/")) { - ensure("Set environment variable PORT to local test server port", PORT); apr_pool_create(&mPool, NULL); LLCurl::initClass(false); mServerPump = new LLPumpIO(mPool); @@ -96,7 +91,7 @@ namespace tut LLHTTPClient::setPump(*mClientPump); } - + ~HTTPClientTestData() { delete mServerPump; @@ -112,7 +107,7 @@ namespace tut LLHTTPStandardServices::useServices(); LLHTTPRegistrar::buildAllServices(root); } - + void runThePump(float timeout = 100.0f) { LLTimer timer; @@ -139,7 +134,6 @@ namespace tut mServerPump = NULL; } - const char* const PORT; const std::string local_server; private: @@ -154,11 +148,11 @@ namespace tut { std::string msg = llformat("error() called when not expected, status %d", - mStatus); + mStatus); fail(msg); } } - + void ensureStatusError() { if (!mSawError) @@ -166,7 +160,7 @@ namespace tut fail("error() wasn't called"); } } - + LLSD getResult() { return mResult; @@ -175,7 +169,7 @@ namespace tut { return mHeader; } - + protected: bool mSawError; U32 mStatus; @@ -193,18 +187,18 @@ namespace tut : mClient(client) { } - + public: static Result* build(HTTPClientTestData& client) { return new Result(client); } - + ~Result() { mClient.mResultDeleted = true; } - + virtual void error(U32 status, const std::string& reason) { mClient.mSawError = true; @@ -222,7 +216,7 @@ namespace tut const LLSD& content) { LLHTTPClient::Responder::completed(status, reason, content); - + mClient.mSawCompleted = true; } @@ -250,12 +244,12 @@ namespace tut mResult.clear(); mHeader.clear(); mResultDeleted = false; - + return Result::build(*this); } }; - - + + typedef test_group HTTPClientTestGroup; typedef HTTPClientTestGroup::object HTTPClientTestObject; HTTPClientTestGroup httpClientTestGroup("http_client"); -- cgit v1.2.3