Esempio n. 1
0
File: abts.c Progetto: vicallee/abts
/* return the tail pointer */
abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name_full)
{
    abts_suite *newsuite;
    char *p;
    const char *suite_name;
    curr_char = 0;
    
    /* Only end the suite if we actually ran it */
    if (suite && !suite->not_run) {
        end_suite(suite);
    }

    newsuite = malloc(sizeof(*newsuite));
    newsuite->num_test = 0;
    newsuite->num_failed = 0;
    newsuite->next = newsuite;
    /* suite_name_full may be an absolute path depending on __FILE__ expansion */
    suite_name = strrchr(suite_name_full, DELIMITER);
    if (suite_name) {
        suite_name++;
    } else {
	    suite_name = suite_name_full;
    }
    p = strrchr(suite_name, '.');
    if (p) {
        newsuite->name = memcpy(calloc(p - suite_name + 1, 1),
                                suite_name, p - suite_name);
    }
    else {
        newsuite->name = strdup(suite_name);
    }

    if (list_tests) {
        fprintf(outfp, "%s\n", newsuite->name);
    }
    
    newsuite->not_run = 0;

	/* append to tail */
    if (suite) {
    	newsuite->next = suite->next;
    	suite->next = newsuite;
    }    
	suite = newsuite;

    if (!should_test_run(newsuite->name)) {
        newsuite->not_run = 1;
        return suite;
    }

    reset_status();
    fprintf(outfp, "%-20s:  ", newsuite->name);
    update_status();
    fflush(outfp);

    return suite;
}
Esempio n. 2
0
File: abts.c Progetto: vicallee/abts
void abts_run_test(abts_suite *ts, abts_case_fntype f, void *arg)
{
    abts_case tc;

    if (!should_test_run(ts->name)) {
        return;
    }
    tc.failed = 0;
    tc.parent = ts;
    
    ts->num_test++;
    update_status();

    f(&tc, arg);
    
    if (tc.failed) {
        ts->num_failed++;
    }
}
Esempio n. 3
0
void abts_run_test(abts_suite *ts, test_func f, void *value)
{
    abts_case tc;
    sub_suite *ss;

    if (!should_test_run(ts->tail->name)) {
        return;
    }
    ss = ts->tail;

    tc.failed = 0;
    tc.suite = ss;
    
    ss->num_test++;
    update_status();

    f(&tc, value);
    
    if (tc.failed) {
        ss->failed++;
    }
}
Esempio n. 4
0
void abts_run_test(abts_suite *ts, test_func f, void *value)
{
    abts_case *tc;
    sub_suite *ss;

    if (!should_test_run(ts->tail->name)) {
        return;
    }
    ss = ts->tail;

    tc = malloc(sizeof(*tc));
    tc->failed = 0;
    tc->suite = ss;
    
    ss->num_test++;
    update_status();

    f(tc, value);
    
    if (tc->failed) {
        ss->failed++;
    }
    free(tc);
}
Esempio n. 5
0
abts_suite *abts_add_suite(abts_suite *suite, const char *suite_name_full)
{
    sub_suite *subsuite;
    char *p;
    const char *suite_name;
    curr_char = 0;
    
    /* Only end the suite if we actually ran it */
    if (suite && suite->tail &&!suite->tail->not_run) {
        end_suite(suite);
    }

    subsuite = malloc(sizeof(*subsuite));
    subsuite->num_test = 0;
    subsuite->failed = 0;
    subsuite->next = NULL;
    /* suite_name_full may be an absolute path depending on __FILE__ 
     * expansion */
    suite_name = strrchr(suite_name_full, '/');
    if (suite_name) {
        suite_name++;
    } else {
        suite_name = suite_name_full;
    }
    p = strrchr(suite_name, '.');
    if (p) {
        subsuite->name = memcpy(calloc(p - suite_name + 1, 1),
                                suite_name, p - suite_name);
    }
    else {
        subsuite->name = suite_name;
    }

    if (list_tests) {
        fprintf(stdout, "%s\n", subsuite->name);
    }
    
    subsuite->not_run = 0;

    if (suite == NULL) {
        suite = malloc(sizeof(*suite));
        suite->head = subsuite;
        suite->tail = subsuite;
    }
    else {
        suite->tail->next = subsuite;
        suite->tail = subsuite;
    }

    if (!should_test_run(subsuite->name)) {
        subsuite->not_run = 1;
        return suite;
    }

    reset_status();
    fprintf(stdout, "%-20s:  ", subsuite->name);
    update_status();
    fflush(stdout);

    return suite;
}