//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
//
// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#if defined(HAVE_CONFIG_H)
#include "bconfig.h"
#endif
extern "C" {
#include <dirent.h>
#include <libgen.h>
#include <unistd.h>
}
#include <cerrno>
#include <cstdlib>
#include <cstring>
extern "C" {
}
#include "../utils.hpp"
#include "exceptions.hpp"
#include "env.hpp"
#include "fs.hpp"
#include "process.hpp"
#include "sanity.hpp"
#include "text.hpp"
// ------------------------------------------------------------------------
// Auxiliary functions.
// ------------------------------------------------------------------------
//!
//! \brief A controlled version of access(2).
//!
//! This function reimplements the standard access(2) system call to
//! safely control its exit status and raise an exception in case of
//! failure.
//!
static
bool
{
bool ok;
if (atf_is_error(err)) {
ok = false;
} else {
// XXX Silence warning; maybe throw_atf_error should be
// an exception and not a function.
ok = false;
}
} else {
// XXX Silence warning; maybe throw_atf_error should be
// an exception and not a function.
ok = false;
}
} else
ok = true;
return ok;
}
// ------------------------------------------------------------------------
// The "path" class.
// ------------------------------------------------------------------------
{
if (atf_is_error(err))
}
{
if (atf_is_error(err))
}
{
if (atf_is_error(err))
}
{
}
const char*
const
{
return atf_fs_path_cstring(&m_path);
}
const atf_fs_path_t*
const
{
return &m_path;
}
const
{
return c_str();
}
bool
const
{
return atf_fs_path_is_absolute(&m_path);
}
bool
const
{
return atf_fs_path_is_root(&m_path);
}
const
{
if (atf_is_error(err))
return p;
}
const
{
if (atf_is_error(err))
return s;
}
const
{
if (atf_is_error(err))
return p;
}
{
if (atf_is_error(err))
else {
}
return *this;
}
bool
const
{
}
bool
const
{
}
const
{
if (atf_is_error(err))
return p2;
}
const
{
atf_fs_path_cstring(&p.m_path));
if (atf_is_error(err))
return p2;
}
bool
const
{
}
// ------------------------------------------------------------------------
// The "file_info" class.
// ------------------------------------------------------------------------
{
if (atf_is_error(err))
}
{
}
{
}
const
{
return atf_fs_stat_get_device(&m_stat);
}
const
{
return atf_fs_stat_get_inode(&m_stat);
}
const
{
return atf_fs_stat_get_mode(&m_stat);
}
const
{
return atf_fs_stat_get_size(&m_stat);
}
int
const
{
return atf_fs_stat_get_type(&m_stat);
}
bool
const
{
return atf_fs_stat_is_owner_readable(&m_stat);
}
bool
const
{
return atf_fs_stat_is_owner_writable(&m_stat);
}
bool
const
{
return atf_fs_stat_is_owner_executable(&m_stat);
}
bool
const
{
return atf_fs_stat_is_group_readable(&m_stat);
}
bool
const
{
return atf_fs_stat_is_group_writable(&m_stat);
}
bool
const
{
return atf_fs_stat_is_group_executable(&m_stat);
}
bool
const
{
return atf_fs_stat_is_other_readable(&m_stat);
}
bool
const
{
return atf_fs_stat_is_other_writable(&m_stat);
}
bool
const
{
return atf_fs_stat_is_other_executable(&m_stat);
}
// ------------------------------------------------------------------------
// The "directory" class.
// ------------------------------------------------------------------------
{
}
}
const
{
return ns;
}
// ------------------------------------------------------------------------
// Free functions.
// ------------------------------------------------------------------------
bool
{
bool b;
if (atf_is_error(err))
return b;
}
bool
{
// Do not bother to provide a default value for PATH. If it is not
// there something is broken in the user's environment.
bool found = false;
found = true;
}
return found;
}
bool
{
if (!exists(p))
return false;
}
void
{
"Is a directory",
EPERM);
errno);
}
void
{
if (atf_is_error(err))
}