Browse Source

Updates m4, and fixes rare race condition in stress test case.

Brian Aker 12 years ago
parent
commit
5eec676a0a
5 changed files with 64 additions and 41 deletions
  1. 16 0
      libtest/alarm.cc
  2. 24 30
      m4/ax_pthread_timedjoin_np.m4
  3. 21 10
      m4/ax_vcs_checkout.m4
  4. 1 1
      man/include.am
  5. 2 0
      tests/stress_worker.cc

+ 16 - 0
libtest/alarm.cc

@@ -59,6 +59,22 @@ void set_alarm()
 
 void set_alarm(long tv_sec, long tv_usec)
 {
+  // For the moment use any value to YATL_ALARM to cancel alarming.
+  if (getenv("YATL_ALARM"))
+  {
+    errno= 0;
+    tv_sec= strtol(getenv("YATL_ALARM"), (char **) NULL, 10);
+
+    if (errno != 0)
+    {
+      fatal_message("Bad value for YATL_ALARM");
+    }
+    else if (tv_sec == 0)
+    {
+      cancel_alarm();
+    }
+  }
+
 #if defined(TARGET_OS_OSX) && TARGET_OS_OSX
   struct timeval it_value= { time_t(tv_sec), suseconds_t(tv_usec) };
 #else

+ 24 - 30
m4/ax_pthread_timedjoin_np.m4

@@ -4,7 +4,7 @@
 #
 # SYNOPSIS
 #
-#   AX_PTHREAD_TIMEDJOIN_NP
+#   AX_PTHREAD_TIMEDJOIN_NP()
 #
 # DESCRIPTION
 #
@@ -19,37 +19,31 @@
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 4
+#serial 5
 
-  AC_DEFUN([AX_PTHREAD_TIMEDJOIN_NP], [
-      AC_REQUIRE([AX_PTHREAD])
-      AC_CACHE_CHECK([check for pthread_timedjoin_np], [ax_cv_pthread_timedjoin_np], [
-        save_LDFLAGS="$LDFLAGS"
-        LDFLAGS="$PTHREAD_LIBS"
-        AC_LANG_PUSH([C])
-        AC_LINK_IFELSE([
-          AC_LANG_PROGRAM([
-#ifndef _GNU_SOURCE 
-#define _GNU_SOURCE 
-#endif
-
-#include <stdlib.h> 
+AC_DEFUN([AX_PTHREAD_TIMEDJOIN_NP],
+    [AC_REQUIRE([AX_PTHREAD])
+    AC_CACHE_CHECK([check for pthread_timedjoin_np], [ax_cv_pthread_timedjoin_np],
+      [AX_SAVE_FLAGS
+      CFLAGS="$PTHREAD_CFLAGS"
+      LIBS="$PTHREAD_LIBS"
+      AC_LANG_PUSH([C])
+      AC_LINK_IFELSE(
+        [AC_LANG_PROGRAM(
+          [
 #include <pthread.h>
-            ], [
-            pthread_t thread;
-            pthread_timedjoin_np(thread, NULL);
-            ])],
-          [ax_cv_pthread_timedjoin_np=yes],
-          [])
-
-        AC_LANG_POP
-        LDFLAGS="$save_LDFLAGS"
-
-      ])
+#include <stdlib.h>
+          ],[
+          pthread_t thread;
+          pthread_timedjoin_np(thread, NULL, NULL);
+          ])],
+        [ax_cv_pthread_timedjoin_np=yes],[])
 
-      AS_IF([test "$ax_cv_pthread_timedjoin_np" = yes],[
-          AC_DEFINE(HAVE_PTHREAD_TIMEDJOIN_NP,[1],[Define if pthread_timedjoin_np is present in pthread.h.])],[
-          AC_DEFINE(HAVE_PTHREAD_TIMEDJOIN_NP,[0],[Define if pthread_timedjoin_np is present in pthread.h.])
-          ])
+      AC_LANG_POP
+      AX_RESTORE_FLAGS
       ])
 
+    AS_IF([test "$ax_cv_pthread_timedjoin_np" = yes],
+        [AC_DEFINE(HAVE_PTHREAD_TIMEDJOIN_NP,[1],[Define if pthread_timedjoin_np is present in pthread.h.])],
+        [AC_DEFINE(HAVE_PTHREAD_TIMEDJOIN_NP,[0],[Define if pthread_timedjoin_np is present in pthread.h.])])
+    ])

+ 21 - 10
m4/ax_vcs_checkout.m4

@@ -45,17 +45,28 @@
 #  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 #  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-#serial 3
+#serial 5
 
-AC_DEFUN([AX_VCS_CHECKOUT],[
-    AC_CACHE_CHECK([for vcs checkout], [ac_cv_vcs_checkout], [
-      AS_IF([test -d ".bzr"],[ac_cv_vcs_checkout=yes])
-      AS_IF([test -d ".svn"],[ac_cv_vcs_checkout=yes])
-      AS_IF([test -d ".hg"], [ac_cv_vcs_checkout=yes])
-      AS_IF([test -d ".git"],[ac_cv_vcs_checkout=yes])
-      ],[
-      ac_cv_vcs_checkout=no
+AC_DEFUN([AX_VCS_SYSTEM],
+    [AC_CACHE_CHECK([for vcs system], [ac_cv_vcs_system],
+      [ac_cv_vcs_system="none"
+      AS_IF([test -d ".bzr"],[ac_cv_vcs_system="bazaar"])
+      AS_IF([test -d ".svn"],[ac_cv_vcs_system="svn"])
+      AS_IF([test -d ".hg"],[ac_cv_vcs_system="mercurial"])
+      AS_IF([test -d ".git"],[ac_cv_vcs_system="git"])
+      ])
+    ])
+
+AC_DEFUN([AX_VCS_CHECKOUT],
+    [AC_REQUIRE([AX_VCS_SYSTEM])
+    AC_CACHE_CHECK([for vcs checkout],[ac_cv_vcs_checkout],
+      [AS_IF([test "x$ac_cv_vcs_system" != "xnone"],
+        [ac_cv_vcs_checkout=yes],
+        [ac_cv_vcs_checkout=no])
       ])
 
-    AM_CONDITIONAL([MAINTAINER_MODE], [ test "$ac_cv_vcs_checkout" = "yes" ])
+    AM_CONDITIONAL([IS_VCS_CHECKOUT], [test "x$ac_cv_vcs_checkout" = "xyes"])
+    AS_IF([test "x$ac_cv_vcs_checkout" = "xyes"],
+      [AC_DEFINE([VCS_CHECKOUT], [1], [Define if the code was built from VCS.])
+      ])
     ])

+ 1 - 1
man/include.am

@@ -4,7 +4,7 @@
 
 if HAVE_RECENT_SPHINX
 
-if MAINTAINER_MODE
+if IS_VCS_CHECKOUT
 
 # Build rule for documentation
 $(dist_man_MANS): man

+ 2 - 0
tests/stress_worker.cc

@@ -208,6 +208,8 @@ static bool join_thread(pthread_t& thread_arg, struct timespec& ts)
       return false;
     }
 #endif
+
+    return true;
   }
 
   if ((error= pthread_join(thread_arg, NULL)) != 0)