示例#1
0
ATF_TC_BODY(free_charpp__empty, tc)
{
    char **array = malloc(sizeof(char *) * 1);
    array[0] = NULL;

    atf_utils_free_charpp(array);
}
示例#2
0
ATF_TC_BODY(free_charpp__some, tc)
{
    char **array = malloc(sizeof(char *) * 4);
    array[0] = strdup("first");
    array[1] = strdup("second");
    array[2] = strdup("third");
    array[3] = NULL;

    atf_utils_free_charpp(array);
}
示例#3
0
文件: tp_main.c 项目: 0mp/freebsd
static
atf_error_t
controlled_main(int argc, char **argv,
                atf_error_t (*add_tcs_hook)(atf_tp_t *),
                int *exitcode)
{
    atf_error_t err;
    struct params p;
    atf_tp_t tp;
    char **raw_config;

    err = process_params(argc, argv, &p);
    if (atf_is_error(err))
        goto out;

    err = handle_srcdir(&p);
    if (atf_is_error(err))
        goto out_p;

    raw_config = atf_map_to_charpp(&p.m_config);
    if (raw_config == NULL) {
        err = atf_no_memory_error();
        goto out_p;
    }
    err = atf_tp_init(&tp, (const char* const*)raw_config);
    atf_utils_free_charpp(raw_config);
    if (atf_is_error(err))
        goto out_p;

    err = add_tcs_hook(&tp);
    if (atf_is_error(err))
        goto out_tp;

    if (p.m_do_list) {
        list_tcs(&tp);
        INV(!atf_is_error(err));
        *exitcode = EXIT_SUCCESS;
    } else {
        err = run_tc(&tp, &p, exitcode);
    }

out_tp:
    atf_tp_fini(&tp);
out_p:
    params_fini(&p);
out:
    return err;
}
示例#4
0
ATF_TC_BODY(cpp, tc)
{
    struct cpp_test *test;

    for (test = cpp_tests; test->expargv[0] != NULL; test++) {
        printf("> Test: %s\n", test->msg);

        verbose_set_env("ATF_BUILD_CPP", test->cpp);
        verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags);
        __atf_config_reinit();

        {
            char **argv;
            if (test->hasoptargs)
                RE(atf_build_cpp(test->sfile, test->ofile, test->optargs,
                                 &argv));
            else
                RE(atf_build_cpp(test->sfile, test->ofile, NULL, &argv));
            check_equal_array(test->expargv, argv);
            atf_utils_free_charpp(argv);
        }
    }
}
示例#5
0
文件: tp_main.c 项目: 0mp/freebsd
static
void
list_tcs(const atf_tp_t *tp)
{
    const atf_tc_t *const *tcs;
    const atf_tc_t *const *tcsptr;

    printf("Content-Type: application/X-atf-tp; version=\"1\"\n\n");

    tcs = atf_tp_get_tcs(tp);
    INV(tcs != NULL);  /* Should be checked. */
    for (tcsptr = tcs; *tcsptr != NULL; tcsptr++) {
        const atf_tc_t *tc = *tcsptr;
        char **vars = atf_tc_get_md_vars(tc);
        char **ptr;

        INV(vars != NULL);  /* Should be checked. */

        if (tcsptr != tcs)  /* Not first. */
            printf("\n");

        for (ptr = vars; *ptr != NULL; ptr += 2) {
            if (strcmp(*ptr, "ident") == 0) {
                printf("ident: %s\n", *(ptr + 1));
                break;
            }
        }

        for (ptr = vars; *ptr != NULL; ptr += 2) {
            if (strcmp(*ptr, "ident") != 0) {
                printf("%s: %s\n", *ptr, *(ptr + 1));
            }
        }

        atf_utils_free_charpp(vars);
    }
}