mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-21 18:27:22 +00:00
MFV: Import atf-0.21.
This commit is contained in:
commit
0677dfd1c4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=273929
|
@ -374,7 +374,6 @@ OLD_FILES+=usr/share/man/man1/atf-report.1.gz
|
|||
OLD_FILES+=usr/share/man/man1/atf-run.1.gz
|
||||
OLD_FILES+=usr/share/man/man1/atf-version.1.gz
|
||||
OLD_FILES+=usr/share/man/man5/atf-formats.5.gz
|
||||
OLD_FILES+=usr/share/man/man7/atf.7.gz
|
||||
OLD_FILES+=usr/share/xml/atf/tests-results.dtd
|
||||
OLD_FILES+=usr/share/xsl/atf/tests-results.xsl
|
||||
# 20131009: freebsd-version moved from /libexec to /bin
|
||||
|
|
|
@ -1,22 +1,12 @@
|
|||
*/*/Atffile
|
||||
*/*/Makefile*
|
||||
*/Atffile
|
||||
*/Makefile*
|
||||
*/*.m4
|
||||
*/*.pc.in
|
||||
Atffile
|
||||
INSTALL
|
||||
Makefile*
|
||||
aclocal.m4
|
||||
admin/
|
||||
atf-config/
|
||||
atf-report/
|
||||
atf-run/
|
||||
atf-version/
|
||||
bconfig.h.in
|
||||
config.h.in
|
||||
bootstrap/
|
||||
configure*
|
||||
doc/atf-formats.5
|
||||
doc/atf.7.in
|
||||
m4/
|
||||
tools/
|
||||
|
|
|
@ -1,6 +1,62 @@
|
|||
Major changes between releases Automated Testing Framework
|
||||
===========================================================================
|
||||
|
||||
Changes in version 0.21
|
||||
***********************
|
||||
|
||||
Released on October 23rd, 2014.
|
||||
|
||||
* Restored the atf(7) manual page to serve as a reference to all the other
|
||||
manual pages shipped by ATF.
|
||||
|
||||
* Added the -s flag to atf-sh to support specifying the shell interpreter
|
||||
to be used.
|
||||
|
||||
* Removed ATF_WORKDIR. The only remaining consumers have been converted to
|
||||
use the standard TMPDIR environment variable. As a benefit, and because
|
||||
Kyua forces the TMPDIR to live within the test case's work directory,
|
||||
any stale files left behind by ATF will be automatically cleaned up.
|
||||
|
||||
* Documented the environment variables recognized by each component in the
|
||||
relevant manual pages. This information was lost with the atf-config(1)
|
||||
removal.
|
||||
|
||||
* Added a new "require.diskspace" metadata property to test cases so that
|
||||
they can specify the minimum amount of disk space required for the test
|
||||
to run.
|
||||
|
||||
* Renamed the atf-{c,c++,sh}-api(3) manual pages to atf-{c,c++,sh}(3) for
|
||||
discoverability purposes. Symbolic links are provided for the time
|
||||
being to still make the old names visible.
|
||||
|
||||
* Issue #5: Recommend the (expected, actual) idiom for calls to the test
|
||||
macros in the manual pages.
|
||||
|
||||
* Issue #7: Stopped catching unhandled exceptions in atf-c++ tests. This
|
||||
propagates the crash to the caller, which in turn allows it to obtain
|
||||
proper debugging information. In particular, Kyua should now be able to
|
||||
extract a stacktrace pinpointing the problem.
|
||||
|
||||
* Issue #8: Fixed atf-c/macros_test:use test failures spotted by the clang
|
||||
that ships with FreeBSD 11.0-CURRENT.
|
||||
|
||||
* Issue #12: Improved documentation of atf-sh(3) and atf-check(1) by better
|
||||
explaining how they relate to each other.
|
||||
|
||||
* Issue #14: Stopped setting 'set -e' in atf-sh. This setting was
|
||||
initially added as a way to enable a "strict" mode in the library and to
|
||||
make test cases fail fast when they run unprotected commands. However,
|
||||
doing so in the library is surprising as the responsibility of enabling
|
||||
'set -e' should be on the user's code. Also, 'set -e' introduces
|
||||
inconsistent behavior on subshells and users do not expect that.
|
||||
|
||||
* Issue #15: Fixed atf_utils_{fork,wait} to support nested calls.
|
||||
|
||||
* Issue #16: Fixed test failures (by removing a long-standing hack) on
|
||||
systems that lack \e support in printf(1).
|
||||
|
||||
* Issue #19: Removed stale references to atf-config and atf-run.
|
||||
|
||||
|
||||
Changes in version 0.20
|
||||
***********************
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,12 +22,11 @@
|
|||
// 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(_ATF_CXX_HPP_)
|
||||
#define _ATF_CXX_HPP_
|
||||
#if !defined(ATF_CXX_HPP)
|
||||
#define ATF_CXX_HPP
|
||||
|
||||
#include <atf-c++/macros.hpp>
|
||||
#include <atf-c++/utils.hpp>
|
||||
|
||||
#endif // !defined(_ATF_CXX_HPP_)
|
||||
#endif // !defined(ATF_CXX_HPP)
|
||||
|
|
|
@ -5,7 +5,6 @@ test_suite("atf")
|
|||
atf_test_program{name="atf_c++_test"}
|
||||
atf_test_program{name="build_test"}
|
||||
atf_test_program{name="check_test"}
|
||||
atf_test_program{name="config_test"}
|
||||
atf_test_program{name="macros_test"}
|
||||
atf_test_program{name="pkg_config_test"}
|
||||
atf_test_program{name="tests_test"}
|
||||
|
|
649
contrib/atf/atf-c++/atf-c++.3
Normal file
649
contrib/atf/atf-c++/atf-c++.3
Normal file
|
@ -0,0 +1,649 @@
|
|||
.\" Copyright (c) 2008 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
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" 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.
|
||||
.Dd October 13, 2014
|
||||
.Dt ATF-C++ 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm atf-c++ ,
|
||||
.Nm ATF_ADD_TEST_CASE ,
|
||||
.Nm ATF_CHECK_ERRNO ,
|
||||
.Nm ATF_FAIL ,
|
||||
.Nm ATF_INIT_TEST_CASES ,
|
||||
.Nm ATF_PASS ,
|
||||
.Nm ATF_REQUIRE ,
|
||||
.Nm ATF_REQUIRE_EQ ,
|
||||
.Nm ATF_REQUIRE_ERRNO ,
|
||||
.Nm ATF_REQUIRE_IN ,
|
||||
.Nm ATF_REQUIRE_MATCH ,
|
||||
.Nm ATF_REQUIRE_NOT_IN ,
|
||||
.Nm ATF_REQUIRE_THROW ,
|
||||
.Nm ATF_REQUIRE_THROW_RE ,
|
||||
.Nm ATF_SKIP ,
|
||||
.Nm ATF_TEST_CASE ,
|
||||
.Nm ATF_TEST_CASE_BODY ,
|
||||
.Nm ATF_TEST_CASE_CLEANUP ,
|
||||
.Nm ATF_TEST_CASE_HEAD ,
|
||||
.Nm ATF_TEST_CASE_NAME ,
|
||||
.Nm ATF_TEST_CASE_USE ,
|
||||
.Nm ATF_TEST_CASE_WITH_CLEANUP ,
|
||||
.Nm ATF_TEST_CASE_WITHOUT_HEAD ,
|
||||
.Nm atf::utils::cat_file ,
|
||||
.Nm atf::utils::compare_file ,
|
||||
.Nm atf::utils::copy_file ,
|
||||
.Nm atf::utils::create_file ,
|
||||
.Nm atf::utils::file_exists ,
|
||||
.Nm atf::utils::fork ,
|
||||
.Nm atf::utils::grep_collection ,
|
||||
.Nm atf::utils::grep_file ,
|
||||
.Nm atf::utils::grep_string ,
|
||||
.Nm atf::utils::redirect ,
|
||||
.Nm atf::utils::wait
|
||||
.Nd C++ API to write ATF-based test programs
|
||||
.Sh SYNOPSIS
|
||||
.In atf-c++.hpp
|
||||
.Fn ATF_ADD_TEST_CASE "tcs" "name"
|
||||
.Fn ATF_CHECK_ERRNO "expected_errno" "bool_expression"
|
||||
.Fn ATF_FAIL "reason"
|
||||
.Fn ATF_INIT_TEST_CASES "tcs"
|
||||
.Fn ATF_PASS
|
||||
.Fn ATF_REQUIRE "expression"
|
||||
.Fn ATF_REQUIRE_EQ "expected_expression" "actual_expression"
|
||||
.Fn ATF_REQUIRE_ERRNO "expected_errno" "bool_expression"
|
||||
.Fn ATF_REQUIRE_IN "element" "collection"
|
||||
.Fn ATF_REQUIRE_MATCH "regexp" "string_expression"
|
||||
.Fn ATF_REQUIRE_NOT_IN "element" "collection"
|
||||
.Fn ATF_REQUIRE_THROW "expected_exception" "statement"
|
||||
.Fn ATF_REQUIRE_THROW_RE "expected_exception" "regexp" "statement"
|
||||
.Fn ATF_SKIP "reason"
|
||||
.Fn ATF_TEST_CASE "name"
|
||||
.Fn ATF_TEST_CASE_BODY "name"
|
||||
.Fn ATF_TEST_CASE_CLEANUP "name"
|
||||
.Fn ATF_TEST_CASE_HEAD "name"
|
||||
.Fn ATF_TEST_CASE_NAME "name"
|
||||
.Fn ATF_TEST_CASE_USE "name"
|
||||
.Fn ATF_TEST_CASE_WITH_CLEANUP "name"
|
||||
.Fn ATF_TEST_CASE_WITHOUT_HEAD "name"
|
||||
.Ft void
|
||||
.Fo atf::utils::cat_file
|
||||
.Fa "const std::string& path"
|
||||
.Fa "const std::string& prefix"
|
||||
.Fc
|
||||
.Ft bool
|
||||
.Fo atf::utils::compare_file
|
||||
.Fa "const std::string& path"
|
||||
.Fa "const std::string& contents"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo atf::utils::copy_file
|
||||
.Fa "const std::string& source"
|
||||
.Fa "const std::string& destination"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo atf::utils::create_file
|
||||
.Fa "const std::string& path"
|
||||
.Fa "const std::string& contents"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo atf::utils::file_exists
|
||||
.Fa "const std::string& path"
|
||||
.Fc
|
||||
.Ft pid_t
|
||||
.Fo atf::utils::fork
|
||||
.Fa "void"
|
||||
.Fc
|
||||
.Ft bool
|
||||
.Fo atf::utils::grep_collection
|
||||
.Fa "const std::string& regexp"
|
||||
.Fa "const Collection& collection"
|
||||
.Fc
|
||||
.Ft bool
|
||||
.Fo atf::utils::grep_file
|
||||
.Fa "const std::string& regexp"
|
||||
.Fa "const std::string& path"
|
||||
.Fc
|
||||
.Ft bool
|
||||
.Fo atf::utils::grep_string
|
||||
.Fa "const std::string& regexp"
|
||||
.Fa "const std::string& path"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo atf::utils::redirect
|
||||
.Fa "const int fd"
|
||||
.Fa "const std::string& path"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo atf::utils::wait
|
||||
.Fa "const pid_t pid"
|
||||
.Fa "const int expected_exit_status"
|
||||
.Fa "const std::string& expected_stdout"
|
||||
.Fa "const std::string& expected_stderr"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
ATF provides a C++ programming interface to implement test programs.
|
||||
C++-based test programs follow this template:
|
||||
.Bd -literal -offset indent
|
||||
extern "C" {
|
||||
.Ns ... C-specific includes go here ...
|
||||
}
|
||||
|
||||
.Ns ... C++-specific includes go here ...
|
||||
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
ATF_TEST_CASE(tc1);
|
||||
ATF_TEST_CASE_HEAD(tc1)
|
||||
{
|
||||
... first test case's header ...
|
||||
}
|
||||
ATF_TEST_CASE_BODY(tc1)
|
||||
{
|
||||
... first test case's body ...
|
||||
}
|
||||
|
||||
ATF_TEST_CASE_WITH_CLEANUP(tc2);
|
||||
ATF_TEST_CASE_HEAD(tc2)
|
||||
{
|
||||
... second test case's header ...
|
||||
}
|
||||
ATF_TEST_CASE_BODY(tc2)
|
||||
{
|
||||
... second test case's body ...
|
||||
}
|
||||
ATF_TEST_CASE_CLEANUP(tc2)
|
||||
{
|
||||
... second test case's cleanup ...
|
||||
}
|
||||
|
||||
ATF_TEST_CASE(tc3);
|
||||
ATF_TEST_CASE_BODY(tc3)
|
||||
{
|
||||
... third test case's body ...
|
||||
}
|
||||
|
||||
.Ns ... additional test cases ...
|
||||
|
||||
ATF_INIT_TEST_CASES(tcs)
|
||||
{
|
||||
ATF_ADD_TEST_CASE(tcs, tc1);
|
||||
ATF_ADD_TEST_CASE(tcs, tc2);
|
||||
ATF_ADD_TEST_CASE(tcs, tc3);
|
||||
... add additional test cases ...
|
||||
}
|
||||
.Ed
|
||||
.Ss Definition of test cases
|
||||
Test cases have an identifier and are composed of three different parts:
|
||||
the header, the body and an optional cleanup routine, all of which are
|
||||
described in
|
||||
.Xr atf-test-case 4 .
|
||||
To define test cases, one can use the
|
||||
.Fn ATF_TEST_CASE ,
|
||||
.Fn ATF_TEST_CASE_WITH_CLEANUP
|
||||
or the
|
||||
.Fn ATF_TEST_CASE_WITHOUT_HEAD
|
||||
macros, which take a single parameter specifiying the test case's
|
||||
name.
|
||||
.Fn ATF_TEST_CASE ,
|
||||
requires to define a head and a body for the test case,
|
||||
.Fn ATF_TEST_CASE_WITH_CLEANUP
|
||||
requires to define a head, a body and a cleanup for the test case and
|
||||
.Fn ATF_TEST_CASE_WITHOUT_HEAD
|
||||
requires only a body for the test case.
|
||||
It is important to note that these
|
||||
.Em do not
|
||||
set the test case up for execution when the program is run.
|
||||
In order to do so, a later registration is needed through the
|
||||
.Fn ATF_ADD_TEST_CASE
|
||||
macro detailed in
|
||||
.Sx Program initialization .
|
||||
.Pp
|
||||
Later on, one must define the three parts of the body by means of three
|
||||
functions.
|
||||
Their headers are given by the
|
||||
.Fn ATF_TEST_CASE_HEAD ,
|
||||
.Fn ATF_TEST_CASE_BODY
|
||||
and
|
||||
.Fn ATF_TEST_CASE_CLEANUP
|
||||
macros, all of which take the test case's name.
|
||||
Following each of these, a block of code is expected, surrounded by the
|
||||
opening and closing brackets.
|
||||
.Pp
|
||||
Additionally, the
|
||||
.Fn ATF_TEST_CASE_NAME
|
||||
macro can be used to obtain the name of the class corresponding to a
|
||||
particular test case, as the name is internally manged by the library to
|
||||
prevent clashes with other user identifiers.
|
||||
Similarly, the
|
||||
.Fn ATF_TEST_CASE_USE
|
||||
macro can be executed on a particular test case to mark it as "used" and
|
||||
thus prevent compiler warnings regarding unused symbols.
|
||||
Note that
|
||||
.Em you should never have to use these macros during regular operation.
|
||||
.Ss Program initialization
|
||||
The library provides a way to easily define the test program's
|
||||
.Fn main
|
||||
function.
|
||||
You should never define one on your own, but rely on the
|
||||
library to do it for you.
|
||||
This is done by using the
|
||||
.Fn ATF_INIT_TEST_CASES
|
||||
macro, which is passed the name of the list that will hold the test cases.
|
||||
This name can be whatever you want as long as it is a valid variable value.
|
||||
.Pp
|
||||
After the macro, you are supposed to provide the body of a function, which
|
||||
should only use the
|
||||
.Fn ATF_ADD_TEST_CASE
|
||||
macro to register the test cases the test program will execute.
|
||||
The first parameter of this macro matches the name you provided in the
|
||||
former call.
|
||||
.Ss Header definitions
|
||||
The test case's header can define the meta-data by using the
|
||||
.Fn set_md_var
|
||||
method, which takes two parameters: the first one specifies the
|
||||
meta-data variable to be set and the second one specifies its value.
|
||||
Both of them are strings.
|
||||
.Ss Configuration variables
|
||||
The test case has read-only access to the current configuration variables
|
||||
by means of the
|
||||
.Ft bool
|
||||
.Fn has_config_var
|
||||
and the
|
||||
.Ft std::string
|
||||
.Fn get_config_var
|
||||
methods, which can be called in any of the three parts of a test case.
|
||||
.Ss Access to the source directory
|
||||
It is possible to get the path to the test case's source directory from any
|
||||
of its three components by querying the
|
||||
.Sq srcdir
|
||||
configuration variable.
|
||||
.Ss Requiring programs
|
||||
Aside from the
|
||||
.Va require.progs
|
||||
meta-data variable available in the header only, one can also check for
|
||||
additional programs in the test case's body by using the
|
||||
.Fn require_prog
|
||||
function, which takes the base name or full path of a single binary.
|
||||
Relative paths are forbidden.
|
||||
If it is not found, the test case will be automatically skipped.
|
||||
.Ss Test case finalization
|
||||
The test case finalizes either when the body reaches its end, at which
|
||||
point the test is assumed to have
|
||||
.Em passed ,
|
||||
or at any explicit call to
|
||||
.Fn ATF_PASS ,
|
||||
.Fn ATF_FAIL
|
||||
or
|
||||
.Fn ATF_SKIP .
|
||||
These three macros terminate the execution of the test case immediately.
|
||||
The cleanup routine will be processed afterwards in a completely automated
|
||||
way, regardless of the test case's termination reason.
|
||||
.Pp
|
||||
.Fn ATF_PASS
|
||||
does not take any parameters.
|
||||
.Fn ATF_FAIL
|
||||
and
|
||||
.Fn ATF_SKIP
|
||||
take a single string that describes why the test case failed or
|
||||
was skipped, respectively.
|
||||
It is very important to provide a clear error message in both cases so that
|
||||
the user can quickly know why the test did not pass.
|
||||
.Ss Expectations
|
||||
Everything explained in the previous section changes when the test case
|
||||
expectations are redefined by the programmer.
|
||||
.Pp
|
||||
Each test case has an internal state called
|
||||
.Sq expect
|
||||
that describes what the test case expectations are at any point in time.
|
||||
The value of this property can change during execution by any of:
|
||||
.Bl -tag -width indent
|
||||
.It Fn expect_death "reason"
|
||||
Expects the test case to exit prematurely regardless of the nature of the
|
||||
exit.
|
||||
.It Fn expect_exit "exitcode" "reason"
|
||||
Expects the test case to exit cleanly.
|
||||
If
|
||||
.Va exitcode
|
||||
is not
|
||||
.Sq -1 ,
|
||||
the runtime engine will validate that the exit code of the test case
|
||||
matches the one provided in this call.
|
||||
Otherwise, the exact value will be ignored.
|
||||
.It Fn expect_fail "reason"
|
||||
Any failure (be it fatal or non-fatal) raised in this mode is recorded.
|
||||
However, such failures do not report the test case as failed; instead, the
|
||||
test case finalizes cleanly and is reported as
|
||||
.Sq expected failure ;
|
||||
this report includes the provided
|
||||
.Fa reason
|
||||
as part of it.
|
||||
If no error is raised while running in this mode, then the test case is
|
||||
reported as
|
||||
.Sq failed .
|
||||
.Pp
|
||||
This mode is useful to reproduce actual known bugs in tests.
|
||||
Whenever the developer fixes the bug later on, the test case will start
|
||||
reporting a failure, signaling the developer that the test case must be
|
||||
adjusted to the new conditions.
|
||||
In this situation, it is useful, for example, to set
|
||||
.Fa reason
|
||||
as the bug number for tracking purposes.
|
||||
.It Fn expect_pass
|
||||
This is the normal mode of execution.
|
||||
In this mode, any failure is reported as such to the user and the test case
|
||||
is marked as
|
||||
.Sq failed .
|
||||
.It Fn expect_race "reason"
|
||||
Any failure or timeout during the execution of the test case will be
|
||||
considered as if a race condition has been triggered and reported as such.
|
||||
If no problems arise, the test will continue execution as usual.
|
||||
.It Fn expect_signal "signo" "reason"
|
||||
Expects the test case to terminate due to the reception of a signal.
|
||||
If
|
||||
.Va signo
|
||||
is not
|
||||
.Sq -1 ,
|
||||
the runtime engine will validate that the signal that terminated the test
|
||||
case matches the one provided in this call.
|
||||
Otherwise, the exact value will be ignored.
|
||||
.It Fn expect_timeout "reason"
|
||||
Expects the test case to execute for longer than its timeout.
|
||||
.El
|
||||
.Ss Helper macros for common checks
|
||||
The library provides several macros that are very handy in multiple
|
||||
situations.
|
||||
These basically check some condition after executing a given statement or
|
||||
processing a given expression and, if the condition is not met, they
|
||||
automatically call
|
||||
.Fn ATF_FAIL
|
||||
with an appropriate error message.
|
||||
.Pp
|
||||
.Fn ATF_REQUIRE
|
||||
takes an expression and raises a failure if it evaluates to false.
|
||||
.Pp
|
||||
.Fn ATF_REQUIRE_EQ
|
||||
takes two expressions and raises a failure if the two do not evaluate to
|
||||
the same exact value.
|
||||
The common style is to put the expected value in the first parameter and the
|
||||
actual value in the second parameter.
|
||||
.Pp
|
||||
.Fn ATF_REQUIRE_IN
|
||||
takes an element and a collection and validates that the element is present in
|
||||
the collection.
|
||||
.Pp
|
||||
.Fn ATF_REQUIRE_MATCH
|
||||
takes a regular expression and a string and raises a failure if the regular
|
||||
expression does not match the string.
|
||||
.Pp
|
||||
.Fn ATF_REQUIRE_NOT_IN
|
||||
takes an element and a collection and validates that the element is not present
|
||||
in the collection.
|
||||
.Pp
|
||||
.Fn ATF_REQUIRE_THROW
|
||||
takes the name of an exception and a statement and raises a failure if
|
||||
the statement does not throw the specified exception.
|
||||
.Fn ATF_REQUIRE_THROW_RE
|
||||
takes the name of an exception, a regular expresion and a statement and raises a
|
||||
failure if the statement does not throw the specified exception and if the
|
||||
message of the exception does not match the regular expression.
|
||||
.Pp
|
||||
.Fn ATF_CHECK_ERRNO
|
||||
and
|
||||
.Fn ATF_REQUIRE_ERRNO
|
||||
take, first, the error code that the check is expecting to find in the
|
||||
.Va errno
|
||||
variable and, second, a boolean expression that, if evaluates to true,
|
||||
means that a call failed and
|
||||
.Va errno
|
||||
has to be checked against the first value.
|
||||
.Ss Utility functions
|
||||
The following functions are provided as part of the
|
||||
.Nm
|
||||
API to simplify the creation of a variety of tests.
|
||||
In particular, these are useful to write tests for command-line interfaces.
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf::utils::cat_file
|
||||
.Fa "const std::string& path"
|
||||
.Fa "const std::string& prefix"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Prints the contents of
|
||||
.Fa path
|
||||
to the standard output, prefixing every line with the string in
|
||||
.Fa prefix .
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft bool
|
||||
.Fo atf::utils::compare_file
|
||||
.Fa "const std::string& path"
|
||||
.Fa "const std::string& contents"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Returns true if the given
|
||||
.Fa path
|
||||
matches exactly the expected inlined
|
||||
.Fa contents .
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf::utils::copy_file
|
||||
.Fa "const std::string& source"
|
||||
.Fa "const std::string& destination"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Copies the file
|
||||
.Fa source
|
||||
to
|
||||
.Fa destination .
|
||||
The permissions of the file are preserved during the code.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf::utils::create_file
|
||||
.Fa "const std::string& path"
|
||||
.Fa "const std::string& contents"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Creates
|
||||
.Fa file
|
||||
with the text given in
|
||||
.Fa contents .
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf::utils::file_exists
|
||||
.Fa "const std::string& path"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Checks if
|
||||
.Fa path
|
||||
exists.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft pid_t
|
||||
.Fo atf::utils::fork
|
||||
.Fa "void"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Forks a process and redirects the standard output and standard error of the
|
||||
child to files for later validation with
|
||||
.Fn atf::utils::wait .
|
||||
Fails the test case if the fork fails, so this does not return an error.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft bool
|
||||
.Fo atf::utils::grep_collection
|
||||
.Fa "const std::string& regexp"
|
||||
.Fa "const Collection& collection"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Searches for the regular expression
|
||||
.Fa regexp
|
||||
in any of the strings contained in the
|
||||
.Fa collection .
|
||||
This is a template that accepts any one-dimensional container of strings.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft bool
|
||||
.Fo atf::utils::grep_file
|
||||
.Fa "const std::string& regexp"
|
||||
.Fa "const std::string& path"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Searches for the regular expression
|
||||
.Fa regexp
|
||||
in the file
|
||||
.Fa path .
|
||||
The variable arguments are used to construct the regular expression.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft bool
|
||||
.Fo atf::utils::grep_string
|
||||
.Fa "const std::string& regexp"
|
||||
.Fa "const std::string& str"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Searches for the regular expression
|
||||
.Fa regexp
|
||||
in the string
|
||||
.Fa str .
|
||||
.Ed
|
||||
.Ft void
|
||||
.Fo atf::utils::redirect
|
||||
.Fa "const int fd"
|
||||
.Fa "const std::string& path"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Redirects the given file descriptor
|
||||
.Fa fd
|
||||
to the file
|
||||
.Fa path .
|
||||
This function exits the process in case of an error and does not properly mark
|
||||
the test case as failed.
|
||||
As a result, it should only be used in subprocesses of the test case; specially
|
||||
those spawned by
|
||||
.Fn atf::utils::fork .
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf::utils::wait
|
||||
.Fa "const pid_t pid"
|
||||
.Fa "const int expected_exit_status"
|
||||
.Fa "const std::string& expected_stdout"
|
||||
.Fa "const std::string& expected_stderr"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Waits and validates the result of a subprocess spawned with
|
||||
.Fn atf::utils::wait .
|
||||
The validation involves checking that the subprocess exited cleanly and returned
|
||||
the code specified in
|
||||
.Fa expected_exit_status
|
||||
and that its standard output and standard error match the strings given in
|
||||
.Fa expected_stdout
|
||||
and
|
||||
.Fa expected_stderr .
|
||||
.Pp
|
||||
If any of the
|
||||
.Fa expected_stdout
|
||||
or
|
||||
.Fa expected_stderr
|
||||
strings are prefixed with
|
||||
.Sq save: ,
|
||||
then they specify the name of the file into which to store the stdout or stderr
|
||||
of the subprocess, and no comparison is performed.
|
||||
.Ed
|
||||
.Sh ENVIRONMENT
|
||||
The following variables are recognized by
|
||||
.Nm
|
||||
but should not be overridden other than for testing purposes:
|
||||
.Pp
|
||||
.Bl -tag -width ATFXBUILDXCXXFLAGSXX -compact
|
||||
.It Va ATF_BUILD_CC
|
||||
Path to the C compiler.
|
||||
.It Va ATF_BUILD_CFLAGS
|
||||
C compiler flags.
|
||||
.It Va ATF_BUILD_CPP
|
||||
Path to the C/C++ preprocessor.
|
||||
.It Va ATF_BUILD_CPPFLAGS
|
||||
C/C++ preprocessor flags.
|
||||
.It Va ATF_BUILD_CXX
|
||||
Path to the C++ compiler.
|
||||
.It Va ATF_BUILD_CXXFLAGS
|
||||
C++ compiler flags.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
The following shows a complete test program with a single test case that
|
||||
validates the addition operator:
|
||||
.Bd -literal -offset indent
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
ATF_TEST_CASE(addition);
|
||||
ATF_TEST_CASE_HEAD(addition)
|
||||
{
|
||||
set_md_var("descr", "Sample tests for the addition operator");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(addition)
|
||||
{
|
||||
ATF_REQUIRE_EQ(0, 0 + 0);
|
||||
ATF_REQUIRE_EQ(1, 0 + 1);
|
||||
ATF_REQUIRE_EQ(1, 1 + 0);
|
||||
|
||||
ATF_REQUIRE_EQ(2, 1 + 1);
|
||||
|
||||
ATF_REQUIRE_EQ(300, 100 + 200);
|
||||
}
|
||||
|
||||
ATF_TEST_CASE(open_failure);
|
||||
ATF_TEST_CASE_HEAD(open_failure)
|
||||
{
|
||||
set_md_var("descr", "Sample tests for the open function");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(open_failure)
|
||||
{
|
||||
ATF_REQUIRE_ERRNO(ENOENT, open("non-existent", O_RDONLY) == -1);
|
||||
}
|
||||
|
||||
ATF_TEST_CASE(known_bug);
|
||||
ATF_TEST_CASE_HEAD(known_bug)
|
||||
{
|
||||
set_md_var("descr", "Reproduces a known bug");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(known_bug)
|
||||
{
|
||||
expect_fail("See bug number foo/bar");
|
||||
ATF_REQUIRE_EQ(3, 1 + 1);
|
||||
expect_pass();
|
||||
ATF_REQUIRE_EQ(3, 1 + 2);
|
||||
}
|
||||
|
||||
ATF_INIT_TEST_CASES(tcs)
|
||||
{
|
||||
ATF_ADD_TEST_CASE(tcs, addition);
|
||||
ATF_ADD_TEST_CASE(tcs, open_failure);
|
||||
ATF_ADD_TEST_CASE(tcs, known_bug);
|
||||
}
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr atf-test-program 1 ,
|
||||
.Xr atf-test-case 4
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,11 +22,10 @@
|
|||
// 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 "macros.hpp"
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
#include "detail/test_helpers.hpp"
|
||||
#include "atf-c++/detail/test_helpers.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Tests cases for the header file.
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,7 +22,8 @@
|
|||
// 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 "atf-c++/build.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "atf-c/build.h"
|
||||
|
@ -33,10 +31,8 @@ extern "C" {
|
|||
#include "atf-c/utils.h"
|
||||
}
|
||||
|
||||
#include "build.hpp"
|
||||
|
||||
#include "detail/exceptions.hpp"
|
||||
#include "detail/process.hpp"
|
||||
#include "atf-c++/detail/exceptions.hpp"
|
||||
#include "atf-c++/detail/process.hpp"
|
||||
|
||||
namespace impl = atf::build;
|
||||
#define IMPL_NAME "atf::build"
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,10 +22,9 @@
|
|||
// 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(_ATF_CXX_BUILD_HPP_)
|
||||
#define _ATF_CXX_BUILD_HPP_
|
||||
#if !defined(ATF_CXX_BUILD_HPP)
|
||||
#define ATF_CXX_BUILD_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -54,4 +50,4 @@ process::argv_array cxx_o(const std::string&, const std::string&,
|
|||
} // namespace build
|
||||
} // namespace atf
|
||||
|
||||
#endif // !defined(_ATF_CXX_BUILD_HPP_)
|
||||
#endif // !defined(ATF_CXX_BUILD_HPP)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,31 +22,25 @@
|
|||
// 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 "atf-c++/build.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include "../atf-c/h_build.h"
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
#include "build.hpp"
|
||||
#include "config.hpp"
|
||||
#include "macros.hpp"
|
||||
extern "C" {
|
||||
#include "atf-c/h_build.h"
|
||||
}
|
||||
|
||||
#include "detail/env.hpp"
|
||||
#include "detail/process.hpp"
|
||||
#include "detail/test_helpers.hpp"
|
||||
#include "atf-c++/detail/env.hpp"
|
||||
#include "atf-c++/detail/process.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Auxiliary functions.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace atf {
|
||||
namespace config {
|
||||
void __reinit(void);
|
||||
}
|
||||
}
|
||||
|
||||
template< class C >
|
||||
void
|
||||
print_col(const char* prefix, const C& c)
|
||||
|
@ -168,7 +159,6 @@ ATF_TEST_CASE_BODY(c_o)
|
|||
verbose_set_env("ATF_BUILD_CC", test->cc);
|
||||
verbose_set_env("ATF_BUILD_CFLAGS", test->cflags);
|
||||
verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags);
|
||||
atf::config::__reinit();
|
||||
|
||||
atf::process::argv_array argv =
|
||||
atf::build::c_o(test->sfile, test->ofile,
|
||||
|
@ -190,7 +180,6 @@ ATF_TEST_CASE_BODY(cpp)
|
|||
|
||||
verbose_set_env("ATF_BUILD_CPP", test->cpp);
|
||||
verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags);
|
||||
atf::config::__reinit();
|
||||
|
||||
atf::process::argv_array argv =
|
||||
atf::build::cpp(test->sfile, test->ofile,
|
||||
|
@ -213,7 +202,6 @@ ATF_TEST_CASE_BODY(cxx_o)
|
|||
verbose_set_env("ATF_BUILD_CXX", test->cxx);
|
||||
verbose_set_env("ATF_BUILD_CXXFLAGS", test->cxxflags);
|
||||
verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags);
|
||||
atf::config::__reinit();
|
||||
|
||||
atf::process::argv_array argv =
|
||||
atf::build::cxx_o(test->sfile, test->ofile,
|
||||
|
@ -222,12 +210,6 @@ ATF_TEST_CASE_BODY(cxx_o)
|
|||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Tests cases for the header file.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
HEADER_TC(include, "atf-c++/build.hpp");
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Main.
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -241,7 +223,4 @@ ATF_INIT_TEST_CASES(tcs)
|
|||
ATF_ADD_TEST_CASE(tcs, c_o);
|
||||
ATF_ADD_TEST_CASE(tcs, cpp);
|
||||
ATF_ADD_TEST_CASE(tcs, cxx_o);
|
||||
|
||||
// Add the test cases for the header file.
|
||||
ATF_ADD_TEST_CASE(tcs, include);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,7 +22,8 @@
|
|||
// 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 "atf-c++/check.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
|
@ -34,11 +32,9 @@ extern "C" {
|
|||
#include "atf-c/error.h"
|
||||
}
|
||||
|
||||
#include "check.hpp"
|
||||
|
||||
#include "detail/exceptions.hpp"
|
||||
#include "detail/process.hpp"
|
||||
#include "detail/sanity.hpp"
|
||||
#include "atf-c++/detail/exceptions.hpp"
|
||||
#include "atf-c++/detail/process.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
|
||||
namespace impl = atf::check;
|
||||
#define IMPL_NAME "atf::check"
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,10 +22,9 @@
|
|||
// 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(_ATF_CXX_CHECK_HPP_)
|
||||
#define _ATF_CXX_CHECK_HPP_
|
||||
#if !defined(ATF_CXX_CHECK_HPP)
|
||||
#define ATF_CXX_CHECK_HPP
|
||||
|
||||
extern "C" {
|
||||
#include <atf-c/check.h>
|
||||
|
@ -132,4 +128,4 @@ check_result test_constructor(void);
|
|||
} // namespace check
|
||||
} // namespace atf
|
||||
|
||||
#endif // !defined(_ATF_CXX_CHECK_HPP_)
|
||||
#endif // !defined(ATF_CXX_CHECK_HPP)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,7 +22,8 @@
|
|||
// 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 "atf-c++/check.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include <fcntl.h>
|
||||
|
@ -43,14 +41,11 @@ extern "C" {
|
|||
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
#include "check.hpp"
|
||||
#include "config.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
#include "detail/fs.hpp"
|
||||
#include "detail/process.hpp"
|
||||
#include "detail/test_helpers.hpp"
|
||||
#include "detail/text.hpp"
|
||||
#include "atf-c++/detail/fs.hpp"
|
||||
#include "atf-c++/detail/process.hpp"
|
||||
#include "atf-c++/detail/test_helpers.hpp"
|
||||
#include "atf-c++/detail/text.hpp"
|
||||
#include "atf-c++/utils.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Auxiliary functions.
|
||||
|
@ -374,7 +369,7 @@ ATF_TEST_CASE_HEAD(exec_unknown)
|
|||
ATF_TEST_CASE_BODY(exec_unknown)
|
||||
{
|
||||
std::vector< std::string > argv;
|
||||
argv.push_back(atf::config::get("atf_workdir") + "/non-existent");
|
||||
argv.push_back("/foo/bar/non-existent");
|
||||
|
||||
atf::process::argv_array argva(argv);
|
||||
std::auto_ptr< atf::check::check_result > r = atf::check::exec(argva);
|
||||
|
@ -382,12 +377,6 @@ ATF_TEST_CASE_BODY(exec_unknown)
|
|||
ATF_REQUIRE_EQ(r->exitcode(), 127);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Tests cases for the header file.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
HEADER_TC(include, "atf-c++/check.hpp");
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Main.
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -402,7 +391,4 @@ ATF_INIT_TEST_CASES(tcs)
|
|||
ATF_ADD_TEST_CASE(tcs, exec_exitstatus);
|
||||
ATF_ADD_TEST_CASE(tcs, exec_stdout_stderr);
|
||||
ATF_ADD_TEST_CASE(tcs, exec_unknown);
|
||||
|
||||
// Add the test cases for the header file.
|
||||
ATF_ADD_TEST_CASE(tcs, include);
|
||||
}
|
||||
|
|
|
@ -1,119 +0,0 @@
|
|||
//
|
||||
// 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
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 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 <map>
|
||||
|
||||
extern "C" {
|
||||
#include "atf-c/config.h"
|
||||
}
|
||||
|
||||
#include "config.hpp"
|
||||
|
||||
#include "detail/env.hpp"
|
||||
#include "detail/sanity.hpp"
|
||||
|
||||
static std::map< std::string, std::string > m_variables;
|
||||
|
||||
//
|
||||
// Adds all predefined standard build-time variables to the m_variables
|
||||
// map, considering the values a user may have provided in the environment.
|
||||
//
|
||||
// Can only be called once during the program's lifetime.
|
||||
//
|
||||
static
|
||||
void
|
||||
init_variables(void)
|
||||
{
|
||||
PRE(m_variables.empty());
|
||||
|
||||
m_variables["atf_build_cc"] = atf_config_get("atf_build_cc");
|
||||
m_variables["atf_build_cflags"] = atf_config_get("atf_build_cflags");
|
||||
m_variables["atf_build_cpp"] = atf_config_get("atf_build_cpp");
|
||||
m_variables["atf_build_cppflags"] = atf_config_get("atf_build_cppflags");
|
||||
m_variables["atf_build_cxx"] = atf_config_get("atf_build_cxx");
|
||||
m_variables["atf_build_cxxflags"] = atf_config_get("atf_build_cxxflags");
|
||||
m_variables["atf_includedir"] = atf_config_get("atf_includedir");
|
||||
m_variables["atf_libexecdir"] = atf_config_get("atf_libexecdir");
|
||||
m_variables["atf_pkgdatadir"] = atf_config_get("atf_pkgdatadir");
|
||||
m_variables["atf_shell"] = atf_config_get("atf_shell");
|
||||
m_variables["atf_workdir"] = atf_config_get("atf_workdir");
|
||||
|
||||
POST(!m_variables.empty());
|
||||
}
|
||||
|
||||
const std::string&
|
||||
atf::config::get(const std::string& varname)
|
||||
{
|
||||
if (m_variables.empty())
|
||||
init_variables();
|
||||
|
||||
PRE(has(varname));
|
||||
return m_variables[varname];
|
||||
}
|
||||
|
||||
const std::map< std::string, std::string >&
|
||||
atf::config::get_all(void)
|
||||
{
|
||||
if (m_variables.empty())
|
||||
init_variables();
|
||||
|
||||
return m_variables;
|
||||
}
|
||||
|
||||
bool
|
||||
atf::config::has(const std::string& varname)
|
||||
{
|
||||
if (m_variables.empty())
|
||||
init_variables();
|
||||
|
||||
return m_variables.find(varname) != m_variables.end();
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
void __atf_config_reinit(void);
|
||||
}
|
||||
|
||||
namespace atf {
|
||||
namespace config {
|
||||
//
|
||||
// Auxiliary function for the t_config test program so that it can
|
||||
// revert the configuration's global status to an empty state and
|
||||
// do new tests from there on.
|
||||
//
|
||||
// Ideally this shouldn't be part of the production library... but
|
||||
// this is so small that it does not matter.
|
||||
//
|
||||
void
|
||||
__reinit(void)
|
||||
{
|
||||
__atf_config_reinit();
|
||||
m_variables.clear();
|
||||
}
|
||||
} // namespace config
|
||||
} // namespace atf
|
|
@ -1,75 +0,0 @@
|
|||
//
|
||||
// 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
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 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(_ATF_CXX_CONFIG_HPP_)
|
||||
#define _ATF_CXX_CONFIG_HPP_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace atf {
|
||||
|
||||
namespace config {
|
||||
|
||||
//!
|
||||
//! \brief Gets a build-time configuration variable's value.
|
||||
//!
|
||||
//! Given the name of a build-time configuration variable, returns its
|
||||
//! textual value. The user is free to override these by setting their
|
||||
//! corresponding environment variables. Therefore always use this
|
||||
//! interface to get the value of these variables.
|
||||
//!
|
||||
//! \pre The variable must exist.
|
||||
//!
|
||||
const std::string& get(const std::string&);
|
||||
|
||||
//!
|
||||
//! \brief Returns all the build-time configuration variables.
|
||||
//!
|
||||
//! Returns a name to value map containing all build-time configuration
|
||||
//! variables.
|
||||
//!
|
||||
const std::map< std::string, std::string >& get_all(void);
|
||||
|
||||
//!
|
||||
//! \brief Checks whether a build-time configuration variable exists.
|
||||
//!
|
||||
//! Given the name of a build-time configuration variable, checks
|
||||
//! whether it is defined and returns a boolean indicating this
|
||||
//! condition. The program only has to use this function to sanity-check
|
||||
//! a variable name provided by the user. Otherwise it can assume that
|
||||
//! the variables are defined.
|
||||
//!
|
||||
bool has(const std::string&);
|
||||
|
||||
} // namespace config
|
||||
|
||||
} // namespace atf
|
||||
|
||||
#endif // !defined(_ATF_CXX_CONFIG_HPP_)
|
|
@ -1,227 +0,0 @@
|
|||
//
|
||||
// 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
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 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 <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "macros.hpp"
|
||||
|
||||
#include "detail/env.hpp"
|
||||
#include "detail/exceptions.hpp"
|
||||
#include "detail/test_helpers.hpp"
|
||||
|
||||
static const char *test_value = "env-value";
|
||||
|
||||
static struct varnames {
|
||||
const char *lc;
|
||||
const char *uc;
|
||||
bool can_be_empty;
|
||||
} all_vars[] = {
|
||||
{ "atf_build_cc", "ATF_BUILD_CC", false },
|
||||
{ "atf_build_cflags", "ATF_BUILD_CFLAGS", true },
|
||||
{ "atf_build_cpp", "ATF_BUILD_CPP", false },
|
||||
{ "atf_build_cppflags", "ATF_BUILD_CPPFLAGS", true },
|
||||
{ "atf_build_cxx", "ATF_BUILD_CXX", false },
|
||||
{ "atf_build_cxxflags", "ATF_BUILD_CXXFLAGS", true },
|
||||
{ "atf_includedir", "ATF_INCLUDEDIR", false },
|
||||
{ "atf_libexecdir", "ATF_LIBEXECDIR", false },
|
||||
{ "atf_pkgdatadir", "ATF_PKGDATADIR", false },
|
||||
{ "atf_shell", "ATF_SHELL", false },
|
||||
{ "atf_workdir", "ATF_WORKDIR", false },
|
||||
{ NULL, NULL, false }
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Auxiliary functions.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace atf {
|
||||
namespace config {
|
||||
void __reinit(void);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
set_env_var(const char* name, const char* val)
|
||||
{
|
||||
try {
|
||||
atf::env::set(name, val);
|
||||
} catch (const atf::system_error&) {
|
||||
ATF_FAIL(std::string("set_env_var(") + name + ", " + val +
|
||||
") failed");
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
unset_env_var(const char* name)
|
||||
{
|
||||
try {
|
||||
atf::env::unset(name);
|
||||
} catch (const atf::system_error&) {
|
||||
ATF_FAIL(std::string("unset_env_var(") + name + ") failed");
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
size_t
|
||||
all_vars_count(void)
|
||||
{
|
||||
size_t count = 0;
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++)
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
unset_all(void)
|
||||
{
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++)
|
||||
unset_env_var(v->uc);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
compare_one(const char* var, const char* expvalue)
|
||||
{
|
||||
std::cout << "Checking that " << var << " is set to " << expvalue << "\n";
|
||||
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++) {
|
||||
if (std::strcmp(v->lc, var) == 0)
|
||||
ATF_REQUIRE_EQ(atf::config::get(v->lc), test_value);
|
||||
else
|
||||
ATF_REQUIRE(atf::config::get(v->lc) != test_value);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Test cases for the free functions.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
ATF_TEST_CASE(get);
|
||||
ATF_TEST_CASE_HEAD(get)
|
||||
{
|
||||
set_md_var("descr", "Tests the config::get function");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(get)
|
||||
{
|
||||
// Unset all known environment variables and make sure the built-in
|
||||
// values do not match the bogus value we will use for testing.
|
||||
unset_all();
|
||||
atf::config::__reinit();
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++)
|
||||
ATF_REQUIRE(atf::config::get(v->lc) != test_value);
|
||||
|
||||
// Test the behavior of empty values.
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++) {
|
||||
unset_all();
|
||||
if (!atf::config::get(v->lc).empty()) {
|
||||
set_env_var(v->uc, "");
|
||||
atf::config::__reinit();
|
||||
if (v->can_be_empty)
|
||||
ATF_REQUIRE(atf::config::get(v->lc).empty());
|
||||
else
|
||||
ATF_REQUIRE(!atf::config::get(v->lc).empty());
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the ATF_ARCH variable is recognized.
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++) {
|
||||
unset_all();
|
||||
set_env_var(v->uc, test_value);
|
||||
atf::config::__reinit();
|
||||
compare_one(v->lc, test_value);
|
||||
}
|
||||
}
|
||||
|
||||
ATF_TEST_CASE(get_all);
|
||||
ATF_TEST_CASE_HEAD(get_all)
|
||||
{
|
||||
set_md_var("descr", "Tests the config::get_all function");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(get_all)
|
||||
{
|
||||
atf::config::__reinit();
|
||||
|
||||
// Check that the valid variables, and only those, are returned.
|
||||
std::map< std::string, std::string > vars = atf::config::get_all();
|
||||
ATF_REQUIRE_EQ(vars.size(), all_vars_count());
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++)
|
||||
ATF_REQUIRE(vars.find(v->lc) != vars.end());
|
||||
}
|
||||
|
||||
ATF_TEST_CASE(has);
|
||||
ATF_TEST_CASE_HEAD(has)
|
||||
{
|
||||
set_md_var("descr", "Tests the config::has function");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(has)
|
||||
{
|
||||
atf::config::__reinit();
|
||||
|
||||
// Check for all the variables that must exist.
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++)
|
||||
ATF_REQUIRE(atf::config::has(v->lc));
|
||||
|
||||
// Same as above, but using uppercase (which is incorrect).
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++)
|
||||
ATF_REQUIRE(!atf::config::has(v->uc));
|
||||
|
||||
// Check for some other variables that cannot exist.
|
||||
ATF_REQUIRE(!atf::config::has("foo"));
|
||||
ATF_REQUIRE(!atf::config::has("BAR"));
|
||||
ATF_REQUIRE(!atf::config::has("atf_foo"));
|
||||
ATF_REQUIRE(!atf::config::has("ATF_BAR"));
|
||||
ATF_REQUIRE(!atf::config::has("atf_shel"));
|
||||
ATF_REQUIRE(!atf::config::has("atf_shells"));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Tests cases for the header file.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
HEADER_TC(include, "atf-c++/config.hpp");
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Main.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
ATF_INIT_TEST_CASES(tcs)
|
||||
{
|
||||
// Add the test cases for the free functions.
|
||||
ATF_ADD_TEST_CASE(tcs, has);
|
||||
ATF_ADD_TEST_CASE(tcs, get);
|
||||
ATF_ADD_TEST_CASE(tcs, get_all);
|
||||
|
||||
// Add the test cases for the header file.
|
||||
ATF_ADD_TEST_CASE(tcs, include);
|
||||
}
|
|
@ -8,5 +8,4 @@ atf_test_program{name="env_test"}
|
|||
atf_test_program{name="exceptions_test"}
|
||||
atf_test_program{name="fs_test"}
|
||||
atf_test_program{name="process_test"}
|
||||
atf_test_program{name="sanity_test"}
|
||||
atf_test_program{name="text_test"}
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,10 +22,11 @@
|
|||
// 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 "atf-c++/detail/application.hpp"
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "bconfig.h"
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
|
@ -45,8 +43,7 @@ extern "C" {
|
|||
#include "atf-c/defs.h"
|
||||
}
|
||||
|
||||
#include "application.hpp"
|
||||
#include "sanity.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
|
||||
#if !defined(HAVE_VSNPRINTF_IN_STD)
|
||||
namespace std {
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,10 +22,9 @@
|
|||
// 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(_ATF_CXX_APPLICATION_HPP_)
|
||||
#define _ATF_CXX_APPLICATION_HPP_
|
||||
#if !defined(ATF_CXX_DETAIL_APPLICATION_HPP)
|
||||
#define ATF_CXX_DETAIL_APPLICATION_HPP
|
||||
|
||||
#include <ostream>
|
||||
#include <set>
|
||||
|
@ -108,4 +104,4 @@ class app {
|
|||
} // namespace application
|
||||
} // namespace atf
|
||||
|
||||
#endif // !defined(_ATF_CXX_APPLICATION_HPP_)
|
||||
#endif // !defined(ATF_CXX_DETAIL_APPLICATION_HPP)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,15 +22,14 @@
|
|||
// 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 "atf-c++/detail/application.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include <unistd.h>
|
||||
}
|
||||
|
||||
#include "application.hpp"
|
||||
|
||||
#include "../macros.hpp"
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
class getopt_app : public atf::application::app {
|
||||
public:
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,10 +22,9 @@
|
|||
// 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(_ATF_CXX_AUTO_ARRAY_HPP_)
|
||||
#define _ATF_CXX_AUTO_ARRAY_HPP_
|
||||
#if !defined(ATF_CXX_DETAIL_AUTO_ARRAY_HPP)
|
||||
#define ATF_CXX_DETAIL_AUTO_ARRAY_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
|
@ -176,4 +172,4 @@ auto_array< T >::operator auto_array_ref< T >(void)
|
|||
|
||||
} // namespace atf
|
||||
|
||||
#endif // !defined(_ATF_CXX_AUTO_ARRAY_HPP_)
|
||||
#endif // !defined(ATF_CXX_DETAIL_AUTO_ARRAY_HPP)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,7 +22,8 @@
|
|||
// 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 "atf-c++/detail/auto_array.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include <sys/types.h>
|
||||
|
@ -33,11 +31,11 @@ extern "C" {
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
extern "C" {
|
||||
#include "atf-c/defs.h"
|
||||
|
||||
#include "../macros.hpp"
|
||||
|
||||
#include "auto_array.hpp"
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Tests for the "auto_array" class.
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,17 +22,16 @@
|
|||
// 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 "atf-c++/detail/env.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "../../atf-c/error.h"
|
||||
|
||||
#include "../../atf-c/detail/env.h"
|
||||
#include "atf-c/detail/env.h"
|
||||
#include "atf-c/error.h"
|
||||
}
|
||||
|
||||
#include "env.hpp"
|
||||
#include "exceptions.hpp"
|
||||
#include "sanity.hpp"
|
||||
#include "atf-c++/detail/exceptions.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
|
||||
namespace impl = atf::env;
|
||||
#define IMPL_NAME "atf::env"
|
||||
|
@ -50,6 +46,12 @@ impl::get(const std::string& name)
|
|||
return atf_env_get(name.c_str());
|
||||
}
|
||||
|
||||
std::string
|
||||
impl::get(const std::string& name, const std::string& default_value)
|
||||
{
|
||||
return atf_env_get_with_default(name.c_str(), default_value.c_str());
|
||||
}
|
||||
|
||||
bool
|
||||
impl::has(const std::string& name)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,10 +22,9 @@
|
|||
// 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(_ATF_CXX_ENV_HPP_)
|
||||
#define _ATF_CXX_ENV_HPP_
|
||||
#if !defined(ATF_CXX_DETAIL_ENV_HPP)
|
||||
#define ATF_CXX_DETAIL_ENV_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
|
@ -47,6 +43,11 @@ namespace env {
|
|||
//!
|
||||
std::string get(const std::string&);
|
||||
|
||||
//!
|
||||
//! \brief Returns the value of an environment variable with a default.
|
||||
//!
|
||||
std::string get(const std::string&, const std::string&);
|
||||
|
||||
//!
|
||||
//! \brief Checks if the environment has a variable.
|
||||
//!
|
||||
|
@ -81,4 +82,4 @@ void unset(const std::string&);
|
|||
} // namespace env
|
||||
} // namespace atf
|
||||
|
||||
#endif // !defined(_ATF_CXX_ENV_HPP_)
|
||||
#endif // !defined(ATF_CXX_DETAIL_ENV_HPP)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,11 +22,10 @@
|
|||
// 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 "../macros.hpp"
|
||||
#include "atf-c++/detail/env.hpp"
|
||||
|
||||
#include "env.hpp"
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Test cases for the free functions.
|
||||
|
@ -48,6 +44,19 @@ ATF_TEST_CASE_BODY(has_get)
|
|||
ATF_REQUIRE(!atf::env::has("_UNDEFINED_VARIABLE_"));
|
||||
}
|
||||
|
||||
ATF_TEST_CASE(get_with_default);
|
||||
ATF_TEST_CASE_HEAD(get_with_default)
|
||||
{
|
||||
set_md_var("descr", "Tests the get function with a default value");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(get_with_default)
|
||||
{
|
||||
ATF_REQUIRE(atf::env::has("PATH"));
|
||||
ATF_REQUIRE(atf::env::get("PATH", "default value") != "default value");
|
||||
|
||||
ATF_REQUIRE_EQ(atf::env::get("_UNDEFINED_VARIABLE_", "foo bar"), "foo bar");
|
||||
}
|
||||
|
||||
ATF_TEST_CASE(set);
|
||||
ATF_TEST_CASE_HEAD(set)
|
||||
{
|
||||
|
@ -86,6 +95,7 @@ ATF_INIT_TEST_CASES(tcs)
|
|||
{
|
||||
// Add the test cases for the free functions.
|
||||
ATF_ADD_TEST_CASE(tcs, has_get);
|
||||
ATF_ADD_TEST_CASE(tcs, get_with_default);
|
||||
ATF_ADD_TEST_CASE(tcs, set);
|
||||
ATF_ADD_TEST_CASE(tcs, unset);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,10 +22,11 @@
|
|||
// 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 "atf-c++/detail/exceptions.hpp"
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "bconfig.h"
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <cstdarg>
|
||||
|
@ -37,11 +35,10 @@
|
|||
#include <new>
|
||||
|
||||
extern "C" {
|
||||
#include "../../atf-c/error.h"
|
||||
};
|
||||
#include "atf-c/error.h"
|
||||
}
|
||||
|
||||
#include "exceptions.hpp"
|
||||
#include "sanity.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// The "system_error" type.
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,10 +22,9 @@
|
|||
// 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(_ATF_CXX_EXCEPTIONS_HPP_)
|
||||
#define _ATF_CXX_EXCEPTIONS_HPP_
|
||||
#if !defined(ATF_CXX_DETAIL_EXCEPTIONS_HPP)
|
||||
#define ATF_CXX_DETAIL_EXCEPTIONS_HPP
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
@ -55,4 +51,4 @@ void throw_atf_error(struct atf_error *);
|
|||
|
||||
} // namespace atf
|
||||
|
||||
#endif // !defined(_ATF_CXX_EXCEPTIONS_HPP_)
|
||||
#endif // !defined(ATF_CXX_DETAIL_EXCEPTIONS_HPP)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,19 +22,19 @@
|
|||
// 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 "atf-c++/detail/exceptions.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "../../atf-c/error.h"
|
||||
#include "atf-c/error.h"
|
||||
}
|
||||
|
||||
#include <cstdio>
|
||||
#include <new>
|
||||
|
||||
#include "../macros.hpp"
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
#include "exceptions.hpp"
|
||||
#include "sanity.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// The "test" error.
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,10 +22,11 @@
|
|||
// 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 "atf-c++/detail/fs.hpp"
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "bconfig.h"
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
|
@ -47,17 +45,15 @@ extern "C" {
|
|||
#include <cstring>
|
||||
|
||||
extern "C" {
|
||||
#include "../../atf-c/error.h"
|
||||
#include "atf-c/error.h"
|
||||
}
|
||||
|
||||
#include "../utils.hpp"
|
||||
|
||||
#include "exceptions.hpp"
|
||||
#include "env.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "process.hpp"
|
||||
#include "sanity.hpp"
|
||||
#include "text.hpp"
|
||||
#include "atf-c++/detail/env.hpp"
|
||||
#include "atf-c++/detail/exceptions.hpp"
|
||||
#include "atf-c++/detail/process.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
#include "atf-c++/detail/text.hpp"
|
||||
#include "atf-c++/utils.hpp"
|
||||
|
||||
namespace impl = atf::fs;
|
||||
#define IMPL_NAME "atf::fs"
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,10 +22,9 @@
|
|||
// 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(_ATF_CXX_FS_HPP_)
|
||||
#define _ATF_CXX_FS_HPP_
|
||||
#if !defined(ATF_CXX_DETAIL_FS_HPP)
|
||||
#define ATF_CXX_DETAIL_FS_HPP
|
||||
|
||||
extern "C" {
|
||||
#include <sys/types.h>
|
||||
|
@ -42,7 +38,7 @@ extern "C" {
|
|||
#include <string>
|
||||
|
||||
extern "C" {
|
||||
#include "../../atf-c/detail/fs.h"
|
||||
#include "atf-c/detail/fs.h"
|
||||
}
|
||||
|
||||
namespace atf {
|
||||
|
@ -388,4 +384,4 @@ void rmdir(const path&);
|
|||
} // namespace fs
|
||||
} // namespace atf
|
||||
|
||||
#endif // !defined(_ATF_CXX_FS_HPP_)
|
||||
#endif // !defined(ATF_CXX_DETAIL_FS_HPP)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,7 +22,8 @@
|
|||
// 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 "atf-c++/detail/fs.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include <sys/types.h>
|
||||
|
@ -36,10 +34,9 @@ extern "C" {
|
|||
#include <cerrno>
|
||||
#include <cstdio>
|
||||
|
||||
#include "../macros.hpp"
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
#include "exceptions.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "atf-c++/detail/exceptions.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Auxiliary functions.
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,21 +22,20 @@
|
|||
// 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 "atf-c++/detail/process.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include <signal.h>
|
||||
|
||||
#include "../../atf-c/error.h"
|
||||
|
||||
#include "../../atf-c/detail/process.h"
|
||||
#include "atf-c/detail/process.h"
|
||||
#include "atf-c/error.h"
|
||||
}
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "exceptions.hpp"
|
||||
#include "process.hpp"
|
||||
#include "sanity.hpp"
|
||||
#include "atf-c++/detail/exceptions.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
|
||||
namespace detail = atf::process::detail;
|
||||
namespace impl = atf::process;
|
||||
|
@ -341,11 +337,6 @@ impl::child::stderr_fd(void)
|
|||
void
|
||||
detail::flush_streams(void)
|
||||
{
|
||||
// This is a weird hack to ensure that the output of the parent process
|
||||
// is flushed before executing a child which prevents, for example, the
|
||||
// output of the atf-run hooks to appear before the output of atf-run
|
||||
// itself.
|
||||
//
|
||||
// TODO: This should only be executed when inheriting the stdout or
|
||||
// stderr file descriptors. However, the flushing is specific to the
|
||||
// iostreams, so we cannot do it from the C library where all the process
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,25 +22,23 @@
|
|||
// 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(_ATF_CXX_PROCESS_HPP_)
|
||||
#define _ATF_CXX_PROCESS_HPP_
|
||||
#if !defined(ATF_CXX_DETAIL_PROCESS_HPP)
|
||||
#define ATF_CXX_DETAIL_PROCESS_HPP
|
||||
|
||||
extern "C" {
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "../../atf-c/error.h"
|
||||
|
||||
#include "../../atf-c/detail/process.h"
|
||||
#include <atf-c/detail/process.h>
|
||||
#include <atf-c/error.h>
|
||||
}
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "auto_array.hpp"
|
||||
#include "exceptions.hpp"
|
||||
#include "fs.hpp"
|
||||
#include <atf-c++/detail/auto_array.hpp>
|
||||
#include <atf-c++/detail/exceptions.hpp>
|
||||
#include <atf-c++/detail/fs.hpp>
|
||||
|
||||
namespace atf {
|
||||
namespace process {
|
||||
|
@ -276,4 +271,4 @@ exec(const atf::fs::path& prog, const argv_array& argv,
|
|||
} // namespace process
|
||||
} // namespace atf
|
||||
|
||||
#endif // !defined(_ATF_CXX_PROCESS_HPP_)
|
||||
#endif // !defined(ATF_CXX_DETAIL_PROCESS_HPP)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,15 +22,15 @@
|
|||
// 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 "atf-c++/detail/process.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "../macros.hpp"
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
#include "process.hpp"
|
||||
#include "test_helpers.hpp"
|
||||
#include "atf-c++/detail/test_helpers.hpp"
|
||||
|
||||
// TODO: Testing the fork function is a huge task and I'm afraid of
|
||||
// copy/pasting tons of stuff from the C version. I'd rather not do that
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,13 +22,12 @@
|
|||
// 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(_ATF_CXX_SANITY_HPP_)
|
||||
#define _ATF_CXX_SANITY_HPP_
|
||||
#if !defined(ATF_CXX_DETAIL_SANITY_HPP)
|
||||
#define ATF_CXX_DETAIL_SANITY_HPP
|
||||
|
||||
extern "C" {
|
||||
#include "../../atf-c/detail/sanity.h"
|
||||
#include <atf-c/detail/sanity.h>
|
||||
}
|
||||
|
||||
#endif // !defined(_ATF_CXX_SANITY_HPP_)
|
||||
#endif // !defined(ATF_CXX_DETAIL_SANITY_HPP)
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2009 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
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 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 "../macros.hpp"
|
||||
|
||||
ATF_TEST_CASE_WITHOUT_HEAD(nothing);
|
||||
ATF_TEST_CASE_BODY(nothing)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
ATF_INIT_TEST_CASES(tcs)
|
||||
{
|
||||
ATF_ADD_TEST_CASE(tcs, nothing);
|
||||
}
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,20 +22,20 @@
|
|||
// 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 "atf-c++/detail/test_helpers.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "../check.hpp"
|
||||
#include "../config.hpp"
|
||||
#include "../macros.hpp"
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
#include "fs.hpp"
|
||||
#include "process.hpp"
|
||||
#include "test_helpers.hpp"
|
||||
#include "atf-c++/check.hpp"
|
||||
#include "atf-c++/detail/env.hpp"
|
||||
#include "atf-c++/detail/fs.hpp"
|
||||
#include "atf-c++/detail/process.hpp"
|
||||
|
||||
// Path to the directory containing the libatf-c tests, used to locate the
|
||||
// process_helpers program. If NULL (the default), the code will use a
|
||||
|
@ -56,7 +53,7 @@ bool
|
|||
build_check_cxx_o(const char* sfile)
|
||||
{
|
||||
std::vector< std::string > optargs;
|
||||
optargs.push_back("-I" + atf::config::get("atf_includedir"));
|
||||
optargs.push_back("-I" + atf::env::get("ATF_INCLUDEDIR", ATF_INCLUDEDIR));
|
||||
optargs.push_back("-Wall");
|
||||
optargs.push_back("-Werror");
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,12 +22,11 @@
|
|||
// 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(TESTS_ATF_ATF_CXX_TEST_HELPERS_H)
|
||||
#if defined(ATF_CXX_DETAIL_TEST_HELPERS_H)
|
||||
# error "Cannot include test_helpers.hpp more than once."
|
||||
#else
|
||||
# define TESTS_ATF_ATF_CXX_TEST_HELPERS_H
|
||||
# define ATF_CXX_DETAIL_TEST_HELPERS_H
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
|
@ -38,9 +34,9 @@
|
|||
#include <sstream>
|
||||
#include <utility>
|
||||
|
||||
#include "../macros.hpp"
|
||||
#include "../tests.hpp"
|
||||
#include "process.hpp"
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
#include <atf-c++/detail/process.hpp>
|
||||
|
||||
#define HEADER_TC(name, hdrname) \
|
||||
ATF_TEST_CASE(name); \
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,7 +22,8 @@
|
|||
// 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 "atf-c++/detail/text.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include <regex.h>
|
||||
|
@ -35,13 +33,11 @@ extern "C" {
|
|||
#include <cstring>
|
||||
|
||||
extern "C" {
|
||||
#include "../../atf-c/error.h"
|
||||
|
||||
#include "../../atf-c/detail/text.h"
|
||||
#include "atf-c/detail/text.h"
|
||||
#include "atf-c/error.h"
|
||||
}
|
||||
|
||||
#include "exceptions.hpp"
|
||||
#include "text.hpp"
|
||||
#include "atf-c++/detail/exceptions.hpp"
|
||||
|
||||
namespace impl = atf::text;
|
||||
#define IMPL_NAME "atf::text"
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,10 +22,9 @@
|
|||
// 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(_ATF_CXX_TEXT_HPP_)
|
||||
#define _ATF_CXX_TEXT_HPP_
|
||||
#if !defined(ATF_CXX_DETAIL_TEXT_HPP)
|
||||
#define ATF_CXX_DETAIL_TEXT_HPP
|
||||
|
||||
extern "C" {
|
||||
#include <stdint.h>
|
||||
|
@ -150,4 +146,4 @@ to_type(const std::string& str)
|
|||
} // namespace text
|
||||
} // namespace atf
|
||||
|
||||
#endif // !defined(_ATF_CXX_TEXT_HPP_)
|
||||
#endif // !defined(ATF_CXX_DETAIL_TEXT_HPP)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,15 +22,14 @@
|
|||
// 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 "atf-c++/detail/text.hpp"
|
||||
|
||||
#include <cstring>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include "../macros.hpp"
|
||||
|
||||
#include "text.hpp"
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Test cases for the free functions.
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "bconfig.h"
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,10 +22,9 @@
|
|||
// 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(_ATF_CXX_MACROS_HPP_)
|
||||
#define _ATF_CXX_MACROS_HPP_
|
||||
#if !defined(ATF_CXX_MACROS_HPP)
|
||||
#define ATF_CXX_MACROS_HPP
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
@ -99,21 +95,23 @@
|
|||
|
||||
#define ATF_PASS() atf::tests::tc::pass()
|
||||
|
||||
#define ATF_REQUIRE(x) \
|
||||
#define ATF_REQUIRE(expression) \
|
||||
do { \
|
||||
if (!(x)) { \
|
||||
if (!(expression)) { \
|
||||
std::ostringstream atfu_ss; \
|
||||
atfu_ss << "Line " << __LINE__ << ": " << #x << " not met"; \
|
||||
atfu_ss << "Line " << __LINE__ << ": " << #expression \
|
||||
<< " not met"; \
|
||||
atf::tests::tc::fail(atfu_ss.str()); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define ATF_REQUIRE_EQ(x, y) \
|
||||
#define ATF_REQUIRE_EQ(expected, actual) \
|
||||
do { \
|
||||
if ((x) != (y)) { \
|
||||
if ((expected) != (actual)) { \
|
||||
std::ostringstream atfu_ss; \
|
||||
atfu_ss << "Line " << __LINE__ << ": " << #x << " != " << #y \
|
||||
<< " (" << (x) << " != " << (y) << ")"; \
|
||||
atfu_ss << "Line " << __LINE__ << ": " \
|
||||
<< #expected << " != " << #actual \
|
||||
<< " (" << (expected) << " != " << (actual) << ")"; \
|
||||
atf::tests::tc::fail(atfu_ss.str()); \
|
||||
} \
|
||||
} while (false)
|
||||
|
@ -134,69 +132,74 @@
|
|||
} \
|
||||
} while (false)
|
||||
|
||||
#define ATF_REQUIRE_THROW(e, x) \
|
||||
#define ATF_REQUIRE_THROW(expected_exception, statement) \
|
||||
do { \
|
||||
try { \
|
||||
x; \
|
||||
statement; \
|
||||
std::ostringstream atfu_ss; \
|
||||
atfu_ss << "Line " << __LINE__ << ": " #x " did not throw " \
|
||||
#e " as expected"; \
|
||||
atfu_ss << "Line " << __LINE__ \
|
||||
<< ": " #statement " did not throw " #expected_exception \
|
||||
" as expected"; \
|
||||
atf::tests::tc::fail(atfu_ss.str()); \
|
||||
} catch (const e&) { \
|
||||
} catch (const expected_exception&) { \
|
||||
} catch (const std::exception& atfu_e) { \
|
||||
std::ostringstream atfu_ss; \
|
||||
atfu_ss << "Line " << __LINE__ << ": " #x " threw an " \
|
||||
"unexpected error (not " #e "): " << atfu_e.what(); \
|
||||
atfu_ss << "Line " << __LINE__ << ": " #statement " threw an " \
|
||||
"unexpected error (not " #expected_exception "): " \
|
||||
<< atfu_e.what(); \
|
||||
atf::tests::tc::fail(atfu_ss.str()); \
|
||||
} catch (...) { \
|
||||
std::ostringstream atfu_ss; \
|
||||
atfu_ss << "Line " << __LINE__ << ": " #x " threw an " \
|
||||
"unexpected error (not " #e ")"; \
|
||||
atfu_ss << "Line " << __LINE__ << ": " #statement " threw an " \
|
||||
"unexpected error (not " #expected_exception ")"; \
|
||||
atf::tests::tc::fail(atfu_ss.str()); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define ATF_REQUIRE_THROW_RE(type, regexp, x) \
|
||||
#define ATF_REQUIRE_THROW_RE(expected_exception, regexp, statement) \
|
||||
do { \
|
||||
try { \
|
||||
x; \
|
||||
statement; \
|
||||
std::ostringstream atfu_ss; \
|
||||
atfu_ss << "Line " << __LINE__ << ": " #x " did not throw " \
|
||||
#type " as expected"; \
|
||||
atfu_ss << "Line " << __LINE__ \
|
||||
<< ": " #statement " did not throw " #expected_exception \
|
||||
" as expected"; \
|
||||
atf::tests::tc::fail(atfu_ss.str()); \
|
||||
} catch (const type& e) { \
|
||||
} catch (const expected_exception& e) { \
|
||||
if (!atf::tests::detail::match(regexp, e.what())) { \
|
||||
std::ostringstream atfu_ss; \
|
||||
atfu_ss << "Line " << __LINE__ << ": " #x " threw " #type "(" \
|
||||
atfu_ss << "Line " << __LINE__ \
|
||||
<< ": " #statement " threw " #expected_exception "(" \
|
||||
<< e.what() << "), but does not match '" << regexp \
|
||||
<< "'"; \
|
||||
atf::tests::tc::fail(atfu_ss.str()); \
|
||||
} \
|
||||
} catch (const std::exception& atfu_e) { \
|
||||
std::ostringstream atfu_ss; \
|
||||
atfu_ss << "Line " << __LINE__ << ": " #x " threw an " \
|
||||
"unexpected error (not " #type "): " << atfu_e.what(); \
|
||||
atfu_ss << "Line " << __LINE__ << ": " #statement " threw an " \
|
||||
"unexpected error (not " #expected_exception "): " \
|
||||
<< atfu_e.what(); \
|
||||
atf::tests::tc::fail(atfu_ss.str()); \
|
||||
} catch (...) { \
|
||||
std::ostringstream atfu_ss; \
|
||||
atfu_ss << "Line " << __LINE__ << ": " #x " threw an " \
|
||||
"unexpected error (not " #type ")"; \
|
||||
atfu_ss << "Line " << __LINE__ << ": " #statement " threw an " \
|
||||
"unexpected error (not " #expected_exception ")"; \
|
||||
atf::tests::tc::fail(atfu_ss.str()); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define ATF_CHECK_ERRNO(exp_errno, bool_expr) \
|
||||
atf::tests::tc::check_errno(__FILE__, __LINE__, exp_errno, #bool_expr, \
|
||||
bool_expr)
|
||||
#define ATF_CHECK_ERRNO(expected_errno, bool_expr) \
|
||||
atf::tests::tc::check_errno(__FILE__, __LINE__, expected_errno, \
|
||||
#bool_expr, bool_expr)
|
||||
|
||||
#define ATF_REQUIRE_ERRNO(exp_errno, bool_expr) \
|
||||
atf::tests::tc::require_errno(__FILE__, __LINE__, exp_errno, #bool_expr, \
|
||||
bool_expr)
|
||||
#define ATF_REQUIRE_ERRNO(expected_errno, bool_expr) \
|
||||
atf::tests::tc::require_errno(__FILE__, __LINE__, expected_errno, \
|
||||
#bool_expr, bool_expr)
|
||||
|
||||
#define ATF_INIT_TEST_CASES(tcs) \
|
||||
namespace atf { \
|
||||
namespace tests { \
|
||||
int run_tp(int, char* const*, \
|
||||
int run_tp(int, char**, \
|
||||
void (*)(std::vector< atf::tests::tc * >&)); \
|
||||
} \
|
||||
} \
|
||||
|
@ -204,7 +207,7 @@
|
|||
static void atfu_init_tcs(std::vector< atf::tests::tc * >&); \
|
||||
\
|
||||
int \
|
||||
main(int argc, char* const* argv) \
|
||||
main(int argc, char** argv) \
|
||||
{ \
|
||||
return atf::tests::run_tp(argc, argv, atfu_init_tcs); \
|
||||
} \
|
||||
|
@ -219,4 +222,4 @@
|
|||
(tcs).push_back(atfu_tcptr_ ## tcname); \
|
||||
} while (0);
|
||||
|
||||
#endif // !defined(_ATF_CXX_MACROS_HPP_)
|
||||
#endif // !defined(ATF_CXX_MACROS_HPP)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,12 +22,11 @@
|
|||
// 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 <stdexcept>
|
||||
|
||||
#include <atf-c++/macros.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
void
|
||||
atf_check_errno_semicolons(void)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,7 +22,8 @@
|
|||
// 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 "atf-c++/macros.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include <fcntl.h>
|
||||
|
@ -37,14 +35,14 @@ extern "C" {
|
|||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "macros.hpp"
|
||||
#include "utils.hpp"
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
#include "detail/fs.hpp"
|
||||
#include "detail/process.hpp"
|
||||
#include "detail/sanity.hpp"
|
||||
#include "detail/test_helpers.hpp"
|
||||
#include "detail/text.hpp"
|
||||
#include "atf-c++/detail/fs.hpp"
|
||||
#include "atf-c++/detail/process.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
#include "atf-c++/detail/test_helpers.hpp"
|
||||
#include "atf-c++/detail/text.hpp"
|
||||
#include "atf-c++/utils.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Auxiliary functions.
|
||||
|
@ -757,7 +755,6 @@ ATF_TEST_CASE_BODY(require_errno)
|
|||
// Tests cases for the header file.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
HEADER_TC(include, "atf-c++/macros.hpp");
|
||||
BUILD_TC(use, "macros_hpp_test.cpp",
|
||||
"Tests that the macros provided by the atf-c++/macros.hpp file "
|
||||
"do not cause syntax errors when used",
|
||||
|
@ -809,7 +806,6 @@ ATF_INIT_TEST_CASES(tcs)
|
|||
ATF_ADD_TEST_CASE(tcs, require_errno);
|
||||
|
||||
// Add the test cases for the header file.
|
||||
ATF_ADD_TEST_CASE(tcs, include);
|
||||
ATF_ADD_TEST_CASE(tcs, use);
|
||||
ATF_ADD_TEST_CASE(tcs, detect_unused_tests);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
|
@ -25,7 +22,6 @@
|
|||
# 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.
|
||||
#
|
||||
|
||||
# The following tests assume that the atfc++.pc file is installed in a
|
||||
# directory that is known by pkg-config. Otherwise they will fail,
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,7 +22,12 @@
|
|||
// 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 "atf-c++/tests.hpp"
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include <sys/types.h>
|
||||
|
@ -55,20 +57,26 @@ extern "C" {
|
|||
#include "atf-c/utils.h"
|
||||
}
|
||||
|
||||
#include "tests.hpp"
|
||||
#include "atf-c++/detail/application.hpp"
|
||||
#include "atf-c++/detail/auto_array.hpp"
|
||||
#include "atf-c++/detail/env.hpp"
|
||||
#include "atf-c++/detail/exceptions.hpp"
|
||||
#include "atf-c++/detail/fs.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
#include "atf-c++/detail/text.hpp"
|
||||
|
||||
#include "detail/application.hpp"
|
||||
#include "detail/auto_array.hpp"
|
||||
#include "detail/env.hpp"
|
||||
#include "detail/exceptions.hpp"
|
||||
#include "detail/fs.hpp"
|
||||
#include "detail/sanity.hpp"
|
||||
#include "detail/text.hpp"
|
||||
#if defined(HAVE_GNU_GETOPT)
|
||||
# define GETOPT_POSIX "+"
|
||||
#else
|
||||
# define GETOPT_POSIX ""
|
||||
#endif
|
||||
|
||||
namespace impl = atf::tests;
|
||||
namespace detail = atf::tests::detail;
|
||||
#define IMPL_NAME "atf::tests"
|
||||
|
||||
using atf::application::usage_error;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// The "atf_tp_writer" class.
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -109,6 +117,21 @@ detail::atf_tp_writer::tc_meta_data(const std::string& name,
|
|||
// Free helper functions.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
std::string Program_Name;
|
||||
|
||||
static void
|
||||
set_program_name(const char* argv0)
|
||||
{
|
||||
const std::string program_name = atf::fs::path(argv0).leaf_name();
|
||||
// Libtool workaround: if running from within the source tree (binaries
|
||||
// that are not installed yet), skip the "lt-" prefix added to files in
|
||||
// the ".libs" directory to show the real (not temporary) name.
|
||||
if (program_name.substr(0, 3) == "lt-")
|
||||
Program_Name = program_name.substr(3);
|
||||
else
|
||||
Program_Name = program_name;
|
||||
}
|
||||
|
||||
bool
|
||||
detail::match(const std::string& regexp, const std::string& str)
|
||||
{
|
||||
|
@ -153,14 +176,7 @@ struct impl::tc_impl {
|
|||
std::map< const atf_tc_t*, const impl::tc* >::const_iterator iter =
|
||||
cwraps.find(tc);
|
||||
INV(iter != cwraps.end());
|
||||
try {
|
||||
(*iter).second->body();
|
||||
} catch (const std::exception& e) {
|
||||
(*iter).second->fail("Caught unhandled exception: " + std::string(
|
||||
e.what()));
|
||||
} catch (...) {
|
||||
(*iter).second->fail("Caught unknown exception");
|
||||
}
|
||||
(*iter).second->body();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -384,197 +400,70 @@ impl::tc::expect_timeout(const std::string& reason)
|
|||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// The "tp" class.
|
||||
// Test program main code.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
class tp : public atf::application::app {
|
||||
public:
|
||||
typedef std::vector< impl::tc * > tc_vector;
|
||||
namespace {
|
||||
|
||||
private:
|
||||
static const char* m_description;
|
||||
typedef std::vector< impl::tc * > tc_vector;
|
||||
|
||||
bool m_lflag;
|
||||
atf::fs::path m_resfile;
|
||||
std::string m_srcdir_arg;
|
||||
atf::fs::path m_srcdir;
|
||||
enum tc_part { BODY, CLEANUP };
|
||||
|
||||
atf::tests::vars_map m_vars;
|
||||
|
||||
std::string specific_args(void) const;
|
||||
options_set specific_options(void) const;
|
||||
void process_option(int, const char*);
|
||||
|
||||
void (*m_add_tcs)(tc_vector&);
|
||||
tc_vector m_tcs;
|
||||
|
||||
void parse_vflag(const std::string&);
|
||||
void handle_srcdir(void);
|
||||
|
||||
tc_vector init_tcs(void);
|
||||
|
||||
enum tc_part {
|
||||
BODY,
|
||||
CLEANUP,
|
||||
};
|
||||
|
||||
void list_tcs(void);
|
||||
impl::tc* find_tc(tc_vector, const std::string&);
|
||||
static std::pair< std::string, tc_part > process_tcarg(const std::string&);
|
||||
int run_tc(const std::string&);
|
||||
|
||||
public:
|
||||
tp(void (*)(tc_vector&));
|
||||
~tp(void);
|
||||
|
||||
int main(void);
|
||||
};
|
||||
|
||||
const char* tp::m_description =
|
||||
"This is an independent atf test program.";
|
||||
|
||||
tp::tp(void (*add_tcs)(tc_vector&)) :
|
||||
app(m_description, "atf-test-program(1)"),
|
||||
m_lflag(false),
|
||||
m_resfile("/dev/stdout"),
|
||||
m_srcdir("."),
|
||||
m_add_tcs(add_tcs)
|
||||
{
|
||||
}
|
||||
|
||||
tp::~tp(void)
|
||||
{
|
||||
for (tc_vector::iterator iter = m_tcs.begin();
|
||||
iter != m_tcs.end(); iter++) {
|
||||
impl::tc* tc = *iter;
|
||||
|
||||
delete tc;
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
tp::specific_args(void)
|
||||
const
|
||||
{
|
||||
return "test_case";
|
||||
}
|
||||
|
||||
tp::options_set
|
||||
tp::specific_options(void)
|
||||
const
|
||||
{
|
||||
using atf::application::option;
|
||||
options_set opts;
|
||||
opts.insert(option('l', "", "List test cases and their purpose"));
|
||||
opts.insert(option('r', "resfile", "The file to which the test program "
|
||||
"will write the results of the "
|
||||
"executed test case"));
|
||||
opts.insert(option('s', "srcdir", "Directory where the test's data "
|
||||
"files are located"));
|
||||
opts.insert(option('v', "var=value", "Sets the configuration variable "
|
||||
"`var' to `value'"));
|
||||
return opts;
|
||||
}
|
||||
|
||||
void
|
||||
tp::process_option(int ch, const char* arg)
|
||||
{
|
||||
switch (ch) {
|
||||
case 'l':
|
||||
m_lflag = true;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
m_resfile = atf::fs::path(arg);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
m_srcdir_arg = arg;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
parse_vflag(arg);
|
||||
break;
|
||||
|
||||
default:
|
||||
UNREACHABLE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tp::parse_vflag(const std::string& str)
|
||||
static void
|
||||
parse_vflag(const std::string& str, atf::tests::vars_map& vars)
|
||||
{
|
||||
if (str.empty())
|
||||
throw std::runtime_error("-v requires a non-empty argument");
|
||||
|
||||
std::vector< std::string > ws = atf::text::split(str, "=");
|
||||
if (ws.size() == 1 && str[str.length() - 1] == '=') {
|
||||
m_vars[ws[0]] = "";
|
||||
vars[ws[0]] = "";
|
||||
} else {
|
||||
if (ws.size() != 2)
|
||||
throw std::runtime_error("-v requires an argument of the form "
|
||||
"var=value");
|
||||
|
||||
m_vars[ws[0]] = ws[1];
|
||||
vars[ws[0]] = ws[1];
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
tp::handle_srcdir(void)
|
||||
static atf::fs::path
|
||||
handle_srcdir(const char* argv0, const std::string& srcdir_arg)
|
||||
{
|
||||
if (m_srcdir_arg.empty()) {
|
||||
m_srcdir = atf::fs::path(m_argv0).branch_path();
|
||||
if (m_srcdir.leaf_name() == ".libs")
|
||||
m_srcdir = m_srcdir.branch_path();
|
||||
atf::fs::path srcdir(".");
|
||||
|
||||
if (srcdir_arg.empty()) {
|
||||
srcdir = atf::fs::path(argv0).branch_path();
|
||||
if (srcdir.leaf_name() == ".libs")
|
||||
srcdir = srcdir.branch_path();
|
||||
} else
|
||||
m_srcdir = atf::fs::path(m_srcdir_arg);
|
||||
srcdir = atf::fs::path(srcdir_arg);
|
||||
|
||||
if (!atf::fs::exists(m_srcdir / m_prog_name))
|
||||
throw std::runtime_error("Cannot find the test program in the "
|
||||
"source directory `" + m_srcdir.str() + "'");
|
||||
if (!atf::fs::exists(srcdir / Program_Name))
|
||||
throw usage_error("Cannot find the test program in the source "
|
||||
"directory `%s'", srcdir.c_str());
|
||||
|
||||
if (!m_srcdir.is_absolute())
|
||||
m_srcdir = m_srcdir.to_absolute();
|
||||
if (!srcdir.is_absolute())
|
||||
srcdir = srcdir.to_absolute();
|
||||
|
||||
m_vars["srcdir"] = m_srcdir.str();
|
||||
return srcdir;
|
||||
}
|
||||
|
||||
tp::tc_vector
|
||||
tp::init_tcs(void)
|
||||
static void
|
||||
init_tcs(void (*add_tcs)(tc_vector&), tc_vector& tcs,
|
||||
const atf::tests::vars_map& vars)
|
||||
{
|
||||
m_add_tcs(m_tcs);
|
||||
for (tc_vector::iterator iter = m_tcs.begin();
|
||||
iter != m_tcs.end(); iter++) {
|
||||
add_tcs(tcs);
|
||||
for (tc_vector::iterator iter = tcs.begin(); iter != tcs.end(); iter++) {
|
||||
impl::tc* tc = *iter;
|
||||
|
||||
tc->init(m_vars);
|
||||
tc->init(vars);
|
||||
}
|
||||
return m_tcs;
|
||||
}
|
||||
|
||||
//
|
||||
// An auxiliary unary predicate that compares the given test case's
|
||||
// identifier to the identifier stored in it.
|
||||
//
|
||||
class tc_equal_to_ident {
|
||||
const std::string& m_ident;
|
||||
|
||||
public:
|
||||
tc_equal_to_ident(const std::string& i) :
|
||||
m_ident(i)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator()(const impl::tc* tc)
|
||||
{
|
||||
return tc->get_md_var("ident") == m_ident;
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
tp::list_tcs(void)
|
||||
static int
|
||||
list_tcs(const tc_vector& tcs)
|
||||
{
|
||||
tc_vector tcs = init_tcs();
|
||||
detail::atf_tp_writer writer(std::cout);
|
||||
|
||||
for (tc_vector::const_iterator iter = tcs.begin();
|
||||
|
@ -596,10 +485,12 @@ tp::list_tcs(void)
|
|||
|
||||
writer.end_tc();
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
impl::tc*
|
||||
tp::find_tc(tc_vector tcs, const std::string& name)
|
||||
static impl::tc*
|
||||
find_tc(tc_vector tcs, const std::string& name)
|
||||
{
|
||||
std::vector< std::string > ids;
|
||||
for (tc_vector::iterator iter = tcs.begin();
|
||||
|
@ -609,12 +500,11 @@ tp::find_tc(tc_vector tcs, const std::string& name)
|
|||
if (tc->get_md_var("ident") == name)
|
||||
return tc;
|
||||
}
|
||||
throw atf::application::usage_error("Unknown test case `%s'",
|
||||
name.c_str());
|
||||
throw usage_error("Unknown test case `%s'", name.c_str());
|
||||
}
|
||||
|
||||
std::pair< std::string, tp::tc_part >
|
||||
tp::process_tcarg(const std::string& tcarg)
|
||||
static std::pair< std::string, tc_part >
|
||||
process_tcarg(const std::string& tcarg)
|
||||
{
|
||||
const std::string::size_type pos = tcarg.find(':');
|
||||
if (pos == std::string::npos) {
|
||||
|
@ -628,83 +518,141 @@ tp::process_tcarg(const std::string& tcarg)
|
|||
else if (partname == "cleanup")
|
||||
return std::make_pair(tcname, CLEANUP);
|
||||
else {
|
||||
using atf::application::usage_error;
|
||||
throw usage_error("Invalid test case part `%s'", partname.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
tp::run_tc(const std::string& tcarg)
|
||||
static int
|
||||
run_tc(tc_vector& tcs, const std::string& tcarg, const atf::fs::path& resfile)
|
||||
{
|
||||
const std::pair< std::string, tc_part > fields = process_tcarg(tcarg);
|
||||
|
||||
impl::tc* tc = find_tc(init_tcs(), fields.first);
|
||||
impl::tc* tc = find_tc(tcs, fields.first);
|
||||
|
||||
if (!atf::env::has("__RUNNING_INSIDE_ATF_RUN") || atf::env::get(
|
||||
"__RUNNING_INSIDE_ATF_RUN") != "internal-yes-value")
|
||||
{
|
||||
std::cerr << m_prog_name << ": WARNING: Running test cases without "
|
||||
"atf-run(1) is unsupported\n";
|
||||
std::cerr << m_prog_name << ": WARNING: No isolation nor timeout "
|
||||
std::cerr << Program_Name << ": WARNING: Running test cases outside "
|
||||
"of kyua(1) is unsupported\n";
|
||||
std::cerr << Program_Name << ": WARNING: No isolation nor timeout "
|
||||
"control is being applied; you may get unexpected failures; see "
|
||||
"atf-test-case(4)\n";
|
||||
}
|
||||
|
||||
try {
|
||||
switch (fields.second) {
|
||||
case BODY:
|
||||
tc->run(m_resfile.str());
|
||||
break;
|
||||
case CLEANUP:
|
||||
tc->run_cleanup();
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
} catch (const std::runtime_error& e) {
|
||||
std::cerr << "ERROR: " << e.what() << "\n";
|
||||
return EXIT_FAILURE;
|
||||
switch (fields.second) {
|
||||
case BODY:
|
||||
tc->run(resfile.str());
|
||||
break;
|
||||
case CLEANUP:
|
||||
tc->run_cleanup();
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
tp::main(void)
|
||||
static int
|
||||
safe_main(int argc, char** argv, void (*add_tcs)(tc_vector&))
|
||||
{
|
||||
using atf::application::usage_error;
|
||||
const char* argv0 = argv[0];
|
||||
|
||||
bool lflag = false;
|
||||
atf::fs::path resfile("/dev/stdout");
|
||||
std::string srcdir_arg;
|
||||
atf::tests::vars_map vars;
|
||||
|
||||
int ch;
|
||||
int old_opterr;
|
||||
|
||||
old_opterr = opterr;
|
||||
::opterr = 0;
|
||||
while ((ch = ::getopt(argc, argv, GETOPT_POSIX ":lr:s:v:")) != -1) {
|
||||
switch (ch) {
|
||||
case 'l':
|
||||
lflag = true;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
resfile = atf::fs::path(::optarg);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
srcdir_arg = ::optarg;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
parse_vflag(::optarg, vars);
|
||||
break;
|
||||
|
||||
case ':':
|
||||
throw usage_error("Option -%c requires an argument.", ::optopt);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
default:
|
||||
throw usage_error("Unknown option -%c.", ::optopt);
|
||||
}
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
// Clear getopt state just in case the test wants to use it.
|
||||
::opterr = old_opterr;
|
||||
::optind = 1;
|
||||
#if defined(HAVE_OPTRESET)
|
||||
::optreset = 1;
|
||||
#endif
|
||||
|
||||
vars["srcdir"] = handle_srcdir(argv0, srcdir_arg).str();
|
||||
|
||||
int errcode;
|
||||
|
||||
handle_srcdir();
|
||||
|
||||
if (m_lflag) {
|
||||
if (m_argc > 0)
|
||||
tc_vector tcs;
|
||||
if (lflag) {
|
||||
if (argc > 0)
|
||||
throw usage_error("Cannot provide test case names with -l");
|
||||
|
||||
list_tcs();
|
||||
errcode = EXIT_SUCCESS;
|
||||
init_tcs(add_tcs, tcs, vars);
|
||||
errcode = list_tcs(tcs);
|
||||
} else {
|
||||
if (m_argc == 0)
|
||||
if (argc == 0)
|
||||
throw usage_error("Must provide a test case name");
|
||||
else if (m_argc > 1)
|
||||
else if (argc > 1)
|
||||
throw usage_error("Cannot provide more than one test case name");
|
||||
INV(m_argc == 1);
|
||||
INV(argc == 1);
|
||||
|
||||
errcode = run_tc(m_argv[0]);
|
||||
init_tcs(add_tcs, tcs, vars);
|
||||
errcode = run_tc(tcs, argv[0], resfile);
|
||||
}
|
||||
for (tc_vector::iterator iter = tcs.begin(); iter != tcs.end(); iter++) {
|
||||
impl::tc* tc = *iter;
|
||||
|
||||
delete tc;
|
||||
}
|
||||
|
||||
return errcode;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace atf {
|
||||
namespace tests {
|
||||
int run_tp(int, char* const*, void (*)(tp::tc_vector&));
|
||||
int run_tp(int, char**, void (*)(tc_vector&));
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
impl::run_tp(int argc, char* const* argv, void (*add_tcs)(tp::tc_vector&))
|
||||
impl::run_tp(int argc, char** argv, void (*add_tcs)(tc_vector&))
|
||||
{
|
||||
return tp(add_tcs).run(argc, argv);
|
||||
try {
|
||||
set_program_name(argv[0]);
|
||||
return ::safe_main(argc, argv, add_tcs);
|
||||
} catch (const usage_error& e) {
|
||||
std::cerr
|
||||
<< Program_Name << ": ERROR: " << e.what() << '\n'
|
||||
<< Program_Name << ": See atf-test-program(1) for usage details.\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,10 +22,9 @@
|
|||
// 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(_ATF_CXX_TESTS_HPP_)
|
||||
#define _ATF_CXX_TESTS_HPP_
|
||||
#if !defined(ATF_CXX_TESTS_HPP)
|
||||
#define ATF_CXX_TESTS_HPP
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
@ -126,4 +122,4 @@ class tc {
|
|||
} // namespace tests
|
||||
} // namespace atf
|
||||
|
||||
#endif // !defined(_ATF_CXX_TESTS_HPP_)
|
||||
#endif // !defined(ATF_CXX_TESTS_HPP)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,7 +22,8 @@
|
|||
// 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 "atf-c++/tests.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include <sys/types.h>
|
||||
|
@ -36,12 +34,12 @@ extern "C" {
|
|||
}
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#include "macros.hpp"
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
#include "detail/test_helpers.hpp"
|
||||
#include "detail/text.hpp"
|
||||
#include "atf-c++/detail/text.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Tests for the "atf_tp_writer" class.
|
||||
|
@ -181,12 +179,6 @@ ATF_TEST_CASE_BODY(atf_tp_writer)
|
|||
#undef RESET
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Tests cases for the header file.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
HEADER_TC(include, "atf-c++/tests.hpp");
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Main.
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -195,7 +187,4 @@ ATF_INIT_TEST_CASES(tcs)
|
|||
{
|
||||
// Add tests for the "atf_tp_writer" class.
|
||||
ATF_ADD_TEST_CASE(tcs, atf_tp_writer);
|
||||
|
||||
// Add the test cases for the header file.
|
||||
ATF_ADD_TEST_CASE(tcs, include);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2012 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,9 +22,8 @@
|
|||
// 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 <atf-c++/macros.hpp>
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
ATF_TEST_CASE(this_is_used);
|
||||
ATF_TEST_CASE_HEAD(this_is_used)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,7 +22,8 @@
|
|||
// 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 "atf-c++/utils.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include "atf-c/utils.h"
|
||||
|
@ -34,8 +32,6 @@ extern "C" {
|
|||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
#include "utils.hpp"
|
||||
|
||||
void
|
||||
atf::utils::cat_file(const std::string& path, const std::string& prefix)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,10 +22,9 @@
|
|||
// 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(_ATF_CXX_UTILS_HPP_)
|
||||
#define _ATF_CXX_UTILS_HPP_
|
||||
#if !defined(ATF_CXX_UTILS_HPP)
|
||||
#define ATF_CXX_UTILS_HPP
|
||||
|
||||
extern "C" {
|
||||
#include <unistd.h>
|
||||
|
@ -65,4 +61,4 @@ grep_collection(const std::string& regexp, const Collection& collection)
|
|||
} // namespace utils
|
||||
} // namespace atf
|
||||
|
||||
#endif // !defined(_ATF_CXX_UTILS_HPP_)
|
||||
#endif // !defined(ATF_CXX_UTILS_HPP)
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
|
@ -25,7 +22,8 @@
|
|||
// 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 "atf-c++/utils.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include <sys/stat.h>
|
||||
|
@ -38,22 +36,20 @@ extern "C" {
|
|||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "macros.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
#include "detail/test_helpers.hpp"
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
static std::string
|
||||
read_file(const char *path)
|
||||
read_file(const std::string& path)
|
||||
{
|
||||
char buffer[1024];
|
||||
|
||||
const int fd = open(path, O_RDONLY);
|
||||
const int fd = open(path.c_str(), O_RDONLY);
|
||||
if (fd == -1)
|
||||
ATF_FAIL("Cannot open " + std::string(path));
|
||||
ATF_FAIL("Cannot open " + path);
|
||||
const ssize_t length = read(fd, buffer, sizeof(buffer) - 1);
|
||||
close(fd);
|
||||
ATF_REQUIRE(length != -1);
|
||||
|
@ -238,8 +234,13 @@ ATF_TEST_CASE_BODY(fork)
|
|||
ATF_REQUIRE(WIFEXITED(status));
|
||||
ATF_REQUIRE_EQ(EXIT_SUCCESS, WEXITSTATUS(status));
|
||||
|
||||
ATF_REQUIRE_EQ("Child stdout\n", read_file("atf_utils_fork_out.txt"));
|
||||
ATF_REQUIRE_EQ("Child stderr\n", read_file("atf_utils_fork_err.txt"));
|
||||
std::ostringstream out_name;
|
||||
out_name << "atf_utils_fork_" << pid << "_out.txt";
|
||||
std::ostringstream err_name;
|
||||
err_name << "atf_utils_fork_" << pid << "_err.txt";
|
||||
|
||||
ATF_REQUIRE_EQ("Child stdout\n", read_file(out_name.str()));
|
||||
ATF_REQUIRE_EQ("Child stderr\n", read_file(err_name.str()));
|
||||
}
|
||||
|
||||
ATF_TEST_CASE_WITHOUT_HEAD(grep_collection__set);
|
||||
|
@ -353,6 +354,35 @@ ATF_TEST_CASE_BODY(wait__ok)
|
|||
}
|
||||
}
|
||||
|
||||
ATF_TEST_CASE_WITHOUT_HEAD(wait__ok_nested);
|
||||
ATF_TEST_CASE_BODY(wait__ok_nested)
|
||||
{
|
||||
const pid_t parent = atf::utils::fork();
|
||||
ATF_REQUIRE(parent != -1);
|
||||
if (parent == 0) {
|
||||
const pid_t child = atf::utils::fork();
|
||||
ATF_REQUIRE(child != -1);
|
||||
if (child == 0) {
|
||||
std::cerr.flush();
|
||||
std::cout << "Child output\n";
|
||||
std::cout.flush();
|
||||
std::cerr << "Child error\n";
|
||||
std::exit(50);
|
||||
} else {
|
||||
std::cout << "Parent output\n";
|
||||
std::cerr << "Parent error\n";
|
||||
atf::utils::wait(child, 50, "Child output\n", "Child error\n");
|
||||
std::exit(40);
|
||||
}
|
||||
} else {
|
||||
atf::utils::wait(parent, 40,
|
||||
"Parent output\n"
|
||||
"subprocess stdout: Child output\n"
|
||||
"subprocess stderr: Child error\n",
|
||||
"Parent error\n");
|
||||
}
|
||||
}
|
||||
|
||||
ATF_TEST_CASE_WITHOUT_HEAD(wait__invalid_exitstatus);
|
||||
ATF_TEST_CASE_BODY(wait__invalid_exitstatus)
|
||||
{
|
||||
|
@ -432,12 +462,6 @@ ATF_TEST_CASE_BODY(wait__save_stderr)
|
|||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Tests cases for the header file.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
HEADER_TC(include, "atf-c++/utils.hpp");
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Main.
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -476,12 +500,10 @@ ATF_INIT_TEST_CASES(tcs)
|
|||
ATF_ADD_TEST_CASE(tcs, redirect__other);
|
||||
|
||||
ATF_ADD_TEST_CASE(tcs, wait__ok);
|
||||
ATF_ADD_TEST_CASE(tcs, wait__ok_nested);
|
||||
ATF_ADD_TEST_CASE(tcs, wait__invalid_exitstatus);
|
||||
ATF_ADD_TEST_CASE(tcs, wait__invalid_stdout);
|
||||
ATF_ADD_TEST_CASE(tcs, wait__invalid_stderr);
|
||||
ATF_ADD_TEST_CASE(tcs, wait__save_stdout);
|
||||
ATF_ADD_TEST_CASE(tcs, wait__save_stderr);
|
||||
|
||||
// Add the test cases for the header file.
|
||||
ATF_ADD_TEST_CASE(tcs, include);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,8 +21,7 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#if !defined(ATF_C_H)
|
||||
#define ATF_C_H
|
||||
|
|
|
@ -5,7 +5,6 @@ test_suite("atf")
|
|||
atf_test_program{name="atf_c_test"}
|
||||
atf_test_program{name="build_test"}
|
||||
atf_test_program{name="check_test"}
|
||||
atf_test_program{name="config_test"}
|
||||
atf_test_program{name="error_test"}
|
||||
atf_test_program{name="macros_test"}
|
||||
atf_test_program{name="pkg_config_test"}
|
||||
|
|
793
contrib/atf/atf-c/atf-c.3
Normal file
793
contrib/atf/atf-c/atf-c.3
Normal file
|
@ -0,0 +1,793 @@
|
|||
.\" Copyright (c) 2008 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
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" 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.
|
||||
.Dd October 13, 2014
|
||||
.Dt ATF-C 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm atf-c ,
|
||||
.Nm ATF_CHECK ,
|
||||
.Nm ATF_CHECK_MSG ,
|
||||
.Nm ATF_CHECK_EQ ,
|
||||
.Nm ATF_CHECK_EQ_MSG ,
|
||||
.Nm ATF_CHECK_MATCH ,
|
||||
.Nm ATF_CHECK_MATCH_MSG ,
|
||||
.Nm ATF_CHECK_STREQ ,
|
||||
.Nm ATF_CHECK_STREQ_MSG ,
|
||||
.Nm ATF_CHECK_ERRNO ,
|
||||
.Nm ATF_REQUIRE ,
|
||||
.Nm ATF_REQUIRE_MSG ,
|
||||
.Nm ATF_REQUIRE_EQ ,
|
||||
.Nm ATF_REQUIRE_EQ_MSG ,
|
||||
.Nm ATF_REQUIRE_MATCH ,
|
||||
.Nm ATF_REQUIRE_MATCH_MSG ,
|
||||
.Nm ATF_REQUIRE_STREQ ,
|
||||
.Nm ATF_REQUIRE_STREQ_MSG ,
|
||||
.Nm ATF_REQUIRE_ERRNO ,
|
||||
.Nm ATF_TC ,
|
||||
.Nm ATF_TC_BODY ,
|
||||
.Nm ATF_TC_BODY_NAME ,
|
||||
.Nm ATF_TC_CLEANUP ,
|
||||
.Nm ATF_TC_CLEANUP_NAME ,
|
||||
.Nm ATF_TC_HEAD ,
|
||||
.Nm ATF_TC_HEAD_NAME ,
|
||||
.Nm ATF_TC_NAME ,
|
||||
.Nm ATF_TC_WITH_CLEANUP ,
|
||||
.Nm ATF_TC_WITHOUT_HEAD ,
|
||||
.Nm ATF_TP_ADD_TC ,
|
||||
.Nm ATF_TP_ADD_TCS ,
|
||||
.Nm atf_tc_get_config_var ,
|
||||
.Nm atf_tc_get_config_var_wd ,
|
||||
.Nm atf_tc_get_config_var_as_bool ,
|
||||
.Nm atf_tc_get_config_var_as_bool_wd ,
|
||||
.Nm atf_tc_get_config_var_as_long ,
|
||||
.Nm atf_tc_get_config_var_as_long_wd ,
|
||||
.Nm atf_no_error ,
|
||||
.Nm atf_tc_expect_death ,
|
||||
.Nm atf_tc_expect_exit ,
|
||||
.Nm atf_tc_expect_fail ,
|
||||
.Nm atf_tc_expect_pass ,
|
||||
.Nm atf_tc_expect_signal ,
|
||||
.Nm atf_tc_expect_timeout ,
|
||||
.Nm atf_tc_fail ,
|
||||
.Nm atf_tc_fail_nonfatal ,
|
||||
.Nm atf_tc_pass ,
|
||||
.Nm atf_tc_skip ,
|
||||
.Nm atf_utils_cat_file ,
|
||||
.Nm atf_utils_compare_file ,
|
||||
.Nm atf_utils_copy_file ,
|
||||
.Nm atf_utils_create_file ,
|
||||
.Nm atf_utils_file_exists ,
|
||||
.Nm atf_utils_fork ,
|
||||
.Nm atf_utils_free_charpp ,
|
||||
.Nm atf_utils_grep_file ,
|
||||
.Nm atf_utils_grep_string ,
|
||||
.Nm atf_utils_readline ,
|
||||
.Nm atf_utils_redirect ,
|
||||
.Nm atf_utils_wait
|
||||
.Nd C API to write ATF-based test programs
|
||||
.Sh SYNOPSIS
|
||||
.In atf-c.h
|
||||
.\" NO_CHECK_STYLE_BEGIN
|
||||
.Fn ATF_CHECK "expression"
|
||||
.Fn ATF_CHECK_MSG "expression" "fail_msg_fmt" ...
|
||||
.Fn ATF_CHECK_EQ "expected_expression" "actual_expression"
|
||||
.Fn ATF_CHECK_EQ_MSG "expected_expression" "actual_expression" "fail_msg_fmt" ...
|
||||
.Fn ATF_CHECK_MATCH "regexp" "string"
|
||||
.Fn ATF_CHECK_MATCH_MSG "regexp" "string" "fail_msg_fmt" ...
|
||||
.Fn ATF_CHECK_STREQ "string_1" "string_2"
|
||||
.Fn ATF_CHECK_STREQ_MSG "string_1" "string_2" "fail_msg_fmt" ...
|
||||
.Fn ATF_CHECK_ERRNO "expected_errno" "bool_expression"
|
||||
.Fn ATF_REQUIRE "expression"
|
||||
.Fn ATF_REQUIRE_MSG "expression" "fail_msg_fmt" ...
|
||||
.Fn ATF_REQUIRE_EQ "expected_expression" "actual_expression"
|
||||
.Fn ATF_REQUIRE_EQ_MSG "expected_expression" "actual_expression" "fail_msg_fmt" ...
|
||||
.Fn ATF_REQUIRE_MATCH "regexp" "string"
|
||||
.Fn ATF_REQUIRE_MATCH_MSG "regexp" "string" "fail_msg_fmt" ...
|
||||
.Fn ATF_REQUIRE_STREQ "expected_string" "actual_string"
|
||||
.Fn ATF_REQUIRE_STREQ_MSG "expected_string" "actual_string" "fail_msg_fmt" ...
|
||||
.Fn ATF_REQUIRE_ERRNO "expected_errno" "bool_expression"
|
||||
.\" NO_CHECK_STYLE_END
|
||||
.Fn ATF_TC "name"
|
||||
.Fn ATF_TC_BODY "name" "tc"
|
||||
.Fn ATF_TC_BODY_NAME "name"
|
||||
.Fn ATF_TC_CLEANUP "name" "tc"
|
||||
.Fn ATF_TC_CLEANUP_NAME "name"
|
||||
.Fn ATF_TC_HEAD "name" "tc"
|
||||
.Fn ATF_TC_HEAD_NAME "name"
|
||||
.Fn ATF_TC_NAME "name"
|
||||
.Fn ATF_TC_WITH_CLEANUP "name"
|
||||
.Fn ATF_TC_WITHOUT_HEAD "name"
|
||||
.Fn ATF_TP_ADD_TC "tp_name" "tc_name"
|
||||
.Fn ATF_TP_ADD_TCS "tp_name"
|
||||
.Fn atf_tc_get_config_var "tc" "varname"
|
||||
.Fn atf_tc_get_config_var_wd "tc" "variable_name" "default_value"
|
||||
.Fn atf_tc_get_config_var_as_bool "tc" "variable_name"
|
||||
.Fn atf_tc_get_config_var_as_bool_wd "tc" "variable_name" "default_value"
|
||||
.Fn atf_tc_get_config_var_as_long "tc" "variable_name"
|
||||
.Fn atf_tc_get_config_var_as_long_wd "tc" "variable_name" "default_value"
|
||||
.Fn atf_no_error
|
||||
.Fn atf_tc_expect_death "reason" "..."
|
||||
.Fn atf_tc_expect_exit "exitcode" "reason" "..."
|
||||
.Fn atf_tc_expect_fail "reason" "..."
|
||||
.Fn atf_tc_expect_pass
|
||||
.Fn atf_tc_expect_signal "signo" "reason" "..."
|
||||
.Fn atf_tc_expect_timeout "reason" "..."
|
||||
.Fn atf_tc_fail "reason"
|
||||
.Fn atf_tc_fail_nonfatal "reason"
|
||||
.Fn atf_tc_pass
|
||||
.Fn atf_tc_skip "reason"
|
||||
.Ft void
|
||||
.Fo atf_utils_cat_file
|
||||
.Fa "const char *file"
|
||||
.Fa "const char *prefix"
|
||||
.Fc
|
||||
.Ft bool
|
||||
.Fo atf_utils_compare_file
|
||||
.Fa "const char *file"
|
||||
.Fa "const char *contents"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo atf_utils_copy_file
|
||||
.Fa "const char *source"
|
||||
.Fa "const char *destination"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo atf_utils_create_file
|
||||
.Fa "const char *file"
|
||||
.Fa "const char *contents"
|
||||
.Fa "..."
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo atf_utils_file_exists
|
||||
.Fa "const char *file"
|
||||
.Fc
|
||||
.Ft pid_t
|
||||
.Fo atf_utils_fork
|
||||
.Fa "void"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo atf_utils_free_charpp
|
||||
.Fa "char **argv"
|
||||
.Fc
|
||||
.Ft bool
|
||||
.Fo atf_utils_grep_file
|
||||
.Fa "const char *regexp"
|
||||
.Fa "const char *file"
|
||||
.Fa "..."
|
||||
.Fc
|
||||
.Ft bool
|
||||
.Fo atf_utils_grep_string
|
||||
.Fa "const char *regexp"
|
||||
.Fa "const char *str"
|
||||
.Fa "..."
|
||||
.Fc
|
||||
.Ft char *
|
||||
.Fo atf_utils_readline
|
||||
.Fa "int fd"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo atf_utils_redirect
|
||||
.Fa "const int fd"
|
||||
.Fa "const char *file"
|
||||
.Fc
|
||||
.Ft void
|
||||
.Fo atf_utils_wait
|
||||
.Fa "const pid_t pid"
|
||||
.Fa "const int expected_exit_status"
|
||||
.Fa "const char *expected_stdout"
|
||||
.Fa "const char *expected_stderr"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
ATF provides a C programming interface to implement test programs.
|
||||
C-based test programs follow this template:
|
||||
.Bd -literal -offset indent
|
||||
.Ns ... C-specific includes go here ...
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
ATF_TC(tc1);
|
||||
ATF_TC_HEAD(tc1, tc)
|
||||
{
|
||||
... first test case's header ...
|
||||
}
|
||||
ATF_TC_BODY(tc1, tc)
|
||||
{
|
||||
... first test case's body ...
|
||||
}
|
||||
|
||||
ATF_TC_WITH_CLEANUP(tc2);
|
||||
ATF_TC_HEAD(tc2, tc)
|
||||
{
|
||||
... second test case's header ...
|
||||
}
|
||||
ATF_TC_BODY(tc2, tc)
|
||||
{
|
||||
... second test case's body ...
|
||||
}
|
||||
ATF_TC_CLEANUP(tc2, tc)
|
||||
{
|
||||
... second test case's cleanup ...
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(tc3);
|
||||
ATF_TC_BODY(tc3, tc)
|
||||
{
|
||||
... third test case's body ...
|
||||
}
|
||||
|
||||
.Ns ... additional test cases ...
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
ATF_TP_ADD_TC(tcs, tc1);
|
||||
ATF_TP_ADD_TC(tcs, tc2);
|
||||
ATF_TP_ADD_TC(tcs, tc3);
|
||||
... add additional test cases ...
|
||||
|
||||
return atf_no_error();
|
||||
}
|
||||
.Ed
|
||||
.Ss Definition of test cases
|
||||
Test cases have an identifier and are composed of three different parts:
|
||||
the header, the body and an optional cleanup routine, all of which are
|
||||
described in
|
||||
.Xr atf-test-case 4 .
|
||||
To define test cases, one can use the
|
||||
.Fn ATF_TC ,
|
||||
.Fn ATF_TC_WITH_CLEANUP
|
||||
or the
|
||||
.Fn ATF_TC_WITHOUT_HEAD
|
||||
macros, which take a single parameter specifiying the test case's name.
|
||||
.Fn ATF_TC ,
|
||||
requires to define a head and a body for the test case,
|
||||
.Fn ATF_TC_WITH_CLEANUP
|
||||
requires to define a head, a body and a cleanup for the test case and
|
||||
.Fn ATF_TC_WITHOUT_HEAD
|
||||
requires only a body for the test case.
|
||||
It is important to note that these
|
||||
.Em do not
|
||||
set the test case up for execution when the program is run.
|
||||
In order to do so, a later registration is needed with the
|
||||
.Fn ATF_TP_ADD_TC
|
||||
macro detailed in
|
||||
.Sx Program initialization .
|
||||
.Pp
|
||||
Later on, one must define the three parts of the body by means of three
|
||||
functions.
|
||||
Their headers are given by the
|
||||
.Fn ATF_TC_HEAD ,
|
||||
.Fn ATF_TC_BODY
|
||||
and
|
||||
.Fn ATF_TC_CLEANUP
|
||||
macros, all of which take the test case name provided to the
|
||||
.Fn ATF_TC
|
||||
.Fn ATF_TC_WITH_CLEANUP ,
|
||||
or
|
||||
.Fn ATF_TC_WITHOUT_HEAD
|
||||
macros and the name of the variable that will hold a pointer to the
|
||||
test case data.
|
||||
Following each of these, a block of code is expected, surrounded by the
|
||||
opening and closing brackets.
|
||||
.Ss Program initialization
|
||||
The library provides a way to easily define the test program's
|
||||
.Fn main
|
||||
function.
|
||||
You should never define one on your own, but rely on the
|
||||
library to do it for you.
|
||||
This is done by using the
|
||||
.Fn ATF_TP_ADD_TCS
|
||||
macro, which is passed the name of the object that will hold the test
|
||||
cases; i.e. the test program instance.
|
||||
This name can be whatever you want as long as it is a valid variable
|
||||
identifier.
|
||||
.Pp
|
||||
After the macro, you are supposed to provide the body of a function, which
|
||||
should only use the
|
||||
.Fn ATF_TP_ADD_TC
|
||||
macro to register the test cases the test program will execute and return
|
||||
a success error code.
|
||||
The first parameter of this macro matches the name you provided in the
|
||||
former call.
|
||||
The success status can be returned using the
|
||||
.Fn atf_no_error
|
||||
function.
|
||||
.Ss Header definitions
|
||||
The test case's header can define the meta-data by using the
|
||||
.Fn atf_tc_set_md_var
|
||||
method, which takes three parameters: the first one points to the test
|
||||
case data, the second one specifies the meta-data variable to be set
|
||||
and the third one specifies its value.
|
||||
Both of them are strings.
|
||||
.Ss Configuration variables
|
||||
The test case has read-only access to the current configuration variables
|
||||
by means of the
|
||||
.Ft bool
|
||||
.Fn atf_tc_has_config_var ,
|
||||
.Ft const char *
|
||||
.Fn atf_tc_get_config_var ,
|
||||
.Ft const char *
|
||||
.Fn atf_tc_get_config_var_wd ,
|
||||
.Ft bool
|
||||
.Fn atf_tc_get_config_var_as_bool ,
|
||||
.Ft bool
|
||||
.Fn atf_tc_get_config_var_as_bool_wd ,
|
||||
.Ft long
|
||||
.Fn atf_tc_get_config_var_as_long ,
|
||||
and the
|
||||
.Ft long
|
||||
.Fn atf_tc_get_config_var_as_long_wd
|
||||
functions, which can be called in any of the three parts of a test case.
|
||||
.Pp
|
||||
The
|
||||
.Sq _wd
|
||||
variants take a default value for the variable which is returned if the
|
||||
variable is not defined.
|
||||
The other functions without the
|
||||
.Sq _wd
|
||||
suffix
|
||||
.Em require
|
||||
the variable to be defined.
|
||||
.Ss Access to the source directory
|
||||
It is possible to get the path to the test case's source directory from any
|
||||
of its three components by querying the
|
||||
.Sq srcdir
|
||||
configuration variable.
|
||||
.Ss Requiring programs
|
||||
Aside from the
|
||||
.Va require.progs
|
||||
meta-data variable available in the header only, one can also check for
|
||||
additional programs in the test case's body by using the
|
||||
.Fn atf_tc_require_prog
|
||||
function, which takes the base name or full path of a single binary.
|
||||
Relative paths are forbidden.
|
||||
If it is not found, the test case will be automatically skipped.
|
||||
.Ss Test case finalization
|
||||
The test case finalizes either when the body reaches its end, at which
|
||||
point the test is assumed to have
|
||||
.Em passed ,
|
||||
unless any non-fatal errors were raised using
|
||||
.Fn atf_tc_fail_nonfatal ,
|
||||
or at any explicit call to
|
||||
.Fn atf_tc_pass ,
|
||||
.Fn atf_tc_fail
|
||||
or
|
||||
.Fn atf_tc_skip .
|
||||
These three functions terminate the execution of the test case immediately.
|
||||
The cleanup routine will be processed afterwards in a completely automated
|
||||
way, regardless of the test case's termination reason.
|
||||
.Pp
|
||||
.Fn atf_tc_pass
|
||||
does not take any parameters.
|
||||
.Fn atf_tc_fail ,
|
||||
.Fn atf_tc_fail_nonfatal
|
||||
and
|
||||
.Fn atf_tc_skip
|
||||
take a format string and a variable list of parameters, which describe, in
|
||||
a user-friendly manner, why the test case failed or was skipped,
|
||||
respectively.
|
||||
It is very important to provide a clear error message in both cases so that
|
||||
the user can quickly know why the test did not pass.
|
||||
.Ss Expectations
|
||||
Everything explained in the previous section changes when the test case
|
||||
expectations are redefined by the programmer.
|
||||
.Pp
|
||||
Each test case has an internal state called
|
||||
.Sq expect
|
||||
that describes what the test case expectations are at any point in time.
|
||||
The value of this property can change during execution by any of:
|
||||
.Bl -tag -width indent
|
||||
.It Fn atf_tc_expect_death "reason" "..."
|
||||
Expects the test case to exit prematurely regardless of the nature of the
|
||||
exit.
|
||||
.It Fn atf_tc_expect_exit "exitcode" "reason" "..."
|
||||
Expects the test case to exit cleanly.
|
||||
If
|
||||
.Va exitcode
|
||||
is not
|
||||
.Sq -1 ,
|
||||
the runtime engine will validate that the exit code of the test case
|
||||
matches the one provided in this call.
|
||||
Otherwise, the exact value will be ignored.
|
||||
.It Fn atf_tc_expect_fail "reason" "..."
|
||||
Any failure (be it fatal or non-fatal) raised in this mode is recorded.
|
||||
However, such failures do not report the test case as failed; instead, the
|
||||
test case finalizes cleanly and is reported as
|
||||
.Sq expected failure ;
|
||||
this report includes the provided
|
||||
.Fa reason
|
||||
as part of it.
|
||||
If no error is raised while running in this mode, then the test case is
|
||||
reported as
|
||||
.Sq failed .
|
||||
.Pp
|
||||
This mode is useful to reproduce actual known bugs in tests.
|
||||
Whenever the developer fixes the bug later on, the test case will start
|
||||
reporting a failure, signaling the developer that the test case must be
|
||||
adjusted to the new conditions.
|
||||
In this situation, it is useful, for example, to set
|
||||
.Fa reason
|
||||
as the bug number for tracking purposes.
|
||||
.It Fn atf_tc_expect_pass
|
||||
This is the normal mode of execution.
|
||||
In this mode, any failure is reported as such to the user and the test case
|
||||
is marked as
|
||||
.Sq failed .
|
||||
.It Fn atf_tc_expect_signal "signo" "reason" "..."
|
||||
Expects the test case to terminate due to the reception of a signal.
|
||||
If
|
||||
.Va signo
|
||||
is not
|
||||
.Sq -1 ,
|
||||
the runtime engine will validate that the signal that terminated the test
|
||||
case matches the one provided in this call.
|
||||
Otherwise, the exact value will be ignored.
|
||||
.It Fn atf_tc_expect_timeout "reason" "..."
|
||||
Expects the test case to execute for longer than its timeout.
|
||||
.El
|
||||
.Ss Helper macros for common checks
|
||||
The library provides several macros that are very handy in multiple
|
||||
situations.
|
||||
These basically check some condition after executing a given statement or
|
||||
processing a given expression and, if the condition is not met, they
|
||||
report the test case as failed.
|
||||
.Pp
|
||||
The
|
||||
.Sq REQUIRE
|
||||
variant of the macros immediately abort the test case as soon as an error
|
||||
condition is detected by calling the
|
||||
.Fn atf_tc_fail
|
||||
function.
|
||||
Use this variant whenever it makes no sense to continue the execution of a
|
||||
test case when the checked condition is not met.
|
||||
The
|
||||
.Sq CHECK
|
||||
variant, on the other hand, reports a failure as soon as it is encountered
|
||||
using the
|
||||
.Fn atf_tc_fail_nonfatal
|
||||
function, but the execution of the test case continues as if nothing had
|
||||
happened.
|
||||
Use this variant whenever the checked condition is important as a result of
|
||||
the test case, but there are other conditions that can be subsequently
|
||||
checked on the same run without aborting.
|
||||
.Pp
|
||||
Additionally, the
|
||||
.Sq MSG
|
||||
variants take an extra set of parameters to explicitly specify the failure
|
||||
message.
|
||||
This failure message is formatted according to the
|
||||
.Xr printf 3
|
||||
formatters.
|
||||
.Pp
|
||||
.Fn ATF_CHECK ,
|
||||
.Fn ATF_CHECK_MSG ,
|
||||
.Fn ATF_REQUIRE
|
||||
and
|
||||
.Fn ATF_REQUIRE_MSG
|
||||
take an expression and fail if the expression evaluates to false.
|
||||
.Pp
|
||||
.Fn ATF_CHECK_EQ ,
|
||||
.Fn ATF_CHECK_EQ_MSG ,
|
||||
.Fn ATF_REQUIRE_EQ
|
||||
and
|
||||
.Fn ATF_REQUIRE_EQ_MSG
|
||||
take two expressions and fail if the two evaluated values are not equal.
|
||||
The common style is to put the expected value in the first parameter and the
|
||||
actual value in the second parameter.
|
||||
.Pp
|
||||
.Fn ATF_CHECK_MATCH ,
|
||||
.Fn ATF_CHECK_MATCH_MSG ,
|
||||
.Fn ATF_REQUIRE_MATCH
|
||||
and
|
||||
.Fn ATF_REQUIRE_MATCH_MSG
|
||||
take a regular expression and a string and fail if the regular expression does
|
||||
not match the given string.
|
||||
Note that the regular expression is not anchored, so it will match anywhere in
|
||||
the string.
|
||||
.Pp
|
||||
.Fn ATF_CHECK_STREQ ,
|
||||
.Fn ATF_CHECK_STREQ_MSG ,
|
||||
.Fn ATF_REQUIRE_STREQ
|
||||
and
|
||||
.Fn ATF_REQUIRE_STREQ_MSG
|
||||
take two strings and fail if the two are not equal character by character.
|
||||
The common style is to put the expected string in the first parameter and the
|
||||
actual string in the second parameter.
|
||||
.Pp
|
||||
.Fn ATF_CHECK_ERRNO
|
||||
and
|
||||
.Fn ATF_REQUIRE_ERRNO
|
||||
take, first, the error code that the check is expecting to find in the
|
||||
.Va errno
|
||||
variable and, second, a boolean expression that, if evaluates to true,
|
||||
means that a call failed and
|
||||
.Va errno
|
||||
has to be checked against the first value.
|
||||
.Ss Utility functions
|
||||
The following functions are provided as part of the
|
||||
.Nm
|
||||
API to simplify the creation of a variety of tests.
|
||||
In particular, these are useful to write tests for command-line interfaces.
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf_utils_cat_file
|
||||
.Fa "const char *file"
|
||||
.Fa "const char *prefix"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Prints the contents of
|
||||
.Fa file
|
||||
to the standard output, prefixing every line with the string in
|
||||
.Fa prefix .
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft bool
|
||||
.Fo atf_utils_compare_file
|
||||
.Fa "const char *file"
|
||||
.Fa "const char *contents"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Returns true if the given
|
||||
.Fa file
|
||||
matches exactly the expected inlined
|
||||
.Fa contents .
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf_utils_copy_file
|
||||
.Fa "const char *source"
|
||||
.Fa "const char *destination"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Copies the file
|
||||
.Fa source
|
||||
to
|
||||
.Fa destination .
|
||||
The permissions of the file are preserved during the code.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf_utils_create_file
|
||||
.Fa "const char *file"
|
||||
.Fa "const char *contents"
|
||||
.Fa "..."
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Creates
|
||||
.Fa file
|
||||
with the text given in
|
||||
.Fa contents ,
|
||||
which is a formatting string that uses the rest of the variable arguments.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf_utils_file_exists
|
||||
.Fa "const char *file"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Checks if
|
||||
.Fa file
|
||||
exists.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft pid_t
|
||||
.Fo atf_utils_fork
|
||||
.Fa "void"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Forks a process and redirects the standard output and standard error of the
|
||||
child to files for later validation with
|
||||
.Fn atf_utils_wait .
|
||||
Fails the test case if the fork fails, so this does not return an error.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf_utils_free_charpp
|
||||
.Fa "char **argv"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Frees a dynamically-allocated array of dynamically-allocated strings.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft bool
|
||||
.Fo atf_utils_grep_file
|
||||
.Fa "const char *regexp"
|
||||
.Fa "const char *file"
|
||||
.Fa "..."
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Searches for the
|
||||
.Fa regexp ,
|
||||
which is a formatting string representing the regular expression,
|
||||
in the
|
||||
.Fa file .
|
||||
The variable arguments are used to construct the regular expression.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft bool
|
||||
.Fo atf_utils_grep_string
|
||||
.Fa "const char *regexp"
|
||||
.Fa "const char *str"
|
||||
.Fa "..."
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Searches for the
|
||||
.Fa regexp ,
|
||||
which is a formatting string representing the regular expression,
|
||||
in the literal string
|
||||
.Fa str .
|
||||
The variable arguments are used to construct the regular expression.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft char *
|
||||
.Fo atf_utils_readline
|
||||
.Fa "int fd"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Reads a line from the file descriptor
|
||||
.Fa fd .
|
||||
The line, if any, is returned as a dynamically-allocated buffer that must be
|
||||
released with
|
||||
.Xr free 3 .
|
||||
If there was nothing to read, returns
|
||||
.Sq NULL .
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf_utils_redirect
|
||||
.Fa "const int fd"
|
||||
.Fa "const char *file"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Redirects the given file descriptor
|
||||
.Fa fd
|
||||
to
|
||||
.Fa file .
|
||||
This function exits the process in case of an error and does not properly mark
|
||||
the test case as failed.
|
||||
As a result, it should only be used in subprocesses of the test case; specially
|
||||
those spawned by
|
||||
.Fn atf_utils_fork .
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf_utils_wait
|
||||
.Fa "const pid_t pid"
|
||||
.Fa "const int expected_exit_status"
|
||||
.Fa "const char *expected_stdout"
|
||||
.Fa "const char *expected_stderr"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Waits and validates the result of a subprocess spawned with
|
||||
.Fn atf_utils_wait .
|
||||
The validation involves checking that the subprocess exited cleanly and returned
|
||||
the code specified in
|
||||
.Fa expected_exit_status
|
||||
and that its standard output and standard error match the strings given in
|
||||
.Fa expected_stdout
|
||||
and
|
||||
.Fa expected_stderr .
|
||||
.Pp
|
||||
If any of the
|
||||
.Fa expected_stdout
|
||||
or
|
||||
.Fa expected_stderr
|
||||
strings are prefixed with
|
||||
.Sq save: ,
|
||||
then they specify the name of the file into which to store the stdout or stderr
|
||||
of the subprocess, and no comparison is performed.
|
||||
.Ed
|
||||
.Sh ENVIRONMENT
|
||||
The following variables are recognized by
|
||||
.Nm
|
||||
but should not be overridden other than for testing purposes:
|
||||
.Pp
|
||||
.Bl -tag -width ATFXBUILDXCXXFLAGSXX -compact
|
||||
.It Va ATF_BUILD_CC
|
||||
Path to the C compiler.
|
||||
.It Va ATF_BUILD_CFLAGS
|
||||
C compiler flags.
|
||||
.It Va ATF_BUILD_CPP
|
||||
Path to the C/C++ preprocessor.
|
||||
.It Va ATF_BUILD_CPPFLAGS
|
||||
C/C++ preprocessor flags.
|
||||
.It Va ATF_BUILD_CXX
|
||||
Path to the C++ compiler.
|
||||
.It Va ATF_BUILD_CXXFLAGS
|
||||
C++ compiler flags.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
The following shows a complete test program with a single test case that
|
||||
validates the addition operator:
|
||||
.Bd -literal -offset indent
|
||||
#include <atf-c.h>
|
||||
|
||||
ATF_TC(addition);
|
||||
ATF_TC_HEAD(addition, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr",
|
||||
"Sample tests for the addition operator");
|
||||
}
|
||||
ATF_TC_BODY(addition, tc)
|
||||
{
|
||||
ATF_CHECK_EQ(0, 0 + 0);
|
||||
ATF_CHECK_EQ(1, 0 + 1);
|
||||
ATF_CHECK_EQ(1, 1 + 0);
|
||||
|
||||
ATF_CHECK_EQ(2, 1 + 1);
|
||||
|
||||
ATF_CHECK_EQ(300, 100 + 200);
|
||||
}
|
||||
|
||||
ATF_TC(string_formatting);
|
||||
ATF_TC_HEAD(string_formatting, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr",
|
||||
"Sample tests for the snprintf");
|
||||
}
|
||||
ATF_TC_BODY(string_formatting, tc)
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, sizeof(buf), "a %s", "string");
|
||||
ATF_CHECK_STREQ_MSG("a string", buf, "%s is not working");
|
||||
}
|
||||
|
||||
ATF_TC(open_failure);
|
||||
ATF_TC_HEAD(open_failure, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr",
|
||||
"Sample tests for the open function");
|
||||
}
|
||||
ATF_TC_BODY(open_failure, tc)
|
||||
{
|
||||
ATF_CHECK_ERRNO(ENOENT, open("non-existent", O_RDONLY) == -1);
|
||||
}
|
||||
|
||||
ATF_TC(known_bug);
|
||||
ATF_TC_HEAD(known_bug, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr",
|
||||
"Reproduces a known bug");
|
||||
}
|
||||
ATF_TC_BODY(known_bug, tc)
|
||||
{
|
||||
atf_tc_expect_fail("See bug number foo/bar");
|
||||
ATF_CHECK_EQ(3, 1 + 1);
|
||||
atf_tc_expect_pass();
|
||||
ATF_CHECK_EQ(3, 1 + 2);
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
ATF_TP_ADD_TC(tp, addition);
|
||||
ATF_TP_ADD_TC(tp, string_formatting);
|
||||
ATF_TP_ADD_TC(tp, open_failure);
|
||||
ATF_TP_ADD_TC(tp, known_bug);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr atf-test-program 1 ,
|
||||
.Xr atf-test-case 4
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,12 +21,11 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include "detail/test_helpers.h"
|
||||
#include "atf-c/detail/test_helpers.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Tests cases for the header file.
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
/* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -24,31 +21,31 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/build.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "atf-c/build.h"
|
||||
#include "atf-c/config.h"
|
||||
#include "atf-c/detail/env.h"
|
||||
#include "atf-c/detail/sanity.h"
|
||||
#include "atf-c/detail/text.h"
|
||||
#include "atf-c/error.h"
|
||||
|
||||
#include "detail/sanity.h"
|
||||
#include "detail/text.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Auxiliary functions.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
static
|
||||
atf_error_t
|
||||
append_config_var(const char *var, atf_list_t *argv)
|
||||
append_config_var(const char *var, const char *default_value, atf_list_t *argv)
|
||||
{
|
||||
atf_error_t err;
|
||||
atf_list_t words;
|
||||
|
||||
err = atf_text_split(atf_config_get(var), " ", &words);
|
||||
err = atf_text_split(atf_env_get_with_default(var, default_value),
|
||||
" ", &words);
|
||||
if (atf_is_error(err))
|
||||
goto out;
|
||||
|
||||
|
@ -158,15 +155,16 @@ atf_build_c_o(const char *sfile,
|
|||
if (atf_is_error(err))
|
||||
goto out;
|
||||
|
||||
err = append_config_var("atf_build_cc", &argv_list);
|
||||
err = append_config_var("ATF_BUILD_CC", ATF_BUILD_CC, &argv_list);
|
||||
if (atf_is_error(err))
|
||||
goto out_list;
|
||||
|
||||
err = append_config_var("atf_build_cppflags", &argv_list);
|
||||
err = append_config_var("ATF_BUILD_CPPFLAGS", ATF_BUILD_CPPFLAGS,
|
||||
&argv_list);
|
||||
if (atf_is_error(err))
|
||||
goto out_list;
|
||||
|
||||
err = append_config_var("atf_build_cflags", &argv_list);
|
||||
err = append_config_var("ATF_BUILD_CFLAGS", ATF_BUILD_CFLAGS, &argv_list);
|
||||
if (atf_is_error(err))
|
||||
goto out_list;
|
||||
|
||||
|
@ -203,11 +201,12 @@ atf_build_cpp(const char *sfile,
|
|||
if (atf_is_error(err))
|
||||
goto out;
|
||||
|
||||
err = append_config_var("atf_build_cpp", &argv_list);
|
||||
err = append_config_var("ATF_BUILD_CPP", ATF_BUILD_CPP, &argv_list);
|
||||
if (atf_is_error(err))
|
||||
goto out_list;
|
||||
|
||||
err = append_config_var("atf_build_cppflags", &argv_list);
|
||||
err = append_config_var("ATF_BUILD_CPPFLAGS", ATF_BUILD_CPPFLAGS,
|
||||
&argv_list);
|
||||
if (atf_is_error(err))
|
||||
goto out_list;
|
||||
|
||||
|
@ -248,15 +247,17 @@ atf_build_cxx_o(const char *sfile,
|
|||
if (atf_is_error(err))
|
||||
goto out;
|
||||
|
||||
err = append_config_var("atf_build_cxx", &argv_list);
|
||||
err = append_config_var("ATF_BUILD_CXX", ATF_BUILD_CXX, &argv_list);
|
||||
if (atf_is_error(err))
|
||||
goto out_list;
|
||||
|
||||
err = append_config_var("atf_build_cppflags", &argv_list);
|
||||
err = append_config_var("ATF_BUILD_CPPFLAGS", ATF_BUILD_CPPFLAGS,
|
||||
&argv_list);
|
||||
if (atf_is_error(err))
|
||||
goto out_list;
|
||||
|
||||
err = append_config_var("atf_build_cxxflags", &argv_list);
|
||||
err = append_config_var("ATF_BUILD_CXXFLAGS", ATF_BUILD_CXXFLAGS,
|
||||
&argv_list);
|
||||
if (atf_is_error(err))
|
||||
goto out_list;
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
/* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -24,8 +21,7 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#if !defined(ATF_C_BUILD_H)
|
||||
#define ATF_C_BUILD_H
|
||||
|
@ -39,4 +35,4 @@ atf_error_t atf_build_cpp(const char *, const char *, const char *const [],
|
|||
atf_error_t atf_build_cxx_o(const char *, const char *, const char *const [],
|
||||
char ***);
|
||||
|
||||
#endif /* ATF_C_BUILD_H */
|
||||
#endif /* !defined(ATF_C_BUILD_H) */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
/* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -24,8 +21,9 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/build.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -33,20 +31,15 @@
|
|||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include "atf-c/build.h"
|
||||
#include "atf-c/config.h"
|
||||
#include "atf-c/detail/env.h"
|
||||
#include "atf-c/detail/test_helpers.h"
|
||||
#include "atf-c/h_build.h"
|
||||
#include "atf-c/utils.h"
|
||||
|
||||
#include "detail/env.h"
|
||||
#include "detail/test_helpers.h"
|
||||
#include "h_build.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Auxiliary functions.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
void __atf_config_reinit(void);
|
||||
|
||||
static
|
||||
bool
|
||||
equal_arrays(const char *const *exp_array, char **actual_array)
|
||||
|
@ -167,7 +160,6 @@ ATF_TC_BODY(c_o, tc)
|
|||
verbose_set_env("ATF_BUILD_CC", test->cc);
|
||||
verbose_set_env("ATF_BUILD_CFLAGS", test->cflags);
|
||||
verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags);
|
||||
__atf_config_reinit();
|
||||
|
||||
{
|
||||
char **argv;
|
||||
|
@ -196,7 +188,6 @@ ATF_TC_BODY(cpp, tc)
|
|||
|
||||
verbose_set_env("ATF_BUILD_CPP", test->cpp);
|
||||
verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags);
|
||||
__atf_config_reinit();
|
||||
|
||||
{
|
||||
char **argv;
|
||||
|
@ -226,7 +217,6 @@ ATF_TC_BODY(cxx_o, tc)
|
|||
verbose_set_env("ATF_BUILD_CXX", test->cxx);
|
||||
verbose_set_env("ATF_BUILD_CXXFLAGS", test->cxxflags);
|
||||
verbose_set_env("ATF_BUILD_CPPFLAGS", test->cppflags);
|
||||
__atf_config_reinit();
|
||||
|
||||
{
|
||||
char **argv;
|
||||
|
@ -241,12 +231,6 @@ ATF_TC_BODY(cxx_o, tc)
|
|||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Tests cases for the header file.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
HEADER_TC(include, "atf-c/build.h");
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Main.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
@ -261,8 +245,5 @@ ATF_TP_ADD_TCS(tp)
|
|||
ATF_TP_ADD_TC(tp, cpp);
|
||||
ATF_TP_ADD_TC(tp, cxx_o);
|
||||
|
||||
/* Add the test cases for the header file. */
|
||||
ATF_TP_ADD_TC(tp, include);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,8 +21,9 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/check.h"
|
||||
|
||||
#include <sys/wait.h>
|
||||
|
||||
|
@ -37,18 +35,16 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "atf-c/build.h"
|
||||
#include "atf-c/check.h"
|
||||
#include "atf-c/config.h"
|
||||
#include "atf-c/defs.h"
|
||||
#include "atf-c/detail/dynstr.h"
|
||||
#include "atf-c/detail/env.h"
|
||||
#include "atf-c/detail/fs.h"
|
||||
#include "atf-c/detail/list.h"
|
||||
#include "atf-c/detail/process.h"
|
||||
#include "atf-c/detail/sanity.h"
|
||||
#include "atf-c/error.h"
|
||||
#include "atf-c/utils.h"
|
||||
|
||||
#include "detail/dynstr.h"
|
||||
#include "detail/fs.h"
|
||||
#include "detail/list.h"
|
||||
#include "detail/process.h"
|
||||
#include "detail/sanity.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Auxiliary functions.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
@ -60,7 +56,7 @@ create_tmpdir(atf_fs_path_t *dir)
|
|||
atf_error_t err;
|
||||
|
||||
err = atf_fs_path_init_fmt(dir, "%s/check.XXXXXX",
|
||||
atf_config_get("atf_workdir"));
|
||||
atf_env_get_with_default("TMPDIR", "/tmp"));
|
||||
if (atf_is_error(err))
|
||||
goto out;
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,8 +21,7 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#if !defined(ATF_C_CHECK_H)
|
||||
#define ATF_C_CHECK_H
|
||||
|
@ -70,4 +66,4 @@ atf_error_t atf_check_build_cxx_o(const char *, const char *,
|
|||
bool *);
|
||||
atf_error_t atf_check_exec_array(const char *const *, atf_check_result_t *);
|
||||
|
||||
#endif /* ATF_C_CHECK_H */
|
||||
#endif /* !defined(ATF_C_CHECK_H) */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,8 +21,9 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/check.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
|
@ -36,13 +34,10 @@
|
|||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include "atf-c/check.h"
|
||||
#include "atf-c/config.h"
|
||||
|
||||
#include "detail/fs.h"
|
||||
#include "detail/map.h"
|
||||
#include "detail/process.h"
|
||||
#include "detail/test_helpers.h"
|
||||
#include "atf-c/detail/fs.h"
|
||||
#include "atf-c/detail/map.h"
|
||||
#include "atf-c/detail/process.h"
|
||||
#include "atf-c/detail/test_helpers.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Auxiliary functions.
|
||||
|
@ -494,12 +489,8 @@ ATF_TC_HEAD(exec_unknown, tc)
|
|||
}
|
||||
ATF_TC_BODY(exec_unknown, tc)
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, sizeof(buf), "%s/non-existent",
|
||||
atf_config_get("atf_workdir"));
|
||||
|
||||
const char *argv[2];
|
||||
argv[0] = buf;
|
||||
argv[0] = "/foo/bar/non-existent";
|
||||
argv[1] = NULL;
|
||||
|
||||
atf_check_result_t result;
|
||||
|
@ -509,12 +500,6 @@ ATF_TC_BODY(exec_unknown, tc)
|
|||
atf_check_result_fini(&result);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Tests cases for the header file.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
HEADER_TC(include, "atf-c/check.h");
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Main.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
@ -532,8 +517,5 @@ ATF_TP_ADD_TCS(tp)
|
|||
ATF_TP_ADD_TC(tp, exec_umask);
|
||||
ATF_TP_ADD_TC(tp, exec_unknown);
|
||||
|
||||
/* Add the test cases for the header file. */
|
||||
ATF_TP_ADD_TC(tp, include);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
||||
|
|
|
@ -1,160 +0,0 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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 <ctype.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "atf-c/config.h"
|
||||
|
||||
#include "detail/env.h"
|
||||
#include "detail/sanity.h"
|
||||
|
||||
static bool initialized = false;
|
||||
|
||||
static struct var {
|
||||
const char *name;
|
||||
const char *default_value;
|
||||
const char *value;
|
||||
bool can_be_empty;
|
||||
} vars[] = {
|
||||
{ "atf_build_cc", ATF_BUILD_CC, NULL, false, },
|
||||
{ "atf_build_cflags", ATF_BUILD_CFLAGS, NULL, true, },
|
||||
{ "atf_build_cpp", ATF_BUILD_CPP, NULL, false, },
|
||||
{ "atf_build_cppflags", ATF_BUILD_CPPFLAGS, NULL, true, },
|
||||
{ "atf_build_cxx", ATF_BUILD_CXX, NULL, false, },
|
||||
{ "atf_build_cxxflags", ATF_BUILD_CXXFLAGS, NULL, true, },
|
||||
{ "atf_includedir", ATF_INCLUDEDIR, NULL, false, },
|
||||
{ "atf_libexecdir", ATF_LIBEXECDIR, NULL, false, },
|
||||
{ "atf_pkgdatadir", ATF_PKGDATADIR, NULL, false, },
|
||||
{ "atf_shell", ATF_SHELL, NULL, false, },
|
||||
{ "atf_workdir", ATF_WORKDIR, NULL, false, },
|
||||
{ NULL, NULL, NULL, false, },
|
||||
};
|
||||
|
||||
/* Only used for unit testing, so this prototype is private. */
|
||||
void __atf_config_reinit(void);
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Auxiliary functions.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
static
|
||||
char *
|
||||
string_to_upper(const char *str)
|
||||
{
|
||||
char *uc;
|
||||
|
||||
uc = (char *)malloc(strlen(str) + 1);
|
||||
if (uc != NULL) {
|
||||
char *ucptr = uc;
|
||||
while (*str != '\0') {
|
||||
*ucptr = toupper((int)*str);
|
||||
|
||||
str++;
|
||||
ucptr++;
|
||||
}
|
||||
*ucptr = '\0';
|
||||
}
|
||||
|
||||
return uc;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
initialize_var(struct var *var, const char *envname)
|
||||
{
|
||||
PRE(var->value == NULL);
|
||||
|
||||
if (atf_env_has(envname)) {
|
||||
const char *val = atf_env_get(envname);
|
||||
if (strlen(val) > 0 || var->can_be_empty)
|
||||
var->value = val;
|
||||
else
|
||||
var->value = var->default_value;
|
||||
} else
|
||||
var->value = var->default_value;
|
||||
|
||||
POST(var->value != NULL);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
initialize(void)
|
||||
{
|
||||
struct var *var;
|
||||
|
||||
PRE(!initialized);
|
||||
|
||||
for (var = vars; var->name != NULL; var++) {
|
||||
char *envname;
|
||||
|
||||
envname = string_to_upper(var->name);
|
||||
initialize_var(var, envname);
|
||||
free(envname);
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Free functions.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
const char *
|
||||
atf_config_get(const char *name)
|
||||
{
|
||||
const struct var *var;
|
||||
const char *value;
|
||||
|
||||
if (!initialized) {
|
||||
initialize();
|
||||
INV(initialized);
|
||||
}
|
||||
|
||||
value = NULL;
|
||||
for (var = vars; value == NULL && var->name != NULL; var++)
|
||||
if (strcmp(var->name, name) == 0)
|
||||
value = var->value;
|
||||
INV(value != NULL);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void
|
||||
__atf_config_reinit(void)
|
||||
{
|
||||
struct var *var;
|
||||
|
||||
initialized = false;
|
||||
|
||||
for (var = vars; var->name != NULL; var++)
|
||||
var->value = NULL;
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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(ATF_C_CONFIG_H)
|
||||
#define ATF_C_CONFIG_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
const char *atf_config_get(const char *);
|
||||
|
||||
#endif /* !defined(ATF_C_CONFIG_H) */
|
|
@ -1,152 +0,0 @@
|
|||
/*
|
||||
* 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
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include "atf-c/config.h"
|
||||
|
||||
#include "detail/env.h"
|
||||
#include "detail/test_helpers.h"
|
||||
|
||||
static const char *test_value = "env-value";
|
||||
|
||||
static struct varnames {
|
||||
const char *lc;
|
||||
const char *uc;
|
||||
bool can_be_empty;
|
||||
} all_vars[] = {
|
||||
{ "atf_build_cc", "ATF_BUILD_CC", false },
|
||||
{ "atf_build_cflags", "ATF_BUILD_CFLAGS", true },
|
||||
{ "atf_build_cpp", "ATF_BUILD_CPP", false },
|
||||
{ "atf_build_cppflags", "ATF_BUILD_CPPFLAGS", true },
|
||||
{ "atf_build_cxx", "ATF_BUILD_CXX", false },
|
||||
{ "atf_build_cxxflags", "ATF_BUILD_CXXFLAGS", true },
|
||||
{ "atf_includedir", "ATF_INCLUDEDIR", false },
|
||||
{ "atf_libexecdir", "ATF_LIBEXECDIR", false },
|
||||
{ "atf_pkgdatadir", "ATF_PKGDATADIR", false },
|
||||
{ "atf_shell", "ATF_SHELL", false },
|
||||
{ "atf_workdir", "ATF_WORKDIR", false },
|
||||
{ NULL, NULL, false }
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Auxiliary functions.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
void __atf_config_reinit(void);
|
||||
|
||||
static
|
||||
void
|
||||
unset_all(void)
|
||||
{
|
||||
const struct varnames *v;
|
||||
for (v = all_vars; v->lc != NULL; v++)
|
||||
RE(atf_env_unset(v->uc));
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
compare_one(const char *var, const char *expvalue)
|
||||
{
|
||||
const struct varnames *v;
|
||||
|
||||
printf("Checking that %s is set to %s\n", var, expvalue);
|
||||
|
||||
for (v = all_vars; v->lc != NULL; v++) {
|
||||
if (strcmp(v->lc, var) == 0)
|
||||
ATF_CHECK_STREQ(atf_config_get(v->lc), test_value);
|
||||
else
|
||||
ATF_CHECK(strcmp(atf_config_get(v->lc), test_value) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Test cases for the free functions.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
ATF_TC(get);
|
||||
ATF_TC_HEAD(get, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Tests the atf_config_get function");
|
||||
}
|
||||
ATF_TC_BODY(get, tc)
|
||||
{
|
||||
const struct varnames *v;
|
||||
|
||||
/* Unset all known environment variables and make sure the built-in
|
||||
* values do not match the bogus value we will use for testing. */
|
||||
unset_all();
|
||||
__atf_config_reinit();
|
||||
for (v = all_vars; v->lc != NULL; v++)
|
||||
ATF_CHECK(strcmp(atf_config_get(v->lc), test_value) != 0);
|
||||
|
||||
/* Test the behavior of empty values. */
|
||||
for (v = all_vars; v->lc != NULL; v++) {
|
||||
unset_all();
|
||||
if (strcmp(atf_config_get(v->lc), "") != 0) {
|
||||
RE(atf_env_set(v->uc, ""));
|
||||
__atf_config_reinit();
|
||||
if (v->can_be_empty)
|
||||
ATF_CHECK(strlen(atf_config_get(v->lc)) == 0);
|
||||
else
|
||||
ATF_CHECK(strlen(atf_config_get(v->lc)) > 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if every variable is recognized individually. */
|
||||
for (v = all_vars; v->lc != NULL; v++) {
|
||||
unset_all();
|
||||
RE(atf_env_set(v->uc, test_value));
|
||||
__atf_config_reinit();
|
||||
compare_one(v->lc, test_value);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Tests cases for the header file.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
HEADER_TC(include, "atf-c/config.h");
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Main.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
ATF_TP_ADD_TC(tp, get);
|
||||
|
||||
/* Add the test cases for the header file. */
|
||||
ATF_TP_ADD_TC(tp, include);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,8 +21,7 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#if !defined(ATF_C_DEFS_H)
|
||||
#define ATF_C_DEFS_H
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,8 +21,9 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/dynstr.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -34,12 +32,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "atf-c/detail/sanity.h"
|
||||
#include "atf-c/detail/text.h"
|
||||
#include "atf-c/error.h"
|
||||
|
||||
#include "dynstr.h"
|
||||
#include "sanity.h"
|
||||
#include "text.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Auxiliary functions.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,11 +21,10 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#if !defined(ATF_C_DYNSTR_H)
|
||||
#define ATF_C_DYNSTR_H
|
||||
#if !defined(ATF_C_DETAIL_DYNSTR_H)
|
||||
#define ATF_C_DETAIL_DYNSTR_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -78,4 +74,4 @@ atf_error_t atf_dynstr_prepend_fmt(atf_dynstr_t *, const char *, ...);
|
|||
bool atf_equal_dynstr_cstring(const atf_dynstr_t *, const char *);
|
||||
bool atf_equal_dynstr_dynstr(const atf_dynstr_t *, const atf_dynstr_t *);
|
||||
|
||||
#endif /* ATF_C_DYNSTR_H */
|
||||
#endif /* !defined(ATF_C_DETAIL_DYNSTR_H) */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,8 +21,9 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/dynstr.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
|
@ -35,8 +33,7 @@
|
|||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include "dynstr.h"
|
||||
#include "test_helpers.h"
|
||||
#include "atf-c/detail/test_helpers.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Tests for the "atf_dynstr" type.
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2007 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
|
||||
|
@ -24,22 +21,21 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/env.h"
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "bconfig.h"
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "atf-c/detail/sanity.h"
|
||||
#include "atf-c/detail/text.h"
|
||||
#include "atf-c/error.h"
|
||||
|
||||
#include "env.h"
|
||||
#include "sanity.h"
|
||||
#include "text.h"
|
||||
|
||||
const char *
|
||||
atf_env_get(const char *name)
|
||||
{
|
||||
|
@ -48,6 +44,16 @@ atf_env_get(const char *name)
|
|||
return val;
|
||||
}
|
||||
|
||||
const char *
|
||||
atf_env_get_with_default(const char *name, const char *default_value)
|
||||
{
|
||||
const char* val = getenv(name);
|
||||
if (val == NULL)
|
||||
return default_value;
|
||||
else
|
||||
return val;
|
||||
}
|
||||
|
||||
bool
|
||||
atf_env_has(const char *name)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,19 +21,19 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#if !defined(ATF_C_ENV_H)
|
||||
#define ATF_C_ENV_H
|
||||
#if !defined(ATF_C_DETAIL_ENV_H)
|
||||
#define ATF_C_DETAIL_ENV_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <atf-c/error_fwd.h>
|
||||
|
||||
const char *atf_env_get(const char *);
|
||||
const char *atf_env_get_with_default(const char *, const char *);
|
||||
bool atf_env_has(const char *);
|
||||
atf_error_t atf_env_set(const char *, const char *);
|
||||
atf_error_t atf_env_unset(const char *);
|
||||
|
||||
#endif /* !defined(ATF_C_ENV_H) */
|
||||
#endif /* !defined(ATF_C_DETAIL_ENV_H) */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2007 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
|
||||
|
@ -24,17 +21,17 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/env.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include "env.h"
|
||||
#include "test_helpers.h"
|
||||
#include "text.h"
|
||||
#include "atf-c/detail/test_helpers.h"
|
||||
#include "atf-c/detail/text.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Test cases for the free functions.
|
||||
|
@ -67,6 +64,25 @@ ATF_TC_BODY(get, tc)
|
|||
ATF_REQUIRE(strchr(val, ':') != NULL);
|
||||
}
|
||||
|
||||
ATF_TC(get_with_default);
|
||||
ATF_TC_HEAD(get_with_default, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Tests the atf_env_get_with_default "
|
||||
"function");
|
||||
}
|
||||
ATF_TC_BODY(get_with_default, tc)
|
||||
{
|
||||
const char *val;
|
||||
|
||||
ATF_REQUIRE(atf_env_has("PATH"));
|
||||
|
||||
val = atf_env_get_with_default("PATH", "unknown");
|
||||
ATF_REQUIRE(strcmp(val, "unknown") != 0);
|
||||
|
||||
val = atf_env_get_with_default("_UNKNOWN_VARIABLE_", "foo bar");
|
||||
ATF_REQUIRE(strcmp(val, "foo bar") == 0);
|
||||
}
|
||||
|
||||
ATF_TC(set);
|
||||
ATF_TC_HEAD(set, tc)
|
||||
{
|
||||
|
@ -109,6 +125,7 @@ ATF_TP_ADD_TCS(tp)
|
|||
{
|
||||
ATF_TP_ADD_TC(tp, has);
|
||||
ATF_TP_ADD_TC(tp, get);
|
||||
ATF_TP_ADD_TC(tp, get_with_default);
|
||||
ATF_TP_ADD_TC(tp, set);
|
||||
ATF_TP_ADD_TC(tp, unset);
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2007 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
|
||||
|
@ -24,11 +21,12 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/fs.h"
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "bconfig.h"
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -47,13 +45,11 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "atf-c/defs.h"
|
||||
#include "atf-c/detail/sanity.h"
|
||||
#include "atf-c/detail/text.h"
|
||||
#include "atf-c/detail/user.h"
|
||||
#include "atf-c/error.h"
|
||||
|
||||
#include "fs.h"
|
||||
#include "sanity.h"
|
||||
#include "text.h"
|
||||
#include "user.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Prototypes for auxiliary functions.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,11 +21,10 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#if !defined(ATF_C_FS_H)
|
||||
#define ATF_C_FS_H
|
||||
#if !defined(ATF_C_DETAIL_FS_H)
|
||||
#define ATF_C_DETAIL_FS_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -36,10 +32,9 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <atf-c/detail/dynstr.h>
|
||||
#include <atf-c/error_fwd.h>
|
||||
|
||||
#include "dynstr.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* The "atf_fs_path" type.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
@ -130,4 +125,4 @@ atf_error_t atf_fs_mkstemp(atf_fs_path_t *, int *);
|
|||
atf_error_t atf_fs_rmdir(const atf_fs_path_t *);
|
||||
atf_error_t atf_fs_unlink(const atf_fs_path_t *);
|
||||
|
||||
#endif /* !defined(ATF_C_FS_H) */
|
||||
#endif /* !defined(ATF_C_DETAIL_FS_H) */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2007 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
|
||||
|
@ -24,8 +21,9 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/fs.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -39,9 +37,8 @@
|
|||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include "fs.h"
|
||||
#include "test_helpers.h"
|
||||
#include "user.h"
|
||||
#include "atf-c/detail/test_helpers.h"
|
||||
#include "atf-c/detail/user.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Auxiliary functions.
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,18 +21,17 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/list.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "atf-c/detail/sanity.h"
|
||||
#include "atf-c/error.h"
|
||||
#include "atf-c/utils.h"
|
||||
|
||||
#include "list.h"
|
||||
#include "sanity.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Auxiliary functions.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,11 +21,10 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#if !defined(ATF_C_LIST_H)
|
||||
#define ATF_C_LIST_H
|
||||
#if !defined(ATF_C_DETAIL_LIST_H)
|
||||
#define ATF_C_DETAIL_LIST_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -112,4 +108,4 @@ void atf_list_append_list(atf_list_t *, atf_list_t *);
|
|||
!atf_equal_list_citer_list_citer((iter), atf_list_end_c(list)); \
|
||||
iter = atf_list_citer_next(iter))
|
||||
|
||||
#endif /* ATF_C_LIST_H */
|
||||
#endif /* !defined(ATF_C_DETAIL_LIST_H) */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,19 +21,18 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/list.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include "atf-c/detail/test_helpers.h"
|
||||
#include "atf-c/utils.h"
|
||||
|
||||
#include "list.h"
|
||||
#include "test_helpers.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Tests for the "atf_list" type.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,19 +21,18 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/map.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "atf-c/detail/sanity.h"
|
||||
#include "atf-c/error.h"
|
||||
#include "atf-c/utils.h"
|
||||
|
||||
#include "map.h"
|
||||
#include "sanity.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Auxiliary functions.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,19 +21,17 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#if !defined(ATF_C_MAP_H)
|
||||
#define ATF_C_MAP_H
|
||||
#if !defined(ATF_C_DETAIL_MAP_H)
|
||||
#define ATF_C_DETAIL_MAP_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <atf-c/detail/list.h>
|
||||
#include <atf-c/error_fwd.h>
|
||||
|
||||
#include "list.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* The "atf_map_citer" type.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
@ -116,4 +111,4 @@ atf_error_t atf_map_insert(atf_map_t *, const char *, void *, bool);
|
|||
!atf_equal_map_citer_map_citer((iter), atf_map_end_c(map)); \
|
||||
iter = atf_map_citer_next(iter))
|
||||
|
||||
#endif /* ATF_C_MAP_H */
|
||||
#endif /* !defined(ATF_C_DETAIL_MAP_H) */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,19 +21,18 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/map.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include "atf-c/detail/test_helpers.h"
|
||||
#include "atf-c/utils.h"
|
||||
|
||||
#include "map.h"
|
||||
#include "test_helpers.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Tests for the "atf_map" type.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2007 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
|
||||
|
@ -24,8 +21,9 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/process.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
@ -38,11 +36,9 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "atf-c/defs.h"
|
||||
#include "atf-c/detail/sanity.h"
|
||||
#include "atf-c/error.h"
|
||||
|
||||
#include "process.h"
|
||||
#include "sanity.h"
|
||||
|
||||
/* This prototype is not in the header file because this is a private
|
||||
* function; however, we need to access it during testing. */
|
||||
atf_error_t atf_process_status_init(atf_process_status_t *, int);
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,21 +21,19 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#if !defined(ATF_C_PROCESS_H)
|
||||
#define ATF_C_PROCESS_H
|
||||
#if !defined(ATF_C_DETAIL_PROCESS_H)
|
||||
#define ATF_C_DETAIL_PROCESS_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <atf-c/detail/fs.h>
|
||||
#include <atf-c/detail/list.h>
|
||||
#include <atf-c/error_fwd.h>
|
||||
|
||||
#include "fs.h"
|
||||
#include "list.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* The "atf_process_stream" type.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
@ -133,4 +128,4 @@ atf_error_t atf_process_exec_list(atf_process_status_t *,
|
|||
const atf_process_stream_t *,
|
||||
void (*)(void));
|
||||
|
||||
#endif /* !defined(ATF_C_PROCESS_H) */
|
||||
#endif /* !defined(ATF_C_DETAIL_PROCESS_H) */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,8 +21,7 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,8 +21,9 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/process.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
|
@ -43,10 +41,8 @@
|
|||
#include <atf-c.h>
|
||||
|
||||
#include "atf-c/defs.h"
|
||||
|
||||
#include "process.h"
|
||||
#include "sanity.h"
|
||||
#include "test_helpers.h"
|
||||
#include "atf-c/detail/sanity.h"
|
||||
#include "atf-c/detail/test_helpers.h"
|
||||
|
||||
atf_error_t atf_process_status_init(atf_process_status_t *, int);
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,11 +21,12 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/sanity.h"
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "bconfig.h"
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <err.h>
|
||||
|
@ -36,8 +34,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sanity.h"
|
||||
|
||||
static
|
||||
void
|
||||
fail(const char *fmt, ...)
|
||||
|
@ -53,7 +49,7 @@ fail(const char *fmt, ...)
|
|||
warnx("This is probably a bug in this application or one of the "
|
||||
"libraries it uses. If you believe this problem is caused "
|
||||
"by, or is related to " PACKAGE_STRING ", please report it "
|
||||
"to " PACKAGE_BUGREPORT " and provide as many detatils as "
|
||||
"to " PACKAGE_BUGREPORT " and provide as many details as "
|
||||
"possible describing how you got to this condition.");
|
||||
|
||||
abort();
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,11 +21,10 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#if !defined(ATF_C_SANITY_H)
|
||||
#define ATF_C_SANITY_H
|
||||
#if !defined(ATF_C_DETAIL_SANITY_H)
|
||||
#define ATF_C_DETAIL_SANITY_H
|
||||
|
||||
void atf_sanity_inv(const char *, int, const char *);
|
||||
void atf_sanity_pre(const char *, int, const char *);
|
||||
|
@ -70,4 +66,4 @@ void atf_sanity_post(const char *, int, const char *);
|
|||
|
||||
#define UNREACHABLE INV(0)
|
||||
|
||||
#endif /* ATF_C_SANITY_H */
|
||||
#endif /* !defined(ATF_C_DETAIL_SANITY_H) */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,11 +21,12 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/sanity.h"
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "bconfig.h"
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -42,10 +40,9 @@
|
|||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include "dynstr.h"
|
||||
#include "process.h"
|
||||
#include "sanity.h"
|
||||
#include "test_helpers.h"
|
||||
#include "atf-c/detail/dynstr.h"
|
||||
#include "atf-c/detail/process.h"
|
||||
#include "atf-c/detail/test_helpers.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Auxiliary functions.
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,24 +21,24 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/test_helpers.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include "atf-c/build.h"
|
||||
#include "atf-c/check.h"
|
||||
#include "atf-c/config.h"
|
||||
#include "atf-c/detail/dynstr.h"
|
||||
#include "atf-c/detail/env.h"
|
||||
#include "atf-c/detail/fs.h"
|
||||
#include "atf-c/detail/process.h"
|
||||
#include "atf-c/error.h"
|
||||
#include "atf-c/macros.h"
|
||||
|
||||
#include "dynstr.h"
|
||||
#include "fs.h"
|
||||
#include "process.h"
|
||||
#include "test_helpers.h"
|
||||
|
||||
bool
|
||||
build_check_c_o(const char *path)
|
||||
|
@ -50,7 +47,8 @@ build_check_c_o(const char *path)
|
|||
atf_dynstr_t iflag;
|
||||
const char *optargs[4];
|
||||
|
||||
RE(atf_dynstr_init_fmt(&iflag, "-I%s", atf_config_get("atf_includedir")));
|
||||
RE(atf_dynstr_init_fmt(&iflag, "-I%s", atf_env_get_with_default(
|
||||
"ATF_INCLUDEDIR", ATF_INCLUDEDIR)));
|
||||
|
||||
optargs[0] = atf_dynstr_cstring(&iflag);
|
||||
optargs[1] = "-Wall";
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,18 +21,20 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#if defined(TESTS_ATF_ATF_C_TEST_HELPERS_H)
|
||||
#if defined(ATF_C_DETAIL_TEST_HELPERS_H)
|
||||
# error "Cannot include test_helpers.h more than once."
|
||||
#else
|
||||
# define TESTS_ATF_ATF_C_TEST_HELPERS_H
|
||||
# define ATF_C_DETAIL_TEST_HELPERS_H
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "atf-c/error_fwd.h"
|
||||
#include <atf-c.h>
|
||||
|
||||
#include <atf-c/error_fwd.h>
|
||||
#include <atf-c/tc.h>
|
||||
|
||||
struct atf_dynstr;
|
||||
struct atf_fs_path;
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,20 +21,19 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/text.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "atf-c/detail/dynstr.h"
|
||||
#include "atf-c/detail/sanity.h"
|
||||
#include "atf-c/error.h"
|
||||
|
||||
#include "dynstr.h"
|
||||
#include "sanity.h"
|
||||
#include "text.h"
|
||||
|
||||
atf_error_t
|
||||
atf_text_for_each_word(const char *instr, const char *sep,
|
||||
atf_error_t (*func)(const char *, void *),
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,19 +21,17 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#if !defined(ATF_C_TEXT_H)
|
||||
#define ATF_C_TEXT_H
|
||||
#if !defined(ATF_C_DETAIL_TEXT_H)
|
||||
#define ATF_C_DETAIL_TEXT_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <atf-c/detail/list.h>
|
||||
#include <atf-c/error_fwd.h>
|
||||
|
||||
#include "list.h"
|
||||
|
||||
atf_error_t atf_text_for_each_word(const char *, const char *,
|
||||
atf_error_t (*)(const char *, void *),
|
||||
void *);
|
||||
|
@ -46,4 +41,4 @@ atf_error_t atf_text_split(const char *, const char *, atf_list_t *);
|
|||
atf_error_t atf_text_to_bool(const char *, bool *);
|
||||
atf_error_t atf_text_to_long(const char *, long *);
|
||||
|
||||
#endif /* ATF_C_TEXT_H */
|
||||
#endif /* !defined(ATF_C_DETAIL_TEXT_H) */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,8 +21,9 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/text.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -33,9 +31,8 @@
|
|||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include "sanity.h"
|
||||
#include "test_helpers.h"
|
||||
#include "text.h"
|
||||
#include "atf-c/detail/sanity.h"
|
||||
#include "atf-c/detail/test_helpers.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Auxiliary functions.
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,11 +21,10 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "bconfig.h"
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
|
@ -38,17 +34,16 @@
|
|||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "atf-c/detail/dynstr.h"
|
||||
#include "atf-c/detail/env.h"
|
||||
#include "atf-c/detail/fs.h"
|
||||
#include "atf-c/detail/map.h"
|
||||
#include "atf-c/detail/sanity.h"
|
||||
#include "atf-c/error.h"
|
||||
#include "atf-c/tc.h"
|
||||
#include "atf-c/tp.h"
|
||||
#include "atf-c/utils.h"
|
||||
|
||||
#include "dynstr.h"
|
||||
#include "env.h"
|
||||
#include "fs.h"
|
||||
#include "map.h"
|
||||
#include "sanity.h"
|
||||
|
||||
#if defined(HAVE_GNU_GETOPT)
|
||||
# define GETOPT_POSIX "+"
|
||||
#else
|
||||
|
@ -499,7 +494,7 @@ run_tc(const atf_tp_t *tp, struct params *p, int *exitcode)
|
|||
if (!atf_env_has("__RUNNING_INSIDE_ATF_RUN") || strcmp(atf_env_get(
|
||||
"__RUNNING_INSIDE_ATF_RUN"), "internal-yes-value") != 0)
|
||||
{
|
||||
print_warning("Running test cases without atf-run(1) is unsupported");
|
||||
print_warning("Running test cases outside of kyua(1) is unsupported");
|
||||
print_warning("No isolation nor timeout control is being applied; you "
|
||||
"may get unexpected failures; see atf-test-case(4)");
|
||||
}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2007 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
|
||||
|
@ -24,16 +21,16 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/user.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sanity.h"
|
||||
#include "user.h"
|
||||
#include "atf-c/detail/sanity.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Free functions.
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2007 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
|
||||
|
@ -24,11 +21,10 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#if !defined(ATF_C_USER_H)
|
||||
#define ATF_C_USER_H
|
||||
#if !defined(ATF_C_DETAIL_USER_H)
|
||||
#define ATF_C_DETAIL_USER_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
|
@ -46,4 +42,4 @@ bool atf_user_is_member_of_group(gid_t);
|
|||
bool atf_user_is_root(void);
|
||||
bool atf_user_is_unprivileged(void);
|
||||
|
||||
#endif /* !defined(ATF_C_USER_H) */
|
||||
#endif /* !defined(ATF_C_DETAIL_USER_H) */
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2007 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
|
||||
|
@ -24,8 +21,9 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/detail/user.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -36,8 +34,7 @@
|
|||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include "test_helpers.h"
|
||||
#include "user.h"
|
||||
#include "atf-c/detail/test_helpers.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Test cases for the free functions.
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "bconfig.h"
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2008 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
|
||||
|
@ -24,17 +21,16 @@
|
|||
* 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 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
||||
|
||||
#include "atf-c/error.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "atf-c/error.h"
|
||||
|
||||
#include "detail/sanity.h"
|
||||
#include "atf-c/detail/sanity.h"
|
||||
|
||||
/* Theoretically, there can only be a single error intance at any given
|
||||
* point in time, because errors are raised at one point and must be
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue