diff options
| author | Loren Shih <seraph@lindenlab.com> | 2011-05-20 14:56:10 -0400 |
|---|---|---|
| committer | Loren Shih <seraph@lindenlab.com> | 2011-05-20 14:56:10 -0400 |
| commit | 6f5313caea9bb8458dca23bbaf4f10cd6641c7fb (patch) | |
| tree | ac34191250860e5f250cf1cc2e9199cdaa8204f6 /indra/llmessage/tests/commtest.h | |
| parent | eb8221338e0276b9afe8d92738166f97782d48d6 (diff) | |
| parent | 0b612741d53a044a0179e1c32018bf8cd4213631 (diff) | |
automated merge mesh-development -> davep-mesh-candidate-2010
Diffstat (limited to 'indra/llmessage/tests/commtest.h')
| -rw-r--r-- | indra/llmessage/tests/commtest.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/indra/llmessage/tests/commtest.h b/indra/llmessage/tests/commtest.h index 32035783e2..0fef596df2 100644 --- a/indra/llmessage/tests/commtest.h +++ b/indra/llmessage/tests/commtest.h @@ -35,6 +35,13 @@ #include "llhost.h" #include "stringize.h" #include <string> +#include <stdexcept> +#include <boost/lexical_cast.hpp> + +struct CommtestError: public std::runtime_error +{ + CommtestError(const std::string& what): std::runtime_error(what) {} +}; /** * This struct is shared by a couple of standalone comm tests (ADD_COMM_BUILD_TEST). @@ -55,13 +62,24 @@ struct commtest_data replyPump("reply"), errorPump("error"), success(false), - host("127.0.0.1", 8000), + host("127.0.0.1", getport("PORT")), server(STRINGIZE("http://" << host.getString() << "/")) { replyPump.listen("self", boost::bind(&commtest_data::outcome, this, _1, true)); errorPump.listen("self", boost::bind(&commtest_data::outcome, this, _1, false)); } + static int getport(const std::string& var) + { + const char* port = getenv(var.c_str()); + if (! port) + { + throw CommtestError("missing $PORT environment variable"); + } + // This will throw, too, if the value of PORT isn't numeric. + return boost::lexical_cast<int>(port); + } + bool outcome(const LLSD& _result, bool _success) { // std::cout << "commtest_data::outcome(" << _result << ", " << _success << ")\n"; |
