You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2011/06/05 07:40:20 UTC

svn commit: r1131847 - in /incubator/mesos/trunk/src: configuration.cpp tests/main.cpp tests/testing_utils.cpp

Author: benh
Date: Sun Jun  5 05:40:20 2011
New Revision: 1131847

URL: http://svn.apache.org/viewvc?rev=1131847&view=rev
Log:
Added some error checking on libc calls

Modified:
    incubator/mesos/trunk/src/configuration.cpp
    incubator/mesos/trunk/src/tests/main.cpp
    incubator/mesos/trunk/src/tests/testing_utils.cpp

Modified: incubator/mesos/trunk/src/configuration.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/configuration.cpp?rev=1131847&r1=1131846&r2=1131847&view=diff
==============================================================================
--- incubator/mesos/trunk/src/configuration.cpp (original)
+++ incubator/mesos/trunk/src/configuration.cpp Sun Jun  5 05:40:20 2011
@@ -84,7 +84,10 @@ void Configuration::loadCommandLine(int 
   // Set home based on argument 0 if asked to do so
   if (inferMesosHomeFromArg0) {
     char buf[4096];
-    realpath(dirname(argv[0]), buf);
+    if (realpath(dirname(argv[0]), buf) == 0) {
+      throw ConfigurationException(
+          "Could not get directory containing argv[0] -- realpath failed");
+    }
     params["home"] = buf;
   }
 
@@ -137,7 +140,7 @@ void Configuration::loadConfigFile(const
   ifstream cfg(fname.c_str(), std::ios::in);
   if (!cfg.is_open()) {
     string message = "Couldn't read Mesos config file: " + fname;
-    throw new ConfigurationException(message.c_str());
+    throw ConfigurationException(message.c_str());
   }
 
   Params fileParams;

Modified: incubator/mesos/trunk/src/tests/main.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/main.cpp?rev=1131847&r1=1131846&r2=1131847&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/main.cpp (original)
+++ incubator/mesos/trunk/src/tests/main.cpp Sun Jun  5 05:40:20 2011
@@ -15,9 +15,10 @@ using namespace nexus::internal::test;
 int main(int argc, char **argv) {
   // Get absolute path to Mesos home direcotry (really src right now)
   char buf[4096];
-  realpath(dirname(argv[0]), buf);
+  if (realpath(dirname(argv[0]), buf) == 0)
+    PLOG(FATAL) << "Failed location of alltests using realpath";
   mesosHome = buf;
-  std::cout << "Mesos home is " << mesosHome << std::endl;
+  LOG(INFO) << "Mesos home is " << mesosHome;
 
   google::InitGoogleLogging("alltests");
   testing::InitGoogleTest(&argc, argv);

Modified: incubator/mesos/trunk/src/tests/testing_utils.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/testing_utils.cpp?rev=1131847&r1=1131846&r2=1131847&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/testing_utils.cpp (original)
+++ incubator/mesos/trunk/src/tests/testing_utils.cpp Sun Jun  5 05:40:20 2011
@@ -49,5 +49,6 @@ void test::enterTestDirectory(const char
   command = "mkdir -p '" + workDir + "'";
   ASSERT_EQ(0, system(command.c_str())) << "Command failed: " << command;
   // Change dir into it
-  chdir(workDir.c_str());
+  if (chdir(workDir.c_str()) != 0)
+    FAIL() << "Could not chdir into " << workDir;
 }