Skip to content

Commit

Permalink
Bug fixes for tests and error handling (#189)
Browse files Browse the repository at this point in the history
* bugfixes to error handling and tests

- handle potential nullptr coming from strerror(errno)
- removed hardcoded "/tmp" in tests and instead use the TMPDIR variable on Linux and Mac. Depending on the build environment a hard coded "/tmp" may not be accessible, leading to sporadic test failures.

Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com

* fix spacing

Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com

* set TMPDIR in tavis ci build

travis ci doesn't appear to automatically set a TMPDIR env var on Linux.


Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com

* Back out travis CI.

exporting TMPDIR for travis CI linux has issues when running valgrind.

Go back to using a hard-coded "/tmp" during testing only if TMPDIR isn't set.

Signed-off-by: The MathWorks, Inc. Roy.Lurie@mathworks.com
  • Loading branch information
jeffdiclemente committed Mar 14, 2017
1 parent 3cc4bfa commit a041ca0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion framework/src/util/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ int GetLastErrorNo()
std::string GetLastErrorStr()
{
#ifdef US_PLATFORM_POSIX
return std::string(strerror(errno));
char* errorString = strerror(errno);
return std::string(((errorString == nullptr)?"":errorString));
#else
// Retrieve the system error message for the last-error code
LPVOID lpMsgBuf;
Expand Down
3 changes: 2 additions & 1 deletion framework/test/TestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ std::string GetTempDirectory()
if (buffer) CoTaskMemFree(static_cast<void*>(buffer));
return std::string(temp_dir.cbegin(), temp_dir.cend());
#else
return std::string("/tmp");
char* tempdir = getenv("TMPDIR");
return std::string(((tempdir == nullptr)?"/tmp":tempdir));
#endif
}

Expand Down

0 comments on commit a041ca0

Please sign in to comment.