[v9_6] update to atf 0.17

3648.	[test]		Updated the ATF test framework to version 0.17.
			[RT #25627]
(cherry picked from commit a747113422)
(cherry picked from commit 72be0a630b)
This commit is contained in:
Evan Hunt 2013-09-12 16:22:36 -07:00
parent 17e856eff2
commit e38e023215
265 changed files with 11197 additions and 8320 deletions

View file

@ -1,3 +1,6 @@
3648. [test] Updated the ATF test framework to version 0.17.
[RT #25627]
3646. [bug] Journal filename string could be set incorrectly,
causing garbage in log messages. [RT #34738]

2
configure vendored
View file

@ -21868,7 +21868,7 @@ fi
/*) ;;
*) srcdir="../../$srcdir";;
esac
${SHELL} "${srcdir}${srcdir:+/unit/atf-src/}./configure" MISSING=: --prefix $atfdir;
${SHELL} "${srcdir}${srcdir:+/unit/atf-src/}./configure" --enable-tools --disable-shared MISSING=: --prefix $atfdir;
) ;;
"chmod":C) chmod a+x isc-config.sh doc/doxygen/doxygen-input-filter ;;

View file

@ -2791,7 +2791,7 @@ if test "$atf" = yes; then
/*) ;;
*) srcdir="../../$srcdir";;
esac
${SHELL} "${srcdir}${srcdir:+/unit/atf-src/}./configure" MISSING=: --prefix $atfdir;
${SHELL} "${srcdir}${srcdir:+/unit/atf-src/}./configure" --enable-tools --disable-shared MISSING=: --prefix $atfdir;
) ],
[atfdir=`pwd`/unit/atf])
AC_MSG_RESULT(building ATF from bind9/unit/atf-src)

View file

@ -1,2 +1,21 @@
These unit tests for BIND 9 are based on the NetBSD Automated Test Framework
release 0.12.
release 0.17.
To build an external copy of ATF for use by BIND 9:
$ cd atf-src
$ configure --prefix=<prefix> --enable-tools --disable-shared
$ make
$ make install
Subsequently, specify the ATF prefix when building BIND 9:
$ configure --with-atf=<prefix>
ATF can also be built automatically during the BIND 9 build,
by specifying --with-atf without an argument:
$ configure --with-atf
This causes BIND 9 to build ATF in the atf-src directory and
link to it directly.

View file

@ -20,6 +20,11 @@ Authors and contributors Automated Testing Framework
initial version of the atf-check utility and started the addition of the
ATF_REQUIRE family of macros in the C interface.
* Paul Goyette <pgoyette@NetBSD.org>
Implemented timestamping of test programs and test cases so that
atf-report can provide timings for their execution.
===========================================================================
vim: filetype=text:textwidth=75:expandtab:shiftwidth=2:softtabstop=2

View file

@ -6,6 +6,7 @@ tp: atf-c
tp: atf-c++
tp: atf-sh
tp: test-programs
tp: atf-config
tp: atf-report
tp: atf-run
tp-glob: atf-config*
tp-glob: atf-report*
tp-glob: atf-run*

View file

@ -5,7 +5,7 @@ Redistribution terms Automated Testing Framework
License
*******
Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
Copyright (c) 2007, 2008, 2009, 2010, 2011, 2012 The NetBSD Foundation, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -31,6 +31,36 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Copyright 2011, 2012 Google 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:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of Google Inc. nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
Relicensed code
***************

View file

@ -40,16 +40,7 @@ To build and use ATF successfully you need:
* A make(1) utility.
If you are building ATF from the code on the repository, you will also need
the following tools. The versions listed here are the ones used to build
the files bundled in the last formal release, but these are not strictly
required. Newer ones will most likely work and, maybe, some slightly older
ones:
* GNU autoconf 2.68
* GNU automake 1.11.1
* GNU libtool 2.2.6b
to have GNU autoconf, automake and libtool installed.
Regenerating the build system
@ -186,26 +177,35 @@ script:
and work directories for test cases. This is just a default and can be
overriden at run time.
* GDB
Possible values: empty, absolute path to GNU GDB.
Default: empty.
Specifies the path to the GNU GDB binary that atf-run will use to gather
a stack trace of a crashing test program. If empty, the configure script
will try to find a suitable binary for you.
The following flags are specific to ATF's 'configure' script:
* --enable-developer
Possible values: yes, no
Default: Depends on the version number. Stable versions define this to
'no' while all others have it set to 'yes'.
Default: 'yes' in Git HEAD builds; 'no' in formal releases.
Enables several features useful for development, such as the inclusion of
debugging symbols in all objects or the enabling of warnings during
compilation.
Enables several features useful for development, such as the inclusion
of debugging symbols in all objects or the enforcement of compilation
warnings.
* --enable-unstable-shared
The compiler will be executed with an exhaustive collection of warning
detection features regardless of the value of this flag. However, such
warnings are only fatal when --enable-developer is 'yes'.
* --enable-tools
Possible values: yes, no
Default: no.
Forces the building of shared libraries in addition to static ones. The
build of shared libraries is currently disabled because their ABIs and
APIs are unstable and subject to change. This flag is provided for
development purposes only and will be removed once the libraries are
stable enough.
Enables the build of the deprecated atf-config, atf-report, atf-run
and atf-version tools. atf-report and atf-run have been superseded by
Kyua, and atf-config and atf-version are unnecessary.
Post-installation steps

18
unit/atf-src/Kyuafile Normal file
View file

@ -0,0 +1,18 @@
syntax("kyuafile", 1)
test_suite("atf")
include("atf-c/Kyuafile")
include("atf-c++/Kyuafile")
include("atf-sh/Kyuafile")
include("test-programs/Kyuafile")
if fs.exists("atf-config/Kyuafile") then
include("atf-config/Kyuafile")
end
if fs.exists("atf-report/Kyuafile") then
include("atf-report/Kyuafile")
end
if fs.exists("atf-run/Kyuafile") then
include("atf-run/Kyuafile")
end

View file

@ -1,7 +1,7 @@
#
# Automated Testing Framework (atf)
#
# Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
# Copyright (c) 2007 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -27,6 +27,7 @@
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
atf_aclocal_DATA =
BUILT_SOURCES =
CLEANFILES =
EXTRA_DIST =
@ -38,21 +39,27 @@ libexec_PROGRAMS =
man_MANS =
noinst_DATA =
noinst_LTLIBRARIES =
INSTALLCHECK_TARGETS =
PHONY_TARGETS =
ACLOCAL_AMFLAGS = -I m4
AM_DISTCHECK_CONFIGURE_FLAGS = --enable-tools
include admin/Makefile.am.inc
include atf-c/Makefile.am.inc
include atf-c++/Makefile.am.inc
include atf-config/Makefile.am.inc
include atf-report/Makefile.am.inc
include atf-run/Makefile.am.inc
include atf-sh/Makefile.am.inc
include atf-version/Makefile.am.inc
include bootstrap/Makefile.am.inc
include doc/Makefile.am.inc
include test-programs/Makefile.am.inc
if ENABLE_TOOLS
include atf-report/Makefile.am.inc
include atf-config/Makefile.am.inc
include atf-run/Makefile.am.inc
include atf-version/Makefile.am.inc
endif
#
# Top-level distfile documents.
#
@ -69,10 +76,11 @@ TESTS_ENVIRONMENT = PATH=$(prefix)/bin:$${PATH} \
PKG_CONFIG_PATH=$(prefix)/lib/pkgconfig
testsdir = $(exec_prefix)/tests
pkgtestsdir = $(testsdir)/atf
pkgtestsdir = $(testsdir)/$(PACKAGE)
installcheck-local: installcheck-atf
.PHONY: installcheck-atf
if ENABLE_TOOLS
INSTALLCHECK_TARGETS += installcheck-atf
PHONY_TARGETS += installcheck-atf
installcheck-atf:
logfile=$$(pwd)/installcheck.log; \
fifofile=$$(pwd)/installcheck.fifo; \
@ -89,8 +97,23 @@ installcheck-atf:
"installcheck.log; exit was $${res}"; \
test $${res} -eq 0
CLEANFILES += installcheck.fifo installcheck.log
endif
pkgtests_DATA = Atffile
PHONY_TARGETS += installcheck-kyua
if HAVE_KYUA
if !ENABLE_TOOLS
INSTALLCHECK_TARGETS += installcheck-kyua
endif
installcheck-kyua:
cd $(pkgtestsdir) && $(TESTS_ENVIRONMENT) $(KYUA) test
endif
installcheck-local: $(INSTALLCHECK_TARGETS)
pkgtests_DATA = Kyuafile
if ENABLE_TOOLS
pkgtests_DATA += Atffile
endif
EXTRA_DIST += $(pkgtests_DATA)
BUILD_SH_TP = \
@ -103,19 +126,29 @@ BUILD_SH_TP = \
# Custom targets.
#
.PHONY: depend
depend:
dist-hook: forbid-dist
if ENABLE_TOOLS
forbid-dist:
@true
else
forbid-dist:
@echo "Sorry; cannot make dist without the tools enabled."
@echo "Please reconfigure with --enable-tools."
@false
endif
.PHONY: clean-all
PHONY_TARGETS += clean-all
clean-all:
MTN="$(MTN)" $(SH) $(srcdir)/admin/clean-all.sh
GIT="$(GIT)" $(SH) $(srcdir)/admin/clean-all.sh
.PHONY: release
PHONY_TARGETS += release
release:
$(SH) $(srcdir)/admin/release.sh $(PACKAGE_VERSION) $(DIST_ARCHIVES)
.PHONY: release-test
PHONY_TARGETS += release-test
release-test:
$(SH) $(srcdir)/admin/release-test.sh $(DIST_ARCHIVES)
.PHONY: $(PHONY_TARGETS)
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,187 @@ Major changes between releases Automated Testing Framework
===========================================================================
Changes in version 0.17
***********************
Experimental version released on February 14th, 2013.
* Added the atf_utils_cat_file, atf_utils_compare_file,
atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists,
atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string,
atf_utils_readline, atf_utils_redirect and atf_utils_wait utility
functions to atf-c-api. Documented the already-public
atf_utils_free_charpp function.
* Added the cat_file, compare_file, copy_file, create_file, file_exists,
fork, grep_collection, grep_file, grep_string, redirect and wait
functions to the atf::utils namespace of atf-c++-api. These are
wrappers around the same functions added to the atf-c-api library.
* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and
ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a
string against a regular expression.
* Miscellaneous fixes for manpage typos and compilation problems with
clang.
* Added caching of the results of those configure tests that rely on
executing a test program. This should help crossbuild systems by
providing a mechanism to pre-specify what the results should be.
* PR bin/45690: Make atf-report convert any non-printable characters to
a plain-text representation (matching their corresponding hexadecimal
entities) in XML output files. This is to prevent the output of test
cases from breaking xsltproc later.
Changes in version 0.16
***********************
Experimental version released on July 10th, 2012.
* Added a --enable-tools flag to configure to request the build of the
deprecated ATF tools, whose build is now disabled by default. In order
to continue running tests, you should migrate to Kyua instead of enabling
the build of the deprecated tools. The kyua-atf-compat package provides
transitional compatibility versions of atf-run and atf-report built on
top of Kyua.
* Tweaked the ATF_TEST_CASE macro of atf-c++ so that the compiler can
detect defined but unused test cases.
* PR bin/45859: Fixed some XSLT bugs that resulted in the tc-time and
tp-time XML tags leaking into the generated HTML file. Also improved
the CSS file slightly to correct alignment and color issues with the
timestamps column.
* Optimized atf-c++/macros.hpp so that GNU G++ consumes less memory during
compilation with GNU G++.
* Flipped the default to building shared libraries for atf-c and atf-c++,
and started versioning them. As a side-effect, this removes the
--enable-unstable-shared flag from configure that appears to not work any
more (under NetBSD). Additionally, some distributions require the use of
shared libraries for proper dependency tracking (e.g. Fedora), so it is
better if we do the right versioning upstream.
* Project hosting moved from an adhoc solution (custom web site and
Monotone repository) to Google Code (standard wiki and Git). ATF now
lives in a subcomponent of the Kyua project.
Changes in version 0.15
***********************
Experimental version released on January 16th, 2012.
* Respect stdin in atf-check. The previous release silenced stdin for any
processes spawned by atf, not only test programs, which caused breakage
in tests that pipe data through atf-check.
* Performance improvements to atf-sh.
* Enabled detection of unused parameters and variables in the code and
fixed all warnings.
* Changed the behavior of "developer mode". Compiler warnings are now
enabled unconditionally regardless of whether we are in developer mode or
not; developer mode is now only used to perform strict warning checks and
to enable assertions. Additionally, developer mode is now only
automatically enabled when building from the repository, not for formal
releases.
* Added new Autoconf M4 macros (ATF_ARG_WITH, ATF_CHECK_C and
ATF_CHECK_CXX) to provide a consistent way of defining a --with-arg flag
in configure scripts and detecting the presence of any of the ATF
bindings. Note that ATF_CHECK_SH was already introduced in 0.14, but it
has now been modified to also honor --with-atf if instantiated.
* Added timing support to atf-run / atf-report.
* Added support for a 'require.memory' property, to specify the minimum
amount of physical memory needed by the test case to yield valid results.
* PR bin/45690: Force an ISO-8859-1 encoding in the XML files generated by
atf-report so that invalid data in the output of test cases does not
mangle our report.
Changes in version 0.14
***********************
Experimental version released on June 14th, 2011.
* Added a pkg-config file for atf-sh and an aclocal file to ease the
detection of atf-sh from autoconf scripts.
* Made the default test case body defined by atf_sh fail. This is to
ensure that test cases are properly defined in test programs and helps
in catching typos in the names of the body functions.
* PR bin/44882: Made atf-run connect the stdin of test cases to /dev/zero.
This provides more consistent results with "normal" execution (in
particular, when tests are executed detached from a terminal).
* Made atf-run hardcode TZ=UTC for test cases. It used to undefine TZ, but
that does not take into account that libc determines the current timezone
from a configuration file.
* All test programs will now print a warning when they are not run through
atf-run(1) stating that this is unsupported and may deliver incorrect
results.
* Added support for the 'require.files' test-case property. This allows
test cases to specify installed files that must be present for the test
case to run.
Changes in version 0.13
***********************
Experimental version released on March 31st, 2011.
This is the first release after the creation of the Kyua project, a more
modular and reliable replacement for ATF. From now on, ATF will change to
accomodate the transition to this new codebase, but ATF will still continue
to see development in the short/medium term. Check out the project page at
http://code.google.com/p/kyua/ for more details.
The changes in this release are:
* Added support to run the tests with the Kyua runtime engine (kyua-cli), a
new package that aims to replace atf-run and atf-report. The ATF tests
can be run with the new system by issuing a 'make installcheck-kyua' from
the top-level directory of the project (assuming the 'kyua' binary is
available during the configuration stage of ATF).
* atf-run and atf-report are now in maintenance mode (but *not* deprecated
yet!). Kyua already implements a new, much more reliable runtime engine
that provides similar features to these tools. That said, it is not
complete yet so all development efforts should go towards it.
* If GDB is installed, atf-run dumps the stack trace of crashing test
programs in an attempt to aid debugging. Contributed by Antti Kantee.
* Reverted default timeout change in previous release and reset its value
to 5 minutes. This was causing several issues, specially when running
the existing NetBSD test suite in qemu.
* Fixed the 'match' output checker in atf-check to properly validate the
last line of a file even if it does not have a newline.
* Added the ATF_REQUIRE_IN and ATF_REQUIRE_NOT_IN macros to atf-c++ to
check for the presence (or lack thereof) of an element in a collection.
* PR bin/44176: Fixed a race condition in atf-run that would crash atf-run
when the cleanup of a test case triggered asynchronous modifications to
its work directory (e.g. killing a daemon process that cleans up a pid
file in the work directory).
* PR bin/44301: Fixed the sample XSLT file to report bogus test programs
instead of just listing them as having 0 test cases.
Changes in version 0.12
***********************

184
unit/atf-src/TODO Normal file
View file

@ -0,0 +1,184 @@
Things to do Automated Testing Framework
===========================================================================
Last revised: November 30th, 2010
This document includes the list of things that need to be done in ATF that
are most requested by the users. This information used to be available in
an ad-hoc bug tracker but that proved to be a bad idea. I have collected
all worthy comments in here.
Please note that most work these days is going into Kyua (see
http://code.google.com/p/kyua/). The ideas listed here apply to the
components of ATF that have *not* been migrated to the new codebase yet.
For bug reports or ideas that apply to the components that already have
been migrated, please use the bug tracker in the URL above. Similarly,
whenever a component is migrated, the ideas in this file should be revised
and migrated to the new bug tracker where appropriate.
---------------------------------------------------------------------------
Add build-time checks to atf-sh
The 0.7 release introduced build-time tests to atf-c and atf-c++, but not
to atf-sh. Expose the functionality to the shell interface.
This will probably require writing an atf-build utility that exposes the C
code and can be called from the shell.
---------------------------------------------------------------------------
Revisit what to do when an Atffile lists a non-existent file
---------------------------------------------------------------------------
Add ATF_CHECK* versions to atf-c++ to support non-fatal tests
---------------------------------------------------------------------------
Implement race-condition tests
gcooper:
I would think that stress/negative tests would be of more value than race
condition tests (they're similar, but not exactly the same in my mind).
In particular,
1. Feed through as much data as possible to determine where reporting
breaks down.
2. Feed through data quickly and terminate ASAP. The data should be
captured. Terminate child applications with unexpected exit codes and
signals (in particular, SIGCHLD, SIGPIPE, exit codes that terminate,
etc).
3. Open up a file descriptor in the test application, don't close the file
descriptor.
4. fork(2) a process; don't wait(2) for the application to complete.
There are other scenarios that could be exercised, but these are the ones
I could think of off the topic of my head.
--
jmmv:
1. The thing is: how do you express any of this in a portable/abstract
interface? How do you express that a test case "receives data"? What
does that exactly mean? I don't think the framework should care about
this: each test should be free to decide where its data is and how to
deal with it.
2. Ditto.
3. Not sure I understand your request, but testing for "unexpected exit
codes" is already supported. See wiki:DesignXFail for the feature
design details.
4. What's the problem with this case? The test case exits right away after
terminating the execution of its body; any open file descriptors,
leaked memory, etc. die with it.
5. forking and not waiting for a subprocess was a problem already
addressed.
I kinda have an idea of what Antti means with "race condition tests", but
every time I have tried to describe my understanding of matters I seem to
be wrong. Would be nice to have a clear description of what this involves;
in particular, what are the expectations from the framework and how should
the feature be exposed.
As of now, what I understand by "race condition test" is: a test case that
exercises a race condition. The test case may finish without triggering
the race, in which case it just exists with a successful status.
Otherwise, if the race triggers, the test case gets stuck and times out.
The result should be reported as an "expected failure" different from
timeout.
--
pooka:
Yup. Plus some atf-wide mechanism for the operator to supply some kind of
guideline if the test should try to trigger the race for a second or for
an hour.
--
jmmv:
Alright. While mocking up some code for this, I think that your two
requests are complementary.
On the one hand, when you are talking about a "race condition" test you
really mean an "expected race condition" test. Correct? If so, we need to
extend the xfail mechanism to add one more case, which is to report any
failures as a race condition error and, if there is no failure, report the
test as successful.
On the other hand, the atf-wide mechanism to support how long the test
should run for can be thought as a "stress test" mechanism. I.e. run this
test for X time / iterations and report its results regularly without
involving xfail at all.
So, with this in mind:
* For a test that triggers an unfixed race condition, you set xfail to
race mode and define the test as a stress test. Any failures are
reported as expected failures.
* For a test that verifies a supposedly-fixed race condition, you do *not*
set xfail to race mode, and only set the test to stress test. Any
failures are reported as real failures.
These stress test cases implement a single iteration of the test and
atf-run is in charge of running the test several times, stopping on the
first failure.
Does that make sense?
---------------------------------------------------------------------------
Implement ATF_REQUIRE_ERRNO
pooka:
Most of the lines in tests against system functionality are:
if (syscall(args) == -1)
atf_tc_fail_errno("flop")
Some shorthand would be helpful, like ATF_REQUIRE_ERRNO(syscall(args))
Also, a variant which allows arbitrary return value checks (e.g. "!= 0" or
"< 124" or "!= size") would be nice.
--
gcooper:
There's a problem with this request; not all functions fail in the same
way ... in particular compare the pthread family of functions (which
return errno) vs many native syscalls. Furthermore, compare some
fcntl-like syscalls vs other syscalls. One size fits all solutions may not
be a wise idea in this case, so I think that the problem statement needs
to be better defined, because the above request is too loose.
FWIW, there's also a TEST macro in LTP, which tests for non-zero status,
and sets an appropriate set of global variables for errnos and return
codes, respectively. It was a good idea, but has been mostly abandoned
because it's too difficult to define a success and failure in a universal
manner, so I think that we need to be careful with what's implemented in
ATF to not repeat the mistakes that others have made.
--
jmmv:
I think you've got a good point.
This was mostly intended to simplify the handling of the stupid errno
global variable. I think this is valuable to have, but maybe the
macro/function name should be different because _ERRNO can be confusing.
Probably something like an ATF_CHECK_LIBC / ATF_CHECK_PTHREAD approach
would be more flexible and simple.
===========================================================================
vim: filetype=text:textwidth=75:expandtab:shiftwidth=2:softtabstop=2

View file

@ -1,7 +1,7 @@
# generated automatically by aclocal 1.10.1 -*- Autoconf -*-
# generated automatically by aclocal 1.12.2 -*- Autoconf -*-
# Copyright (C) 1996-2012 Free Software Foundation, Inc.
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@ -13,28 +13,30 @@
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
m4_if(AC_AUTOCONF_VERSION, [2.67],,
[m4_warning([this file was generated for autoconf 2.67.
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
[m4_warning([this file was generated for autoconf 2.69.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically `autoreconf'.])])
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
# Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
# Copyright (C) 2002-2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 8
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
# generated from the m4 files accompanying Automake X.Y.
# (This private macro should not be called outside this file.)
AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.10'
[am__api_version='1.12'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.10.1], [],
m4_if([$1], [1.12.2], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
@ -48,24 +50,26 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.10.1])dnl
[AM_AUTOMAKE_VERSION([1.12.2])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)])
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
# Copyright (C) 2001-2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to
# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
#
# Of course, Automake must honor this variable whenever it calls a
# tool from the auxiliary directory. The problem is that $srcdir (and
@ -84,7 +88,7 @@ _AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)])
#
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
# are both prefixed by $srcdir. In an in-source build this is usually
# harmless because $srcdir is `.', but things will broke when you
# harmless because $srcdir is '.', but things will broke when you
# start a VPATH build or use an absolute $srcdir.
#
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
@ -110,26 +114,26 @@ am_aux_dir=`cd $ac_aux_dir && pwd`
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006
# Free Software Foundation, Inc.
# Copyright (C) 1997-2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 8
# serial 10
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_PREREQ(2.52)dnl
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
[AC_PREREQ([2.52])dnl
m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_SUBST([$1_TRUE])dnl
AC_SUBST([$1_FALSE])dnl
_AM_SUBST_NOTMAKE([$1_TRUE])dnl
_AM_SUBST_NOTMAKE([$1_FALSE])dnl
m4_define([_AM_COND_VALUE_$1], [$2])dnl
if $2; then
$1_TRUE=
$1_FALSE='#'
@ -143,16 +147,15 @@ AC_CONFIG_COMMANDS_PRE(
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
# Free Software Foundation, Inc.
# Copyright (C) 1999-2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 9
# serial 17
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
# written in clear, in which case automake, when reading aclocal.m4,
# will think it sees a *use*, and therefore will trigger all it's
# C support machinery. Also note that it means that autoscan, seeing
@ -162,7 +165,7 @@ fi])])
# _AM_DEPENDENCIES(NAME)
# ----------------------
# See how the compiler implements dependency checking.
# NAME is "CC", "CXX", "GCJ", or "OBJC".
# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
# We try a few techniques and use that to set a single cache variable.
#
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
@ -175,12 +178,13 @@ AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
AC_REQUIRE([AM_DEP_TRACK])dnl
ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
[$1], CXX, [depcc="$CXX" am_compiler_list=],
[$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
[$1], UPC, [depcc="$UPC" am_compiler_list=],
[$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
[depcc="$$1" am_compiler_list=])
m4_if([$1], [CC], [depcc="$CC" am_compiler_list=],
[$1], [CXX], [depcc="$CXX" am_compiler_list=],
[$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
[$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
[$1], [UPC], [depcc="$UPC" am_compiler_list=],
[$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
[depcc="$$1" am_compiler_list=])
AC_CACHE_CHECK([dependency style of $depcc],
[am_cv_$1_dependencies_compiler_type],
@ -188,8 +192,9 @@ AC_CACHE_CHECK([dependency style of $depcc],
# We make a subdir and do the tests there. Otherwise we can end up
# making bogus files that we don't know about and never remove. For
# instance it was reported that on HP-UX the gcc test will end up
# making a dummy file named `D' -- because `-MD' means `put the output
# in D'.
# making a dummy file named 'D' -- because '-MD' means "put the output
# in D".
rm -rf conftest.dir
mkdir conftest.dir
# Copy depcomp to subdir because otherwise we won't find it if we're
# using a relative directory.
@ -207,6 +212,16 @@ AC_CACHE_CHECK([dependency style of $depcc],
if test "$am_compiler_list" = ""; then
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
fi
am__universal=false
m4_case([$1], [CC],
[case " $depcc " in #(
*\ -arch\ *\ -arch\ *) am__universal=true ;;
esac],
[CXX],
[case " $depcc " in #(
*\ -arch\ *\ -arch\ *) am__universal=true ;;
esac])
for depmode in $am_compiler_list; do
# Setup a source with many dependencies, because some compilers
# like to wrap large dependency lists on column 80 (with \), and
@ -218,35 +233,49 @@ AC_CACHE_CHECK([dependency style of $depcc],
: > sub/conftest.c
for i in 1 2 3 4 5 6; do
echo '#include "conftst'$i'.h"' >> sub/conftest.c
# Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
# Solaris 8's {/usr,}/bin/sh.
touch sub/conftst$i.h
# Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
# Solaris 10 /bin/sh.
echo '/* dummy */' > sub/conftst$i.h
done
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
# We check with '-c' and '-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly
# handle '-M -o', and we need to detect this. Also, some Intel
# versions had trouble with output in subdirs.
am__obj=sub/conftest.${OBJEXT-o}
am__minus_obj="-o $am__obj"
case $depmode in
gcc)
# This depmode causes a compiler race in universal mode.
test "$am__universal" = false || continue
;;
nosideeffect)
# after this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested
# After this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested.
if test "x$enable_dependency_tracking" = xyes; then
continue
else
break
fi
;;
msvc7 | msvc7msys | msvisualcpp | msvcmsys)
# This compiler won't grok '-c -o', but also, the minuso test has
# not run yet. These depmodes are late enough in the game, and
# so weak that their functioning should not be impacted.
am__obj=conftest.${OBJEXT-o}
am__minus_obj=
;;
none) break ;;
esac
# We check with `-c' and `-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly
# handle `-M -o', and we need to detect this.
if depmode=$depmode \
source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
source=sub/conftest.c object=$am__obj \
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
$SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
$SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
>/dev/null 2>conftest.err &&
grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
# icc doesn't choke on unknown options, it will just issue warnings
# or remarks (even with -Werror). So we grep stderr for any message
@ -279,7 +308,7 @@ AM_CONDITIONAL([am__fastdep$1], [
# AM_SET_DEPDIR
# -------------
# Choose a directory name for dependency files.
# This macro is AC_REQUIREd in _AM_DEPENDENCIES
# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
AC_DEFUN([AM_SET_DEPDIR],
[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
@ -289,71 +318,86 @@ AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
# AM_DEP_TRACK
# ------------
AC_DEFUN([AM_DEP_TRACK],
[AC_ARG_ENABLE(dependency-tracking,
[ --disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors])
[AC_ARG_ENABLE([dependency-tracking], [dnl
AS_HELP_STRING(
[--enable-dependency-tracking],
[do not reject slow dependency extractors])
AS_HELP_STRING(
[--disable-dependency-tracking],
[speeds up one-time build])])
if test "x$enable_dependency_tracking" != xno; then
am_depcomp="$ac_aux_dir/depcomp"
AMDEPBACKSLASH='\'
am__nodep='_no'
fi
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
AC_SUBST([AMDEPBACKSLASH])dnl
_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
AC_SUBST([am__nodep])dnl
_AM_SUBST_NOTMAKE([am__nodep])dnl
])
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
# Copyright (C) 1999-2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
#serial 3
# serial 6
# _AM_OUTPUT_DEPENDENCY_COMMANDS
# ------------------------------
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
[for mf in $CONFIG_FILES; do
# Strip MF so we end up with the name of the file.
mf=`echo "$mf" | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile or not.
# We used to match only the files named `Makefile.in', but
# some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so.
# Grep'ing the whole file is not good either: AIX grep has a line
# limit of 2048, but all sed's we know have understand at least 4000.
if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
fi
# Extract the definition of DEPDIR, am__include, and am__quote
# from the Makefile without running `make'.
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
test -z "$DEPDIR" && continue
am__include=`sed -n 's/^am__include = //p' < "$mf"`
test -z "am__include" && continue
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
# When using ansi2knr, U may be empty or an underscore; expand it
U=`sed -n 's/^U = //p' < "$mf"`
# Find all dependency output files, they are included files with
# $(DEPDIR) in their names. We invoke sed twice because it is the
# simplest approach to changing $(DEPDIR) to its actual value in the
# expansion.
for file in `sed -n "
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
# Make sure the directory exists.
test -f "$dirpart/$file" && continue
fdir=`AS_DIRNAME(["$file"])`
AS_MKDIR_P([$dirpart/$fdir])
# echo "creating $dirpart/$file"
echo '# dummy' > "$dirpart/$file"
[{
# Autoconf 2.62 quotes --file arguments for eval, but not when files
# are listed without --file. Let's play safe and only enable the eval
# if we detect the quoting.
case $CONFIG_FILES in
*\'*) eval set x "$CONFIG_FILES" ;;
*) set x $CONFIG_FILES ;;
esac
shift
for mf
do
# Strip MF so we end up with the name of the file.
mf=`echo "$mf" | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile or not.
# We used to match only the files named 'Makefile.in', but
# some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so.
# Grep'ing the whole file is not good either: AIX grep has a line
# limit of 2048, but all sed's we know have understand at least 4000.
if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
fi
# Extract the definition of DEPDIR, am__include, and am__quote
# from the Makefile without running 'make'.
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
test -z "$DEPDIR" && continue
am__include=`sed -n 's/^am__include = //p' < "$mf"`
test -z "am__include" && continue
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
# Find all dependency output files, they are included files with
# $(DEPDIR) in their names. We invoke sed twice because it is the
# simplest approach to changing $(DEPDIR) to its actual value in the
# expansion.
for file in `sed -n "
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
# Make sure the directory exists.
test -f "$dirpart/$file" && continue
fdir=`AS_DIRNAME(["$file"])`
AS_MKDIR_P([$dirpart/$fdir])
# echo "creating $dirpart/$file"
echo '# dummy' > "$dirpart/$file"
done
done
done
}
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
@ -362,7 +406,7 @@ done
# This macro should only be invoked once -- use via AC_REQUIRE.
#
# This code is only required when automatic dependency tracking
# is enabled. FIXME. This creates each `.P' file that we will
# is enabled. FIXME. This creates each '.P' file that we will
# need in order to bootstrap the dependency handling code.
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
[AC_CONFIG_COMMANDS([depfiles],
@ -372,14 +416,13 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
# Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2008 Free Software Foundation, Inc.
# Copyright (C) 1996-2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 13
# serial 19
# This macro actually does too much. Some checks are only needed if
# your package does certain things. But this isn't really a big deal.
@ -396,7 +439,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
# arguments mandatory, and then we can depend on a new Autoconf
# release and drop the old call support.
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_PREREQ([2.60])dnl
[AC_PREREQ([2.62])dnl
dnl Autoconf wants to disallow AM_ names. We explicitly allow
dnl the ones we care about.
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
@ -425,55 +468,85 @@ AC_SUBST([CYGPATH_W])
# Define the identity of the package.
dnl Distinguish between old-style and new-style calls.
m4_ifval([$2],
[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
[AC_DIAGNOSE([obsolete],
[$0: two- and three-arguments forms are deprecated. For more info, see:
http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_INIT_AUTOMAKE-invocation])
m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
AC_SUBST([PACKAGE], [$1])dnl
AC_SUBST([VERSION], [$2])],
[_AM_SET_OPTIONS([$1])dnl
dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
m4_if(
m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
[ok:ok],,
[m4_fatal([AC_INIT should be called with package and version arguments])])dnl
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
_AM_IF_OPTION([no-define],,
[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
# Some tools Automake needs.
AC_REQUIRE([AM_SANITY_CHECK])dnl
AC_REQUIRE([AC_ARG_PROGRAM])dnl
AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
AM_MISSING_PROG(AUTOCONF, autoconf)
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
AM_MISSING_PROG(AUTOHEADER, autoheader)
AM_MISSING_PROG(MAKEINFO, makeinfo)
AM_PROG_INSTALL_SH
AM_PROG_INSTALL_STRIP
AC_REQUIRE([AM_PROG_MKDIR_P])dnl
AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
AM_MISSING_PROG([AUTOCONF], [autoconf])
AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
AM_MISSING_PROG([AUTOHEADER], [autoheader])
AM_MISSING_PROG([MAKEINFO], [makeinfo])
AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
AC_REQUIRE([AC_PROG_MKDIR_P])dnl
# For better backward compatibility. To be removed once Automake 1.9.x
# dies out for good. For more background, see:
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
[_AM_PROG_TAR([v7])])])
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
[_AM_PROG_TAR([v7])])])
_AM_IF_OPTION([no-dependencies],,
[AC_PROVIDE_IFELSE([AC_PROG_CC],
[_AM_DEPENDENCIES(CC)],
[define([AC_PROG_CC],
defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
[_AM_DEPENDENCIES([CC])],
[m4_define([AC_PROG_CC],
m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
AC_PROVIDE_IFELSE([AC_PROG_CXX],
[_AM_DEPENDENCIES(CXX)],
[define([AC_PROG_CXX],
defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
[_AM_DEPENDENCIES([CXX])],
[m4_define([AC_PROG_CXX],
m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
AC_PROVIDE_IFELSE([AC_PROG_OBJC],
[_AM_DEPENDENCIES(OBJC)],
[define([AC_PROG_OBJC],
defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
[_AM_DEPENDENCIES([OBJC])],
[m4_define([AC_PROG_OBJC],
m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
dnl Support for Objective C++ was only introduced in Autoconf 2.65,
dnl but we still cater to Autoconf 2.62.
m4_ifdef([AC_PROG_OBJCXX],
[AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
[_AM_DEPENDENCIES([OBJCXX])],
[m4_define([AC_PROG_OBJCXX],
m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])])dnl
])
_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
dnl The 'parallel-tests' driver may need to know about EXEEXT, so add the
dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro
dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
AC_CONFIG_COMMANDS_PRE(dnl
[m4_provide_if([_AM_COMPILER_EXEEXT],
[AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
])
dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
dnl mangled by Autoconf and run in a shell conditional statement.
m4_define([_AC_COMPILER_EXEEXT],
m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
# When config.status generates a header, we must update the stamp-h file.
# This file resides in the same directory as the config header
@ -496,21 +569,30 @@ for _am_header in $config_headers :; do
done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
# Copyright (C) 2001-2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 8
# AM_PROG_INSTALL_SH
# ------------------
# Define $install_sh.
AC_DEFUN([AM_PROG_INSTALL_SH],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
AC_SUBST(install_sh)])
if test x"${install_sh}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
*)
install_sh="\${SHELL} $am_aux_dir/install-sh"
esac
fi
AC_SUBST([install_sh])])
# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
# Copyright (C) 2003-2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -533,13 +615,13 @@ AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
# Copyright (C) 2001-2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 3
# serial 5
# AM_MAKE_INCLUDE()
# -----------------
@ -548,7 +630,7 @@ AC_DEFUN([AM_MAKE_INCLUDE],
[am_make=${MAKE-make}
cat > confinc << 'END'
am__doit:
@echo done
@echo this is the am__doit target
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
@ -558,24 +640,24 @@ am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# We grep out `Entering directory' and `Leaving directory'
# messages which can occur if `w' ends up in MAKEFLAGS.
# In particular we don't look at `^make:' because GNU make might
# be invoked under some other name (usually "gmake"), in which
# case it prints its new name instead of `make'.
if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
am__include=include
am__quote=
_am_result=GNU
fi
# Ignore all kinds of additional output from 'make'.
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
am__include=include
am__quote=
_am_result=GNU
;;
esac
# Now try BSD make style include.
if test "$am__include" = "#"; then
echo '.include "confinc"' > confmf
if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
am__include=.include
am__quote="\""
_am_result=BSD
fi
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
am__include=.include
am__quote="\""
_am_result=BSD
;;
esac
fi
AC_SUBST([am__include])
AC_SUBST([am__quote])
@ -583,14 +665,13 @@ AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005
# Free Software Foundation, Inc.
# Copyright (C) 1999-2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 5
# serial 6
# AM_PROG_CC_C_O
# --------------
@ -602,8 +683,9 @@ AC_REQUIRE_AUX_FILE([compile])dnl
# FIXME: we rely on the cache variable name because
# there is no other way.
set dummy $CC
ac_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']`
if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" != yes"; then
am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']`
eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
if test "$am_t" != yes; then
# Losing compiler, so override with the script.
# FIXME: It is wrong to rewrite CC.
# But if we don't then we get into trouble of one sort or another.
@ -619,14 +701,13 @@ m4_define([AC_PROG_CC],
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005
# Free Software Foundation, Inc.
# Copyright (C) 1997-2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 5
# serial 7
# AM_MISSING_PROG(NAME, PROGRAM)
# ------------------------------
@ -643,51 +724,32 @@ AC_SUBST($1)])
AC_DEFUN([AM_MISSING_HAS_RUN],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
AC_REQUIRE_AUX_FILE([missing])dnl
test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
if test x"${MISSING+set}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
*)
MISSING="\${SHELL} $am_aux_dir/missing" ;;
esac
fi
# Use eval to expand $SHELL
if eval "$MISSING --run true"; then
am_missing_run="$MISSING --run "
else
am_missing_run=
AC_MSG_WARN([`missing' script is too old or missing])
AC_MSG_WARN(['missing' script is too old or missing])
fi
])
# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_MKDIR_P
# ---------------
# Check for `mkdir -p'.
AC_DEFUN([AM_PROG_MKDIR_P],
[AC_PREREQ([2.60])dnl
AC_REQUIRE([AC_PROG_MKDIR_P])dnl
dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P,
dnl while keeping a definition of mkdir_p for backward compatibility.
dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
dnl Makefile.ins that do not define MKDIR_P, so we do our own
dnl adjustment using top_builddir (which is defined more often than
dnl MKDIR_P).
AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
case $mkdir_p in
[[\\/$]]* | ?:[[\\/]]*) ;;
*/*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
esac
])
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
# Copyright (C) 2001-2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 3
# serial 6
# _AM_MANGLE_OPTION(NAME)
# -----------------------
@ -695,16 +757,16 @@ AC_DEFUN([_AM_MANGLE_OPTION],
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
# _AM_SET_OPTION(NAME)
# ------------------------------
# --------------------
# Set option NAME. Presently that only means defining a flag for this option.
AC_DEFUN([_AM_SET_OPTION],
[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
# _AM_SET_OPTIONS(OPTIONS)
# ----------------------------------
# ------------------------
# OPTIONS is a space-separated list of Automake options.
AC_DEFUN([_AM_SET_OPTIONS],
[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
# -------------------------------------------
@ -714,45 +776,62 @@ AC_DEFUN([_AM_IF_OPTION],
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
# Free Software Foundation, Inc.
# Copyright (C) 1996-2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 4
# serial 9
# AM_SANITY_CHECK
# ---------------
AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftest.file
# Do `set' in a subshell so we don't clobber the current shell's
# Reject unsafe characters in $srcdir or the absolute working directory
# name. Accept space and tab only in the latter.
am_lf='
'
case `pwd` in
*[[\\\"\#\$\&\'\`$am_lf]]*)
AC_MSG_ERROR([unsafe absolute working directory name]);;
esac
case $srcdir in
*[[\\\"\#\$\&\'\`$am_lf\ \ ]]*)
AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
esac
# Do 'set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
if test "$[*]" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftest.file`
fi
rm -f conftest.file
if test "$[*]" != "X $srcdir/configure conftest.file" \
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
am_has_slept=no
for am_try in 1 2; do
echo "timestamp, slept: $am_has_slept" > conftest.file
set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
if test "$[*]" = "X"; then
# -L didn't work.
set X `ls -t "$srcdir/configure" conftest.file`
fi
if test "$[*]" != "X $srcdir/configure conftest.file" \
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
if test "$[2]" = conftest.file || test $am_try -eq 2; then
break
fi
# Just in case.
sleep 1
am_has_slept=yes
done
test "$[2]" = conftest.file
)
then
@ -762,51 +841,25 @@ else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
AC_MSG_RESULT(yes)])
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_STRIP
# ---------------------
# One issue with vendor `install' (even GNU) is that you can't
# specify the program used to strip binaries. This is especially
# annoying in cross-compiling environments, where the build's strip
# is unlikely to handle the host's binaries.
# Fortunately install-sh will honor a STRIPPROG variable, so we
# always use install-sh in `make install-strip', and initialize
# STRIPPROG with the value of the STRIP variable (set by the user).
AC_DEFUN([AM_PROG_INSTALL_STRIP],
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
# Installed binaries are usually stripped using `strip' when the user
# run `make install-strip'. However `strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake
# will honor the `STRIP' environment variable to overrule this program.
dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
if test "$cross_compiling" != no; then
AC_CHECK_TOOL([STRIP], [strip], :)
AC_MSG_RESULT([yes])
# If we didn't sleep, we still need to ensure time stamps of config.status and
# generated files are strictly newer.
am_sleep_pid=
if grep 'slept: no' conftest.file >/dev/null 2>&1; then
( sleep 1 ) &
am_sleep_pid=$!
fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
AC_CONFIG_COMMANDS_PRE(
[AC_MSG_CHECKING([that generated files are newer than configure])
if test -n "$am_sleep_pid"; then
# Hide warnings about reused PIDs.
wait $am_sleep_pid 2>/dev/null
fi
AC_MSG_RESULT([done])])
rm -f conftest.file
])
# Copyright (C) 2006 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# _AM_SUBST_NOTMAKE(VARIABLE)
# ---------------------------
# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
# This macro is traced by Automake.
AC_DEFUN([_AM_SUBST_NOTMAKE])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
# Copyright (C) 2001-2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -814,10 +867,61 @@ AC_DEFUN([_AM_SUBST_NOTMAKE])
# serial 2
# AM_PROG_INSTALL_STRIP
# ---------------------
# One issue with vendor 'install' (even GNU) is that you can't
# specify the program used to strip binaries. This is especially
# annoying in cross-compiling environments, where the build's strip
# is unlikely to handle the host's binaries.
# Fortunately install-sh will honor a STRIPPROG variable, so we
# always use install-sh in "make install-strip", and initialize
# STRIPPROG with the value of the STRIP variable (set by the user).
AC_DEFUN([AM_PROG_INSTALL_STRIP],
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
# Installed binaries are usually stripped using 'strip' when the user
# run "make install-strip". However 'strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake
# will honor the 'STRIP' environment variable to overrule this program.
dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
if test "$cross_compiling" != no; then
AC_CHECK_TOOL([STRIP], [strip], :)
fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Copyright (C) 2006-2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 3
# _AM_SUBST_NOTMAKE(VARIABLE)
# ---------------------------
# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
# This macro is traced by Automake.
AC_DEFUN([_AM_SUBST_NOTMAKE])
# AM_SUBST_NOTMAKE(VARIABLE)
# --------------------------
# Public sister of _AM_SUBST_NOTMAKE.
AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004-2012 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 3
# _AM_PROG_TAR(FORMAT)
# --------------------
# Check how to create a tarball in format FORMAT.
# FORMAT should be one of `v7', `ustar', or `pax'.
# FORMAT should be one of 'v7', 'ustar', or 'pax'.
#
# Substitute a variable $(am__tar) that is a command
# writing to stdout a FORMAT-tarball containing the directory
@ -828,10 +932,11 @@ AC_DEFUN([_AM_SUBST_NOTMAKE])
# a tarball read from stdin.
# $(am__untar) < result.tar
AC_DEFUN([_AM_PROG_TAR],
[# Always define AMTAR for backward compatibility.
AM_MISSING_PROG([AMTAR], [tar])
[# Always define AMTAR for backward compatibility. Yes, it's still used
# in the wild :-( We should find a proper way to deprecate it ...
AC_SUBST([AMTAR], ['$${TAR-tar}'])
m4_if([$1], [v7],
[am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
[am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
[m4_case([$1], [ustar],, [pax],,
[m4_fatal([Unknown tar format])])
AC_MSG_CHECKING([how to create a $1 tar archive])
@ -839,7 +944,7 @@ AC_MSG_CHECKING([how to create a $1 tar archive])
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
# Do not fold the above two line into one, because Tru64 sh and
# Solaris sh will not grok spaces in the rhs of `-'.
# Solaris sh will not grok spaces in the rhs of '-'.
for _am_tool in $_am_tools
do
case $_am_tool in

View file

@ -1,7 +1,7 @@
#
# Automated Testing Framework (atf)
#
# Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
# Copyright (c) 2007 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -27,18 +27,12 @@
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
dist-hook: check-install
.PHONY: check-install
check-install: $(srcdir)/INSTALL
$(srcdir)/admin/check-install.sh $(srcdir)/INSTALL
dist-hook: check-style
.PHONY: check-style
PHONY_TARGETS += check-style
check-style:
$(srcdir)/admin/check-style.sh
EXTRA_DIST += admin/check-install.sh \
admin/check-style-common.awk \
EXTRA_DIST += admin/check-style-common.awk \
admin/check-style-c.awk \
admin/check-style-cpp.awk \
admin/check-style-man.awk \

View file

@ -1,92 +0,0 @@
#! /bin/sh
#
# Automated Testing Framework (atf)
#
# Copyright (c) 2007, 2008, 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.
#
#
# A utility to ensure that INSTALL lists the correct versions of the
# tools used to generate the distfile.
#
Prog_Name=${0##*/}
#
# err message
#
err() {
echo "${Prog_Name}: ${@}" 1>&2
exit 1
}
#
# warn message
#
warn() {
echo "${Prog_Name}: ${@}" 1>&2
}
#
# check_tool readme_file prog_name verbose_name
#
# Executes 'prog_name' to determine its version and checks if the
# given 'readme_file' contains 'verbose_name <version>' in it.
#
check_tool() {
readme=${1}
prog=${2}
name=${3}
ver=$(${prog} --version | head -n 1 | cut -d ' ' -f 4)
if grep "\\* ${name} ${ver}" ${readme} >/dev/null; then
true
else
warn "Incorrect version of ${name}"
false
fi
}
#
# main readme_file
#
# Entry point.
#
main() {
readme=${1}
ret=0
check_tool ${readme} autoconf "GNU autoconf" || ret=1
check_tool ${readme} automake "GNU automake" || ret=1
check_tool ${readme} libtool "GNU libtool" || ret=1
return ${ret}
}
main "${@}"
# vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,7 +2,7 @@
#
# Automated Testing Framework (atf)
#
# Copyright (c) 2007, 2008, 2009 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
@ -91,6 +91,7 @@ find_sources() {
-name "*.c" -o \
-name "*.cpp" -o \
-name "*.h" -o \
-name "*.h.in" -o \
-name "*.hpp" -o \
-name "*.m4" -o \
-name "*.sh" \
@ -100,6 +101,7 @@ find_sources() {
-type f -a \
\! -name "aclocal.m4" \
\! -name "bconfig.h" \
\! -name "defs.h" \
\! -name "libtool.m4" \
\! -name "ltoptions.m4" \
\! -name "ltsugar.m4" \

View file

@ -1,10 +1,9 @@
#! /bin/sh
# Wrapper for compilers which do not understand `-c -o'.
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2009-10-06.20; # UTC
scriptversion=2012-03-05.13; # UTC
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software
# Foundation, Inc.
# Copyright (C) 1999-2012 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
@ -29,21 +28,219 @@ scriptversion=2009-10-06.20; # UTC
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand `-c -o'.
Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file `INSTALL'.
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
@ -53,11 +250,13 @@ EOF
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
eat=
for arg
do
@ -66,8 +265,8 @@ do
else
case $1 in
-o)
# configure might choose to run compile as `compile cc -o foo foo.c'.
# So we strip `-o arg' only if arg is an object.
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
@ -94,10 +293,10 @@ do
done
if test -z "$ofile" || test -z "$cfile"; then
# If no `-o' option was seen then we might have been invoked from a
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# `.c' file was seen then we are probably linking. That is also
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
@ -106,7 +305,7 @@ fi
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use `[/\\:.-]' here to ensure that we don't use the same name
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d

View file

@ -1,10 +1,9 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2009-04-28.21; # UTC
scriptversion=2012-03-27.16; # UTC
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
# Software Foundation, Inc.
# Copyright (C) 1999-2012 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -28,7 +27,7 @@ scriptversion=2009-04-28.21; # UTC
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
@ -40,11 +39,11 @@ as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by `PROGRAMS ARGS'.
object Object file output by `PROGRAMS ARGS'.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputing dependencies.
tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
@ -57,6 +56,12 @@ EOF
;;
esac
# A tabulation character.
tab=' '
# A newline character.
nl='
'
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
@ -90,10 +95,24 @@ if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u="sed s,\\\\\\\\,/,g"
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
@ -148,20 +167,21 @@ gcc)
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
tr ' ' "$nl" < "$tmpdepfile" |
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well.
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
@ -193,18 +213,15 @@ sgi)
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> "$depfile"
tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
@ -216,10 +233,17 @@ sgi)
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts `$object:' at the
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
@ -249,12 +273,11 @@ aix)
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
# Each line is of the form `foo.o: dependent.h'.
# Each line is of the form 'foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
# '$object: dependent.h' and one to simply 'dependent.h:'.
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
@ -265,23 +288,26 @@ aix)
;;
icc)
# Intel's C compiler understands `-MD -MF file'. However on
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'.
# However on
# $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# which is wrong. We want
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using \ :
# and will wrap long lines using '\':
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
# tcc 0.9.26 (FIXME still under development at the moment of writing)
# will emit a similar output, but also prepend the continuation lines
# with horizontal tabulation characters.
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
@ -290,15 +316,21 @@ icc)
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Each line is of the form 'foo.o: dependent.h',
# or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
sed -e 's/$/ :/' >> "$depfile"
# '$object: dependent.h' and one to simply 'dependent.h:'.
sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \
< "$tmpdepfile" > "$depfile"
sed '
s/[ '"$tab"'][ '"$tab"']*/ /g
s/^ *//
s/ *\\*$//
s/^[^:]*: *//
/^$/d
/:$/d
s/$/ :/
' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
@ -334,7 +366,7 @@ hp2)
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
# Add `dependent.h:' lines.
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
@ -349,9 +381,9 @@ hp2)
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
@ -397,14 +429,59 @@ tru64)
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test "$stat" = 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
@ -422,7 +499,7 @@ dashmstdout)
shift
fi
# Remove `-o $object'.
# Remove '-o $object'.
IFS=" "
for arg
do
@ -442,15 +519,14 @@ dashmstdout)
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for `:'
# Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
tr ' ' "$nl" < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
@ -503,9 +579,10 @@ makedepend)
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
@ -525,7 +602,7 @@ cpp)
shift
fi
# Remove `-o $object'.
# Remove '-o $object'.
IFS=" "
for arg
do
@ -594,8 +671,8 @@ msvisualcpp)
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;

View file

@ -1,6 +1,6 @@
#!/bin/sh
#
# $NetBSD: install-sh.in,v 1.4 2007/07/12 18:32:50 jlam Exp $
# $NetBSD: install-sh.in,v 1.6 2012/01/11 13:07:31 hans Exp $
# This script now also installs multiple files, but might choke on installing
# multiple files with spaces in the file names.
#
@ -44,7 +44,8 @@ stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
instcmd="$mvprog"
instcmd="$cpprog"
instflags=""
pathcompchmodcmd="$chmodprog 755"
chmodcmd="$chmodprog 755"
chowncmd=""
@ -84,6 +85,11 @@ while [ x"$1" != x ]; do
shift
continue;;
-m*)
chmodcmd="$chmodprog ${1#-m}"
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
@ -104,6 +110,10 @@ while [ x"$1" != x ]; do
shift
continue;;
-p) instflags="-p"
shift
continue;;
*) if [ x"$msrc" = x ]
then
msrc="$dst"
@ -154,7 +164,7 @@ else
if [ -f "$srcarg" ]
then
doinst="$instcmd"
doinst="$instcmd $instflags"
elif [ -d "$srcarg" ]
then
echo "install: $srcarg: not a regular file"

View file

@ -4522,7 +4522,7 @@ func_mode_link ()
-l*)
if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
# These systems don't actually have a C or math library (as such)
continue
;;
@ -6308,6 +6308,7 @@ func_mode_link ()
func_arith $current - $age
major=.$func_arith_result
versuffix="$major.$age.$revision"
versuffix2="$major.$age"
;;
osf)
@ -6368,8 +6369,10 @@ func_mode_link ()
esac
if test "$need_version" = no; then
versuffix=
versuffix2=
else
versuffix=".0.0"
versuffix2=".0.0"
fi
fi
@ -6377,6 +6380,7 @@ func_mode_link ()
if test "$avoid_version" = yes && test "$need_version" = no; then
major=
versuffix=
versuffix2=
verstring=""
fi
@ -6476,7 +6480,7 @@ func_mode_link ()
if test "$build_libtool_libs" = yes; then
if test -n "$rpath"; then
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
# these systems don't actually have a c library (as such)!
;;
*-*-rhapsody* | *-*-darwin1.[012])

View file

@ -1,10 +1,9 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
scriptversion=2009-04-28.21; # UTC
scriptversion=2012-01-06.18; # UTC
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
# 2008, 2009 Free Software Foundation, Inc.
# Copyright (C) 1996-2012 Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
@ -26,7 +25,7 @@ scriptversion=2009-04-28.21; # UTC
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
echo 1>&2 "Try '$0 --help' for more information"
exit 1
fi
@ -34,7 +33,7 @@ run=:
sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
# In the cases where this matters, `missing' is being run in the
# In the cases where this matters, 'missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
@ -65,7 +64,7 @@ case $1 in
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
Handle 'PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
@ -74,21 +73,20 @@ Options:
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
aclocal touch file 'aclocal.m4'
autoconf touch file 'configure'
autoheader touch file 'config.h.in'
autom4te touch the output file, or create a stub one
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
automake touch all 'Makefile.in' files
bison create 'y.tab.[ch]', if possible, from existing .[ch]
flex create 'lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
lex create 'lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
yacc create 'y.tab.[ch]', if possible, from existing .[ch]
Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
\`g' are ignored when checking the name.
Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and
'g' are ignored when checking the name.
Send bug reports to <bug-automake@gnu.org>."
exit $?
@ -100,8 +98,8 @@ Send bug reports to <bug-automake@gnu.org>."
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
echo 1>&2 "$0: Unknown '$1' option"
echo 1>&2 "Try '$0 --help' for more information"
exit 1
;;
@ -122,22 +120,13 @@ case $1 in
# Not GNU programs, they don't have --version.
;;
tar*)
if test -n "$run"; then
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
exit 1
fi
;;
*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
# Could not run --version or --help. This is probably someone
# running `$TOOL --version' or `$TOOL --help' to check whether
# running '$TOOL --version' or '$TOOL --help' to check whether
# $TOOL exists and not knowing $TOOL uses missing.
exit 1
fi
@ -149,27 +138,27 @@ esac
case $program in
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
WARNING: '$1' is $msg. You should only need it if
you modified 'acinclude.m4' or '${configure_ac}'. You might want
to install the Automake and Perl packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
WARNING: '$1' is $msg. You should only need it if
you modified '${configure_ac}'. You might want to install the
Autoconf and GNU m4 packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
WARNING: '$1' is $msg. You should only need it if
you modified 'acconfig.h' or '${configure_ac}'. You might want
to install the Autoconf and GNU m4 packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
@ -186,9 +175,9 @@ WARNING: \`$1' is $msg. You should only need it if
automake*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
WARNING: '$1' is $msg. You should only need it if
you modified 'Makefile.am', 'acinclude.m4' or '${configure_ac}'.
You might want to install the Automake and Perl packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
@ -197,10 +186,10 @@ WARNING: \`$1' is $msg. You should only need it if
autom4te*)
echo 1>&2 "\
WARNING: \`$1' is needed, but is $msg.
WARNING: '$1' is needed, but is $msg.
You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
You can get '$1' as part of Autoconf from any GNU
archive site."
file=`echo "$*" | sed -n "$sed_output"`
@ -220,13 +209,13 @@ WARNING: \`$1' is needed, but is $msg.
bison*|yacc*)
echo 1>&2 "\
WARNING: \`$1' $msg. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
WARNING: '$1' $msg. You should only need it if
you modified a '.y' file. You may need the Bison package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
Bison from any GNU archive site."
rm -f y.tab.c y.tab.h
if test $# -ne 1; then
eval LASTARG="\${$#}"
eval LASTARG=\${$#}
case $LASTARG in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
@ -250,13 +239,13 @@ WARNING: \`$1' $msg. You should only need it if
lex*|flex*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
WARNING: '$1' is $msg. You should only need it if
you modified a '.l' file. You may need the Flex package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
Flex from any GNU archive site."
rm -f lex.yy.c
if test $# -ne 1; then
eval LASTARG="\${$#}"
eval LASTARG=\${$#}
case $LASTARG in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
@ -273,10 +262,10 @@ WARNING: \`$1' is $msg. You should only need it if
help2man*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
WARNING: '$1' is $msg. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
Help2man package in order for those modifications to take
effect. You can get Help2man from any GNU archive site."
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
@ -291,12 +280,12 @@ WARNING: \`$1' is $msg. You should only need it if
makeinfo*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
WARNING: '$1' is $msg. You should only need it if
you modified a '.texi' or '.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
call might also be the consequence of using a buggy 'make' (AIX,
DU, IRIX). You might want to install the Texinfo package or
the GNU make package. Grab either from any GNU archive site."
# The file to touch is that specified with -o ...
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
@ -318,49 +307,14 @@ WARNING: \`$1' is $msg. You should only need it if
touch $file
;;
tar*)
shift
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
case $firstarg in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" "$@" && exit 0
;;
esac
case $firstarg in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" "$@" && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and is $msg.
WARNING: '$1' is needed, and is $msg.
You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
proper tools for further handling them. Check the 'README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
some other package would contain this missing '$1' program."
exit 1
;;
esac

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -31,5 +31,6 @@
#define _ATF_CXX_HPP_
#include <atf-c++/macros.hpp>
#include <atf-c++/utils.hpp>
#endif // !defined(_ATF_CXX_HPP_)

View file

@ -0,0 +1,14 @@
syntax("kyuafile", 1)
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"}
atf_test_program{name="utils_test"}
include("detail/Kyuafile")

View file

@ -1,7 +1,7 @@
#
# Automated Testing Framework (atf)
#
# Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
# Copyright (c) 2007 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -27,6 +27,8 @@
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
ATF_CXX_LIBS = libatf-c++.la libatf-c.la
lib_LTLIBRARIES += libatf-c++.la
libatf_c___la_LIBADD = libatf-c.la
libatf_c___la_SOURCES = atf-c++/build.cpp \
@ -36,59 +38,63 @@ libatf_c___la_SOURCES = atf-c++/build.cpp \
atf-c++/config.cpp \
atf-c++/config.hpp \
atf-c++/macros.hpp \
atf-c++/noncopyable.hpp \
atf-c++/tests.cpp \
atf-c++/tests.hpp \
atf-c++/utils.cpp \
atf-c++/utils.hpp
libatf_c___la_LDFLAGS = -version-info 0:0:0
include_HEADERS += atf-c++.hpp
atf_c___HEADERS = atf-c++/build.hpp \
atf-c++/check.hpp \
atf-c++/config.hpp \
atf-c++/macros.hpp \
atf-c++/noncopyable.hpp \
atf-c++/tests.hpp \
atf-c++/utils.hpp
atf_c__dir = $(includedir)/atf-c++
dist_man_MANS += atf-c++/atf-c++-api.3
atf_aclocal_DATA += atf-c++/atf-c++.m4
EXTRA_DIST += atf-c++/atf-c++.m4
atf_c__dirpkgconfigdir = $(atf_pkgconfigdir)
atf_c__dirpkgconfig_DATA = atf-c++/atf-c++.pc
CLEANFILES += atf-c++/atf-c++.pc
EXTRA_DIST += atf-c++/atf-c++.pc.in
atf-c++/atf-c++.pc: $(srcdir)/atf-c++/atf-c++.pc.in
atf-c++/atf-c++.pc: $(srcdir)/atf-c++/atf-c++.pc.in Makefile
test -d atf-c++ || mkdir -p atf-c++
sed -e 's,__ATF_VERSION__,@PACKAGE_VERSION@,g' \
-e 's,__CXX__,$(CXX),g' \
-e 's,__INCLUDEDIR__,$(includedir),g' \
-e 's,__LIBDIR__,$(libdir),g' \
sed -e 's#__ATF_VERSION__#$(PACKAGE_VERSION)#g' \
-e 's#__CXX__#$(CXX)#g' \
-e 's#__INCLUDEDIR__#$(includedir)#g' \
-e 's#__LIBDIR__#$(libdir)#g' \
<$(srcdir)/atf-c++/atf-c++.pc.in >atf-c++/atf-c++.pc.tmp
mv atf-c++/atf-c++.pc.tmp atf-c++/atf-c++.pc
tests_atf_c___DATA = atf-c++/Atffile \
atf-c++/macros_hpp_test.cpp
atf-c++/Kyuafile \
atf-c++/macros_hpp_test.cpp \
atf-c++/unused_test.cpp
tests_atf_c__dir = $(pkgtestsdir)/atf-c++
EXTRA_DIST += $(tests_atf_c___DATA)
tests_atf_c___PROGRAMS = atf-c++/atf_c++_test
atf_c___atf_c___test_SOURCES = atf-c++/atf_c++_test.cpp
atf_c___atf_c___test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___atf_c___test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
tests_atf_c___PROGRAMS += atf-c++/build_test
atf_c___build_test_SOURCES = atf-c++/build_test.cpp atf-c/h_build.h
atf_c___build_test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___build_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
tests_atf_c___PROGRAMS += atf-c++/check_test
atf_c___check_test_SOURCES = atf-c++/check_test.cpp
atf_c___check_test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___check_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
tests_atf_c___PROGRAMS += atf-c++/config_test
atf_c___config_test_SOURCES = atf-c++/config_test.cpp
atf_c___config_test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___config_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
tests_atf_c___PROGRAMS += atf-c++/macros_test
atf_c___macros_test_SOURCES = atf-c++/macros_test.cpp
atf_c___macros_test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___macros_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
tests_atf_c___SCRIPTS = atf-c++/pkg_config_test
CLEANFILES += atf-c++/pkg_config_test
EXTRA_DIST += atf-c++/pkg_config_test.sh
@ -99,12 +105,10 @@ atf-c++/pkg_config_test: $(srcdir)/atf-c++/pkg_config_test.sh
tests_atf_c___PROGRAMS += atf-c++/tests_test
atf_c___tests_test_SOURCES = atf-c++/tests_test.cpp
atf_c___tests_test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___tests_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
tests_atf_c___PROGRAMS += atf-c++/utils_test
atf_c___utils_test_SOURCES = atf-c++/utils_test.cpp
atf_c___utils_test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___utils_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
include atf-c++/detail/Makefile.am.inc
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8

View file

@ -1,7 +1,7 @@
.\"
.\" Automated Testing Framework (atf)
.\"
.\" Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
.\" Copyright (c) 2008 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@ -26,10 +26,11 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd October 21, 2010
.Dd November 30, 2012
.Dt ATF-C++-API 3
.Os
.Sh NAME
.Nm atf-c++-api ,
.Nm ATF_ADD_TEST_CASE ,
.Nm ATF_CHECK_ERRNO ,
.Nm ATF_FAIL ,
@ -38,7 +39,9 @@
.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 ,
@ -46,8 +49,21 @@
.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
@ -59,7 +75,9 @@
.Fn ATF_REQUIRE "expression"
.Fn ATF_REQUIRE_EQ "expression_1" "expression_2"
.Fn ATF_REQUIRE_ERRNO "exp_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"
@ -67,8 +85,65 @@
.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 mostly-macro-based programming interface to implement test
programs in C or C++.
@ -166,6 +241,18 @@ and
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
@ -185,7 +272,7 @@ 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
.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.
@ -313,14 +400,22 @@ takes an expression and raises a failure if it evaluates to false.
takes two expressions and raises a failure if the two do not evaluate to
the same exact value.
.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_EQ
.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.
@ -334,6 +429,163 @@ 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 -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 -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 -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 -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 -offset indent
Checks if
.Fa path
exists.
.Ed
.Pp
.Ft pid_t
.Fo atf::utils::fork
.Fa "void"
.Fc
.Bd -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 -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 -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 -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 -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 -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 EXAMPLES
The following shows a complete test program with a single test case that
validates the addition operator:
@ -343,7 +595,7 @@ validates the addition operator:
ATF_TEST_CASE(addition);
ATF_TEST_CASE_HEAD(addition)
{
set("descr", "Sample tests for the addition operator");
set_md_var("descr", "Sample tests for the addition operator");
}
ATF_TEST_CASE_BODY(addition)
{
@ -359,7 +611,7 @@ ATF_TEST_CASE_BODY(addition)
ATF_TEST_CASE(open_failure);
ATF_TEST_CASE_HEAD(open_failure)
{
set("descr", "Sample tests for the open function");
set_md_var("descr", "Sample tests for the open function");
}
ATF_TEST_CASE_BODY(open_failure)
{
@ -369,7 +621,7 @@ ATF_TEST_CASE_BODY(open_failure)
ATF_TEST_CASE(known_bug);
ATF_TEST_CASE_HEAD(known_bug)
{
set("descr", "Reproduces a known bug");
set_md_var("descr", "Reproduces a known bug");
}
ATF_TEST_CASE_BODY(known_bug)
{

View file

@ -0,0 +1,48 @@
dnl
dnl Automated Testing Framework (atf)
dnl
dnl Copyright 2011 Google Inc.
dnl All rights reserved.
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are permitted provided that the following conditions are
dnl met:
dnl
dnl * Redistributions of source code must retain the above copyright
dnl notice, this list of conditions and the following disclaimer.
dnl * Redistributions in binary form must reproduce the above copyright
dnl notice, this list of conditions and the following disclaimer in the
dnl documentation and/or other materials provided with the distribution.
dnl * Neither the name of Google Inc. nor the names of its contributors
dnl may be used to endorse or promote products derived from this software
dnl without specific prior written permission.
dnl
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dnl
dnl ATF_CHECK_CXX([version-spec])
dnl
dnl Checks if atf-c++ is present. If version-spec is provided, ensures that
dnl the installed version of atf-sh matches the required version. This
dnl argument must be something like '>= 0.14' and accepts any version
dnl specification supported by pkg-config.
dnl
dnl Defines and substitutes ATF_CXX_CFLAGS and ATF_CXX_LIBS with the compiler
dnl and linker flags need to build against atf-c++.
AC_DEFUN([ATF_CHECK_CXX], [
spec="atf-c++[]m4_default_nblank([ $1], [])"
_ATF_CHECK_ARG_WITH(
[PKG_CHECK_MODULES([ATF_CXX], [${spec}],
[found=yes found_atf_cxx=yes], [found=no])],
[required ${spec} not found])
])

View file

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

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2009 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
@ -39,7 +39,7 @@ extern "C" {
#include <string>
#include <vector>
#include <atf-c++/utils.hpp>
#include <atf-c++/noncopyable.hpp>
namespace atf {
@ -60,7 +60,7 @@ namespace check {
//! of executing arbitrary command and manages files containing
//! its output.
//!
class check_result : utils::noncopyable {
class check_result : noncopyable {
//!
//! \brief Internal representation of a result.
//!

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -191,15 +191,17 @@ ATF_TEST_CASE_HEAD(build_c_o)
}
ATF_TEST_CASE_BODY(build_c_o)
{
ATF_TEST_CASE_USE(h_build_c_o_ok);
run_h_tc< ATF_TEST_CASE_NAME(h_build_c_o_ok) >();
ATF_REQUIRE(grep_file("stdout", "-o test.o"));
ATF_REQUIRE(grep_file("stdout", "-c test.c"));
ATF_REQUIRE(atf::utils::grep_file("-o test.o", "stdout"));
ATF_REQUIRE(atf::utils::grep_file("-c test.c", "stdout"));
ATF_TEST_CASE_USE(h_build_c_o_fail);
run_h_tc< ATF_TEST_CASE_NAME(h_build_c_o_fail) >();
ATF_REQUIRE(grep_file("stdout", "-o test.o"));
ATF_REQUIRE(grep_file("stdout", "-c test.c"));
ATF_REQUIRE(grep_file("stderr", "test.c"));
ATF_REQUIRE(grep_file("stderr", "UNDEFINED_SYMBOL"));
ATF_REQUIRE(atf::utils::grep_file("-o test.o", "stdout"));
ATF_REQUIRE(atf::utils::grep_file("-c test.c", "stdout"));
ATF_REQUIRE(atf::utils::grep_file("test.c", "stderr"));
ATF_REQUIRE(atf::utils::grep_file("UNDEFINED_SYMBOL", "stderr"));
}
ATF_TEST_CASE(build_cpp);
@ -209,16 +211,18 @@ ATF_TEST_CASE_HEAD(build_cpp)
}
ATF_TEST_CASE_BODY(build_cpp)
{
ATF_TEST_CASE_USE(h_build_cpp_ok);
run_h_tc< ATF_TEST_CASE_NAME(h_build_cpp_ok) >();
ATF_REQUIRE(grep_file("stdout", "-o.*test.p"));
ATF_REQUIRE(grep_file("stdout", "test.c"));
ATF_REQUIRE(grep_file("test.p", "foo bar"));
ATF_REQUIRE(atf::utils::grep_file("-o.*test.p", "stdout"));
ATF_REQUIRE(atf::utils::grep_file("test.c", "stdout"));
ATF_REQUIRE(atf::utils::grep_file("foo bar", "test.p"));
ATF_TEST_CASE_USE(h_build_cpp_fail);
run_h_tc< ATF_TEST_CASE_NAME(h_build_cpp_fail) >();
ATF_REQUIRE(grep_file("stdout", "-o test.p"));
ATF_REQUIRE(grep_file("stdout", "test.c"));
ATF_REQUIRE(grep_file("stderr", "test.c"));
ATF_REQUIRE(grep_file("stderr", "non-existent.h"));
ATF_REQUIRE(atf::utils::grep_file("-o test.p", "stdout"));
ATF_REQUIRE(atf::utils::grep_file("test.c", "stdout"));
ATF_REQUIRE(atf::utils::grep_file("test.c", "stderr"));
ATF_REQUIRE(atf::utils::grep_file("non-existent.h", "stderr"));
}
ATF_TEST_CASE(build_cxx_o);
@ -228,15 +232,17 @@ ATF_TEST_CASE_HEAD(build_cxx_o)
}
ATF_TEST_CASE_BODY(build_cxx_o)
{
ATF_TEST_CASE_USE(h_build_cxx_o_ok);
run_h_tc< ATF_TEST_CASE_NAME(h_build_cxx_o_ok) >();
ATF_REQUIRE(grep_file("stdout", "-o test.o"));
ATF_REQUIRE(grep_file("stdout", "-c test.cpp"));
ATF_REQUIRE(atf::utils::grep_file("-o test.o", "stdout"));
ATF_REQUIRE(atf::utils::grep_file("-c test.cpp", "stdout"));
ATF_TEST_CASE_USE(h_build_cxx_o_fail);
run_h_tc< ATF_TEST_CASE_NAME(h_build_cxx_o_fail) >();
ATF_REQUIRE(grep_file("stdout", "-o test.o"));
ATF_REQUIRE(grep_file("stdout", "-c test.cpp"));
ATF_REQUIRE(grep_file("stderr", "test.cpp"));
ATF_REQUIRE(grep_file("stderr", "UNDEFINED_SYMBOL"));
ATF_REQUIRE(atf::utils::grep_file("-o test.o", "stdout"));
ATF_REQUIRE(atf::utils::grep_file("-c test.cpp", "stdout"));
ATF_REQUIRE(atf::utils::grep_file("test.cpp", "stderr"));
ATF_REQUIRE(atf::utils::grep_file("UNDEFINED_SYMBOL", "stderr"));
}
ATF_TEST_CASE(exec_cleanup);

View file

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

View file

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

View file

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

View file

@ -3,6 +3,7 @@ Content-Type: application/X-atf-atffile; version="1"
prop: test-suite = atf
tp: application_test
tp: auto_array_test
tp: env_test
tp: exceptions_test
tp: expand_test

View file

@ -0,0 +1,14 @@
syntax("kyuafile", 1)
test_suite("atf")
atf_test_program{name="application_test"}
atf_test_program{name="auto_array_test"}
atf_test_program{name="env_test"}
atf_test_program{name="exceptions_test"}
atf_test_program{name="expand_test"}
atf_test_program{name="fs_test"}
atf_test_program{name="parser_test"}
atf_test_program{name="sanity_test"}
atf_test_program{name="text_test"}
atf_test_program{name="ui_test"}

View file

@ -1,7 +1,7 @@
#
# Automated Testing Framework (atf)
#
# Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
# Copyright (c) 2007 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -29,6 +29,7 @@
libatf_c___la_SOURCES += atf-c++/detail/application.cpp \
atf-c++/detail/application.hpp \
atf-c++/detail/auto_array.hpp \
atf-c++/detail/env.cpp \
atf-c++/detail/env.hpp \
atf-c++/detail/exceptions.cpp \
@ -47,7 +48,8 @@ libatf_c___la_SOURCES += atf-c++/detail/application.cpp \
atf-c++/detail/ui.cpp \
atf-c++/detail/ui.hpp
tests_atf_c___detail_DATA = atf-c++/detail/Atffile
tests_atf_c___detail_DATA = atf-c++/detail/Atffile \
atf-c++/detail/Kyuafile
tests_atf_c___detaildir = $(pkgtestsdir)/atf-c++/detail
EXTRA_DIST += $(tests_atf_c___detail_DATA)
@ -57,42 +59,46 @@ atf_c___detail_libtest_helpers_la_SOURCES = atf-c++/detail/test_helpers.cpp \
tests_atf_c___detail_PROGRAMS = atf-c++/detail/application_test
atf_c___detail_application_test_SOURCES = atf-c++/detail/application_test.cpp
atf_c___detail_application_test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___detail_application_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
tests_atf_c___detail_PROGRAMS += atf-c++/detail/auto_array_test
atf_c___detail_auto_array_test_SOURCES = atf-c++/detail/auto_array_test.cpp
atf_c___detail_auto_array_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
tests_atf_c___detail_PROGRAMS += atf-c++/detail/env_test
atf_c___detail_env_test_SOURCES = atf-c++/detail/env_test.cpp
atf_c___detail_env_test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___detail_env_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
tests_atf_c___detail_PROGRAMS += atf-c++/detail/exceptions_test
atf_c___detail_exceptions_test_SOURCES = atf-c++/detail/exceptions_test.cpp
atf_c___detail_exceptions_test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___detail_exceptions_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
tests_atf_c___detail_PROGRAMS += atf-c++/detail/expand_test
atf_c___detail_expand_test_SOURCES = atf-c++/detail/expand_test.cpp
atf_c___detail_expand_test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___detail_expand_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
tests_atf_c___detail_PROGRAMS += atf-c++/detail/fs_test
atf_c___detail_fs_test_SOURCES = atf-c++/detail/fs_test.cpp
atf_c___detail_fs_test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___detail_fs_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
tests_atf_c___detail_PROGRAMS += atf-c++/detail/parser_test
atf_c___detail_parser_test_SOURCES = atf-c++/detail/parser_test.cpp
atf_c___detail_parser_test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___detail_parser_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
tests_atf_c___detail_PROGRAMS += atf-c++/detail/process_test
atf_c___detail_process_test_SOURCES = atf-c++/detail/process_test.cpp
atf_c___detail_process_test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___detail_process_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
tests_atf_c___detail_PROGRAMS += atf-c++/detail/sanity_test
atf_c___detail_sanity_test_SOURCES = atf-c++/detail/sanity_test.cpp
atf_c___detail_sanity_test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___detail_sanity_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
tests_atf_c___detail_PROGRAMS += atf-c++/detail/text_test
atf_c___detail_text_test_SOURCES = atf-c++/detail/text_test.cpp
atf_c___detail_text_test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___detail_text_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
tests_atf_c___detail_PROGRAMS += atf-c++/detail/ui_test
atf_c___detail_ui_test_SOURCES = atf-c++/detail/ui_test.cpp
atf_c___detail_ui_test_LDADD = atf-c++/detail/libtest_helpers.la libatf-c++.la
atf_c___detail_ui_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2010 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -41,6 +41,10 @@ extern "C" {
#include <cstring>
#include <iostream>
extern "C" {
#include "atf-c/defs.h"
}
#include "application.hpp"
#include "sanity.hpp"
#include "ui.hpp"
@ -151,7 +155,8 @@ impl::app::specific_options(void)
}
void
impl::app::process_option(int ch, const char* arg)
impl::app::process_option(int ch ATF_DEFS_ATTRIBUTE_UNUSED,
const char* arg ATF_DEFS_ATTRIBUTE_UNUSED)
{
}
@ -178,6 +183,7 @@ impl::app::process_options(void)
}
int ch;
const int old_opterr = ::opterr;
::opterr = 0;
while ((ch = ::getopt(m_argc, m_argv, optstr.c_str())) != -1) {
switch (ch) {
@ -201,6 +207,7 @@ impl::app::process_options(void)
m_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;

View file

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

View file

@ -52,13 +52,16 @@ public:
char *const argv[] = { arg1, arg2, arg3, arg4, NULL };
int ch;
bool zflag;
// Given that this obviously is an application, and that we used the
// same driver to start, we can test getopt(3) right here without doing
// any fancy stuff.
zflag = false;
while ((ch = ::getopt(argc, argv, ":Z")) != -1) {
switch (ch) {
case 'Z':
zflag = true;
break;
case '?':
@ -68,6 +71,7 @@ public:
}
}
ATF_REQUIRE(zflag);
ATF_REQUIRE_EQ(1, argc - optind);
ATF_REQUIRE_EQ(std::string("foo"), argv[optind]);

View file

@ -0,0 +1,179 @@
//
// 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_AUTO_ARRAY_HPP_)
#define _ATF_CXX_AUTO_ARRAY_HPP_
#include <cstddef>
namespace atf {
// ------------------------------------------------------------------------
// The "auto_array" class.
// ------------------------------------------------------------------------
template< class T >
struct auto_array_ref {
T* m_ptr;
explicit auto_array_ref(T*);
};
template< class T >
auto_array_ref< T >::auto_array_ref(T* ptr) :
m_ptr(ptr)
{
}
template< class T >
class auto_array {
T* m_ptr;
public:
auto_array(T* = NULL) throw();
auto_array(auto_array< T >&) throw();
auto_array(auto_array_ref< T >) throw();
~auto_array(void) throw();
T* get(void) throw();
const T* get(void) const throw();
T* release(void) throw();
void reset(T* = NULL) throw();
auto_array< T >& operator=(auto_array< T >&) throw();
auto_array< T >& operator=(auto_array_ref< T >) throw();
T& operator[](int) throw();
operator auto_array_ref< T >(void) throw();
};
template< class T >
auto_array< T >::auto_array(T* ptr)
throw() :
m_ptr(ptr)
{
}
template< class T >
auto_array< T >::auto_array(auto_array< T >& ptr)
throw() :
m_ptr(ptr.release())
{
}
template< class T >
auto_array< T >::auto_array(auto_array_ref< T > ref)
throw() :
m_ptr(ref.m_ptr)
{
}
template< class T >
auto_array< T >::~auto_array(void)
throw()
{
if (m_ptr != NULL)
delete [] m_ptr;
}
template< class T >
T*
auto_array< T >::get(void)
throw()
{
return m_ptr;
}
template< class T >
const T*
auto_array< T >::get(void)
const throw()
{
return m_ptr;
}
template< class T >
T*
auto_array< T >::release(void)
throw()
{
T* ptr = m_ptr;
m_ptr = NULL;
return ptr;
}
template< class T >
void
auto_array< T >::reset(T* ptr)
throw()
{
if (m_ptr != NULL)
delete [] m_ptr;
m_ptr = ptr;
}
template< class T >
auto_array< T >&
auto_array< T >::operator=(auto_array< T >& ptr)
throw()
{
reset(ptr.release());
return *this;
}
template< class T >
auto_array< T >&
auto_array< T >::operator=(auto_array_ref< T > ref)
throw()
{
if (m_ptr != ref.m_ptr) {
delete [] m_ptr;
m_ptr = ref.m_ptr;
}
return *this;
}
template< class T >
T&
auto_array< T >::operator[](int pos)
throw()
{
return m_ptr[pos];
}
template< class T >
auto_array< T >::operator auto_array_ref< T >(void)
throw()
{
return auto_array_ref< T >(release());
}
} // namespace atf
#endif // !defined(_ATF_CXX_AUTO_ARRAY_HPP_)

View file

@ -0,0 +1,304 @@
//
// 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.
//
extern "C" {
#include <sys/types.h>
}
#include <iostream>
#include "atf-c/defs.h"
#include "../macros.hpp"
#include "auto_array.hpp"
// ------------------------------------------------------------------------
// Tests for the "auto_array" class.
// ------------------------------------------------------------------------
class test_array {
public:
int m_value;
static ssize_t m_nblocks;
static
atf::auto_array< test_array >
do_copy(atf::auto_array< test_array >& ta)
{
return atf::auto_array< test_array >(ta);
}
void* operator new(size_t size ATF_DEFS_ATTRIBUTE_UNUSED)
{
ATF_FAIL("New called but should have been new[]");
return new int(5);
}
void* operator new[](size_t size)
{
m_nblocks++;
void* mem = ::operator new(size);
std::cout << "Allocated 'test_array' object " << mem << "\n";
return mem;
}
void operator delete(void* mem ATF_DEFS_ATTRIBUTE_UNUSED)
{
ATF_FAIL("Delete called but should have been delete[]");
}
void operator delete[](void* mem)
{
std::cout << "Releasing 'test_array' object " << mem << "\n";
if (m_nblocks == 0)
ATF_FAIL("Unbalanced delete[]");
m_nblocks--;
::operator delete(mem);
}
};
ssize_t test_array::m_nblocks = 0;
ATF_TEST_CASE(auto_array_scope);
ATF_TEST_CASE_HEAD(auto_array_scope)
{
set_md_var("descr", "Tests the automatic scope handling in the "
"auto_array smart pointer class");
}
ATF_TEST_CASE_BODY(auto_array_scope)
{
using atf::auto_array;
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
{
auto_array< test_array > t(new test_array[10]);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_TEST_CASE(auto_array_copy);
ATF_TEST_CASE_HEAD(auto_array_copy)
{
set_md_var("descr", "Tests the auto_array smart pointer class' copy "
"constructor");
}
ATF_TEST_CASE_BODY(auto_array_copy)
{
using atf::auto_array;
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
{
auto_array< test_array > t1(new test_array[10]);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
{
auto_array< test_array > t2(t1);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_TEST_CASE(auto_array_copy_ref);
ATF_TEST_CASE_HEAD(auto_array_copy_ref)
{
set_md_var("descr", "Tests the auto_array smart pointer class' copy "
"constructor through the auxiliary auto_array_ref object");
}
ATF_TEST_CASE_BODY(auto_array_copy_ref)
{
using atf::auto_array;
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
{
auto_array< test_array > t1(new test_array[10]);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
{
auto_array< test_array > t2 = test_array::do_copy(t1);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_TEST_CASE(auto_array_get);
ATF_TEST_CASE_HEAD(auto_array_get)
{
set_md_var("descr", "Tests the auto_array smart pointer class' get "
"method");
}
ATF_TEST_CASE_BODY(auto_array_get)
{
using atf::auto_array;
test_array* ta = new test_array[10];
auto_array< test_array > t(ta);
ATF_REQUIRE_EQ(t.get(), ta);
}
ATF_TEST_CASE(auto_array_release);
ATF_TEST_CASE_HEAD(auto_array_release)
{
set_md_var("descr", "Tests the auto_array smart pointer class' release "
"method");
}
ATF_TEST_CASE_BODY(auto_array_release)
{
using atf::auto_array;
test_array* ta1 = new test_array[10];
{
auto_array< test_array > t(ta1);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
test_array* ta2 = t.release();
ATF_REQUIRE_EQ(ta2, ta1);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
delete [] ta1;
}
ATF_TEST_CASE(auto_array_reset);
ATF_TEST_CASE_HEAD(auto_array_reset)
{
set_md_var("descr", "Tests the auto_array smart pointer class' reset "
"method");
}
ATF_TEST_CASE_BODY(auto_array_reset)
{
using atf::auto_array;
test_array* ta1 = new test_array[10];
test_array* ta2 = new test_array[10];
ATF_REQUIRE_EQ(test_array::m_nblocks, 2);
{
auto_array< test_array > t(ta1);
ATF_REQUIRE_EQ(test_array::m_nblocks, 2);
t.reset(ta2);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
t.reset();
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_TEST_CASE(auto_array_assign);
ATF_TEST_CASE_HEAD(auto_array_assign)
{
set_md_var("descr", "Tests the auto_array smart pointer class' "
"assignment operator");
}
ATF_TEST_CASE_BODY(auto_array_assign)
{
using atf::auto_array;
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
{
auto_array< test_array > t1(new test_array[10]);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
{
auto_array< test_array > t2;
t2 = t1;
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_TEST_CASE(auto_array_assign_ref);
ATF_TEST_CASE_HEAD(auto_array_assign_ref)
{
set_md_var("descr", "Tests the auto_array smart pointer class' "
"assignment operator through the auxiliary auto_array_ref "
"object");
}
ATF_TEST_CASE_BODY(auto_array_assign_ref)
{
using atf::auto_array;
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
{
auto_array< test_array > t1(new test_array[10]);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
{
auto_array< test_array > t2;
t2 = test_array::do_copy(t1);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_TEST_CASE(auto_array_access);
ATF_TEST_CASE_HEAD(auto_array_access)
{
set_md_var("descr", "Tests the auto_array smart pointer class' access "
"operator");
}
ATF_TEST_CASE_BODY(auto_array_access)
{
using atf::auto_array;
auto_array< test_array > t(new test_array[10]);
for (int i = 0; i < 10; i++)
t[i].m_value = i * 2;
for (int i = 0; i < 10; i++)
ATF_REQUIRE_EQ(t[i].m_value, i * 2);
}
// ------------------------------------------------------------------------
// Main.
// ------------------------------------------------------------------------
ATF_INIT_TEST_CASES(tcs)
{
// Add the test for the "auto_array" class.
ATF_ADD_TEST_CASE(tcs, auto_array_scope);
ATF_ADD_TEST_CASE(tcs, auto_array_copy);
ATF_ADD_TEST_CASE(tcs, auto_array_copy_ref);
ATF_ADD_TEST_CASE(tcs, auto_array_get);
ATF_ADD_TEST_CASE(tcs, auto_array_release);
ATF_ADD_TEST_CASE(tcs, auto_array_reset);
ATF_ADD_TEST_CASE(tcs, auto_array_assign);
ATF_ADD_TEST_CASE(tcs, auto_array_assign_ref);
ATF_ADD_TEST_CASE(tcs, auto_array_access);
}

View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2009 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
@ -34,6 +34,7 @@
#include <cstdarg>
#include <cstdio>
#include <cstring>
#include <new>
extern "C" {
#include "../../atf-c/error.h"

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -31,6 +31,7 @@
#define _ATF_CXX_EXCEPTIONS_HPP_
#include <stdexcept>
#include <string>
extern "C" {
struct atf_error;

View file

@ -32,6 +32,7 @@ extern "C" {
}
#include <cstdio>
#include <new>
#include "../macros.hpp"

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2008, 2009 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
@ -50,10 +50,10 @@ namespace impl = atf::process;
// ------------------------------------------------------------------------
template< class C >
atf::utils::auto_array< const char* >
atf::auto_array< const char* >
collection_to_argv(const C& c)
{
atf::utils::auto_array< const char* > argv(new const char*[c.size() + 1]);
atf::auto_array< const char* > argv(new const char*[c.size() + 1]);
std::size_t pos = 0;
for (typename C::const_iterator iter = c.begin(); iter != c.end();

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
// Copyright (c) 2008 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -41,11 +41,10 @@ extern "C" {
#include <string>
#include <vector>
#include "auto_array.hpp"
#include "exceptions.hpp"
#include "fs.hpp"
#include "../utils.hpp"
namespace atf {
namespace process {
@ -64,7 +63,7 @@ class argv_array {
// std::tr1::shared_array instead when it becomes widely available.
// The reason would be to remove all copy constructors and assignment
// operators from this class.
utils::auto_array< const char* > m_exec_argv;
auto_array< const char* > m_exec_argv;
void ctor_init_exec_argv(void);
public:
@ -118,7 +117,7 @@ class stream_capture : basic_stream {
child fork(void (*)(void*), const OutStream&, const ErrStream&, void*);
template< class OutStream, class ErrStream > friend
status exec(const atf::fs::path&, const argv_array&,
const OutStream&, const ErrStream&);
const OutStream&, const ErrStream&, void (*)(void));
public:
stream_capture(void);
@ -130,7 +129,7 @@ class stream_connect : basic_stream {
child fork(void (*)(void*), const OutStream&, const ErrStream&, void*);
template< class OutStream, class ErrStream > friend
status exec(const atf::fs::path&, const argv_array&,
const OutStream&, const ErrStream&);
const OutStream&, const ErrStream&, void (*)(void));
public:
stream_connect(const int, const int);
@ -142,7 +141,7 @@ class stream_inherit : basic_stream {
child fork(void (*)(void*), const OutStream&, const ErrStream&, void*);
template< class OutStream, class ErrStream > friend
status exec(const atf::fs::path&, const argv_array&,
const OutStream&, const ErrStream&);
const OutStream&, const ErrStream&, void (*)(void));
public:
stream_inherit(void);
@ -154,7 +153,7 @@ class stream_redirect_fd : basic_stream {
child fork(void (*)(void*), const OutStream&, const ErrStream&, void*);
template< class OutStream, class ErrStream > friend
status exec(const atf::fs::path&, const argv_array&,
const OutStream&, const ErrStream&);
const OutStream&, const ErrStream&, void (*)(void));
public:
stream_redirect_fd(const int);
@ -166,7 +165,7 @@ class stream_redirect_path : basic_stream {
child fork(void (*)(void*), const OutStream&, const ErrStream&, void*);
template< class OutStream, class ErrStream > friend
status exec(const atf::fs::path&, const argv_array&,
const OutStream&, const ErrStream&);
const OutStream&, const ErrStream&, void (*)(void));
public:
stream_redirect_path(const fs::path&);
@ -182,7 +181,7 @@ class status {
friend class child;
template< class OutStream, class ErrStream > friend
status exec(const atf::fs::path&, const argv_array&,
const OutStream&, const ErrStream&);
const OutStream&, const ErrStream&, void (*)(void));
status(atf_process_status_t&);
@ -249,7 +248,8 @@ fork(void (*start)(void*), const OutStream& outsb,
template< class OutStream, class ErrStream >
status
exec(const atf::fs::path& prog, const argv_array& argv,
const OutStream& outsb, const ErrStream& errsb)
const OutStream& outsb, const ErrStream& errsb,
void (*prehook)(void))
{
atf_process_status_t s;
@ -257,13 +257,22 @@ exec(const atf::fs::path& prog, const argv_array& argv,
atf_error_t err = atf_process_exec_array(&s, prog.c_path(),
argv.exec_argv(),
outsb.get_sb(),
errsb.get_sb());
errsb.get_sb(),
prehook);
if (atf_is_error(err))
throw_atf_error(err);
return status(s);
}
template< class OutStream, class ErrStream >
status
exec(const atf::fs::path& prog, const argv_array& argv,
const OutStream& outsb, const ErrStream& errsb)
{
return exec(prog, argv, outsb, errsb, NULL);
}
} // namespace process
} // namespace atf

View file

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

View file

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

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2009, 2010 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
@ -27,10 +27,6 @@
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
extern "C" {
#include <regex.h>
}
#include <fstream>
#include <iostream>
#include <string>
@ -45,27 +41,31 @@ extern "C" {
#include "test_helpers.hpp"
void
build_check_cxx_o_aux(const atf::fs::path& sfile, const char* failmsg)
build_check_cxx_o_aux(const atf::fs::path& sfile, const char* failmsg,
const bool expect_pass)
{
std::vector< std::string > optargs;
optargs.push_back("-I" + atf::config::get("atf_includedir"));
optargs.push_back("-Wall");
optargs.push_back("-Werror");
if (!atf::check::build_cxx_o(sfile.str(), "test.o",
atf::process::argv_array(optargs)))
const bool result = atf::check::build_cxx_o(
sfile.str(), "test.o", atf::process::argv_array(optargs));
if ((expect_pass && !result) || (!expect_pass && result))
ATF_FAIL(failmsg);
}
void
build_check_cxx_o(const atf::tests::tc& tc, const char* sfile,
const char* failmsg)
const char* failmsg, const bool expect_pass)
{
const atf::fs::path sfilepath =
atf::fs::path(tc.get_config_var("srcdir")) / sfile;
build_check_cxx_o_aux(sfilepath, failmsg);
build_check_cxx_o_aux(sfilepath, failmsg, expect_pass);
}
void
header_check(const atf::tests::tc& tc, const char *hdrname)
header_check(const char *hdrname)
{
std::ofstream srcfile("test.c");
ATF_REQUIRE(srcfile);
@ -74,7 +74,7 @@ header_check(const atf::tests::tc& tc, const char *hdrname)
const std::string failmsg = std::string("Header check failed; ") +
hdrname + " is not self-contained";
build_check_cxx_o_aux(atf::fs::path("test.c"), failmsg.c_str());
build_check_cxx_o_aux(atf::fs::path("test.c"), failmsg.c_str(), true);
}
atf::fs::path
@ -84,43 +84,6 @@ get_process_helpers_path(const atf::tests::tc& tc)
".." / "atf-c" / "detail" / "process_helpers";
}
bool
grep_file(const char* name, const char* regex)
{
std::ifstream is(name);
ATF_REQUIRE(is);
bool found = false;
std::string line;
std::getline(is, line);
while (!found && is.good()) {
if (grep_string(line, regex))
found = true;
else
std::getline(is, line);
}
return found;
}
bool
grep_string(const std::string& str, const char* regex)
{
int res;
regex_t preg;
std::cout << "Looking for '" << regex << "' in '" << str << "'\n";
ATF_REQUIRE(::regcomp(&preg, regex, REG_EXTENDED) == 0);
res = ::regexec(&preg, str.c_str(), 0, NULL, 0);
ATF_REQUIRE(res == 0 || res == REG_NOMATCH);
::regfree(&preg);
return res == 0;
}
void
test_helpers_detail::check_equal(const char* expected[],
const string_vector& actual)

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2009, 2010 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
@ -53,7 +53,7 @@
} \
ATF_TEST_CASE_BODY(name) \
{ \
header_check(*this, hdrname); \
header_check(hdrname); \
}
#define BUILD_TC(name, sfile, descr, failmsg) \
@ -64,7 +64,18 @@
} \
ATF_TEST_CASE_BODY(name) \
{ \
build_check_cxx_o(*this, sfile, failmsg); \
build_check_cxx_o(*this, sfile, failmsg, true); \
}
#define BUILD_TC_FAIL(name, sfile, descr, failmsg) \
ATF_TEST_CASE(name); \
ATF_TEST_CASE_HEAD(name) \
{ \
set_md_var("descr", descr); \
} \
ATF_TEST_CASE_BODY(name) \
{ \
build_check_cxx_o(*this, sfile, failmsg, false); \
}
namespace atf {
@ -73,11 +84,9 @@ class tc;
}
}
void header_check(const atf::tests::tc&, const char*);
void build_check_cxx_o(const atf::tests::tc&, const char*, const char*);
void header_check(const char*);
void build_check_cxx_o(const atf::tests::tc&, const char*, const char*, bool);
atf::fs::path get_process_helpers_path(const atf::tests::tc&);
bool grep_file(const char*, const char*);
bool grep_string(const std::string&, const char*);
struct run_h_tc_data {
const atf::tests::vars_map& m_config;

View file

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

View file

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

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2009, 2010 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
@ -310,6 +310,29 @@ ATF_TEST_CASE_BODY(to_bool)
ATF_REQUIRE_THROW(std::runtime_error, to_bool("false2"));
}
ATF_TEST_CASE(to_bytes);
ATF_TEST_CASE_HEAD(to_bytes)
{
set_md_var("descr", "Tests the to_bytes function");
}
ATF_TEST_CASE_BODY(to_bytes)
{
using atf::text::to_bytes;
ATF_REQUIRE_EQ(0, to_bytes("0"));
ATF_REQUIRE_EQ(12345, to_bytes("12345"));
ATF_REQUIRE_EQ(2 * 1024, to_bytes("2k"));
ATF_REQUIRE_EQ(4 * 1024 * 1024, to_bytes("4m"));
ATF_REQUIRE_EQ(int64_t(8) * 1024 * 1024 * 1024, to_bytes("8g"));
ATF_REQUIRE_EQ(int64_t(16) * 1024 * 1024 * 1024 * 1024, to_bytes("16t"));
ATF_REQUIRE_THROW_RE(std::runtime_error, "Empty", to_bytes(""));
ATF_REQUIRE_THROW_RE(std::runtime_error, "Unknown size unit 'd'",
to_bytes("12d"));
ATF_REQUIRE_THROW(std::runtime_error, to_bytes(" "));
ATF_REQUIRE_THROW(std::runtime_error, to_bytes(" k"));
}
ATF_TEST_CASE(to_string);
ATF_TEST_CASE_HEAD(to_string)
{
@ -335,6 +358,7 @@ ATF_TEST_CASE_BODY(to_type)
ATF_REQUIRE_EQ(to_type< int >("0"), 0);
ATF_REQUIRE_EQ(to_type< int >("1234"), 1234);
ATF_REQUIRE_THROW(std::runtime_error, to_type< int >(" "));
ATF_REQUIRE_THROW(std::runtime_error, to_type< int >("0 a"));
ATF_REQUIRE_THROW(std::runtime_error, to_type< int >("a"));
@ -360,6 +384,7 @@ ATF_INIT_TEST_CASES(tcs)
ATF_ADD_TEST_CASE(tcs, split_delims);
ATF_ADD_TEST_CASE(tcs, trim);
ATF_ADD_TEST_CASE(tcs, to_bool);
ATF_ADD_TEST_CASE(tcs, to_bytes);
ATF_ADD_TEST_CASE(tcs, to_string);
ATF_ADD_TEST_CASE(tcs, to_type);
}

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2010 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -28,11 +28,10 @@
//
extern "C" {
#include <unistd.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
}
#include <sstream>

View file

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

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2010 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -36,31 +36,48 @@
#include <atf-c++/tests.hpp>
// Do not define inline methods for the test case classes. Doing so
// significantly increases the memory requirements of GNU G++ during
// compilation.
#define ATF_TEST_CASE_WITHOUT_HEAD(name) \
namespace { \
class atfu_tc_ ## name : public atf::tests::tc { \
void body(void) const; \
public: \
atfu_tc_ ## name(void) : atf::tests::tc(#name, false) {} \
};
atfu_tc_ ## name(void); \
}; \
static atfu_tc_ ## name* atfu_tcptr_ ## name; \
atfu_tc_ ## name::atfu_tc_ ## name(void) : atf::tests::tc(#name, false) {} \
}
#define ATF_TEST_CASE(name) \
namespace { \
class atfu_tc_ ## name : public atf::tests::tc { \
void head(void); \
void body(void) const; \
public: \
atfu_tc_ ## name(void) : atf::tests::tc(#name, false) {} \
};
atfu_tc_ ## name(void); \
}; \
static atfu_tc_ ## name* atfu_tcptr_ ## name; \
atfu_tc_ ## name::atfu_tc_ ## name(void) : atf::tests::tc(#name, false) {} \
}
#define ATF_TEST_CASE_WITH_CLEANUP(name) \
namespace { \
class atfu_tc_ ## name : public atf::tests::tc { \
void head(void); \
void body(void) const; \
void cleanup(void) const; \
public: \
atfu_tc_ ## name(void) : atf::tests::tc(#name, true) {} \
};
atfu_tc_ ## name(void); \
}; \
static atfu_tc_ ## name* atfu_tcptr_ ## name; \
atfu_tc_ ## name::atfu_tc_ ## name(void) : atf::tests::tc(#name, true) {} \
}
#define ATF_TEST_CASE_NAME(name) atfu_tc_ ## name
#define ATF_TEST_CASE_USE(name) (atfu_tcptr_ ## name) = NULL
#define ATF_TEST_CASE_HEAD(name) \
void \
@ -101,6 +118,12 @@
} \
} while (false)
#define ATF_REQUIRE_IN(element, collection) \
ATF_REQUIRE((collection).find(element) != (collection).end())
#define ATF_REQUIRE_NOT_IN(element, collection) \
ATF_REQUIRE((collection).find(element) == (collection).end())
#define ATF_REQUIRE_MATCH(regexp, string) \
do { \
if (!atf::tests::detail::match(regexp, string)) { \
@ -192,8 +215,8 @@
#define ATF_ADD_TEST_CASE(tcs, tcname) \
do { \
atf::tests::tc* tcptr = new atfu_tc_ ## tcname(); \
(tcs).push_back(tcptr); \
atfu_tcptr_ ## tcname = new atfu_tc_ ## tcname(); \
(tcs).push_back(atfu_tcptr_ ## tcname); \
} while (0);
#endif // !defined(_ATF_CXX_MACROS_HPP_)

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
// Copyright (c) 2008 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -106,6 +106,7 @@ ATF_TEST_CASE(TEST_MACRO_1);
ATF_TEST_CASE_HEAD(TEST_MACRO_1) { }
ATF_TEST_CASE_BODY(TEST_MACRO_1) { }
void instantiate_1(void) {
ATF_TEST_CASE_USE(TEST_MACRO_1);
atf::tests::tc* the_test = new ATF_TEST_CASE_NAME(TEST_MACRO_1)();
delete the_test;
}
@ -114,12 +115,16 @@ ATF_TEST_CASE_HEAD(TEST_MACRO_2) { }
ATF_TEST_CASE_BODY(TEST_MACRO_2) { }
ATF_TEST_CASE_CLEANUP(TEST_MACRO_2) { }
void instatiate_2(void) {
ATF_TEST_CASE_USE(TEST_MACRO_2);
atf::tests::tc* the_test = new ATF_TEST_CASE_NAME(TEST_MACRO_2)();
delete the_test;
}
ATF_TEST_CASE_WITH_CLEANUP(TEST_MACRO_3);
ATF_TEST_CASE_HEAD(TEST_MACRO_3) { }
ATF_TEST_CASE_BODY(TEST_MACRO_3) { }
ATF_TEST_CASE_CLEANUP(TEST_MACRO_3) { }
void instatiate_3(void) {
ATF_TEST_CASE_USE(TEST_MACRO_3);
atf::tests::tc* the_test = new ATF_TEST_CASE_NAME(TEST_MACRO_3)();
delete the_test;
}

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
// Copyright (c) 2008 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -38,6 +38,7 @@ extern "C" {
#include <stdexcept>
#include "macros.hpp"
#include "utils.hpp"
#include "detail/fs.hpp"
#include "detail/process.hpp"
@ -51,7 +52,7 @@ extern "C" {
static
void
create_ctl_file(const atf::tests::tc& tc, const char *name)
create_ctl_file(const char *name)
{
ATF_REQUIRE(open(name, O_CREAT | O_WRONLY | O_TRUNC, 0644) != -1);
}
@ -67,9 +68,9 @@ ATF_TEST_CASE_HEAD(h_pass)
}
ATF_TEST_CASE_BODY(h_pass)
{
create_ctl_file(*this, "before");
create_ctl_file("before");
ATF_PASS();
create_ctl_file(*this, "after");
create_ctl_file("after");
}
ATF_TEST_CASE(h_fail);
@ -79,9 +80,9 @@ ATF_TEST_CASE_HEAD(h_fail)
}
ATF_TEST_CASE_BODY(h_fail)
{
create_ctl_file(*this, "before");
create_ctl_file("before");
ATF_FAIL("Failed on purpose");
create_ctl_file(*this, "after");
create_ctl_file("after");
}
ATF_TEST_CASE(h_skip);
@ -91,9 +92,9 @@ ATF_TEST_CASE_HEAD(h_skip)
}
ATF_TEST_CASE_BODY(h_skip)
{
create_ctl_file(*this, "before");
create_ctl_file("before");
ATF_SKIP("Skipped on purpose");
create_ctl_file(*this, "after");
create_ctl_file("after");
}
ATF_TEST_CASE(h_require);
@ -105,9 +106,9 @@ ATF_TEST_CASE_BODY(h_require)
{
bool condition = atf::text::to_bool(get_config_var("condition"));
create_ctl_file(*this, "before");
create_ctl_file("before");
ATF_REQUIRE(condition);
create_ctl_file(*this, "after");
create_ctl_file("after");
}
ATF_TEST_CASE(h_require_eq);
@ -120,9 +121,28 @@ ATF_TEST_CASE_BODY(h_require_eq)
long v1 = atf::text::to_type< long >(get_config_var("v1"));
long v2 = atf::text::to_type< long >(get_config_var("v2"));
create_ctl_file(*this, "before");
create_ctl_file("before");
ATF_REQUIRE_EQ(v1, v2);
create_ctl_file(*this, "after");
create_ctl_file("after");
}
ATF_TEST_CASE(h_require_in);
ATF_TEST_CASE_HEAD(h_require_in)
{
set_md_var("descr", "Helper test case");
}
ATF_TEST_CASE_BODY(h_require_in)
{
const std::string element = get_config_var("value");
std::set< std::string > collection;
collection.insert("foo");
collection.insert("bar");
collection.insert("baz");
create_ctl_file("before");
ATF_REQUIRE_IN(element, collection);
create_ctl_file("after");
}
ATF_TEST_CASE(h_require_match);
@ -135,9 +155,28 @@ ATF_TEST_CASE_BODY(h_require_match)
const std::string regexp = get_config_var("regexp");
const std::string string = get_config_var("string");
create_ctl_file(*this, "before");
create_ctl_file("before");
ATF_REQUIRE_MATCH(regexp, string);
create_ctl_file(*this, "after");
create_ctl_file("after");
}
ATF_TEST_CASE(h_require_not_in);
ATF_TEST_CASE_HEAD(h_require_not_in)
{
set_md_var("descr", "Helper test case");
}
ATF_TEST_CASE_BODY(h_require_not_in)
{
const std::string element = get_config_var("value");
std::set< std::string > collection;
collection.insert("foo");
collection.insert("bar");
collection.insert("baz");
create_ctl_file("before");
ATF_REQUIRE_NOT_IN(element, collection);
create_ctl_file("after");
}
ATF_TEST_CASE(h_require_throw);
@ -147,7 +186,7 @@ ATF_TEST_CASE_HEAD(h_require_throw)
}
ATF_TEST_CASE_BODY(h_require_throw)
{
create_ctl_file(*this, "before");
create_ctl_file("before");
if (get_config_var("what") == "throw_int")
ATF_REQUIRE_THROW(std::runtime_error, if (1) throw int(5));
@ -158,7 +197,7 @@ ATF_TEST_CASE_BODY(h_require_throw)
ATF_REQUIRE_THROW(std::runtime_error,
if (0) throw std::runtime_error("e"));
create_ctl_file(*this, "after");
create_ctl_file("after");
}
ATF_TEST_CASE(h_require_throw_re);
@ -168,7 +207,7 @@ ATF_TEST_CASE_HEAD(h_require_throw_re)
}
ATF_TEST_CASE_BODY(h_require_throw_re)
{
create_ctl_file(*this, "before");
create_ctl_file("before");
if (get_config_var("what") == "throw_int")
ATF_REQUIRE_THROW_RE(std::runtime_error, "5", if (1) throw int(5));
@ -182,7 +221,7 @@ ATF_TEST_CASE_BODY(h_require_throw_re)
ATF_REQUIRE_THROW_RE(std::runtime_error, "e",
if (0) throw std::runtime_error("e"));
create_ctl_file(*this, "after");
create_ctl_file("after");
}
static int
@ -205,7 +244,7 @@ ATF_TEST_CASE_HEAD(h_check_errno)
}
ATF_TEST_CASE_BODY(h_check_errno)
{
create_ctl_file(*this, "before");
create_ctl_file("before");
if (get_config_var("what") == "no_error")
ATF_CHECK_ERRNO(-1, errno_ok_stub() == -1);
@ -216,7 +255,7 @@ ATF_TEST_CASE_BODY(h_check_errno)
else
UNREACHABLE;
create_ctl_file(*this, "after");
create_ctl_file("after");
}
ATF_TEST_CASE(h_require_errno);
@ -226,7 +265,7 @@ ATF_TEST_CASE_HEAD(h_require_errno)
}
ATF_TEST_CASE_BODY(h_require_errno)
{
create_ctl_file(*this, "before");
create_ctl_file("before");
if (get_config_var("what") == "no_error")
ATF_REQUIRE_ERRNO(-1, errno_ok_stub() == -1);
@ -237,7 +276,7 @@ ATF_TEST_CASE_BODY(h_require_errno)
else
UNREACHABLE;
create_ctl_file(*this, "after");
create_ctl_file("after");
}
// ------------------------------------------------------------------------
@ -251,8 +290,9 @@ ATF_TEST_CASE_HEAD(pass)
}
ATF_TEST_CASE_BODY(pass)
{
ATF_TEST_CASE_USE(h_pass);
run_h_tc< ATF_TEST_CASE_NAME(h_pass) >();
ATF_REQUIRE(grep_file("result", "^passed"));
ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));
ATF_REQUIRE(atf::fs::exists(atf::fs::path("before")));
ATF_REQUIRE(!atf::fs::exists(atf::fs::path("after")));
}
@ -264,8 +304,9 @@ ATF_TEST_CASE_HEAD(fail)
}
ATF_TEST_CASE_BODY(fail)
{
ATF_TEST_CASE_USE(h_fail);
run_h_tc< ATF_TEST_CASE_NAME(h_fail) >();
ATF_REQUIRE(grep_file("result", "^failed: Failed on purpose"));
ATF_REQUIRE(atf::utils::grep_file("^failed: Failed on purpose", "result"));
ATF_REQUIRE(atf::fs::exists(atf::fs::path("before")));
ATF_REQUIRE(!atf::fs::exists(atf::fs::path("after")));
}
@ -277,8 +318,10 @@ ATF_TEST_CASE_HEAD(skip)
}
ATF_TEST_CASE_BODY(skip)
{
ATF_TEST_CASE_USE(h_skip);
run_h_tc< ATF_TEST_CASE_NAME(h_skip) >();
ATF_REQUIRE(grep_file("result", "^skipped: Skipped on purpose"));
ATF_REQUIRE(atf::utils::grep_file("^skipped: Skipped on purpose",
"result"));
ATF_REQUIRE(atf::fs::exists(atf::fs::path("before")));
ATF_REQUIRE(!atf::fs::exists(atf::fs::path("after")));
}
@ -308,14 +351,16 @@ ATF_TEST_CASE_BODY(require)
std::cout << "Checking with a " << t->cond << " value\n";
ATF_TEST_CASE_USE(h_require);
run_h_tc< ATF_TEST_CASE_NAME(h_require) >(config);
ATF_REQUIRE(atf::fs::exists(before));
if (t->ok) {
ATF_REQUIRE(grep_file("result", "^passed"));
ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));
ATF_REQUIRE(atf::fs::exists(after));
} else {
ATF_REQUIRE(grep_file("result", "^failed: .*condition not met"));
ATF_REQUIRE(atf::utils::grep_file(
"^failed: .*condition not met", "result"));
ATF_REQUIRE(!atf::fs::exists(after));
}
@ -356,14 +401,60 @@ ATF_TEST_CASE_BODY(require_eq)
<< " and expecting " << (t->ok ? "true" : "false")
<< "\n";
ATF_TEST_CASE_USE(h_require_eq);
run_h_tc< ATF_TEST_CASE_NAME(h_require_eq) >(config);
ATF_REQUIRE(atf::fs::exists(before));
if (t->ok) {
ATF_REQUIRE(grep_file("result", "^passed"));
ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));
ATF_REQUIRE(atf::fs::exists(after));
} else {
ATF_REQUIRE(grep_file("result", "^failed: .*v1 != v2"));
ATF_REQUIRE(atf::utils::grep_file("^failed: .*v1 != v2", "result"));
ATF_REQUIRE(!atf::fs::exists(after));
}
atf::fs::remove(before);
if (t->ok)
atf::fs::remove(after);
}
}
ATF_TEST_CASE(require_in);
ATF_TEST_CASE_HEAD(require_in)
{
set_md_var("descr", "Tests the ATF_REQUIRE_IN macro");
}
ATF_TEST_CASE_BODY(require_in)
{
struct test {
const char *value;
bool ok;
} *t, tests[] = {
{ "foo", true },
{ "bar", true },
{ "baz", true },
{ "xxx", false },
{ "fooa", false },
{ "foo ", false },
{ NULL, false }
};
const atf::fs::path before("before");
const atf::fs::path after("after");
for (t = &tests[0]; t->value != NULL; t++) {
atf::tests::vars_map config;
config["value"] = t->value;
ATF_TEST_CASE_USE(h_require_in);
run_h_tc< ATF_TEST_CASE_NAME(h_require_in) >(config);
ATF_REQUIRE(atf::fs::exists(before));
if (t->ok) {
ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));
ATF_REQUIRE(atf::fs::exists(after));
} else {
ATF_REQUIRE(atf::utils::grep_file("^failed: ", "result"));
ATF_REQUIRE(!atf::fs::exists(after));
}
@ -402,14 +493,60 @@ ATF_TEST_CASE_BODY(require_match)
<< " and expecting " << (t->ok ? "true" : "false")
<< "\n";
ATF_TEST_CASE_USE(h_require_match);
run_h_tc< ATF_TEST_CASE_NAME(h_require_match) >(config);
ATF_REQUIRE(atf::fs::exists(before));
if (t->ok) {
ATF_REQUIRE(grep_file("result", "^passed"));
ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));
ATF_REQUIRE(atf::fs::exists(after));
} else {
ATF_REQUIRE(grep_file("result", "^failed: "));
ATF_REQUIRE(atf::utils::grep_file("^failed: ", "result"));
ATF_REQUIRE(!atf::fs::exists(after));
}
atf::fs::remove(before);
if (t->ok)
atf::fs::remove(after);
}
}
ATF_TEST_CASE(require_not_in);
ATF_TEST_CASE_HEAD(require_not_in)
{
set_md_var("descr", "Tests the ATF_REQUIRE_NOT_IN macro");
}
ATF_TEST_CASE_BODY(require_not_in)
{
struct test {
const char *value;
bool ok;
} *t, tests[] = {
{ "foo", false },
{ "bar", false },
{ "baz", false },
{ "xxx", true },
{ "fooa", true },
{ "foo ", true },
{ NULL, false }
};
const atf::fs::path before("before");
const atf::fs::path after("after");
for (t = &tests[0]; t->value != NULL; t++) {
atf::tests::vars_map config;
config["value"] = t->value;
ATF_TEST_CASE_USE(h_require_not_in);
run_h_tc< ATF_TEST_CASE_NAME(h_require_not_in) >(config);
ATF_REQUIRE(atf::fs::exists(before));
if (t->ok) {
ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));
ATF_REQUIRE(atf::fs::exists(after));
} else {
ATF_REQUIRE(atf::utils::grep_file("^failed: ", "result"));
ATF_REQUIRE(!atf::fs::exists(after));
}
@ -447,17 +584,18 @@ ATF_TEST_CASE_BODY(require_throw)
std::cout << "Checking with " << t->what << " and expecting "
<< (t->ok ? "true" : "false") << "\n";
ATF_TEST_CASE_USE(h_require_throw);
run_h_tc< ATF_TEST_CASE_NAME(h_require_throw) >(config);
ATF_REQUIRE(atf::fs::exists(before));
if (t->ok) {
ATF_REQUIRE(grep_file("result", "^passed"));
ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));
ATF_REQUIRE(atf::fs::exists(after));
} else {
std::cout << "Checking that message contains '" << t->msg
<< "'\n";
std::string exp_result = std::string("^failed: .*") + t->msg;
ATF_REQUIRE(grep_file("result", exp_result.c_str()));
ATF_REQUIRE(atf::utils::grep_file(exp_result.c_str(), "result"));
ATF_REQUIRE(!atf::fs::exists(after));
}
@ -481,8 +619,9 @@ ATF_TEST_CASE_BODY(require_throw_re)
} *t, tests[] = {
{ "throw_int", false, "unexpected error" },
{ "throw_rt_match", true, NULL },
{ "throw_rt_no_match", true, "threw.*runtime_error(baz foo bar a).*"
"does not match 'a foo bar baz'" },
{ "throw_rt_no_match", false,
"threw.*runtime_error\\(baz foo bar a\\).*"
"does not match 'foo\\.\\*baz'" },
{ "no_throw_rt", false, "did not throw" },
{ NULL, false, NULL }
};
@ -497,17 +636,18 @@ ATF_TEST_CASE_BODY(require_throw_re)
std::cout << "Checking with " << t->what << " and expecting "
<< (t->ok ? "true" : "false") << "\n";
run_h_tc< ATF_TEST_CASE_NAME(h_require_throw) >(config);
ATF_TEST_CASE_USE(h_require_throw_re);
run_h_tc< ATF_TEST_CASE_NAME(h_require_throw_re) >(config);
ATF_REQUIRE(atf::fs::exists(before));
if (t->ok) {
ATF_REQUIRE(grep_file("result", "^passed"));
ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));
ATF_REQUIRE(atf::fs::exists(after));
} else {
std::cout << "Checking that message contains '" << t->msg
<< "'\n";
std::string exp_result = std::string("^failed: .*") + t->msg;
ATF_REQUIRE(grep_file("result", exp_result.c_str()));
ATF_REQUIRE(atf::utils::grep_file(exp_result.c_str(), "result"));
ATF_REQUIRE(!atf::fs::exists(after));
}
@ -544,19 +684,20 @@ ATF_TEST_CASE_BODY(check_errno)
atf::tests::vars_map config;
config["what"] = t->what;
ATF_TEST_CASE_USE(h_check_errno);
run_h_tc< ATF_TEST_CASE_NAME(h_check_errno) >(config);
ATF_REQUIRE(atf::fs::exists(before));
ATF_REQUIRE(atf::fs::exists(after));
if (t->ok) {
ATF_REQUIRE(grep_file("result", "^passed"));
ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));
} else {
ATF_REQUIRE(grep_file("result", "^failed"));
ATF_REQUIRE(atf::utils::grep_file("^failed", "result"));
std::string exp_result = "macros_test.cpp:[0-9]+: " +
std::string(t->msg) + "$";
ATF_REQUIRE(grep_file("stderr", exp_result.c_str()));
ATF_REQUIRE(atf::utils::grep_file(exp_result.c_str(), "stderr"));
}
atf::fs::remove(before);
@ -591,16 +732,17 @@ ATF_TEST_CASE_BODY(require_errno)
atf::tests::vars_map config;
config["what"] = t->what;
ATF_TEST_CASE_USE(h_require_errno);
run_h_tc< ATF_TEST_CASE_NAME(h_require_errno) >(config);
ATF_REQUIRE(atf::fs::exists(before));
if (t->ok) {
ATF_REQUIRE(grep_file("result", "^passed"));
ATF_REQUIRE(atf::utils::grep_file("^passed", "result"));
ATF_REQUIRE(atf::fs::exists(after));
} else {
std::string exp_result = "^failed: .*macros_test.cpp:[0-9]+: " +
std::string(t->msg) + "$";
ATF_REQUIRE(grep_file("result", exp_result.c_str()));
ATF_REQUIRE(atf::utils::grep_file(exp_result.c_str(), "result"));
ATF_REQUIRE(!atf::fs::exists(after));
}
@ -621,6 +763,11 @@ BUILD_TC(use, "macros_hpp_test.cpp",
"do not cause syntax errors when used",
"Build of macros_hpp_test.cpp failed; some macros in "
"atf-c++/macros.hpp are broken");
BUILD_TC_FAIL(detect_unused_tests, "unused_test.cpp",
"Tests that defining an unused test case raises a warning (and thus "
"an error)",
"Build of unused_test.cpp passed; unused test cases are not properly "
"detected");
// ------------------------------------------------------------------------
// Main.
@ -635,7 +782,9 @@ ATF_INIT_TEST_CASES(tcs)
ATF_ADD_TEST_CASE(tcs, check_errno);
ATF_ADD_TEST_CASE(tcs, require);
ATF_ADD_TEST_CASE(tcs, require_eq);
ATF_ADD_TEST_CASE(tcs, require_in);
ATF_ADD_TEST_CASE(tcs, require_match);
ATF_ADD_TEST_CASE(tcs, require_not_in);
ATF_ADD_TEST_CASE(tcs, require_throw);
ATF_ADD_TEST_CASE(tcs, require_throw_re);
ATF_ADD_TEST_CASE(tcs, require_errno);
@ -643,4 +792,5 @@ ATF_INIT_TEST_CASES(tcs)
// 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);
}

View file

@ -0,0 +1,56 @@
//
// 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_NONCOPYABLE_HPP_)
#define _ATF_CXX_NONCOPYABLE_HPP_
namespace atf {
// ------------------------------------------------------------------------
// The "noncopyable" class.
// ------------------------------------------------------------------------
class noncopyable {
// The class cannot be empty; otherwise we get ABI-stability warnings
// during the build, which will break it due to strict checking.
int m_noncopyable_dummy;
noncopyable(const noncopyable& nc);
noncopyable& operator=(const noncopyable& nc);
protected:
// Explicitly needed to provide some non-private functions. Otherwise
// we also get some warnings during the build.
noncopyable(void) {}
~noncopyable(void) {}
};
} // namespace atf
#endif // !defined(_ATF_CXX_NONCOPYABLE_HPP_)

View file

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

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -55,9 +55,11 @@ extern "C" {
#include "atf-c/utils.h"
}
#include "noncopyable.hpp"
#include "tests.hpp"
#include "detail/application.hpp"
#include "detail/auto_array.hpp"
#include "detail/env.hpp"
#include "detail/exceptions.hpp"
#include "detail/fs.hpp"
@ -127,7 +129,7 @@ detail::match(const std::string& regexp, const std::string& str)
static std::map< atf_tc_t*, impl::tc* > wraps;
static std::map< const atf_tc_t*, const impl::tc* > cwraps;
struct impl::tc_impl : atf::utils::noncopyable {
struct impl::tc_impl : atf::noncopyable {
std::string m_ident;
atf_tc_t m_tc;
bool m_has_cleanup;
@ -190,8 +192,7 @@ impl::tc::init(const vars_map& config)
{
atf_error_t err;
utils::auto_array< const char * > array(
new const char*[(config.size() * 2) + 1]);
auto_array< const char * > array(new const char*[(config.size() * 2) + 1]);
const char **ptr = array.get();
for (vars_map::const_iterator iter = config.begin();
iter != config.end(); iter++) {
@ -641,6 +642,16 @@ tp::run_tc(const std::string& tcarg)
impl::tc* tc = find_tc(init_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 "
"control is being applied; you may get unexpected failures; see "
"atf-test-case(4)\n";
}
try {
switch (fields.second) {
case BODY:

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -38,7 +38,7 @@ extern "C" {
#include <atf-c/defs.h>
}
#include <atf-c++/utils.hpp>
#include <atf-c++/noncopyable.hpp>
namespace atf {
namespace tests {
@ -74,7 +74,7 @@ typedef std::map< std::string, std::string > vars_map;
struct tc_impl;
class tc : utils::noncopyable {
class tc : noncopyable {
std::auto_ptr< tc_impl > pimpl;
protected:

View file

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

View file

@ -0,0 +1,52 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2012 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 <atf-c++/macros.hpp>
ATF_TEST_CASE(this_is_used);
ATF_TEST_CASE_HEAD(this_is_used)
{
}
ATF_TEST_CASE_BODY(this_is_used)
{
}
ATF_TEST_CASE(this_is_unused);
ATF_TEST_CASE_HEAD(this_is_unused)
{
}
ATF_TEST_CASE_BODY(this_is_unused)
{
}
ATF_INIT_TEST_CASES(tcs)
{
ATF_ADD_TEST_CASE(tcs, this_is_used);
//ATF_ADD_TEST_CASE(tcs, this_is_unused);
}

View file

@ -0,0 +1,104 @@
//
// 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.
//
extern "C" {
#include "atf-c/utils.h"
}
#include <cstdlib>
#include <iostream>
#include "utils.hpp"
void
atf::utils::cat_file(const std::string& path, const std::string& prefix)
{
atf_utils_cat_file(path.c_str(), prefix.c_str());
}
void
atf::utils::copy_file(const std::string& source, const std::string& destination)
{
atf_utils_copy_file(source.c_str(), destination.c_str());
}
bool
atf::utils::compare_file(const std::string& path, const std::string& contents)
{
return atf_utils_compare_file(path.c_str(), contents.c_str());
}
void
atf::utils::create_file(const std::string& path, const std::string& contents)
{
atf_utils_create_file(path.c_str(), "%s", contents.c_str());
}
bool
atf::utils::file_exists(const std::string& path)
{
return atf_utils_file_exists(path.c_str());
}
pid_t
atf::utils::fork(void)
{
std::cout.flush();
std::cerr.flush();
return atf_utils_fork();
}
bool
atf::utils::grep_file(const std::string& regex, const std::string& path)
{
return atf_utils_grep_file("%s", path.c_str(), regex.c_str());
}
bool
atf::utils::grep_string(const std::string& regex, const std::string& str)
{
return atf_utils_grep_string("%s", str.c_str(), regex.c_str());
}
void
atf::utils::redirect(const int fd, const std::string& path)
{
if (fd == STDOUT_FILENO)
std::cout.flush();
else if (fd == STDERR_FILENO)
std::cerr.flush();
atf_utils_redirect(fd, path.c_str());
}
void
atf::utils::wait(const pid_t pid, const int exitstatus,
const std::string& expout, const std::string& experr)
{
atf_utils_wait(pid, exitstatus, expout.c_str(), experr.c_str());
}

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -30,170 +30,38 @@
#if !defined(_ATF_CXX_UTILS_HPP_)
#define _ATF_CXX_UTILS_HPP_
#include <cstddef>
extern "C" {
#include <unistd.h>
}
#include <string>
namespace atf {
namespace utils {
// ------------------------------------------------------------------------
// The "auto_array" class.
// ------------------------------------------------------------------------
void cat_file(const std::string&, const std::string&);
bool compare_file(const std::string&, const std::string&);
void copy_file(const std::string&, const std::string&);
void create_file(const std::string&, const std::string&);
bool file_exists(const std::string&);
pid_t fork(void);
bool grep_file(const std::string&, const std::string&);
bool grep_string(const std::string&, const std::string&);
void redirect(const int, const std::string&);
void wait(const pid_t, const int, const std::string&, const std::string&);
template< class T >
struct auto_array_ref {
T* m_ptr;
explicit auto_array_ref(T*);
};
template< class T >
auto_array_ref< T >::auto_array_ref(T* ptr) :
m_ptr(ptr)
template< typename Collection >
bool
grep_collection(const std::string& regexp, const Collection& collection)
{
}
template< class T >
class auto_array {
T* m_ptr;
public:
auto_array(T* = NULL) throw();
auto_array(auto_array< T >&) throw();
auto_array(auto_array_ref< T >) throw();
~auto_array(void) throw();
T* get(void) throw();
const T* get(void) const throw();
T* release(void) throw();
void reset(T* = NULL) throw();
auto_array< T >& operator=(auto_array< T >&) throw();
auto_array< T >& operator=(auto_array_ref< T >) throw();
T& operator[](int) throw();
operator auto_array_ref< T >(void) throw();
};
template< class T >
auto_array< T >::auto_array(T* ptr)
throw() :
m_ptr(ptr)
{
}
template< class T >
auto_array< T >::auto_array(auto_array< T >& ptr)
throw() :
m_ptr(ptr.release())
{
}
template< class T >
auto_array< T >::auto_array(auto_array_ref< T > ref)
throw() :
m_ptr(ref.m_ptr)
{
}
template< class T >
auto_array< T >::~auto_array(void)
throw()
{
if (m_ptr != NULL)
delete [] m_ptr;
}
template< class T >
T*
auto_array< T >::get(void)
throw()
{
return m_ptr;
}
template< class T >
const T*
auto_array< T >::get(void)
const throw()
{
return m_ptr;
}
template< class T >
T*
auto_array< T >::release(void)
throw()
{
T* ptr = m_ptr;
m_ptr = NULL;
return ptr;
}
template< class T >
void
auto_array< T >::reset(T* ptr)
throw()
{
if (m_ptr != NULL)
delete [] m_ptr;
m_ptr = ptr;
}
template< class T >
auto_array< T >&
auto_array< T >::operator=(auto_array< T >& ptr)
throw()
{
reset(ptr.release());
return *this;
}
template< class T >
auto_array< T >&
auto_array< T >::operator=(auto_array_ref< T > ref)
throw()
{
if (m_ptr != ref.m_ptr) {
delete [] m_ptr;
m_ptr = ref.m_ptr;
for (typename Collection::const_iterator iter = collection.begin();
iter != collection.end(); ++iter) {
if (grep_string(regexp, *iter))
return true;
}
return *this;
return false;
}
template< class T >
T&
auto_array< T >::operator[](int pos)
throw()
{
return m_ptr[pos];
}
template< class T >
auto_array< T >::operator auto_array_ref< T >(void)
throw()
{
return auto_array_ref< T >(release());
}
// ------------------------------------------------------------------------
// The "noncopyable" class.
// ------------------------------------------------------------------------
class noncopyable {
// The class cannot be empty; otherwise we get ABI-stability warnings
// during the build, which will break it due to strict checking.
int m_noncopyable_dummy;
noncopyable(const noncopyable& nc);
noncopyable& operator=(const noncopyable& nc);
protected:
// Explicitly needed to provide some non-private functions. Otherwise
// we also get some warnings during the build.
noncopyable(void) {}
~noncopyable(void) {}
};
} // namespace utils
} // namespace atf

View file

@ -1,7 +1,7 @@
//
// Automated Testing Framework (atf)
//
// Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
// Copyright (c) 2007 The NetBSD Foundation, Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@ -27,257 +27,409 @@
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
extern "C" {
#include <sys/stat.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
}
#include <cstdlib>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include "macros.hpp"
#include "utils.hpp"
#include "detail/test_helpers.hpp"
static std::string
read_file(const char *path)
{
char buffer[1024];
const int fd = open(path, O_RDONLY);
if (fd == -1)
ATF_FAIL("Cannot open " + std::string(path));
const ssize_t length = read(fd, buffer, sizeof(buffer) - 1);
close(fd);
ATF_REQUIRE(length != -1);
if (length == sizeof(buffer) - 1)
ATF_FAIL("Internal buffer not long enough to read temporary file");
((char *)buffer)[length] = '\0';
return buffer;
}
// ------------------------------------------------------------------------
// Tests for the "auto_array" class.
// Tests cases for the free functions.
// ------------------------------------------------------------------------
class test_array {
public:
int m_value;
ATF_TEST_CASE_WITHOUT_HEAD(cat_file__empty);
ATF_TEST_CASE_BODY(cat_file__empty)
{
atf::utils::create_file("file.txt", "");
atf::utils::redirect(STDOUT_FILENO, "captured.txt");
atf::utils::cat_file("file.txt", "PREFIX");
std::cout.flush();
close(STDOUT_FILENO);
static ssize_t m_nblocks;
ATF_REQUIRE_EQ("", read_file("captured.txt"));
}
static
atf::utils::auto_array< test_array >
do_copy(atf::utils::auto_array< test_array >& ta)
{
return atf::utils::auto_array< test_array >(ta);
ATF_TEST_CASE_WITHOUT_HEAD(cat_file__one_line);
ATF_TEST_CASE_BODY(cat_file__one_line)
{
atf::utils::create_file("file.txt", "This is a single line\n");
atf::utils::redirect(STDOUT_FILENO, "captured.txt");
atf::utils::cat_file("file.txt", "PREFIX");
std::cout.flush();
close(STDOUT_FILENO);
ATF_REQUIRE_EQ("PREFIXThis is a single line\n", read_file("captured.txt"));
}
ATF_TEST_CASE_WITHOUT_HEAD(cat_file__several_lines);
ATF_TEST_CASE_BODY(cat_file__several_lines)
{
atf::utils::create_file("file.txt", "First\nSecond line\nAnd third\n");
atf::utils::redirect(STDOUT_FILENO, "captured.txt");
atf::utils::cat_file("file.txt", ">");
std::cout.flush();
close(STDOUT_FILENO);
ATF_REQUIRE_EQ(">First\n>Second line\n>And third\n",
read_file("captured.txt"));
}
ATF_TEST_CASE_WITHOUT_HEAD(cat_file__no_newline_eof);
ATF_TEST_CASE_BODY(cat_file__no_newline_eof)
{
atf::utils::create_file("file.txt", "Foo\n bar baz");
atf::utils::redirect(STDOUT_FILENO, "captured.txt");
atf::utils::cat_file("file.txt", "PREFIX");
std::cout.flush();
close(STDOUT_FILENO);
ATF_REQUIRE_EQ("PREFIXFoo\nPREFIX bar baz", read_file("captured.txt"));
}
ATF_TEST_CASE_WITHOUT_HEAD(compare_file__empty__match);
ATF_TEST_CASE_BODY(compare_file__empty__match)
{
atf::utils::create_file("test.txt", "");
ATF_REQUIRE(atf::utils::compare_file("test.txt", ""));
}
ATF_TEST_CASE_WITHOUT_HEAD(compare_file__empty__not_match);
ATF_TEST_CASE_BODY(compare_file__empty__not_match)
{
atf::utils::create_file("test.txt", "");
ATF_REQUIRE(!atf::utils::compare_file("test.txt", "\n"));
ATF_REQUIRE(!atf::utils::compare_file("test.txt", "foo"));
ATF_REQUIRE(!atf::utils::compare_file("test.txt", " "));
}
ATF_TEST_CASE_WITHOUT_HEAD(compare_file__short__match);
ATF_TEST_CASE_BODY(compare_file__short__match)
{
atf::utils::create_file("test.txt", "this is a short file");
ATF_REQUIRE(atf::utils::compare_file("test.txt", "this is a short file"));
}
ATF_TEST_CASE_WITHOUT_HEAD(compare_file__short__not_match);
ATF_TEST_CASE_BODY(compare_file__short__not_match)
{
atf::utils::create_file("test.txt", "this is a short file");
ATF_REQUIRE(!atf::utils::compare_file("test.txt", ""));
ATF_REQUIRE(!atf::utils::compare_file("test.txt", "\n"));
ATF_REQUIRE(!atf::utils::compare_file("test.txt", "this is a Short file"));
ATF_REQUIRE(!atf::utils::compare_file("test.txt", "this is a short fil"));
ATF_REQUIRE(!atf::utils::compare_file("test.txt", "this is a short file "));
}
ATF_TEST_CASE_WITHOUT_HEAD(compare_file__long__match);
ATF_TEST_CASE_BODY(compare_file__long__match)
{
char long_contents[3456];
size_t i = 0;
for (; i < sizeof(long_contents) - 1; i++)
long_contents[i] = '0' + (i % 10);
long_contents[i] = '\0';
atf::utils::create_file("test.txt", long_contents);
ATF_REQUIRE(atf::utils::compare_file("test.txt", long_contents));
}
ATF_TEST_CASE_WITHOUT_HEAD(compare_file__long__not_match);
ATF_TEST_CASE_BODY(compare_file__long__not_match)
{
char long_contents[3456];
size_t i = 0;
for (; i < sizeof(long_contents) - 1; i++)
long_contents[i] = '0' + (i % 10);
long_contents[i] = '\0';
atf::utils::create_file("test.txt", long_contents);
ATF_REQUIRE(!atf::utils::compare_file("test.txt", ""));
ATF_REQUIRE(!atf::utils::compare_file("test.txt", "\n"));
ATF_REQUIRE(!atf::utils::compare_file("test.txt", "0123456789"));
long_contents[i - 1] = 'Z';
ATF_REQUIRE(!atf::utils::compare_file("test.txt", long_contents));
}
ATF_TEST_CASE_WITHOUT_HEAD(copy_file__empty);
ATF_TEST_CASE_BODY(copy_file__empty)
{
atf::utils::create_file("src.txt", "");
ATF_REQUIRE(chmod("src.txt", 0520) != -1);
atf::utils::copy_file("src.txt", "dest.txt");
ATF_REQUIRE(atf::utils::compare_file("dest.txt", ""));
struct stat sb;
ATF_REQUIRE(stat("dest.txt", &sb) != -1);
ATF_REQUIRE_EQ(0520, sb.st_mode & 0xfff);
}
ATF_TEST_CASE_WITHOUT_HEAD(copy_file__some_contents);
ATF_TEST_CASE_BODY(copy_file__some_contents)
{
atf::utils::create_file("src.txt", "This is a\ntest file\n");
atf::utils::copy_file("src.txt", "dest.txt");
ATF_REQUIRE(atf::utils::compare_file("dest.txt", "This is a\ntest file\n"));
}
ATF_TEST_CASE_WITHOUT_HEAD(create_file);
ATF_TEST_CASE_BODY(create_file)
{
atf::utils::create_file("test.txt", "This is a %d test");
ATF_REQUIRE_EQ("This is a %d test", read_file("test.txt"));
}
ATF_TEST_CASE_WITHOUT_HEAD(file_exists);
ATF_TEST_CASE_BODY(file_exists)
{
atf::utils::create_file("test.txt", "foo");
ATF_REQUIRE( atf::utils::file_exists("test.txt"));
ATF_REQUIRE( atf::utils::file_exists("./test.txt"));
ATF_REQUIRE(!atf::utils::file_exists("./test.tx"));
ATF_REQUIRE(!atf::utils::file_exists("test.txt2"));
}
ATF_TEST_CASE_WITHOUT_HEAD(fork);
ATF_TEST_CASE_BODY(fork)
{
std::cout << "Should not get into child\n";
std::cerr << "Should not get into child\n";
pid_t pid = atf::utils::fork();
if (pid == 0) {
std::cout << "Child stdout\n";
std::cerr << "Child stderr\n";
exit(EXIT_SUCCESS);
}
void* operator new(size_t size)
{
ATF_FAIL("New called but should have been new[]");
return new int(5);
int status;
ATF_REQUIRE(waitpid(pid, &status, 0) != -1);
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"));
}
ATF_TEST_CASE_WITHOUT_HEAD(grep_collection__set);
ATF_TEST_CASE_BODY(grep_collection__set)
{
std::set< std::string > strings;
strings.insert("First");
strings.insert("Second");
ATF_REQUIRE( atf::utils::grep_collection("irs", strings));
ATF_REQUIRE( atf::utils::grep_collection("cond", strings));
ATF_REQUIRE(!atf::utils::grep_collection("Third", strings));
}
ATF_TEST_CASE_WITHOUT_HEAD(grep_collection__vector);
ATF_TEST_CASE_BODY(grep_collection__vector)
{
std::vector< std::string > strings;
strings.push_back("First");
strings.push_back("Second");
ATF_REQUIRE( atf::utils::grep_collection("irs", strings));
ATF_REQUIRE( atf::utils::grep_collection("cond", strings));
ATF_REQUIRE(!atf::utils::grep_collection("Third", strings));
}
ATF_TEST_CASE_WITHOUT_HEAD(grep_file);
ATF_TEST_CASE_BODY(grep_file)
{
atf::utils::create_file("test.txt", "line1\nthe second line\naaaabbbb\n");
ATF_REQUIRE(atf::utils::grep_file("line1", "test.txt"));
ATF_REQUIRE(atf::utils::grep_file("second line", "test.txt"));
ATF_REQUIRE(atf::utils::grep_file("aa.*bb", "test.txt"));
ATF_REQUIRE(!atf::utils::grep_file("foo", "test.txt"));
ATF_REQUIRE(!atf::utils::grep_file("bar", "test.txt"));
ATF_REQUIRE(!atf::utils::grep_file("aaaaa", "test.txt"));
}
ATF_TEST_CASE_WITHOUT_HEAD(grep_string);
ATF_TEST_CASE_BODY(grep_string)
{
const char *str = "a string - aaaabbbb";
ATF_REQUIRE(atf::utils::grep_string("a string", str));
ATF_REQUIRE(atf::utils::grep_string("^a string", str));
ATF_REQUIRE(atf::utils::grep_string("aaaabbbb$", str));
ATF_REQUIRE(atf::utils::grep_string("aa.*bb", str));
ATF_REQUIRE(!atf::utils::grep_string("foo", str));
ATF_REQUIRE(!atf::utils::grep_string("bar", str));
ATF_REQUIRE(!atf::utils::grep_string("aaaaa", str));
}
ATF_TEST_CASE_WITHOUT_HEAD(redirect__stdout);
ATF_TEST_CASE_BODY(redirect__stdout)
{
std::cout << "Buffer this";
atf::utils::redirect(STDOUT_FILENO, "captured.txt");
std::cout << "The printed message";
std::cout.flush();
ATF_REQUIRE_EQ("The printed message", read_file("captured.txt"));
}
ATF_TEST_CASE_WITHOUT_HEAD(redirect__stderr);
ATF_TEST_CASE_BODY(redirect__stderr)
{
std::cerr << "Buffer this";
atf::utils::redirect(STDERR_FILENO, "captured.txt");
std::cerr << "The printed message";
std::cerr.flush();
ATF_REQUIRE_EQ("The printed message", read_file("captured.txt"));
}
ATF_TEST_CASE_WITHOUT_HEAD(redirect__other);
ATF_TEST_CASE_BODY(redirect__other)
{
const std::string message = "Foo bar\nbaz\n";
atf::utils::redirect(15, "captured.txt");
ATF_REQUIRE(write(15, message.c_str(), message.length()) != -1);
close(15);
ATF_REQUIRE_EQ(message, read_file("captured.txt"));
}
static void
fork_and_wait(const int exitstatus, const char* expout, const char* experr)
{
const pid_t pid = atf::utils::fork();
if (pid == 0) {
std::cout << "Some output\n";
std::cerr << "Some error\n";
exit(123);
}
atf::utils::wait(pid, exitstatus, expout, experr);
exit(EXIT_SUCCESS);
}
void* operator new[](size_t size)
{
m_nblocks++;
void* mem = ::operator new(size);
std::cout << "Allocated 'test_array' object " << mem << "\n";
return mem;
ATF_TEST_CASE_WITHOUT_HEAD(wait__ok);
ATF_TEST_CASE_BODY(wait__ok)
{
const pid_t control = fork();
ATF_REQUIRE(control != -1);
if (control == 0)
fork_and_wait(123, "Some output\n", "Some error\n");
else {
int status;
ATF_REQUIRE(waitpid(control, &status, 0) != -1);
ATF_REQUIRE(WIFEXITED(status));
ATF_REQUIRE_EQ(EXIT_SUCCESS, WEXITSTATUS(status));
}
}
void operator delete(void* mem)
{
ATF_FAIL("Delete called but should have been delete[]");
ATF_TEST_CASE_WITHOUT_HEAD(wait__invalid_exitstatus);
ATF_TEST_CASE_BODY(wait__invalid_exitstatus)
{
const pid_t control = fork();
ATF_REQUIRE(control != -1);
if (control == 0)
fork_and_wait(120, "Some output\n", "Some error\n");
else {
int status;
ATF_REQUIRE(waitpid(control, &status, 0) != -1);
ATF_REQUIRE(WIFEXITED(status));
ATF_REQUIRE_EQ(EXIT_FAILURE, WEXITSTATUS(status));
}
}
void operator delete[](void* mem)
{
std::cout << "Releasing 'test_array' object " << mem << "\n";
if (m_nblocks == 0)
ATF_FAIL("Unbalanced delete[]");
m_nblocks--;
::operator delete(mem);
ATF_TEST_CASE_WITHOUT_HEAD(wait__invalid_stdout);
ATF_TEST_CASE_BODY(wait__invalid_stdout)
{
const pid_t control = fork();
ATF_REQUIRE(control != -1);
if (control == 0)
fork_and_wait(123, "Some output foo\n", "Some error\n");
else {
int status;
ATF_REQUIRE(waitpid(control, &status, 0) != -1);
ATF_REQUIRE(WIFEXITED(status));
ATF_REQUIRE_EQ(EXIT_FAILURE, WEXITSTATUS(status));
}
};
ssize_t test_array::m_nblocks = 0;
ATF_TEST_CASE(auto_array_scope);
ATF_TEST_CASE_HEAD(auto_array_scope)
{
set_md_var("descr", "Tests the automatic scope handling in the "
"auto_array smart pointer class");
}
ATF_TEST_CASE_BODY(auto_array_scope)
{
using atf::utils::auto_array;
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
{
auto_array< test_array > t(new test_array[10]);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
ATF_TEST_CASE_WITHOUT_HEAD(wait__invalid_stderr);
ATF_TEST_CASE_BODY(wait__invalid_stderr)
{
const pid_t control = fork();
ATF_REQUIRE(control != -1);
if (control == 0)
fork_and_wait(123, "Some output\n", "Some error foo\n");
else {
int status;
ATF_REQUIRE(waitpid(control, &status, 0) != -1);
ATF_REQUIRE(WIFEXITED(status));
ATF_REQUIRE_EQ(EXIT_FAILURE, WEXITSTATUS(status));
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_TEST_CASE(auto_array_copy);
ATF_TEST_CASE_HEAD(auto_array_copy)
ATF_TEST_CASE_WITHOUT_HEAD(wait__save_stdout);
ATF_TEST_CASE_BODY(wait__save_stdout)
{
set_md_var("descr", "Tests the auto_array smart pointer class' copy "
"constructor");
}
ATF_TEST_CASE_BODY(auto_array_copy)
{
using atf::utils::auto_array;
const pid_t control = fork();
ATF_REQUIRE(control != -1);
if (control == 0)
fork_and_wait(123, "save:my-output.txt", "Some error\n");
else {
int status;
ATF_REQUIRE(waitpid(control, &status, 0) != -1);
ATF_REQUIRE(WIFEXITED(status));
ATF_REQUIRE_EQ(EXIT_SUCCESS, WEXITSTATUS(status));
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
{
auto_array< test_array > t1(new test_array[10]);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
{
auto_array< test_array > t2(t1);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
ATF_REQUIRE(atf::utils::compare_file("my-output.txt", "Some output\n"));
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_TEST_CASE(auto_array_copy_ref);
ATF_TEST_CASE_HEAD(auto_array_copy_ref)
ATF_TEST_CASE_WITHOUT_HEAD(wait__save_stderr);
ATF_TEST_CASE_BODY(wait__save_stderr)
{
set_md_var("descr", "Tests the auto_array smart pointer class' copy "
"constructor through the auxiliary auto_array_ref object");
}
ATF_TEST_CASE_BODY(auto_array_copy_ref)
{
using atf::utils::auto_array;
const pid_t control = fork();
ATF_REQUIRE(control != -1);
if (control == 0)
fork_and_wait(123, "Some output\n", "save:my-output.txt");
else {
int status;
ATF_REQUIRE(waitpid(control, &status, 0) != -1);
ATF_REQUIRE(WIFEXITED(status));
ATF_REQUIRE_EQ(EXIT_SUCCESS, WEXITSTATUS(status));
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
{
auto_array< test_array > t1(new test_array[10]);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
{
auto_array< test_array > t2 = test_array::do_copy(t1);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
ATF_REQUIRE(atf::utils::compare_file("my-output.txt", "Some error\n"));
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_TEST_CASE(auto_array_get);
ATF_TEST_CASE_HEAD(auto_array_get)
{
set_md_var("descr", "Tests the auto_array smart pointer class' get "
"method");
}
ATF_TEST_CASE_BODY(auto_array_get)
{
using atf::utils::auto_array;
test_array* ta = new test_array[10];
auto_array< test_array > t(ta);
ATF_REQUIRE_EQ(t.get(), ta);
}
ATF_TEST_CASE(auto_array_release);
ATF_TEST_CASE_HEAD(auto_array_release)
{
set_md_var("descr", "Tests the auto_array smart pointer class' release "
"method");
}
ATF_TEST_CASE_BODY(auto_array_release)
{
using atf::utils::auto_array;
test_array* ta1 = new test_array[10];
{
auto_array< test_array > t(ta1);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
test_array* ta2 = t.release();
ATF_REQUIRE_EQ(ta2, ta1);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
delete [] ta1;
}
ATF_TEST_CASE(auto_array_reset);
ATF_TEST_CASE_HEAD(auto_array_reset)
{
set_md_var("descr", "Tests the auto_array smart pointer class' reset "
"method");
}
ATF_TEST_CASE_BODY(auto_array_reset)
{
using atf::utils::auto_array;
test_array* ta1 = new test_array[10];
test_array* ta2 = new test_array[10];
ATF_REQUIRE_EQ(test_array::m_nblocks, 2);
{
auto_array< test_array > t(ta1);
ATF_REQUIRE_EQ(test_array::m_nblocks, 2);
t.reset(ta2);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
t.reset();
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_TEST_CASE(auto_array_assign);
ATF_TEST_CASE_HEAD(auto_array_assign)
{
set_md_var("descr", "Tests the auto_array smart pointer class' "
"assignment operator");
}
ATF_TEST_CASE_BODY(auto_array_assign)
{
using atf::utils::auto_array;
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
{
auto_array< test_array > t1(new test_array[10]);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
{
auto_array< test_array > t2;
t2 = t1;
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_TEST_CASE(auto_array_assign_ref);
ATF_TEST_CASE_HEAD(auto_array_assign_ref)
{
set_md_var("descr", "Tests the auto_array smart pointer class' "
"assignment operator through the auxiliary auto_array_ref "
"object");
}
ATF_TEST_CASE_BODY(auto_array_assign_ref)
{
using atf::utils::auto_array;
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
{
auto_array< test_array > t1(new test_array[10]);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
{
auto_array< test_array > t2;
t2 = test_array::do_copy(t1);
ATF_REQUIRE_EQ(test_array::m_nblocks, 1);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_REQUIRE_EQ(test_array::m_nblocks, 0);
}
ATF_TEST_CASE(auto_array_access);
ATF_TEST_CASE_HEAD(auto_array_access)
{
set_md_var("descr", "Tests the auto_array smart pointer class' access "
"operator");
}
ATF_TEST_CASE_BODY(auto_array_access)
{
using atf::utils::auto_array;
auto_array< test_array > t(new test_array[10]);
for (int i = 0; i < 10; i++)
t[i].m_value = i * 2;
for (int i = 0; i < 10; i++)
ATF_REQUIRE_EQ(t[i].m_value, i * 2);
}
// ------------------------------------------------------------------------
@ -292,16 +444,43 @@ HEADER_TC(include, "atf-c++/utils.hpp");
ATF_INIT_TEST_CASES(tcs)
{
// Add the test for the "auto_array" class.
ATF_ADD_TEST_CASE(tcs, auto_array_scope);
ATF_ADD_TEST_CASE(tcs, auto_array_copy);
ATF_ADD_TEST_CASE(tcs, auto_array_copy_ref);
ATF_ADD_TEST_CASE(tcs, auto_array_get);
ATF_ADD_TEST_CASE(tcs, auto_array_release);
ATF_ADD_TEST_CASE(tcs, auto_array_reset);
ATF_ADD_TEST_CASE(tcs, auto_array_assign);
ATF_ADD_TEST_CASE(tcs, auto_array_assign_ref);
ATF_ADD_TEST_CASE(tcs, auto_array_access);
// Add the test for the free functions.
ATF_ADD_TEST_CASE(tcs, cat_file__empty);
ATF_ADD_TEST_CASE(tcs, cat_file__one_line);
ATF_ADD_TEST_CASE(tcs, cat_file__several_lines);
ATF_ADD_TEST_CASE(tcs, cat_file__no_newline_eof);
ATF_ADD_TEST_CASE(tcs, compare_file__empty__match);
ATF_ADD_TEST_CASE(tcs, compare_file__empty__not_match);
ATF_ADD_TEST_CASE(tcs, compare_file__short__match);
ATF_ADD_TEST_CASE(tcs, compare_file__short__not_match);
ATF_ADD_TEST_CASE(tcs, compare_file__long__match);
ATF_ADD_TEST_CASE(tcs, compare_file__long__not_match);
ATF_ADD_TEST_CASE(tcs, copy_file__empty);
ATF_ADD_TEST_CASE(tcs, copy_file__some_contents);
ATF_ADD_TEST_CASE(tcs, create_file);
ATF_ADD_TEST_CASE(tcs, file_exists);
ATF_ADD_TEST_CASE(tcs, fork);
ATF_ADD_TEST_CASE(tcs, grep_collection__set);
ATF_ADD_TEST_CASE(tcs, grep_collection__vector);
ATF_ADD_TEST_CASE(tcs, grep_file);
ATF_ADD_TEST_CASE(tcs, grep_string);
ATF_ADD_TEST_CASE(tcs, redirect__stdout);
ATF_ADD_TEST_CASE(tcs, redirect__stderr);
ATF_ADD_TEST_CASE(tcs, redirect__other);
ATF_ADD_TEST_CASE(tcs, wait__ok);
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);

View file

@ -32,5 +32,6 @@
#include <atf-c/error.h>
#include <atf-c/macros.h>
#include <atf-c/utils.h>
#endif /* !defined(ATF_C_H) */

View file

@ -10,6 +10,7 @@ tp: check_test
tp: config_test
tp: error_test
tp: macros_test
tp: pkg_config_test
tp: tc_test
tp: tp_test
tp: utils_test

View file

@ -0,0 +1,16 @@
syntax("kyuafile", 1)
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"}
atf_test_program{name="tc_test"}
atf_test_program{name="tp_test"}
atf_test_program{name="utils_test"}
include("detail/Kyuafile")

View file

@ -1,7 +1,7 @@
#
# Automated Testing Framework (atf)
#
# Copyright (c) 2007, 2008, 2009, 2010 The NetBSD Foundation, Inc.
# Copyright (c) 2007 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -62,6 +62,7 @@ libatf_c_la_CPPFLAGS = "-DATF_ARCH=\"$(atf_arch)\"" \
"-DATF_SHELL=\"$(ATF_SHELL)\"" \
"-DATF_WORKDIR=\"$(ATF_WORKDIR)\"" \
-I$(srcdir)/atf-c
libatf_c_la_LDFLAGS = -version-info 0:0:0
# XXX For some reason, the nodist line above does not work as expected.
# Work this problem around.
@ -84,21 +85,26 @@ atf_cdir = $(includedir)/atf-c
dist_man_MANS += atf-c/atf-c-api.3
atf_aclocal_DATA += atf-c/atf-common.m4 atf-c/atf-c.m4
EXTRA_DIST += atf-c/atf-common.m4 atf-c/atf-c.m4
atf_cpkgconfigdir = $(atf_pkgconfigdir)
atf_cpkgconfig_DATA = atf-c/atf-c.pc
CLEANFILES += atf-c/atf-c.pc
EXTRA_DIST += atf-c/atf-c.pc.in
atf-c/atf-c.pc: $(srcdir)/atf-c/atf-c.pc.in
atf-c/atf-c.pc: $(srcdir)/atf-c/atf-c.pc.in Makefile
test -d atf-c || mkdir -p atf-c
sed -e 's,__ATF_VERSION__,@PACKAGE_VERSION@,g' \
-e 's,__CC__,$(CC),g' \
-e 's,__INCLUDEDIR__,$(includedir),g' \
-e 's,__LIBDIR__,$(libdir),g' \
sed -e 's#__ATF_VERSION__#$(PACKAGE_VERSION)#g' \
-e 's#__CC__#$(CC)#g' \
-e 's#__INCLUDEDIR__#$(includedir)#g' \
-e 's#__LIBDIR__#$(libdir)#g' \
<$(srcdir)/atf-c/atf-c.pc.in >atf-c/atf-c.pc.tmp
mv atf-c/atf-c.pc.tmp atf-c/atf-c.pc
tests_atf_c_DATA = atf-c/Atffile \
atf-c/macros_h_test.c
atf-c/Kyuafile \
atf-c/macros_h_test.c \
atf-c/unused_test.c
tests_atf_cdir = $(pkgtestsdir)/atf-c
EXTRA_DIST += $(tests_atf_c_DATA)

View file

@ -1,7 +1,7 @@
.\"
.\" Automated Testing Framework (atf)
.\"
.\" Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
.\" Copyright (c) 2008 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@ -26,14 +26,17 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd November 1, 2010
.Dd November 30, 2012
.Dt ATF-C-API 3
.Os
.Sh NAME
.Nm atf-c-api ,
.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 ,
@ -41,6 +44,8 @@
.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 ,
@ -56,6 +61,12 @@
.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 ,
@ -66,7 +77,19 @@
.Nm atf_tc_fail ,
.Nm atf_tc_fail_nonfatal ,
.Nm atf_tc_pass ,
.Nm atf_tc_skip
.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
@ -74,6 +97,8 @@
.Fn ATF_CHECK_MSG "expression" "fail_msg_fmt" ...
.Fn ATF_CHECK_EQ "expression_1" "expression_2"
.Fn ATF_CHECK_EQ_MSG "expression_1" "expression_2" "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 "exp_errno" "bool_expression"
@ -81,6 +106,8 @@
.Fn ATF_REQUIRE_MSG "expression" "fail_msg_fmt" ...
.Fn ATF_REQUIRE_EQ "expression_1" "expression_2"
.Fn ATF_REQUIRE_EQ_MSG "expression_1" "expression_2" "fail_msg_fmt" ...
.Fn ATF_REQUIRE_MATCH "regexp" "string"
.Fn ATF_REQUIRE_MATCH_MSG "regexp" "string" "fail_msg_fmt" ...
.Fn ATF_REQUIRE_STREQ "string_1" "string_2"
.Fn ATF_REQUIRE_STREQ_MSG "string_1" "string_2" "fail_msg_fmt" ...
.Fn ATF_REQUIRE_ERRNO "exp_errno" "bool_expression"
@ -96,6 +123,12 @@
.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" "..."
@ -107,6 +140,67 @@
.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
The ATF
.Pp
@ -248,6 +342,16 @@ 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
@ -360,7 +464,7 @@ 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 now sense to continue the execution of a
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
@ -395,6 +499,16 @@ and
.Fn ATF_REQUIRE_EQ_MSG
take two expressions and fail if the two evaluated values are not equal.
.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
@ -411,6 +525,180 @@ 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 -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 -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 -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 -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 -offset indent
Checks if
.Fa file
exists.
.Ed
.Pp
.Ft pid_t
.Fo atf_utils_fork
.Fa "void"
.Fc
.Bd -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 -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 -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 -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 -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 -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 -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 EXAMPLES
The following shows a complete test program with a single test case that
validates the addition operator:

View file

@ -0,0 +1,48 @@
dnl
dnl Automated Testing Framework (atf)
dnl
dnl Copyright 2011 Google Inc.
dnl All rights reserved.
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are permitted provided that the following conditions are
dnl met:
dnl
dnl * Redistributions of source code must retain the above copyright
dnl notice, this list of conditions and the following disclaimer.
dnl * Redistributions in binary form must reproduce the above copyright
dnl notice, this list of conditions and the following disclaimer in the
dnl documentation and/or other materials provided with the distribution.
dnl * Neither the name of Google Inc. nor the names of its contributors
dnl may be used to endorse or promote products derived from this software
dnl without specific prior written permission.
dnl
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dnl
dnl ATF_CHECK_C([version-spec])
dnl
dnl Checks if atf-c is present. If version-spec is provided, ensures that
dnl the installed version of atf-sh matches the required version. This
dnl argument must be something like '>= 0.14' and accepts any version
dnl specification supported by pkg-config.
dnl
dnl Defines and substitutes ATF_C_CFLAGS and ATF_C_LIBS with the compiler
dnl and linker flags need to build against atf-c.
AC_DEFUN([ATF_CHECK_C], [
spec="atf-c[]m4_default_nblank([ $1], [])"
_ATF_CHECK_ARG_WITH(
[PKG_CHECK_MODULES([ATF_C], [${spec}],
[found=yes found_atf_c=yes], [found=no])],
[required ${spec} not found])
])

View file

@ -0,0 +1,92 @@
dnl
dnl Automated Testing Framework (atf)
dnl
dnl Copyright 2011 Google Inc.
dnl All rights reserved.
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are permitted provided that the following conditions are
dnl met:
dnl
dnl * Redistributions of source code must retain the above copyright
dnl notice, this list of conditions and the following disclaimer.
dnl * Redistributions in binary form must reproduce the above copyright
dnl notice, this list of conditions and the following disclaimer in the
dnl documentation and/or other materials provided with the distribution.
dnl * Neither the name of Google Inc. nor the names of its contributors
dnl may be used to endorse or promote products derived from this software
dnl without specific prior written permission.
dnl
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dnl
dnl ATF_ARG_WITH
dnl
dnl Adds a --with-atf flag to the configure script that allows the user to
dnl enable or disable atf support.
dnl
dnl The ATF_CHECK_{C,CXX,SH} macros honor the flag defined herein if
dnl instantiated. If not instantiated, they will request the presence of
dnl the libraries unconditionally.
dnl
dnl Defines the WITH_ATF Automake conditional if ATF has been found by any
dnl of the ATF_CHECK_{C,CXX,SH} macros.
AC_DEFUN([ATF_ARG_WITH], [
m4_define([atf_arg_with_called], [yes])
m4_divert_text([DEFAULTS], [with_atf=auto])
AC_ARG_WITH([atf],
[AS_HELP_STRING([--with-atf=<yes|no|auto>],
[build atf-based test programs])],
[with_atf=${withval}], [with_atf=auto])
m4_divert_text([DEFAULTS], [
found_atf_c=no
found_atf_cxx=no
found_atf_sh=no
])
AM_CONDITIONAL([WITH_ATF], [test x"${found_atf_c}" = x"yes" -o \
x"${found_atf_cxx}" = x"yes" -o \
x"${found_atf_sh}" = x"yes"])
])
dnl _ATF_CHECK_ARG_WITH(check, error_message)
dnl
dnl Internal macro to execute a check conditional on the --with-atf flag
dnl and handle the result accordingly.
dnl
dnl 'check' specifies the piece of code to be run to detect the feature.
dnl This code must set the 'found' shell variable to yes or no depending
dnl on the raw result of the check.
AC_DEFUN([_ATF_CHECK_ARG_WITH], [
m4_ifdef([atf_arg_with_called], [
m4_fatal([ATF_ARG_WITH must be called after the ATF_CHECK_* checks])
])
m4_divert_text([DEFAULTS], [with_atf=yes])
if test x"${with_atf}" = x"no"; then
_found=no
else
$1
if test x"${with_atf}" = x"auto"; then
_found="${found}"
else
if test x"${found}" = x"yes"; then
_found=yes
else
AC_MSG_ERROR([$2])
fi
fi
fi
])

View file

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

View file

@ -1,7 +1,7 @@
/*
* Automated Testing Framework (atf)
*
* Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -306,8 +306,6 @@ atf_check_result_init(atf_check_result_t *r, const char *const *argv,
if (r->pimpl == NULL)
return atf_no_memory_error();
(void) atf_config_get("atf_workdir");
err = array_to_list(argv, &r->pimpl->m_argv);
if (atf_is_error(err))
goto out;

View file

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

View file

@ -1,7 +1,7 @@
/*
* Automated Testing Framework (atf)
*
* Copyright (c) 2008, 2009, 2010 The NetBSD Foundation, Inc.
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -90,14 +90,10 @@ static
void
check_line(int fd, const char *exp)
{
atf_dynstr_t line;
atf_dynstr_init(&line);
ATF_CHECK(!read_line(fd, &line));
ATF_CHECK_MSG(atf_equal_dynstr_cstring(&line, exp),
"read: '%s', expected: '%s'",
atf_dynstr_cstring(&line), exp);
atf_dynstr_fini(&line);
char *line = atf_utils_readline(fd);
ATF_CHECK(line != NULL);
ATF_CHECK_STREQ_MSG(exp, line, "read: '%s', expected: '%s'", line, exp);
free(line);
}
/* ---------------------------------------------------------------------
@ -246,15 +242,15 @@ ATF_TC_BODY(build_c_o, tc)
{
init_and_run_h_tc(&ATF_TC_NAME(h_build_c_o_ok),
&ATF_TC_PACK_NAME(h_build_c_o_ok), "stdout", "stderr");
ATF_CHECK(grep_file("stdout", "-o test.o"));
ATF_CHECK(grep_file("stdout", "-c test.c"));
ATF_CHECK(atf_utils_grep_file("-o test.o", "stdout"));
ATF_CHECK(atf_utils_grep_file("-c test.c", "stdout"));
init_and_run_h_tc(&ATF_TC_NAME(h_build_c_o_fail),
&ATF_TC_PACK_NAME(h_build_c_o_fail), "stdout", "stderr");
ATF_CHECK(grep_file("stdout", "-o test.o"));
ATF_CHECK(grep_file("stdout", "-c test.c"));
ATF_CHECK(grep_file("stderr", "test.c"));
ATF_CHECK(grep_file("stderr", "UNDEFINED_SYMBOL"));
ATF_CHECK(atf_utils_grep_file("-o test.o", "stdout"));
ATF_CHECK(atf_utils_grep_file("-c test.c", "stdout"));
ATF_CHECK(atf_utils_grep_file("test.c", "stderr"));
ATF_CHECK(atf_utils_grep_file("UNDEFINED_SYMBOL", "stderr"));
}
ATF_TC(build_cpp);
@ -267,16 +263,16 @@ ATF_TC_BODY(build_cpp, tc)
{
init_and_run_h_tc(&ATF_TC_NAME(h_build_cpp_ok),
&ATF_TC_PACK_NAME(h_build_cpp_ok), "stdout", "stderr");
ATF_CHECK(grep_file("stdout", "-o.*test.p"));
ATF_CHECK(grep_file("stdout", "test.c"));
ATF_CHECK(grep_file("test.p", "foo bar"));
ATF_CHECK(atf_utils_grep_file("-o.*test.p", "stdout"));
ATF_CHECK(atf_utils_grep_file("test.c", "stdout"));
ATF_CHECK(atf_utils_grep_file("foo bar", "test.p"));
init_and_run_h_tc(&ATF_TC_NAME(h_build_cpp_fail),
&ATF_TC_PACK_NAME(h_build_cpp_fail), "stdout", "stderr");
ATF_CHECK(grep_file("stdout", "-o test.p"));
ATF_CHECK(grep_file("stdout", "test.c"));
ATF_CHECK(grep_file("stderr", "test.c"));
ATF_CHECK(grep_file("stderr", "non-existent.h"));
ATF_CHECK(atf_utils_grep_file("-o test.p", "stdout"));
ATF_CHECK(atf_utils_grep_file("test.c", "stdout"));
ATF_CHECK(atf_utils_grep_file("test.c", "stderr"));
ATF_CHECK(atf_utils_grep_file("non-existent.h", "stderr"));
}
ATF_TC(build_cxx_o);
@ -289,15 +285,15 @@ ATF_TC_BODY(build_cxx_o, tc)
{
init_and_run_h_tc(&ATF_TC_NAME(h_build_cxx_o_ok),
&ATF_TC_PACK_NAME(h_build_cxx_o_ok), "stdout", "stderr");
ATF_CHECK(grep_file("stdout", "-o test.o"));
ATF_CHECK(grep_file("stdout", "-c test.cpp"));
ATF_CHECK(atf_utils_grep_file("-o test.o", "stdout"));
ATF_CHECK(atf_utils_grep_file("-c test.cpp", "stdout"));
init_and_run_h_tc(&ATF_TC_NAME(h_build_cxx_o_fail),
&ATF_TC_PACK_NAME(h_build_cxx_o_fail), "stdout", "stderr");
ATF_CHECK(grep_file("stdout", "-o test.o"));
ATF_CHECK(grep_file("stdout", "-c test.cpp"));
ATF_CHECK(grep_file("stderr", "test.cpp"));
ATF_CHECK(grep_file("stderr", "UNDEFINED_SYMBOL"));
ATF_CHECK(atf_utils_grep_file("-o test.o", "stdout"));
ATF_CHECK(atf_utils_grep_file("-c test.cpp", "stdout"));
ATF_CHECK(atf_utils_grep_file("test.cpp", "stderr"));
ATF_CHECK(atf_utils_grep_file("UNDEFINED_SYMBOL", "stderr"));
}
ATF_TC(exec_array);

View file

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

View file

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

View file

@ -30,6 +30,8 @@
#if !defined(ATF_C_DEFS_H)
#define ATF_C_DEFS_H
#define ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(a, b) @ATTRIBUTE_FORMAT_PRINTF@
#define ATF_DEFS_ATTRIBUTE_NORETURN @ATTRIBUTE_NORETURN@
#define ATF_DEFS_ATTRIBUTE_UNUSED @ATTRIBUTE_UNUSED@
#endif /* !defined(ATF_C_DEFS_H) */

View file

@ -9,6 +9,5 @@ tp: list_test
tp: map_test
tp: process_test
tp: sanity_test
tp: test_helpers_test
tp: text_test
tp: user_test

View file

@ -0,0 +1,13 @@
syntax("kyuafile", 1)
test_suite("atf")
atf_test_program{name="dynstr_test"}
atf_test_program{name="env_test"}
atf_test_program{name="fs_test"}
atf_test_program{name="list_test"}
atf_test_program{name="map_test"}
atf_test_program{name="process_test"}
atf_test_program{name="sanity_test"}
atf_test_program{name="text_test"}
atf_test_program{name="user_test"}

Some files were not shown because too many files have changed in this diff Show more