//
// Automated Testing Framework (atf)
//
// Copyright (c) 2010 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.
//
#include <fstream>
#include <iostream>
#include "atf-c++/macros.hpp"
#include "atf-c++/detail/parser.hpp"
#include "atf-c++/detail/test_helpers.hpp"
#include "test-program.hpp"
// -------------------------------------------------------------------------
// Auxiliary functions.
// -------------------------------------------------------------------------
static
{
}
static
void
{
}
static void
{
}
static
void
{
}
static
void
{
}
// XXX Should this string handling and verbosity level be part of the
// ATF_REQUIRE_EQ macro? It may be hard to predict sometimes that a
// string can have newlines in it, and so the error message generated
// at the moment will be bogus if there are some.
static
void
{
<< "Adding >> and << to delimit the string boundaries "
"below.\n";
}
}
// -------------------------------------------------------------------------
// Tests for the "tp" reader.
// -------------------------------------------------------------------------
void
{
call += ", ";
}
call += "})";
}
void
got_eof(void)
{
}
public:
{
}
void
read(void)
{
atf_tp_reader::read();
}
};
{
const char* input =
"Content-Type: application/X-atf-tp; version=\"1\"\n"
"\n"
"ident: test_case_1\n"
"\n"
"ident: test_case_2\n"
"\n"
"ident: test_case_3\n"
;
const char* exp_calls[] = {
"got_tc(test_case_1, {ident=test_case_1})",
"got_tc(test_case_2, {ident=test_case_2})",
"got_tc(test_case_3, {ident=test_case_3})",
"got_eof()",
};
const char* exp_errors[] = {
};
}
{
const char* input =
"Content-Type: application/X-atf-tp; version=\"1\"\n"
"\n"
"ident: test_case_1\n"
"descr: This is the description\n"
"timeout: 300\n"
"\n"
"ident: test_case_2\n"
"\n"
"ident: test_case_3\n"
"X-prop1: A custom property\n"
"descr: Third test case\n"
;
// NO_CHECK_STYLE_BEGIN
const char* exp_calls[] = {
"got_tc(test_case_1, {descr=This is the description, ident=test_case_1, timeout=300})",
"got_tc(test_case_2, {ident=test_case_2})",
"got_tc(test_case_3, {X-prop1=A custom property, descr=Third test case, ident=test_case_3})",
"got_eof()",
};
// NO_CHECK_STYLE_END
const char* exp_errors[] = {
};
}
{
const char* input =
"Content-Type: application/X-atf-tp; version=\"1\"\n"
"\n"
"ident: single_test\n"
"descr: Some description\n"
"timeout: 300\n"
"require.arch: thearch\n"
"require.config: foo-bar\n"
"require.files: /a/1 /b/2\n"
"require.machine: themachine\n"
"require.user: root\n"
;
// NO_CHECK_STYLE_BEGIN
const char* exp_calls[] = {
"got_tc(single_test, {descr=Some description, ident=single_test, require.arch=thearch, require.config=foo-bar, require.files=/a/1 /b/2, require.machine=themachine, require.progs=/bin/cp mv, require.user=root, timeout=300})",
"got_eof()",
};
// NO_CHECK_STYLE_END
const char* exp_errors[] = {
};
}
{
const char* input =
"Content-Type: application/X-atf-tp; version=\"1\"\n"
"\n"
"ident: single_test \n"
"descr: Some description \n"
;
const char* exp_calls[] = {
"got_tc(single_test, {descr=Some description, ident=single_test})",
"got_eof()",
};
const char* exp_errors[] = {
};
}
{
const char* input =
"Content-Type: application/X-atf-tp; version=\"1\"\n"
"\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"3: Unexpected token `<<EOF>>'; expected property name",
};
}
{
const char* input =
"Content-Type: application/X-atf-tp; version=\"1\"\n"
"\n"
"\n"
"\n"
"\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"3: Unexpected token `<<NEWLINE>>'; expected property name",
};
}
{
const char* input =
"Content-Type: application/X-atf-tp; version=\"1\"\n"
"\n"
"ident: test1\n"
"ident: test2\n"
;
const char* exp_calls[] = {
"got_tc(test1, {ident=test1})",
"got_eof()",
};
const char* exp_errors[] = {
};
}
{
const char* input =
"Content-Type: application/X-atf-tp; version=\"1\"\n"
"\n"
"descr: Out of order\n"
"ident: test1\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"3: First property of a test case must be 'ident'",
};
}
{
const char* input =
"Content-Type: application/X-atf-tp; version=\"1\"\n"
"\n"
"ident:\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"3: The value for 'ident' cannot be empty",
};
}
{
const char* input =
"Content-Type: application/X-atf-tp; version=\"1\"\n"
"\n"
"ident: +*,\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"3: The identifier must match ^[_A-Za-z0-9]+$; was '+*,'",
};
}
{
const char* input =
"Content-Type: application/X-atf-tp; version=\"1\"\n"
"\n"
"ident: test\n"
"timeout: hello\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"4: The timeout property requires an integer value",
};
}
{
const char* input =
"Content-Type: application/X-atf-tp; version=\"1\"\n"
"\n"
"ident: test\n"
"unknown: property\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"4: Unknown property 'unknown'",
};
}
{
const char* input =
"Content-Type: application/X-atf-tp; version=\"1\"\n"
"\n"
"ident: test\n"
"X-foo:\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"4: The value for 'X-foo' cannot be empty",
};
}
{
const char* input =
"Content-Type: application/X-atf-tp; version=\"1\"\n"
"\n"
"\n"
"ident: test\n"
"timeout: 300\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"3: Unexpected token `<<NEWLINE>>'; expected property name",
};
}
{
const char* input =
"Content-Type: application/X-atf-tp; version=\"1\"\n"
"\n"
"ident: test\n"
"require.memory: 12345D\n"
;
const char* exp_calls[] = {
};
const char* exp_errors[] = {
"4: The require.memory property requires an integer value representing"
" an amount of bytes",
};
}
// -------------------------------------------------------------------------
// Tests for the "tps" writer.
// -------------------------------------------------------------------------
{
}
{
#define RESET \
#define CHECK \
{
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
}
{
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
expss << "info: foo, bar\n";
expss << "info: baz, second info\n";
}
{
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
w.ntps(0);
expss << "tps-count: 0\n";
}
{
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
w.ntps(123);
expss << "tps-count: 123\n";
}
{
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
w.ntps(2);
expss << "tps-count: 2\n";
w.start_tp("foo", 0);
w.end_tp("");
w.start_tp("bar", 0);
w.end_tp("failed program");
}
{
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
w.ntps(1);
expss << "tps-count: 1\n";
w.start_tc("brokentc");
w.end_tp("aborted");
}
{
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
w.ntps(1);
expss << "tps-count: 1\n";
w.start_tc("passtc");
w.start_tc("failtc");
w.start_tc("skiptc");
w.end_tp("");
}
{
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
w.ntps(1);
expss << "tps-count: 1\n";
w.start_tc("thetc");
w.stdout_tc("a line");
expss << "tc-so:a line\n";
w.stdout_tc("another line");
expss << "tc-so:another line\n";
w.stderr_tc("an error message");
expss << "tc-se:an error message\n";
w.end_tp("");
}
{
expss << "Content-Type: application/X-atf-tps; version=\"3\"\n\n";
w.ntps(1);
expss << "tps-count: 1\n";
w.start_tp("thetp", 0);
w.end_tp("");
expss << "info: foo, bar\n";
expss << "info: baz, second value\n";
}
}
// -------------------------------------------------------------------------
// Tests for the free functions.
// -------------------------------------------------------------------------
}
}
{
}
{
}
{
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
// -------------------------------------------------------------------------
// Main.
// -------------------------------------------------------------------------
{
// TODO: Add tests for run_test_case once all the missing functionality
// is implemented.
}