Beispiel #1
0
int main(int argc, char *argv[])
{
    char *pgm = argv[0];
    int rc, test_rc, chained;;
    int rmid = 1;
    
    if (argc < 3) {
        fprintf(stderr, "%s: at least two options must be specified\n",
                argv[0]);
        exit (1);
    }
    chained = strtol(argv[1], NULL, 0);
    test_rc = strtol(argv[2], NULL, 0);

    printf("%s| starting...\n", pgm);

    printf("%s| tx_commit(): %d\n", pgm, rc = tx_commit());
    assert(TX_PROTOCOL_ERROR == rc);

    printf("%s| tx_open(): %d\n", pgm, rc = tx_open());
    assert(TX_OK == rc);

    printf("%s| tx_commit(): %d\n", pgm, rc = tx_commit());
    assert(TX_PROTOCOL_ERROR == rc);

    if (chained) {
        printf("%s| tx_set_transaction_control(): %d\n", pgm,
               rc = tx_set_transaction_control(TX_CHAINED));
        assert(TX_OK == 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, rmid, rc = lixa_monkeyrm_call_ax_reg(rmid));
    assert(TM_OK == rc);

    printf("%s| tx_commit(): %d\n", pgm, rc = tx_commit());
    assert(test_rc == rc);

    if (TX_FAIL != test_rc) {
        printf("%s| tx_close(): %d\n", pgm, rc = tx_close());
        assert(TX_OK == rc);
    }

    printf("%s| ...finished\n", pgm);
    return 0;
}
Beispiel #2
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;
}