Ejemplo n.º 1
0
/* TODO: Investigate if it's worth to add this functionality as part of
 * the public API.  I.e. a function to easily run a test case body in a
 * subprocess. */
void
run_h_tc(atf_tc_t *tc, const char *outname, const char *errname,
         const char *resname)
{
    atf_fs_path_t outpath, errpath;
    atf_process_stream_t outb, errb;
    atf_process_child_t child;
    atf_process_status_t status;

    RE(atf_fs_path_init_fmt(&outpath, outname));
    RE(atf_fs_path_init_fmt(&errpath, errname));

    struct run_h_tc_data data = { tc, resname };

    RE(atf_process_stream_init_redirect_path(&outb, &outpath));
    RE(atf_process_stream_init_redirect_path(&errb, &errpath));
    RE(atf_process_fork(&child, run_h_tc_child, &outb, &errb, &data));
    atf_process_stream_fini(&errb);
    atf_process_stream_fini(&outb);

    RE(atf_process_child_wait(&child, &status));
    ATF_CHECK(atf_process_status_exited(&status));
    atf_process_status_fini(&status);

    atf_fs_path_fini(&errpath);
    atf_fs_path_fini(&outpath);
}
Ejemplo n.º 2
0
ATF_TC_BODY(mkstemp_ok, tc)
{
    int fd1, fd2;
    atf_fs_path_t p1, p2;
    atf_fs_stat_t s1, s2;

    RE(atf_fs_path_init_fmt(&p1, "testfile.XXXXXX"));
    RE(atf_fs_path_init_fmt(&p2, "testfile.XXXXXX"));
    fd1 = fd2 = -1;
    RE(atf_fs_mkstemp(&p1, &fd1));
    RE(atf_fs_mkstemp(&p2, &fd2));
    ATF_REQUIRE(!atf_equal_fs_path_fs_path(&p1, &p2));
    ATF_REQUIRE(exists(&p1));
    ATF_REQUIRE(exists(&p2));

    ATF_CHECK(fd1 != -1);
    ATF_CHECK(fd2 != -1);
    ATF_CHECK(write(fd1, "foo", 3) == 3);
    ATF_CHECK(write(fd2, "bar", 3) == 3);
    close(fd1);
    close(fd2);

    RE(atf_fs_stat_init(&s1, &p1));
    ATF_CHECK_EQ(atf_fs_stat_get_type(&s1), atf_fs_stat_reg_type);
    ATF_CHECK( atf_fs_stat_is_owner_readable(&s1));
    ATF_CHECK( atf_fs_stat_is_owner_writable(&s1));
    ATF_CHECK(!atf_fs_stat_is_owner_executable(&s1));
    ATF_CHECK(!atf_fs_stat_is_group_readable(&s1));
    ATF_CHECK(!atf_fs_stat_is_group_writable(&s1));
    ATF_CHECK(!atf_fs_stat_is_group_executable(&s1));
    ATF_CHECK(!atf_fs_stat_is_other_readable(&s1));
    ATF_CHECK(!atf_fs_stat_is_other_writable(&s1));
    ATF_CHECK(!atf_fs_stat_is_other_executable(&s1));

    RE(atf_fs_stat_init(&s2, &p2));
    ATF_CHECK_EQ(atf_fs_stat_get_type(&s2), atf_fs_stat_reg_type);
    ATF_CHECK( atf_fs_stat_is_owner_readable(&s2));
    ATF_CHECK( atf_fs_stat_is_owner_writable(&s2));
    ATF_CHECK(!atf_fs_stat_is_owner_executable(&s2));
    ATF_CHECK(!atf_fs_stat_is_group_readable(&s2));
    ATF_CHECK(!atf_fs_stat_is_group_writable(&s2));
    ATF_CHECK(!atf_fs_stat_is_group_executable(&s2));
    ATF_CHECK(!atf_fs_stat_is_other_readable(&s2));
    ATF_CHECK(!atf_fs_stat_is_other_writable(&s2));
    ATF_CHECK(!atf_fs_stat_is_other_executable(&s2));

    atf_fs_stat_fini(&s2);
    atf_fs_stat_fini(&s1);
    atf_fs_path_fini(&p2);
    atf_fs_path_fini(&p1);
}
Ejemplo n.º 3
0
ATF_TC_BODY(path_leaf_name, tc)
{
    struct test {
        const char *in;
        const char *leaf;
    } tests[] = {
        { ".", "." },
        { "foo", "foo" },
        { "foo/bar", "bar" },
        { "/foo", "foo" },
        { "/foo/bar", "bar" },
        { NULL, NULL },
    };
    struct test *t;

    for (t = &tests[0]; t->in != NULL; t++) {
        atf_fs_path_t p;
        atf_dynstr_t ln;

        printf("Input          : %s\n", t->in);
        printf("Expected output: %s\n", t->leaf);

        RE(atf_fs_path_init_fmt(&p, "%s", t->in));
        RE(atf_fs_path_leaf_name(&p, &ln));
        printf("Output         : %s\n", atf_dynstr_cstring(&ln));
        ATF_REQUIRE(atf_equal_dynstr_cstring(&ln, t->leaf));
        atf_dynstr_fini(&ln);
        atf_fs_path_fini(&p);

        printf("\n");
    }
}
Ejemplo n.º 4
0
ATF_TC_BODY(path_branch_path, tc)
{
    struct test {
        const char *in;
        const char *branch;
    } tests[] = {
        { ".", "." },
        { "foo", "." },
        { "foo/bar", "foo" },
        { "/foo", "/" },
        { "/foo/bar", "/foo" },
        { NULL, NULL },
    };
    struct test *t;

    for (t = &tests[0]; t->in != NULL; t++) {
        atf_fs_path_t p, bp;

        printf("Input          : %s\n", t->in);
        printf("Expected output: %s\n", t->branch);

        RE(atf_fs_path_init_fmt(&p, "%s", t->in));
        RE(atf_fs_path_branch_path(&p, &bp));
        printf("Output         : %s\n", atf_fs_path_cstring(&bp));
        ATF_REQUIRE(strcmp(atf_fs_path_cstring(&bp), t->branch) == 0);
        atf_fs_path_fini(&bp);
        atf_fs_path_fini(&p);

        printf("\n");
    }
}
Ejemplo n.º 5
0
ATF_TC_BODY(path_to_absolute, tc)
{
    const char *names[] = { ".", "dir", NULL };
    const char **n;

    ATF_REQUIRE(mkdir("dir", 0755) != -1);

    for (n = names; *n != NULL; n++) {
        atf_fs_path_t p, p2;
        atf_fs_stat_t st1, st2;

        RE(atf_fs_path_init_fmt(&p, "%s", *n));
        RE(atf_fs_stat_init(&st1, &p));
        printf("Relative path: %s\n", atf_fs_path_cstring(&p));

        RE(atf_fs_path_to_absolute(&p, &p2));
        printf("Absolute path: %s\n", atf_fs_path_cstring(&p2));

        ATF_REQUIRE(atf_fs_path_is_absolute(&p2));
        RE(atf_fs_stat_init(&st2, &p2));

        ATF_REQUIRE_EQ(atf_fs_stat_get_device(&st1),
                        atf_fs_stat_get_device(&st2));
        ATF_REQUIRE_EQ(atf_fs_stat_get_inode(&st1),
                        atf_fs_stat_get_inode(&st2));

        atf_fs_stat_fini(&st2);
        atf_fs_stat_fini(&st1);
        atf_fs_path_fini(&p2);
        atf_fs_path_fini(&p);

        printf("\n");
    }
}
Ejemplo n.º 6
0
ATF_TC_BODY(path_equal, tc)
{
    atf_fs_path_t p1, p2;

    RE(atf_fs_path_init_fmt(&p1, "foo"));

    RE(atf_fs_path_init_fmt(&p2, "foo"));
    ATF_REQUIRE(atf_equal_fs_path_fs_path(&p1, &p2));
    atf_fs_path_fini(&p2);

    RE(atf_fs_path_init_fmt(&p2, "bar"));
    ATF_REQUIRE(!atf_equal_fs_path_fs_path(&p1, &p2));
    atf_fs_path_fini(&p2);

    atf_fs_path_fini(&p1);
}
Ejemplo n.º 7
0
static
atf_error_t
params_init(struct params *p, const char *argv0)
{
    atf_error_t err;

    p->m_do_list = false;
    p->m_tcname = NULL;
    p->m_tcpart = BODY;

    err = argv0_to_dir(argv0, &p->m_srcdir);
    if (atf_is_error(err))
        return err;

    err = atf_fs_path_init_fmt(&p->m_resfile, "/dev/stdout");
    if (atf_is_error(err)) {
        atf_fs_path_fini(&p->m_srcdir);
        return err;
    }

    err = atf_map_init(&p->m_config);
    if (atf_is_error(err)) {
        atf_fs_path_fini(&p->m_resfile);
        atf_fs_path_fini(&p->m_srcdir);
        return err;
    }

    return err;
}
Ejemplo n.º 8
0
ATF_TC_BODY(path_append, tc)
{
    struct test {
        const char *in;
        const char *ap;
        const char *out;
    } tests[] = {
        { "foo", "bar", "foo/bar" },
        { "foo/", "/bar", "foo/bar" },
        { "foo/", "/bar/baz", "foo/bar/baz" },
        { "foo/", "///bar///baz", "foo/bar/baz" }, /* NO_CHECK_STYLE */

        { NULL, NULL, NULL }
    };
    struct test *t;

    for (t = &tests[0]; t->in != NULL; t++) {
        atf_fs_path_t p;

        printf("Input          : >%s<\n", t->in);
        printf("Append         : >%s<\n", t->ap);
        printf("Expected output: >%s<\n", t->out);

        RE(atf_fs_path_init_fmt(&p, "%s", t->in));

        RE(atf_fs_path_append_fmt(&p, "%s", t->ap));

        printf("Output         : >%s<\n", atf_fs_path_cstring(&p));
        ATF_REQUIRE(strcmp(atf_fs_path_cstring(&p), t->out) == 0);

        atf_fs_path_fini(&p);

        printf("\n");
    }
}
Ejemplo n.º 9
0
ATF_TC_BODY(path_is_root, tc)
{
    struct test {
        const char *in;
        bool root;
    } tests[] = {
        { "/", true },
        { "////", true }, /* NO_CHECK_STYLE */
        { "////a", false }, /* NO_CHECK_STYLE */
        { "//a//", false }, /* NO_CHECK_STYLE */
        { "a////", false }, /* NO_CHECK_STYLE */
        { "../foo", false },
        { NULL, false },
    };
    struct test *t;

    for (t = &tests[0]; t->in != NULL; t++) {
        atf_fs_path_t p;

        printf("Input          : %s\n", t->in);
        printf("Expected result: %s\n", t->root ? "true" : "false");

        RE(atf_fs_path_init_fmt(&p, "%s", t->in));
        printf("Result         : %s\n",
               atf_fs_path_is_root(&p) ? "true" : "false");
        if (t->root)
            ATF_REQUIRE(atf_fs_path_is_root(&p));
        else
            ATF_REQUIRE(!atf_fs_path_is_root(&p));
        atf_fs_path_fini(&p);

        printf("\n");
    }
}
Ejemplo n.º 10
0
void
get_process_helpers_path(const atf_tc_t *tc, const bool is_detail,
                         atf_fs_path_t *path)
{
    RE(atf_fs_path_init_fmt(path, "%s/%sprocess_helpers",
                            atf_tc_get_config_var(tc, "srcdir"),
                            is_detail ? "" : "detail/"));
}
Ejemplo n.º 11
0
ATF_TC_BODY(exec_cleanup, tc)
{
    atf_fs_path_t out, err;
    atf_check_result_t result;
    bool exists;

    do_exec(tc, "exit-success", &result);
    RE(atf_fs_path_init_fmt(&out, "%s", atf_check_result_stdout(&result)));
    RE(atf_fs_path_init_fmt(&err, "%s", atf_check_result_stderr(&result)));

    RE(atf_fs_exists(&out, &exists)); ATF_CHECK(exists);
    RE(atf_fs_exists(&err, &exists)); ATF_CHECK(exists);
    atf_check_result_fini(&result);
    RE(atf_fs_exists(&out, &exists)); ATF_CHECK(!exists);
    RE(atf_fs_exists(&err, &exists)); ATF_CHECK(!exists);

    atf_fs_path_fini(&err);
    atf_fs_path_fini(&out);
}
Ejemplo n.º 12
0
void
build_check_c_o(const atf_tc_t *tc, const char *sfile, const char *failmsg)
{
    atf_fs_path_t path;

    RE(atf_fs_path_init_fmt(&path, "%s/%s",
                            atf_tc_get_config_var(tc, "srcdir"), sfile));
    build_check_c_o_aux(atf_fs_path_cstring(&path), failmsg);
    atf_fs_path_fini(&path);
}
Ejemplo n.º 13
0
static void redirect_path_stream_init (void *v)
{
    struct redirect_path_stream *s = v;

    switch (s->m_base.m_type)
    {
        case stdout_type:
            RE (atf_fs_path_init_fmt (&s->m_path, "stdout"));
            break;
        case stderr_type:
            RE (atf_fs_path_init_fmt (&s->m_path, "stderr"));
            break;
        default:
            UNREACHABLE;
    }

    s->m_base.m_sb_ptr = &s->m_base.m_sb;
    RE (atf_process_stream_init_redirect_path (&s->m_base.m_sb, &s->m_path));
}
Ejemplo n.º 14
0
ATF_TC_BODY(exists, tc)
{
    atf_error_t err;
    atf_fs_path_t pdir, pfile;
    bool b;

    RE(atf_fs_path_init_fmt(&pdir, "dir"));
    RE(atf_fs_path_init_fmt(&pfile, "dir/file"));

    create_dir(atf_fs_path_cstring(&pdir), 0755);
    create_file(atf_fs_path_cstring(&pfile), 0644);

    printf("Checking existence of a directory\n");
    RE(atf_fs_exists(&pdir, &b));
    ATF_REQUIRE(b);

    printf("Checking existence of a file\n");
    RE(atf_fs_exists(&pfile, &b));
    ATF_REQUIRE(b);

    /* XXX: This should probably be a separate test case to let the user
     * be aware that some tests were skipped because privileges were not
     * correct. */
    if (!atf_user_is_root()) {
        printf("Checking existence of a file inside a directory without "
               "permissions\n");
        ATF_REQUIRE(chmod(atf_fs_path_cstring(&pdir), 0000) != -1);
        err = atf_fs_exists(&pfile, &b);
        ATF_REQUIRE(atf_is_error(err));
        ATF_REQUIRE(atf_error_is(err, "libc"));
        ATF_REQUIRE(chmod(atf_fs_path_cstring(&pdir), 0755) != -1);
        atf_error_free(err);
    }

    printf("Checking existence of a non-existent file\n");
    ATF_REQUIRE(unlink(atf_fs_path_cstring(&pfile)) != -1);
    RE(atf_fs_exists(&pfile, &b));
    ATF_REQUIRE(!b);

    atf_fs_path_fini(&pfile);
    atf_fs_path_fini(&pdir);
}
Ejemplo n.º 15
0
ATF_TC_BODY(mkdtemp_ok, tc)
{
    atf_fs_path_t p1, p2;
    atf_fs_stat_t s1, s2;

    RE(atf_fs_path_init_fmt(&p1, "testdir.XXXXXX"));
    RE(atf_fs_path_init_fmt(&p2, "testdir.XXXXXX"));
    RE(atf_fs_mkdtemp(&p1));
    RE(atf_fs_mkdtemp(&p2));
    ATF_REQUIRE(!atf_equal_fs_path_fs_path(&p1, &p2));
    ATF_REQUIRE(exists(&p1));
    ATF_REQUIRE(exists(&p2));

    RE(atf_fs_stat_init(&s1, &p1));
    ATF_REQUIRE_EQ(atf_fs_stat_get_type(&s1), atf_fs_stat_dir_type);
    ATF_REQUIRE( atf_fs_stat_is_owner_readable(&s1));
    ATF_REQUIRE( atf_fs_stat_is_owner_writable(&s1));
    ATF_REQUIRE( atf_fs_stat_is_owner_executable(&s1));
    ATF_REQUIRE(!atf_fs_stat_is_group_readable(&s1));
    ATF_REQUIRE(!atf_fs_stat_is_group_writable(&s1));
    ATF_REQUIRE(!atf_fs_stat_is_group_executable(&s1));
    ATF_REQUIRE(!atf_fs_stat_is_other_readable(&s1));
    ATF_REQUIRE(!atf_fs_stat_is_other_writable(&s1));
    ATF_REQUIRE(!atf_fs_stat_is_other_executable(&s1));

    RE(atf_fs_stat_init(&s2, &p2));
    ATF_REQUIRE_EQ(atf_fs_stat_get_type(&s2), atf_fs_stat_dir_type);
    ATF_REQUIRE( atf_fs_stat_is_owner_readable(&s2));
    ATF_REQUIRE( atf_fs_stat_is_owner_writable(&s2));
    ATF_REQUIRE( atf_fs_stat_is_owner_executable(&s2));
    ATF_REQUIRE(!atf_fs_stat_is_group_readable(&s2));
    ATF_REQUIRE(!atf_fs_stat_is_group_writable(&s2));
    ATF_REQUIRE(!atf_fs_stat_is_group_executable(&s2));
    ATF_REQUIRE(!atf_fs_stat_is_other_readable(&s2));
    ATF_REQUIRE(!atf_fs_stat_is_other_writable(&s2));
    ATF_REQUIRE(!atf_fs_stat_is_other_executable(&s2));

    atf_fs_stat_fini(&s2);
    atf_fs_stat_fini(&s1);
    atf_fs_path_fini(&p2);
    atf_fs_path_fini(&p1);
}
Ejemplo n.º 16
0
ATF_TC_BODY(stat_mode, tc)
{
    atf_fs_path_t p;
    atf_fs_stat_t st;

    create_file("f1", 0400);
    create_file("f2", 0644);

    RE(atf_fs_path_init_fmt(&p, "f1"));
    RE(atf_fs_stat_init(&st, &p));
    ATF_CHECK_EQ(0400, atf_fs_stat_get_mode(&st));
    atf_fs_stat_fini(&st);
    atf_fs_path_fini(&p);

    RE(atf_fs_path_init_fmt(&p, "f2"));
    RE(atf_fs_stat_init(&st, &p));
    ATF_CHECK_EQ(0644, atf_fs_stat_get_mode(&st));
    atf_fs_stat_fini(&st);
    atf_fs_path_fini(&p);
}
Ejemplo n.º 17
0
bool
build_check_c_o_srcdir(const atf_tc_t *tc, const char *sfile)
{
    atf_fs_path_t path;

    RE(atf_fs_path_init_fmt(&path, "%s/%s",
                            atf_tc_get_config_var(tc, "srcdir"), sfile));
    const bool result = build_check_c_o(atf_fs_path_cstring(&path));
    atf_fs_path_fini(&path);
    return result;
}
Ejemplo n.º 18
0
atf_error_t
atf_fs_path_branch_path(const atf_fs_path_t *p, atf_fs_path_t *bp)
{
    const size_t endpos = atf_dynstr_rfind_ch(&p->m_data, '/');
    atf_error_t err;

    if (endpos == atf_dynstr_npos)
        err = atf_fs_path_init_fmt(bp, ".");
    else if (endpos == 0)
        err = atf_fs_path_init_fmt(bp, "/");
    else
        err = atf_dynstr_init_substr(&bp->m_data, &p->m_data, 0, endpos);

#if defined(HAVE_CONST_DIRNAME)
    INV(atf_equal_dynstr_cstring(&bp->m_data,
                                 dirname(atf_dynstr_cstring(&p->m_data))));
#endif /* defined(HAVE_CONST_DIRNAME) */

    return err;
}
Ejemplo n.º 19
0
ATF_TC_BODY(stat_type, tc)
{
    atf_fs_path_t p;
    atf_fs_stat_t st;

    create_dir("dir", 0755);
    create_file("reg", 0644);

    RE(atf_fs_path_init_fmt(&p, "dir"));
    RE(atf_fs_stat_init(&st, &p));
    ATF_REQUIRE_EQ(atf_fs_stat_get_type(&st), atf_fs_stat_dir_type);
    atf_fs_stat_fini(&st);
    atf_fs_path_fini(&p);

    RE(atf_fs_path_init_fmt(&p, "reg"));
    RE(atf_fs_stat_init(&st, &p));
    ATF_REQUIRE_EQ(atf_fs_stat_get_type(&st), atf_fs_stat_reg_type);
    atf_fs_stat_fini(&st);
    atf_fs_path_fini(&p);
}
Ejemplo n.º 20
0
static
void
create_ctl_file(const char *name)
{
    atf_fs_path_t p;

    RE(atf_fs_path_init_fmt(&p, "%s", name));
    ATF_REQUIRE(open(atf_fs_path_cstring(&p),
                   O_CREAT | O_WRONLY | O_TRUNC, 0644) != -1);
    atf_fs_path_fini(&p);
}
Ejemplo n.º 21
0
ATF_TC_BODY(srcdir_exists, tc)
{
    atf_fs_path_t p;
    bool b;

    RE(atf_fs_path_init_fmt(&p, "%s/datafile",
                            atf_tc_get_config_var(tc, "srcdir")));
    RE(atf_fs_exists(&p, &b));
    atf_fs_path_fini(&p);
    if (!b)
        atf_tc_fail("Cannot find datafile");
}
Ejemplo n.º 22
0
ATF_TC_BODY(mkstemp_umask, tc)
{
    atf_fs_path_t p;

    RE(atf_fs_path_init_fmt(&p, "testfile.XXXXXX"));

    do_umask_check(mkstemp_discard_fd, &p, 00100, "00100", "regular file");
    do_umask_check(mkstemp_discard_fd, &p, 00200, "00200", "regular file");
    do_umask_check(mkstemp_discard_fd, &p, 00400, "00400", "regular file");

    atf_fs_path_fini(&p);
}
Ejemplo n.º 23
0
static
bool
exists(const char *p)
{
    bool b;
    atf_fs_path_t pp;

    RE(atf_fs_path_init_fmt(&pp, "%s", p));
    RE(atf_fs_exists(&pp, &b));
    atf_fs_path_fini(&pp);

    return b;
}
Ejemplo n.º 24
0
ATF_TC_BODY(rmdir_empty, tc)
{
    atf_fs_path_t p;

    RE(atf_fs_path_init_fmt(&p, "test-dir"));

    ATF_REQUIRE(mkdir("test-dir", 0755) != -1);
    ATF_REQUIRE(exists(&p));
    RE(atf_fs_rmdir(&p));
    ATF_REQUIRE(!exists(&p));

    atf_fs_path_fini(&p);
}
Ejemplo n.º 25
0
ATF_TC_BODY (stream_init_redirect_path, tc)
{
    atf_process_stream_t sb;

    atf_fs_path_t path;

    RE (atf_fs_path_init_fmt (&path, "foo"));
    RE (atf_process_stream_init_redirect_path (&sb, &path));

    ATF_CHECK_EQ (atf_process_stream_type (&sb), atf_process_stream_type_redirect_path);

    atf_process_stream_fini (&sb);
    atf_fs_path_fini (&path);
}
Ejemplo n.º 26
0
ATF_TC_BODY(mkdtemp_umask, tc)
{
    atf_fs_path_t p;

    RE(atf_fs_path_init_fmt(&p, "testdir.XXXXXX"));

    do_umask_check(atf_fs_mkdtemp, &p, 00100, "00100", "directory");
    do_umask_check(atf_fs_mkdtemp, &p, 00200, "00200", "directory");
    do_umask_check(atf_fs_mkdtemp, &p, 00400, "00400", "directory");
    do_umask_check(atf_fs_mkdtemp, &p, 00500, "00500", "directory");
    do_umask_check(atf_fs_mkdtemp, &p, 00600, "00600", "directory");

    atf_fs_path_fini(&p);
}
Ejemplo n.º 27
0
static
atf_error_t
replace_path_param(atf_fs_path_t *param, const char *value)
{
    atf_error_t err;
    atf_fs_path_t temp;

    err = atf_fs_path_init_fmt(&temp, "%s", value);
    if (!atf_is_error(err)) {
        atf_fs_path_fini(param);
        *param = temp;
    }

    return err;
}
Ejemplo n.º 28
0
ATF_TC_BODY(path_copy, tc)
{
    atf_fs_path_t str, str2;

    RE(atf_fs_path_init_fmt(&str, "foo"));
    RE(atf_fs_path_copy(&str2, &str));

    ATF_REQUIRE(atf_equal_fs_path_fs_path(&str, &str2));

    RE(atf_fs_path_append_fmt(&str2, "bar"));

    ATF_REQUIRE(!atf_equal_fs_path_fs_path(&str, &str2));

    atf_fs_path_fini(&str2);
    atf_fs_path_fini(&str);
}
Ejemplo n.º 29
0
static
atf_error_t
argv0_to_dir(const char *argv0, atf_fs_path_t *dir)
{
    atf_error_t err;
    atf_fs_path_t temp;

    err = atf_fs_path_init_fmt(&temp, "%s", argv0);
    if (atf_is_error(err))
        goto out;

    err = atf_fs_path_branch_path(&temp, dir);

    atf_fs_path_fini(&temp);
out:
    return err;
}
Ejemplo n.º 30
0
ATF_TC_BODY(rmdir_enotempty, tc)
{
    atf_fs_path_t p;
    atf_error_t err;

    RE(atf_fs_path_init_fmt(&p, "test-dir"));

    ATF_REQUIRE(mkdir("test-dir", 0755) != -1);
    ATF_REQUIRE(exists(&p));
    create_file("test-dir/foo", 0644);

    err = atf_fs_rmdir(&p);
    ATF_REQUIRE(atf_is_error(err));
    ATF_REQUIRE(atf_error_is(err, "libc"));
    ATF_REQUIRE_EQ(atf_libc_error_code(err), ENOTEMPTY);
    atf_error_free(err);

    atf_fs_path_fini(&p);
}