Fixed compensations test; FreeBSD fix (?) for makefile.

This commit is contained in:
Sears Russell 2005-02-28 00:00:17 +00:00
parent 890a7385d0
commit 3b88909c5f
5 changed files with 31 additions and 17 deletions

View file

@ -16,7 +16,7 @@ AC_PROG_LN_S
AC_PROG_MAKE_SET
## Need AC_PROG_LIBTOOL
AC_PROG_LIBTOOL
#AC_PROG_RANLIB
AC_PROG_RANLIB
# Checks for libraries.

View file

@ -64,7 +64,8 @@ terms specified in this license.
#define BLOB0_FILE "blob0_file.txt"
#define BLOB1_FILE "blob1_file.txt"
/* @define error codes
/*
define error codes
*/
#define LLADD_DEADLOCK -1
#define LLADD_NO_MEM -2

View file

@ -1,7 +1,10 @@
#include <lladd/compensations.h>
#include <assert.h>
pthread_key_t error_key;
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
static pthread_key_t error_key;
void compensations_init () {
int ret = pthread_key_create(&error_key, NULL);
@ -10,7 +13,8 @@ void compensations_init () {
}
void compensations_deinit() {
pthread_key_delete(error_key);
int ret = pthread_key_delete(error_key);
assert(!ret);
}
int compensation_error() {
@ -23,5 +27,10 @@ void compensation_clear_error() {
}
void compensation_set_error(int error) {
pthread_setspecific(error_key, (void *)error);
int ret = pthread_setspecific(error_key, (void *)error);
if(ret) {
printf("Unhandled error: %s\n", strerror(ret));
abort();
}
assert(!ret);
}

View file

@ -1,12 +1,12 @@
INCLUDES = @CHECK_CFLAGS@
INCLUDES = @CHECK_CFLAGS@
if HAVE_CHECK
## 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
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_lladdhash
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
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
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
AM_CFLAGS= -g -Wall -pedantic -std=gnu99

View file

@ -30,30 +30,31 @@ void * pageWorkerThread(void * j) {
if(rw) {
// readlock
// int locked = 0;
// begin_action_ret(NULL,NULL, 0) {
int locked = 0;
// try_ret(0) {
if(LLADD_DEADLOCK == globalLockManager.readLockPage(xid, m)) {
k = 0;
assert(compensation_error() == LLADD_DEADLOCK);
compensation_clear_error();
globalLockManager.abort(xid);
deadlocks++;
printf("-");
locked = 1;
}
// } end_action_ret(0);
/* if(locked) {
assert(compensation_error() == LLADD_DEADLOCK);
compensation_clear_error();
} */
// } end_ret();
} else {
// writelock
int locked = 0;
// begin_action_ret(NULL, NULL, 0) {
if(LLADD_DEADLOCK == globalLockManager.writeLockPage(xid, m)) {
k = 0;
globalLockManager.abort(xid);
deadlocks++;
printf("-");
locked = 1;
int err = compensation_error();
assert(err == LLADD_DEADLOCK);
compensation_clear_error();
}
/* if(locked) {
int err = compensation_error();
@ -162,6 +163,9 @@ Suite * check_suite(void) {
/* Begin a new test */
TCase *tc = tcase_create("multithreaded");
// kinda hacky, but here it is:
compensations_init();
/* Sub tests are added, one per line, here */
tcase_add_test(tc, recordidLockManagerTest);