Resolve conflicts after the import of atf 0.15.

This commit is contained in:
jmmv 2012-01-16 22:41:30 +00:00
parent a551a20f66
commit 36b886fe83
29 changed files with 508 additions and 273 deletions

View File

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
// Copyright (c) 2008 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2010 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -33,7 +33,6 @@ extern "C" {
#include <cctype>
#include <cstring>
#include <cstdlib>
extern "C" {
#include "../../atf-c/error.h"
@ -136,10 +135,26 @@ impl::to_bool(const std::string& str)
}
int64_t
impl::to_number(const std::string& str)
impl::to_bytes(std::string str)
{
int64_t num;
::dehumanize_number(str.c_str(), &num);
return num;
if (str.empty())
throw std::runtime_error("Empty value");
const char unit = str[str.length() - 1];
int64_t multiplier;
switch (unit) {
case 'k': case 'K': multiplier = 1 << 10; break;
case 'm': case 'M': multiplier = 1 << 20; break;
case 'g': case 'G': multiplier = 1 << 30; break;
case 't': case 'T': multiplier = int64_t(1) << 40; break;
default:
if (!std::isdigit(unit))
throw std::runtime_error(std::string("Unknown size unit '") + unit
+ "'");
multiplier = 1;
}
if (multiplier != 1)
str.erase(str.length() - 1);
return to_type< int64_t >(str) * multiplier;
}

View File

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2010 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -30,6 +30,10 @@
#if !defined(_ATF_CXX_TEXT_HPP_)
#define _ATF_CXX_TEXT_HPP_
extern "C" {
#include <stdint.h>
}
#include <sstream>
#include <stdexcept>
#include <string>
@ -97,6 +101,11 @@ std::string trim(const std::string&);
//!
bool to_bool(const std::string&);
//!
//! \brief Converts the given string to a bytes size.
//!
int64_t to_bytes(std::string);
//!
//! \brief Changes the case of a string to lowercase.
//!
@ -105,13 +114,6 @@ bool to_bool(const std::string&);
//!
std::string to_lower(const std::string&);
//!
//! \brief Converts the given string to a number
//!
//! The string should be of the form ^[0-9]+[KMGT]$ or ^[0-9]$
//!
int64_t to_number(const std::string&);
//!
//! \brief Converts the given object to a string.
//!
@ -140,7 +142,7 @@ to_type(const std::string& str)
std::istringstream ss(str);
T value;
ss >> value;
if (!ss.eof() || (!ss.eof() && !ss.good()))
if (!ss.eof() || (ss.eof() && (ss.fail() || ss.bad())))
throw std::runtime_error("Cannot convert string to requested type");
return value;
}

View File

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
/*
* Automated Testing Framework (atf)
*
* Copyright (c) 2008, 2011 The NetBSD Foundation, Inc.
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -32,5 +32,6 @@
#define ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(a, b) @ATTRIBUTE_FORMAT_PRINTF@
#define ATF_DEFS_ATTRIBUTE_NORETURN @ATTRIBUTE_NORETURN@
#define ATF_DEFS_ATTRIBUTE_UNUSED @ATTRIBUTE_UNUSED@
#endif /* !defined(ATF_C_DEFS_H) */

View File

