int main(int argc, char *argv[]) { char *pgm = argv[0]; int rc, test_rc; int rmid1 = 2, rmid2 = 3; if (argc < 2) { fprintf(stderr, "%s: at least one option must be specified\n", argv[0]); exit (1); } test_rc = strtol(argv[1], NULL, 0); printf("%s| starting...\n", pgm); printf("%s| lixa_monkeyrm_call_ax_reg(%d): %d\n", pgm, rmid1, rc = lixa_monkeyrm_call_ax_reg(rmid1)); assert(TMER_PROTO == rc); printf("%s| lixa_monkeyrm_call_ax_reg(%d): %d\n", pgm, rmid2, rc = lixa_monkeyrm_call_ax_reg(rmid2)); assert(TMER_PROTO == rc); printf("%s| tx_begin(): %d\n", pgm, rc = tx_begin()); assert(TX_PROTOCOL_ERROR == rc); printf("%s| tx_open(): %d\n", pgm, rc = tx_open()); assert(test_rc == rc); if (TX_OK != test_rc) { printf("%s| tx_open(): %d\n", pgm, rc = tx_open()); assert(TX_OK == rc); } printf("%s| tx_open(): %d\n", pgm, rc = tx_open()); assert(TX_OK == rc); /* memory leak prevention */ printf("%s| tx_close(): %d\n", pgm, rc = tx_close()); lixa_monkeyrm_call_cleanup(); printf("%s| ...finished\n", pgm); return 0; }
int main(int argc, char *argv[]) { char *pgm = argv[0]; int rc, test_rc; if (argc < 2) { fprintf(stderr, "%s: at least one option must be specified\n", argv[0]); exit (1); } test_rc = strtol(argv[1], NULL, 0); printf("%s| starting...\n", pgm); printf("%s| tx_open(): %d\n", pgm, rc = tx_open()); assert(TX_OK == rc); printf("%s| tx_begin(): %d\n", pgm, rc = tx_begin()); assert(test_rc == rc); if (TX_OK == test_rc) { printf("%s| tx_rollback(): %d\n", pgm, rc = tx_rollback()); assert(TX_OK == rc); } printf("%s| tx_close(): %d\n", pgm, rc = tx_close()); if (TX_FAIL == test_rc) assert(TX_FAIL == test_rc); else assert(TX_OK == rc); /* memory leak prevention */ lixa_tx_close_cleanup(); lixa_monkeyrm_call_cleanup(); printf("%s| ...finished\n", pgm); return 0; }
int main(int argc, char *argv[]) { char *pgm = argv[0]; int rc, test_rc, xaopen; if (argc < 3) { fprintf(stderr, "%s: at least two options must be specified\n", argv[0]); exit (1); } xaopen = strtol(argv[1], NULL, 0); test_rc = strtol(argv[2], NULL, 0); printf("%s| starting...\n", pgm); printf("%s| tx_open(): %d\n", pgm, rc = tx_open()); if (xaopen) assert(test_rc == rc); else assert(TX_OK == rc); if (xaopen && TX_OK == test_rc) { printf("%s| tx_close(): %d\n", pgm, rc = tx_close()); assert(TX_OK == rc); } else if (!xaopen) { printf("%s| tx_close(): %d\n", pgm, rc = tx_close()); assert(test_rc == rc); } /* memory leak prevention */ lixa_tx_close_cleanup(); lixa_monkeyrm_call_cleanup(); printf("%s| ...finished\n", pgm); return 0; }
int main(int argc, char *argv[]) { char *pgm = argv[0]; int rc; long begin_pos; int rmid; if (argc < 2) { fprintf(stderr, "%s: at least one option must be specified\n", argv[0]); exit (1); } begin_pos = strtol(argv[1], NULL, 0); printf("%s| starting...\n", pgm); printf("%s| tx_open(): %d\n", pgm, rc = tx_open()); assert(TX_OK == rc); if (0 == begin_pos) { printf("%s| tx_begin(): %d\n", pgm, rc = tx_begin()); assert(TX_OK == rc); } /* emulate callback registration from resource manager when accessing * resource manager owned resources; you may imagine these are the * equivalent of a SQLExecDirect function call */ for (rmid=0; rmid<3; ++rmid) { printf("%s| lixa_monkeyrm_call_ax_reg(%d): %d\n", pgm, rmid, rc = lixa_monkeyrm_call_ax_reg(rmid)); } if (1 == begin_pos) { printf("%s| tx_begin(): %d\n", pgm, rc = tx_begin()); assert(TX_OUTSIDE == rc); } /* emulate callback de-registration from resource manager when accessing * resource manager owned resources; you may imagine these are the * equivalent of a SQLEndTran function call */ for (rmid=0; rmid<3; ++rmid) { printf("%s| lixa_monkeyrm_call_ax_unreg(%d): %d\n", pgm, rmid, rc = lixa_monkeyrm_call_ax_unreg(rmid)); if (0 == begin_pos) assert(TMER_PROTO == rc); } if (2 == begin_pos) { printf("%s| tx_begin(): %d\n", pgm, rc = tx_begin()); assert(TX_OK == rc); } printf("%s| tx_commit(): %d\n", pgm, rc = tx_commit()); if (1 == begin_pos) assert(TX_PROTOCOL_ERROR == rc); else assert(TX_OK == rc); /* emulate callback registration from resource manager when accessing * resource manager owned resources; you may imagine these are the * equivalent of a SQLExecDirect function call */ for (rmid=0; rmid<3; ++rmid) { printf("%s| lixa_monkeyrm_call_ax_reg(%d): %d\n", pgm, rmid, rc = lixa_monkeyrm_call_ax_reg(rmid)); assert(TM_OK == rc); } /* emulate callback de-registration from resource manager when accessing * resource manager owned resources; you may imagine these are the * equivalent of a SQLEndTran function call */ for (rmid=0; rmid<3; ++rmid) { printf("%s| lixa_monkeyrm_call_ax_unreg(%d): %d\n", pgm, rmid, rc = lixa_monkeyrm_call_ax_unreg(rmid)); assert(TM_OK == rc); } printf("%s| tx_close(): %d\n", pgm, rc = tx_close()); assert(TX_OK == rc); /* memory leak prevention */ lixa_monkeyrm_call_cleanup(); printf("%s| ...finished\n", pgm); return 0; }
int main(int argc, char *argv[]) { char *pgm = argv[0]; TXINFO info; int rc; printf("%s| starting...\n", pgm); printf("%s| tx_set_commit_return(): %d\n", pgm, rc = tx_set_commit_return(TX_COMMIT_COMPLETED)); assert(TX_PROTOCOL_ERROR == rc); printf("%s| tx_open(): %d\n", pgm, rc = tx_open()); assert(TX_OK == rc); printf("%s| tx_set_commit_return(): %d\n", pgm, rc = tx_set_commit_return(333)); assert(TX_EINVAL == rc); printf("%s| tx_info(): %d\n", pgm, tx_info(&info)); assert(TX_COMMIT_COMPLETED == info.when_return); printf("%s| tx_set_commit_return(): %d\n", pgm, rc = tx_set_commit_return(TX_COMMIT_COMPLETED)); assert(TX_OK == rc); printf("%s| tx_info(): %d\n", pgm, tx_info(&info)); assert(TX_COMMIT_COMPLETED == info.when_return); printf("%s| tx_set_commit_return(): %d\n", pgm, rc = tx_set_commit_return(TX_COMMIT_DECISION_LOGGED)); assert(TX_NOT_SUPPORTED == rc); printf("%s| tx_info(): %d\n", pgm, tx_info(&info)); assert(TX_COMMIT_COMPLETED == info.when_return); printf("%s| tx_begin(): %d\n", pgm, rc = tx_begin()); assert(TX_OK == rc); printf("%s| tx_set_commit_return(): %d\n", pgm, rc = tx_set_commit_return(TX_COMMIT_COMPLETED)); assert(TX_OK == rc); printf("%s| tx_info(): %d\n", pgm, tx_info(&info)); assert(TX_COMMIT_COMPLETED == info.when_return); printf("%s| tx_set_commit_return(): %d\n", pgm, rc = tx_set_commit_return(TX_COMMIT_DECISION_LOGGED)); assert(TX_NOT_SUPPORTED == rc); printf("%s| tx_info(): %d\n", pgm, tx_info(&info)); assert(TX_COMMIT_COMPLETED == info.when_return); printf("%s| tx_commit(): %d\n", pgm, rc = tx_commit()); assert(TX_OK == rc); printf("%s| tx_close(): %d\n", pgm, rc = tx_close()); assert(TX_OK == rc); /* memory leak prevention */ lixa_monkeyrm_call_cleanup(); printf("%s| ...finished\n", pgm); return 0; }
int main(int argc, char *argv[]) { char *pgm = argv[0]; TXINFO info; int rc; long fail_point; if (argc < 2) { fprintf(stderr, "%s: at least one option must be specified\n", argv[0]); exit(1); } fail_point = strtol(argv[1], NULL, 0); printf("%s| starting...\n", pgm); printf("%s| tx_open(): %d\n", pgm, rc = tx_open()); assert(TX_OK == rc); printf("%s| tx_begin(): %d\n", pgm, rc = tx_begin()); if (0 == fail_point) assert(TX_FAIL == rc); else assert(TX_OK == rc); printf("%s| tx_set_transaction_control(): %d\n", pgm, rc = tx_set_transaction_control(TX_UNCHAINED)); if (0 == fail_point) assert(TX_FAIL == rc); else assert(TX_OK == rc); printf("%s| tx_set_commit_return(): %d\n", pgm, rc = tx_set_commit_return(TX_COMMIT_COMPLETED)); if (0 == fail_point) assert(TX_FAIL == rc); else assert(TX_OK == rc); printf("%s| tx_set_transaction_timeout(): %d\n", pgm, rc = tx_set_transaction_timeout(1)); if (0 == fail_point) assert(TX_FAIL == rc); else assert(TX_OK == rc); printf("%s| tx_info(): %d\n", pgm, tx_info(&info)); if (0 == fail_point) assert(TX_FAIL == rc); else assert(TX_OK == rc); if (0 == fail_point) { printf("%s| tx_commit(): %d\n", pgm, rc = tx_commit()); assert(TX_FAIL == rc); printf("%s| tx_rollback(): %d\n", pgm, rc = tx_rollback()); assert(TX_FAIL == rc); printf("%s| ...finished (TX_FAIL)\n", pgm); /* memory leak prevention */ lixa_monkeyrm_call_cleanup(); return 0; } printf("%s| tx_commit(): %d\n", pgm, rc = tx_commit()); if (1 == fail_point) assert(TX_FAIL == rc); else assert(TX_OK == rc); printf("%s| tx_begin(): %d\n", pgm, rc = tx_begin()); if (1 == fail_point) { assert(TX_FAIL == rc); printf("%s| ...finished (TX_FAIL)\n", pgm); /* memory leak prevention */ lixa_monkeyrm_call_cleanup(); return 0; } else assert(TX_OK == rc); printf("%s| tx_rollback(): %d\n", pgm, rc = tx_rollback()); if (2 == fail_point) assert(TX_FAIL == rc); else assert(TX_OK == rc); printf("%s| tx_close(): %d\n", pgm, rc = tx_close()); if (2 == fail_point) { assert(TX_FAIL == rc); printf("%s| ...finished (TX_FAIL)\n", pgm); /* memory leak prevention */ lixa_monkeyrm_call_cleanup(); return 0; } else assert(TX_OK == rc); printf("%s| tx_open(): %d\n", pgm, rc = tx_open()); assert(TX_OK == rc); printf("%s| tx_close(): %d\n", pgm, rc = tx_close()); if (3 == fail_point) assert(TX_FAIL == rc); else assert(TX_OK == rc); printf("%s| tx_open(): %d\n", pgm, rc = tx_open()); if (3 == fail_point) { assert(TX_FAIL == rc); printf("%s| ...finished (TX_FAIL)\n", pgm); exit(0); } else assert(TX_OK == rc); printf("%s| ...finished\n", pgm); return 0; }
int main(int argc, char *argv[]) { char *pgm = argv[0]; int rc, test_rc; int rmid = 2; if (argc < 2) { fprintf(stderr, "%s: at least one option must be specified\n", argv[0]); exit (1); } test_rc = strtol(argv[1], NULL, 0); printf("%s| starting...\n", pgm); printf("%s| tx_begin(): %d\n", pgm, rc = tx_begin()); assert(TX_PROTOCOL_ERROR == rc); printf("%s| tx_open(): %d\n", pgm, rc = tx_open()); assert(TX_OK == rc); printf("%s| tx_begin(): %d\n", pgm, rc = tx_begin()); assert(TX_OK == rc); printf("%s| tx_begin(): %d\n", pgm, rc = tx_begin()); assert(TX_PROTOCOL_ERROR == rc); printf("%s| tx_commit(): %d\n", pgm, rc = tx_commit()); assert(TX_OK == rc); printf("%s| lixa_monkeyrm_call_ax_reg(%d): %d\n", pgm, rmid, rc = lixa_monkeyrm_call_ax_reg(rmid)); assert(TM_OK == rc); printf("%s| tx_begin(): %d\n", pgm, rc = tx_begin()); assert(TX_OUTSIDE == rc); printf("%s| lixa_monkeyrm_call_ax_unreg(%d): %d\n", pgm, rmid, rc = lixa_monkeyrm_call_ax_unreg(rmid)); assert(TM_OK == rc); printf("%s| tx_begin(): %d\n", pgm, rc = tx_begin()); assert(TX_OK == rc); printf("%s| tx_commit(): %d\n", pgm, rc = tx_commit()); assert(TX_OK == rc); printf("%s| tx_begin(): %d\n", pgm, rc = tx_begin()); assert(test_rc == rc); if (TX_FAIL == test_rc) { /* test can not go on after TX_FAIL */ /* memory leak prevention */ lixa_monkeyrm_call_cleanup(); printf("%s| ...finished\n", pgm); return 0; } printf("%s| tx_begin(): %d\n", pgm, rc = tx_begin()); assert(TX_OK == rc); printf("%s| lixa_monkeyrm_call_ax_reg(%d): %d\n", pgm, rmid, rc = lixa_monkeyrm_call_ax_reg(rmid)); assert(TM_OK == rc); printf("%s| tx_commit(): %d\n", pgm, rc = tx_commit()); assert(TX_OK == rc); printf("%s| tx_close(): %d\n", pgm, rc = tx_close()); assert(TX_OK == rc); /* memory leak prevention */ lixa_monkeyrm_call_cleanup(); printf("%s| ...finished\n", pgm); return 0; }
int main(int argc, char *argv[]) { char *pgm = argv[0]; int rc; int commit; int expected_rc; struct thread_data_s data; pthread_t tids[THREAD_NUMBER]; int i, j, n, rnd; struct timeval to; if (argc < 5) { fprintf(stderr, "%s: at least four options must be specified\n", argv[0]); exit (1); } if (!strcmp(argv[1], "commit")) commit = TRUE; else if (!strcmp(argv[1], "rollback")) commit = FALSE; else { fprintf(stderr, "%s: first option must be [commit|rollback]\n", argv[0]); exit (1); } expected_rc = (int)strtol(argv[2], NULL, 0); n = (int)strtol(argv[3], NULL, 0); if (n < 1) n = 1; else if (n > THREAD_NUMBER) n = THREAD_NUMBER; rnd = (int)strtol(argv[4], NULL, 0); printf("%s| max random delay (%s): %d\n", pgm, argv[4], rnd); printf("%s| starting (%s/%d)...\n", pgm, argv[1], expected_rc); data.commit = commit; data.expected_rc = expected_rc; data.pgm = pgm; data.rnd = rnd; for (j=0; j<2; ++j) { for (i=0; i<n; ++i) { data.i = i; rc = pthread_create(tids+i, NULL, transaction, (void *)&data); assert(0 == rc); printf("%s| thread %d created\n", pgm, i); to.tv_sec = 0; to.tv_usec = 1000; select(0, NULL, NULL, NULL, &to); } for (i=0; i<n; ++i) { rc = pthread_join(tids[i], NULL); assert(0 == rc); printf("%s| thread %d joined\n", pgm, i); } } /* clean-up monkeyrm stuff (memory leak detection) */ lixa_monkeyrm_call_cleanup(); printf("%s| ...finished\n", pgm); return 0; }
int main(int argc, char *argv[]) { char *pgm = argv[0]; int rc, test_rc; int rmid1 = 2, rmid2 = 3; if (argc < 2) { fprintf(stderr, "%s: at least one option must be specified\n", argv[0]); exit (1); } test_rc = strtol(argv[1], NULL, 0); printf("%s| starting...\n", pgm); printf("%s| tx_open(): %d\n", pgm, rc = tx_open()); assert(test_rc == rc); printf("%s| lixa_monkeyrm_call_ax_reg(%d): %d\n", pgm, 0, rc = lixa_monkeyrm_call_ax_reg(0)); assert(TMER_TMERR == rc); printf("%s| lixa_monkeyrm_call_ax_reg(%d): %d\n", pgm, rmid1, rc = lixa_monkeyrm_call_ax_reg(rmid1)); assert(TM_OK == rc); printf("%s| lixa_monkeyrm_call_ax_reg(%d): %d\n", pgm, rmid1, rc = lixa_monkeyrm_call_ax_reg(rmid1)); assert(TMER_PROTO == rc); printf("%s| lixa_monkeyrm_call_ax_unreg(%d): %d\n", pgm, rmid1, rc = lixa_monkeyrm_call_ax_unreg(rmid1)); assert(TM_OK == rc); printf("%s| lixa_monkeyrm_call_ax_unreg(%d): %d\n", pgm, rmid1, rc = lixa_monkeyrm_call_ax_unreg(rmid1)); assert(TMER_PROTO == rc); printf("%s| lixa_monkeyrm_call_ax_unreg(%d): %d\n", pgm, rmid2, rc = lixa_monkeyrm_call_ax_unreg(rmid2)); assert(TMER_PROTO == rc); printf("%s| tx_begin(): %d\n", pgm, rc = tx_begin()); assert(TX_OK == rc); printf("%s| lixa_monkeyrm_call_ax_reg(%d): %d\n", pgm, rmid2, rc = lixa_monkeyrm_call_ax_reg(rmid2)); assert(TM_OK == rc); printf("%s| lixa_monkeyrm_call_ax_reg(%d): %d\n", pgm, rmid2, rc = lixa_monkeyrm_call_ax_reg(rmid2)); assert(TMER_PROTO == rc); printf("%s| lixa_monkeyrm_call_ax_unreg(%d): %d\n", pgm, rmid2, rc = lixa_monkeyrm_call_ax_unreg(rmid2)); assert(TMER_PROTO == rc); printf("%s| lixa_monkeyrm_call_ax_reg(%d): %d\n", pgm, 1, rc = lixa_monkeyrm_call_ax_reg(1)); assert(TMER_TMERR == rc); printf("%s| lixa_monkeyrm_call_ax_reg(%d): %d\n", pgm, 4, rc = lixa_monkeyrm_call_ax_reg(4)); assert(TMER_INVAL == rc); printf("%s| lixa_monkeyrm_call_ax_unreg(%d): %d\n", pgm, 4, rc = lixa_monkeyrm_call_ax_unreg(4)); assert(TMER_INVAL == rc); printf("%s| tx_rollback(): %d\n", pgm, rc = tx_rollback()); assert(TX_OK == rc); printf("%s| tx_close(): %d\n", pgm, rc = tx_close()); assert(TX_OK == rc); lixa_monkeyrm_call_cleanup(); printf("%s| ...finished\n", pgm); return 0; }