Portability fixes for FreeBSD and Mac OS. Check broke compatibility w/

old versions; added #ifdef so that both versions of check will work.
This commit is contained in:
Sears Russell 2005-03-13 02:24:01 +00:00
parent 1bfb634103
commit 34bfccb439
10 changed files with 244 additions and 16 deletions

View file

@ -1,3 +1,3 @@
LDADD=-ldb -lpthread
bin_PROGRAMS=transapp bdbRaw bdbHash bdbHashThreaded
bin_PROGRAMS=transapp bdbRaw bdbHash bdbHashThreaded bdbHashWriteRequests
AM_CFLAGS=-g

View file

@ -102,6 +102,9 @@ static void * go (void * arg_ptr) {
ThashInsert(xid, hash, (byte*)&j, sizeof(int), (byte*)&j, sizeof(int));
Tcommit(xid); // used to be outside of loop!
gettimeofday(&endtime_tv, NULL);
endtime.tv_sec = endtime_tv.tv_sec;
@ -132,7 +135,6 @@ static void * go (void * arg_ptr) {
}
Tcommit(xid);
/*
for(j = k * count; j < (k+1) *(count) ; j++) {
int tmp = -100;

View file

@ -24,10 +24,10 @@ AC_PROG_RANLIB
# [have_check="no"])
#AM_CONDITIONAL(HAVE_CHECK, test x"$have_check", "xyes")
AM_PATH_CHECK(,[have_check=true],
AC_MSG_WARN([Check not found; cannot run unit tests!])
[have_check=false])
AM_CONDITIONAL(HAVE_CHECK, test x$have_check = xtrue)
#AM_PATH_CHECK(,[have_check=true],
# AC_MSG_WARN([Check not found; cannot run unit tests!])
# [have_check=false])
#AM_CONDITIONAL(HAVE_CHECK, test x$have_check = xtrue)
## alas, it won't link if this is put in here.. instead, it's linked in manually in the test directory...
@ -67,10 +67,34 @@ if test "$db_cv_open_o_direct" = "yes"; then
AH_TEMPLATE(HAVE_O_DIRECT, [Define to 1 if you have the O_DIRECT flag.])
fi
AC_CONFIG_DB
AC_CHECK_LIB([check], [suite_create], , AC_MSG_WARN([Check not found; cannot run unit tests!]))
## This perl script thing is a total hack, but we need to define HAVE_LIBCHECK
## inside of an AM_CONDITIONAL to get conditional compilation to work.
AM_CONDITIONAL(HAVE_LIBCHECK, echo $LIBS | [
perl -ne 'if($_=~/-lcheck/)
{ print qq(Check found, make check will run full test suite.
); exit 0; } else { print qq(
--------------------------------
Check not found! Most tests will be skipped by make check!
--------------------------------
); exit 1; }'])
#have_libcheck", "xyes")
#AC_CHECK_LIB([check],
# [suite_create], AC_MSG_WARN([Check not found; cannot run unit tests!]
# have_check=yes,
# AC_MSG_WARN([Check not found; cannot run unit tests!]))
#AM_CONDITIONAL(HAVE_CHECK, test x"$have_check", "xyes")
#AC_CHECK_FUNC([tcase_set_timeout])
#AM_CONDITIONAL(HAVE_CHECK, test xyes, xyes)
AC_CHECK_LIB([m], [sqrt])
AC_CHECK_LIB([db], [db_open])
AC_CHECK_LIB([pthread], [pthread_create])
AC_CHECK_LIB([confuse], [cfg_set_validate_func])
# Checks for header files.
@ -92,7 +116,7 @@ AC_FUNC_MALLOC
AC_FUNC_MEMCMP
AC_FUNC_REALLOC
AC_FUNC_STAT
AC_CHECK_FUNCS([bzero fdatasync getcwd gettimeofday inet_ntoa localtime_r memmove memset mkdir powl posix_memalign socket sqrt strchr strdup strerror strrchr strstr strtoul])
AC_CHECK_FUNCS([bzero fdatasync getcwd gettimeofday inet_ntoa localtime_r memmove memset mkdir powl posix_memalign socket sqrt strchr strdup strerror strrchr strstr strtoul tcase_set_timeout])
#AC_CONFIG_LIBMYSQLD

View file

@ -88,6 +88,13 @@ int main ()
if test "x$no_check" = x ; then
AC_MSG_RESULT(yes)
# echo "checking for tcase_set_timeout in check"
# AC_TRY_LINK([#include <check.h>],
# [ Suite *s = suite_create("foo"); TCase *tc = tcase_create("bar"); tcase_set_timeout(tc, 0) ],
# [ echo tcase_set_timeout found. ],
# [ echo tcase_set_timeout not found. This is harmless.
#
# ]
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
@ -130,4 +137,6 @@ int main ()
rm -f conf.check-test
fi
])

186
m4/db.m4 Normal file
View file

@ -0,0 +1,186 @@
dnl
dnl Autoconf support for finding Berkeley DB
dnl
AC_DEFUN([AC_DB_HELP], [
cat <<EOF
Configure error with Berkeley DB...
If your installed version is not one of [$dbversions], you may
have to specify it with --with-dbver.
If your installation is in a non-standard path, you can specify
it with --with-db=DIR.
To download the latest version, go to http://www.sleepycat.com
To build and install to /usr/local/BerkeleyDB-<version>:
# cd <db_download_dir>/build_unix
# ../dist/configure --enable-cxx
# make
# make install
EOF
])
dnl
dnl Main macro for finding a usable db installation
dnl
AC_DEFUN([AC_CONFIG_DB], [
ac_dbvers='4.3 4.2'
ac_dbdir='yes'
AC_ARG_WITH(db,
AC_HELP_STRING([--with-db=DIR],
[location of a Berkeley DB installation (default system)]),
ac_dbdir=$withval)
AC_ARG_WITH(dbver,
AC_HELP_STRING([--with-dbver=VERSION],
Berkeley DB versions to try (default 4.3 or 4.2)),
ac_dbvers=$withval)
dnl
dnl First make sure we even want it
dnl
if test x$ac_dbdir = xno ; then
DB_ENABLED=0
else
DB_ENABLED=1
dnl
dnl Now check if we have a cached value, and if not, find it.
dnl
if test ! x$dtn_cv_path_db_h = x ; then
echo "checking for Berkeley DB installation... (cached) $dtn_cv_path_db_h/db_cxx.h, $dtn_cv_path_db_lib -l$dtn_cv_lib_db"
else
AC_FIND_DB
fi
if test ! $dtn_cv_path_db_h = /usr/include ; then
CPPFLAGS="$CPPFLAGS -I$dtn_cv_path_db_h"
fi
if test ! $dtn_cv_path_db_lib = /usr/lib ; then
LDFLAGS="$LDFLAGS -L$dtn_cv_path_db_lib"
fi
LIBS="$LIBS -l$dtn_cv_lib_db"
fi # DB_ENABLED
AC_SUBST(DB_ENABLED)
])
dnl
dnl Find db
dnl
AC_DEFUN([AC_FIND_DB], [
dtn_cv_path_db_h=
dtn_cv_path_db_lib=
dtn_cv_lib_db=
ac_save_CPPFLAGS="$CPPFLAGS"
ac_save_LDFLAGS="$LDFLAGS"
ac_save_LIBS="$LIBS"
AC_LANG_PUSH(C++)
for ac_dbver in $ac_dbvers ; do
ac_dbver_major=`echo $ac_dbver | cut -d . -f1`
ac_dbver_minor=`echo $ac_dbver | cut -d . -f2`
if test ! x"$ac_dbdir" = x"yes" ; then
ac_dbincdirs=$ac_dbdir/include
else
ac_dbincdirs="/usr/include /usr/local/include/db4"
ac_dbincdirs="$ac_dbincdirs /usr/include/db$ac_dbver"
ac_dbincdirs="$ac_dbincdirs /usr/local/BerkeleyDB.$ac_dbver/include"
fi
if test ! x"$ac_dbdir" = x"yes" ; then
ac_dblibdirs="$ac_dbdir/lib"
else
ac_dblibdirs="/usr/lib /usr/local/lib"
ac_dblibdirs="$ac_dblibdirs /usr/local/BerkeleyDB.$ac_dbver/lib"
fi
for ac_dbincdir in $ac_dbincdirs; do
CPPFLAGS="$ac_save_CPPFLAGS -I$ac_dbincdir"
LDFLAGS="$ac_save_LDFLAGS"
LIBS="$ac_save_LIBS"
dnl
dnl First check the version in the header file. If there's a match,
dnl fall through to the other check to make sure it links.
dnl If not, then we can break out of the two inner loops.
dnl
AC_MSG_CHECKING([for Berkeley DB header (version $ac_dbver) in $ac_dbincdir])
AC_LINK_IFELSE(
AC_LANG_PROGRAM(
[
#include <db_cxx.h>
#if (DB_VERSION_MAJOR != ${ac_dbver_major}) || \
(DB_VERSION_MINOR != ${ac_dbver_minor})
#error "incorrect version"
#endif
],
[
]),
[
AC_MSG_RESULT([yes])
],
[
AC_MSG_RESULT([no])
continue
])
for ac_dblibdir in $ac_dblibdirs; do
for ac_dblib in db_cxx-$ac_dbver; do
LDFLAGS="$ac_save_LDFLAGS -L$ac_dblibdir"
LIBS="$ac_save_LIBS -l$ac_dblib"
AC_MSG_CHECKING([for Berkeley DB library in $ac_dblibdir, -l$ac_dblib])
AC_LINK_IFELSE(
AC_LANG_PROGRAM(
[
#include <db_cxx.h>
],
[
DB *db;
db_create(&db, NULL, 0);
]),
[
AC_MSG_RESULT([yes])
dtn_cv_path_db_h=$ac_dbincdir
dtn_cv_path_db_lib=$ac_dblibdir
dtn_cv_lib_db=$ac_dblib
break 4
],
[
AC_MSG_RESULT([no])
])
done
done
done
done
AC_LANG_POP(C++)
CPPFLAGS="$ac_save_CPPFLAGS"
LDFLAGS="$ac_save_LDFLAGS"
LIBS="$ac_save_LIBS"
if test x$dtn_cv_path_db_h = x ; then
AC_DB_HELP
AC_MSG_ERROR([can't find usable Berkeley DB installation])
fi
])

View file

@ -1,11 +1,11 @@
SUBDIRS = lladd monotree messages dfa 2pc cht pobj
INCLUDES = @CHECK_CFLAGS@
if HAVE_CHECK
#INCLUDES = @CHECK_CFLAGS@
if HAVE_LIBCHECK
TESTS = check_check
else
TESTS =
endif
noinst_PROGRAMS = $(TESTS)
check_check_SOURCES = check_check.c
check_check_LDADD = @CHECK_LIBS@
#check_check_LDADD = @CHECK_LIBS@
CLEANFILES = check_check.log

View file

@ -1,4 +1,9 @@
#include <stdio.h>
#include <config.h>
#ifndef HAVE_TCASE_SET_TIMEOUT
#define tcase_set_timeout(x, y) 0
#endif
void setup (void) {
remove("logfile.txt");

View file

@ -1,7 +1,7 @@
LDADD= @CHECK_LIBS@ $(top_builddir)/src/libdfa/libdfa.a $(top_builddir)/src/lladd/liblladd.a $(top_builddir)/src/pbl/libpbl.a $(top_builddir)/src/libdfa/librw.a -lconfuse
LDADD= $(top_builddir)/src/libdfa/libdfa.a $(top_builddir)/src/lladd/liblladd.a $(top_builddir)/src/pbl/libpbl.a $(top_builddir)/src/libdfa/librw.a -lconfuse
bin_PROGRAMS=ping_pong_dfa fork_bomb star
AM_FLAGS= -g -Wall -pedantic -std=c99
if HAVE_CHECK
if HAVE_LIBCHECK
TESTS = check_networksetup ping_pong_dfa
else
TESTS =

View file

@ -1,5 +1,5 @@
INCLUDES = @CHECK_CFLAGS@
if HAVE_CHECK
# INCLUDES = @CHECK_CFLAGS@
if HAVE_LIBCHECK
## Had to disable check_lht because lht needs to be rewritten.
TESTS = check_logEntry check_logWriter check_page check_operations check_transactional2 check_recovery check_blobRecovery check_bufferManager check_indirect check_pageOperations check_linearHash check_logicalLinearHash check_header check_linkedListNTA check_linearHashNTA check_pageOrientedList check_lockManager check_compensations check_errorHandling check_ringbuffer check_iterator
#check_lladdhash
@ -7,6 +7,6 @@ else
TESTS =
endif
noinst_PROGRAMS = $(TESTS)
LDADD = @CHECK_LIBS@ $(top_builddir)/src/lladd/liblladd.a $(top_builddir)/src/pbl/libpbl.a $(top_builddir)/src/libdfa/librw.a #-lefence
LDADD = $(top_builddir)/src/lladd/liblladd.a $(top_builddir)/src/pbl/libpbl.a $(top_builddir)/src/libdfa/librw.a #-lefence
CLEANFILES = check_lht.log check_logEntry.log storefile.txt logfile.txt blob0_file.txt blob1_file.txt check_blobRecovery.log check_logWriter.log check_operations.log check_recovery.log check_transactional2.log check_page.log check_bufferManager.log check_indirect.log check_bufferMananger.log check_lladdhash.log check_pageOperations.log check_linearhash.log check_linkedListNTA.log check_linearHashNTA.log check_pageOrientedListNTA.log check_lockManager.log check_compensations.log check_errorhandling.log check_header.logg check_iterator.log check_linearHash.log check_ringbuffer.log
AM_CFLAGS= -g -Wall -pedantic -std=gnu99

View file

@ -625,7 +625,9 @@ START_TEST(operation_array_list) {
Suite * check_suite(void) {
Suite *s = suite_create("operations");
/* Begin a new test */
TCase *tc = tcase_create("operations_simple");
tcase_set_timeout(tc, 0); // disable timeouts
/* Sub tests are added, one per line, here */
tcase_add_test(tc, operation_physical_do_undo);