@ -1,7 +1,7 @@
/*
* Automated Testing Framework (atf)
*
* Copyright (c) 2007, 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -197,7 +197,7 @@ atf_process_status_init(atf_process_status_t *s, int status)
}
void
atf_process_status_fini(atf_process_status_t *s)
atf_process_status_fini(atf_process_status_t *s ATF_DEFS_ATTRIBUTE_UNUSED)
{
}

View File

@ -1,7 +1,7 @@
/*
* Automated Testing Framework (atf)
*
* Copyright (c) 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
/*
* Automated Testing Framework (atf)
*
* Copyright (c) 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -28,8 +28,8 @@
*/
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <errno.h>
@ -135,13 +135,12 @@ capture_stream_process(void *v, atf_process_child_t *c)
{
struct capture_stream *s = v;
bool eof;
switch (s->m_base.m_type) {
case stdout_type:
eof = read_line(atf_process_child_stdout(c), &s->m_msg);
(void)read_line(atf_process_child_stdout(c), &s->m_msg);
break;
case stderr_type:
eof = read_line(atf_process_child_stderr(c), &s->m_msg);
(void)read_line(atf_process_child_stderr(c), &s->m_msg);
break;
default:
UNREACHABLE;
@ -690,7 +689,7 @@ static void child_report_pid(void *) ATF_DEFS_ATTRIBUTE_NORETURN;
static
void
child_report_pid(void *v)
child_report_pid(void *v ATF_DEFS_ATTRIBUTE_UNUSED)
{
const pid_t pid = getpid();
if (write(STDOUT_FILENO, &pid, sizeof(pid)) != sizeof(pid))
@ -731,7 +730,7 @@ ATF_TC_BODY(child_pid, tc)
static
void
child_loop(void *v)
child_loop(void *v ATF_DEFS_ATTRIBUTE_UNUSED)
{
for (;;)
sleep(1);
@ -739,13 +738,13 @@ child_loop(void *v)
static
void
nop_signal(int sig)
nop_signal(int sig ATF_DEFS_ATTRIBUTE_UNUSED)
{
}
static
void
child_spawn_loop_and_wait_eintr(void *v)
child_spawn_loop_and_wait_eintr(void *v ATF_DEFS_ATTRIBUTE_UNUSED)
{
atf_process_child_t child;
atf_process_status_t status;

View File

@ -1,7 +1,7 @@
/*
* Automated Testing Framework (atf)
*
* Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -77,7 +77,7 @@ build_check_c_o(const atf_tc_t *tc, const char *sfile, const char *failmsg)
}
void
header_check(const atf_tc_t *tc, const char *hdrname)
header_check(const char *hdrname)
{
FILE *srcfile;
char failmsg[128];

View File

@ -1,7 +1,7 @@
/*
* Automated Testing Framework (atf)
*
* Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -104,7 +104,7 @@ static void errno_test(struct context *, const char *, const size_t,
const int, const char *, const bool,
void (*)(struct context *, atf_dynstr_t *));
static atf_error_t check_prog_in_dir(const char *, void *);
static atf_error_t check_prog(struct context *, const char *, void *);
static atf_error_t check_prog(struct context *, const char *);
static void
context_init(struct context *ctx, const atf_tc_t *tc, const char *resfile)
@ -166,22 +166,24 @@ write_resfile(const int fd, const char *result, const int arg,
INV(arg == -1 || reason != NULL);
iov[count].iov_base = __UNCONST(result);
#define UNCONST(a) ((void *)(unsigned long)(const void *)(a))
iov[count].iov_base = UNCONST(result);
iov[count++].iov_len = strlen(result);
if (reason != NULL) {
if (arg != -1) {
iov[count].iov_base = buf;
iov[count++].iov_len = snprintf(buf, sizeof(buf), "(%d)", arg);
}
if (arg != -1) {
iov[count].iov_base = buf;
iov[count++].iov_len = snprintf(buf, sizeof(buf), "(%d)", arg);
}
iov[count].iov_base = CS;
iov[count++].iov_len = sizeof(CS) - 1;
iov[count].iov_base = CS;
iov[count++].iov_len = sizeof(CS) - 1;
r = atf_dynstr_cstring(reason);
iov[count].iov_base = __UNCONST(r);
iov[count++].iov_len = strlen(r);
r = atf_dynstr_cstring(reason);
iov[count].iov_base = UNCONST(r);
iov[count++].iov_len = strlen(r);
}
#undef UNCONST
iov[count].iov_base = NL;
iov[count++].iov_len = sizeof(NL) - 1;
@ -460,7 +462,7 @@ out_p:
}
static atf_error_t
check_prog(struct context *ctx, const char *prog, void *data)
check_prog(struct context *ctx, const char *prog)
{
atf_error_t err;
atf_fs_path_t p;
@ -874,7 +876,7 @@ _atf_tc_pass(struct context *ctx)
static void
_atf_tc_require_prog(struct context *ctx, const char *prog)
{
check_fatal_error(check_prog(ctx, prog, NULL));
check_fatal_error(check_prog(ctx, prog));
}
static void

View File

@ -1,7 +1,7 @@
/*
* Automated Testing Framework (atf)
*
* Copyright (c) 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
#
# Automated Testing Framework (atf)
#
# Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
# Copyright (c) 2007 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -27,13 +27,21 @@
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
extern "C" {
#include <sys/time.h>
}
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <memory>
#include <sstream>
#include <utility>
#include <vector>
#include "atf-c/defs.h"
#include "atf-c++/detail/application.hpp"
#include "atf-c++/detail/fs.hpp"
#include "atf-c++/detail/sanity.hpp"
@ -44,7 +52,7 @@
typedef std::auto_ptr< std::ostream > ostream_ptr;
ostream_ptr
static ostream_ptr
open_outfile(const atf::fs::path& path)
{
ostream_ptr osp;
@ -57,6 +65,16 @@ open_outfile(const atf::fs::path& path)
return osp;
}
static std::string
format_tv(struct timeval* tv)
{
std::ostringstream output;
output << static_cast< long >(tv->tv_sec) << '.'
<< std::setfill('0') << std::setw(6)
<< static_cast< long >(tv->tv_usec);
return output.str();
}
// ------------------------------------------------------------------------
// The "writer" interface.
// ------------------------------------------------------------------------
@ -80,11 +98,12 @@ public:
virtual void write_info(const std::string&, const std::string&) {}
virtual void write_ntps(size_t) {}
virtual void write_tp_start(const std::string&, size_t) {}
virtual void write_tp_end(const std::string&) {}
virtual void write_tp_end(struct timeval*, const std::string&) {}
virtual void write_tc_start(const std::string&) {}
virtual void write_tc_stdout_line(const std::string&) {}
virtual void write_tc_stderr_line(const std::string&) {}
virtual void write_tc_end(const std::string&, const std::string&) {}
virtual void write_tc_end(const std::string&, struct timeval*,
const std::string&) {}
virtual void write_eof(void) {}
};
@ -115,7 +134,8 @@ public:
virtual
void
write_tp_start(const std::string& name, size_t ntcs)
write_tp_start(const std::string& name,
size_t ntcs ATF_DEFS_ATTRIBUTE_UNUSED)
{
m_tpname = name;
m_failed = false;
@ -123,14 +143,17 @@ public:
virtual
void
write_tp_end(const std::string& reason)
write_tp_end(struct timeval* tv, const std::string& reason)
{
const std::string timestamp = format_tv(tv);
if (!reason.empty())
(*m_os) << "tp, " << m_tpname << ", bogus, " << reason << "\n";
(*m_os) << "tp, " << timestamp << ", " << m_tpname << ", bogus, "
<< reason << "\n";
else if (m_failed)
(*m_os) << "tp, " << m_tpname << ", failed\n";
(*m_os) << "tp, " << timestamp << ", "<< m_tpname << ", failed\n";
else
(*m_os) << "tp, " << m_tpname << ", passed\n";
(*m_os) << "tp, " << timestamp << ", "<< m_tpname << ", passed\n";
}
virtual
@ -142,12 +165,13 @@ public:
virtual
void
write_tc_end(const std::string& state, const std::string& reason)
write_tc_end(const std::string& state, struct timeval* tv,
const std::string& reason)
{
std::string str = "tc, " + m_tpname + ", " + m_tcname + ", " + state;
std::string str = m_tpname + ", " + m_tcname + ", " + state;
if (!reason.empty())
str += ", " + reason;
(*m_os) << str << "\n";
(*m_os) << "tc, " << format_tv(tv) << ", " << str << "\n";
if (state == "failed")
m_failed = true;
@ -211,7 +235,7 @@ class ticker_writer : public writer {
}
void
write_tp_end(const std::string& reason)
write_tp_end(struct timeval* tv, const std::string& reason)
{
using atf::ui::format_text_with_tag;
@ -225,7 +249,7 @@ class ticker_writer : public writer {
<< "\n";
m_failed_tps.push_back(m_tpname);
}
(*m_os) << "\n";
(*m_os) << "[" << format_tv(tv) << "s]\n\n";
(*m_os).flush();
m_tpname.clear();
@ -241,10 +265,13 @@ class ticker_writer : public writer {
}
void
write_tc_end(const std::string& state, const std::string& reason)
write_tc_end(const std::string& state, struct timeval* tv,
const std::string& reason)
{
std::string str;
(*m_os) << "[" << format_tv(tv) << "s] ";
if (state == "expected_death" || state == "expected_exit" ||
state == "expected_failure" || state == "expected_signal" ||
state == "expected_timeout") {
@ -267,7 +294,7 @@ class ticker_writer : public writer {
// XXX Wrap text. format_text_with_tag does not currently allow
// to specify the current column, which is needed because we have
// already printed the tc's name.
(*m_os) << str << "\n";
(*m_os) << str << '\n';
m_tcname = "";
}
@ -388,16 +415,18 @@ class xml_writer : public writer {
}
void
write_tp_start(const std::string& tp, size_t ntcs)
write_tp_start(const std::string& tp,
size_t ntcs ATF_DEFS_ATTRIBUTE_UNUSED)
{
(*m_os) << "<tp id=\"" << attrval(tp) << "\">\n";
}
void
write_tp_end(const std::string& reason)
write_tp_end(struct timeval* tv, const std::string& reason)
{
if (!reason.empty())
(*m_os) << "<failed>" << elemval(reason) << "</failed>\n";
(*m_os) << "<tp-time>" << format_tv(tv) << "</tp-time>";
(*m_os) << "</tp>\n";
}
@ -420,7 +449,8 @@ class xml_writer : public writer {
}
void
write_tc_end(const std::string& state, const std::string& reason)
write_tc_end(const std::string& state, struct timeval* tv,
const std::string& reason)
{
std::string str;
@ -437,6 +467,7 @@ class xml_writer : public writer {
(*m_os) << "<skipped>" << elemval(reason) << "</skipped>\n";
} else
UNREACHABLE;
(*m_os) << "<tc-time>" << format_tv(tv) << "</tc-time>";
(*m_os) << "</tc>\n";
}
@ -450,7 +481,7 @@ public:
xml_writer(const atf::fs::path& p) :
m_os(open_outfile(p))
{
(*m_os) << "<?xml version=\"1.0\"?>\n"
(*m_os) << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
<< "<!DOCTYPE tests-results PUBLIC "
"\"-//NetBSD//DTD ATF Tests Results 0.1//EN\" "
"\"http://www.NetBSD.org/XML/atf/tests-results.dtd\">\n\n"
@ -498,11 +529,11 @@ class converter : public atf::atf_report::atf_tps_reader {
}
void
got_tp_end(const std::string& reason)
got_tp_end(struct timeval* tv, const std::string& reason)
{
for (outs_vector::iterator iter = m_outs.begin();
iter != m_outs.end(); iter++)
(*iter)->write_tp_end(reason);
(*iter)->write_tp_end(tv, reason);
}
void
@ -530,11 +561,12 @@ class converter : public atf::atf_report::atf_tps_reader {
}
void
got_tc_end(const std::string& state, const std::string& reason)
got_tc_end(const std::string& state, struct timeval* tv,
const std::string& reason)
{
for (outs_vector::iterator iter = m_outs.begin();
iter != m_outs.end(); iter++)
(*iter)->write_tc_end(state, reason);
(*iter)->write_tc_end(state, tv, reason);
}
void
@ -638,6 +670,9 @@ atf_report::specific_options(void)
int
atf_report::main(void)
{
if (m_argc > 0)
throw std::runtime_error("No arguments allowed");
if (m_oflags.empty())
m_oflags.push_back(fmt_path_pair("ticker", atf::fs::path("-")));

View File

@ -1,7 +1,7 @@
/*
* Automated Testing Framework (atf)
*
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
* Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -31,6 +31,10 @@ body {
margin: 0 0 0 0;
}
.nobr {
white-space: nowrap;
}
h1 {
background: black;
color: white;
@ -56,6 +60,11 @@ h3 {
padding: 3pt;
}
p.details {
margin-left: 20pt;
margin-right: 20pt;
}
p.term {
margin-left: 40pt;
margin-right: 40pt;
@ -138,9 +147,15 @@ table.tcs-summary th {
padding: 3pt 6pt 3pt 6pt;
}
table.tcs-summary td.numeric {
text-align: right;
width: 1pt;
}
table.tcs-summary td.tp-id {
background: #dddddd;
font-weight: bold;
width: 1pt;
}
table.tcs-summary td.tc-id p {
@ -149,16 +164,24 @@ table.tcs-summary td.tc-id p {
table.tcs-summary td.tcr-passed {
background: #aaffaa;
width: 1pt;
}
table.tcs-summary td.tcr-failed {
background: #ffaaaa;
width: 1pt;
}
table.tcs-summary td.tcr-skipped {
background: #ffffaa;
width: 1pt;
}
table.tcs-summary td.tcr-xfail {
background: #ffaaff;
width: 1pt;
}
table.tcs-summary td.tcr-reason {
width: 100%;
}

View File

@ -4,7 +4,7 @@
<!--
++ Automated Testing Framework (atf)
++
++ Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
++ Copyright (c) 2007 The NetBSD Foundation, Inc.
++ All rights reserved.
++
++ Redistribution and use in source and binary forms, with or without
@ -101,8 +101,8 @@
<table class="summary">
<tr>
<th><p>Item</p></th>
<th><p>Value</p></th>
<th class="nobr"><p>Item</p></th>
<th class="nobr"><p>Value</p></th>
</tr>
<tr class="group">
@ -277,9 +277,10 @@
<table class="tcs-summary">
<tr>
<th><p>Test case</p></th>
<th><p>Result</p></th>
<th><p>Reason</p></th>
<th class="nobr"><p>Test case</p></th>
<th class="nobr"><p>Result</p></th>
<th class="nobr"><p>Reason</p></th>
<th class="nobr"><p>Duration</p></th>
</tr>
<xsl:apply-templates select="tp" mode="summary">
<xsl:with-param name="which">all</xsl:with-param>
@ -293,9 +294,10 @@
<table class="tcs-summary">
<tr>
<th><p>Test case</p></th>
<th><p>Result</p></th>
<th><p>Reason</p></th>
<th class="nobr"><p>Test case</p></th>
<th class="nobr"><p>Result</p></th>
<th class="nobr"><p>Reason</p></th>
<th class="nobr"><p>Duration</p></th>
</tr>
<xsl:apply-templates select="tp" mode="summary">
<xsl:with-param name="which">xfail</xsl:with-param>
@ -309,9 +311,10 @@
<table class="tcs-summary">
<tr>
<th><p>Test case</p></th>
<th><p>Result</p></th>
<th><p>Reason</p></th>
<th class="nobr"><p>Test case</p></th>
<th class="nobr"><p>Result</p></th>
<th class="nobr"><p>Reason</p></th>
<th class="nobr"><p>Duration</p></th>
</tr>
<xsl:apply-templates select="tp" mode="summary">
<xsl:with-param name="which">failed</xsl:with-param>
@ -325,7 +328,7 @@
<table class="tcs-summary">
<tr>
<th>Test program</th>
<th class="nobr">Test program</th>
</tr>
<xsl:apply-templates select="tp" mode="summary">
<xsl:with-param name="which">bogus</xsl:with-param>
@ -339,9 +342,10 @@
<table class="tcs-summary">
<tr>
<th><p>Test case</p></th>
<th><p>Result</p></th>
<th><p>Reason</p></th>
<th class="nobr"><p>Test case</p></th>
<th class="nobr"><p>Result</p></th>
<th class="nobr"><p>Reason</p></th>
<th class="nobr"><p>Duration</p></th>
</tr>
<xsl:apply-templates select="tp" mode="summary">
<xsl:with-param name="which">skipped</xsl:with-param>
@ -378,6 +382,9 @@
<td class="tp-id" colspan="3">
<p><xsl:value-of select="@id" /></p>
</td>
<td class="numeric">
<xsl:apply-templates select="tp-time" />s
</td>
</tr>
<xsl:if test="$which != 'bogus'">
<xsl:apply-templates select="tc" mode="summary">
@ -430,48 +437,51 @@
expected_failure|expected_timeout|
expected_signal|failed|passed|
skipped" mode="tc" />
<td class="numeric">
<xsl:apply-templates select="tc-time" />s
</td>
</tr>
</xsl:if>
</xsl:template>
<xsl:template match="passed" mode="tc">
<td class="tcr-passed"><p>Passed</p></td>
<td><p>N/A</p></td>
<td class="tcr-passed"><p class="nobr">Passed</p></td>
<td class="tcr-reason"><p>N/A</p></td>
</xsl:template>
<xsl:template match="expected_death" mode="tc">
<td class="tcr-xfail"><p>Expected death</p></td>
<td><p><xsl:apply-templates /></p></td>
<td class="tcr-xfail"><p class="nobr">Expected death</p></td>
<td class="tcr-reason"><p><xsl:apply-templates /></p></td>
</xsl:template>
<xsl:template match="expected_exit" mode="tc">
<td class="tcr-xfail"><p>Expected exit</p></td>
<td><p><xsl:apply-templates /></p></td>
<td class="tcr-xfail"><p class="nobr">Expected exit</p></td>
<td class="tcr-reason"><p><xsl:apply-templates /></p></td>
</xsl:template>
<xsl:template match="expected_failure" mode="tc">
<td class="tcr-xfail"><p>Expected failure</p></td>
<td><p><xsl:apply-templates /></p></td>
<td class="tcr-xfail"><p class="nobr">Expected failure</p></td>
<td class="tcr-reason"><p><xsl:apply-templates /></p></td>
</xsl:template>
<xsl:template match="expected_timeout" mode="tc">
<td class="tcr-xfail"><p>Expected timeout</p></td>
<td><p><xsl:apply-templates /></p></td>
<td class="tcr-xfail"><p class="nobr">Expected timeout</p></td>
<td class="tcr-reason"><p><xsl:apply-templates /></p></td>
</xsl:template>
<xsl:template match="expected_signal" mode="tc">
<td class="tcr-xfail"><p>Expected signal</p></td>
<td><p><xsl:apply-templates /></p></td>
<td class="tcr-xfail"><p class="nobr">Expected signal</p></td>
<td class="tcr-reason"><p><xsl:apply-templates /></p></td>
</xsl:template>
<xsl:template match="failed" mode="tc">
<td class="tcr-failed"><p>Failed</p></td>
<td><p><xsl:apply-templates /></p></td>
<td class="tcr-failed"><p class="nobr">Failed</p></td>
<td class="tcr-reason"><p><xsl:apply-templates /></p></td>
</xsl:template>
<xsl:template match="skipped" mode="tc">
<td class="tcr-skipped"><p>Skipped</p></td>
<td><p><xsl:apply-templates /></p></td>
<td class="tcr-skipped"><p class="nobr">Skipped</p></td>
<td class="tcr-reason"><p><xsl:apply-templates /></p></td>
</xsl:template>
<xsl:template match="tp" mode="details">
@ -503,6 +513,11 @@
<xsl:value-of select="../@id" /><xsl:text>/</xsl:text>
<xsl:value-of select="@id" /></h2>
<xsl:if test="tc-time">
<p class="details">Duration:
<xsl:apply-templates select="tc-time" mode="details" /></p>
</xsl:if>
<h3>Termination reason</h3>
<xsl:apply-templates select="expected_death|expected_exit|expected_failure|
expected_signal|expected_timeout|
@ -520,6 +535,10 @@
</xsl:if>
</xsl:template>
<xsl:template match="tc-time" mode="details">
<xsl:apply-templates /> seconds
</xsl:template>
<xsl:template match="so" mode="details">
<xsl:apply-templates />
<xsl:if test="position() != last()">

View File

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2009, 2011 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
#
# Automated Testing Framework (atf)
#
# Copyright (c) 2007, 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
# Copyright (c) 2007 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -381,8 +381,9 @@ EOF
create_atffile helper
re='^tc-end: [0-9][0-9]*\.[0-9]*, tc1,'
atf_check -s eq:1 \
-o match:'^tc-end: tc1, failed,.*failed to create' \
-o match:"${re} failed,.*failed to create" \
-o not-match:'resfile found' \
-e empty atf-run
}
@ -407,7 +408,8 @@ EOF
create_atffile helper
atf_check -s eq:1 -o match:'^tc-end: tc1, .*line 1.*line 2' -e empty atf-run
re='^tc-end: [0-9][0-9]*\.[0-9]*, tc1,'
atf_check -s eq:1 -o match:"${re} .*line 1.*line 2" -e empty atf-run
}
atf_test_case broken_tp_list
@ -436,7 +438,7 @@ EOF
create_atffile helper
re='^tp-end: helper,'
re='^tp-end: [0-9][0-9]*\.[0-9]*, helper,'
re="${re} Invalid format for test case list:.*First property.*ident"
atf_check -s eq:1 -o match:"${re}" -e empty atf-run
}
@ -458,8 +460,9 @@ EOF
create_atffile helper
re='^tp-end: [0-9][0-9]*\.[0-9]*, helper,'
atf_check -s eq:1 \
-o match:'^tp-end: helper,.*Invalid format for test case list' \
-o match:"${re} .*Invalid format for test case list" \
-e empty atf-run
}
@ -479,8 +482,9 @@ EOF
create_atffile helper
re='^tc-end: [0-9][0-9]*\.[0-9]*, tc1,'
atf_check -s eq:1 \
-o match:'^tc-end: tc1,.*exited successfully.*reported failure' \
-o match:"${re} .*exited successfully.*reported failure" \
-e empty atf-run
}
@ -503,7 +507,8 @@ EOF
create_atffile helper
atf_check -s eq:1 -o match:'^tc-end: tc2,.*received signal 9' \
re='^tc-end: [0-9][0-9]*\.[0-9]*, tc2,'
atf_check -s eq:1 -o match:"${re} .*received signal 9" \
-e empty atf-run
}

View File

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -407,8 +407,9 @@ muxer_test(const size_t bufsize, const size_t iterations)
std::cout << "flush done\n";
check_stream(std::cout);
sigchld.unprogram();
int status;
::wait(&status);
ATF_REQUIRE(::waitpid(pid, &status, 0) != -1);
ATF_REQUIRE(WIFEXITED(status));
ATF_REQUIRE(WEXITSTATUS(status) == EXIT_SUCCESS);

View File

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -27,18 +27,19 @@
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// TODO: We probably don't want to raise std::runtime_error for the errors
// detected in this file.
extern "C" {
#include <sys/param.h>
#include <sys/sysctl.h>
};
}
#include <cstdlib>
#include <cstring>
#include <cerrno>
#include <cstring>
#include <stdexcept>
extern "C" {
#include "atf-c/defs.h"
}
#include "atf-c++/config.hpp"
#include "atf-c++/detail/fs.hpp"
@ -147,6 +148,66 @@ check_machine(const std::string& machines)
return "Requires one of the '" + machines + "' machine types";
}
#if defined(__APPLE__) || defined(__NetBSD__)
static
std::string
check_memory_sysctl(const int64_t needed, const char* sysctl_variable)
{
int64_t available;
std::size_t available_length = sizeof(available);
if (::sysctlbyname(sysctl_variable, &available, &available_length,
NULL, 0) == -1) {
const char* e = std::strerror(errno);
return "Failed to get sysctl(hw.usermem64) value: " + std::string(e);
}
if (available < needed) {
return "Not enough memory; needed " + atf::text::to_string(needed) +
", available " + atf::text::to_string(available);
} else
return "";
}
# if defined(__APPLE__)
static
std::string
check_memory_darwin(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 ATF_DEFS_ATTRIBUTE_UNUSED)
{
return "";
}
#endif
static
std::string
check_memory(const std::string& raw_memory)
{
const int64_t needed = atf::text::to_bytes(raw_memory);
#if defined(__APPLE__)
return check_memory_darwin(needed);
#elif defined(__NetBSD__)
return check_memory_netbsd(needed);
#else
return check_memory_unknown(needed);
#endif
}
static
std::string
check_progs(const std::string& progs)
@ -193,36 +254,6 @@ check_user(const std::string& user, const atf::tests::vars_map& config)
"require.user");
}
static
std::string
check_memory(const std::string& memory)
{
// Make sure we have enough memory
int64_t memneed = atf::text::to_number(memory);
int64_t memavail;
size_t len = sizeof(memavail);
if (::sysctlbyname("hw.usermem64", &memavail, &len, NULL, 0) == -1) {
const char *e = ::strerror(errno);
std::stringstream ss;
ss << "sysctl hw.usermem64 failed (" << e << ")";
return ss.str();
}
if (memavail < memneed) {
char avail[6], need[6];
::humanize_number(avail, sizeof(avail), memavail, "", HN_AUTOSCALE,
HN_B | HN_NOSPACE);
::humanize_number(need, sizeof(need), memneed, "", HN_AUTOSCALE,
HN_B | HN_NOSPACE);
std::stringstream ss;
ss << "available memory (" << avail <<
") is less than required (" << need << ")";
return ss.str();
}
return "";
}
} // anonymous namespace
std::string
@ -245,12 +276,12 @@ impl::check_requirements(const atf::tests::vars_map& metadata,
failure_reason = check_files(value);
else if (name == "require.machine")
failure_reason = check_machine(value);
else if (name == "require.memory")
failure_reason = check_memory(value);
else if (name == "require.progs")
failure_reason = check_progs(value);
else if (name == "require.user")
failure_reason = check_user(value, config);
else if (name == "require.memory")
failure_reason = check_memory(value);
else {
// Unknown require.* properties are forbidden by the
// application/X-atf-tp parser.

View File

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2009, 2010, 2011 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -30,6 +30,7 @@
extern "C" {
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <fcntl.h>
#include <signal.h>
@ -42,6 +43,8 @@ extern "C" {
#include <fstream>
#include <iostream>
#include "atf-c/defs.h"
#include "atf-c++/detail/env.hpp"
#include "atf-c++/detail/parser.hpp"
#include "atf-c++/detail/process.hpp"
@ -167,6 +170,24 @@ struct test_case_params {
}
};
static
std::string
generate_timestamp(void)
{
struct timeval tv;
if (gettimeofday(&tv, NULL) == -1)
return "0.0";
char buf[32];
const int len = snprintf(buf, sizeof(buf), "%ld.%ld",
static_cast< long >(tv.tv_sec),
static_cast< long >(tv.tv_usec));
if (len >= static_cast< int >(sizeof(buf)) || len < 0)
return "0.0";
else
return buf;
}
static
void
append_to_vector(std::vector< std::string >& v1,
@ -395,8 +416,9 @@ detail::atf_tp_reader::~atf_tp_reader(void)
}
void
detail::atf_tp_reader::got_tc(const std::string& ident,
const std::map< std::string, std::string >& md)
detail::atf_tp_reader::got_tc(
const std::string& ident ATF_DEFS_ATTRIBUTE_UNUSED,
const std::map< std::string, std::string >& md ATF_DEFS_ATTRIBUTE_UNUSED)
{
}
@ -418,7 +440,6 @@ detail::atf_tp_reader::validate_and_insert(const std::string& name,
const std::string ident_regex = "^[_A-Za-z0-9]+$";
const std::string integer_regex = "^[0-9]+$";
const std::string memory_regex = "^[0-9]+[KMGT]$";
if (name == "descr") {
// Any non-empty value is valid.
@ -437,14 +458,15 @@ detail::atf_tp_reader::validate_and_insert(const std::string& name,
} else if (name == "require.config") {
} else if (name == "require.files") {
} else if (name == "require.machine") {
} else if (name == "require.memory") {
try {
(void)atf::text::to_bytes(value);
} catch (const std::runtime_error&) {
throw parse_error(lineno, "The require.memory property requires an "
"integer value representing an amount of bytes");
}
} else if (name == "require.progs") {
} else if (name == "require.user") {
} else if (name == "require.memory") {
if (!atf::text::match(value, integer_regex) &&
!atf::text::match(value, memory_regex))
throw parse_error(lineno, "The require.memory property requires"
" an integer value or a string of the form"
" <number>[KMGT]");
} else if (name == "timeout") {
if (!atf::text::match(value, integer_regex))
throw parse_error(lineno, "The timeout property requires an integer"
@ -545,7 +567,7 @@ impl::atf_tps_writer::atf_tps_writer(std::ostream& os) :
{
atf::parser::headers_map hm;
atf::parser::attrs_map ct_attrs;
ct_attrs["version"] = "2";
ct_attrs["version"] = "3";
hm["Content-Type"] =
atf::parser::header_entry("Content-Type", "application/X-atf-tps",
ct_attrs);
@ -570,7 +592,8 @@ void
impl::atf_tps_writer::start_tp(const std::string& tp, size_t ntcs)
{
m_tpname = tp;
m_os << "tp-start: " << tp << ", " << ntcs << "\n";
m_os << "tp-start: " << generate_timestamp() << ", " << tp << ", "
<< ntcs << "\n";
m_os.flush();
}
@ -579,9 +602,10 @@ impl::atf_tps_writer::end_tp(const std::string& reason)
{
PRE(reason.find('\n') == std::string::npos);
if (reason.empty())
m_os << "tp-end: " << m_tpname << "\n";
m_os << "tp-end: " << generate_timestamp() << ", " << m_tpname << "\n";
else
m_os << "tp-end: " << m_tpname << ", " << reason << "\n";
m_os << "tp-end: " << generate_timestamp() << ", " << m_tpname
<< ", " << reason << "\n";
m_os.flush();
}
@ -589,7 +613,7 @@ void
impl::atf_tps_writer::start_tc(const std::string& tcname)
{
m_tcname = tcname;
m_os << "tc-start: " << tcname << "\n";
m_os << "tc-start: " << generate_timestamp() << ", " << tcname << "\n";
m_os.flush();
}
@ -615,10 +639,10 @@ void
impl::atf_tps_writer::end_tc(const std::string& state,
const std::string& reason)
{
std::string str = "tc-end: " + m_tcname + ", " + state;
std::string str = ", " + m_tcname + ", " + state;
if (!reason.empty())
str += ", " + reason;
m_os << str << "\n";
m_os << "tc-end: " << generate_timestamp() << str << "\n";
m_os.flush();
}
@ -671,7 +695,7 @@ namespace {
static volatile bool terminate_poll;
static void
sigchld_handler(const int signo)
sigchld_handler(const int signo ATF_DEFS_ATTRIBUTE_UNUSED)
{
terminate_poll = true;
}

View File

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
// Copyright (c) 2010 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -98,11 +98,11 @@ print_indented(const std::string& str)
// at the moment will be bogus if there are some.
static
void
check_equal(const atf::tests::tc& tc, const std::string& str,
check_match(const atf::tests::tc& tc, const std::string& str,
const std::string& exp)
{
if (str != exp) {
std::cout << "String equality check failed.\n"
if (!atf::text::match(str, exp)) {
std::cout << "String match check failed.\n"
<< "Adding >> and << to delimit the string boundaries "
"below.\n";
std::cout << "GOT:\n";
@ -490,6 +490,29 @@ ATF_TEST_CASE_BODY(tp_59)
do_parser_test< tp_reader >(input, exp_calls, exp_errors);
}
ATF_TEST_CASE_WITHOUT_HEAD(tp_60);
ATF_TEST_CASE_BODY(tp_60)
{
const char* input =
"Content-Type: application/X-atf-tp; version=\"1\"\n"
"\n"
"ident: test\n"
"require.memory: 12345D\n"
;
const char* exp_calls[] = {
NULL
};
const char* exp_errors[] = {
"4: The require.memory property requires an integer value representing"
" an amount of bytes",
NULL
};
do_parser_test< tp_reader >(input, exp_calls, exp_errors);
}
// -------------------------------------------------------------------------
// Tests for the "tps" writer.
// -------------------------------------------------------------------------
@ -503,19 +526,20 @@ ATF_TEST_CASE_BODY(atf_tps_writer)
{
std::ostringstream expss;
std::ostringstream ss;
const char *ts_regex = "[0-9]+\\.[0-9]{1,6}, ";
#define RESET \
expss.str(""); \
ss.str("")
#define CHECK \
check_equal(*this, ss.str(), expss.str())
check_match(*this, ss.str(), expss.str())
{
RESET;
impl::atf_tps_writer w(ss);
expss << "Content-Type: application/X-atf-tps; version=\"2\"\n\n";
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
CHECK;
}
@ -523,7 +547,7 @@ ATF_TEST_CASE_BODY(atf_tps_writer)
RESET;
impl::atf_tps_writer w(ss);
expss << "Content-Type: application/X-atf-tps; version=\"2\"\n\n";
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
CHECK;
w.info("foo", "bar");
@ -539,7 +563,7 @@ ATF_TEST_CASE_BODY(atf_tps_writer)
RESET;
impl::atf_tps_writer w(ss);
expss << "Content-Type: application/X-atf-tps; version=\"2\"\n\n";
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
CHECK;
w.ntps(0);
@ -551,7 +575,7 @@ ATF_TEST_CASE_BODY(atf_tps_writer)
RESET;
impl::atf_tps_writer w(ss);
expss << "Content-Type: application/X-atf-tps; version=\"2\"\n\n";
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
CHECK;
w.ntps(123);
@ -563,7 +587,7 @@ ATF_TEST_CASE_BODY(atf_tps_writer)
RESET;
impl::atf_tps_writer w(ss);
expss << "Content-Type: application/X-atf-tps; version=\"2\"\n\n";
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
CHECK;
w.ntps(2);
@ -571,19 +595,19 @@ ATF_TEST_CASE_BODY(atf_tps_writer)
CHECK;
w.start_tp("foo", 0);
expss << "tp-start: foo, 0\n";
expss << "tp-start: " << ts_regex << "foo, 0\n";
CHECK;
w.end_tp("");
expss << "tp-end: foo\n";
expss << "tp-end: " << ts_regex << "foo\n";
CHECK;
w.start_tp("bar", 0);
expss << "tp-start: bar, 0\n";
expss << "tp-start: " << ts_regex << "bar, 0\n";
CHECK;
w.end_tp("failed program");
expss << "tp-end: bar, failed program\n";
expss << "tp-end: " << ts_regex << "bar, failed program\n";
CHECK;
}
@ -591,7 +615,7 @@ ATF_TEST_CASE_BODY(atf_tps_writer)
RESET;
impl::atf_tps_writer w(ss);
expss << "Content-Type: application/X-atf-tps; version=\"2\"\n\n";
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
CHECK;
w.ntps(1);
@ -599,15 +623,15 @@ ATF_TEST_CASE_BODY(atf_tps_writer)
CHECK;
w.start_tp("foo", 1);
expss << "tp-start: foo, 1\n";
expss << "tp-start: " << ts_regex << "foo, 1\n";
CHECK;
w.start_tc("brokentc");
expss << "tc-start: brokentc\n";
expss << "tc-start: " << ts_regex << "brokentc\n";
CHECK;
w.end_tp("aborted");
expss << "tp-end: foo, aborted\n";
expss << "tp-end: " << ts_regex << "foo, aborted\n";
CHECK;
}
@ -615,7 +639,7 @@ ATF_TEST_CASE_BODY(atf_tps_writer)
RESET;
impl::atf_tps_writer w(ss);
expss << "Content-Type: application/X-atf-tps; version=\"2\"\n\n";
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
CHECK;
w.ntps(1);
@ -623,35 +647,35 @@ ATF_TEST_CASE_BODY(atf_tps_writer)
CHECK;
w.start_tp("thetp", 3);
expss << "tp-start: thetp, 3\n";
expss << "tp-start: " << ts_regex << "thetp, 3\n";
CHECK;
w.start_tc("passtc");
expss << "tc-start: passtc\n";
expss << "tc-start: " << ts_regex << "passtc\n";
CHECK;
w.end_tc("passed", "");
expss << "tc-end: passtc, passed\n";
expss << "tc-end: " << ts_regex << "passtc, passed\n";
CHECK;
w.start_tc("failtc");
expss << "tc-start: failtc\n";
expss << "tc-start: " << ts_regex << "failtc\n";
CHECK;
w.end_tc("failed", "The reason");
expss << "tc-end: failtc, failed, The reason\n";
expss << "tc-end: " << ts_regex << "failtc, failed, The reason\n";
CHECK;
w.start_tc("skiptc");
expss << "tc-start: skiptc\n";
expss << "tc-start: " << ts_regex << "skiptc\n";
CHECK;
w.end_tc("skipped", "The reason");
expss << "tc-end: skiptc, skipped, The reason\n";
expss << "tc-end: " << ts_regex << "skiptc, skipped, The reason\n";
CHECK;
w.end_tp("");
expss << "tp-end: thetp\n";
expss << "tp-end: " << ts_regex << "thetp\n";
CHECK;
}
@ -659,7 +683,7 @@ ATF_TEST_CASE_BODY(atf_tps_writer)
RESET;
impl::atf_tps_writer w(ss);
expss << "Content-Type: application/X-atf-tps; version=\"2\"\n\n";
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
CHECK;
w.ntps(1);
@ -667,11 +691,11 @@ ATF_TEST_CASE_BODY(atf_tps_writer)
CHECK;
w.start_tp("thetp", 1);
expss << "tp-start: thetp, 1\n";
expss << "tp-start: " << ts_regex << "thetp, 1\n";
CHECK;
w.start_tc("thetc");
expss << "tc-start: thetc\n";
expss << "tc-start: " << ts_regex << "thetc\n";
CHECK;
w.stdout_tc("a line");
@ -687,11 +711,11 @@ ATF_TEST_CASE_BODY(atf_tps_writer)
CHECK;
w.end_tc("passed", "");
expss << "tc-end: thetc, passed\n";
expss << "tc-end: " << ts_regex << "thetc, passed\n";
CHECK;
w.end_tp("");
expss << "tp-end: thetp\n";
expss << "tp-end: " << ts_regex << "thetp\n";
CHECK;
}
@ -699,7 +723,7 @@ ATF_TEST_CASE_BODY(atf_tps_writer)
RESET;
impl::atf_tps_writer w(ss);
expss << "Content-Type: application/X-atf-tps; version=\"2\"\n\n";
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
CHECK;
w.ntps(1);
@ -707,11 +731,11 @@ ATF_TEST_CASE_BODY(atf_tps_writer)
CHECK;
w.start_tp("thetp", 0);
expss << "tp-start: thetp, 0\n";
expss << "tp-start: " << ts_regex << "thetp, 0\n";
CHECK;
w.end_tp("");
expss << "tp-end: thetp\n";
expss << "tp-end: " << ts_regex << "thetp\n";
CHECK;
w.info("foo", "bar");
@ -966,6 +990,7 @@ ATF_INIT_TEST_CASES(tcs)
ATF_ADD_TEST_CASE(tcs, tp_57);
ATF_ADD_TEST_CASE(tcs, tp_58);
ATF_ADD_TEST_CASE(tcs, tp_59);
ATF_ADD_TEST_CASE(tcs, tp_60);
ATF_ADD_TEST_CASE(tcs, atf_tps_writer);

View File

@ -27,9 +27,21 @@
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#include <csignal>
#if defined(HAVE_CONFIG_H)
# include <bconfig.h>
#endif
extern "C" {
#include <sys/time.h>
}
#include <cerrno>
#include <csignal>
#include <ctime>
extern "C" {
#include "atf-c/defs.h"
}
#include "atf-c++/detail/exceptions.hpp"
#include "atf-c++/detail/sanity.hpp"
@ -40,110 +52,139 @@
namespace impl = atf::atf_run;
#define IMPL_NAME "atf::atf_run"
#if !defined(HAVE_TIMER_T)
static impl::timer* compat_handle;
#endif
// ------------------------------------------------------------------------
// Auxiliary functions.
// ------------------------------------------------------------------------
#ifdef SIGEV_NONE
#define HAVE_POSIX_TIMER
#endif
#ifndef HAVE_POSIX_TIMER
static void *handle;
#endif
#if defined(HAVE_TIMER_T)
static
void
handler(int signo, siginfo_t *si, void *uc)
handler(const int signo ATF_DEFS_ATTRIBUTE_UNUSED, siginfo_t* si,
void* uc ATF_DEFS_ATTRIBUTE_UNUSED)
{
impl::timer *timer = static_cast<impl::timer *>(
#ifdef HAVE_POSIX_TIMER
si->si_value.sival_ptr
#else
handle
#endif
);
timer->setfired();
impl::timer* timer = static_cast< impl::timer* >(si->si_value.sival_ptr);
timer->set_fired();
timer->timeout_callback();
}
#else
static
void
handler(const int signo ATF_DEFS_ATTRIBUTE_UNUSED,
siginfo_t* si ATF_DEFS_ATTRIBUTE_UNUSED,
void* uc ATF_DEFS_ATTRIBUTE_UNUSED)
{
compat_handle->set_fired();
compat_handle->timeout_callback();
}
#endif
// ------------------------------------------------------------------------
// The "timer" class.
// ------------------------------------------------------------------------
impl::timer::timer(const unsigned int seconds) : m_fired(false)
struct impl::timer::impl {
#if defined(HAVE_TIMER_T)
::timer_t m_timer;
::itimerspec m_old_it;
#else
::itimerval m_old_it;
#endif
struct ::sigaction m_old_sa;
volatile bool m_fired;
impl(void) : m_fired(false)
{
}
};
impl::timer::timer(const unsigned int seconds) :
m_pimpl(new impl())
{
struct sigaction sa;
::sigemptyset(&sa.sa_mask);
struct ::sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = ::handler;
if (::sigaction(SIGALRM, &sa, &m_old_sa) == -1)
if (::sigaction(SIGALRM, &sa, &m_pimpl->m_old_sa) == -1)
throw system_error(IMPL_NAME "::timer::timer",
"Failed to set signal handler", errno);
#ifdef HAVE_POSIX_TIMER
::sigevent se;
#if defined(HAVE_TIMER_T)
struct ::sigevent se;
se.sigev_notify = SIGEV_SIGNAL;
se.sigev_signo = SIGALRM;
se.sigev_value.sival_ptr = static_cast<void *>(this);
se.sigev_value.sival_ptr = static_cast< void* >(this);
se.sigev_notify_function = NULL;
se.sigev_notify_attributes = NULL;
if (::timer_create(CLOCK_MONOTONIC, &se, &m_timer) == -1) {
::sigaction(SIGALRM, &m_old_sa, NULL);
if (::timer_create(CLOCK_MONOTONIC, &se, &m_pimpl->m_timer) == -1) {
::sigaction(SIGALRM, &m_pimpl->m_old_sa, NULL);
throw system_error(IMPL_NAME "::timer::timer",
"Failed to create timer", errno);
}
::itimerspec it;
struct ::itimerspec it;
it.it_interval.tv_sec = 0;
it.it_interval.tv_nsec = 0;
it.it_value.tv_sec = seconds;
it.it_value.tv_nsec = 0;
if (::timer_settime(m_timer, 0, &it, &m_old_it) == -1) {
::sigaction(SIGALRM, &m_old_sa, NULL);
::timer_delete(m_timer);
if (::timer_settime(m_pimpl->m_timer, 0, &it, &m_pimpl->m_old_it) == -1) {
::sigaction(SIGALRM, &m_pimpl->m_old_sa, NULL);
::timer_delete(m_pimpl->m_timer);
throw system_error(IMPL_NAME "::timer::timer",
"Failed to program timer", errno);
}
#else
::itimerval it, oit;
::itimerval it;
it.it_interval.tv_sec = 0;
it.it_interval.tv_usec = 0;
it.it_value.tv_sec = seconds;
it.it_value.tv_usec = 0;
if (::setitimer(ITIMER_REAL, &it, &oit) == -1) {
::sigaction(SIGALRM, &m_old_sa, NULL);
if (::setitimer(ITIMER_REAL, &it, &m_pimpl->m_old_it) == -1) {
::sigaction(SIGALRM, &m_pimpl->m_old_sa, NULL);
throw system_error(IMPL_NAME "::timer::timer",
"Failed to program timer", errno);
}
TIMEVAL_TO_TIMESPEC(&oit.it_interval, &m_old_it.it_interval);
TIMEVAL_TO_TIMESPEC(&oit.it_value, &m_old_it.it_value);
handle = static_cast<void *>(this);
INV(compat_handle == NULL);
compat_handle = this;
#endif
}
impl::timer::~timer(void)
{
int ret;
#ifdef HAVE_POSIX_TIMER
ret = ::timer_delete(m_timer);
#if defined(HAVE_TIMER_T)
{
const int ret = ::timer_delete(m_pimpl->m_timer);
INV(ret != -1);
}
#else
::itimerval oit;
TIMESPEC_TO_TIMEVAL(&oit.it_interval, &m_old_it.it_interval);
TIMESPEC_TO_TIMEVAL(&oit.it_value, &m_old_it.it_value);
ret = ::setitimer(ITIMER_REAL, &oit, NULL);
{
const int ret = ::setitimer(ITIMER_REAL, &m_pimpl->m_old_it, NULL);
INV(ret != -1);
}
#endif
const int ret = ::sigaction(SIGALRM, &m_pimpl->m_old_sa, NULL);
INV(ret != -1);
ret = ::sigaction(SIGALRM, &m_old_sa, NULL);
INV(ret != -1);
#if !defined(HAVE_TIMER_T)
compat_handle = NULL;
#endif
}
bool
impl::timer::fired(void)
const
{
return m_fired;
return m_pimpl->m_fired;
}
void
impl::timer::set_fired(void)
{
m_pimpl->m_fired = true;
}
// ------------------------------------------------------------------------
@ -170,5 +211,5 @@ impl::child_timer::timeout_callback(void)
::kill(-m_pid, SIGTERM);
::nanosleep(&ts, NULL);
if (::kill(-m_pid, 0) != -1)
::kill(-m_pid, SIGKILL);
::kill(-m_pid, SIGKILL);
}

View File

@ -30,8 +30,11 @@
#if !defined(_ATF_RUN_ALARM_HPP_)
#define _ATF_RUN_ALARM_HPP_
#include <ctime>
#include <csignal>
extern "C" {
#include <sys/types.h>
}
#include <memory>
#include "atf-c++/utils.hpp"
@ -45,17 +48,15 @@ class signal_programmer;
// ------------------------------------------------------------------------
class timer : utils::noncopyable {
::timer_t m_timer;
::itimerspec m_old_it;
struct sigaction m_old_sa;
bool m_fired;
struct impl;
std::auto_ptr< impl > m_pimpl;
public:
timer(const unsigned int);
virtual ~timer(void);
bool fired(void) const;
void setfired(void) { m_fired = true; }
void set_fired(void);
virtual void timeout_callback(void) = 0;
};

View File

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
// Copyright (c) 2008 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
#
# Automated Testing Framework (atf)
#
# Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
# Copyright (c) 2008 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -214,7 +214,7 @@ oflag_inline_body()
# XXX Ugly hack to workaround the lack of \e in FreeBSD. Look for a
# nicer solution...
case $(uname) in
FreeBSD)
Darwin|FreeBSD)
h_pass "printf '\a\b\f\n\r\t\v'" -o inline:"\a\b\f\n\r\t\v"
;;
*)
@ -334,7 +334,7 @@ eflag_inline_body()
# XXX Ugly hack to workaround the lack of \e in FreeBSD. Look for a
# nicer solution...
case $(uname) in
FreeBSD)
Darwin|FreeBSD)
h_pass "printf '\a\b\f\n\r\t\v' 1>&2" -e inline:"\a\b\f\n\r\t\v"
;;
*)

View File

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
.\"
.\" Automated Testing Framework (atf)
.\"
.\" Copyright (c) 2007, 2008, 2010, 2011 The NetBSD Foundation, Inc.
.\" Copyright (c) 2007 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@ -26,7 +26,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd May 29, 2011
.Dd January 13, 2011
.Dt ATF-TEST-CASE 4
.Os
.Sh NAME
@ -210,6 +210,17 @@ Optional.
.Pp
A whitespace separated list of machine types that the test case can be run
under without causing errors due to a machine type mismatch.
.It require.memory
Type: integer.
Optional.
Specifies the minimum amount of physical memory needed by the test.
The value can have a size suffix such as
.Sq K ,
.Sq M ,
.Sq G
or
.Sq T
to make the amount of bytes easier to type and read.
.It require.progs
Type: textual.
Optional.