Beispiel #1
0
void
tp::handle_srcdir(void)
{
    if (m_srcdir_arg.empty()) {
        m_srcdir = atf::fs::path(m_argv0).branch_path();
        if (m_srcdir.leaf_name() == ".libs")
            m_srcdir = m_srcdir.branch_path();
    } else
        m_srcdir = atf::fs::path(m_srcdir_arg);

    if (!atf::fs::exists(m_srcdir / m_prog_name))
        throw std::runtime_error("Cannot find the test program in the "
                                 "source directory `" + m_srcdir.str() + "'");

    if (!m_srcdir.is_absolute())
        m_srcdir = m_srcdir.to_absolute();

    m_vars["srcdir"] = m_srcdir.str();
}
Beispiel #2
0
static
void
do_unmount(const atf::fs::path& in_path)
{
    // At least, FreeBSD's unmount(2) requires the path to be absolute.
    // Let's make it absolute in all cases just to be safe that this does
    // not affect other systems.
    const atf::fs::path& abs_path = in_path.is_absolute() ?
        in_path : in_path.to_absolute();

#if defined(HAVE_UNMOUNT)
    int retries = max_retries;
retry_unmount:
    if (unmount(abs_path.c_str(), 0) == -1) {
        if (errno == EBUSY && retries > 0) {
            retries--;
            ::sleep(retry_delay_in_seconds);
            goto retry_unmount;
        } else {
            throw atf::system_error(IMPL_NAME "::cleanup(" + in_path.str() +
                                    ")", "unmount(2) failed", errno);
        }
    }
#else
    // We could use umount(2) instead if it was available... but
    // trying to do so under, e.g. Linux, is a nightmare because we
    // also have to update /etc/mtab to match what we did.  It is
    // satf::fser to just leave the system-specific umount(8) tool deal
    // with it, at least for now.

    const atf::fs::path prog("umount");
    atf::process::argv_array argv("umount", abs_path.c_str(), NULL);

    atf::process::status s = atf::process::exec(prog, argv,
        atf::process::stream_inherit(), atf::process::stream_inherit());
    if (!s.exited() || s.exitstatus() != EXIT_SUCCESS)
        throw std::runtime_error("Call to unmount failed");
#endif
}