Make sure gdb is installed for tests.
[m6w6/libmemcached] / libtest / unittest.cc
index bffa4ecbf6544cd50b694bd13b14d3c234a99893..7f0c7404fc2d5ca74997efaf1dc3a0bfcb281809 100644 (file)
@@ -324,6 +324,7 @@ static test_return_t application_true_BINARY(void *)
 
 static test_return_t application_gdb_true_BINARY2(void *)
 {
+  test_skip(0, access("/usr/bin/gdb", X_OK ));
   Application true_app("true");
   true_app.use_gdb();
 
@@ -335,6 +336,7 @@ static test_return_t application_gdb_true_BINARY2(void *)
 
 static test_return_t application_gdb_true_BINARY(void *)
 {
+  test_skip(0, access("/usr/bin/gdb", X_OK ));
   Application true_app("true");
   true_app.use_gdb();
 
@@ -362,8 +364,24 @@ static test_return_t application_doesnotexist_BINARY(void *)
   Application true_app("doesnotexist");
 
   const char *args[]= { "--fubar", 0 };
+#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
+  test_compare(Application::INVALID, true_app.run(args));
+#else
   test_compare(Application::SUCCESS, true_app.run(args));
-  test_compare(Application::INVALID, true_app.wait());
+#endif
+  // Behavior is different if we are running under valgrind
+  if (getenv("TESTS_ENVIRONMENT") and strstr(getenv("TESTS_ENVIRONMENT"), "valgrind"))
+  {
+    test_compare(Application::FAILURE, true_app.wait());
+  }
+  else
+  {
+#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
+    test_compare(Application::FAILURE, true_app.wait());
+#else
+    test_compare(Application::INVALID, true_app.wait());
+#endif
+  }
   test_compare(0, true_app.stdout_result().size());
 
   return TEST_SUCCESS;
@@ -539,6 +557,7 @@ static test_return_t wait_services_BINARY2(void *)
 
 static test_return_t wait_services_appliction_TEST(void *)
 {
+  test_skip(0, access("/usr/bin/gdb", X_OK ));
   test_skip(0, access("/etc/services", R_OK ));
 
   libtest::Application wait_app("libtest/wait", true);
@@ -553,6 +572,11 @@ static test_return_t wait_services_appliction_TEST(void *)
 
 static test_return_t gdb_wait_services_appliction_TEST(void *)
 {
+#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
+  test_skip(0, TARGET_OS_OSX);
+#endif
+
+  test_skip(0, access("/usr/bin/gdb", X_OK ));
   test_skip(0, access("/etc/services", R_OK ));
 
   libtest::Application wait_app("libtest/wait", true);
@@ -567,6 +591,12 @@ static test_return_t gdb_wait_services_appliction_TEST(void *)
 
 static test_return_t gdb_abort_services_appliction_TEST(void *)
 {
+  test_skip(0, access("/usr/bin/gdb", X_OK ));
+
+#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
+  test_skip(0, TARGET_OS_OSX);
+#endif
+
   libtest::Application abort_app("libtest/abort", true);
   abort_app.use_gdb();