MFV: Import atf-0.18.
Approved by: rpaulo (mentor)
This commit is contained in:
commit
a18eacbefd
@ -1,151 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
atf_aclocal_DATA =
|
||||
BUILT_SOURCES =
|
||||
CLEANFILES =
|
||||
EXTRA_DIST =
|
||||
bin_PROGRAMS =
|
||||
dist_man_MANS =
|
||||
include_HEADERS =
|
||||
lib_LTLIBRARIES =
|
||||
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-sh/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.
|
||||
#
|
||||
|
||||
doc_DATA = AUTHORS COPYING NEWS README
|
||||
noinst_DATA += INSTALL README
|
||||
EXTRA_DIST += $(doc_DATA) INSTALL README
|
||||
|
||||
#
|
||||
# Supporting logic to run our custom testsuite.
|
||||
#
|
||||
|
||||
TESTS_ENVIRONMENT = PATH=$(prefix)/bin:$${PATH} \
|
||||
PKG_CONFIG_PATH=$(prefix)/lib/pkgconfig
|
||||
|
||||
testsdir = $(exec_prefix)/tests
|
||||
pkgtestsdir = $(testsdir)/$(PACKAGE)
|
||||
|
||||
if ENABLE_TOOLS
|
||||
INSTALLCHECK_TARGETS += installcheck-atf
|
||||
PHONY_TARGETS += installcheck-atf
|
||||
installcheck-atf:
|
||||
logfile=$$(pwd)/installcheck.log; \
|
||||
fifofile=$$(pwd)/installcheck.fifo; \
|
||||
cd $(pkgtestsdir); \
|
||||
rm -f $${fifofile}; \
|
||||
mkfifo $${fifofile}; \
|
||||
cat $${fifofile} | tee $${logfile} | $(TESTS_ENVIRONMENT) atf-report & \
|
||||
$(TESTS_ENVIRONMENT) atf-run >>$${fifofile}; \
|
||||
res=$${?}; \
|
||||
wait; \
|
||||
rm $${fifofile}; \
|
||||
echo; \
|
||||
echo "The verbatim output of atf-run has been saved to" \
|
||||
"installcheck.log; exit was $${res}"; \
|
||||
test $${res} -eq 0
|
||||
CLEANFILES += installcheck.fifo installcheck.log
|
||||
endif
|
||||
|
||||
PHONY_TARGETS += installcheck-kyua
|
||||
if HAVE_KYUA
|
||||
installcheck-kyua:
|
||||
cd $(pkgtestsdir) && $(TESTS_ENVIRONMENT) $(KYUA) test
|
||||
endif
|
||||
|
||||
installcheck-targets: $(INSTALLCHECK_TARGETS)
|
||||
|
||||
pkgtests_DATA = Kyuafile
|
||||
if ENABLE_TOOLS
|
||||
pkgtests_DATA += Atffile
|
||||
endif
|
||||
EXTRA_DIST += $(pkgtests_DATA)
|
||||
|
||||
BUILD_SH_TP = \
|
||||
echo "Creating $${dst}"; \
|
||||
echo "\#! $(bindir)/atf-sh" >$${dst}; \
|
||||
cat $${src} >>$${dst}; \
|
||||
chmod +x $${dst}
|
||||
|
||||
#
|
||||
# Custom targets.
|
||||
#
|
||||
|
||||
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_TARGETS += clean-all
|
||||
clean-all:
|
||||
GIT="$(GIT)" $(SH) $(srcdir)/admin/clean-all.sh
|
||||
|
||||
PHONY_TARGETS += release
|
||||
release:
|
||||
$(SH) $(srcdir)/admin/release.sh $(PACKAGE_VERSION) $(DIST_ARCHIVES)
|
||||
|
||||
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
@ -2,6 +2,58 @@ Major changes between releases Automated Testing Framework
|
||||
===========================================================================
|
||||
|
||||
|
||||
Changes in version 0.18
|
||||
***********************
|
||||
|
||||
Experimental version released on November 16th, 2013.
|
||||
|
||||
* Issue 45: Added require.memory support in atf-run for FreeBSD.
|
||||
|
||||
* Fixed an issue with the handling of cin with libc++.
|
||||
|
||||
* Issue 64: Fixed various mandoc formatting warnings.
|
||||
|
||||
* NetBSD PR bin/48284: Made atf-check flush its progress message to
|
||||
stdout so that an interrupted test case always shows the last message
|
||||
being executed.
|
||||
|
||||
* NetBSD PR bin/48285: Fixed atf_check examples in atf-sh-api(3).
|
||||
|
||||
|
||||
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
|
||||
***********************
|
||||
|
||||
|
@ -1,48 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
dist-hook: check-install
|
||||
PHONY_TARGETS += check-install
|
||||
check-install: $(srcdir)/INSTALL
|
||||
$(srcdir)/admin/check-install.sh $(srcdir)/INSTALL
|
||||
|
||||
dist-hook: check-style
|
||||
PHONY_TARGETS += check-style
|
||||
check-style:
|
||||
$(srcdir)/admin/check-style.sh
|
||||
|
||||
EXTRA_DIST += admin/check-install.sh \
|
||||
admin/check-style-common.awk \
|
||||
admin/check-style-c.awk \
|
||||
admin/check-style-cpp.awk \
|
||||
admin/check-style-man.awk \
|
||||
admin/check-style-shell.awk \
|
||||
admin/check-style.sh
|
||||
|
||||
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
|
@ -1,92 +0,0 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
#
|
||||
# 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
|
@ -1,94 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
function warn(msg) {
|
||||
print FILENAME "[" FNR "]: " msg > "/dev/stderr"
|
||||
error = 1
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
skip = 0
|
||||
error = 0
|
||||
}
|
||||
|
||||
/NO_CHECK_STYLE_BEGIN/ {
|
||||
skip = 1
|
||||
next
|
||||
}
|
||||
|
||||
/NO_CHECK_STYLE_END/ {
|
||||
skip = 0
|
||||
next
|
||||
}
|
||||
|
||||
/NO_CHECK_STYLE/ {
|
||||
next
|
||||
}
|
||||
|
||||
{
|
||||
if (skip)
|
||||
next
|
||||
}
|
||||
|
||||
/#ifdef/ {
|
||||
warn("Undesired usage of #ifdef; use #if defined()")
|
||||
}
|
||||
|
||||
/#ifndef/ {
|
||||
warn("Undesired usage of #ifndef; use #if !defined()")
|
||||
}
|
||||
|
||||
/assert[ \t]*\(/ {
|
||||
warn("Use the macros in sanity.h instead of assert");
|
||||
}
|
||||
|
||||
/getprogname/ {
|
||||
warn("getprogname(3) is not portable");
|
||||
}
|
||||
|
||||
/include.*assert.h/ {
|
||||
warn("Do not include assert.h");
|
||||
}
|
||||
|
||||
/setprogname/ {
|
||||
warn("setprogname(3) is not portable");
|
||||
}
|
||||
|
||||
/\/\// {
|
||||
warn("Do not use C99-style comments");
|
||||
}
|
||||
|
||||
END {
|
||||
if (skip)
|
||||
warn("Missing NO_CHECK_STYLE_END");
|
||||
if (error)
|
||||
exit 1
|
||||
}
|
||||
|
||||
# vim: syntax=awk:expandtab:shiftwidth=4:softtabstop=4
|
@ -1,82 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
function warn(msg) {
|
||||
print FILENAME "[" FNR "]: " msg > "/dev/stderr"
|
||||
error = 1
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
skip = 0
|
||||
error = 0
|
||||
}
|
||||
|
||||
/NO_CHECK_STYLE_BEGIN/ {
|
||||
skip = 1
|
||||
next
|
||||
}
|
||||
|
||||
/NO_CHECK_STYLE_END/ {
|
||||
skip = 0
|
||||
next
|
||||
}
|
||||
|
||||
/NO_CHECK_STYLE/ {
|
||||
next
|
||||
}
|
||||
|
||||
{
|
||||
if (skip)
|
||||
next
|
||||
|
||||
if (length > 80)
|
||||
warn("Line too long to fit on screen")
|
||||
}
|
||||
|
||||
/^ *\t+/ {
|
||||
if (! match(FILENAME, "Makefile"))
|
||||
warn("Tab character used for indentation");
|
||||
}
|
||||
|
||||
/[ \t]+$/ {
|
||||
warn("Trailing spaces or tabs");
|
||||
}
|
||||
|
||||
/#![^ ]/ { # NO_CHECK_STYLE
|
||||
warn("Invalid shellbang: missing space after !");
|
||||
}
|
||||
|
||||
END {
|
||||
if (skip)
|
||||
warn("Missing NO_CHECK_STYLE_END");
|
||||
if (error)
|
||||
exit 1
|
||||
}
|
||||
|
||||
# vim: syntax=awk:expandtab:shiftwidth=4:softtabstop=4
|
@ -1,90 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
function warn(msg) {
|
||||
print FILENAME "[" FNR "]: " msg > "/dev/stderr"
|
||||
error = 1
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
skip = 0
|
||||
error = 0
|
||||
}
|
||||
|
||||
/NO_CHECK_STYLE_BEGIN/ {
|
||||
skip = 1
|
||||
next
|
||||
}
|
||||
|
||||
/NO_CHECK_STYLE_END/ {
|
||||
skip = 0
|
||||
next
|
||||
}
|
||||
|
||||
/NO_CHECK_STYLE/ {
|
||||
next
|
||||
}
|
||||
|
||||
{
|
||||
if (skip)
|
||||
next
|
||||
}
|
||||
|
||||
/#ifdef/ {
|
||||
warn("Undesired usage of #ifdef; use #if defined()")
|
||||
}
|
||||
|
||||
/#ifndef/ {
|
||||
warn("Undesired usage of #ifndef; use #if !defined()")
|
||||
}
|
||||
|
||||
/assert[ \t]*\(/ {
|
||||
warn("Use the macros in sanity.hpp instead of assert");
|
||||
}
|
||||
|
||||
/include.*assert/ {
|
||||
warn("Do not include assert.h nor cassert");
|
||||
}
|
||||
|
||||
/std::endl/ {
|
||||
warn("Use \\n instead of std::endl");
|
||||
}
|
||||
|
||||
/\/\*/ {
|
||||
warn("Do not use C-style comments");
|
||||
}
|
||||
|
||||
END {
|
||||
if (skip)
|
||||
warn("Missing NO_CHECK_STYLE_END");
|
||||
if (error)
|
||||
exit 1
|
||||
}
|
||||
|
||||
# vim: syntax=awk:expandtab:shiftwidth=4:softtabstop=4
|
@ -1,78 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
function warn(msg) {
|
||||
print FILENAME "[" FNR "]: " msg > "/dev/stderr"
|
||||
error = 1
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
skip = 0
|
||||
error = 0
|
||||
}
|
||||
|
||||
/NO_CHECK_STYLE_BEGIN|^\.Bd/ {
|
||||
skip = 1
|
||||
next
|
||||
}
|
||||
|
||||
/NO_CHECK_STYLE_END|^\.Ed/ {
|
||||
skip = 0
|
||||
next
|
||||
}
|
||||
|
||||
/NO_CHECK_STYLE/ {
|
||||
next
|
||||
}
|
||||
|
||||
/^\.\\"/ {
|
||||
next
|
||||
}
|
||||
|
||||
{
|
||||
if (skip)
|
||||
next
|
||||
}
|
||||
|
||||
/\.\.|e\.g\.|i\.e\./ {
|
||||
next
|
||||
}
|
||||
|
||||
/\.[ ]+[a-zA-Z]+/ {
|
||||
warn("Sentence does not start on new line")
|
||||
}
|
||||
|
||||
END {
|
||||
if (skip)
|
||||
warn("Missing NO_CHECK_STYLE_END");
|
||||
if (error)
|
||||
exit 1
|
||||
}
|
||||
|
||||
# vim: syntax=awk:expandtab:shiftwidth=4:softtabstop=4
|
@ -1,106 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
function warn(msg) {
|
||||
print FILENAME "[" FNR "]: " msg > "/dev/stderr"
|
||||
error = 1
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
skip = 0
|
||||
error = 0
|
||||
emacs_modeline = 0
|
||||
vim_modeline = 0
|
||||
}
|
||||
|
||||
/NO_CHECK_STYLE_BEGIN/ {
|
||||
skip = 1
|
||||
next
|
||||
}
|
||||
|
||||
/NO_CHECK_STYLE_END/ {
|
||||
skip = 0
|
||||
next
|
||||
}
|
||||
|
||||
/NO_CHECK_STYLE/ {
|
||||
next
|
||||
}
|
||||
|
||||
{
|
||||
if (skip)
|
||||
next
|
||||
}
|
||||
|
||||
/vim: syntax=sh/ {
|
||||
vim_modeline = 1
|
||||
}
|
||||
|
||||
/^[ \t]*#/ {
|
||||
next
|
||||
}
|
||||
|
||||
/[$ \t]+_[a-zA-Z0-9]+=/ {
|
||||
warn("Variable should not start with an underline")
|
||||
}
|
||||
|
||||
/[^\\]\$[^0-9!'"$?@#*{}(|\/,]+/ {
|
||||
warn("Missing braces around variable name")
|
||||
}
|
||||
|
||||
/=(""|'')/ {
|
||||
warn("Assignment to the empty string does not need quotes");
|
||||
}
|
||||
|
||||
/basename[ \t]+/ {
|
||||
warn("Use parameter expansion instead of basename");
|
||||
}
|
||||
|
||||
/if[ \t]+(test|![ \t]+test)/ {
|
||||
warn("Use [ instead of test");
|
||||
}
|
||||
|
||||
/[ \t]+(test|\[).*==/ {
|
||||
warn("test(1)'s == operator is not portable");
|
||||
}
|
||||
|
||||
/if.*;[ \t]*fi$/ {
|
||||
warn("Avoid using a single-line if conditional");
|
||||
}
|
||||
|
||||
END {
|
||||
if (skip)
|
||||
warn("Missing NO_CHECK_STYLE_END");
|
||||
if (! vim_modeline)
|
||||
warn("Missing mode lines");
|
||||
if (error)
|
||||
exit 1
|
||||
}
|
||||
|
||||
# vim: syntax=awk:expandtab:shiftwidth=4:softtabstop=4
|
@ -1,189 +0,0 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
#
|
||||
# A utility to sanity check the coding style of all source files in the
|
||||
# project tree.
|
||||
#
|
||||
|
||||
Prog_Name=${0##*/}
|
||||
|
||||
#
|
||||
# err message
|
||||
#
|
||||
err() {
|
||||
echo "${Prog_Name}: ${@}" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
#
|
||||
# warn message
|
||||
#
|
||||
warn() {
|
||||
echo "${Prog_Name}: ${@}" 1>&2
|
||||
}
|
||||
|
||||
#
|
||||
# guess_topdir
|
||||
#
|
||||
# Locates the project's top directory and prints its path. The caller
|
||||
# must verify if the result is correct or not.
|
||||
#
|
||||
guess_topdir() {
|
||||
olddir=$(pwd)
|
||||
topdir=$(pwd)
|
||||
while [ ${topdir} != / ]; do
|
||||
if [ -f ./atf-c.h ]; then
|
||||
break
|
||||
else
|
||||
cd ..
|
||||
topdir=$(pwd)
|
||||
fi
|
||||
done
|
||||
cd ${olddir}
|
||||
echo ${topdir}
|
||||
}
|
||||
|
||||
#
|
||||
# find_sources
|
||||
#
|
||||
# Locates all source files within the project, relative to the current
|
||||
# directory, and prints their paths.
|
||||
#
|
||||
find_sources() {
|
||||
find . \( -name "AUTHORS" -o \
|
||||
-name "COPYING" -o \
|
||||
-name "ChangeLog" -o \
|
||||
-name "NEWS" -o \
|
||||
-name "README" -o \
|
||||
-name "TODO" -o \
|
||||
-name "*.[0-9]" -o \
|
||||
-name "*.ac" -o \
|
||||
-name "*.at" -o \
|
||||
-name "*.awk" -o \
|
||||
-name "*.c" -o \
|
||||
-name "*.cpp" -o \
|
||||
-name "*.h" -o \
|
||||
-name "*.h.in" -o \
|
||||
-name "*.hpp" -o \
|
||||
-name "*.m4" -o \
|
||||
-name "*.sh" \
|
||||
\) -a \( \
|
||||
\! -path "*/atf-[0-9]*" -a \
|
||||
\! -path "*autom4te*" -a \
|
||||
-type f -a \
|
||||
\! -name "aclocal.m4" \
|
||||
\! -name "bconfig.h" \
|
||||
\! -name "defs.h" \
|
||||
\! -name "libtool.m4" \
|
||||
\! -name "ltoptions.m4" \
|
||||
\! -name "ltsugar.m4" \
|
||||
\! -name "lt~obsolete.m4" \
|
||||
\! -name "*.so.*" \
|
||||
\)
|
||||
}
|
||||
|
||||
#
|
||||
# guess_formats file
|
||||
#
|
||||
# Guesses the formats applicable to the given file and prints the resulting
|
||||
# list.
|
||||
#
|
||||
guess_formats() {
|
||||
case ${1} in
|
||||
*/ltmain.sh)
|
||||
;;
|
||||
*.[0-9])
|
||||
echo common man
|
||||
;;
|
||||
*.c|*.h)
|
||||
echo common c
|
||||
;;
|
||||
*.cpp|*.hpp)
|
||||
echo common cpp
|
||||
;;
|
||||
*.sh)
|
||||
echo common shell
|
||||
;;
|
||||
*)
|
||||
echo common
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#
|
||||
# check_file file
|
||||
#
|
||||
# Checks the validity of the given file.
|
||||
#
|
||||
check_file() {
|
||||
err=0
|
||||
for format in $(guess_formats ${1}); do
|
||||
awk -f ${topdir}/admin/check-style-${format}.awk ${1} || err=1
|
||||
done
|
||||
|
||||
return ${err}
|
||||
}
|
||||
|
||||
#
|
||||
# main [file list]
|
||||
#
|
||||
# Entry point.
|
||||
#
|
||||
main() {
|
||||
topdir=$(guess_topdir)
|
||||
if [ ! -f ${topdir}/atf-c.h ]; then
|
||||
err "Could not locate the project's top directory"
|
||||
fi
|
||||
|
||||
if [ ${#} -gt 0 ]; then
|
||||
sources=${@}
|
||||
else
|
||||
cd ${topdir}
|
||||
sources=$(find_sources)
|
||||
fi
|
||||
|
||||
ok=0
|
||||
for file in ${sources}; do
|
||||
file=$(echo ${file} | sed -e "s,\\./,,")
|
||||
|
||||
if [ ! -f ${file} ]; then
|
||||
err "Could not open ${file}"
|
||||
else
|
||||
check_file ${file} || ok=1
|
||||
fi
|
||||
done
|
||||
|
||||
return ${ok}
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
|
||||
# vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4
|
@ -1,310 +0,0 @@
|
||||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand '-c -o'.
|
||||
|
||||
scriptversion=2012-01-04.17; # UTC
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free
|
||||
# Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# 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_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*)
|
||||
func_file_conv "${1#-I}" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-l*)
|
||||
lib=${1#-l}
|
||||
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
|
||||
set x "$@" "$dir/$lib.dll.lib"
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/$lib.lib"; then
|
||||
found=yes
|
||||
set x "$@" "$dir/$lib.lib"
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS=$save_IFS
|
||||
|
||||
test "$found" != yes && set x "$@" "$lib.lib"
|
||||
shift
|
||||
;;
|
||||
-L*)
|
||||
func_file_conv "${1#-L}"
|
||||
if test -z "$lib_path"; then
|
||||
lib_path=$file
|
||||
else
|
||||
lib_path="$lib_path;$file"
|
||||
fi
|
||||
linker_opts="$linker_opts -LIBPATH:$file"
|
||||
;;
|
||||
-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
|
||||
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
|
||||
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'.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "compile $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
|
||||
func_cl_wrapper "$@" # Doesn't return...
|
||||
;;
|
||||
esac
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
|
||||
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'.
|
||||
# So we strip '-o arg' only if arg is an object.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.obj)
|
||||
ofile=$2
|
||||
;;
|
||||
*)
|
||||
set x "$@" -o "$2"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*.c)
|
||||
cfile=$1
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# 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
|
||||
# ok.
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
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
|
||||
# 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
|
||||
while true; do
|
||||
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
# FIXME: race condition here if user kills between mkdir and trap.
|
||||
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||
|
||||
# Run the compile.
|
||||
"$@"
|
||||
ret=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||
elif test -f "${cofile}bj"; then
|
||||
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir "$lockdir"
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
1522
contrib/atf/admin/config.guess
vendored
1522
contrib/atf/admin/config.guess
vendored
File diff suppressed because it is too large
Load Diff
1766
contrib/atf/admin/config.sub
vendored
1766
contrib/atf/admin/config.sub
vendored
File diff suppressed because it is too large
Load Diff
@ -1,688 +0,0 @@
|
||||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2011-12-04.11; # UTC
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
|
||||
# 2011 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
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||
as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
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 outputting dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "depcomp $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||
depfile=${depfile-`echo "$object" |
|
||||
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
cygpath_u="cygpath -u -f -"
|
||||
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'
|
||||
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
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say).
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||
## 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.
|
||||
## 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
|
||||
## that the space means something, we add a space to the output as
|
||||
## 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 "s|.*$object$||" -e '/:$/d' \
|
||||
| sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# 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
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# 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
|
||||
# dependency line.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
|
||||
tr '
|
||||
' ' ' >> "$depfile"
|
||||
echo >> "$depfile"
|
||||
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
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
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$base.u
|
||||
tmpdepfile3=$dir.libs/$base.u
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$dir$base.u
|
||||
tmpdepfile3=$dir$base.u
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
# 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:'.
|
||||
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"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
icc)
|
||||
# Intel's C compiler understands `-MD -MF file'. However on
|
||||
# icc -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:
|
||||
# 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 \ :
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
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 \'.
|
||||
# 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"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add `dependent.h:' lines.
|
||||
sed -ne '2,${
|
||||
s/^ *//
|
||||
s/ \\*$//
|
||||
s/$/:/
|
||||
p
|
||||
}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
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'.
|
||||
# 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.
|
||||
# Subdirectories are respected.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# With Tru64 cc, shared objects can also be used to make a
|
||||
# static library. This mechanism is used in libtool 1.4 series to
|
||||
# handle both shared and static libraries in a single compilation.
|
||||
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
|
||||
#
|
||||
# With libtool 1.5 this exception was removed, and libtool now
|
||||
# generates 2 separate objects for the 2 libraries. These two
|
||||
# compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
|
||||
tmpdepfile2=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
|
||||
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.o.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
tmpdepfile4=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
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"
|
||||
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/\(.*\)/ \1 \\/p
|
||||
s/.\(.*\) \\/\1:/
|
||||
H
|
||||
$ {
|
||||
s/.*/ /
|
||||
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.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# 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.
|
||||
"$@" $dashmflag |
|
||||
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
tr ' ' '
|
||||
' < "$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"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no eat=no
|
||||
for arg
|
||||
do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
if test $eat = yes; then
|
||||
eat=no
|
||||
continue
|
||||
fi
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-arch)
|
||||
eat=yes ;;
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix=`echo "$object" | sed 's/^.*\././'`
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
# 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 ' ' '
|
||||
' | \
|
||||
## 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"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E |
|
||||
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E 2>/dev/null |
|
||||
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::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvcmsys)
|
||||
# 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
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
@ -1,527 +0,0 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2011-01-19.21; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
|
||||
nl='
|
||||
'
|
||||
IFS=" "" $nl"
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit=${DOITPROG-}
|
||||
if test -z "$doit"; then
|
||||
doit_exec=exec
|
||||
else
|
||||
doit_exec=$doit
|
||||
fi
|
||||
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
chgrpprog=${CHGRPPROG-chgrp}
|
||||
chmodprog=${CHMODPROG-chmod}
|
||||
chownprog=${CHOWNPROG-chown}
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
cpprog=${CPPROG-cp}
|
||||
mkdirprog=${MKDIRPROG-mkdir}
|
||||
mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
|
||||
posix_glob='?'
|
||||
initialize_posix_glob='
|
||||
test "$posix_glob" != "?" || {
|
||||
if (set -f) 2>/dev/null; then
|
||||
posix_glob=
|
||||
else
|
||||
posix_glob=:
|
||||
fi
|
||||
}
|
||||
'
|
||||
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
chgrpcmd=
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
mvcmd=$mvprog
|
||||
rmcmd="$rmprog -f"
|
||||
stripcmd=
|
||||
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dst_arg=
|
||||
|
||||
copy_on_change=false
|
||||
no_target_directory=
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
-c (ignored)
|
||||
-C install only if different (preserve the last data modification time)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-s $stripprog installed files.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||
RMPROG STRIPPROG
|
||||
"
|
||||
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) ;;
|
||||
|
||||
-C) copy_on_change=true;;
|
||||
|
||||
-d) dir_arg=true;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *' '* | *'
|
||||
'* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift;;
|
||||
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-t) dst_arg=$2
|
||||
# Protect names problematic for `test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-T) no_target_directory=true;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dst_arg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dst_arg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
# Protect names problematic for `test' and other utilities.
|
||||
case $dst_arg in
|
||||
-* | [=\(\)!]) dst_arg=./$dst_arg;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call `install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
do_exit='(exit $ret); exit $ret'
|
||||
trap "ret=129; $do_exit" 1
|
||||
trap "ret=130; $do_exit" 2
|
||||
trap "ret=141; $do_exit" 13
|
||||
trap "ret=143; $do_exit" 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names problematic for `test' and other utilities.
|
||||
case $src in
|
||||
-* | [=\(\)!]) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dst_arg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
dst=$dst_arg
|
||||
|
||||
# If destination is a directory, append the input filename; won't work
|
||||
# if double slashes aren't ignored.
|
||||
if test -d "$dst"; then
|
||||
if test -n "$no_target_directory"; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dstdir=$dst
|
||||
dst=$dstdir/`basename "$src"`
|
||||
dstdir_status=0
|
||||
else
|
||||
# Prefer dirname, but fall back on a substitute if dirname fails.
|
||||
dstdir=`
|
||||
(dirname "$dst") 2>/dev/null ||
|
||||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
X"$dst" : 'X\(//\)[^/]' \| \
|
||||
X"$dst" : 'X\(//\)$' \| \
|
||||
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
|
||||
echo X"$dst" |
|
||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)[^/].*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\).*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
s/.*/./; q'
|
||||
`
|
||||
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# Create intermediate dirs using mode 755 as modified by the umask.
|
||||
# This is like FreeBSD 'install' as of 1997-10-28.
|
||||
umask=`umask`
|
||||
case $stripcmd.$umask in
|
||||
# Optimize common cases.
|
||||
*[2367][2367]) mkdir_umask=$umask;;
|
||||
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
mkdir_umask=`expr $umask + 22 \
|
||||
- $umask % 100 % 40 + $umask % 20 \
|
||||
- $umask % 10 % 4 + $umask % 2
|
||||
`;;
|
||||
*) mkdir_umask=$umask,go-w;;
|
||||
esac
|
||||
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
posix_mkdir=false
|
||||
case $umask in
|
||||
*[123567][0-7][0-7])
|
||||
# POSIX mkdir -p sets u+wx bits regardless of umask, which
|
||||
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
|
||||
;;
|
||||
*)
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
|
||||
|
||||
if (umask $mkdir_umask &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writeable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
ls_ld_tmpdir=`ls -ld "$tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/d" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac;;
|
||||
esac
|
||||
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
# The umask is ridiculous, or mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
[-=\(\)!]*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
eval "$initialize_posix_glob"
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
$posix_glob set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
$posix_glob set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test X"$d" = X && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask=$mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# If -C, don't bother to copy if it wouldn't change the file.
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
|
||||
eval "$initialize_posix_glob" &&
|
||||
$posix_glob set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
$posix_glob set +f &&
|
||||
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
rm -f "$dsttmp"
|
||||
else
|
||||
# Rename the file to the real destination.
|
||||
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
{
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
test ! -f "$dst" ||
|
||||
$doit $rmcmd -f "$dst" 2>/dev/null ||
|
||||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
|
||||
} ||
|
||||
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
fi || exit 1
|
||||
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
File diff suppressed because it is too large
Load Diff
@ -1,331 +0,0 @@
|
||||
#! /bin/sh
|
||||
# Common stub for a few missing GNU programs while installing.
|
||||
|
||||
scriptversion=2012-01-06.13; # UTC
|
||||
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
|
||||
# 2008, 2009, 2010, 2011, 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# 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"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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
|
||||
# srcdir already.
|
||||
if test -f configure.ac; then
|
||||
configure_ac=configure.ac
|
||||
else
|
||||
configure_ac=configure.in
|
||||
fi
|
||||
|
||||
msg="missing on your system"
|
||||
|
||||
case $1 in
|
||||
--run)
|
||||
# Try to run requested program, and just exit if it succeeds.
|
||||
run=
|
||||
shift
|
||||
"$@" && exit 0
|
||||
# Exit code 63 means version mismatch. This often happens
|
||||
# when the user try to use an ancient version of a tool on
|
||||
# a file that requires a minimum version. In this case we
|
||||
# we should proceed has if the program had been absent, or
|
||||
# if --run hadn't been passed.
|
||||
if test $? = 63; then
|
||||
run=:
|
||||
msg="probably too old"
|
||||
fi
|
||||
;;
|
||||
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "\
|
||||
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||
|
||||
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
|
||||
error status if there is no known handling for PROGRAM.
|
||||
|
||||
Options:
|
||||
-h, --help display this help and exit
|
||||
-v, --version output version information and exit
|
||||
--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'
|
||||
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
|
||||
help2man touch the output file
|
||||
lex create \`lex.yy.c', if possible, from existing .c
|
||||
makeinfo touch the output file
|
||||
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.
|
||||
|
||||
Send bug reports to <bug-automake@gnu.org>."
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||
echo "missing $scriptversion (GNU Automake)"
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo 1>&2 "$0: Unknown \`$1' option"
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# normalize program name to check for.
|
||||
program=`echo "$1" | sed '
|
||||
s/^gnu-//; t
|
||||
s/^gnu//; t
|
||||
s/^g//; t'`
|
||||
|
||||
# Now exit if we have it, but it failed. Also exit now if we
|
||||
# don't have it and --version was passed (most likely to detect
|
||||
# the program). This is about non-GNU programs, so use $1 not
|
||||
# $program.
|
||||
case $1 in
|
||||
lex*|yacc*)
|
||||
# Not GNU programs, they don't have --version.
|
||||
;;
|
||||
|
||||
*)
|
||||
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
|
||||
# $TOOL exists and not knowing $TOOL uses missing.
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# If it does not exist, or fails to run (possibly an outdated version),
|
||||
# try to emulate it.
|
||||
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
|
||||
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
|
||||
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
|
||||
from any GNU archive site."
|
||||
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
|
||||
test -z "$files" && files="config.h"
|
||||
touch_files=
|
||||
for f in $files; do
|
||||
case $f in
|
||||
*:*) touch_files="$touch_files "`echo "$f" |
|
||||
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
|
||||
*) touch_files="$touch_files $f.in";;
|
||||
esac
|
||||
done
|
||||
touch $touch_files
|
||||
;;
|
||||
|
||||
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.
|
||||
Grab them from any GNU archive site."
|
||||
find . -type f -name Makefile.am -print |
|
||||
sed 's/\.am$/.in/' |
|
||||
while read f; do touch "$f"; done
|
||||
;;
|
||||
|
||||
autom4te*)
|
||||
echo 1>&2 "\
|
||||
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
|
||||
archive site."
|
||||
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo "#! /bin/sh"
|
||||
echo "# Created by GNU Automake missing as a replacement of"
|
||||
echo "# $ $@"
|
||||
echo "exit 0"
|
||||
chmod +x $file
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
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
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Bison' from any GNU archive site."
|
||||
rm -f y.tab.c y.tab.h
|
||||
if test $# -ne 1; then
|
||||
eval LASTARG=\${$#}
|
||||
case $LASTARG in
|
||||
*.y)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" y.tab.c
|
||||
fi
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" y.tab.h
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if test ! -f y.tab.h; then
|
||||
echo >y.tab.h
|
||||
fi
|
||||
if test ! -f y.tab.c; then
|
||||
echo 'main() { return 0; }' >y.tab.c
|
||||
fi
|
||||
;;
|
||||
|
||||
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
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Flex' from any GNU archive site."
|
||||
rm -f lex.yy.c
|
||||
if test $# -ne 1; then
|
||||
eval LASTARG=\${$#}
|
||||
case $LASTARG in
|
||||
*.l)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" lex.yy.c
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if test ! -f lex.yy.c; then
|
||||
echo 'main() { return 0; }' >lex.yy.c
|
||||
fi
|
||||
;;
|
||||
|
||||
help2man*)
|
||||
echo 1>&2 "\
|
||||
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."
|
||||
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo ".ab help2man is required to generate this page"
|
||||
exit $?
|
||||
fi
|
||||
;;
|
||||
|
||||
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
|
||||
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."
|
||||
# The file to touch is that specified with -o ...
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -z "$file"; then
|
||||
# ... or it is the one specified with @setfilename ...
|
||||
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
|
||||
file=`sed -n '
|
||||
/^@setfilename/{
|
||||
s/.* \([^ ]*\) *$/\1/
|
||||
p
|
||||
q
|
||||
}' $infile`
|
||||
# ... or it is derived from the source name (dir/f.texi becomes f.info)
|
||||
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
|
||||
fi
|
||||
# If the file does not exist, the user really needs makeinfo;
|
||||
# let's fail without touching anything.
|
||||
test -f $file || exit 1
|
||||
touch $file
|
||||
;;
|
||||
|
||||
*)
|
||||
echo 1>&2 "\
|
||||
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,
|
||||
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."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
@ -31,5 +31,6 @@
|
||||
#define _ATF_CXX_HPP_
|
||||
|
||||
#include <atf-c++/macros.hpp>
|
||||
#include <atf-c++/utils.hpp>
|
||||
|
||||
#endif // !defined(_ATF_CXX_HPP_)
|
||||
|
@ -1,111 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
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 \
|
||||
atf-c++/build.hpp \
|
||||
atf-c++/check.cpp \
|
||||
atf-c++/check.hpp \
|
||||
atf-c++/config.cpp \
|
||||
atf-c++/config.hpp \
|
||||
atf-c++/macros.hpp \
|
||||
atf-c++/tests.cpp \
|
||||
atf-c++/tests.hpp \
|
||||
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++/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 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' \
|
||||
<$(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++/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 $(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 $(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 $(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 $(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 $(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
|
||||
atf-c++/pkg_config_test: $(srcdir)/atf-c++/pkg_config_test.sh
|
||||
test -d atf-c++ || mkdir -p atf-c++
|
||||
@src="$(srcdir)/atf-c++/pkg_config_test.sh"; \
|
||||
dst="atf-c++/pkg_config_test"; $(BUILD_SH_TP)
|
||||
|
||||
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 $(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 $(ATF_CXX_LIBS)
|
||||
include atf-c++/detail/Makefile.am.inc
|
||||
|
||||
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
|
@ -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 January 21, 2012
|
||||
.Dd November 15, 2013
|
||||
.Dt ATF-C++-API 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm atf-c++-api ,
|
||||
.Nm ATF_ADD_TEST_CASE ,
|
||||
.Nm ATF_CHECK_ERRNO ,
|
||||
.Nm ATF_FAIL ,
|
||||
@ -52,6 +53,17 @@
|
||||
.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
|
||||
@ -77,18 +89,64 @@
|
||||
.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++.
|
||||
This interface is backed by a C++ implementation, but this fact is
|
||||
hidden from the developer as much as possible through the use of
|
||||
macros to simplify programming.
|
||||
However, the use of C++ is not hidden everywhere and while you can
|
||||
implement test cases without knowing anything at all about the object model
|
||||
underneath the provided calls, you might need some minimum notions of the
|
||||
language in very specific circumstances.
|
||||
.Pp
|
||||
C++-based test programs always follow this template:
|
||||
ATF provides a C++ programming interface to implement test programs.
|
||||
C++-based test programs follow this template:
|
||||
.Bd -literal -offset indent
|
||||
extern "C" {
|
||||
.Ns ... C-specific includes go here ...
|
||||
@ -205,7 +263,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.
|
||||
@ -348,7 +406,7 @@ in the collection.
|
||||
.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.
|
||||
@ -362,6 +420,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 -ragged -offset indent
|
||||
Prints the contents of
|
||||
.Fa path
|
||||
to the standard output, prefixing every line with the string in
|
||||
.Fa prefix .
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft bool
|
||||
.Fo atf::utils::compare_file
|
||||
.Fa "const std::string& path"
|
||||
.Fa "const std::string& contents"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Returns true if the given
|
||||
.Fa path
|
||||
matches exactly the expected inlined
|
||||
.Fa contents .
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf::utils::copy_file
|
||||
.Fa "const std::string& source"
|
||||
.Fa "const std::string& destination"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Copies the file
|
||||
.Fa source
|
||||
to
|
||||
.Fa destination .
|
||||
The permissions of the file are preserved during the code.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf::utils::create_file
|
||||
.Fa "const std::string& path"
|
||||
.Fa "const std::string& contents"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Creates
|
||||
.Fa file
|
||||
with the text given in
|
||||
.Fa contents .
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf::utils::file_exists
|
||||
.Fa "const std::string& path"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Checks if
|
||||
.Fa path
|
||||
exists.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft pid_t
|
||||
.Fo atf::utils::fork
|
||||
.Fa "void"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Forks a process and redirects the standard output and standard error of the
|
||||
child to files for later validation with
|
||||
.Fn atf::utils::wait .
|
||||
Fails the test case if the fork fails, so this does not return an error.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft bool
|
||||
.Fo atf::utils::grep_collection
|
||||
.Fa "const std::string& regexp"
|
||||
.Fa "const Collection& collection"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Searches for the regular expression
|
||||
.Fa regexp
|
||||
in any of the strings contained in the
|
||||
.Fa collection .
|
||||
This is a template that accepts any one-dimensional container of strings.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft bool
|
||||
.Fo atf::utils::grep_file
|
||||
.Fa "const std::string& regexp"
|
||||
.Fa "const std::string& path"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Searches for the regular expression
|
||||
.Fa regexp
|
||||
in the file
|
||||
.Fa path .
|
||||
The variable arguments are used to construct the regular expression.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft bool
|
||||
.Fo atf::utils::grep_string
|
||||
.Fa "const std::string& regexp"
|
||||
.Fa "const std::string& str"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Searches for the regular expression
|
||||
.Fa regexp
|
||||
in the string
|
||||
.Fa str .
|
||||
.Ed
|
||||
.Ft void
|
||||
.Fo atf::utils::redirect
|
||||
.Fa "const int fd"
|
||||
.Fa "const std::string& path"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Redirects the given file descriptor
|
||||
.Fa fd
|
||||
to the file
|
||||
.Fa path .
|
||||
This function exits the process in case of an error and does not properly mark
|
||||
the test case as failed.
|
||||
As a result, it should only be used in subprocesses of the test case; specially
|
||||
those spawned by
|
||||
.Fn atf::utils::fork .
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf::utils::wait
|
||||
.Fa "const pid_t pid"
|
||||
.Fa "const int expected_exit_status"
|
||||
.Fa "const std::string& expected_stdout"
|
||||
.Fa "const std::string& expected_stderr"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Waits and validates the result of a subprocess spawned with
|
||||
.Fn atf::utils::wait .
|
||||
The validation involves checking that the subprocess exited cleanly and returned
|
||||
the code specified in
|
||||
.Fa expected_exit_status
|
||||
and that its standard output and standard error match the strings given in
|
||||
.Fa expected_stdout
|
||||
and
|
||||
.Fa expected_stderr .
|
||||
.Pp
|
||||
If any of the
|
||||
.Fa expected_stdout
|
||||
or
|
||||
.Fa expected_stderr
|
||||
strings are prefixed with
|
||||
.Sq save: ,
|
||||
then they specify the name of the file into which to store the stdout or stderr
|
||||
of the subprocess, and no comparison is performed.
|
||||
.Ed
|
||||
.Sh EXAMPLES
|
||||
The following shows a complete test program with a single test case that
|
||||
validates the addition operator:
|
||||
@ -371,7 +586,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)
|
||||
{
|
||||
@ -387,7 +602,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)
|
||||
{
|
||||
@ -397,7 +612,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)
|
||||
{
|
||||
|
@ -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.
|
||||
//!
|
||||
|
@ -193,15 +193,15 @@ 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);
|
||||
@ -213,16 +213,16 @@ 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);
|
||||
@ -234,15 +234,15 @@ 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);
|
||||
|
@ -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
|
||||
|
@ -3,6 +3,7 @@ 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"}
|
||||
|
@ -1,99 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
libatf_c___la_SOURCES += atf-c++/detail/application.cpp \
|
||||
atf-c++/detail/application.hpp \
|
||||
atf-c++/detail/env.cpp \
|
||||
atf-c++/detail/env.hpp \
|
||||
atf-c++/detail/exceptions.cpp \
|
||||
atf-c++/detail/exceptions.hpp \
|
||||
atf-c++/detail/expand.cpp \
|
||||
atf-c++/detail/expand.hpp \
|
||||
atf-c++/detail/fs.cpp \
|
||||
atf-c++/detail/fs.hpp \
|
||||
atf-c++/detail/parser.cpp \
|
||||
atf-c++/detail/parser.hpp \
|
||||
atf-c++/detail/process.cpp \
|
||||
atf-c++/detail/process.hpp \
|
||||
atf-c++/detail/sanity.hpp \
|
||||
atf-c++/detail/text.cpp \
|
||||
atf-c++/detail/text.hpp \
|
||||
atf-c++/detail/ui.cpp \
|
||||
atf-c++/detail/ui.hpp
|
||||
|
||||
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)
|
||||
|
||||
noinst_LTLIBRARIES += atf-c++/detail/libtest_helpers.la
|
||||
atf_c___detail_libtest_helpers_la_SOURCES = atf-c++/detail/test_helpers.cpp \
|
||||
atf-c++/detail/test_helpers.hpp
|
||||
|
||||
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 $(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 $(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 $(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 $(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 $(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 $(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 $(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 $(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 $(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 $(ATF_CXX_LIBS)
|
||||
|
||||
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
|
179
contrib/atf/atf-c++/detail/auto_array.hpp
Normal file
179
contrib/atf/atf-c++/detail/auto_array.hpp
Normal 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_)
|
304
contrib/atf/atf-c++/detail/auto_array_test.cpp
Normal file
304
contrib/atf/atf-c++/detail/auto_array_test.cpp
Normal 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);
|
||||
}
|
@ -259,7 +259,7 @@ tokenizer< IS >::next(void)
|
||||
t = token(m_lineno, m_text_type, text);
|
||||
quoted = true;
|
||||
} else {
|
||||
m_is.unget();
|
||||
m_is.putback(ch);
|
||||
done = true;
|
||||
}
|
||||
} else {
|
||||
@ -271,13 +271,13 @@ tokenizer< IS >::next(void)
|
||||
t = token(m_lineno, (*idelim).second,
|
||||
std::string("") + ch);
|
||||
else
|
||||
m_is.unget();
|
||||
m_is.putback(ch);
|
||||
} else if (ch == '\n') {
|
||||
done = true;
|
||||
if (text.empty())
|
||||
t = token(m_lineno, m_nl_type, "<<NEWLINE>>");
|
||||
else
|
||||
m_is.unget();
|
||||
m_is.putback(ch);
|
||||
} else if (m_skipws && (ch == ' ' || ch == '\t')) {
|
||||
if (!text.empty())
|
||||
done = true;
|
||||
|
@ -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();
|
||||
|
@ -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:
|
||||
|
@ -27,10 +27,6 @@
|
||||
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
extern "C" {
|
||||
#include <regex.h>
|
||||
}
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -92,43 +88,6 @@ get_process_helpers_path(const atf::tests::tc& tc, bool is_detail)
|
||||
".." / "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)
|
||||
|
@ -87,8 +87,6 @@ class tc;
|
||||
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);
|
||||
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;
|
||||
|
@ -38,6 +38,7 @@ extern "C" {
|
||||
#include <stdexcept>
|
||||
|
||||
#include "macros.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
#include "detail/fs.hpp"
|
||||
#include "detail/process.hpp"
|
||||
@ -291,7 +292,7 @@ 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")));
|
||||
}
|
||||
@ -305,7 +306,7 @@ 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")));
|
||||
}
|
||||
@ -319,7 +320,8 @@ 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")));
|
||||
}
|
||||
@ -354,10 +356,11 @@ ATF_TEST_CASE_BODY(require)
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@ -403,10 +406,10 @@ ATF_TEST_CASE_BODY(require_eq)
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@ -448,10 +451,10 @@ ATF_TEST_CASE_BODY(require_in)
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@ -495,10 +498,10 @@ ATF_TEST_CASE_BODY(require_match)
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@ -540,10 +543,10 @@ ATF_TEST_CASE_BODY(require_not_in)
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@ -586,13 +589,13 @@ ATF_TEST_CASE_BODY(require_throw)
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@ -638,13 +641,13 @@ ATF_TEST_CASE_BODY(require_throw_re)
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
@ -688,13 +691,13 @@ ATF_TEST_CASE_BODY(check_errno)
|
||||
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);
|
||||
@ -734,12 +737,12 @@ ATF_TEST_CASE_BODY(require_errno)
|
||||
|
||||
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));
|
||||
}
|
||||
|
56
contrib/atf/atf-c++/noncopyable.hpp
Normal file
56
contrib/atf/atf-c++/noncopyable.hpp
Normal 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_)
|
@ -59,7 +59,7 @@ atf_test_case version
|
||||
version_head()
|
||||
{
|
||||
atf_set "descr" "Checks that the version in atf-c++ is correct"
|
||||
atf_set "require.progs" "pkg-config"
|
||||
atf_set "require.progs" "atf-version pkg-config"
|
||||
}
|
||||
version_body()
|
||||
{
|
||||
|
@ -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++) {
|
||||
|
@ -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:
|
||||
|
104
contrib/atf/atf-c++/utils.cpp
Normal file
104
contrib/atf/atf-c++/utils.cpp
Normal 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());
|
||||
}
|
@ -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
|
||||
|
||||
|
@ -27,259 +27,409 @@
|
||||
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
extern "C" {
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include "atf-c/defs.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_DEFS_ATTRIBUTE_UNUSED)
|
||||
{
|
||||
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_DEFS_ATTRIBUTE_UNUSED)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@ -294,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);
|
||||
|
@ -32,5 +32,6 @@
|
||||
|
||||
#include <atf-c/error.h>
|
||||
#include <atf-c/macros.h>
|
||||
#include <atf-c/utils.h>
|
||||
|
||||
#endif /* !defined(ATF_C_H) */
|
||||
|
@ -1,157 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
lib_LTLIBRARIES += libatf-c.la
|
||||
libatf_c_la_SOURCES = atf-c/build.c \
|
||||
atf-c/build.h \
|
||||
atf-c/check.c \
|
||||
atf-c/check.h \
|
||||
atf-c/config.c \
|
||||
atf-c/config.h \
|
||||
atf-c/error.c \
|
||||
atf-c/error.h \
|
||||
atf-c/error_fwd.h \
|
||||
atf-c/macros.h \
|
||||
atf-c/tc.c \
|
||||
atf-c/tc.h \
|
||||
atf-c/tp.c \
|
||||
atf-c/tp.h \
|
||||
atf-c/utils.c \
|
||||
atf-c/utils.h
|
||||
nodist_libatf_c_la_SOURCES = atf-c/defs.h
|
||||
libatf_c_la_CPPFLAGS = "-DATF_ARCH=\"$(atf_arch)\"" \
|
||||
"-DATF_BUILD_CC=\"$(ATF_BUILD_CC)\"" \
|
||||
"-DATF_BUILD_CFLAGS=\"$(ATF_BUILD_CFLAGS)\"" \
|
||||
"-DATF_BUILD_CPP=\"$(ATF_BUILD_CPP)\"" \
|
||||
"-DATF_BUILD_CPPFLAGS=\"$(ATF_BUILD_CPPFLAGS)\"" \
|
||||
"-DATF_BUILD_CXX=\"$(ATF_BUILD_CXX)\"" \
|
||||
"-DATF_BUILD_CXXFLAGS=\"$(ATF_BUILD_CXXFLAGS)\"" \
|
||||
"-DATF_CONFDIR=\"$(atf_confdir)\"" \
|
||||
"-DATF_INCLUDEDIR=\"$(includedir)\"" \
|
||||
"-DATF_LIBDIR=\"$(libdir)\"" \
|
||||
"-DATF_LIBEXECDIR=\"$(libexecdir)\"" \
|
||||
"-DATF_MACHINE=\"$(atf_machine)\"" \
|
||||
"-DATF_M4=\"$(ATF_M4)\"" \
|
||||
"-DATF_PKGDATADIR=\"$(pkgdatadir)\"" \
|
||||
"-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.
|
||||
dist-hook: kill-defs-h
|
||||
kill-defs-h:
|
||||
rm -f $(distdir)/atf-c/defs.h
|
||||
|
||||
include_HEADERS += atf-c.h
|
||||
atf_c_HEADERS = atf-c/build.h \
|
||||
atf-c/check.h \
|
||||
atf-c/config.h \
|
||||
atf-c/defs.h \
|
||||
atf-c/error.h \
|
||||
atf-c/error_fwd.h \
|
||||
atf-c/macros.h \
|
||||
atf-c/tc.h \
|
||||
atf-c/tp.h \
|
||||
atf-c/utils.h
|
||||
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 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' \
|
||||
<$(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/Kyuafile \
|
||||
atf-c/macros_h_test.c \
|
||||
atf-c/unused_test.c
|
||||
tests_atf_cdir = $(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.c
|
||||
atf_c_atf_c_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
tests_atf_c_PROGRAMS += atf-c/build_test
|
||||
atf_c_build_test_SOURCES = atf-c/build_test.c atf-c/h_build.h
|
||||
atf_c_build_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
tests_atf_c_PROGRAMS += atf-c/check_test
|
||||
atf_c_check_test_SOURCES = atf-c/check_test.c
|
||||
atf_c_check_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
tests_atf_c_PROGRAMS += atf-c/config_test
|
||||
atf_c_config_test_SOURCES = atf-c/config_test.c
|
||||
atf_c_config_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
tests_atf_c_PROGRAMS += atf-c/error_test
|
||||
atf_c_error_test_SOURCES = atf-c/error_test.c
|
||||
atf_c_error_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
tests_atf_c_PROGRAMS += atf-c/macros_test
|
||||
atf_c_macros_test_SOURCES = atf-c/macros_test.c
|
||||
atf_c_macros_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
tests_atf_c_SCRIPTS = atf-c/pkg_config_test
|
||||
CLEANFILES += atf-c/pkg_config_test
|
||||
EXTRA_DIST += atf-c/pkg_config_test.sh
|
||||
atf-c/pkg_config_test: $(srcdir)/atf-c/pkg_config_test.sh
|
||||
test -d atf-c || mkdir -p atf-c
|
||||
@src="$(srcdir)/atf-c/pkg_config_test.sh"; \
|
||||
dst="atf-c/pkg_config_test"; $(BUILD_SH_TP)
|
||||
|
||||
tests_atf_c_PROGRAMS += atf-c/tc_test
|
||||
atf_c_tc_test_SOURCES = atf-c/tc_test.c
|
||||
atf_c_tc_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
tests_atf_c_PROGRAMS += atf-c/tp_test
|
||||
atf_c_tp_test_SOURCES = atf-c/tp_test.c
|
||||
atf_c_tp_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
tests_atf_c_PROGRAMS += atf-c/utils_test
|
||||
atf_c_utils_test_SOURCES = atf-c/utils_test.c atf-c/h_build.h
|
||||
atf_c_utils_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
include atf-c/detail/Makefile.am.inc
|
||||
|
||||
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
|
@ -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 December 26, 2010
|
||||
.Dd November 15, 2013
|
||||
.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 ,
|
||||
@ -72,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
|
||||
@ -80,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"
|
||||
@ -87,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"
|
||||
@ -119,10 +140,70 @@
|
||||
.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
|
||||
C-based test programs always follow this template:
|
||||
ATF provides a C programming interface to implement test programs.
|
||||
C-based test programs follow this template:
|
||||
.Bd -literal -offset indent
|
||||
.Ns ... C-specific includes go here ...
|
||||
|
||||
@ -382,7 +463,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
|
||||
@ -417,6 +498,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
|
||||
@ -433,6 +524,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 -ragged -offset indent
|
||||
Prints the contents of
|
||||
.Fa file
|
||||
to the standard output, prefixing every line with the string in
|
||||
.Fa prefix .
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft bool
|
||||
.Fo atf_utils_compare_file
|
||||
.Fa "const char *file"
|
||||
.Fa "const char *contents"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Returns true if the given
|
||||
.Fa file
|
||||
matches exactly the expected inlined
|
||||
.Fa contents .
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf_utils_copy_file
|
||||
.Fa "const char *source"
|
||||
.Fa "const char *destination"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Copies the file
|
||||
.Fa source
|
||||
to
|
||||
.Fa destination .
|
||||
The permissions of the file are preserved during the code.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf_utils_create_file
|
||||
.Fa "const char *file"
|
||||
.Fa "const char *contents"
|
||||
.Fa "..."
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Creates
|
||||
.Fa file
|
||||
with the text given in
|
||||
.Fa contents ,
|
||||
which is a formatting string that uses the rest of the variable arguments.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf_utils_file_exists
|
||||
.Fa "const char *file"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Checks if
|
||||
.Fa file
|
||||
exists.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft pid_t
|
||||
.Fo atf_utils_fork
|
||||
.Fa "void"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Forks a process and redirects the standard output and standard error of the
|
||||
child to files for later validation with
|
||||
.Fn atf_utils_wait .
|
||||
Fails the test case if the fork fails, so this does not return an error.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf_utils_free_charpp
|
||||
.Fa "char **argv"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Frees a dynamically-allocated array of dynamically-allocated strings.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft bool
|
||||
.Fo atf_utils_grep_file
|
||||
.Fa "const char *regexp"
|
||||
.Fa "const char *file"
|
||||
.Fa "..."
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Searches for the
|
||||
.Fa regexp ,
|
||||
which is a formatting string representing the regular expression,
|
||||
in the
|
||||
.Fa file .
|
||||
The variable arguments are used to construct the regular expression.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft bool
|
||||
.Fo atf_utils_grep_string
|
||||
.Fa "const char *regexp"
|
||||
.Fa "const char *str"
|
||||
.Fa "..."
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Searches for the
|
||||
.Fa regexp ,
|
||||
which is a formatting string representing the regular expression,
|
||||
in the literal string
|
||||
.Fa str .
|
||||
The variable arguments are used to construct the regular expression.
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft char *
|
||||
.Fo atf_utils_readline
|
||||
.Fa "int fd"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Reads a line from the file descriptor
|
||||
.Fa fd .
|
||||
The line, if any, is returned as a dynamically-allocated buffer that must be
|
||||
released with
|
||||
.Xr free 3 .
|
||||
If there was nothing to read, returns
|
||||
.Sq NULL .
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf_utils_redirect
|
||||
.Fa "const int fd"
|
||||
.Fa "const char *file"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Redirects the given file descriptor
|
||||
.Fa fd
|
||||
to
|
||||
.Fa file .
|
||||
This function exits the process in case of an error and does not properly mark
|
||||
the test case as failed.
|
||||
As a result, it should only be used in subprocesses of the test case; specially
|
||||
those spawned by
|
||||
.Fn atf_utils_fork .
|
||||
.Ed
|
||||
.Pp
|
||||
.Ft void
|
||||
.Fo atf_utils_wait
|
||||
.Fa "const pid_t pid"
|
||||
.Fa "const int expected_exit_status"
|
||||
.Fa "const char *expected_stdout"
|
||||
.Fa "const char *expected_stderr"
|
||||
.Fc
|
||||
.Bd -ragged -offset indent
|
||||
Waits and validates the result of a subprocess spawned with
|
||||
.Fn atf_utils_wait .
|
||||
The validation involves checking that the subprocess exited cleanly and returned
|
||||
the code specified in
|
||||
.Fa expected_exit_status
|
||||
and that its standard output and standard error match the strings given in
|
||||
.Fa expected_stdout
|
||||
and
|
||||
.Fa expected_stderr .
|
||||
.Pp
|
||||
If any of the
|
||||
.Fa expected_stdout
|
||||
or
|
||||
.Fa expected_stderr
|
||||
strings are prefixed with
|
||||
.Sq save: ,
|
||||
then they specify the name of the file into which to store the stdout or stderr
|
||||
of the subprocess, and no comparison is performed.
|
||||
.Ed
|
||||
.Sh EXAMPLES
|
||||
The following shows a complete test program with a single test case that
|
||||
validates the addition operator:
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -9,6 +9,5 @@ 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="test_helpers_test"}
|
||||
atf_test_program{name="text_test"}
|
||||
atf_test_program{name="user_test"}
|
||||
|
@ -1,104 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
libatf_c_la_SOURCES += atf-c/detail/dynstr.c \
|
||||
atf-c/detail/dynstr.h \
|
||||
atf-c/detail/env.c \
|
||||
atf-c/detail/env.h \
|
||||
atf-c/detail/fs.c \
|
||||
atf-c/detail/fs.h \
|
||||
atf-c/detail/list.c \
|
||||
atf-c/detail/list.h \
|
||||
atf-c/detail/map.c \
|
||||
atf-c/detail/map.h \
|
||||
atf-c/detail/process.c \
|
||||
atf-c/detail/process.h \
|
||||
atf-c/detail/sanity.c \
|
||||
atf-c/detail/sanity.h \
|
||||
atf-c/detail/text.c \
|
||||
atf-c/detail/text.h \
|
||||
atf-c/detail/tp_main.c \
|
||||
atf-c/detail/user.c \
|
||||
atf-c/detail/user.h
|
||||
|
||||
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)
|
||||
|
||||
noinst_LTLIBRARIES += atf-c/detail/libtest_helpers.la
|
||||
atf_c_detail_libtest_helpers_la_SOURCES = atf-c/detail/test_helpers.c \
|
||||
atf-c/detail/test_helpers.h
|
||||
atf_c_detail_libtest_helpers_la_CPPFLAGS = -I$(srcdir)/atf-c
|
||||
|
||||
tests_atf_c_detail_PROGRAMS = atf-c/detail/dynstr_test
|
||||
atf_c_detail_dynstr_test_SOURCES = atf-c/detail/dynstr_test.c
|
||||
atf_c_detail_dynstr_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
tests_atf_c_detail_PROGRAMS += atf-c/detail/env_test
|
||||
atf_c_detail_env_test_SOURCES = atf-c/detail/env_test.c
|
||||
atf_c_detail_env_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
tests_atf_c_detail_PROGRAMS += atf-c/detail/fs_test
|
||||
atf_c_detail_fs_test_SOURCES = atf-c/detail/fs_test.c
|
||||
atf_c_detail_fs_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
tests_atf_c_detail_PROGRAMS += atf-c/detail/test_helpers_test
|
||||
atf_c_detail_test_helpers_test_SOURCES = atf-c/detail/test_helpers_test.c
|
||||
atf_c_detail_test_helpers_test_LDADD = atf-c/detail/libtest_helpers.la \
|
||||
libatf-c.la
|
||||
|
||||
tests_atf_c_detail_PROGRAMS += atf-c/detail/list_test
|
||||
atf_c_detail_list_test_SOURCES = atf-c/detail/list_test.c
|
||||
atf_c_detail_list_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
tests_atf_c_detail_PROGRAMS += atf-c/detail/map_test
|
||||
atf_c_detail_map_test_SOURCES = atf-c/detail/map_test.c
|
||||
atf_c_detail_map_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
tests_atf_c_detail_PROGRAMS += atf-c/detail/process_helpers
|
||||
atf_c_detail_process_helpers_SOURCES = atf-c/detail/process_helpers.c
|
||||
|
||||
tests_atf_c_detail_PROGRAMS += atf-c/detail/process_test
|
||||
atf_c_detail_process_test_SOURCES = atf-c/detail/process_test.c
|
||||
atf_c_detail_process_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
tests_atf_c_detail_PROGRAMS += atf-c/detail/sanity_test
|
||||
atf_c_detail_sanity_test_SOURCES = atf-c/detail/sanity_test.c
|
||||
atf_c_detail_sanity_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
tests_atf_c_detail_PROGRAMS += atf-c/detail/text_test
|
||||
atf_c_detail_text_test_SOURCES = atf-c/detail/text_test.c
|
||||
atf_c_detail_text_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
tests_atf_c_detail_PROGRAMS += atf-c/detail/user_test
|
||||
atf_c_detail_user_test_SOURCES = atf-c/detail/user_test.c
|
||||
atf_c_detail_user_test_LDADD = atf-c/detail/libtest_helpers.la libatf-c.la
|
||||
|
||||
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
|
@ -95,12 +95,12 @@ check_file(const enum out_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case stdout_type:
|
||||
ATF_CHECK(grep_file("stdout", "stdout: msg"));
|
||||
ATF_CHECK(!grep_file("stdout", "stderr: msg"));
|
||||
ATF_CHECK(atf_utils_grep_file("stdout: msg", "stdout"));
|
||||
ATF_CHECK(!atf_utils_grep_file("stderr: msg", "stdout"));
|
||||
break;
|
||||
case stderr_type:
|
||||
ATF_CHECK(grep_file("stderr", "stderr: msg"));
|
||||
ATF_CHECK(!grep_file("stderr", "stdout: msg"));
|
||||
ATF_CHECK(atf_utils_grep_file("stderr: msg", "stderr"));
|
||||
ATF_CHECK(!atf_utils_grep_file("stdout: msg", "stderr"));
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE;
|
||||
@ -110,7 +110,7 @@ check_file(const enum out_type type)
|
||||
struct capture_stream {
|
||||
struct base_stream m_base;
|
||||
|
||||
atf_dynstr_t m_msg;
|
||||
char *m_msg;
|
||||
};
|
||||
#define CAPTURE_STREAM(type) \
|
||||
{ .m_base = BASE_STREAM(capture_stream_init, \
|
||||
@ -126,7 +126,7 @@ capture_stream_init(void *v)
|
||||
|
||||
s->m_base.m_sb_ptr = &s->m_base.m_sb;
|
||||
RE(atf_process_stream_init_capture(&s->m_base.m_sb));
|
||||
RE(atf_dynstr_init(&s->m_msg));
|
||||
s->m_msg = NULL;
|
||||
}
|
||||
|
||||
static
|
||||
@ -137,10 +137,10 @@ capture_stream_process(void *v, atf_process_child_t *c)
|
||||
|
||||
switch (s->m_base.m_type) {
|
||||
case stdout_type:
|
||||
(void)read_line(atf_process_child_stdout(c), &s->m_msg);
|
||||
s->m_msg = atf_utils_readline(atf_process_child_stdout(c));
|
||||
break;
|
||||
case stderr_type:
|
||||
(void)read_line(atf_process_child_stderr(c), &s->m_msg);
|
||||
s->m_msg = atf_utils_readline(atf_process_child_stderr(c));
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE;
|
||||
@ -155,18 +155,18 @@ capture_stream_fini(void *v)
|
||||
|
||||
switch (s->m_base.m_type) {
|
||||
case stdout_type:
|
||||
ATF_CHECK(grep_string(&s->m_msg, "stdout: msg"));
|
||||
ATF_CHECK(!grep_string(&s->m_msg, "stderr: msg"));
|
||||
ATF_CHECK(atf_utils_grep_string("stdout: msg", s->m_msg));
|
||||
ATF_CHECK(!atf_utils_grep_string("stderr: msg", s->m_msg));
|
||||
break;
|
||||
case stderr_type:
|
||||
ATF_CHECK(!grep_string(&s->m_msg, "stdout: msg"));
|
||||
ATF_CHECK(grep_string(&s->m_msg, "stderr: msg"));
|
||||
ATF_CHECK(!atf_utils_grep_string("stdout: msg", s->m_msg));
|
||||
ATF_CHECK(atf_utils_grep_string("stderr: msg", s->m_msg));
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE;
|
||||
}
|
||||
|
||||
atf_dynstr_fini(&s->m_msg);
|
||||
free(s->m_msg);
|
||||
atf_process_stream_fini(&s->m_base.m_sb);
|
||||
}
|
||||
|
||||
@ -881,16 +881,10 @@ static
|
||||
void
|
||||
check_line(int fd, const char *exp)
|
||||
{
|
||||
atf_dynstr_t line;
|
||||
bool eof;
|
||||
|
||||
atf_dynstr_init(&line);
|
||||
eof = read_line(fd, &line);
|
||||
ATF_CHECK(!eof);
|
||||
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);
|
||||
}
|
||||
|
||||
ATF_TC(exec_failure);
|
||||
|
@ -53,21 +53,6 @@
|
||||
|
||||
enum type { inv, pre, post, unreachable };
|
||||
|
||||
static
|
||||
bool
|
||||
grep(const atf_dynstr_t *line, const char *text)
|
||||
{
|
||||
const char *l = atf_dynstr_cstring(line);
|
||||
bool found;
|
||||
|
||||
found = false;
|
||||
|
||||
if (strstr(l, text) != NULL)
|
||||
found = true;
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
struct test_data {
|
||||
enum type m_type;
|
||||
bool m_cond;
|
||||
@ -109,9 +94,8 @@ do_test(enum type t, bool cond)
|
||||
{
|
||||
atf_process_child_t child;
|
||||
atf_process_status_t status;
|
||||
bool eof;
|
||||
int nlines;
|
||||
atf_dynstr_t lines[3];
|
||||
char *lines[3];
|
||||
|
||||
{
|
||||
atf_process_stream_t outsb, errsb;
|
||||
@ -125,13 +109,9 @@ do_test(enum type t, bool cond)
|
||||
}
|
||||
|
||||
nlines = 0;
|
||||
eof = false;
|
||||
do {
|
||||
RE(atf_dynstr_init(&lines[nlines]));
|
||||
if (!eof)
|
||||
eof = read_line(atf_process_child_stderr(&child), &lines[nlines]);
|
||||
while (nlines < 3 && (lines[nlines] =
|
||||
atf_utils_readline(atf_process_child_stderr(&child))) != NULL)
|
||||
nlines++;
|
||||
} while (nlines < 3);
|
||||
ATF_REQUIRE(nlines == 0 || nlines == 3);
|
||||
|
||||
RE(atf_process_child_wait(&child, &status));
|
||||
@ -147,29 +127,29 @@ do_test(enum type t, bool cond)
|
||||
if (!cond) {
|
||||
switch (t) {
|
||||
case inv:
|
||||
ATF_REQUIRE(grep(&lines[0], "Invariant"));
|
||||
ATF_REQUIRE(atf_utils_grep_string("Invariant", lines[0]));
|
||||
break;
|
||||
|
||||
case pre:
|
||||
ATF_REQUIRE(grep(&lines[0], "Precondition"));
|
||||
ATF_REQUIRE(atf_utils_grep_string("Precondition", lines[0]));
|
||||
break;
|
||||
|
||||
case post:
|
||||
ATF_REQUIRE(grep(&lines[0], "Postcondition"));
|
||||
ATF_REQUIRE(atf_utils_grep_string("Postcondition", lines[0]));
|
||||
break;
|
||||
|
||||
case unreachable:
|
||||
ATF_REQUIRE(grep(&lines[0], "Invariant"));
|
||||
ATF_REQUIRE(atf_utils_grep_string("Invariant", lines[0]));
|
||||
break;
|
||||
}
|
||||
|
||||
ATF_REQUIRE(grep(&lines[0], __FILE__));
|
||||
ATF_REQUIRE(grep(&lines[2], PACKAGE_BUGREPORT));
|
||||
ATF_REQUIRE(atf_utils_grep_string(__FILE__, lines[0]));
|
||||
ATF_REQUIRE(atf_utils_grep_string(PACKAGE_BUGREPORT, lines[2]));
|
||||
}
|
||||
|
||||
while (nlines > 0) {
|
||||
nlines--;
|
||||
atf_dynstr_fini(&lines[nlines]);
|
||||
free(lines[nlines]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <regex.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "atf-c/build.h"
|
||||
@ -106,72 +105,6 @@ get_process_helpers_path(const atf_tc_t *tc, const bool is_detail,
|
||||
is_detail ? "" : "detail/"));
|
||||
}
|
||||
|
||||
bool
|
||||
grep_string(const atf_dynstr_t *str, const char *regex)
|
||||
{
|
||||
int res;
|
||||
regex_t preg;
|
||||
|
||||
printf("Looking for '%s' in '%s'\n", regex, atf_dynstr_cstring(str));
|
||||
ATF_REQUIRE(regcomp(&preg, regex, REG_EXTENDED) == 0);
|
||||
|
||||
res = regexec(&preg, atf_dynstr_cstring(str), 0, NULL, 0);
|
||||
ATF_REQUIRE(res == 0 || res == REG_NOMATCH);
|
||||
|
||||
regfree(&preg);
|
||||
|
||||
return res == 0;
|
||||
}
|
||||
|
||||
bool
|
||||
grep_file(const char *file, const char *regex, ...)
|
||||
{
|
||||
bool done, found;
|
||||
int fd;
|
||||
va_list ap;
|
||||
atf_dynstr_t formatted;
|
||||
|
||||
va_start(ap, regex);
|
||||
RE(atf_dynstr_init_ap(&formatted, regex, ap));
|
||||
va_end(ap);
|
||||
|
||||
done = false;
|
||||
found = false;
|
||||
ATF_REQUIRE((fd = open(file, O_RDONLY)) != -1);
|
||||
do {
|
||||
atf_dynstr_t line;
|
||||
|
||||
RE(atf_dynstr_init(&line));
|
||||
|
||||
done = read_line(fd, &line);
|
||||
if (!done)
|
||||
found = grep_string(&line, atf_dynstr_cstring(&formatted));
|
||||
|
||||
atf_dynstr_fini(&line);
|
||||
} while (!found && !done);
|
||||
close(fd);
|
||||
|
||||
atf_dynstr_fini(&formatted);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
bool
|
||||
read_line(int fd, atf_dynstr_t *dest)
|
||||
{
|
||||
char ch;
|
||||
ssize_t cnt;
|
||||
|
||||
while ((cnt = read(fd, &ch, sizeof(ch))) == sizeof(ch) &&
|
||||
ch != '\n') {
|
||||
const atf_error_t err = atf_dynstr_append_fmt(dest, "%c", ch);
|
||||
ATF_REQUIRE(!atf_is_error(err));
|
||||
}
|
||||
ATF_REQUIRE(cnt != -1);
|
||||
|
||||
return cnt == 0;
|
||||
}
|
||||
|
||||
struct run_h_tc_data {
|
||||
atf_tc_t *m_tc;
|
||||
const char *m_resname;
|
||||
|
@ -81,7 +81,5 @@ void build_check_c_o(const atf_tc_t *, const char *, const char *, const bool);
|
||||
void header_check(const char *);
|
||||
void get_process_helpers_path(const atf_tc_t *, const bool,
|
||||
struct atf_fs_path *);
|
||||
bool grep_string(const struct atf_dynstr *, const char *);
|
||||
bool grep_file(const char *, const char *, ...);
|
||||
bool read_line(int, struct atf_dynstr *);
|
||||
void run_h_tc(atf_tc_t *, const char *, const char *, const char *);
|
||||
|
@ -1,185 +0,0 @@
|
||||
/*
|
||||
* Automated Testing Framework (atf)
|
||||
*
|
||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include "dynstr.h"
|
||||
#include "test_helpers.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Test cases for the free functions.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
/* TODO: Add checks for build_check_c_o and the macros defined in the
|
||||
* header file. */
|
||||
|
||||
ATF_TC(grep_string);
|
||||
ATF_TC_HEAD(grep_string, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Tests the grep_string helper "
|
||||
"function");
|
||||
}
|
||||
ATF_TC_BODY(grep_string, tc)
|
||||
{
|
||||
atf_dynstr_t str;
|
||||
|
||||
atf_dynstr_init_fmt(&str, "a string - aaaabbbb");
|
||||
ATF_CHECK(grep_string(&str, "a string"));
|
||||
ATF_CHECK(grep_string(&str, "^a string"));
|
||||
ATF_CHECK(grep_string(&str, "aaaabbbb$"));
|
||||
ATF_CHECK(grep_string(&str, "aa.*bb"));
|
||||
ATF_CHECK(!grep_string(&str, "foo"));
|
||||
ATF_CHECK(!grep_string(&str, "bar"));
|
||||
ATF_CHECK(!grep_string(&str, "aaaaa"));
|
||||
|
||||
atf_dynstr_fini(&str);
|
||||
}
|
||||
|
||||
|
||||
ATF_TC(grep_file);
|
||||
ATF_TC_HEAD(grep_file, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Tests the grep_file helper function");
|
||||
}
|
||||
ATF_TC_BODY(grep_file, tc)
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
f = fopen("test.txt", "w");
|
||||
ATF_CHECK(f != NULL);
|
||||
fprintf(f, "line1\n");
|
||||
fprintf(f, "the second line\n");
|
||||
fprintf(f, "aaaabbbb\n");
|
||||
fclose(f);
|
||||
|
||||
ATF_CHECK(grep_file("test.txt", "line1"));
|
||||
ATF_CHECK(grep_file("test.txt", "line%d", 1));
|
||||
ATF_CHECK(grep_file("test.txt", "second line"));
|
||||
ATF_CHECK(grep_file("test.txt", "aa.*bb"));
|
||||
ATF_CHECK(!grep_file("test.txt", "foo"));
|
||||
ATF_CHECK(!grep_file("test.txt", "bar"));
|
||||
ATF_CHECK(!grep_file("test.txt", "aaaaa"));
|
||||
}
|
||||
|
||||
ATF_TC(read_line);
|
||||
ATF_TC_HEAD(read_line, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Tests the read_line function");
|
||||
}
|
||||
ATF_TC_BODY(read_line, tc)
|
||||
{
|
||||
const char *l1 = "First line with % formatting % characters %";
|
||||
const char *l2 = "Second line; much longer than the first one";
|
||||
const char *l3 = "Last line, without terminator";
|
||||
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
f = fopen("test", "w");
|
||||
ATF_REQUIRE(f != NULL);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
{
|
||||
int fd;
|
||||
atf_dynstr_t dest;
|
||||
bool eof;
|
||||
|
||||
fd = open("test", O_RDONLY);
|
||||
ATF_REQUIRE(fd != -1);
|
||||
|
||||
RE(atf_dynstr_init(&dest));
|
||||
eof = read_line(fd, &dest);
|
||||
ATF_REQUIRE(eof);
|
||||
atf_dynstr_fini(&dest);
|
||||
}
|
||||
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
f = fopen("test", "w");
|
||||
ATF_REQUIRE(f != NULL);
|
||||
|
||||
fprintf(f, "%s\n", l1);
|
||||
fprintf(f, "%s\n", l2);
|
||||
fprintf(f, "%s", l3);
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
{
|
||||
int fd;
|
||||
atf_dynstr_t dest;
|
||||
bool eof;
|
||||
|
||||
fd = open("test", O_RDONLY);
|
||||
ATF_REQUIRE(fd != -1);
|
||||
|
||||
RE(atf_dynstr_init(&dest));
|
||||
eof = read_line(fd, &dest);
|
||||
ATF_REQUIRE(!eof);
|
||||
printf("1st line: >%s<\n", atf_dynstr_cstring(&dest));
|
||||
ATF_REQUIRE(atf_equal_dynstr_cstring(&dest, l1));
|
||||
atf_dynstr_fini(&dest);
|
||||
|
||||
RE(atf_dynstr_init(&dest));
|
||||
eof = read_line(fd, &dest);
|
||||
ATF_REQUIRE(!eof);
|
||||
printf("2nd line: >%s<\n", atf_dynstr_cstring(&dest));
|
||||
ATF_REQUIRE(atf_equal_dynstr_cstring(&dest, l2));
|
||||
atf_dynstr_fini(&dest);
|
||||
|
||||
RE(atf_dynstr_init(&dest));
|
||||
eof = read_line(fd, &dest);
|
||||
ATF_REQUIRE(eof);
|
||||
printf("3rd line: >%s<\n", atf_dynstr_cstring(&dest));
|
||||
ATF_REQUIRE(atf_equal_dynstr_cstring(&dest, l3));
|
||||
atf_dynstr_fini(&dest);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Main.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
/* Add the tests for the free functions. */
|
||||
ATF_TP_ADD_TC(tp, grep_string);
|
||||
ATF_TP_ADD_TC(tp, grep_file);
|
||||
ATF_TP_ADD_TC(tp, read_line);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
@ -80,7 +80,7 @@
|
||||
#define ATF_TC_HEAD(tc, tcptr) \
|
||||
static \
|
||||
void \
|
||||
atfu_ ## tc ## _head(atf_tc_t *tcptr)
|
||||
atfu_ ## tc ## _head(atf_tc_t *tcptr ATF_DEFS_ATTRIBUTE_UNUSED)
|
||||
|
||||
#define ATF_TC_HEAD_NAME(tc) \
|
||||
(atfu_ ## tc ## _head)
|
||||
@ -181,6 +181,24 @@
|
||||
ATF_CHECK_MSG(strcmp(x, y) == 0, "%s != %s (%s != %s): " fmt, \
|
||||
#x, #y, x, y, ##__VA_ARGS__)
|
||||
|
||||
#define ATF_REQUIRE_MATCH(regexp, string) \
|
||||
ATF_REQUIRE_MSG(atf_utils_grep_string("%s", string, regexp), \
|
||||
"'%s' not matched in '%s'", regexp, string);
|
||||
|
||||
#define ATF_CHECK_MATCH(regexp, string) \
|
||||
ATF_CHECK_MSG(atf_utils_grep_string("%s", string, regexp), \
|
||||
"'%s' not matched in '%s'", regexp, string);
|
||||
|
||||
#define ATF_REQUIRE_MATCH_MSG(regexp, string, fmt, ...) \
|
||||
ATF_REQUIRE_MSG(atf_utils_grep_string("%s", string, regexp), \
|
||||
"'%s' not matched in '%s': " fmt, regexp, string, \
|
||||
##__VA_ARGS__);
|
||||
|
||||
#define ATF_CHECK_MATCH_MSG(regexp, string, fmt, ...) \
|
||||
ATF_CHECK_MSG(atf_utils_grep_string("%s", string, regexp), \
|
||||
"'%s' not matched in '%s': " fmt, regexp, string, \
|
||||
##__VA_ARGS__);
|
||||
|
||||
#define ATF_CHECK_ERRNO(exp_errno, bool_expr) \
|
||||
atf_tc_check_errno(__FILE__, __LINE__, exp_errno, #bool_expr, bool_expr)
|
||||
|
||||
|
@ -125,6 +125,11 @@ init_and_run_h_tc(const char *name, void (*head)(atf_tc_t *),
|
||||
#define H_CHECK_STREQ(id, v1, v2) \
|
||||
H_DEF(check_streq_ ## id, ATF_CHECK_STREQ(v1, v2))
|
||||
|
||||
#define H_CHECK_MATCH_HEAD_NAME(id) ATF_TC_HEAD_NAME(h_check_match_ ## id)
|
||||
#define H_CHECK_MATCH_BODY_NAME(id) ATF_TC_BODY_NAME(h_check_match_ ## id)
|
||||
#define H_CHECK_MATCH(id, v1, v2) \
|
||||
H_DEF(check_match_ ## id, ATF_CHECK_MATCH(v1, v2))
|
||||
|
||||
#define H_CHECK_EQ_MSG_HEAD_NAME(id) \
|
||||
ATF_TC_HEAD_NAME(h_check_eq_msg_ ## id)
|
||||
#define H_CHECK_EQ_MSG_BODY_NAME(id) \
|
||||
@ -139,6 +144,13 @@ init_and_run_h_tc(const char *name, void (*head)(atf_tc_t *),
|
||||
#define H_CHECK_STREQ_MSG(id, v1, v2, msg) \
|
||||
H_DEF(check_streq_msg_ ## id, ATF_CHECK_STREQ_MSG(v1, v2, msg))
|
||||
|
||||
#define H_CHECK_MATCH_MSG_HEAD_NAME(id) \
|
||||
ATF_TC_HEAD_NAME(h_check_match_msg_ ## id)
|
||||
#define H_CHECK_MATCH_MSG_BODY_NAME(id) \
|
||||
ATF_TC_BODY_NAME(h_check_match_msg_ ## id)
|
||||
#define H_CHECK_MATCH_MSG(id, v1, v2, msg) \
|
||||
H_DEF(check_match_msg_ ## id, ATF_CHECK_MATCH_MSG(v1, v2, msg))
|
||||
|
||||
#define H_CHECK_ERRNO_HEAD_NAME(id) ATF_TC_HEAD_NAME(h_check_errno_ ## id)
|
||||
#define H_CHECK_ERRNO_BODY_NAME(id) ATF_TC_BODY_NAME(h_check_errno_ ## id)
|
||||
#define H_CHECK_ERRNO(id, exp_errno, bool_expr) \
|
||||
@ -164,6 +176,11 @@ init_and_run_h_tc(const char *name, void (*head)(atf_tc_t *),
|
||||
#define H_REQUIRE_STREQ(id, v1, v2) \
|
||||
H_DEF(require_streq_ ## id, ATF_REQUIRE_STREQ(v1, v2))
|
||||
|
||||
#define H_REQUIRE_MATCH_HEAD_NAME(id) ATF_TC_HEAD_NAME(h_require_match_ ## id)
|
||||
#define H_REQUIRE_MATCH_BODY_NAME(id) ATF_TC_BODY_NAME(h_require_match_ ## id)
|
||||
#define H_REQUIRE_MATCH(id, v1, v2) \
|
||||
H_DEF(require_match_ ## id, ATF_REQUIRE_MATCH(v1, v2))
|
||||
|
||||
#define H_REQUIRE_EQ_MSG_HEAD_NAME(id) \
|
||||
ATF_TC_HEAD_NAME(h_require_eq_msg_ ## id)
|
||||
#define H_REQUIRE_EQ_MSG_BODY_NAME(id) \
|
||||
@ -178,6 +195,13 @@ init_and_run_h_tc(const char *name, void (*head)(atf_tc_t *),
|
||||
#define H_REQUIRE_STREQ_MSG(id, v1, v2, msg) \
|
||||
H_DEF(require_streq_msg_ ## id, ATF_REQUIRE_STREQ_MSG(v1, v2, msg))
|
||||
|
||||
#define H_REQUIRE_MATCH_MSG_HEAD_NAME(id) \
|
||||
ATF_TC_HEAD_NAME(h_require_match_msg_ ## id)
|
||||
#define H_REQUIRE_MATCH_MSG_BODY_NAME(id) \
|
||||
ATF_TC_BODY_NAME(h_require_match_msg_ ## id)
|
||||
#define H_REQUIRE_MATCH_MSG(id, v1, v2, msg) \
|
||||
H_DEF(require_match_msg_ ## id, ATF_REQUIRE_MATCH_MSG(v1, v2, msg))
|
||||
|
||||
#define H_REQUIRE_ERRNO_HEAD_NAME(id) ATF_TC_HEAD_NAME(h_require_errno_ ## id)
|
||||
#define H_REQUIRE_ERRNO_BODY_NAME(id) ATF_TC_BODY_NAME(h_require_errno_ ## id)
|
||||
#define H_REQUIRE_ERRNO(id, exp_errno, bool_expr) \
|
||||
@ -240,11 +264,11 @@ ATF_TC_BODY(check_errno, tc)
|
||||
ATF_REQUIRE(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(grep_file("error", "macros_test.c:[0-9]+: %s$",
|
||||
t->exp_regex));
|
||||
ATF_REQUIRE(atf_utils_grep_file("^failed", "result"));
|
||||
ATF_REQUIRE(atf_utils_grep_file(
|
||||
"macros_test.c:[0-9]+: %s$", "error", t->exp_regex));
|
||||
}
|
||||
|
||||
ATF_REQUIRE(unlink("before") != -1);
|
||||
@ -282,11 +306,12 @@ ATF_TC_BODY(require_errno, tc)
|
||||
|
||||
ATF_REQUIRE(exists("before"));
|
||||
if (t->ok) {
|
||||
ATF_REQUIRE(grep_file("result", "^passed"));
|
||||
ATF_REQUIRE(atf_utils_grep_file("^passed", "result"));
|
||||
ATF_REQUIRE(exists("after"));
|
||||
} else {
|
||||
ATF_REQUIRE(grep_file("result", "^failed: .*macros_test.c:[0-9]+: "
|
||||
"%s$", t->exp_regex));
|
||||
ATF_REQUIRE(atf_utils_grep_file(
|
||||
"^failed: .*macros_test.c:[0-9]+: %s$", "result",
|
||||
t->exp_regex));
|
||||
ATF_REQUIRE(!exists("after"));
|
||||
}
|
||||
|
||||
@ -340,11 +365,11 @@ ATF_TC_BODY(check, tc)
|
||||
ATF_REQUIRE(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(grep_file("error", "Check failed: .*"
|
||||
"macros_test.c:[0-9]+: %s$", t->msg));
|
||||
ATF_REQUIRE(atf_utils_grep_file("^failed", "result"));
|
||||
ATF_REQUIRE(atf_utils_grep_file("Check failed: .*"
|
||||
"macros_test.c:[0-9]+: %s$", "error", t->msg));
|
||||
}
|
||||
|
||||
ATF_REQUIRE(unlink("before") != -1);
|
||||
@ -381,11 +406,11 @@ do_check_eq_tests(const struct check_eq_test *tests)
|
||||
ATF_CHECK(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_CHECK(grep_file("error", "Check failed: .*"
|
||||
"macros_test.c:[0-9]+: %s$", t->msg));
|
||||
ATF_REQUIRE(atf_utils_grep_file("^failed", "result"));
|
||||
ATF_CHECK(atf_utils_grep_file("Check failed: .*"
|
||||
"macros_test.c:[0-9]+: %s$", "error", t->msg));
|
||||
}
|
||||
|
||||
ATF_CHECK(unlink("before") != -1);
|
||||
@ -442,8 +467,8 @@ H_CHECK_STREQ_MSG(2_1, "2", "1", "2 does not match 1");
|
||||
H_CHECK_STREQ_MSG(2_2, "2", "2", "2 does not match 2");
|
||||
#define CHECK_STREQ_VAR1 "5"
|
||||
#define CHECK_STREQ_VAR2 "9"
|
||||
const const char *check_streq_var1 = CHECK_STREQ_VAR1;
|
||||
const const char *check_streq_var2 = CHECK_STREQ_VAR2;
|
||||
const char *check_streq_var1 = CHECK_STREQ_VAR1;
|
||||
const char *check_streq_var2 = CHECK_STREQ_VAR2;
|
||||
H_CHECK_STREQ(vars, check_streq_var1, check_streq_var2);
|
||||
|
||||
ATF_TC(check_streq);
|
||||
@ -484,6 +509,40 @@ ATF_TC_BODY(check_streq, tc)
|
||||
do_check_eq_tests(tests);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Test cases for the ATF_CHECK_MATCH and ATF_CHECK_MATCH_MSG macros.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
H_CHECK_MATCH(yes, "hello [a-z]+", "abc hello world");
|
||||
H_CHECK_MATCH(no, "hello [a-z]+", "abc hello WORLD");
|
||||
H_CHECK_MATCH_MSG(yes, "hello [a-z]+", "abc hello world", "lowercase");
|
||||
H_CHECK_MATCH_MSG(no, "hello [a-z]+", "abc hello WORLD", "uppercase");
|
||||
|
||||
ATF_TC(check_match);
|
||||
ATF_TC_HEAD(check_match, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Tests the ATF_CHECK_MATCH and "
|
||||
"ATF_CHECK_MATCH_MSG macros");
|
||||
}
|
||||
ATF_TC_BODY(check_match, tc)
|
||||
{
|
||||
struct check_eq_test tests[] = {
|
||||
{ H_CHECK_MATCH_HEAD_NAME(yes), H_CHECK_MATCH_BODY_NAME(yes),
|
||||
"hello [a-z]+", "abc hello world", "", true },
|
||||
{ H_CHECK_MATCH_HEAD_NAME(no), H_CHECK_MATCH_BODY_NAME(no),
|
||||
"hello [a-z]+", "abc hello WORLD",
|
||||
"'hello \\[a-z\\]\\+' not matched in 'abc hello WORLD'", false },
|
||||
{ H_CHECK_MATCH_MSG_HEAD_NAME(yes), H_CHECK_MATCH_MSG_BODY_NAME(yes),
|
||||
"hello [a-z]+", "abc hello world", "", true },
|
||||
{ H_CHECK_MATCH_MSG_HEAD_NAME(no), H_CHECK_MATCH_MSG_BODY_NAME(no),
|
||||
"hello [a-z]+", "abc hello WORLD",
|
||||
"'hello \\[a-z\\]\\+' not matched in 'abc hello WORLD': uppercase",
|
||||
false },
|
||||
{ NULL, NULL, 0, 0, "", false }
|
||||
};
|
||||
do_check_eq_tests(tests);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Test cases for the ATF_REQUIRE and ATF_REQUIRE_MSG macros.
|
||||
* --------------------------------------------------------------------- */
|
||||
@ -526,11 +585,11 @@ ATF_TC_BODY(require, tc)
|
||||
|
||||
ATF_REQUIRE(exists("before"));
|
||||
if (t->ok) {
|
||||
ATF_REQUIRE(grep_file("result", "^passed"));
|
||||
ATF_REQUIRE(atf_utils_grep_file("^passed", "result"));
|
||||
ATF_REQUIRE(exists("after"));
|
||||
} else {
|
||||
ATF_REQUIRE(grep_file("result", "^failed: .*macros_test.c:[0-9]+: "
|
||||
"%s$", t->msg));
|
||||
ATF_REQUIRE(atf_utils_grep_file(
|
||||
"^failed: .*macros_test.c:[0-9]+: %s$", "result", t->msg));
|
||||
ATF_REQUIRE(!exists("after"));
|
||||
}
|
||||
|
||||
@ -567,11 +626,11 @@ do_require_eq_tests(const struct require_eq_test *tests)
|
||||
|
||||
ATF_REQUIRE(exists("before"));
|
||||
if (t->ok) {
|
||||
ATF_REQUIRE(grep_file("result", "^passed"));
|
||||
ATF_REQUIRE(atf_utils_grep_file("^passed", "result"));
|
||||
ATF_REQUIRE(exists("after"));
|
||||
} else {
|
||||
ATF_REQUIRE(grep_file("result", "^failed: .*macros_test.c"
|
||||
":[0-9]+: %s$", t->msg));
|
||||
ATF_REQUIRE(atf_utils_grep_file("^failed: .*macros_test.c"
|
||||
":[0-9]+: %s$", "result", t->msg));
|
||||
ATF_REQUIRE(!exists("after"));
|
||||
}
|
||||
|
||||
@ -630,8 +689,8 @@ H_REQUIRE_STREQ_MSG(2_1, "2", "1", "2 does not match 1");
|
||||
H_REQUIRE_STREQ_MSG(2_2, "2", "2", "2 does not match 2");
|
||||
#define REQUIRE_STREQ_VAR1 "5"
|
||||
#define REQUIRE_STREQ_VAR2 "9"
|
||||
const const char *require_streq_var1 = REQUIRE_STREQ_VAR1;
|
||||
const const char *require_streq_var2 = REQUIRE_STREQ_VAR2;
|
||||
const char *require_streq_var1 = REQUIRE_STREQ_VAR1;
|
||||
const char *require_streq_var2 = REQUIRE_STREQ_VAR2;
|
||||
H_REQUIRE_STREQ(vars, require_streq_var1, require_streq_var2);
|
||||
|
||||
ATF_TC(require_streq);
|
||||
@ -672,6 +731,41 @@ ATF_TC_BODY(require_streq, tc)
|
||||
do_require_eq_tests(tests);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Test cases for the ATF_REQUIRE_MATCH and ATF_REQUIRE_MATCH_MSG macros.
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
H_REQUIRE_MATCH(yes, "hello [a-z]+", "abc hello world");
|
||||
H_REQUIRE_MATCH(no, "hello [a-z]+", "abc hello WORLD");
|
||||
H_REQUIRE_MATCH_MSG(yes, "hello [a-z]+", "abc hello world", "lowercase");
|
||||
H_REQUIRE_MATCH_MSG(no, "hello [a-z]+", "abc hello WORLD", "uppercase");
|
||||
|
||||
ATF_TC(require_match);
|
||||
ATF_TC_HEAD(require_match, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Tests the ATF_REQUIRE_MATCH and "
|
||||
"ATF_REQUIRE_MATCH_MSG macros");
|
||||
}
|
||||
ATF_TC_BODY(require_match, tc)
|
||||
{
|
||||
struct require_eq_test tests[] = {
|
||||
{ H_REQUIRE_MATCH_HEAD_NAME(yes), H_REQUIRE_MATCH_BODY_NAME(yes),
|
||||
"hello [a-z]+", "abc hello world", "", true },
|
||||
{ H_REQUIRE_MATCH_HEAD_NAME(no), H_REQUIRE_MATCH_BODY_NAME(no),
|
||||
"hello [a-z]+", "abc hello WORLD",
|
||||
"'hello \\[a-z\\]\\+' not matched in 'abc hello WORLD'", false },
|
||||
{ H_REQUIRE_MATCH_MSG_HEAD_NAME(yes),
|
||||
H_REQUIRE_MATCH_MSG_BODY_NAME(yes),
|
||||
"hello [a-z]+", "abc hello world", "", true },
|
||||
{ H_REQUIRE_MATCH_MSG_HEAD_NAME(no), H_REQUIRE_MATCH_MSG_BODY_NAME(no),
|
||||
"hello [a-z]+", "abc hello WORLD",
|
||||
"'hello \\[a-z\\]\\+' not matched in 'abc hello WORLD': uppercase",
|
||||
false },
|
||||
{ NULL, NULL, 0, 0, "", false }
|
||||
};
|
||||
do_require_eq_tests(tests);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Miscellaneous test cases covering several macros.
|
||||
* --------------------------------------------------------------------- */
|
||||
@ -728,12 +822,12 @@ ATF_TC_BODY(msg_embedded_fmt, tc)
|
||||
|
||||
if (t->fatal) {
|
||||
bool matched =
|
||||
grep_file("result", "^failed: .*macros_test.c:[0-9]+: "
|
||||
"%s$", t->msg);
|
||||
atf_utils_grep_file(
|
||||
"^failed: .*macros_test.c:[0-9]+: %s$", "result", t->msg);
|
||||
ATF_CHECK_MSG(matched, "couldn't find error string in result");
|
||||
} else {
|
||||
bool matched = grep_file("error", "Check failed: .*"
|
||||
"macros_test.c:[0-9]+: %s$", t->msg);
|
||||
bool matched = atf_utils_grep_file("Check failed: .*"
|
||||
"macros_test.c:[0-9]+: %s$", "error", t->msg);
|
||||
ATF_CHECK_MSG(matched, "couldn't find error string in output");
|
||||
}
|
||||
}
|
||||
@ -765,11 +859,13 @@ ATF_TP_ADD_TCS(tp)
|
||||
ATF_TP_ADD_TC(tp, check_eq);
|
||||
ATF_TP_ADD_TC(tp, check_streq);
|
||||
ATF_TP_ADD_TC(tp, check_errno);
|
||||
ATF_TP_ADD_TC(tp, check_match);
|
||||
|
||||
ATF_TP_ADD_TC(tp, require);
|
||||
ATF_TP_ADD_TC(tp, require_eq);
|
||||
ATF_TP_ADD_TC(tp, require_streq);
|
||||
ATF_TP_ADD_TC(tp, require_errno);
|
||||
ATF_TP_ADD_TC(tp, require_match);
|
||||
|
||||
ATF_TP_ADD_TC(tp, msg_embedded_fmt);
|
||||
|
||||
|
@ -59,7 +59,7 @@ atf_test_case version
|
||||
version_head()
|
||||
{
|
||||
atf_set "descr" "Checks that the version in atf-c is correct"
|
||||
atf_set "require.progs" "pkg-config"
|
||||
atf_set "require.progs" "atf-version pkg-config"
|
||||
}
|
||||
version_body()
|
||||
{
|
||||
|
@ -27,10 +27,221 @@
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "atf-c/utils.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <regex.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
#include "detail/dynstr.h"
|
||||
|
||||
/** Searches for a regexp in a string.
|
||||
*
|
||||
* \param regex The regexp to look for.
|
||||
* \param str The string in which to look for the expression.
|
||||
*
|
||||
* \return True if there is a match; false otherwise. */
|
||||
static
|
||||
bool
|
||||
grep_string(const char *regex, const char *str)
|
||||
{
|
||||
int res;
|
||||
regex_t preg;
|
||||
|
||||
printf("Looking for '%s' in '%s'\n", regex, str);
|
||||
ATF_REQUIRE(regcomp(&preg, regex, REG_EXTENDED) == 0);
|
||||
|
||||
res = regexec(&preg, str, 0, NULL, 0);
|
||||
ATF_REQUIRE(res == 0 || res == REG_NOMATCH);
|
||||
|
||||
regfree(&preg);
|
||||
|
||||
return res == 0;
|
||||
}
|
||||
|
||||
/** Prints the contents of a file to stdout.
|
||||
*
|
||||
* \param name The name of the file to be printed.
|
||||
* \param prefix An string to be prepended to every line of the printed
|
||||
* file. */
|
||||
void
|
||||
atf_utils_cat_file(const char *name, const char *prefix)
|
||||
{
|
||||
const int fd = open(name, O_RDONLY);
|
||||
ATF_REQUIRE_MSG(fd != -1, "Cannot open %s", name);
|
||||
|
||||
char buffer[1024];
|
||||
ssize_t count;
|
||||
bool continued = false;
|
||||
while ((count = read(fd, buffer, sizeof(buffer) - 1)) > 0) {
|
||||
buffer[count] = '\0';
|
||||
|
||||
if (!continued)
|
||||
printf("%s", prefix);
|
||||
|
||||
char *iter = buffer;
|
||||
char *end;
|
||||
while ((end = strchr(iter, '\n')) != NULL) {
|
||||
*end = '\0';
|
||||
printf("%s\n", iter);
|
||||
|
||||
iter = end + 1;
|
||||
if (iter != buffer + count)
|
||||
printf("%s", prefix);
|
||||
else
|
||||
continued = false;
|
||||
}
|
||||
if (iter < buffer + count) {
|
||||
printf("%s", iter);
|
||||
continued = true;
|
||||
}
|
||||
}
|
||||
ATF_REQUIRE(count == 0);
|
||||
}
|
||||
|
||||
/** Compares a file against the given golden contents.
|
||||
*
|
||||
* \param name Name of the file to be compared.
|
||||
* \param contents Expected contents of the file.
|
||||
*
|
||||
* \return True if the file matches the contents; false otherwise. */
|
||||
bool
|
||||
atf_utils_compare_file(const char *name, const char *contents)
|
||||
{
|
||||
const int fd = open(name, O_RDONLY);
|
||||
ATF_REQUIRE_MSG(fd != -1, "Cannot open %s", name);
|
||||
|
||||
const char *pos = contents;
|
||||
ssize_t remaining = strlen(contents);
|
||||
|
||||
char buffer[1024];
|
||||
ssize_t count;
|
||||
while ((count = read(fd, buffer, sizeof(buffer))) > 0 &&
|
||||
count <= remaining) {
|
||||
if (memcmp(pos, buffer, count) != 0) {
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
remaining -= count;
|
||||
pos += count;
|
||||
}
|
||||
close(fd);
|
||||
return count == 0 && remaining == 0;
|
||||
}
|
||||
|
||||
/** Copies a file.
|
||||
*
|
||||
* \param source Path to the source file.
|
||||
* \param destination Path to the destination file. */
|
||||
void
|
||||
atf_utils_copy_file(const char *source, const char *destination)
|
||||
{
|
||||
const int input = open(source, O_RDONLY);
|
||||
ATF_REQUIRE_MSG(input != -1, "Failed to open source file during "
|
||||
"copy (%s)", source);
|
||||
|
||||
const int output = open(destination, O_WRONLY | O_CREAT | O_TRUNC, 0777);
|
||||
ATF_REQUIRE_MSG(output != -1, "Failed to open destination file during "
|
||||
"copy (%s)", destination);
|
||||
|
||||
char buffer[1024];
|
||||
ssize_t length;
|
||||
while ((length = read(input, buffer, sizeof(buffer))) > 0)
|
||||
ATF_REQUIRE_MSG(write(output, buffer, length) == length,
|
||||
"Failed to write to %s during copy", destination);
|
||||
ATF_REQUIRE_MSG(length != -1, "Failed to read from %s during copy", source);
|
||||
|
||||
struct stat sb;
|
||||
ATF_REQUIRE_MSG(fstat(input, &sb) != -1,
|
||||
"Failed to stat source file %s during copy", source);
|
||||
ATF_REQUIRE_MSG(fchmod(output, sb.st_mode) != -1,
|
||||
"Failed to chmod destination file %s during copy",
|
||||
destination);
|
||||
|
||||
close(output);
|
||||
close(input);
|
||||
}
|
||||
|
||||
/** Creates a file.
|
||||
*
|
||||
* \param name Name of the file to create.
|
||||
* \param contents Text to write into the created file.
|
||||
* \param ... Positional parameters to the contents. */
|
||||
void
|
||||
atf_utils_create_file(const char *name, const char *contents, ...)
|
||||
{
|
||||
va_list ap;
|
||||
atf_dynstr_t formatted;
|
||||
atf_error_t error;
|
||||
|
||||
va_start(ap, contents);
|
||||
error = atf_dynstr_init_ap(&formatted, contents, ap);
|
||||
va_end(ap);
|
||||
ATF_REQUIRE(!atf_is_error(error));
|
||||
|
||||
const int fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||
ATF_REQUIRE_MSG(fd != -1, "Cannot create file %s", name);
|
||||
ATF_REQUIRE(write(fd, atf_dynstr_cstring(&formatted),
|
||||
atf_dynstr_length(&formatted)) != -1);
|
||||
close(fd);
|
||||
|
||||
atf_dynstr_fini(&formatted);
|
||||
}
|
||||
|
||||
/** Checks if a file exists.
|
||||
*
|
||||
* \param path Location of the file to check for.
|
||||
*
|
||||
* \return True if the file exists, false otherwise. */
|
||||
bool
|
||||
atf_utils_file_exists(const char *path)
|
||||
{
|
||||
const int ret = access(path, F_OK);
|
||||
if (ret == -1) {
|
||||
if (errno != ENOENT)
|
||||
atf_tc_fail("Failed to check the existence of %s: %s", path,
|
||||
strerror(errno));
|
||||
else
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Spawns a subprocess and redirects its output to files.
|
||||
*
|
||||
* Use the atf_utils_wait() function to wait for the completion of the spawned
|
||||
* subprocess and validate its exit conditions.
|
||||
*
|
||||
* \return 0 in the new child; the PID of the new child in the parent. Does
|
||||
* not return in error conditions. */
|
||||
pid_t
|
||||
atf_utils_fork(void)
|
||||
{
|
||||
const pid_t pid = fork();
|
||||
if (pid == -1)
|
||||
atf_tc_fail("fork failed");
|
||||
|
||||
if (pid == 0) {
|
||||
atf_utils_redirect(STDOUT_FILENO, "atf_utils_fork_out.txt");
|
||||
atf_utils_redirect(STDERR_FILENO, "atf_utils_fork_err.txt");
|
||||
}
|
||||
return pid;
|
||||
}
|
||||
|
||||
/** Frees an dynamically-allocated "argv" array.
|
||||
*
|
||||
* \param argv A dynamically-allocated array of dynamically-allocated
|
||||
* strings. */
|
||||
void
|
||||
atf_utils_free_charpp(char **argv)
|
||||
{
|
||||
@ -41,3 +252,164 @@ atf_utils_free_charpp(char **argv)
|
||||
|
||||
free(argv);
|
||||
}
|
||||
|
||||
/** Searches for a regexp in a file.
|
||||
*
|
||||
* \param regex The regexp to look for.
|
||||
* \param file The file in which to look for the expression.
|
||||
* \param ... Positional parameters to the regex.
|
||||
*
|
||||
* \return True if there is a match; false otherwise. */
|
||||
bool
|
||||
atf_utils_grep_file(const char *regex, const char *file, ...)
|
||||
{
|
||||
int fd;
|
||||
va_list ap;
|
||||
atf_dynstr_t formatted;
|
||||
atf_error_t error;
|
||||
|
||||
va_start(ap, file);
|
||||
error = atf_dynstr_init_ap(&formatted, regex, ap);
|
||||
va_end(ap);
|
||||
ATF_REQUIRE(!atf_is_error(error));
|
||||
|
||||
ATF_REQUIRE((fd = open(file, O_RDONLY)) != -1);
|
||||
bool found = false;
|
||||
char *line = NULL;
|
||||
while (!found && (line = atf_utils_readline(fd)) != NULL) {
|
||||
found = grep_string(atf_dynstr_cstring(&formatted), line);
|
||||
free(line);
|
||||
}
|
||||
close(fd);
|
||||
|
||||
atf_dynstr_fini(&formatted);
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/** Searches for a regexp in a string.
|
||||
*
|
||||
* \param regex The regexp to look for.
|
||||
* \param str The string in which to look for the expression.
|
||||
* \param ... Positional parameters to the regex.
|
||||
*
|
||||
* \return True if there is a match; false otherwise. */
|
||||
bool
|
||||
atf_utils_grep_string(const char *regex, const char *str, ...)
|
||||
{
|
||||
bool res;
|
||||
va_list ap;
|
||||
atf_dynstr_t formatted;
|
||||
atf_error_t error;
|
||||
|
||||
va_start(ap, str);
|
||||
error = atf_dynstr_init_ap(&formatted, regex, ap);
|
||||
va_end(ap);
|
||||
ATF_REQUIRE(!atf_is_error(error));
|
||||
|
||||
res = grep_string(atf_dynstr_cstring(&formatted), str);
|
||||
|
||||
atf_dynstr_fini(&formatted);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/** Reads a line of arbitrary length.
|
||||
*
|
||||
* \param fd The descriptor from which to read the line.
|
||||
*
|
||||
* \return A pointer to the read line, which must be released with free(), or
|
||||
* NULL if there was nothing to read from the file. */
|
||||
char *
|
||||
atf_utils_readline(const int fd)
|
||||
{
|
||||
char ch;
|
||||
ssize_t cnt;
|
||||
atf_dynstr_t temp;
|
||||
atf_error_t error;
|
||||
|
||||
error = atf_dynstr_init(&temp);
|
||||
ATF_REQUIRE(!atf_is_error(error));
|
||||
|
||||
while ((cnt = read(fd, &ch, sizeof(ch))) == sizeof(ch) &&
|
||||
ch != '\n') {
|
||||
error = atf_dynstr_append_fmt(&temp, "%c", ch);
|
||||
ATF_REQUIRE(!atf_is_error(error));
|
||||
}
|
||||
ATF_REQUIRE(cnt != -1);
|
||||
|
||||
if (cnt == 0 && atf_dynstr_length(&temp) == 0) {
|
||||
atf_dynstr_fini(&temp);
|
||||
return NULL;
|
||||
} else
|
||||
return atf_dynstr_fini_disown(&temp);
|
||||
}
|
||||
|
||||
/** Redirects a file descriptor to a file.
|
||||
*
|
||||
* \param target_fd The file descriptor to be replaced.
|
||||
* \param name The name of the file to direct the descriptor to.
|
||||
*
|
||||
* \pre Should only be called from the process spawned by fork_for_testing
|
||||
* because this exits uncontrolledly.
|
||||
* \post Terminates execution if the redirection fails. */
|
||||
void
|
||||
atf_utils_redirect(const int target_fd, const char *name)
|
||||
{
|
||||
if (target_fd == STDOUT_FILENO)
|
||||
fflush(stdout);
|
||||
else if (target_fd == STDERR_FILENO)
|
||||
fflush(stderr);
|
||||
|
||||
const int new_fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||
if (new_fd == -1)
|
||||
err(EXIT_FAILURE, "Cannot create %s", name);
|
||||
if (new_fd != target_fd) {
|
||||
if (dup2(new_fd, target_fd) == -1)
|
||||
err(EXIT_FAILURE, "Cannot redirect to fd %d", target_fd);
|
||||
}
|
||||
close(new_fd);
|
||||
}
|
||||
|
||||
/** Waits for a subprocess and validates its exit condition.
|
||||
*
|
||||
* \param pid The process to be waited for. Must have been started by
|
||||
* testutils_fork().
|
||||
* \param exitstatus Expected exit status.
|
||||
* \param expout Expected contents of stdout.
|
||||
* \param experr Expected contents of stderr. */
|
||||
void
|
||||
atf_utils_wait(const pid_t pid, const int exitstatus, const char *expout,
|
||||
const char *experr)
|
||||
{
|
||||
int status;
|
||||
ATF_REQUIRE(waitpid(pid, &status, 0) != -1);
|
||||
|
||||
atf_utils_cat_file("atf_utils_fork_out.txt", "subprocess stdout: ");
|
||||
atf_utils_cat_file("atf_utils_fork_err.txt", "subprocess stderr: ");
|
||||
|
||||
ATF_REQUIRE(WIFEXITED(status));
|
||||
ATF_REQUIRE_EQ(exitstatus, WEXITSTATUS(status));
|
||||
|
||||
const char *save_prefix = "save:";
|
||||
const size_t save_prefix_length = strlen(save_prefix);
|
||||
|
||||
if (strlen(expout) > save_prefix_length &&
|
||||
strncmp(expout, save_prefix, save_prefix_length) == 0) {
|
||||
atf_utils_copy_file("atf_utils_fork_out.txt",
|
||||
expout + save_prefix_length);
|
||||
} else {
|
||||
ATF_REQUIRE(atf_utils_compare_file("atf_utils_fork_out.txt", expout));
|
||||
}
|
||||
|
||||
if (strlen(experr) > save_prefix_length &&
|
||||
strncmp(experr, save_prefix, save_prefix_length) == 0) {
|
||||
atf_utils_copy_file("atf_utils_fork_err.txt",
|
||||
experr + save_prefix_length);
|
||||
} else {
|
||||
ATF_REQUIRE(atf_utils_compare_file("atf_utils_fork_err.txt", experr));
|
||||
}
|
||||
|
||||
ATF_REQUIRE(unlink("atf_utils_fork_out.txt") != -1);
|
||||
ATF_REQUIRE(unlink("atf_utils_fork_err.txt") != -1);
|
||||
}
|
||||
|
@ -30,6 +30,25 @@
|
||||
#if !defined(ATF_C_UTILS_H)
|
||||
#define ATF_C_UTILS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <atf-c/defs.h>
|
||||
|
||||
void atf_utils_cat_file(const char *, const char *);
|
||||
bool atf_utils_compare_file(const char *, const char *);
|
||||
void atf_utils_copy_file(const char *, const char *);
|
||||
void atf_utils_create_file(const char *, const char *, ...)
|
||||
ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(2, 3);
|
||||
bool atf_utils_file_exists(const char *);
|
||||
pid_t atf_utils_fork(void);
|
||||
void atf_utils_free_charpp(char **);
|
||||
bool atf_utils_grep_file(const char *, const char *, ...)
|
||||
ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 3);
|
||||
bool atf_utils_grep_string(const char *, const char *, ...)
|
||||
ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(1, 3);
|
||||
char *atf_utils_readline(int);
|
||||
void atf_utils_redirect(const int, const char *);
|
||||
void atf_utils_wait(const pid_t, const int, const char *, const char *);
|
||||
|
||||
#endif /* ATF_C_UTILS_H */
|
||||
|
@ -27,8 +27,15 @@
|
||||
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <atf-c.h>
|
||||
|
||||
@ -36,8 +43,218 @@
|
||||
|
||||
#include "detail/test_helpers.h"
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(free_charpp_empty);
|
||||
ATF_TC_BODY(free_charpp_empty, tc)
|
||||
/** Reads the contents of a file into a buffer.
|
||||
*
|
||||
* Up to buflen-1 characters are read into buffer. If this function returns,
|
||||
* the contents read into the buffer are guaranteed to be nul-terminated.
|
||||
* Note, however, that if the file contains any nul characters itself,
|
||||
* comparing it "as a string" will not work.
|
||||
*
|
||||
* \param path The file to be read, which must exist.
|
||||
* \param buffer Buffer into which to store the file contents.
|
||||
* \param buflen Size of the target buffer.
|
||||
*
|
||||
* \return The count of bytes read. */
|
||||
static ssize_t
|
||||
read_file(const char *path, void *const buffer, const size_t buflen)
|
||||
{
|
||||
const int fd = open(path, O_RDONLY);
|
||||
ATF_REQUIRE_MSG(fd != -1, "Cannot open %s", path);
|
||||
const ssize_t length = read(fd, buffer, buflen - 1);
|
||||
close(fd);
|
||||
ATF_REQUIRE(length != -1);
|
||||
((char *)buffer)[length] = '\0';
|
||||
return length;
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(cat_file__empty);
|
||||
ATF_TC_BODY(cat_file__empty, tc)
|
||||
{
|
||||
atf_utils_create_file("file.txt", "%s", "");
|
||||
atf_utils_redirect(STDOUT_FILENO, "captured.txt");
|
||||
atf_utils_cat_file("file.txt", "PREFIX");
|
||||
fflush(stdout);
|
||||
close(STDOUT_FILENO);
|
||||
|
||||
char buffer[1024];
|
||||
read_file("captured.txt", buffer, sizeof(buffer));
|
||||
ATF_REQUIRE_STREQ("", buffer);
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(cat_file__one_line);
|
||||
ATF_TC_BODY(cat_file__one_line, tc)
|
||||
{
|
||||
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");
|
||||
fflush(stdout);
|
||||
close(STDOUT_FILENO);
|
||||
|
||||
char buffer[1024];
|
||||
read_file("captured.txt", buffer, sizeof(buffer));
|
||||
ATF_REQUIRE_STREQ("PREFIXThis is a single line\n", buffer);
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(cat_file__several_lines);
|
||||
ATF_TC_BODY(cat_file__several_lines, tc)
|
||||
{
|
||||
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", ">");
|
||||
fflush(stdout);
|
||||
close(STDOUT_FILENO);
|
||||
|
||||
char buffer[1024];
|
||||
read_file("captured.txt", buffer, sizeof(buffer));
|
||||
ATF_REQUIRE_STREQ(">First\n>Second line\n>And third\n", buffer);
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(cat_file__no_newline_eof);
|
||||
ATF_TC_BODY(cat_file__no_newline_eof, tc)
|
||||
{
|
||||
atf_utils_create_file("file.txt", "Foo\n bar baz");
|
||||
atf_utils_redirect(STDOUT_FILENO, "captured.txt");
|
||||
atf_utils_cat_file("file.txt", "PREFIX");
|
||||
fflush(stdout);
|
||||
close(STDOUT_FILENO);
|
||||
|
||||
char buffer[1024];
|
||||
read_file("captured.txt", buffer, sizeof(buffer));
|
||||
ATF_REQUIRE_STREQ("PREFIXFoo\nPREFIX bar baz", buffer);
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(compare_file__empty__match);
|
||||
ATF_TC_BODY(compare_file__empty__match, tc)
|
||||
{
|
||||
atf_utils_create_file("test.txt", "%s", "");
|
||||
ATF_REQUIRE(atf_utils_compare_file("test.txt", ""));
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(compare_file__empty__not_match);
|
||||
ATF_TC_BODY(compare_file__empty__not_match, tc)
|
||||
{
|
||||
atf_utils_create_file("test.txt", "%s", "");
|
||||
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_TC_WITHOUT_HEAD(compare_file__short__match);
|
||||
ATF_TC_BODY(compare_file__short__match, tc)
|
||||
{
|
||||
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_TC_WITHOUT_HEAD(compare_file__short__not_match);
|
||||
ATF_TC_BODY(compare_file__short__not_match, tc)
|
||||
{
|
||||
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_TC_WITHOUT_HEAD(compare_file__long__match);
|
||||
ATF_TC_BODY(compare_file__long__match, tc)
|
||||
{
|
||||
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", "%s", long_contents);
|
||||
|
||||
ATF_REQUIRE(atf_utils_compare_file("test.txt", long_contents));
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(compare_file__long__not_match);
|
||||
ATF_TC_BODY(compare_file__long__not_match, tc)
|
||||
{
|
||||
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", "%s", 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_TC_WITHOUT_HEAD(copy_file__empty);
|
||||
ATF_TC_BODY(copy_file__empty, tc)
|
||||
{
|
||||
atf_utils_create_file("src.txt", "%s", "");
|
||||
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_TC_WITHOUT_HEAD(copy_file__some_contents);
|
||||
ATF_TC_BODY(copy_file__some_contents, tc)
|
||||
{
|
||||
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_TC_WITHOUT_HEAD(create_file);
|
||||
ATF_TC_BODY(create_file, tc)
|
||||
{
|
||||
atf_utils_create_file("test.txt", "This is a test with %d", 12345);
|
||||
|
||||
char buffer[128];
|
||||
read_file("test.txt", buffer, sizeof(buffer));
|
||||
ATF_REQUIRE_STREQ("This is a test with 12345", buffer);
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(file_exists);
|
||||
ATF_TC_BODY(file_exists, tc)
|
||||
{
|
||||
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_TC_WITHOUT_HEAD(fork);
|
||||
ATF_TC_BODY(fork, tc)
|
||||
{
|
||||
fprintf(stdout, "Should not get into child\n");
|
||||
fprintf(stderr, "Should not get into child\n");
|
||||
pid_t pid = atf_utils_fork();
|
||||
if (pid == 0) {
|
||||
fprintf(stdout, "Child stdout\n");
|
||||
fprintf(stderr, "Child stderr\n");
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
int status;
|
||||
ATF_REQUIRE(waitpid(pid, &status, 0) != -1);
|
||||
ATF_REQUIRE(WIFEXITED(status));
|
||||
ATF_REQUIRE_EQ(EXIT_SUCCESS, WEXITSTATUS(status));
|
||||
|
||||
char buffer[1024];
|
||||
read_file("atf_utils_fork_out.txt", buffer, sizeof(buffer));
|
||||
ATF_REQUIRE_STREQ("Child stdout\n", buffer);
|
||||
read_file("atf_utils_fork_err.txt", buffer, sizeof(buffer));
|
||||
ATF_REQUIRE_STREQ("Child stderr\n", buffer);
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(free_charpp__empty);
|
||||
ATF_TC_BODY(free_charpp__empty, tc)
|
||||
{
|
||||
char **array = malloc(sizeof(char *) * 1);
|
||||
array[0] = NULL;
|
||||
@ -45,8 +262,8 @@ ATF_TC_BODY(free_charpp_empty, tc)
|
||||
atf_utils_free_charpp(array);
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(free_charpp_some);
|
||||
ATF_TC_BODY(free_charpp_some, tc)
|
||||
ATF_TC_WITHOUT_HEAD(free_charpp__some);
|
||||
ATF_TC_BODY(free_charpp__some, tc)
|
||||
{
|
||||
char **array = malloc(sizeof(char *) * 4);
|
||||
array[0] = strdup("first");
|
||||
@ -57,12 +274,263 @@ ATF_TC_BODY(free_charpp_some, tc)
|
||||
atf_utils_free_charpp(array);
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(grep_file);
|
||||
ATF_TC_BODY(grep_file, tc)
|
||||
{
|
||||
atf_utils_create_file("test.txt", "line1\nthe second line\naaaabbbb\n");
|
||||
|
||||
ATF_CHECK(atf_utils_grep_file("line1", "test.txt"));
|
||||
ATF_CHECK(atf_utils_grep_file("line%d", "test.txt", 1));
|
||||
ATF_CHECK(atf_utils_grep_file("second line", "test.txt"));
|
||||
ATF_CHECK(atf_utils_grep_file("aa.*bb", "test.txt"));
|
||||
ATF_CHECK(!atf_utils_grep_file("foo", "test.txt"));
|
||||
ATF_CHECK(!atf_utils_grep_file("bar", "test.txt"));
|
||||
ATF_CHECK(!atf_utils_grep_file("aaaaa", "test.txt"));
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(grep_string);
|
||||
ATF_TC_BODY(grep_string, tc)
|
||||
{
|
||||
const char *str = "a string - aaaabbbb";
|
||||
ATF_CHECK(atf_utils_grep_string("a string", str));
|
||||
ATF_CHECK(atf_utils_grep_string("^a string", str));
|
||||
ATF_CHECK(atf_utils_grep_string("aaaabbbb$", str));
|
||||
ATF_CHECK(atf_utils_grep_string("a%s*bb", str, "a."));
|
||||
ATF_CHECK(!atf_utils_grep_string("foo", str));
|
||||
ATF_CHECK(!atf_utils_grep_string("bar", str));
|
||||
ATF_CHECK(!atf_utils_grep_string("aaaaa", str));
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(readline__none);
|
||||
ATF_TC_BODY(readline__none, tc)
|
||||
{
|
||||
atf_utils_create_file("empty.txt", "%s", "");
|
||||
|
||||
const int fd = open("empty.txt", O_RDONLY);
|
||||
ATF_REQUIRE(fd != -1);
|
||||
ATF_REQUIRE(atf_utils_readline(fd) == NULL);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(readline__some);
|
||||
ATF_TC_BODY(readline__some, tc)
|
||||
{
|
||||
const char *l1 = "First line with % formatting % characters %";
|
||||
const char *l2 = "Second line; much longer than the first one";
|
||||
const char *l3 = "Last line, without terminator";
|
||||
|
||||
atf_utils_create_file("test.txt", "%s\n%s\n%s", l1, l2, l3);
|
||||
|
||||
const int fd = open("test.txt", O_RDONLY);
|
||||
ATF_REQUIRE(fd != -1);
|
||||
|
||||
char *line;
|
||||
|
||||
line = atf_utils_readline(fd);
|
||||
ATF_REQUIRE_STREQ(l1, line);
|
||||
free(line);
|
||||
|
||||
line = atf_utils_readline(fd);
|
||||
ATF_REQUIRE_STREQ(l2, line);
|
||||
free(line);
|
||||
|
||||
line = atf_utils_readline(fd);
|
||||
ATF_REQUIRE_STREQ(l3, line);
|
||||
free(line);
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(redirect__stdout);
|
||||
ATF_TC_BODY(redirect__stdout, tc)
|
||||
{
|
||||
printf("Buffer this");
|
||||
atf_utils_redirect(STDOUT_FILENO, "captured.txt");
|
||||
printf("The printed message");
|
||||
fflush(stdout);
|
||||
|
||||
char buffer[1024];
|
||||
read_file("captured.txt", buffer, sizeof(buffer));
|
||||
ATF_REQUIRE_STREQ("The printed message", buffer);
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(redirect__stderr);
|
||||
ATF_TC_BODY(redirect__stderr, tc)
|
||||
{
|
||||
fprintf(stderr, "Buffer this");
|
||||
atf_utils_redirect(STDERR_FILENO, "captured.txt");
|
||||
fprintf(stderr, "The printed message");
|
||||
fflush(stderr);
|
||||
|
||||
char buffer[1024];
|
||||
read_file("captured.txt", buffer, sizeof(buffer));
|
||||
ATF_REQUIRE_STREQ("The printed message", buffer);
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(redirect__other);
|
||||
ATF_TC_BODY(redirect__other, tc)
|
||||
{
|
||||
const char *message = "Foo bar\nbaz\n";
|
||||
atf_utils_redirect(15, "captured.txt");
|
||||
ATF_REQUIRE(write(15, message, strlen(message)) != -1);
|
||||
close(15);
|
||||
|
||||
char buffer[1024];
|
||||
read_file("captured.txt", buffer, sizeof(buffer));
|
||||
ATF_REQUIRE_STREQ(message, buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
fork_and_wait(const int exitstatus, const char* expout, const char* experr)
|
||||
{
|
||||
const pid_t pid = atf_utils_fork();
|
||||
if (pid == 0) {
|
||||
fprintf(stdout, "Some output\n");
|
||||
fprintf(stderr, "Some error\n");
|
||||
exit(123);
|
||||
}
|
||||
atf_utils_wait(pid, exitstatus, expout, experr);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(wait__ok);
|
||||
ATF_TC_BODY(wait__ok, tc)
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(wait__invalid_exitstatus);
|
||||
ATF_TC_BODY(wait__invalid_exitstatus, tc)
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(wait__invalid_stdout);
|
||||
ATF_TC_BODY(wait__invalid_stdout, tc)
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(wait__invalid_stderr);
|
||||
ATF_TC_BODY(wait__invalid_stderr, tc)
|
||||
{
|
||||
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_TC_WITHOUT_HEAD(wait__save_stdout);
|
||||
ATF_TC_BODY(wait__save_stdout, tc)
|
||||
{
|
||||
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(atf_utils_compare_file("my-output.txt", "Some output\n"));
|
||||
}
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(wait__save_stderr);
|
||||
ATF_TC_BODY(wait__save_stderr, tc)
|
||||
{
|
||||
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(atf_utils_compare_file("my-output.txt", "Some error\n"));
|
||||
}
|
||||
}
|
||||
|
||||
HEADER_TC(include, "atf-c/utils.h");
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
ATF_TP_ADD_TC(tp, free_charpp_empty);
|
||||
ATF_TP_ADD_TC(tp, free_charpp_some);
|
||||
ATF_TP_ADD_TC(tp, cat_file__empty);
|
||||
ATF_TP_ADD_TC(tp, cat_file__one_line);
|
||||
ATF_TP_ADD_TC(tp, cat_file__several_lines);
|
||||
ATF_TP_ADD_TC(tp, cat_file__no_newline_eof);
|
||||
|
||||
ATF_TP_ADD_TC(tp, compare_file__empty__match);
|
||||
ATF_TP_ADD_TC(tp, compare_file__empty__not_match);
|
||||
ATF_TP_ADD_TC(tp, compare_file__short__match);
|
||||
ATF_TP_ADD_TC(tp, compare_file__short__not_match);
|
||||
ATF_TP_ADD_TC(tp, compare_file__long__match);
|
||||
ATF_TP_ADD_TC(tp, compare_file__long__not_match);
|
||||
|
||||
ATF_TP_ADD_TC(tp, copy_file__empty);
|
||||
ATF_TP_ADD_TC(tp, copy_file__some_contents);
|
||||
|
||||
ATF_TP_ADD_TC(tp, create_file);
|
||||
|
||||
ATF_TP_ADD_TC(tp, file_exists);
|
||||
|
||||
ATF_TP_ADD_TC(tp, fork);
|
||||
|
||||
ATF_TP_ADD_TC(tp, free_charpp__empty);
|
||||
ATF_TP_ADD_TC(tp, free_charpp__some);
|
||||
|
||||
ATF_TP_ADD_TC(tp, grep_file);
|
||||
ATF_TP_ADD_TC(tp, grep_string);
|
||||
|
||||
ATF_TP_ADD_TC(tp, readline__none);
|
||||
ATF_TP_ADD_TC(tp, readline__some);
|
||||
|
||||
ATF_TP_ADD_TC(tp, redirect__stdout);
|
||||
ATF_TP_ADD_TC(tp, redirect__stderr);
|
||||
ATF_TP_ADD_TC(tp, redirect__other);
|
||||
|
||||
ATF_TP_ADD_TC(tp, wait__ok);
|
||||
ATF_TP_ADD_TC(tp, wait__save_stdout);
|
||||
ATF_TP_ADD_TC(tp, wait__save_stderr);
|
||||
ATF_TP_ADD_TC(tp, wait__invalid_exitstatus);
|
||||
ATF_TP_ADD_TC(tp, wait__invalid_stdout);
|
||||
ATF_TP_ADD_TC(tp, wait__invalid_stderr);
|
||||
|
||||
ATF_TP_ADD_TC(tp, include);
|
||||
|
||||
|
@ -1,48 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
bin_PROGRAMS += atf-config/atf-config
|
||||
atf_config_atf_config_SOURCES = atf-config/atf-config.cpp
|
||||
atf_config_atf_config_LDADD = $(ATF_CXX_LIBS)
|
||||
dist_man_MANS += atf-config/atf-config.1
|
||||
|
||||
tests_atf_config_DATA = atf-config/Atffile \
|
||||
atf-config/Kyuafile
|
||||
tests_atf_configdir = $(pkgtestsdir)/atf-config
|
||||
EXTRA_DIST += $(tests_atf_config_DATA)
|
||||
|
||||
tests_atf_config_SCRIPTS = atf-config/integration_test
|
||||
CLEANFILES += atf-config/integration_test
|
||||
EXTRA_DIST += atf-config/integration_test.sh
|
||||
atf-config/integration_test: $(srcdir)/atf-config/integration_test.sh
|
||||
test -d atf-config || mkdir -p atf-config
|
||||
@src="$(srcdir)/atf-config/integration_test.sh"; \
|
||||
dst="atf-config/integration_test"; $(BUILD_SH_TP)
|
||||
|
||||
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
|
@ -1,80 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
bin_PROGRAMS += atf-report/atf-report
|
||||
atf_report_atf_report_SOURCES = atf-report/atf-report.cpp \
|
||||
atf-report/reader.cpp \
|
||||
atf-report/reader.hpp
|
||||
atf_report_atf_report_LDADD = $(ATF_CXX_LIBS)
|
||||
dist_man_MANS += atf-report/atf-report.1
|
||||
|
||||
cssdir = $(atf_cssdir)
|
||||
css_DATA = atf-report/tests-results.css
|
||||
EXTRA_DIST += $(css_DATA)
|
||||
|
||||
dtddir = $(atf_dtddir)
|
||||
dtd_DATA = atf-report/tests-results.dtd
|
||||
EXTRA_DIST += $(dtd_DATA)
|
||||
|
||||
xsldir = $(atf_xsldir)
|
||||
xsl_DATA = atf-report/tests-results.xsl
|
||||
EXTRA_DIST += $(xsl_DATA)
|
||||
|
||||
tests_atf_report_DATA = atf-report/Atffile \
|
||||
atf-report/Kyuafile
|
||||
tests_atf_reportdir = $(pkgtestsdir)/atf-report
|
||||
EXTRA_DIST += $(tests_atf_report_DATA)
|
||||
|
||||
tests_atf_report_PROGRAMS = atf-report/fail_helper
|
||||
atf_report_fail_helper_SOURCES = atf-report/fail_helper.cpp
|
||||
atf_report_fail_helper_LDADD = $(ATF_CXX_LIBS)
|
||||
|
||||
tests_atf_report_PROGRAMS += atf-report/misc_helpers
|
||||
atf_report_misc_helpers_SOURCES = atf-report/misc_helpers.cpp
|
||||
atf_report_misc_helpers_LDADD = $(ATF_CXX_LIBS)
|
||||
|
||||
tests_atf_report_PROGRAMS += atf-report/pass_helper
|
||||
atf_report_pass_helper_SOURCES = atf-report/pass_helper.cpp
|
||||
atf_report_pass_helper_LDADD = $(ATF_CXX_LIBS)
|
||||
|
||||
tests_atf_report_SCRIPTS = atf-report/integration_test
|
||||
CLEANFILES += atf-report/integration_test
|
||||
EXTRA_DIST += atf-report/integration_test.sh
|
||||
atf-report/integration_test: $(srcdir)/atf-report/integration_test.sh
|
||||
test -d atf-report || mkdir -p atf-report
|
||||
@src="$(srcdir)/atf-report/integration_test.sh"; \
|
||||
dst="atf-report/integration_test"; $(BUILD_SH_TP)
|
||||
|
||||
tests_atf_report_PROGRAMS += atf-report/reader_test
|
||||
atf_report_reader_test_SOURCES = atf-report/reader_test.cpp \
|
||||
atf-report/reader.cpp
|
||||
atf_report_reader_test_CPPFLAGS = -I$(srcdir)/atf-c++/detail
|
||||
atf_report_reader_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
|
||||
|
||||
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
|
@ -31,6 +31,7 @@ extern "C" {
|
||||
#include <sys/time.h>
|
||||
}
|
||||
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
@ -394,17 +395,24 @@ class xml_writer : public writer {
|
||||
std::string
|
||||
elemval(const std::string& str)
|
||||
{
|
||||
std::string ostr;
|
||||
std::ostringstream buf;
|
||||
for (std::string::const_iterator iter = str.begin();
|
||||
iter != str.end(); iter++) {
|
||||
switch (*iter) {
|
||||
case '&': ostr += "&"; break;
|
||||
case '<': ostr += "<"; break;
|
||||
case '>': ostr += ">"; break;
|
||||
default: ostr += *iter;
|
||||
const int character = static_cast< unsigned char >(*iter);
|
||||
if (character == '&') {
|
||||
buf << "&";
|
||||
} else if (character == '<') {
|
||||
buf << "<";
|
||||
} else if (character == '>') {
|
||||
buf << ">";
|
||||
} else if (std::isalnum(character) || std::ispunct(character) ||
|
||||
std::isspace(character)) {
|
||||
buf << static_cast< char >(character);
|
||||
} else {
|
||||
buf << "&#" << character << ";";
|
||||
}
|
||||
}
|
||||
return ostr;
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1,150 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
bin_PROGRAMS += atf-run/atf-run
|
||||
atf_run_atf_run_CPPFLAGS = "-DGDB=\"$(GDB)\""
|
||||
atf_run_atf_run_SOURCES = atf-run/atf-run.cpp \
|
||||
atf-run/atffile.cpp \
|
||||
atf-run/atffile.hpp \
|
||||
atf-run/config.cpp \
|
||||
atf-run/config.hpp \
|
||||
atf-run/fs.cpp \
|
||||
atf-run/fs.hpp \
|
||||
atf-run/io.cpp \
|
||||
atf-run/io.hpp \
|
||||
atf-run/requirements.cpp \
|
||||
atf-run/requirements.hpp \
|
||||
atf-run/signals.cpp \
|
||||
atf-run/signals.hpp \
|
||||
atf-run/test-program.cpp \
|
||||
atf-run/test-program.hpp \
|
||||
atf-run/timer.cpp \
|
||||
atf-run/timer.hpp \
|
||||
atf-run/user.cpp \
|
||||
atf-run/user.hpp
|
||||
atf_run_atf_run_LDADD = $(ATF_CXX_LIBS)
|
||||
dist_man_MANS += atf-run/atf-run.1
|
||||
|
||||
tests_atf_run_DATA = atf-run/Atffile \
|
||||
atf-run/Kyuafile
|
||||
tests_atf_rundir = $(pkgtestsdir)/atf-run
|
||||
EXTRA_DIST += $(tests_atf_run_DATA)
|
||||
|
||||
tests_atf_run_PROGRAMS = atf-run/atffile_test
|
||||
atf_run_atffile_test_SOURCES = atf-run/atffile_test.cpp \
|
||||
atf-run/atffile.cpp
|
||||
atf_run_atffile_test_CPPFLAGS = -I$(srcdir)/atf-c++/detail
|
||||
atf_run_atffile_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
|
||||
|
||||
tests_atf_run_PROGRAMS += atf-run/bad_metadata_helper
|
||||
atf_run_bad_metadata_helper_SOURCES = atf-run/bad_metadata_helper.c
|
||||
atf_run_bad_metadata_helper_LDADD = libatf-c.la
|
||||
|
||||
tests_atf_run_PROGRAMS += atf-run/config_test
|
||||
atf_run_config_test_SOURCES = atf-run/config_test.cpp \
|
||||
atf-run/config.cpp
|
||||
atf_run_config_test_CPPFLAGS = -I$(srcdir)/atf-c++/detail
|
||||
atf_run_config_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
|
||||
|
||||
tests_atf_run_PROGRAMS += atf-run/expect_helpers
|
||||
atf_run_expect_helpers_SOURCES = atf-run/expect_helpers.c
|
||||
atf_run_expect_helpers_LDADD = libatf-c.la
|
||||
|
||||
tests_atf_run_PROGRAMS += atf-run/fs_test
|
||||
atf_run_fs_test_SOURCES = atf-run/fs_test.cpp \
|
||||
atf-run/fs.cpp \
|
||||
atf-run/user.cpp
|
||||
atf_run_fs_test_LDADD = $(ATF_CXX_LIBS)
|
||||
|
||||
tests_atf_run_PROGRAMS += atf-run/io_test
|
||||
atf_run_io_test_SOURCES = atf-run/io_test.cpp \
|
||||
atf-run/io.cpp \
|
||||
atf-run/signals.cpp
|
||||
atf_run_io_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
|
||||
|
||||
tests_atf_run_PROGRAMS += atf-run/misc_helpers
|
||||
atf_run_misc_helpers_SOURCES = atf-run/misc_helpers.cpp
|
||||
atf_run_misc_helpers_LDADD = $(ATF_CXX_LIBS)
|
||||
|
||||
tests_atf_run_PROGRAMS += atf-run/pass_helper
|
||||
atf_run_pass_helper_SOURCES = atf-run/pass_helper.cpp
|
||||
atf_run_pass_helper_LDADD = $(ATF_CXX_LIBS)
|
||||
|
||||
tests_atf_run_PROGRAMS += atf-run/several_tcs_helper
|
||||
atf_run_several_tcs_helper_SOURCES = atf-run/several_tcs_helper.c
|
||||
atf_run_several_tcs_helper_LDADD = libatf-c.la
|
||||
|
||||
tests_atf_run_PROGRAMS += atf-run/requirements_test
|
||||
atf_run_requirements_test_SOURCES = atf-run/requirements_test.cpp \
|
||||
atf-run/requirements.cpp \
|
||||
atf-run/user.cpp
|
||||
atf_run_requirements_test_LDADD = $(ATF_CXX_LIBS)
|
||||
|
||||
tests_atf_run_PROGRAMS += atf-run/signals_test
|
||||
atf_run_signals_test_SOURCES = atf-run/signals_test.cpp atf-run/signals.cpp
|
||||
atf_run_signals_test_LDADD = $(ATF_CXX_LIBS)
|
||||
|
||||
tests_atf_run_PROGRAMS += atf-run/test_program_test
|
||||
atf_run_test_program_test_SOURCES = atf-run/test_program_test.cpp \
|
||||
atf-run/fs.cpp \
|
||||
atf-run/io.cpp \
|
||||
atf-run/requirements.cpp \
|
||||
atf-run/signals.cpp \
|
||||
atf-run/test-program.cpp \
|
||||
atf-run/timer.cpp \
|
||||
atf-run/user.cpp
|
||||
atf_run_test_program_test_CPPFLAGS = -I$(srcdir)/atf-c++/detail
|
||||
atf_run_test_program_test_LDADD = atf-c++/detail/libtest_helpers.la $(ATF_CXX_LIBS)
|
||||
|
||||
tests_atf_run_PROGRAMS += atf-run/user_test
|
||||
atf_run_user_test_SOURCES = atf-run/user_test.cpp atf-run/user.cpp
|
||||
atf_run_user_test_LDADD = $(ATF_CXX_LIBS)
|
||||
|
||||
tests_atf_run_PROGRAMS += atf-run/zero_tcs_helper
|
||||
atf_run_zero_tcs_helper_SOURCES = atf-run/zero_tcs_helper.c
|
||||
atf_run_zero_tcs_helper_LDADD = libatf-c.la
|
||||
|
||||
tests_atf_run_SCRIPTS = atf-run/integration_test
|
||||
CLEANFILES += atf-run/integration_test
|
||||
EXTRA_DIST += atf-run/integration_test.sh
|
||||
atf-run/integration_test: $(srcdir)/atf-run/integration_test.sh
|
||||
test -d atf-run || mkdir -p atf-run
|
||||
@src="$(srcdir)/atf-run/integration_test.sh"; \
|
||||
dst="atf-run/integration_test"; $(BUILD_SH_TP)
|
||||
|
||||
hooksdir = $(pkgdatadir)
|
||||
hooks_DATA = atf-run/share/atf-run.hooks
|
||||
EXTRA_DIST += $(hooks_DATA)
|
||||
|
||||
egdir = $(atf_egdir)
|
||||
eg_DATA = atf-run/sample/atf-run.hooks
|
||||
eg_DATA += atf-run/sample/common.conf
|
||||
EXTRA_DIST += $(eg_DATA)
|
||||
|
||||
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
|
@ -44,6 +44,7 @@ extern "C" {
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "atf-c++/detail/auto_array.hpp"
|
||||
#include "atf-c++/detail/process.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
|
||||
@ -200,7 +201,7 @@ retry_unmount:
|
||||
|
||||
impl::temp_dir::temp_dir(const atf::fs::path& p)
|
||||
{
|
||||
atf::utils::auto_array< char > buf(new char[p.str().length() + 1]);
|
||||
atf::auto_array< char > buf(new char[p.str().length() + 1]);
|
||||
std::strcpy(buf.get(), p.c_str());
|
||||
if (::mkdtemp(buf.get()) == NULL)
|
||||
throw system_error(IMPL_NAME "::temp_dir::temp_dir(" +
|
||||
|
@ -41,9 +41,9 @@ extern "C" {
|
||||
#include "../atf-c/error.h"
|
||||
}
|
||||
|
||||
#include "../atf-c++/detail/auto_array.hpp"
|
||||
#include "../atf-c++/detail/exceptions.hpp"
|
||||
#include "../atf-c++/detail/sanity.hpp"
|
||||
#include "../atf-c++/utils.hpp"
|
||||
|
||||
#include "io.hpp"
|
||||
|
||||
@ -290,7 +290,7 @@ size_t
|
||||
impl::muxer::read_one(const size_t index, const int fd, std::string& accum,
|
||||
const bool report_errors)
|
||||
{
|
||||
atf::utils::auto_array< char > buffer(new char[m_bufsize]);
|
||||
atf::auto_array< char > buffer(new char[m_bufsize]);
|
||||
const size_t nbytes = safe_read(fd, buffer.get(), m_bufsize - 1,
|
||||
report_errors);
|
||||
INV(nbytes < m_bufsize);
|
||||
@ -319,7 +319,7 @@ impl::muxer::read_one(const size_t index, const int fd, std::string& accum,
|
||||
void
|
||||
impl::muxer::mux(volatile const bool& terminate)
|
||||
{
|
||||
atf::utils::auto_array< struct pollfd > poll_fds(new struct pollfd[m_nfds]);
|
||||
atf::auto_array< struct pollfd > poll_fds(new struct pollfd[m_nfds]);
|
||||
for (size_t i = 0; i < m_nfds; i++) {
|
||||
poll_fds[i].fd = m_fds[i];
|
||||
poll_fds[i].events = POLLIN;
|
||||
|
@ -36,7 +36,8 @@
|
||||
|
||||
#include "fs.hpp"
|
||||
|
||||
#include "../atf-c++/utils.hpp"
|
||||
#include "../atf-c++/detail/auto_array.hpp"
|
||||
#include "../atf-c++/noncopyable.hpp"
|
||||
|
||||
namespace atf {
|
||||
namespace atf_run {
|
||||
@ -253,8 +254,7 @@ private:
|
||||
//! However, it is not copyable to avoid introducing inconsistences with
|
||||
//! the on-disk file and the in-memory buffers.
|
||||
//!
|
||||
class systembuf :
|
||||
public std::streambuf, atf::utils::noncopyable
|
||||
class systembuf : public std::streambuf, atf::noncopyable
|
||||
{
|
||||
public:
|
||||
typedef int handle_type;
|
||||
@ -374,8 +374,7 @@ protected:
|
||||
//! this happens, the buffer eventually empties and the system blocks
|
||||
//! until the writer generates some data.
|
||||
//!
|
||||
class pistream :
|
||||
public std::istream, utils::noncopyable
|
||||
class pistream : public std::istream, noncopyable
|
||||
{
|
||||
//!
|
||||
//! \brief The systembuf object used to manage this stream's data.
|
||||
@ -401,12 +400,12 @@ public:
|
||||
// The "muxer" class.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
class muxer : utils::noncopyable {
|
||||
class muxer : noncopyable {
|
||||
const int* m_fds;
|
||||
const size_t m_nfds;
|
||||
|
||||
const size_t m_bufsize;
|
||||
atf::utils::auto_array< std::string > m_buffers;
|
||||
atf::auto_array< std::string > m_buffers;
|
||||
|
||||
protected:
|
||||
virtual void line_callback(const size_t, const std::string&) = 0;
|
||||
|
@ -148,7 +148,7 @@ check_machine(const std::string& machines)
|
||||
return "Requires one of the '" + machines + "' machine types";
|
||||
}
|
||||
|
||||
#if defined(__APPLE__) || defined(__NetBSD__)
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
static
|
||||
std::string
|
||||
check_memory_sysctl(const int64_t needed, const char* sysctl_variable)
|
||||
@ -174,6 +174,13 @@ check_memory_darwin(const int64_t needed)
|
||||
{
|
||||
return check_memory_sysctl(needed, "hw.usermem");
|
||||
}
|
||||
# elif defined(__FreeBSD__)
|
||||
static
|
||||
std::string
|
||||
check_memory_freebsd(const int64_t needed)
|
||||
{
|
||||
return check_memory_sysctl(needed, "hw.usermem");
|
||||
}
|
||||
# elif defined(__NetBSD__)
|
||||
static
|
||||
std::string
|
||||
@ -201,6 +208,8 @@ check_memory(const std::string& raw_memory)
|
||||
|
||||
#if defined(__APPLE__)
|
||||
return check_memory_darwin(needed);
|
||||
#elif defined(__FreeBSD__)
|
||||
return check_memory_freebsd(needed);
|
||||
#elif defined(__NetBSD__)
|
||||
return check_memory_netbsd(needed);
|
||||
#else
|
||||
|
@ -36,7 +36,7 @@ extern "C" {
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "atf-c++/utils.hpp"
|
||||
#include "atf-c++/noncopyable.hpp"
|
||||
|
||||
namespace atf {
|
||||
namespace atf_run {
|
||||
@ -47,7 +47,7 @@ class signal_programmer;
|
||||
// The "timer" class.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
class timer : utils::noncopyable {
|
||||
class timer : noncopyable {
|
||||
struct impl;
|
||||
std::auto_ptr< impl > m_pimpl;
|
||||
|
||||
|
@ -1,129 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
libexec_PROGRAMS += atf-sh/atf-check
|
||||
atf_sh_atf_check_SOURCES = atf-sh/atf-check.cpp
|
||||
atf_sh_atf_check_LDADD = $(ATF_CXX_LIBS)
|
||||
dist_man_MANS += atf-sh/atf-check.1
|
||||
|
||||
bin_PROGRAMS += atf-sh/atf-sh
|
||||
atf_sh_atf_sh_SOURCES = atf-sh/atf-sh.cpp
|
||||
atf_sh_atf_sh_LDADD = $(ATF_CXX_LIBS)
|
||||
dist_man_MANS += atf-sh/atf-sh.1
|
||||
|
||||
atf_sh_DATA = atf-sh/libatf-sh.subr
|
||||
atf_shdir = $(pkgdatadir)
|
||||
EXTRA_DIST += $(atf_sh_DATA)
|
||||
|
||||
dist_man_MANS += atf-sh/atf-sh-api.3
|
||||
|
||||
atf_aclocal_DATA += atf-sh/atf-sh.m4
|
||||
EXTRA_DIST += atf-sh/atf-sh.m4
|
||||
|
||||
atf_shpkgconfigdir = $(atf_pkgconfigdir)
|
||||
atf_shpkgconfig_DATA = atf-sh/atf-sh.pc
|
||||
CLEANFILES += atf-sh/atf-sh.pc
|
||||
EXTRA_DIST += atf-sh/atf-sh.pc.in
|
||||
atf-sh/atf-sh.pc: $(srcdir)/atf-sh/atf-sh.pc.in Makefile
|
||||
test -d atf-sh || mkdir -p atf-sh
|
||||
sed -e 's#__ATF_VERSION__#$(PACKAGE_VERSION)#g' \
|
||||
-e 's#__EXEC_PREFIX__#$(exec_prefix)#g' \
|
||||
<$(srcdir)/atf-sh/atf-sh.pc.in >atf-sh/atf-sh.pc.tmp
|
||||
mv atf-sh/atf-sh.pc.tmp atf-sh/atf-sh.pc
|
||||
|
||||
tests_atf_sh_DATA = atf-sh/Atffile \
|
||||
atf-sh/Kyuafile
|
||||
tests_atf_shdir = $(pkgtestsdir)/atf-sh
|
||||
EXTRA_DIST += $(tests_atf_sh_DATA)
|
||||
|
||||
tests_atf_sh_SCRIPTS = atf-sh/misc_helpers
|
||||
CLEANFILES += atf-sh/misc_helpers
|
||||
EXTRA_DIST += atf-sh/misc_helpers.sh
|
||||
atf-sh/misc_helpers: $(srcdir)/atf-sh/misc_helpers.sh
|
||||
test -d atf-sh || mkdir -p atf-sh
|
||||
@src="$(srcdir)/atf-sh/misc_helpers.sh"; \
|
||||
dst="atf-sh/misc_helpers"; $(BUILD_SH_TP)
|
||||
|
||||
tests_atf_sh_SCRIPTS += atf-sh/atf_check_test
|
||||
CLEANFILES += atf-sh/atf_check_test
|
||||
EXTRA_DIST += atf-sh/atf_check_test.sh
|
||||
atf-sh/atf_check_test: $(srcdir)/atf-sh/atf_check_test.sh
|
||||
test -d atf-sh || mkdir -p atf-sh
|
||||
@src="$(srcdir)/atf-sh/atf_check_test.sh"; \
|
||||
dst="atf-sh/atf_check_test"; $(BUILD_SH_TP)
|
||||
|
||||
tests_atf_sh_SCRIPTS += atf-sh/atf-check_test
|
||||
CLEANFILES += atf-sh/atf-check_test
|
||||
EXTRA_DIST += atf-sh/atf-check_test.sh
|
||||
atf-sh/atf-check_test: $(srcdir)/atf-sh/atf-check_test.sh
|
||||
test -d atf-sh || mkdir -p atf-sh
|
||||
@src="$(srcdir)/atf-sh/atf-check_test.sh"; \
|
||||
dst="atf-sh/atf-check_test"; $(BUILD_SH_TP)
|
||||
|
||||
tests_atf_sh_SCRIPTS += atf-sh/config_test
|
||||
CLEANFILES += atf-sh/config_test
|
||||
EXTRA_DIST += atf-sh/config_test.sh
|
||||
atf-sh/config_test: $(srcdir)/atf-sh/config_test.sh
|
||||
test -d atf-sh || mkdir -p atf-sh
|
||||
@src="$(srcdir)/atf-sh/config_test.sh"; \
|
||||
dst="atf-sh/config_test"; $(BUILD_SH_TP)
|
||||
|
||||
tests_atf_sh_SCRIPTS += atf-sh/integration_test
|
||||
CLEANFILES += atf-sh/integration_test
|
||||
EXTRA_DIST += atf-sh/integration_test.sh
|
||||
atf-sh/integration_test: $(srcdir)/atf-sh/integration_test.sh
|
||||
test -d atf-sh || mkdir -p atf-sh
|
||||
@src="$(srcdir)/atf-sh/integration_test.sh"; \
|
||||
dst="atf-sh/integration_test"; $(BUILD_SH_TP)
|
||||
|
||||
tests_atf_sh_SCRIPTS += atf-sh/normalize_test
|
||||
CLEANFILES += atf-sh/normalize_test
|
||||
EXTRA_DIST += atf-sh/normalize_test.sh
|
||||
atf-sh/normalize_test: $(srcdir)/atf-sh/normalize_test.sh
|
||||
test -d atf-sh || mkdir -p atf-sh
|
||||
@src="$(srcdir)/atf-sh/normalize_test.sh"; \
|
||||
dst="atf-sh/normalize_test"; $(BUILD_SH_TP)
|
||||
|
||||
tests_atf_sh_SCRIPTS += atf-sh/tc_test
|
||||
CLEANFILES += atf-sh/tc_test
|
||||
EXTRA_DIST += atf-sh/tc_test.sh
|
||||
atf-sh/tc_test: $(srcdir)/atf-sh/tc_test.sh
|
||||
test -d atf-sh || mkdir -p atf-sh
|
||||
@src="$(srcdir)/atf-sh/tc_test.sh"; \
|
||||
dst="atf-sh/tc_test"; $(BUILD_SH_TP)
|
||||
|
||||
tests_atf_sh_SCRIPTS += atf-sh/tp_test
|
||||
CLEANFILES += atf-sh/tp_test
|
||||
EXTRA_DIST += atf-sh/tp_test.sh
|
||||
atf-sh/tp_test: $(srcdir)/atf-sh/tp_test.sh
|
||||
test -d atf-sh || mkdir -p atf-sh
|
||||
@src="$(srcdir)/atf-sh/tp_test.sh"; \
|
||||
dst="atf-sh/tp_test"; $(BUILD_SH_TP)
|
||||
|
||||
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
|
@ -49,9 +49,9 @@ extern "C" {
|
||||
|
||||
#include "atf-c++/check.hpp"
|
||||
#include "atf-c++/config.hpp"
|
||||
#include "atf-c++/utils.hpp"
|
||||
|
||||
#include "atf-c++/detail/application.hpp"
|
||||
#include "atf-c++/detail/auto_array.hpp"
|
||||
#include "atf-c++/detail/exceptions.hpp"
|
||||
#include "atf-c++/detail/fs.hpp"
|
||||
#include "atf-c++/detail/process.hpp"
|
||||
@ -116,7 +116,7 @@ public:
|
||||
std::ostream(NULL),
|
||||
m_fd(-1)
|
||||
{
|
||||
atf::utils::auto_array< char > buf(new char[p.str().length() + 1]);
|
||||
atf::auto_array< char > buf(new char[p.str().length() + 1]);
|
||||
std::strcpy(buf.get(), p.c_str());
|
||||
|
||||
m_fd = ::mkstemp(buf.get());
|
||||
@ -331,10 +331,13 @@ static
|
||||
std::auto_ptr< atf::check::check_result >
|
||||
execute(const char* const* argv)
|
||||
{
|
||||
// TODO: This should go to stderr... but fixing it now may be hard as test
|
||||
// cases out there might be relying on stderr being silent.
|
||||
std::cout << "Executing command [ ";
|
||||
for (int i = 0; argv[i] != NULL; ++i)
|
||||
std::cout << argv[i] << " ";
|
||||
std::cout << "]\n";
|
||||
std::cout.flush();
|
||||
|
||||
atf::process::argv_array argva(argv);
|
||||
return atf::check::exec(argva);
|
||||
|
@ -211,10 +211,10 @@ oflag_inline_body()
|
||||
h_pass "echo foo bar" -o inline:"foo bar\n"
|
||||
h_pass "printf 'foo bar'" -o inline:"foo bar"
|
||||
h_pass "printf '\t\n\t\n'" -o inline:"\t\n\t\n"
|
||||
# XXX Ugly hack to workaround the lack of \e in FreeBSD. Look for a
|
||||
# nicer solution...
|
||||
# XXX Ugly hack to workaround the lack of \e in FreeBSD. Also, \e doesn't
|
||||
# seem to work as expected in Linux. Look for a nicer solution.
|
||||
case $(uname) in
|
||||
Darwin|FreeBSD)
|
||||
Darwin|FreeBSD|Linux)
|
||||
h_pass "printf '\a\b\f\n\r\t\v'" -o inline:"\a\b\f\n\r\t\v"
|
||||
;;
|
||||
*)
|
||||
@ -331,10 +331,10 @@ eflag_inline_body()
|
||||
h_pass "echo foo bar 1>&2" -e inline:"foo bar\n"
|
||||
h_pass "printf 'foo bar' 1>&2" -e inline:"foo bar"
|
||||
h_pass "printf '\t\n\t\n' 1>&2" -e inline:"\t\n\t\n"
|
||||
# XXX Ugly hack to workaround the lack of \e in FreeBSD. Look for a
|
||||
# nicer solution...
|
||||
# XXX Ugly hack to workaround the lack of \e in FreeBSD. Also, \e doesn't
|
||||
# seem to work as expected in Linux. Look for a nicer solution.
|
||||
case $(uname) in
|
||||
Darwin|FreeBSD)
|
||||
Darwin|FreeBSD|Linux)
|
||||
h_pass "printf '\a\b\f\n\r\t\v' 1>&2" -e inline:"\a\b\f\n\r\t\v"
|
||||
;;
|
||||
*)
|
||||
|
@ -26,7 +26,7 @@
|
||||
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd June 28, 2010
|
||||
.Dd October 13, 2013
|
||||
.Dt ATF-SH-API 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -320,18 +320,21 @@ This example demonstrates the use of the very useful
|
||||
function:
|
||||
.Bd -literal -offset indent
|
||||
# Check for silent output
|
||||
atf_check 'true' 0 null null
|
||||
atf_check -s exit:0 -o empty -e empty 'true'
|
||||
|
||||
# Check for silent output and failure
|
||||
atf_check 'false' 1 null null
|
||||
atf_check -s exit:1 -o empty -e empty 'false'
|
||||
|
||||
# Check for known stdout and silent stderr
|
||||
echo foo >expout
|
||||
atf_check 'echo foo' 0 expout null
|
||||
atf_check -s exit:0 -o file:expout -e empty 'echo foo'
|
||||
|
||||
# Generate a file for later inspection
|
||||
atf_check 'ls' 0 stdout null
|
||||
atf_check -s exit:0 -o save:stdout -e empty 'ls'
|
||||
grep foo ls || atf_fail "foo file not found in listing"
|
||||
|
||||
# Or just do the match along the way
|
||||
atf_check -s exit:0 -o match:"^foo$" -e empty 'ls'
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr atf-sh 1 ,
|
||||
|
@ -26,7 +26,7 @@
|
||||
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd May 9, 2010
|
||||
.Dd October 15, 2013
|
||||
.Dt ATF-SH 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -67,9 +67,6 @@ The following options are available:
|
||||
.Bl -tag -width XhXX
|
||||
.It Fl h
|
||||
Shows a short summary of all available options and their purpose.
|
||||
For those formats that write to a single file, specifying a
|
||||
.Sq -
|
||||
as the path will redirect the report to the standard output.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr atf-config 1 ,
|
||||
|
@ -168,6 +168,21 @@ equal_body()
|
||||
grep '^failed: \${x} != \${y} (a != b)$' resfile
|
||||
}
|
||||
|
||||
atf_test_case flush_stdout_on_timeout
|
||||
flush_stdout_on_timeout_body()
|
||||
{
|
||||
"$(atf_get_srcdir)/misc_helpers" -s "$(atf_get_srcdir)" atf_check_timeout \
|
||||
>out 2>err &
|
||||
pid="${!}"
|
||||
sleep 1
|
||||
kill "${pid}"
|
||||
|
||||
grep 'Executing command.*true' out \
|
||||
|| atf_fail 'First command not in output'
|
||||
grep 'Executing command.*sleep 42' out \
|
||||
|| atf_fail 'Second command not in output'
|
||||
}
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
atf_add_test_case info_ok
|
||||
@ -176,6 +191,7 @@ atf_init_test_cases()
|
||||
atf_add_test_case null_stdout
|
||||
atf_add_test_case null_stderr
|
||||
atf_add_test_case equal
|
||||
atf_add_test_case flush_stdout_on_timeout
|
||||
}
|
||||
|
||||
# vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4
|
||||
|
@ -143,6 +143,18 @@ atf_check_equal_eval_fail_body()
|
||||
atf_check_equal '${x}' '${y}'
|
||||
}
|
||||
|
||||
atf_test_case atf_check_timeout
|
||||
atf_check_timeout_head()
|
||||
{
|
||||
atf_set "descr" "Helper test case for the t_atf_check test program"
|
||||
atf_set "timeout" 1
|
||||
}
|
||||
atf_check_timeout_body()
|
||||
{
|
||||
atf_check true
|
||||
atf_check sleep 42
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Helper tests for "t_config".
|
||||
# -------------------------------------------------------------------------
|
||||
@ -273,6 +285,7 @@ atf_init_test_cases()
|
||||
atf_add_test_case atf_check_equal_fail
|
||||
atf_add_test_case atf_check_equal_eval_ok
|
||||
atf_add_test_case atf_check_equal_eval_fail
|
||||
atf_add_test_case atf_check_timeout
|
||||
|
||||
# Add helper tests for t_config.
|
||||
atf_add_test_case config_get
|
||||
|
@ -1,54 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
bin_PROGRAMS += atf-version/atf-version
|
||||
atf_version_atf_version_SOURCES = atf-version/atf-version.cpp
|
||||
nodist_atf_version_atf_version_SOURCES = atf-version/revision.h
|
||||
atf_version_atf_version_CPPFLAGS = -Iatf-version
|
||||
atf_version_atf_version_LDADD = $(ATF_CXX_LIBS)
|
||||
dist_man_MANS += atf-version/atf-version.1
|
||||
|
||||
EXTRA_DIST += atf-version/generate-revision.sh
|
||||
|
||||
BUILT_SOURCES += atf-version/revision.h
|
||||
CLEANFILES += atf-version/revision.h
|
||||
atf-version/revision.h: atf-version/revision.h.stamp
|
||||
@test -d atf-version || mkdir -p atf-version
|
||||
@cmp -s atf-version/revision.h atf-version/revision.h.stamp || \
|
||||
cp -p atf-version/revision.h.stamp atf-version/revision.h
|
||||
|
||||
CLEANFILES += atf-version/revision.h.stamp
|
||||
PHONY_TARGETS += atf-version/revision.h.stamp
|
||||
atf-version/revision.h.stamp:
|
||||
@test -d atf-version || mkdir -p atf-version
|
||||
@$(top_srcdir)/atf-version/generate-revision.sh \
|
||||
-g "$(GIT)" -r $(top_srcdir) -o atf-version/revision.h.stamp \
|
||||
-v $(PACKAGE_VERSION)
|
||||
|
||||
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
|
@ -23,7 +23,7 @@
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if getopt has optreset */
|
||||
/* #undef HAVE_OPTRESET */
|
||||
#define HAVE_OPTRESET 1
|
||||
|
||||
/* Define to 1 if you have the `putenv' function. */
|
||||
#define HAVE_PUTENV 1
|
||||
@ -80,9 +80,6 @@
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
/* #undef NO_MINUS_C_MINUS_O */
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "atf"
|
||||
|
||||
@ -96,7 +93,7 @@
|
||||
#define PACKAGE_NAME "Automated Testing Framework"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "Automated Testing Framework 0.16"
|
||||
#define PACKAGE_STRING "Automated Testing Framework 0.18"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "atf"
|
||||
@ -105,10 +102,10 @@
|
||||
#define PACKAGE_URL "http://code.google.com/p/kyua/wiki/ATF"
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "0.16"
|
||||
#define PACKAGE_VERSION "0.18"
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "0.16"
|
||||
#define VERSION "0.18"
|
||||
|
@ -1,113 +0,0 @@
|
||||
/* bconfig.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define to 1 if basename takes a constant pointer */
|
||||
#undef HAVE_CONST_BASENAME
|
||||
|
||||
/* Define to 1 if dirname takes a constant pointer */
|
||||
#undef HAVE_CONST_DIRNAME
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if getcwd(NULL, 0) works */
|
||||
#undef HAVE_GETCWD_DYN
|
||||
|
||||
/* Define to 1 if getopt allows a + sign for POSIX behavior */
|
||||
#undef HAVE_GNU_GETOPT
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if getopt has optreset */
|
||||
#undef HAVE_OPTRESET
|
||||
|
||||
/* Define to 1 if you have the `putenv' function. */
|
||||
#undef HAVE_PUTENV
|
||||
|
||||
/* Define to 1 if putenv is in std */
|
||||
#undef HAVE_PUTENV_IN_STD
|
||||
|
||||
/* Define to 1 if you have the `setenv' function. */
|
||||
#undef HAVE_SETENV
|
||||
|
||||
/* Define to 1 if setenv is in std */
|
||||
#undef HAVE_SETENV_IN_STD
|
||||
|
||||
/* Define to 1 if snprintf is in std */
|
||||
#undef HAVE_SNPRINTF_IN_STD
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if you have the `unmount' function. */
|
||||
#undef HAVE_UNMOUNT
|
||||
|
||||
/* Define to 1 if you have the `unsetenv' function. */
|
||||
#undef HAVE_UNSETENV
|
||||
|
||||
/* Define to 1 if unsetenv is in std */
|
||||
#undef HAVE_UNSETENV_IN_STD
|
||||
|
||||
/* Define to 1 if vsnprintf is in std */
|
||||
#undef HAVE_VSNPRINTF_IN_STD
|
||||
|
||||
/* Define to the last valid signal number */
|
||||
#undef LAST_SIGNO
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#undef LT_OBJDIR
|
||||
|
||||
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
|
||||
#undef NO_MINUS_C_MINUS_O
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the copyright string applicable to this package. */
|
||||
#undef PACKAGE_COPYRIGHT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
19965
contrib/atf/configure
vendored
19965
contrib/atf/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -1,228 +0,0 @@
|
||||
dnl
|
||||
dnl Automated Testing Framework (atf)
|
||||
dnl
|
||||
dnl Copyright (c) 2007 The NetBSD Foundation, 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
|
||||
dnl are met:
|
||||
dnl 1. Redistributions of source code must retain the above copyright
|
||||
dnl notice, this list of conditions and the following disclaimer.
|
||||
dnl 2. 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
|
||||
dnl THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
dnl CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
dnl IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
dnl GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
dnl IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
dnl
|
||||
|
||||
dnl -----------------------------------------------------------------------
|
||||
dnl Initialize the GNU build system.
|
||||
dnl -----------------------------------------------------------------------
|
||||
|
||||
AC_INIT([Automated Testing Framework], [0.16], [atf-devel@NetBSD.org], [atf],
|
||||
[http://code.google.com/p/kyua/wiki/ATF])
|
||||
AC_PREREQ([2.65])
|
||||
AC_COPYRIGHT([Copyright (c) 2007-2012 The NetBSD Foundation, Inc.])
|
||||
AC_DEFINE([PACKAGE_COPYRIGHT],
|
||||
["Copyright (c) 2007-2012 The NetBSD Foundation, Inc."],
|
||||
[Define to the copyright string applicable to this package.])
|
||||
AC_CONFIG_AUX_DIR([admin])
|
||||
AC_CONFIG_HEADERS([bconfig.h])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AC_CONFIG_SRCDIR([atf-c.h])
|
||||
AC_CONFIG_TESTDIR([bootstrap])
|
||||
|
||||
AC_CANONICAL_TARGET
|
||||
|
||||
AM_INIT_AUTOMAKE([1.9 check-news foreign subdir-objects -Wall])
|
||||
|
||||
LT_INIT
|
||||
|
||||
AC_ARG_ENABLE(tools,
|
||||
AS_HELP_STRING([--enable-tools],
|
||||
[Enables the build of the deprecated ATF tools]),
|
||||
[case $enableval in
|
||||
yes|no) enable_tools=${enableval} ;;
|
||||
*) AC_MSG_ERROR([Invalid value passed to --enable-tools]) ;;
|
||||
esac],
|
||||
[enable_tools=no])
|
||||
AC_SUBST([ENABLE_TOOLS], ${enable_tools})
|
||||
AM_CONDITIONAL([ENABLE_TOOLS], [test "${enable_tools}" = yes])
|
||||
|
||||
dnl -----------------------------------------------------------------------
|
||||
dnl Check for the C and C++ compilers and required features.
|
||||
dnl -----------------------------------------------------------------------
|
||||
|
||||
AC_LANG(C)
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
dnl The C compiler check automatically aborts if the compiler does not work.
|
||||
dnl Nothing to do here.
|
||||
|
||||
AC_LANG(C++)
|
||||
AC_PROG_CXX
|
||||
AC_CACHE_CHECK([whether the C++ compiler works],
|
||||
[atf_cv_prog_cxx_works],
|
||||
[AC_LANG_PUSH([C++])
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
|
||||
[atf_cv_prog_cxx_works=yes],
|
||||
[atf_cv_prog_cxx_works=no])
|
||||
AC_LANG_POP])
|
||||
if test "${atf_cv_prog_cxx_works}" = no; then
|
||||
AC_MSG_ERROR([C++ compiler cannot create executables])
|
||||
fi
|
||||
|
||||
KYUA_DEVELOPER_MODE([C,C++])
|
||||
|
||||
ATF_MODULE_APPLICATION
|
||||
ATF_MODULE_DEFS
|
||||
ATF_MODULE_ENV
|
||||
ATF_MODULE_FS
|
||||
ATF_MODULE_SANITY
|
||||
ATF_MODULE_SIGNALS
|
||||
|
||||
AC_CHECK_TYPE([timer_t], [], [], [[#include <time.h>]])
|
||||
|
||||
ATF_RUNTIME_TOOL([ATF_BUILD_CC],
|
||||
[C compiler to use at runtime], [${CC}])
|
||||
ATF_RUNTIME_TOOL([ATF_BUILD_CFLAGS],
|
||||
[C compiler flags to use at runtime], [${CFLAGS}])
|
||||
ATF_RUNTIME_TOOL([ATF_BUILD_CPP],
|
||||
[C/C++ preprocessor to use at runtime], [${CPP}])
|
||||
ATF_RUNTIME_TOOL([ATF_BUILD_CPPFLAGS],
|
||||
[C/C++ preprocessor flags to use at runtime], [${CPPFLAGS}])
|
||||
ATF_RUNTIME_TOOL([ATF_BUILD_CXX],
|
||||
[C++ compiler to use at runtime], [${CXX}])
|
||||
ATF_RUNTIME_TOOL([ATF_BUILD_CXXFLAGS],
|
||||
[C++ compiler flags to use at runtime], [${CXXFLAGS}])
|
||||
|
||||
dnl -----------------------------------------------------------------------
|
||||
dnl Generation of files in srcdir.
|
||||
dnl -----------------------------------------------------------------------
|
||||
|
||||
dnl BSD make(1) doesn't deal with targets specified as './foo' well: they
|
||||
dnl need to be specified as 'foo'. The following hack is to workaround this
|
||||
dnl issue.
|
||||
if test "${srcdir}" = .; then
|
||||
target_srcdir=
|
||||
else
|
||||
target_srcdir="${srcdir}/"
|
||||
fi
|
||||
AC_SUBST([target_srcdir])
|
||||
|
||||
dnl -----------------------------------------------------------------------
|
||||
dnl Architecture and machine checks.
|
||||
dnl -----------------------------------------------------------------------
|
||||
|
||||
atf_arch=`uname -p`
|
||||
atf_machine=`uname -m`
|
||||
|
||||
AC_MSG_NOTICE([Machine type: ${atf_machine}, architecture: ${atf_arch}])
|
||||
AC_SUBST(atf_arch, ${atf_arch})
|
||||
AC_SUBST(atf_machine, ${atf_machine})
|
||||
|
||||
dnl -----------------------------------------------------------------------
|
||||
dnl User-customizable variables.
|
||||
dnl -----------------------------------------------------------------------
|
||||
|
||||
AC_ARG_VAR([ATF_CONFSUBDIR],
|
||||
[Subdirectory of sysconfdir under which to look for files])
|
||||
if test x"${ATF_CONFSUBDIR-unset}" = x"unset"; then
|
||||
ATF_CONFSUBDIR=atf
|
||||
else
|
||||
case ${ATF_CONFSUBDIR} in
|
||||
/*)
|
||||
AC_MSG_ERROR([ATF_CONFSUBDIR must hold a relative path])
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if test x"${ATF_CONFSUBDIR}" = x""; then
|
||||
AC_SUBST(atf_confdir, \${sysconfdir})
|
||||
else
|
||||
AC_SUBST(atf_confdir, \${sysconfdir}/${ATF_CONFSUBDIR})
|
||||
fi
|
||||
|
||||
AC_ARG_VAR([ATF_WORKDIR],
|
||||
[Default location to use for ATF work directories])
|
||||
if test x"${ATF_WORKDIR}" = x""; then
|
||||
for t in /tmp /var/tmp; do
|
||||
if test -d ${t}; then
|
||||
ATF_WORKDIR=${t}
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test x"${ATF_WORKDIR}" = x""; then
|
||||
AC_MSG_ERROR([Could not guess a value for ATF_WORKDIR])
|
||||
fi
|
||||
else
|
||||
case ${ATF_WORKDIR} in
|
||||
/*)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([ATF_WORKDIR must hold an absolute path])
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
AC_SUBST(atf_aclocaldir, \${datadir}/aclocal)
|
||||
AC_SUBST(atf_cssdir, \${datadir}/examples/atf)
|
||||
AC_SUBST(atf_dtddir, \${datadir}/xml/atf)
|
||||
AC_SUBST(atf_egdir, \${datadir}/examples/atf)
|
||||
AC_SUBST(atf_pkgconfigdir, \${libdir}/pkgconfig)
|
||||
AC_SUBST(atf_xsldir, \${datadir}/xsl/atf)
|
||||
|
||||
dnl -----------------------------------------------------------------------
|
||||
dnl Check for the shell and portability problems.
|
||||
dnl -----------------------------------------------------------------------
|
||||
|
||||
AC_ARG_VAR([ATF_SHELL], [Location of the POSIX shell interpreter to use])
|
||||
if test x"${ATF_SHELL}" = x""; then
|
||||
AC_PATH_PROGS(ATF_SHELL, [bash sh])
|
||||
else
|
||||
case ${ATF_SHELL} in
|
||||
/*)
|
||||
;;
|
||||
*)
|
||||
AC_MSG_ERROR([ATF_SHELL must hold an absolute path])
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if test x"${ATF_SHELL}" = x""; then
|
||||
AC_MSG_ERROR([No POSIX shell interpreter found; maybe set ATF_SHELL?])
|
||||
fi
|
||||
|
||||
dnl -----------------------------------------------------------------------
|
||||
dnl Check for required tools.
|
||||
dnl -----------------------------------------------------------------------
|
||||
|
||||
AC_PATH_PROG([GDB], [gdb])
|
||||
AC_PATH_PROG([KYUA], [kyua])
|
||||
AM_CONDITIONAL([HAVE_KYUA], [test -n "${KYUA}"])
|
||||
AC_PATH_PROG([GIT], [git])
|
||||
|
||||
dnl -----------------------------------------------------------------------
|
||||
dnl Finally, generate output.
|
||||
dnl -----------------------------------------------------------------------
|
||||
|
||||
AC_OUTPUT([Makefile atf-c/defs.h])
|
||||
|
||||
if test ${enable_tools} = yes; then
|
||||
AC_MSG_WARN([Building the deprecated ATF tools (atf-run and atf-report);])
|
||||
AC_MSG_WARN([please migrate to Kyua as soon as feasible.])
|
||||
fi
|
||||
|
||||
dnl vim: syntax=m4:expandtab:shiftwidth=4:softtabstop=4
|
@ -1,50 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
dist_man_MANS += doc/atf-test-case.4 \
|
||||
doc/atf-test-program.1
|
||||
|
||||
if ENABLE_TOOLS
|
||||
|
||||
man_MANS += doc/atf.7
|
||||
CLEANFILES += doc/atf.7
|
||||
EXTRA_DIST += doc/atf.7.in
|
||||
|
||||
dist_man_MANS += doc/atf-formats.5
|
||||
|
||||
doc/atf.7: $(srcdir)/doc/atf.7.in
|
||||
test -d doc || mkdir -p doc
|
||||
sed -e 's#__DOCDIR__#$(docdir)#g' \
|
||||
-e 's#__TESTSDIR__#$(testsdir)#g' \
|
||||
<$(srcdir)/doc/atf.7.in >doc/atf.7.tmp
|
||||
mv doc/atf.7.tmp doc/atf.7
|
||||
|
||||
endif
|
||||
|
||||
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
|
@ -34,9 +34,9 @@
|
||||
.Nd introduction to the Automated Testing Framework
|
||||
.Sh DESCRIPTION
|
||||
.Em IMPORTANT: If you are here because you want to know how to run the tests in
|
||||
.Em Pa __TESTSDIR__ ,
|
||||
.Pa __TESTSDIR__ ,
|
||||
.Em you most likely want to read the
|
||||
.Em Xr tests 7
|
||||
.Xr tests 7
|
||||
.Em manual page instead.
|
||||
.Pp
|
||||
The Automated Testing Framework
|
||||
|
@ -4,7 +4,6 @@ prop: test-suite = atf
|
||||
|
||||
tp: config_test
|
||||
tp: expect_test
|
||||
tp: fork_test
|
||||
tp: meta_data_test
|
||||
tp: srcdir_test
|
||||
tp: result_test
|
||||
|
@ -4,7 +4,6 @@ test_suite("atf")
|
||||
|
||||
atf_test_program{name="config_test"}
|
||||
atf_test_program{name="expect_test"}
|
||||
atf_test_program{name="fork_test"}
|
||||
atf_test_program{name="meta_data_test"}
|
||||
atf_test_program{name="srcdir_test"}
|
||||
atf_test_program{name="result_test"}
|
||||
|
@ -1,102 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
tests_test_programs_DATA = test-programs/Atffile \
|
||||
test-programs/Kyuafile
|
||||
tests_test_programsdir = $(pkgtestsdir)/test-programs
|
||||
EXTRA_DIST += $(tests_test_programs_DATA)
|
||||
|
||||
tests_test_programs_PROGRAMS = test-programs/c_helpers
|
||||
test_programs_c_helpers_SOURCES = test-programs/c_helpers.c
|
||||
test_programs_c_helpers_LDADD = libatf-c.la
|
||||
|
||||
tests_test_programs_PROGRAMS += test-programs/cpp_helpers
|
||||
test_programs_cpp_helpers_SOURCES = test-programs/cpp_helpers.cpp
|
||||
test_programs_cpp_helpers_LDADD = $(ATF_CXX_LIBS)
|
||||
|
||||
common_sh = $(srcdir)/test-programs/common.sh
|
||||
EXTRA_DIST += test-programs/common.sh
|
||||
|
||||
tests_test_programs_SCRIPTS = test-programs/sh_helpers
|
||||
CLEANFILES += test-programs/sh_helpers
|
||||
EXTRA_DIST += test-programs/sh_helpers.sh
|
||||
test-programs/sh_helpers: $(srcdir)/test-programs/sh_helpers.sh
|
||||
test -d test-programs || mkdir -p test-programs
|
||||
@src="$(srcdir)/test-programs/sh_helpers.sh $(common_sh)"; \
|
||||
dst="test-programs/sh_helpers"; $(BUILD_SH_TP)
|
||||
|
||||
tests_test_programs_SCRIPTS += test-programs/config_test
|
||||
CLEANFILES += test-programs/config_test
|
||||
EXTRA_DIST += test-programs/config_test.sh
|
||||
test-programs/config_test: $(srcdir)/test-programs/config_test.sh
|
||||
test -d test-programs || mkdir -p test-programs
|
||||
@src="$(srcdir)/test-programs/config_test.sh $(common_sh)"; \
|
||||
dst="test-programs/config_test"; $(BUILD_SH_TP)
|
||||
|
||||
tests_test_programs_SCRIPTS += test-programs/expect_test
|
||||
CLEANFILES += test-programs/expect_test
|
||||
EXTRA_DIST += test-programs/expect_test.sh
|
||||
test-programs/expect_test: $(srcdir)/test-programs/expect_test.sh
|
||||
test -d test-programs || mkdir -p test-programs
|
||||
@src="$(srcdir)/test-programs/expect_test.sh $(common_sh)"; \
|
||||
dst="test-programs/expect_test"; $(BUILD_SH_TP)
|
||||
|
||||
tests_test_programs_SCRIPTS += test-programs/fork_test
|
||||
CLEANFILES += test-programs/fork_test
|
||||
EXTRA_DIST += test-programs/fork_test.sh
|
||||
test-programs/fork_test: $(srcdir)/test-programs/fork_test.sh
|
||||
test -d test-programs || mkdir -p test-programs
|
||||
@src="$(srcdir)/test-programs/fork_test.sh $(common_sh)"; \
|
||||
dst="test-programs/fork_test"; $(BUILD_SH_TP)
|
||||
|
||||
tests_test_programs_SCRIPTS += test-programs/meta_data_test
|
||||
CLEANFILES += test-programs/meta_data_test
|
||||
EXTRA_DIST += test-programs/meta_data_test.sh
|
||||
test-programs/meta_data_test: $(srcdir)/test-programs/meta_data_test.sh
|
||||
test -d test-programs || mkdir -p test-programs
|
||||
@src="$(srcdir)/test-programs/meta_data_test.sh $(common_sh)"; \
|
||||
dst="test-programs/meta_data_test"; $(BUILD_SH_TP)
|
||||
|
||||
tests_test_programs_SCRIPTS += test-programs/result_test
|
||||
CLEANFILES += test-programs/result_test
|
||||
EXTRA_DIST += test-programs/result_test.sh
|
||||
test-programs/result_test: $(srcdir)/test-programs/result_test.sh
|
||||
test -d test-programs || mkdir -p test-programs
|
||||
@src="$(srcdir)/test-programs/result_test.sh $(common_sh)"; \
|
||||
dst="test-programs/result_test"; $(BUILD_SH_TP)
|
||||
|
||||
tests_test_programs_SCRIPTS += test-programs/srcdir_test
|
||||
CLEANFILES += test-programs/srcdir_test
|
||||
EXTRA_DIST += test-programs/srcdir_test.sh
|
||||
test-programs/srcdir_test: $(srcdir)/test-programs/srcdir_test.sh
|
||||
test -d test-programs || mkdir -p test-programs
|
||||
@src="$(srcdir)/test-programs/srcdir_test.sh $(common_sh)"; \
|
||||
dst="test-programs/srcdir_test"; $(BUILD_SH_TP)
|
||||
|
||||
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
|
@ -177,22 +177,6 @@ ATF_TC_CLEANUP(cleanup_sigterm, tc)
|
||||
safe_remove(atf_tc_get_config_var(tc, "tmpfile"));
|
||||
}
|
||||
|
||||
ATF_TC_WITH_CLEANUP(cleanup_fork);
|
||||
ATF_TC_HEAD(cleanup_fork, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Helper test case for the t_cleanup test "
|
||||
"program");
|
||||
}
|
||||
ATF_TC_BODY(cleanup_fork, tc)
|
||||
{
|
||||
}
|
||||
ATF_TC_CLEANUP(cleanup_fork, tc)
|
||||
{
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
close(3);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Helper tests for "t_config".
|
||||
* --------------------------------------------------------------------- */
|
||||
@ -385,37 +369,6 @@ ATF_TC_BODY(expect_timeout_but_pass, tc)
|
||||
atf_tc_expect_timeout("Will just exit");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Helper tests for "t_fork".
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
ATF_TC(fork_stop);
|
||||
ATF_TC_HEAD(fork_stop, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Helper test case for the t_fork test "
|
||||
"program");
|
||||
}
|
||||
ATF_TC_BODY(fork_stop, tc)
|
||||
{
|
||||
FILE *f;
|
||||
const char *dfstr, *pfstr;
|
||||
|
||||
dfstr = atf_tc_get_config_var(tc, "donefile");
|
||||
pfstr = atf_tc_get_config_var(tc, "pidfile");
|
||||
|
||||
f = fopen(pfstr, "w");
|
||||
if (f == NULL)
|
||||
atf_tc_fail("Failed to create pidfile %s", pfstr);
|
||||
fprintf(f, "%d", (int)getpid());
|
||||
fclose(f);
|
||||
printf("Wrote pid file\n");
|
||||
|
||||
printf("Waiting for done file\n");
|
||||
while (access(dfstr, F_OK) != 0)
|
||||
usleep(10000);
|
||||
printf("Exiting\n");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Helper tests for "t_meta_data".
|
||||
* --------------------------------------------------------------------- */
|
||||
@ -511,7 +464,6 @@ ATF_TP_ADD_TCS(tp)
|
||||
ATF_TP_ADD_TC(tp, cleanup_skip);
|
||||
ATF_TP_ADD_TC(tp, cleanup_curdir);
|
||||
ATF_TP_ADD_TC(tp, cleanup_sigterm);
|
||||
ATF_TP_ADD_TC(tp, cleanup_fork);
|
||||
|
||||
/* Add helper tests for t_config. */
|
||||
ATF_TP_ADD_TC(tp, config_unset);
|
||||
@ -538,9 +490,6 @@ ATF_TP_ADD_TCS(tp)
|
||||
ATF_TP_ADD_TC(tp, expect_timeout_and_hang);
|
||||
ATF_TP_ADD_TC(tp, expect_timeout_but_pass);
|
||||
|
||||
/* Add helper tests for t_fork. */
|
||||
ATF_TP_ADD_TC(tp, fork_stop);
|
||||
|
||||
/* Add helper tests for t_meta_data. */
|
||||
ATF_TP_ADD_TC(tp, metadata_no_descr);
|
||||
ATF_TP_ADD_TC(tp, metadata_no_head);
|
||||
|
@ -36,7 +36,7 @@ extern "C" {
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "atf-c++/macros.hpp"
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
#include "atf-c++/detail/fs.hpp"
|
||||
|
||||
@ -224,27 +224,6 @@ ATF_TEST_CASE_BODY(expect_timeout_but_pass)
|
||||
expect_timeout("Will just exit");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Helper tests for "t_fork".
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
ATF_TEST_CASE(fork_stop);
|
||||
ATF_TEST_CASE_HEAD(fork_stop)
|
||||
{
|
||||
set_md_var("descr", "Helper test case for the t_fork test program");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(fork_stop)
|
||||
{
|
||||
std::ofstream os(get_config_var("pidfile").c_str());
|
||||
os << ::getpid() << "\n";
|
||||
os.close();
|
||||
std::cout << "Wrote pid file\n";
|
||||
std::cout << "Waiting for done file\n";
|
||||
while (::access(get_config_var("donefile").c_str(), F_OK) != 0)
|
||||
::usleep(10000);
|
||||
std::cout << "Exiting\n";
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Helper tests for "t_meta_data".
|
||||
// ------------------------------------------------------------------------
|
||||
@ -363,9 +342,6 @@ ATF_INIT_TEST_CASES(tcs)
|
||||
ATF_ADD_TEST_CASE(tcs, expect_timeout_and_hang);
|
||||
ATF_ADD_TEST_CASE(tcs, expect_timeout_but_pass);
|
||||
|
||||
// Add helper tests for t_fork.
|
||||
ATF_ADD_TEST_CASE(tcs, fork_stop);
|
||||
|
||||
// Add helper tests for t_meta_data.
|
||||
ATF_ADD_TEST_CASE(tcs, metadata_no_descr);
|
||||
ATF_ADD_TEST_CASE(tcs, metadata_no_head);
|
||||
|
@ -1,64 +0,0 @@
|
||||
#
|
||||
# Automated Testing Framework (atf)
|
||||
#
|
||||
# Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
# TODO: This test program is about checking the test case's "environment"
|
||||
# (not the variables). Should be named something else than t_fork.
|
||||
|
||||
atf_test_case stop
|
||||
stop_head()
|
||||
{
|
||||
atf_set "descr" "Tests that sending a stop signal to a test case does" \
|
||||
"not report it as failed"
|
||||
}
|
||||
stop_body()
|
||||
{
|
||||
for h in $(get_helpers); do
|
||||
${h} -s $(atf_get_srcdir) -v pidfile=$(pwd)/pid \
|
||||
-v donefile=$(pwd)/done -r resfile fork_stop &
|
||||
ppid=${!}
|
||||
echo "Waiting for pid file for test program ${ppid}"
|
||||
while test ! -f pid; do sleep 1; done
|
||||
pid=$(cat pid)
|
||||
echo "Test case's pid is ${pid}"
|
||||
kill -STOP ${pid}
|
||||
touch done
|
||||
echo "Wrote done file"
|
||||
kill -CONT ${pid}
|
||||
wait ${ppid}
|
||||
atf_check -s eq:0 -o ignore -e empty grep '^passed$' resfile
|
||||
rm -f pid done
|
||||
done
|
||||
}
|
||||
|
||||
atf_init_test_cases()
|
||||
{
|
||||
atf_add_test_case stop
|
||||
}
|
||||
|
||||
# vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4
|
@ -111,23 +111,6 @@ cleanup_sigterm_cleanup()
|
||||
rm $(atf_config_get tmpfile)
|
||||
}
|
||||
|
||||
atf_test_case cleanup_fork cleanup
|
||||
cleanup_fork_head()
|
||||
{
|
||||
atf_set "descr" "Helper test case for the t_cleanup test program"
|
||||
}
|
||||
cleanup_fork_body()
|
||||
{
|
||||
:
|
||||
}
|
||||
cleanup_fork_cleanup()
|
||||
{
|
||||
exec 1>out
|
||||
exec 2>err
|
||||
exec 3>res
|
||||
rm -f out err res
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Helper tests for "t_config".
|
||||
# -------------------------------------------------------------------------
|
||||
@ -174,24 +157,6 @@ config_multi_value_body()
|
||||
atf_check_equal "$(atf_config_get 'test')" "foo bar"
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Helper tests for "t_fork".
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
atf_test_case fork_stop
|
||||
fork_stop_head()
|
||||
{
|
||||
atf_set "descr" "Helper test case for the t_fork test program"
|
||||
}
|
||||
fork_stop_body()
|
||||
{
|
||||
echo ${$} >$(atf_config_get pidfile)
|
||||
echo "Wrote pid file"
|
||||
echo "Waiting for done file"
|
||||
while ! test -f $(atf_config_get donefile); do sleep 1; done
|
||||
echo "Exiting"
|
||||
}
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Helper tests for "t_expect".
|
||||
# -------------------------------------------------------------------------
|
||||
@ -387,7 +352,6 @@ atf_init_test_cases()
|
||||
atf_add_test_case cleanup_skip
|
||||
atf_add_test_case cleanup_curdir
|
||||
atf_add_test_case cleanup_sigterm
|
||||
atf_add_test_case cleanup_fork
|
||||
|
||||
# Add helper tests for t_config.
|
||||
atf_add_test_case config_unset
|
||||
@ -414,9 +378,6 @@ atf_init_test_cases()
|
||||
atf_add_test_case expect_timeout_and_hang
|
||||
atf_add_test_case expect_timeout_but_pass
|
||||
|
||||
# Add helper tests for t_fork.
|
||||
atf_add_test_case fork_stop
|
||||
|
||||
# Add helper tests for t_meta_data.
|
||||
atf_add_test_case metadata_no_descr
|
||||
atf_add_test_case metadata_no_head
|
||||
|
@ -59,12 +59,14 @@ SRCS= application.cpp \
|
||||
process.cpp \
|
||||
tests.cpp \
|
||||
text.cpp \
|
||||
ui.cpp
|
||||
ui.cpp \
|
||||
utils.cpp
|
||||
|
||||
INCS= build.hpp \
|
||||
check.hpp \
|
||||
config.hpp \
|
||||
macros.hpp \
|
||||
noncopyable.hpp \
|
||||
tests.hpp \
|
||||
utils.hpp
|
||||
INCSDIR= ${INCLUDEDIR}/atf-c++
|
||||
|
@ -47,7 +47,6 @@ ATF_TESTS_SH= pkg_config_test
|
||||
map_test \
|
||||
process_test \
|
||||
sanity_test \
|
||||
test_helpers_test \
|
||||
text_test \
|
||||
user_test
|
||||
ATF_TESTS_C+= ${_T}
|
||||
|
@ -16,7 +16,7 @@ ATF_TESTS_CXX= cpp_helpers
|
||||
SRCS.cpp_helpers= cpp_helpers.cpp
|
||||
|
||||
ATF_TESTS_SH= sh_helpers
|
||||
.for _T in config_test expect_test fork_test meta_data_test result_test srcdir_test
|
||||
.for _T in config_test expect_test meta_data_test result_test srcdir_test
|
||||
ATF_TESTS_SH+= ${_T}
|
||||
ATF_TESTS_SH_SRC_${_T}= common.sh ${_T}.sh
|
||||
.endfor
|
||||
|
@ -4056,7 +4056,10 @@ OLD_FILES+=usr/share/man/man1/telnet.1.gz
|
||||
OLD_FILES+=usr/share/man/man8/telnetd.8.gz
|
||||
.endif
|
||||
|
||||
.if ${MK_TESTS} == no
|
||||
.if ${MK_TESTS} == yes
|
||||
OLD_FILES+=usr/tests/lib/atf/libatf-c/test_helpers_test
|
||||
OLD_FILES+=usr/tests/lib/atf/test-programs/fork_test
|
||||
.else
|
||||
# ATF libraries.
|
||||
OLD_FILES+=usr/bin/atf-sh
|
||||
OLD_DIRS+=usr/include/atf-c
|
||||
|
Loading…
x
Reference in New Issue
Block a user