//
// 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.
//
extern "C" {
}
#include <cctype>
#include <cstdlib>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <memory>
#include <sstream>
#include <utility>
#include <vector>
#include "atf-c++/detail/application.hpp"
#include "atf-c++/detail/sanity.hpp"
#include "reader.hpp"
static ostream_ptr
{
else
if (!(*osp))
return osp;
}
{
}
// ------------------------------------------------------------------------
// The "writer" interface.
// ------------------------------------------------------------------------
//!
//! \brief A base class that defines an output format.
//!
//! The writer base class defines a generic interface to output formats.
//! This is meant to be subclassed, and each subclass can redefine any
//! method to format the information as it wishes.
//!
//! This class is not tied to a output stream nor a file because, depending
//! on the output format, we will want to write to a single file or to
//! multiple ones.
//!
class writer {
public:
writer(void) {}
virtual ~writer(void) {}
virtual void write_eof(void) {}
};
// ------------------------------------------------------------------------
// The "csv_writer" class.
// ------------------------------------------------------------------------
//!
//! \brief A very simple plain-text output format.
//!
//! The csv_writer class implements a very simple plain-text output
//! format that summarizes the results of each executed test case. The
//! results are meant to be easily parseable by third-party tools, hence
//! they are formatted as a CSV file.
//!
bool m_failed;
public:
m_os(open_outfile(p))
{
}
virtual
void
{
m_failed = false;
}
virtual
void
{
<< reason << "\n";
else if (m_failed)
else
}
virtual
void
{
}
virtual
void
{
if (state == "failed")
m_failed = true;
}
};
// ------------------------------------------------------------------------
// The "ticker_writer" class.
// ------------------------------------------------------------------------
//!
//! \brief A console-friendly output format.
//!
//! The ticker_writer class implements a formatter that is user-friendly
//! in the sense that it shows the execution of test cases in an easy to
//! read format. It is not meant to be parseable and its format can
//! freely change across releases.
//!
void
{
if (what == "tests.root") {
}
}
void
{
m_curtp = 1;
m_tcs_passed = 0;
m_tcs_failed = 0;
m_tcs_skipped = 0;
}
void
{
<< "\n";
}
void
{
m_curtp++;
"trust its results because "
m_tpname + ": ", false)
<< "\n";
}
}
void
{
}
void
{
state == "expected_timeout") {
} else if (state == "failed") {
m_tcs_failed++;
} else if (state == "passed") {
str = "Passed.";
m_tcs_passed++;
} else if (state == "skipped") {
} else
// 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_tcname = "";
}
static void
{
<< "\n";
}
}
void
write_eof(void)
{
if (!m_failed_tps.empty()) {
<< "\n";
" ", false) << "\n\n";
}
if (!m_expected_failures_tcs.empty()) {
(*m_os) << "\n";
}
if (!m_failed_tcs.empty()) {
" ", false) << "\n\n";
}
" test programs:") << "\n";
" passed test cases.",
" ", false) << "\n";
" failed test cases.",
" ", false) << "\n";
" expected failed test cases.",
" ", false) << "\n";
" skipped test cases.",
" ", false) << "\n";
}
public:
m_os(open_outfile(p))
{
}
};
// ------------------------------------------------------------------------
// The "xml" class.
// ------------------------------------------------------------------------
//!
//! \brief A single-file XML output format.
//!
//! The xml_writer class implements a formatter that prints the results
//! of test cases in an XML format easily parseable later on by other
//! utilities.
//!
static
{
return str;
}
static
{
if (character == '&') {
buf << "&";
} else if (character == '<') {
buf << "<";
} else if (character == '>') {
buf << ">";
} else {
}
}
}
void
{
}
void
{
}
void
{
(*m_os) << "</tp>\n";
}
void
{
}
void
{
}
void
{
}
void
{
state == "expected_timeout") {
} else if (state == "passed") {
(*m_os) << "<passed />\n";
} else if (state == "failed") {
} else if (state == "skipped") {
} else
(*m_os) << "</tc>\n";
}
void
write_eof(void)
{
(*m_os) << "</tests-results>\n";
}
public:
m_os(open_outfile(p))
{
(*m_os) << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
<< "<!DOCTYPE tests-results PUBLIC "
"\"-//NetBSD//DTD ATF Tests Results 0.1//EN\" "
"<tests-results>\n";
}
};
// ------------------------------------------------------------------------
// The "converter" class.
// ------------------------------------------------------------------------
//!
//! \brief A reader that redirects events to multiple writers.
//!
//! The converter class implements an atf_tps_reader that, for each event
//! raised by the parser, redirects it to multiple writers so that they
//! can reformat it according to their output rules.
//!
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
{
}
void
got_eof(void)
{
}
public:
{
}
~converter(void)
{
delete *iter;
}
void
{
if (fmt == "csv") {
} else if (fmt == "ticker") {
} else if (fmt == "xml") {
} else
}
};
// ------------------------------------------------------------------------
// The "atf_report" class.
// ------------------------------------------------------------------------
static const char* m_description;
void process_option(int, const char*);
options_set specific_options(void) const;
public:
atf_report(void);
int main(void);
};
"atf-report is a tool that parses the output of atf-run and "
"generates user-friendly reports in multiple different formats.";
{
}
void
{
switch (ch) {
case 'o':
{
else {
}
}
break;
default:
}
}
const
{
"ones can be specified, and a - "
"path means stdout"));
return opts;
}
int
{
if (m_argc > 0)
// Look for path duplicates.
"specified more than once");
}
// Generate the output files.
return EXIT_SUCCESS;
}
int
{
}