summaryrefslogtreecommitdiff
path: root/indra/llmessage/tests/commtest.h
diff options
context:
space:
mode:
authorDave SIMmONs <simon@lindenlab.com>2011-05-16 16:16:11 -0700
committerDave SIMmONs <simon@lindenlab.com>2011-05-16 16:16:11 -0700
commiteaf293f62f06e37f914efaf1cd33ab63648699d4 (patch)
tree1110079e0deff4b48e9eb841b3b6883f0c6e4b0d /indra/llmessage/tests/commtest.h
parent8a6965a3f94c0e56e0c2b17af329a6ac2c235735 (diff)
parent113f532ee57eeeca4dc7eb6ca05f923f1f3543d3 (diff)
Merge latest from lindenlab/viewer-development
Diffstat (limited to 'indra/llmessage/tests/commtest.h')
-rw-r--r--indra/llmessage/tests/commtest.h20
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";