Browse Source

First part, test for lp:1098409

Brian Aker 12 years ago
parent
commit
eeb1f4b018

+ 1 - 1
libtest/alarm.cc

@@ -68,7 +68,7 @@ void set_alarm(long tv_sec, long tv_usec)
 
     if (errno != 0)
     {
-      fatal_message("Bad value for YATL_ALARM");
+      FATAL("Bad value for YATL_ALARM");
     }
     else if (tv_sec == 0)
     {

+ 1 - 1
libtest/client.cc

@@ -198,7 +198,7 @@ bool SimpleClient::instance_connect()
         }
         else
         {
-          fatal_message(strerror(errno));
+          FATAL(strerror(errno));
         }
         address_info_next= address_info_next->ai_next;
       }

+ 7 - 9
libtest/cmdline.cc

@@ -138,7 +138,7 @@ Application::Application(const std::string& arg, const bool _use_libtool_arg) :
     {
       if (libtool() == NULL)
       {
-        fatal_message("libtool requested, but know libtool was found");
+        FATAL("libtool requested, but know libtool was found");
       }
     }
 
@@ -366,15 +366,15 @@ bool Application::slurp()
 
     case EFAULT:
     case ENOMEM:
-      fatal_message(strerror(error));
+      FATAL(strerror(error));
       break;
 
     case EINVAL:
-      fatal_message("RLIMIT_NOFILE exceeded, or if OSX the timeout value was invalid");
+      FATAL("RLIMIT_NOFILE exceeded, or if OSX the timeout value was invalid");
       break;
 
     default:
-      fatal_message(strerror(error));
+      FATAL(strerror(error));
       break;
     }
 
@@ -589,7 +589,7 @@ void Application::Pipe::reset()
   if (pipe(_pipe_fd) == -1)
 #endif
   {
-    fatal_message(strerror(errno));
+    FATAL(strerror(errno));
   }
   _open[0]= true;
   _open[1]= true;
@@ -655,14 +655,12 @@ void Application::Pipe::dup_for_spawn(posix_spawn_file_actions_t& file_actions)
   int ret;
   if ((ret= posix_spawn_file_actions_adddup2(&file_actions, _pipe_fd[type], _std_fd )) < 0)
   {
-    Error << "posix_spawn_file_actions_adddup2(" << strerror(ret) << ")";
-    fatal_message(strerror(ret));
+    FATAL("posix_spawn_file_actions_adddup2(%s)", strerror(ret));
   }
 
   if ((ret= posix_spawn_file_actions_addclose(&file_actions, _pipe_fd[type])) < 0)
   {
-    Error << "posix_spawn_file_actions_adddup2(" << strerror(ret) << ")";
-    fatal_message(strerror(ret));
+    FATAL("posix_spawn_file_actions_addclose(%s)", strerror(ret));
   }
 }
 

+ 1 - 1
libtest/collection.cc

@@ -159,7 +159,7 @@ test_return_t Collection::exec()
         break;
 
       default:
-        fatal_message("invalid return code");
+        FATAL("invalid return code");
       }
 #if 0
       @TODO add code here to allow for a collection to define a method to reset to allow tests to continue.

+ 1 - 1
libtest/comparison.hpp

@@ -95,7 +95,7 @@ bool _compare_strcmp(const char *file, int line, const char *func, const T1_comp
 {
   if (__expected == NULL)
   {
-    fatal_message("Expected value was NULL, programmer error");
+    FATAL("Expected value was NULL, programmer error");
   }
 
   if (__actual == NULL)

+ 3 - 3
libtest/http.cc

@@ -57,13 +57,13 @@ static void initialize_curl_startup()
 #if defined(HAVE_LIBCURL) && HAVE_LIBCURL
   if (curl_global_init(CURL_GLOBAL_ALL))
   {
-    fatal_message("curl_global_init(CURL_GLOBAL_ALL) failed");
+    FATAL("curl_global_init(CURL_GLOBAL_ALL) failed");
   }
 #endif
 
   if (atexit(cleanup_curl))
   {
-    fatal_message("atexit() failed");
+    FATAL("atexit() failed");
   }
 }
 
@@ -73,7 +73,7 @@ static void initialize_curl(void)
   int ret;
   if ((ret= pthread_once(&start_key_once, initialize_curl_startup)) != 0)
   {
-    fatal_message(strerror(ret));
+    FATAL(strerror(ret));
   }
 }
 

+ 4 - 4
libtest/port.cc

@@ -204,22 +204,22 @@ in_port_t get_free_port()
   // We handle the case where if we max out retries, we still abort.
   if (retries == 0)
   {
-    fatal_message("No port could be found, exhausted retry");
+    FATAL("No port could be found, exhausted retry");
   }
 
   if (ret_port == 0)
   {
-    fatal_message("No port could be found");
+    FATAL("No port could be found");
   }
 
   if (ret_port == default_port)
   {
-    fatal_message("No port could be found");
+    FATAL("No port could be found");
   }
 
   if (ret_port <= 1024)
   {
-    fatal_message("No port could be found, though some where available below or at 1024");
+    FATAL("No port could be found, though some where available below or at 1024");
   }
 
   all_socket_fd.last_port= ret_port;

+ 17 - 1
libtest/result.hpp

@@ -57,10 +57,26 @@ do \
   throw libtest::__failure(LIBYATL_DEFAULT_PARAM, __VA_ARGS__); \
 } while (0)
 
-#define fatal_message(...) \
+#define FATAL(...) \
 do \
 { \
   throw libtest::fatal(LIBYATL_DEFAULT_PARAM, __VA_ARGS__); \
 } while (0)
 
+#define FATAL_IF(__expression, ...) \
+do \
+{ \
+  if ((__expression)) { \
+    throw libtest::fatal(LIBYATL_DEFAULT_PARAM, (#__expression)); \
+  } \
+} while (0)
+
+#define FATAL_IF_(__expression, ...) \
+do \
+{ \
+  if ((__expression)) { \
+    throw libtest::fatal(LIBYATL_DEFAULT_PARAM, __VA_ARGS__); \
+  } \
+} while (0)
+
 #define fatal_assert(__assert) if((__assert)) {} else { throw libtest::fatal(LIBYATL_DEFAULT_PARAM, #__assert); }

+ 1 - 1
libtest/strerror.cc

@@ -52,7 +52,7 @@ const char *test_strerror(test_return_t code)
     return "skipped";
   }
 
-  fatal_message("No port could be found");
+  FATAL("No port could be found");
 }
 
 } // namespace libtest

+ 1 - 1
libtest/unittest.cc

@@ -896,7 +896,7 @@ static test_return_t create_tmpfile_TEST(void *)
 static test_return_t fatal_message_TEST(void *)
 {
   ASSERT_EQ(fatal_calls++, fatal::disabled_counter());
-  fatal_message("Fatal test");
+  FATAL("Fatal test");
 
   return TEST_SUCCESS;
 }

Some files were not shown because too many files changed in this diff