2009-04-14 20:21:05 +00:00
|
|
|
#include "../check_includes.h"
|
|
|
|
|
2007-06-11 21:36:57 +00:00
|
|
|
#include <stasis/transactional.h>
|
|
|
|
#include <stasis/lockManager.h>
|
2005-03-02 05:14:59 +00:00
|
|
|
|
2009-04-14 20:21:05 +00:00
|
|
|
#include <pthread.h>
|
2005-03-02 05:14:59 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#define LOG_NAME "check_errorhandling.log"
|
|
|
|
|
|
|
|
START_TEST(simpleDeadlockTest) {
|
|
|
|
printf("\n");
|
|
|
|
Tinit();
|
|
|
|
setupLockManagerCallbacksPage();
|
2009-04-14 20:21:05 +00:00
|
|
|
|
2005-03-02 05:14:59 +00:00
|
|
|
int xid = Tbegin();
|
2009-04-14 20:21:05 +00:00
|
|
|
|
2005-03-02 05:14:59 +00:00
|
|
|
recordid rid = Talloc(xid, sizeof(int));
|
2005-03-09 03:24:36 +00:00
|
|
|
Talloc(xid, sizeof(int));
|
2009-04-14 20:21:05 +00:00
|
|
|
|
2005-03-02 05:14:59 +00:00
|
|
|
Tcommit(xid);
|
|
|
|
assert(!compensation_error());
|
2009-04-14 20:21:05 +00:00
|
|
|
|
2005-03-02 05:14:59 +00:00
|
|
|
xid = Tbegin();
|
|
|
|
int xid2 = Tbegin();
|
|
|
|
|
|
|
|
int i;
|
2009-04-14 20:21:05 +00:00
|
|
|
|
2005-03-02 05:14:59 +00:00
|
|
|
Tread(xid, rid, &i);
|
2009-04-14 20:21:05 +00:00
|
|
|
|
2005-03-02 05:14:59 +00:00
|
|
|
Tread(xid2, rid, &i);
|
|
|
|
|
|
|
|
assert(!compensation_error());
|
|
|
|
|
|
|
|
Tset(xid, rid, &i);
|
|
|
|
|
|
|
|
assert(compensation_error()==LLADD_DEADLOCK);
|
|
|
|
compensation_set_error(0);
|
|
|
|
Tabort(xid);
|
|
|
|
Tabort(xid2);
|
|
|
|
assert(!compensation_error());
|
|
|
|
|
|
|
|
} END_TEST
|
|
|
|
|
|
|
|
Suite * check_suite(void) {
|
|
|
|
Suite *s = suite_create("error_handling");
|
|
|
|
/* Begin a new test */
|
|
|
|
TCase *tc = tcase_create("deadlocks");
|
|
|
|
|
|
|
|
/* Sub tests are added, one per line, here */
|
|
|
|
|
2009-04-14 20:21:05 +00:00
|
|
|
tcase_add_test(tc, simpleDeadlockTest);
|
|
|
|
|
2005-03-02 05:14:59 +00:00
|
|
|
/* --------------------------------------------- */
|
2009-04-14 20:21:05 +00:00
|
|
|
|
2005-03-02 05:14:59 +00:00
|
|
|
tcase_add_checked_fixture(tc, setup, teardown);
|
|
|
|
|
|
|
|
|
|
|
|
suite_add_tcase(s, tc);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "../check_setup.h"
|