remove dependency on the check unit test suite
This commit is contained in:
parent
5bb8dbc2b9
commit
02469fb735
8 changed files with 133 additions and 81 deletions
|
@ -25,10 +25,10 @@ FIND_PACKAGE(FLEX)
|
|||
FIND_PACKAGE(BISON)
|
||||
|
||||
|
||||
FIND_LIBRARY(CHECK_LIBRARY NAMES check)
|
||||
if(NOT CHECK_LIBRARY)
|
||||
message(STATUS "libcheck not found; unit tests will not be built.")
|
||||
endif(NOT CHECK_LIBRARY)
|
||||
#FIND_LIBRARY(CHECK_LIBRARY NAMES check)
|
||||
#if(NOT CHECK_LIBRARY)
|
||||
# message(STATUS "libcheck not found; unit tests will not be built.")
|
||||
#endif(NOT CHECK_LIBRARY)
|
||||
|
||||
FIND_LIBRARY(HAVE_CONFUSE NAMES confuse)
|
||||
if(NOT HAVE_CONFUSE)
|
||||
|
@ -42,13 +42,13 @@ endif(NOT HAVE_FUSE)
|
|||
|
||||
MACRO(CREATE_CHECK NAME)
|
||||
ADD_EXECUTABLE(${NAME} ${NAME}.c)
|
||||
TARGET_LINK_LIBRARIES(${NAME} -lcheck ${COMMON_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES(${NAME} ${COMMON_LIBRARIES})
|
||||
ADD_TEST(${NAME} ${NAME})
|
||||
ENDMACRO(CREATE_CHECK)
|
||||
|
||||
MACRO(CREATE_CHECK_OPT NAME OPT)
|
||||
ADD_EXECUTABLE(${NAME} ${NAME}.c)
|
||||
TARGET_LINK_LIBRARIES(${NAME} -lcheck ${COMMON_LIBRARIES})
|
||||
TARGET_LINK_LIBRARIES(${NAME} ${COMMON_LIBRARIES})
|
||||
ADD_TEST(${NAME} ${NAME} ${OPT})
|
||||
ENDMACRO(CREATE_CHECK_OPT)
|
||||
|
||||
|
|
65
configure.in
65
configure.in
|
@ -31,16 +31,6 @@ SWIG_ENABLE_CXX
|
|||
SWIG_PYTHON
|
||||
AM_CONDITIONAL(HAVE_SWIG, test x"$have_swig" = "xyes")
|
||||
|
||||
#AM_PATH_CHECK(,[have_check="yes"],
|
||||
# AC_MSG_WARN([Check not found; cannot run unit tests!])
|
||||
# [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)
|
||||
|
||||
## alas, it won't link if this is put in here.. instead, it's linked in manually in the test directory...
|
||||
|
||||
#AC_ARG_ENABLE(efence,
|
||||
|
@ -79,57 +69,18 @@ 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_CHECK_LIB([check], [suite_create])
|
||||
AC_CHECK_LIB([check], [suite_create],
|
||||
have_libcheck=yes,
|
||||
have_libcheck=no)
|
||||
|
||||
if test x$have_libcheck = xyes ; then
|
||||
AM_CONDITIONAL(HAVE_LIBCHECK, true)
|
||||
else
|
||||
AM_CONDITIONAL(HAVE_LIBCHECK, false)
|
||||
AC_MSG_WARN([Check not found; cannot run unit tests!])
|
||||
fi
|
||||
|
||||
#AC_CHECK_LIB([check], [tcase_set_timeout],
|
||||
# have_libcheck_timeout=yes,
|
||||
# have_libcheck_timeout=no)
|
||||
#AC_CHECK_LIB([check], [suite_create])
|
||||
#AC_CHECK_LIB([check], [suite_create],
|
||||
# have_libcheck=yes,
|
||||
# have_libcheck=no)
|
||||
#
|
||||
#if test x$have_libcheck_timeout = xyes ; then
|
||||
#AC_DEFINE(HAVE_CHECK_TCASE_SET_TIMEOUT)
|
||||
#AH_TEMPLATE(HAVE_CHECK_TCASE_SET_TIMEOUT, [Define to 1 if your version of check supports tcase_set_timeout().])
|
||||
#else
|
||||
#if test x$have_libcheck = xyes ; then
|
||||
#AC_MSG_WARN([Found a really old version of check; disabling test case timeouts. Expect compiler warnings...])
|
||||
#fi
|
||||
#AM_CONDITIONAL(HAVE_LIBCHECK, true)
|
||||
#else
|
||||
#AM_CONDITIONAL(HAVE_LIBCHECK, false)
|
||||
#AC_MSG_WARN([Check not found; cannot run unit tests!])
|
||||
#fi
|
||||
|
||||
#AM_CONDITIONAL(HAVE_LIBCHECK, test x$have_libcheck=xyes)
|
||||
|
||||
## 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 test suites
|
||||
#); 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([pthread], [pthread_create])
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#INCLUDES = @CHECK_CFLAGS@
|
||||
if HAVE_LIBCHECK
|
||||
|
||||
SUBDIRS = stasis
|
||||
|
||||
|
@ -12,9 +11,7 @@ SUBDIRS += pobj
|
|||
endif
|
||||
|
||||
TESTS = check_check
|
||||
else
|
||||
TESTS =
|
||||
endif
|
||||
|
||||
noinst_PROGRAMS = $(TESTS)
|
||||
check_check_SOURCES = check_check.c
|
||||
#check_check_LDADD = @CHECK_LIBS@
|
||||
|
|
|
@ -39,7 +39,7 @@ authors grant the U.S. Government and others acting in its behalf
|
|||
permission to use and distribute the software in accordance with the
|
||||
terms specified in this license.
|
||||
---*/
|
||||
#include <check.h>
|
||||
#include "check_includes.h"
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
|
111
test/check_impl.h
Normal file
111
test/check_impl.h
Normal file
|
@ -0,0 +1,111 @@
|
|||
/**
|
||||
* @file check_impl.h
|
||||
*
|
||||
* A quick-and-dirty implementation of check, the C-unit test suite.
|
||||
*
|
||||
* Created on: Apr 14, 2009
|
||||
* Author: sears
|
||||
*/
|
||||
|
||||
#ifndef CHECK_IMPL_H_
|
||||
#define CHECK_IMPL_H_
|
||||
|
||||
#define CK_NORMAL 0
|
||||
|
||||
#define START_TEST(x) static void x() {
|
||||
#define END_TEST }
|
||||
|
||||
#define tcase_set_timeout(x, y)
|
||||
|
||||
#define fail_unless(x,y) assert(x)
|
||||
|
||||
typedef struct {
|
||||
void(*setup)(void);
|
||||
void(*teardown)(void);
|
||||
void(**tests)(void);
|
||||
char **names;
|
||||
int count;
|
||||
} TCase;
|
||||
|
||||
typedef struct {
|
||||
char * name;
|
||||
TCase * tc;
|
||||
} Suite;
|
||||
typedef struct {
|
||||
Suite * s;
|
||||
} SRunner;
|
||||
|
||||
static TCase* tcase_create(const char * ignored) {
|
||||
TCase* tc = malloc(sizeof(*tc));
|
||||
tc->count = 0;
|
||||
tc->names = 0;
|
||||
tc->tests = 0;
|
||||
tc->setup = 0;
|
||||
tc->teardown = 0;
|
||||
return tc;
|
||||
}
|
||||
static inline void tcase_add_checked_fixture(TCase * tc, void(*setup)(void), void(*teardown)(void)) {
|
||||
assert(tc->setup == 0);
|
||||
assert(tc->teardown == 0);
|
||||
tc->setup = setup;
|
||||
tc->teardown = teardown;
|
||||
}
|
||||
#define tcase_add_test(tc, fcn) tcase_add_test_(tc, fcn, #fcn)
|
||||
static void tcase_add_test_(TCase * tc, void(*fcn)(void), const char* name) {
|
||||
(tc->count)++;
|
||||
tc->tests = realloc(tc->tests, sizeof(tc->tests[0])*tc->count);
|
||||
tc->names = realloc(tc->names, sizeof(tc->names[0])*tc->count);
|
||||
tc->tests[tc->count-1] = fcn;
|
||||
tc->names[tc->count-1] = strdup(name);
|
||||
}
|
||||
static void tcase_free(TCase * tc) {
|
||||
int i = 0;
|
||||
for(i = 0; i < tc->count; i++) {
|
||||
free(tc->names[i]);
|
||||
}
|
||||
free(tc->names);
|
||||
free(tc->tests);
|
||||
free(tc);
|
||||
}
|
||||
|
||||
static Suite * suite_create(const char * name) {
|
||||
Suite* ret = malloc(sizeof(*ret));
|
||||
ret->name = strdup(name);
|
||||
ret->tc = 0;
|
||||
return ret;
|
||||
}
|
||||
static void suite_add_tcase(Suite* s, TCase* tc) {
|
||||
assert(s->tc == 0);
|
||||
s->tc = tc;
|
||||
}
|
||||
static void suite_free(Suite* s) {
|
||||
free(s->name);
|
||||
tcase_free(s->tc);
|
||||
free(s);
|
||||
}
|
||||
static SRunner * srunner_create(Suite* s) {
|
||||
SRunner * ret = malloc(sizeof(SRunner));
|
||||
ret->s = s;
|
||||
return ret;
|
||||
}
|
||||
static void srunner_set_log(void * p, const char * ignored) { /* noop */ }
|
||||
static void srunner_run_all(SRunner* sr, int ignored) {
|
||||
int i = 0;
|
||||
fprintf(stderr, "%s:\n", sr->s->name);
|
||||
for(i = 0; i < sr->s->tc->count; i++) {
|
||||
fprintf(stderr, "\t%s...",sr->s->tc->names[i]);
|
||||
if(sr->s->tc->setup) { sr->s->tc->setup(); }
|
||||
sr->s->tc->tests[i]();
|
||||
if(sr->s->tc->teardown) { sr->s->tc->teardown(); }
|
||||
fprintf(stderr, "pass\n");
|
||||
}
|
||||
fprintf(stderr,"All tests passed.\n");
|
||||
}
|
||||
static void srunner_free(SRunner* sr) {
|
||||
suite_free(sr->s);
|
||||
free(sr);
|
||||
}
|
||||
static int srunner_ntests_failed(SRunner * sr) {
|
||||
return 0;
|
||||
}
|
||||
#endif /* CHECK_IMPL_H_ */
|
|
@ -1,11 +1,10 @@
|
|||
#include <check.h>
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef HAVE_TCASE_SET_TIMEOUT
|
||||
#define tcase_set_timeout(x, y) 0
|
||||
#endif
|
||||
#include "check_impl.h"
|
||||
|
||||
void setup (void) {
|
||||
remove("logfile.txt");
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
LDADD= $(top_builddir)/src/libdfa/libdfa.la $(top_builddir)/src/stasis/libstasis.la -lconfuse
|
||||
AM_CFLAGS=${GLOBAL_CFLAGS}
|
||||
if HAVE_LIBCHECK
|
||||
|
||||
TESTS = check_networksetup ping_pong_dfa
|
||||
else
|
||||
TESTS =
|
||||
endif
|
||||
|
||||
noinst_PROGRAMS = ping_pong_dfa fork_bomb star $(TESTS)
|
||||
CLEANFILES = check_networksetup.log
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
# INCLUDES = @CHECK_CFLAGS@
|
||||
|
||||
if HAVE_LIBCHECK
|
||||
## Had to disable check_lht because lht needs to be rewritten.
|
||||
TESTS = check_lhtable check_logEntry check_logWriter check_page check_operations check_transactional2 check_recovery check_blobRecovery check_bufferManager check_indirect check_pageOperations check_linearHash check_header check_linkedListNTA check_linearHashNTA check_pageOrientedList check_lockManager check_compensations check_errorHandling check_ringbuffer check_iterator check_multiplexer check_bTree check_regions check_allocationPolicy check_io check_rangeTracker check_replacementPolicy check_lsmTree
|
||||
#check_lladdhash
|
||||
else
|
||||
TESTS =
|
||||
endif
|
||||
|
||||
noinst_PROGRAMS = $(TESTS)
|
||||
LDADD = $(top_builddir)/src/stasis/libstasis.la
|
||||
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.log check_iterator.log check_linearHash.log check_ringbuffer.log check_bTree.log
|
||||
|
|
Loading…
Reference in a new issue