summaryrefslogtreecommitdiff
path: root/indra/llcommon/tests
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2018-12-14 15:38:13 -0500
committerNat Goodspeed <nat@lindenlab.com>2018-12-14 15:38:13 -0500
commitc4096f670c7b3d43f8a5c1f65ef7e02033b0329d (patch)
tree29f3f8cae0dc5bfc983a25ec6e4e9afb245d4925 /indra/llcommon/tests
parent132e708fec50fd756b822925313456c70a4ff27f (diff)
SL-10153: Review and rationalize fetching paths from environment.
Use LLStringUtil::getenv() or getoptenv() whenever we fetch a string that will be used as a pathname. Use LLFile::tmpdir() instead of getenv("TEMP"). As an added extra-special bonus, finally clean up $TMP/llcontrol-test-zzzzzz directories that have been accumulating every time we run a local build!
Diffstat (limited to 'indra/llcommon/tests')
-rw-r--r--indra/llcommon/tests/llleap_test.cpp7
-rw-r--r--indra/llcommon/tests/llprocess_test.cpp5
-rw-r--r--indra/llcommon/tests/llsdserialize_test.cpp7
3 files changed, 10 insertions, 9 deletions
diff --git a/indra/llcommon/tests/llleap_test.cpp b/indra/llcommon/tests/llleap_test.cpp
index c387da6c48..45648536c4 100644
--- a/indra/llcommon/tests/llleap_test.cpp
+++ b/indra/llcommon/tests/llleap_test.cpp
@@ -26,6 +26,7 @@
#include "wrapllerrs.h"
#include "llevents.h"
#include "llprocess.h"
+#include "llstring.h"
#include "stringize.h"
#include "StringVec.h"
#include <functional>
@@ -198,14 +199,12 @@ namespace tut
// basename.
reader_module(LLProcess::basename(
reader.getName().substr(0, reader.getName().length()-3))),
- pPYTHON(getenv("PYTHON")),
- PYTHON(pPYTHON? pPYTHON : "")
+ PYTHON(LLStringUtil::getenv("PYTHON"))
{
- ensure("Set PYTHON to interpreter pathname", pPYTHON);
+ ensure("Set PYTHON to interpreter pathname", !PYTHON.empty());
}
NamedExtTempFile reader;
const std::string reader_module;
- const char* pPYTHON;
const std::string PYTHON;
};
typedef test_group<llleap_data> llleap_group;
diff --git a/indra/llcommon/tests/llprocess_test.cpp b/indra/llcommon/tests/llprocess_test.cpp
index b27e125d2e..5c87cdabd9 100644
--- a/indra/llcommon/tests/llprocess_test.cpp
+++ b/indra/llcommon/tests/llprocess_test.cpp
@@ -34,6 +34,7 @@
#include "stringize.h"
#include "llsdutil.h"
#include "llevents.h"
+#include "llstring.h"
#include "wrapllerrs.h"
#if defined(LL_WINDOWS)
@@ -142,8 +143,8 @@ struct PythonProcessLauncher
mDesc(desc),
mScript("py", script)
{
- const char* PYTHON(getenv("PYTHON"));
- tut::ensure("Set $PYTHON to the Python interpreter", PYTHON);
+ auto PYTHON(LLStringUtil::getenv("PYTHON"));
+ tut::ensure("Set $PYTHON to the Python interpreter", !PYTHON.empty());
mParams.desc = desc + " script";
mParams.executable = PYTHON;
diff --git a/indra/llcommon/tests/llsdserialize_test.cpp b/indra/llcommon/tests/llsdserialize_test.cpp
index 745e3a168c..6ac974e659 100644
--- a/indra/llcommon/tests/llsdserialize_test.cpp
+++ b/indra/llcommon/tests/llsdserialize_test.cpp
@@ -41,6 +41,7 @@ typedef U32 uint32_t;
#include <sys/stat.h>
#include <sys/wait.h>
#include "llprocess.h"
+#include "llstring.h"
#endif
#include "boost/range.hpp"
@@ -1705,8 +1706,8 @@ namespace tut
template <typename CONTENT>
void python(const std::string& desc, const CONTENT& script, int expect=0)
{
- const char* PYTHON(getenv("PYTHON"));
- ensure("Set $PYTHON to the Python interpreter", PYTHON);
+ auto PYTHON(LLStringUtil::getenv("PYTHON"));
+ ensure("Set $PYTHON to the Python interpreter", !PYTHON.empty());
NamedTempFile scriptfile("py", script);
@@ -1714,7 +1715,7 @@ namespace tut
std::string q("\"");
std::string qPYTHON(q + PYTHON + q);
std::string qscript(q + scriptfile.getName() + q);
- int rc = _spawnl(_P_WAIT, PYTHON, qPYTHON.c_str(), qscript.c_str(), NULL);
+ int rc = _spawnl(_P_WAIT, PYTHON.c_str(), qPYTHON.c_str(), qscript.c_str(), NULL);
if (rc == -1)
{
char buffer[256];