Remove portability-related guards from the atf tools.

Just assume we are building for NetBSD given that the tools code is now
owned by the NetBSD tree.
This commit is contained in:
jmmv 2014-02-11 18:13:45 +00:00
parent 892cb06d80
commit 646fe152bb
5 changed files with 5 additions and 69 deletions

View File

@ -64,12 +64,6 @@ typedef std::map< std::string, std::string > vars_map;
} // anonymous namespace
#if defined(MAXCOMLEN)
static const std::string::size_type max_core_name_length = MAXCOMLEN;
#else
static const std::string::size_type max_core_name_length = std::string::npos;
#endif
class atf_run : public tools::application::app {
static const char* m_description;
@ -127,7 +121,7 @@ dump_stacktrace(const tools::fs::path& tp, const tools::process::status& s,
w.stderr_tc("Test program crashed; attempting to get stack trace");
const tools::fs::path corename = workdir /
(tp.leaf_name().substr(0, max_core_name_length) + ".core");
(tp.leaf_name().substr(0, MAXCOMLEN) + ".core");
if (!tools::fs::exists(corename)) {
w.stderr_tc("Expected file " + corename.str() + " not found");
return;

View File

@ -434,9 +434,7 @@ impl::file_info::file_info(const path& p)
case S_IFLNK: m_type = lnk_type; break;
case S_IFREG: m_type = reg_type; break;
case S_IFSOCK: m_type = sock_type; break;
#if defined(S_IFWHT)
case S_IFWHT: m_type = wht_type; break;
#endif
default:
throw system_error(IMPL_NAME "::file_info", "Unknown file type "
"error", EINVAL);

View File

@ -399,12 +399,8 @@ impl::status::coredump(void)
const
{
assert(signaled());
#if defined(WCOREDUMP)
int mutable_status = m_status;
return WCOREDUMP(mutable_status);
#else
return false;
#endif
}
// ------------------------------------------------------------------------

View File

@ -145,14 +145,15 @@ check_machine(const std::string& machines)
return "Requires one of the '" + machines + "' machine types";
}
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
static
std::string
check_memory_sysctl(const int64_t needed, const char* sysctl_variable)
check_memory(const std::string& raw_memory)
{
const int64_t needed = tools::text::to_bytes(raw_memory);
int64_t available;
std::size_t available_length = sizeof(available);
if (::sysctlbyname(sysctl_variable, &available, &available_length,
if (::sysctlbyname("hw.usermem64", &available, &available_length,
NULL, 0) == -1) {
const char* e = std::strerror(errno);
return "Failed to get sysctl(hw.usermem64) value: " + std::string(e);
@ -164,55 +165,6 @@ check_memory_sysctl(const int64_t needed, const char* sysctl_variable)
} else
return "";
}
# if defined(__APPLE__)
static
std::string
check_memory_darwin(const int64_t needed)
{
return check_memory_sysctl(needed, "hw.usermem");
}
# elif defined(__FreeBSD__)
static
std::string
check_memory_freebsd(const int64_t needed)
{
return check_memory_sysctl(needed, "hw.usermem");
}
# elif defined(__NetBSD__)
static
std::string
check_memory_netbsd(const int64_t needed)
{
return check_memory_sysctl(needed, "hw.usermem64");
}
# else
# error "Conditional error"
# endif
#else
static
std::string
check_memory_unknown(const int64_t needed __attribute__((__unused__)))
{
return "";
}
#endif
static
std::string
check_memory(const std::string& raw_memory)
{
const int64_t needed = tools::text::to_bytes(raw_memory);
#if defined(__APPLE__)
return check_memory_darwin(needed);
#elif defined(__FreeBSD__)
return check_memory_freebsd(needed);
#elif defined(__NetBSD__)
return check_memory_netbsd(needed);
#else
return check_memory_unknown(needed);
#endif
}
static
std::string

View File

@ -241,12 +241,8 @@ ATF_TEST_CASE_WITHOUT_HEAD(require_memory_not_enough);
ATF_TEST_CASE_BODY(require_memory_not_enough) {
vars_map metadata;
metadata["require.memory"] = "128t";
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
do_check("Not enough memory; needed 140737488355328, available [0-9]*",
metadata);
#else
skip("Don't know how to check for the amount of physical memory");
#endif
}
ATF_TEST_CASE_WITHOUT_HEAD(require_memory_fail);