Import atf-0.19:
Experimental version released on February 7th, 2014. This is the last release to bundle the code for the deprecated tools. The next release will drop their code and will stop worrying about backwards compatibility between the ATF libraries and what the old tools may or may not support. If you still require the old tools for some reason, grab a copy of the 'tools' directory now. The code in this directory is standalone and does not depend on any internal details of atf-c++ any longer. * Various fixes and improvements to support running as part of the FreeBSD test suite. * Project hosting moved from Google Code (as a subproject of Kyua) to GitHub (as a first-class project). The main reason for the change is the suppression of binary downloads in Google Code on Jan 15th, 2014. See https://github.com/jmmv/atf/ * Removed builtin help from atf-sh(1) and atf-check(1) for simplicity reasons. In other words, their -h option is gone. * Moved the code of the deprecated tools into a 'tools' directory and completely decoupled their code from the internals of atf-c++. The reason for this is to painlessly allow a third-party to maintain a copy of these tools after we delete them because upcoming changes to atf-c++ would break the stale tools.
This commit is contained in:
parent
b849e3606c
commit
a817576754
4
Atffile
4
Atffile
@ -7,6 +7,4 @@ tp: atf-c++
|
||||
tp: atf-sh
|
||||
tp: test-programs
|
||||
|
||||
tp-glob: atf-config*
|
||||
tp-glob: atf-report*
|
||||
tp-glob: atf-run*
|
||||
tp-glob: tools*
|
||||
|
10
Kyuafile
10
Kyuafile
@ -7,12 +7,6 @@ include("atf-c++/Kyuafile")
|
||||
include("atf-sh/Kyuafile")
|
||||
include("test-programs/Kyuafile")
|
||||
|
||||
if fs.exists("atf-config/Kyuafile") then
|
||||
include("atf-config/Kyuafile")
|
||||
end
|
||||
if fs.exists("atf-report/Kyuafile") then
|
||||
include("atf-report/Kyuafile")
|
||||
end
|
||||
if fs.exists("atf-run/Kyuafile") then
|
||||
include("atf-run/Kyuafile")
|
||||
if fs.exists("tools/Kyuafile") then
|
||||
include("tools/Kyuafile")
|
||||
end
|
||||
|
10
Makefile.am
10
Makefile.am
@ -30,6 +30,7 @@
|
||||
atf_aclocal_DATA =
|
||||
BUILT_SOURCES =
|
||||
CLEANFILES =
|
||||
DIST_HOOKS =
|
||||
EXTRA_DIST =
|
||||
bin_PROGRAMS =
|
||||
dist_man_MANS =
|
||||
@ -54,10 +55,7 @@ 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
|
||||
include tools/Makefile.am.inc
|
||||
endif
|
||||
|
||||
#
|
||||
@ -126,7 +124,7 @@ BUILD_SH_TP = \
|
||||
# Custom targets.
|
||||
#
|
||||
|
||||
dist-hook: forbid-dist
|
||||
DIST_HOOKS += forbid-dist
|
||||
if ENABLE_TOOLS
|
||||
forbid-dist:
|
||||
@true
|
||||
@ -151,4 +149,6 @@ release-test:
|
||||
|
||||
.PHONY: $(PHONY_TARGETS)
|
||||
|
||||
dist-hook: $(DIST_HOOKS)
|
||||
|
||||
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
|
||||
|
3176
Makefile.in
3176
Makefile.in
File diff suppressed because it is too large
Load Diff
32
NEWS
32
NEWS
@ -2,6 +2,38 @@ Major changes between releases Automated Testing Framework
|
||||
===========================================================================
|
||||
|
||||
|
||||
Changes in version 0.19
|
||||
***********************
|
||||
|
||||
Experimental version released on February 7th, 2014.
|
||||
|
||||
This is the last release to bundle the code for the deprecated tools.
|
||||
The next release will drop their code and will stop worrying about
|
||||
backwards compatibility between the ATF libraries and what the old tools
|
||||
may or may not support.
|
||||
|
||||
If you still require the old tools for some reason, grab a copy of the
|
||||
'tools' directory now. The code in this directory is standalone and
|
||||
does not depend on any internal details of atf-c++ any longer.
|
||||
|
||||
* Various fixes and improvements to support running as part of the FreeBSD
|
||||
test suite.
|
||||
|
||||
* Project hosting moved from Google Code (as a subproject of Kyua) to
|
||||
GitHub (as a first-class project). The main reason for the change is
|
||||
the suppression of binary downloads in Google Code on Jan 15th, 2014.
|
||||
See https://github.com/jmmv/atf/
|
||||
|
||||
* Removed builtin help from atf-sh(1) and atf-check(1) for simplicity
|
||||
reasons. In other words, their -h option is gone.
|
||||
|
||||
* Moved the code of the deprecated tools into a 'tools' directory and
|
||||
completely decoupled their code from the internals of atf-c++. The
|
||||
reason for this is to painlessly allow a third-party to maintain a
|
||||
copy of these tools after we delete them because upcoming changes to
|
||||
atf-c++ would break the stale tools.
|
||||
|
||||
|
||||
Changes in version 0.18
|
||||
***********************
|
||||
|
||||
|
61
aclocal.m4
vendored
61
aclocal.m4
vendored
@ -56,6 +56,66 @@ m4_ifndef([AC_AUTOCONF_VERSION],
|
||||
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
|
||||
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
|
||||
|
||||
# Copyright (C) 2011-2013 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# AM_PROG_AR([ACT-IF-FAIL])
|
||||
# -------------------------
|
||||
# Try to determine the archiver interface, and trigger the ar-lib wrapper
|
||||
# if it is needed. If the detection of archiver interface fails, run
|
||||
# ACT-IF-FAIL (default is to abort configure with a proper error message).
|
||||
AC_DEFUN([AM_PROG_AR],
|
||||
[AC_BEFORE([$0], [LT_INIT])dnl
|
||||
AC_BEFORE([$0], [AC_PROG_LIBTOOL])dnl
|
||||
AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||
AC_REQUIRE_AUX_FILE([ar-lib])dnl
|
||||
AC_CHECK_TOOLS([AR], [ar lib "link -lib"], [false])
|
||||
: ${AR=ar}
|
||||
|
||||
AC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface],
|
||||
[AC_LANG_PUSH([C])
|
||||
am_cv_ar_interface=ar
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int some_variable = 0;]])],
|
||||
[am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
|
||||
AC_TRY_EVAL([am_ar_try])
|
||||
if test "$ac_status" -eq 0; then
|
||||
am_cv_ar_interface=ar
|
||||
else
|
||||
am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
|
||||
AC_TRY_EVAL([am_ar_try])
|
||||
if test "$ac_status" -eq 0; then
|
||||
am_cv_ar_interface=lib
|
||||
else
|
||||
am_cv_ar_interface=unknown
|
||||
fi
|
||||
fi
|
||||
rm -f conftest.lib libconftest.a
|
||||
])
|
||||
AC_LANG_POP([C])])
|
||||
|
||||
case $am_cv_ar_interface in
|
||||
ar)
|
||||
;;
|
||||
lib)
|
||||
# Microsoft lib, so override with the ar-lib wrapper script.
|
||||
# FIXME: It is wrong to rewrite AR.
|
||||
# But if we don't then we get into trouble of one sort or another.
|
||||
# A longer-term fix would be to have automake use am__AR in this case,
|
||||
# and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something
|
||||
# similar.
|
||||
AR="$am_aux_dir/ar-lib $AR"
|
||||
;;
|
||||
unknown)
|
||||
m4_default([$1],
|
||||
[AC_MSG_ERROR([could not determine $AR interface])])
|
||||
;;
|
||||
esac
|
||||
AC_SUBST([AR])dnl
|
||||
])
|
||||
|
||||
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
|
||||
@ -1159,6 +1219,5 @@ m4_include([m4/module-application.m4])
|
||||
m4_include([m4/module-defs.m4])
|
||||
m4_include([m4/module-env.m4])
|
||||
m4_include([m4/module-fs.m4])
|
||||
m4_include([m4/module-sanity.m4])
|
||||
m4_include([m4/module-signals.m4])
|
||||
m4_include([m4/runtime-tool.m4])
|
||||
|
270
admin/ar-lib
Executable file
270
admin/ar-lib
Executable file
@ -0,0 +1,270 @@
|
||||
#! /bin/sh
|
||||
# Wrapper for Microsoft lib.exe
|
||||
|
||||
me=ar-lib
|
||||
scriptversion=2012-03-01.08; # UTC
|
||||
|
||||
# Copyright (C) 2010-2013 Free Software Foundation, Inc.
|
||||
# Written by Peter Rosin <peda@lysator.liu.se>.
|
||||
#
|
||||
# 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>.
|
||||
|
||||
|
||||
# func_error message
|
||||
func_error ()
|
||||
{
|
||||
echo "$me: $1" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts.
|
||||
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 in
|
||||
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_at_file at_file operation archive
|
||||
# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE
|
||||
# for each of them.
|
||||
# When interpreting the content of the @FILE, do NOT use func_file_conv,
|
||||
# since the user would need to supply preconverted file names to
|
||||
# binutils ar, at least for MinGW.
|
||||
func_at_file ()
|
||||
{
|
||||
operation=$2
|
||||
archive=$3
|
||||
at_file_contents=`cat "$1"`
|
||||
eval set x "$at_file_contents"
|
||||
shift
|
||||
|
||||
for member
|
||||
do
|
||||
$AR -NOLOGO $operation:"$member" "$archive" || exit $?
|
||||
done
|
||||
}
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
func_error "no command. Try '$0 --help' for more information."
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<EOF
|
||||
Usage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]
|
||||
|
||||
Members may be specified in a file named with @FILE.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "$me, version $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
if test $# -lt 3; then
|
||||
func_error "you must specify a program, an action and an archive"
|
||||
fi
|
||||
|
||||
AR=$1
|
||||
shift
|
||||
while :
|
||||
do
|
||||
if test $# -lt 2; then
|
||||
func_error "you must specify a program, an action and an archive"
|
||||
fi
|
||||
case $1 in
|
||||
-lib | -LIB \
|
||||
| -ltcg | -LTCG \
|
||||
| -machine* | -MACHINE* \
|
||||
| -subsystem* | -SUBSYSTEM* \
|
||||
| -verbose | -VERBOSE \
|
||||
| -wx* | -WX* )
|
||||
AR="$AR $1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
action=$1
|
||||
shift
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
orig_archive=$1
|
||||
shift
|
||||
func_file_conv "$orig_archive"
|
||||
archive=$file
|
||||
|
||||
# strip leading dash in $action
|
||||
action=${action#-}
|
||||
|
||||
delete=
|
||||
extract=
|
||||
list=
|
||||
quick=
|
||||
replace=
|
||||
index=
|
||||
create=
|
||||
|
||||
while test -n "$action"
|
||||
do
|
||||
case $action in
|
||||
d*) delete=yes ;;
|
||||
x*) extract=yes ;;
|
||||
t*) list=yes ;;
|
||||
q*) quick=yes ;;
|
||||
r*) replace=yes ;;
|
||||
s*) index=yes ;;
|
||||
S*) ;; # the index is always updated implicitly
|
||||
c*) create=yes ;;
|
||||
u*) ;; # TODO: don't ignore the update modifier
|
||||
v*) ;; # TODO: don't ignore the verbose modifier
|
||||
*)
|
||||
func_error "unknown action specified"
|
||||
;;
|
||||
esac
|
||||
action=${action#?}
|
||||
done
|
||||
|
||||
case $delete$extract$list$quick$replace,$index in
|
||||
yes,* | ,yes)
|
||||
;;
|
||||
yesyes*)
|
||||
func_error "more than one action specified"
|
||||
;;
|
||||
*)
|
||||
func_error "no action specified"
|
||||
;;
|
||||
esac
|
||||
|
||||
if test -n "$delete"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
func_error "archive not found"
|
||||
fi
|
||||
for member
|
||||
do
|
||||
case $1 in
|
||||
@*)
|
||||
func_at_file "${1#@}" -REMOVE "$archive"
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$1"
|
||||
$AR -NOLOGO -REMOVE:"$file" "$archive" || exit $?
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
elif test -n "$extract"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
func_error "archive not found"
|
||||
fi
|
||||
if test $# -gt 0; then
|
||||
for member
|
||||
do
|
||||
case $1 in
|
||||
@*)
|
||||
func_at_file "${1#@}" -EXTRACT "$archive"
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$1"
|
||||
$AR -NOLOGO -EXTRACT:"$file" "$archive" || exit $?
|
||||
;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
$AR -NOLOGO -LIST "$archive" | sed -e 's/\\/\\\\/g' | while read member
|
||||
do
|
||||
$AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
|
||||
done
|
||||
fi
|
||||
|
||||
elif test -n "$quick$replace"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
if test -z "$create"; then
|
||||
echo "$me: creating $orig_archive"
|
||||
fi
|
||||
orig_archive=
|
||||
else
|
||||
orig_archive=$archive
|
||||
fi
|
||||
|
||||
for member
|
||||
do
|
||||
case $1 in
|
||||
@*)
|
||||
func_file_conv "${1#@}"
|
||||
set x "$@" "@$file"
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$1"
|
||||
set x "$@" "$file"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
shift
|
||||
done
|
||||
|
||||
if test -n "$orig_archive"; then
|
||||
$AR -NOLOGO -OUT:"$archive" "$orig_archive" "$@" || exit $?
|
||||
else
|
||||
$AR -NOLOGO -OUT:"$archive" "$@" || exit $?
|
||||
fi
|
||||
|
||||
elif test -n "$list"; then
|
||||
if test ! -f "$orig_archive"; then
|
||||
func_error "archive not found"
|
||||
fi
|
||||
$AR -NOLOGO -LIST "$archive" || exit $?
|
||||
fi
|
@ -102,12 +102,13 @@ find_sources() {
|
||||
\! -name "aclocal.m4" \
|
||||
\! -name "bconfig.h" \
|
||||
\! -name "defs.h" \
|
||||
\! -name "defs.hpp" \
|
||||
\! -name "libtool.m4" \
|
||||
\! -name "ltoptions.m4" \
|
||||
\! -name "ltsugar.m4" \
|
||||
\! -name "lt~obsolete.m4" \
|
||||
\! -name "*.so.*" \
|
||||
\)
|
||||
\) | grep -v tools/
|
||||
}
|
||||
|
||||
#
|
||||
|
@ -38,19 +38,17 @@ libatf_c___la_SOURCES = atf-c++/build.cpp \
|
||||
atf-c++/config.cpp \
|
||||
atf-c++/config.hpp \
|
||||
atf-c++/macros.hpp \
|
||||
atf-c++/noncopyable.hpp \
|
||||
atf-c++/tests.cpp \
|
||||
atf-c++/tests.hpp \
|
||||
atf-c++/utils.cpp \
|
||||
atf-c++/utils.hpp
|
||||
libatf_c___la_LDFLAGS = -version-info 0:0:0
|
||||
libatf_c___la_LDFLAGS = -version-info 1:0:0
|
||||
|
||||
include_HEADERS += atf-c++.hpp
|
||||
atf_c___HEADERS = atf-c++/build.hpp \
|
||||
atf-c++/check.hpp \
|
||||
atf-c++/config.hpp \
|
||||
atf-c++/macros.hpp \
|
||||
atf-c++/noncopyable.hpp \
|
||||
atf-c++/tests.hpp \
|
||||
atf-c++/utils.hpp
|
||||
atf_c__dir = $(includedir)/atf-c++
|
||||
|
@ -39,8 +39,6 @@ extern "C" {
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <atf-c++/noncopyable.hpp>
|
||||
|
||||
namespace atf {
|
||||
|
||||
namespace process {
|
||||
@ -60,7 +58,11 @@ namespace check {
|
||||
//! of executing arbitrary command and manages files containing
|
||||
//! its output.
|
||||
//!
|
||||
class check_result : noncopyable {
|
||||
class check_result {
|
||||
// Non-copyable.
|
||||
check_result(const check_result&);
|
||||
check_result& operator=(const check_result&);
|
||||
|
||||
//!
|
||||
//! \brief Internal representation of a result.
|
||||
//!
|
||||
|
@ -61,7 +61,7 @@ std::auto_ptr< atf::check::check_result >
|
||||
do_exec(const atf::tests::tc* tc, const char* helper_name)
|
||||
{
|
||||
std::vector< std::string > argv;
|
||||
argv.push_back(get_process_helpers_path(*tc).str());
|
||||
argv.push_back(get_process_helpers_path(*tc, false).str());
|
||||
argv.push_back(helper_name);
|
||||
std::cout << "Executing " << argv[0] << " " << argv[1] << "\n";
|
||||
|
||||
@ -74,7 +74,7 @@ std::auto_ptr< atf::check::check_result >
|
||||
do_exec(const atf::tests::tc* tc, const char* helper_name, const char *carg2)
|
||||
{
|
||||
std::vector< std::string > argv;
|
||||
argv.push_back(get_process_helpers_path(*tc).str());
|
||||
argv.push_back(get_process_helpers_path(*tc, false).str());
|
||||
argv.push_back(helper_name);
|
||||
argv.push_back(carg2);
|
||||
std::cout << "Executing " << argv[0] << " " << argv[1] << " "
|
||||
|
@ -52,18 +52,14 @@ init_variables(void)
|
||||
{
|
||||
PRE(m_variables.empty());
|
||||
|
||||
m_variables["atf_arch"] = atf_config_get("atf_arch");
|
||||
m_variables["atf_build_cc"] = atf_config_get("atf_build_cc");
|
||||
m_variables["atf_build_cflags"] = atf_config_get("atf_build_cflags");
|
||||
m_variables["atf_build_cpp"] = atf_config_get("atf_build_cpp");
|
||||
m_variables["atf_build_cppflags"] = atf_config_get("atf_build_cppflags");
|
||||
m_variables["atf_build_cxx"] = atf_config_get("atf_build_cxx");
|
||||
m_variables["atf_build_cxxflags"] = atf_config_get("atf_build_cxxflags");
|
||||
m_variables["atf_confdir"] = atf_config_get("atf_confdir");
|
||||
m_variables["atf_includedir"] = atf_config_get("atf_includedir");
|
||||
m_variables["atf_libdir"] = atf_config_get("atf_libdir");
|
||||
m_variables["atf_libexecdir"] = atf_config_get("atf_libexecdir");
|
||||
m_variables["atf_machine"] = atf_config_get("atf_machine");
|
||||
m_variables["atf_pkgdatadir"] = atf_config_get("atf_pkgdatadir");
|
||||
m_variables["atf_shell"] = atf_config_get("atf_shell");
|
||||
m_variables["atf_workdir"] = atf_config_get("atf_workdir");
|
||||
|
@ -44,18 +44,14 @@ static struct varnames {
|
||||
const char *uc;
|
||||
bool can_be_empty;
|
||||
} all_vars[] = {
|
||||
{ "atf_arch", "ATF_ARCH", false },
|
||||
{ "atf_build_cc", "ATF_BUILD_CC", false },
|
||||
{ "atf_build_cflags", "ATF_BUILD_CFLAGS", true },
|
||||
{ "atf_build_cpp", "ATF_BUILD_CPP", false },
|
||||
{ "atf_build_cppflags", "ATF_BUILD_CPPFLAGS", true },
|
||||
{ "atf_build_cxx", "ATF_BUILD_CXX", false },
|
||||
{ "atf_build_cxxflags", "ATF_BUILD_CXXFLAGS", true },
|
||||
{ "atf_confdir", "ATF_CONFDIR", false },
|
||||
{ "atf_includedir", "ATF_INCLUDEDIR", false },
|
||||
{ "atf_libdir", "ATF_LIBDIR", false },
|
||||
{ "atf_libexecdir", "ATF_LIBEXECDIR", false },
|
||||
{ "atf_machine", "ATF_MACHINE", false },
|
||||
{ "atf_pkgdatadir", "ATF_PKGDATADIR", false },
|
||||
{ "atf_shell", "ATF_SHELL", false },
|
||||
{ "atf_workdir", "ATF_WORKDIR", false },
|
||||
|
@ -6,9 +6,6 @@ tp: application_test
|
||||
tp: auto_array_test
|
||||
tp: env_test
|
||||
tp: exceptions_test
|
||||
tp: expand_test
|
||||
tp: fs_test
|
||||
tp: parser_test
|
||||
tp: sanity_test
|
||||
tp: text_test
|
||||
tp: ui_test
|
||||
|
@ -6,9 +6,7 @@ atf_test_program{name="application_test"}
|
||||
atf_test_program{name="auto_array_test"}
|
||||
atf_test_program{name="env_test"}
|
||||
atf_test_program{name="exceptions_test"}
|
||||
atf_test_program{name="expand_test"}
|
||||
atf_test_program{name="fs_test"}
|
||||
atf_test_program{name="parser_test"}
|
||||
atf_test_program{name="process_test"}
|
||||
atf_test_program{name="sanity_test"}
|
||||
atf_test_program{name="text_test"}
|
||||
atf_test_program{name="ui_test"}
|
||||
|
@ -34,19 +34,13 @@ libatf_c___la_SOURCES += atf-c++/detail/application.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
|
||||
atf-c++/detail/text.hpp
|
||||
|
||||
tests_atf_c___detail_DATA = atf-c++/detail/Atffile \
|
||||
atf-c++/detail/Kyuafile
|
||||
@ -73,18 +67,10 @@ 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)
|
||||
@ -97,8 +83,7 @@ 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)
|
||||
tests_atf_c___detail_PROGRAMS += atf-c++/detail/version_helper
|
||||
atf_c___detail_version_helper_SOURCES = atf-c++/detail/version_helper.cpp
|
||||
|
||||
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
|
||||
|
@ -47,7 +47,6 @@ extern "C" {
|
||||
|
||||
#include "application.hpp"
|
||||
#include "sanity.hpp"
|
||||
#include "ui.hpp"
|
||||
|
||||
#if !defined(HAVE_VSNPRINTF_IN_STD)
|
||||
namespace std {
|
||||
@ -106,17 +105,12 @@ impl::option::operator<(const impl::option& o)
|
||||
}
|
||||
|
||||
impl::app::app(const std::string& description,
|
||||
const std::string& manpage,
|
||||
const std::string& global_manpage,
|
||||
const bool use_ui) :
|
||||
m_hflag(false),
|
||||
const std::string& manpage) :
|
||||
m_argc(-1),
|
||||
m_argv(NULL),
|
||||
m_prog_name(NULL),
|
||||
m_description(description),
|
||||
m_manpage(manpage),
|
||||
m_global_manpage(global_manpage),
|
||||
m_use_ui(use_ui)
|
||||
m_manpage(manpage)
|
||||
{
|
||||
}
|
||||
|
||||
@ -133,11 +127,7 @@ impl::app::inited(void)
|
||||
impl::app::options_set
|
||||
impl::app::options(void)
|
||||
{
|
||||
options_set opts = specific_options();
|
||||
if (m_use_ui) {
|
||||
opts.insert(option('h', "", "Shows this help message"));
|
||||
}
|
||||
return opts;
|
||||
return specific_options();
|
||||
}
|
||||
|
||||
std::string
|
||||
@ -187,11 +177,6 @@ impl::app::process_options(void)
|
||||
::opterr = 0;
|
||||
while ((ch = ::getopt(m_argc, m_argv, optstr.c_str())) != -1) {
|
||||
switch (ch) {
|
||||
case 'h':
|
||||
INV(m_use_ui);
|
||||
m_hflag = true;
|
||||
break;
|
||||
|
||||
case ':':
|
||||
throw usage_error("Option -%c requires an argument.",
|
||||
::optopt);
|
||||
@ -214,51 +199,6 @@ impl::app::process_options(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
impl::app::usage(std::ostream& os)
|
||||
{
|
||||
PRE(inited());
|
||||
|
||||
std::string args = specific_args();
|
||||
if (!args.empty())
|
||||
args = " " + args;
|
||||
os << ui::format_text_with_tag(std::string(m_prog_name) + " [options]" +
|
||||
args, "Usage: ", false) << "\n\n"
|
||||
<< ui::format_text(m_description) << "\n\n";
|
||||
|
||||
options_set opts = options();
|
||||
INV(!opts.empty());
|
||||
os << "Available options:\n";
|
||||
size_t coldesc = 0;
|
||||
for (options_set::const_iterator iter = opts.begin();
|
||||
iter != opts.end(); iter++) {
|
||||
const option& opt = (*iter);
|
||||
|
||||
if (opt.m_argument.length() + 1 > coldesc)
|
||||
coldesc = opt.m_argument.length() + 1;
|
||||
}
|
||||
for (options_set::const_iterator iter = opts.begin();
|
||||
iter != opts.end(); iter++) {
|
||||
const option& opt = (*iter);
|
||||
|
||||
std::string tag = std::string(" -") + opt.m_character;
|
||||
if (opt.m_argument.empty())
|
||||
tag += " ";
|
||||
else
|
||||
tag += " " + opt.m_argument + " ";
|
||||
os << ui::format_text_with_tag(opt.m_description, tag, false,
|
||||
coldesc + 10) << "\n";
|
||||
}
|
||||
os << "\n";
|
||||
|
||||
std::string gmp;
|
||||
if (!m_global_manpage.empty())
|
||||
gmp = " and " + m_global_manpage;
|
||||
os << ui::format_text("For more details please see " + m_manpage +
|
||||
gmp + ".")
|
||||
<< "\n";
|
||||
}
|
||||
|
||||
int
|
||||
impl::app::run(int argc, char* const* argv)
|
||||
{
|
||||
@ -290,55 +230,22 @@ impl::app::run(int argc, char* const* argv)
|
||||
|
||||
int errcode;
|
||||
try {
|
||||
int oldargc = m_argc;
|
||||
|
||||
process_options();
|
||||
|
||||
if (m_hflag) {
|
||||
INV(m_use_ui);
|
||||
if (oldargc != 2)
|
||||
throw usage_error("-h must be given alone.");
|
||||
|
||||
usage(std::cout);
|
||||
errcode = EXIT_SUCCESS;
|
||||
} else
|
||||
errcode = main();
|
||||
errcode = main();
|
||||
} catch (const usage_error& e) {
|
||||
if (m_use_ui) {
|
||||
std::cerr << ui::format_error(m_prog_name, e.what()) << "\n"
|
||||
<< ui::format_info(m_prog_name, std::string("Type `") +
|
||||
m_prog_name + " -h' for more details.")
|
||||
<< "\n";
|
||||
} else {
|
||||
std::cerr << m_prog_name << ": ERROR: " << e.what() << "\n";
|
||||
std::cerr << m_prog_name << ": See " << m_manpage << " for usage "
|
||||
"details.\n";
|
||||
}
|
||||
std::cerr << m_prog_name << ": ERROR: " << e.what() << "\n";
|
||||
std::cerr << m_prog_name << ": See " << m_manpage << " for usage "
|
||||
"details.\n";
|
||||
errcode = EXIT_FAILURE;
|
||||
} catch (const std::runtime_error& e) {
|
||||
if (m_use_ui) {
|
||||
std::cerr << ui::format_error(m_prog_name, std::string(e.what()))
|
||||
<< "\n";
|
||||
} else {
|
||||
std::cerr << m_prog_name << ": ERROR: " << e.what() << "\n";
|
||||
}
|
||||
std::cerr << m_prog_name << ": ERROR: " << e.what() << "\n";
|
||||
errcode = EXIT_FAILURE;
|
||||
} catch (const std::exception& e) {
|
||||
if (m_use_ui) {
|
||||
std::cerr << ui::format_error(m_prog_name, std::string("Caught "
|
||||
"unexpected error: ") + e.what() + "\n" + bug) << "\n";
|
||||
} else {
|
||||
std::cerr << m_prog_name << ": ERROR: Caught unexpected error: "
|
||||
<< e.what() << "\n";
|
||||
}
|
||||
std::cerr << m_prog_name << ": ERROR: Caught unexpected error: "
|
||||
<< e.what() << "\n";
|
||||
errcode = EXIT_FAILURE;
|
||||
} catch (...) {
|
||||
if (m_use_ui) {
|
||||
std::cerr << ui::format_error(m_prog_name, std::string("Caught "
|
||||
"unknown error\n") + bug) << "\n";
|
||||
} else {
|
||||
std::cerr << m_prog_name << ": ERROR: Caught unknown error\n";
|
||||
}
|
||||
std::cerr << m_prog_name << ": ERROR: Caught unknown error\n";
|
||||
errcode = EXIT_FAILURE;
|
||||
}
|
||||
return errcode;
|
||||
|
@ -74,8 +74,6 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
class app {
|
||||
bool m_hflag;
|
||||
|
||||
void process_options(void);
|
||||
void usage(std::ostream&);
|
||||
|
||||
@ -90,8 +88,7 @@ protected:
|
||||
const char* m_argv0;
|
||||
const char* m_prog_name;
|
||||
std::string m_description;
|
||||
std::string m_manpage, m_global_manpage;
|
||||
const bool m_use_ui;
|
||||
std::string m_manpage;
|
||||
|
||||
options_set options(void);
|
||||
|
||||
@ -102,8 +99,7 @@ protected:
|
||||
virtual int main(void) = 0;
|
||||
|
||||
public:
|
||||
app(const std::string&, const std::string&, const std::string&,
|
||||
bool = true);
|
||||
app(const std::string&, const std::string&);
|
||||
virtual ~app(void);
|
||||
|
||||
int run(int, char* const*);
|
||||
|
@ -37,7 +37,7 @@ extern "C" {
|
||||
|
||||
class getopt_app : public atf::application::app {
|
||||
public:
|
||||
getopt_app(void) : app("description", "manpage", "other") {}
|
||||
getopt_app(void) : app("description", "manpage") {}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
@ -39,47 +39,6 @@ struct atf_error;
|
||||
|
||||
namespace atf {
|
||||
|
||||
template< class T >
|
||||
class not_found_error :
|
||||
public std::runtime_error
|
||||
{
|
||||
T m_value;
|
||||
|
||||
public:
|
||||
not_found_error(const std::string& message, const T& value) throw();
|
||||
|
||||
virtual ~not_found_error(void) throw();
|
||||
|
||||
const T& get_value(void) const throw();
|
||||
};
|
||||
|
||||
template< class T >
|
||||
inline
|
||||
not_found_error< T >::not_found_error(const std::string& message,
|
||||
const T& value)
|
||||
throw() :
|
||||
std::runtime_error(message),
|
||||
m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline
|
||||
not_found_error< T >::~not_found_error(void)
|
||||
throw()
|
||||
{
|
||||
}
|
||||
|
||||
template< class T >
|
||||
inline
|
||||
const T&
|
||||
not_found_error< T >::get_value(void)
|
||||
const
|
||||
throw()
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
class system_error : public std::runtime_error {
|
||||
int m_sys_err;
|
||||
mutable std::string m_message;
|
||||
|
@ -64,10 +64,10 @@ exec_process_helpers(const atf::tests::tc& tc, const char* helper_name)
|
||||
using atf::process::exec;
|
||||
|
||||
std::vector< std::string > argv;
|
||||
argv.push_back(get_process_helpers_path(tc).leaf_name());
|
||||
argv.push_back(get_process_helpers_path(tc, true).leaf_name());
|
||||
argv.push_back(helper_name);
|
||||
|
||||
return exec(get_process_helpers_path(tc),
|
||||
return exec(get_process_helpers_path(tc, true),
|
||||
atf::process::argv_array(argv),
|
||||
atf::process::stream_inherit(),
|
||||
atf::process::stream_inherit());
|
||||
|
@ -40,80 +40,64 @@
|
||||
#include "process.hpp"
|
||||
#include "test_helpers.hpp"
|
||||
|
||||
void
|
||||
build_check_cxx_o_aux(const atf::fs::path& sfile, const char* failmsg,
|
||||
const bool expect_pass)
|
||||
// Path to the directory containing the libatf-c tests, used to locate the
|
||||
// process_helpers program. If NULL (the default), the code will use a
|
||||
// relative path. Otherwise, the provided path will be used; this is so
|
||||
// that we can locate the helpers binary if the installation uses a
|
||||
// different layout than the one we provide (as is the case in FreeBSD).
|
||||
#if defined(ATF_C_TESTS_BASE)
|
||||
static const char* atf_c_tests_base = ATF_C_TESTS_BASE;
|
||||
#else
|
||||
static const char* atf_c_tests_base = NULL;
|
||||
#endif
|
||||
#undef ATF_C_TESTS_BASE
|
||||
|
||||
bool
|
||||
build_check_cxx_o(const char* sfile)
|
||||
{
|
||||
std::vector< std::string > optargs;
|
||||
optargs.push_back("-I" + atf::config::get("atf_includedir"));
|
||||
optargs.push_back("-Wall");
|
||||
optargs.push_back("-Werror");
|
||||
|
||||
const bool result = atf::check::build_cxx_o(
|
||||
sfile.str(), "test.o", atf::process::argv_array(optargs));
|
||||
if ((expect_pass && !result) || (!expect_pass && result))
|
||||
ATF_FAIL(failmsg);
|
||||
return atf::check::build_cxx_o(sfile, "test.o",
|
||||
atf::process::argv_array(optargs));
|
||||
}
|
||||
|
||||
void
|
||||
build_check_cxx_o(const atf::tests::tc& tc, const char* sfile,
|
||||
const char* failmsg, const bool expect_pass)
|
||||
bool
|
||||
build_check_cxx_o_srcdir(const atf::tests::tc& tc, const char* sfile)
|
||||
{
|
||||
const atf::fs::path sfilepath =
|
||||
atf::fs::path(tc.get_config_var("srcdir")) / sfile;
|
||||
build_check_cxx_o_aux(sfilepath, failmsg, expect_pass);
|
||||
return build_check_cxx_o(sfilepath.c_str());
|
||||
}
|
||||
|
||||
void
|
||||
header_check(const char *hdrname)
|
||||
{
|
||||
std::ofstream srcfile("test.c");
|
||||
std::ofstream srcfile("test.cpp");
|
||||
ATF_REQUIRE(srcfile);
|
||||
srcfile << "#include <" << hdrname << ">\n";
|
||||
srcfile.close();
|
||||
|
||||
const std::string failmsg = std::string("Header check failed; ") +
|
||||
hdrname + " is not self-contained";
|
||||
build_check_cxx_o_aux(atf::fs::path("test.c"), failmsg.c_str(), true);
|
||||
if (!build_check_cxx_o("test.cpp"))
|
||||
ATF_FAIL(failmsg);
|
||||
}
|
||||
|
||||
atf::fs::path
|
||||
get_process_helpers_path(const atf::tests::tc& tc)
|
||||
get_process_helpers_path(const atf::tests::tc& tc, bool is_detail)
|
||||
{
|
||||
return atf::fs::path(tc.get_config_var("srcdir")) /
|
||||
".." / "atf-c" / "detail" / "process_helpers";
|
||||
}
|
||||
|
||||
void
|
||||
test_helpers_detail::check_equal(const char* expected[],
|
||||
const string_vector& actual)
|
||||
{
|
||||
const char** expected_iter = expected;
|
||||
string_vector::const_iterator actual_iter = actual.begin();
|
||||
|
||||
bool equals = true;
|
||||
while (equals && *expected_iter != NULL && actual_iter != actual.end()) {
|
||||
if (*expected_iter != *actual_iter) {
|
||||
equals = false;
|
||||
} else {
|
||||
expected_iter++;
|
||||
actual_iter++;
|
||||
}
|
||||
}
|
||||
if (equals && ((*expected_iter == NULL && actual_iter != actual.end()) ||
|
||||
(*expected_iter != NULL && actual_iter == actual.end())))
|
||||
equals = false;
|
||||
|
||||
if (!equals) {
|
||||
std::cerr << "EXPECTED:\n";
|
||||
for (expected_iter = expected; *expected_iter != NULL; expected_iter++)
|
||||
std::cerr << *expected_iter << "\n";
|
||||
|
||||
std::cerr << "ACTUAL:\n";
|
||||
for (actual_iter = actual.begin(); actual_iter != actual.end();
|
||||
actual_iter++)
|
||||
std::cerr << *actual_iter << "\n";
|
||||
|
||||
ATF_FAIL("Expected results differ to actual values");
|
||||
const char* helper = "detail/process_helpers";
|
||||
if (atf_c_tests_base == NULL) {
|
||||
if (is_detail)
|
||||
return atf::fs::path(tc.get_config_var("srcdir")) /
|
||||
".." / ".." / "atf-c" / helper;
|
||||
else
|
||||
return atf::fs::path(tc.get_config_var("srcdir")) /
|
||||
".." / "atf-c" / helper;
|
||||
} else {
|
||||
return atf::fs::path(atf_c_tests_base) / helper;
|
||||
}
|
||||
}
|
||||
|
@ -40,9 +40,7 @@
|
||||
|
||||
#include "../macros.hpp"
|
||||
#include "../tests.hpp"
|
||||
#include "parser.hpp"
|
||||
#include "process.hpp"
|
||||
#include "text.hpp"
|
||||
|
||||
#define HEADER_TC(name, hdrname) \
|
||||
ATF_TEST_CASE(name); \
|
||||
@ -64,18 +62,8 @@
|
||||
} \
|
||||
ATF_TEST_CASE_BODY(name) \
|
||||
{ \
|
||||
build_check_cxx_o(*this, sfile, failmsg, true); \
|
||||
}
|
||||
|
||||
#define BUILD_TC_FAIL(name, sfile, descr, failmsg) \
|
||||
ATF_TEST_CASE(name); \
|
||||
ATF_TEST_CASE_HEAD(name) \
|
||||
{ \
|
||||
set_md_var("descr", descr); \
|
||||
} \
|
||||
ATF_TEST_CASE_BODY(name) \
|
||||
{ \
|
||||
build_check_cxx_o(*this, sfile, failmsg, false); \
|
||||
if (!build_check_cxx_o_srcdir(*this, sfile)) \
|
||||
ATF_FAIL(failmsg); \
|
||||
}
|
||||
|
||||
namespace atf {
|
||||
@ -85,8 +73,9 @@ 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 build_check_cxx_o(const char*);
|
||||
bool build_check_cxx_o_srcdir(const atf::tests::tc&, const char*);
|
||||
atf::fs::path get_process_helpers_path(const atf::tests::tc&, bool);
|
||||
|
||||
struct run_h_tc_data {
|
||||
const atf::tests::vars_map& m_config;
|
||||
@ -120,45 +109,3 @@ run_h_tc(atf::tests::vars_map config = atf::tests::vars_map())
|
||||
const atf::process::status s = c.wait();
|
||||
ATF_REQUIRE(s.exited());
|
||||
}
|
||||
|
||||
namespace test_helpers_detail {
|
||||
|
||||
typedef std::vector< std::string > string_vector;
|
||||
|
||||
template< class Reader >
|
||||
std::pair< string_vector, string_vector >
|
||||
do_read(const char* input)
|
||||
{
|
||||
string_vector errors;
|
||||
|
||||
std::istringstream is(input);
|
||||
Reader reader(is);
|
||||
try {
|
||||
reader.read();
|
||||
} catch (const atf::parser::parse_errors& pes) {
|
||||
for (std::vector< atf::parser::parse_error >::const_iterator iter =
|
||||
pes.begin(); iter != pes.end(); iter++)
|
||||
errors.push_back(*iter);
|
||||
} catch (const atf::parser::parse_error& pe) {
|
||||
ATF_FAIL("Raised a lonely parse error: " +
|
||||
atf::text::to_string(pe.first) + ": " + pe.second);
|
||||
}
|
||||
|
||||
return std::make_pair(reader.m_calls, errors);
|
||||
}
|
||||
|
||||
void check_equal(const char*[], const string_vector&);
|
||||
|
||||
} // namespace test_helpers_detail
|
||||
|
||||
template< class Reader >
|
||||
void
|
||||
do_parser_test(const char* input, const char* exp_calls[],
|
||||
const char* exp_errors[])
|
||||
{
|
||||
const std::pair< test_helpers_detail::string_vector,
|
||||
test_helpers_detail::string_vector >
|
||||
actual = test_helpers_detail::do_read< Reader >(input);
|
||||
test_helpers_detail::check_equal(exp_calls, actual.first);
|
||||
test_helpers_detail::check_equal(exp_errors, actual.second);
|
||||
}
|
||||
|
41
atf-c++/detail/version_helper.cpp
Normal file
41
atf-c++/detail/version_helper.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright 2014 Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its contributors
|
||||
// may be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "bconfig.h"
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
std::cout << PACKAGE_VERSION << "\n";
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -763,11 +763,30 @@ BUILD_TC(use, "macros_hpp_test.cpp",
|
||||
"do not cause syntax errors when used",
|
||||
"Build of macros_hpp_test.cpp failed; some macros in "
|
||||
"atf-c++/macros.hpp are broken");
|
||||
BUILD_TC_FAIL(detect_unused_tests, "unused_test.cpp",
|
||||
"Tests that defining an unused test case raises a warning (and thus "
|
||||
"an error)",
|
||||
"Build of unused_test.cpp passed; unused test cases are not properly "
|
||||
"detected");
|
||||
|
||||
ATF_TEST_CASE(detect_unused_tests);
|
||||
ATF_TEST_CASE_HEAD(detect_unused_tests)
|
||||
{
|
||||
set_md_var("descr",
|
||||
"Tests that defining an unused test case raises a warning (and "
|
||||
"thus an error)");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(detect_unused_tests)
|
||||
{
|
||||
const char* validate_compiler =
|
||||
"class test_class { public: int dummy; };\n"
|
||||
"#define define_unused static test_class unused\n"
|
||||
"define_unused;\n";
|
||||
|
||||
atf::utils::create_file("compiler_test.cpp", validate_compiler);
|
||||
if (build_check_cxx_o("compiler_test.cpp"))
|
||||
expect_fail("Compiler does not raise a warning on an unused "
|
||||
"static global variable declared by a macro");
|
||||
|
||||
if (build_check_cxx_o_srcdir(*this, "unused_test.cpp"))
|
||||
ATF_FAIL("Build of unused_test.cpp passed; unused test cases are "
|
||||
"not properly detected");
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Main.
|
||||
|
@ -43,10 +43,8 @@ require_pc()
|
||||
|
||||
check_version()
|
||||
{
|
||||
atf_check -s eq:0 -o save:stdout -e empty -x \
|
||||
"atf-version | head -n 1 | cut -d ' ' -f 4"
|
||||
ver1=$(cat stdout)
|
||||
echo "Version reported by atf-version: ${ver1}"
|
||||
ver1=$($(atf_get_srcdir)/detail/version_helper)
|
||||
echo "Version reported by builtin PACKAGE_VERSION: ${ver1}"
|
||||
|
||||
atf_check -s eq:0 -o save:stdout -e empty pkg-config --modversion "${1}"
|
||||
ver2=$(cat stdout)
|
||||
@ -59,7 +57,7 @@ atf_test_case version
|
||||
version_head()
|
||||
{
|
||||
atf_set "descr" "Checks that the version in atf-c++ is correct"
|
||||
atf_set "require.progs" "atf-version pkg-config"
|
||||
atf_set "require.progs" "pkg-config"
|
||||
}
|
||||
version_body()
|
||||
{
|
||||
|
@ -55,7 +55,6 @@ extern "C" {
|
||||
#include "atf-c/utils.h"
|
||||
}
|
||||
|
||||
#include "noncopyable.hpp"
|
||||
#include "tests.hpp"
|
||||
|
||||
#include "detail/application.hpp"
|
||||
@ -63,7 +62,6 @@ extern "C" {
|
||||
#include "detail/env.hpp"
|
||||
#include "detail/exceptions.hpp"
|
||||
#include "detail/fs.hpp"
|
||||
#include "detail/parser.hpp"
|
||||
#include "detail/sanity.hpp"
|
||||
#include "detail/text.hpp"
|
||||
|
||||
@ -79,12 +77,7 @@ detail::atf_tp_writer::atf_tp_writer(std::ostream& os) :
|
||||
m_os(os),
|
||||
m_is_first(true)
|
||||
{
|
||||
atf::parser::headers_map hm;
|
||||
atf::parser::attrs_map ct_attrs;
|
||||
ct_attrs["version"] = "1";
|
||||
hm["Content-Type"] = atf::parser::header_entry("Content-Type",
|
||||
"application/X-atf-tp", ct_attrs);
|
||||
atf::parser::write_headers(hm, m_os);
|
||||
m_os << "Content-Type: application/X-atf-tp; version=\"1\"\n\n";
|
||||
}
|
||||
|
||||
void
|
||||
@ -129,7 +122,13 @@ 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::noncopyable {
|
||||
struct impl::tc_impl {
|
||||
private:
|
||||
// Non-copyable.
|
||||
tc_impl(const tc_impl&);
|
||||
tc_impl& operator=(const tc_impl&);
|
||||
|
||||
public:
|
||||
std::string m_ident;
|
||||
atf_tc_t m_tc;
|
||||
bool m_has_cleanup;
|
||||
@ -435,7 +434,7 @@ const char* tp::m_description =
|
||||
"This is an independent atf test program.";
|
||||
|
||||
tp::tp(void (*add_tcs)(tc_vector&)) :
|
||||
app(m_description, "atf-test-program(1)", "atf(7)", false),
|
||||
app(m_description, "atf-test-program(1)"),
|
||||
m_lflag(false),
|
||||
m_resfile("/dev/stdout"),
|
||||
m_srcdir("."),
|
||||
|
@ -38,8 +38,6 @@ extern "C" {
|
||||
#include <atf-c/defs.h>
|
||||
}
|
||||
|
||||
#include <atf-c++/noncopyable.hpp>
|
||||
|
||||
namespace atf {
|
||||
namespace tests {
|
||||
|
||||
@ -74,7 +72,11 @@ typedef std::map< std::string, std::string > vars_map;
|
||||
|
||||
struct tc_impl;
|
||||
|
||||
class tc : noncopyable {
|
||||
class tc {
|
||||
// Non-copyable.
|
||||
tc(const tc&);
|
||||
tc& operator=(const tc&);
|
||||
|
||||
std::auto_ptr< tc_impl > pimpl;
|
||||
|
||||
protected:
|
||||
|
@ -40,8 +40,8 @@ extern "C" {
|
||||
|
||||
#include "macros.hpp"
|
||||
|
||||
#include "detail/parser.hpp"
|
||||
#include "detail/test_helpers.hpp"
|
||||
#include "detail/text.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Tests for the "atf_tp_writer" class.
|
||||
|
@ -45,28 +45,22 @@ libatf_c_la_SOURCES = atf-c/build.c \
|
||||
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)\"" \
|
||||
libatf_c_la_CPPFLAGS = "-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
|
||||
"-DATF_WORKDIR=\"$(ATF_WORKDIR)\""
|
||||
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
|
||||
DIST_HOOKS += kill-defs-h
|
||||
kill-defs-h:
|
||||
rm -f $(distdir)/atf-c/defs.h
|
||||
|
||||
|
@ -45,18 +45,14 @@ static struct var {
|
||||
const char *value;
|
||||
bool can_be_empty;
|
||||
} vars[] = {
|
||||
{ "atf_arch", ATF_ARCH, NULL, false, },
|
||||
{ "atf_build_cc", ATF_BUILD_CC, NULL, false, },
|
||||
{ "atf_build_cflags", ATF_BUILD_CFLAGS, NULL, true, },
|
||||
{ "atf_build_cpp", ATF_BUILD_CPP, NULL, false, },
|
||||
{ "atf_build_cppflags", ATF_BUILD_CPPFLAGS, NULL, true, },
|
||||
{ "atf_build_cxx", ATF_BUILD_CXX, NULL, false, },
|
||||
{ "atf_build_cxxflags", ATF_BUILD_CXXFLAGS, NULL, true, },
|
||||
{ "atf_confdir", ATF_CONFDIR, NULL, false, },
|
||||
{ "atf_includedir", ATF_INCLUDEDIR, NULL, false, },
|
||||
{ "atf_libdir", ATF_LIBDIR, NULL, false, },
|
||||
{ "atf_libexecdir", ATF_LIBEXECDIR, NULL, false, },
|
||||
{ "atf_machine", ATF_MACHINE, NULL, false, },
|
||||
{ "atf_pkgdatadir", ATF_PKGDATADIR, NULL, false, },
|
||||
{ "atf_shell", ATF_SHELL, NULL, false, },
|
||||
{ "atf_workdir", ATF_WORKDIR, NULL, false, },
|
||||
|
@ -44,18 +44,14 @@ static struct varnames {
|
||||
const char *uc;
|
||||
bool can_be_empty;
|
||||
} all_vars[] = {
|
||||
{ "atf_arch", "ATF_ARCH", false },
|
||||
{ "atf_build_cc", "ATF_BUILD_CC", false },
|
||||
{ "atf_build_cflags", "ATF_BUILD_CFLAGS", true },
|
||||
{ "atf_build_cpp", "ATF_BUILD_CPP", false },
|
||||
{ "atf_build_cppflags", "ATF_BUILD_CPPFLAGS", true },
|
||||
{ "atf_build_cxx", "ATF_BUILD_CXX", false },
|
||||
{ "atf_build_cxxflags", "ATF_BUILD_CXXFLAGS", true },
|
||||
{ "atf_confdir", "ATF_CONFDIR", false },
|
||||
{ "atf_includedir", "ATF_INCLUDEDIR", false },
|
||||
{ "atf_libdir", "ATF_LIBDIR", false },
|
||||
{ "atf_libexecdir", "ATF_LIBEXECDIR", false },
|
||||
{ "atf_machine", "ATF_MACHINE", false },
|
||||
{ "atf_pkgdatadir", "ATF_PKGDATADIR", false },
|
||||
{ "atf_shell", "ATF_SHELL", false },
|
||||
{ "atf_workdir", "ATF_WORKDIR", false },
|
||||
|
@ -96,4 +96,7 @@ 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
|
||||
|
||||
tests_atf_c_detail_PROGRAMS += atf-c/detail/version_helper
|
||||
atf_c_detail_version_helper_SOURCES = atf-c/detail/version_helper.c
|
||||
|
||||
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
|
||||
|
@ -43,10 +43,8 @@
|
||||
#include "process.h"
|
||||
#include "test_helpers.h"
|
||||
|
||||
static
|
||||
void
|
||||
build_check_c_o_aux(const char *path, const char *failmsg,
|
||||
const bool expect_pass)
|
||||
bool
|
||||
build_check_c_o(const char *path)
|
||||
{
|
||||
bool success;
|
||||
atf_dynstr_t iflag;
|
||||
@ -63,20 +61,19 @@ build_check_c_o_aux(const char *path, const char *failmsg,
|
||||
|
||||
atf_dynstr_fini(&iflag);
|
||||
|
||||
if ((expect_pass && !success) || (!expect_pass && success))
|
||||
atf_tc_fail("%s", failmsg);
|
||||
return success;
|
||||
}
|
||||
|
||||
void
|
||||
build_check_c_o(const atf_tc_t *tc, const char *sfile, const char *failmsg,
|
||||
const bool expect_pass)
|
||||
bool
|
||||
build_check_c_o_srcdir(const atf_tc_t *tc, const char *sfile)
|
||||
{
|
||||
atf_fs_path_t path;
|
||||
|
||||
RE(atf_fs_path_init_fmt(&path, "%s/%s",
|
||||
atf_tc_get_config_var(tc, "srcdir"), sfile));
|
||||
build_check_c_o_aux(atf_fs_path_cstring(&path), failmsg, expect_pass);
|
||||
const bool result = build_check_c_o(atf_fs_path_cstring(&path));
|
||||
atf_fs_path_fini(&path);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
@ -93,7 +90,8 @@ header_check(const char *hdrname)
|
||||
snprintf(failmsg, sizeof(failmsg),
|
||||
"Header check failed; %s is not self-contained", hdrname);
|
||||
|
||||
build_check_c_o_aux("test.c", failmsg, true);
|
||||
if (!build_check_c_o("test.c"))
|
||||
atf_tc_fail("%s", failmsg);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -63,21 +63,12 @@ struct atf_fs_path;
|
||||
} \
|
||||
ATF_TC_BODY(name, tc) \
|
||||
{ \
|
||||
build_check_c_o(tc, sfile, failmsg, true); \
|
||||
if (!build_check_c_o_srcdir(tc, sfile)) \
|
||||
atf_tc_fail("%s", failmsg); \
|
||||
}
|
||||
|
||||
#define BUILD_TC_FAIL(name, sfile, descr, failmsg) \
|
||||
ATF_TC(name); \
|
||||
ATF_TC_HEAD(name, tc) \
|
||||
{ \
|
||||
atf_tc_set_md_var(tc, "descr", descr); \
|
||||
} \
|
||||
ATF_TC_BODY(name, tc) \
|
||||
{ \
|
||||
build_check_c_o(tc, sfile, failmsg, false); \
|
||||
}
|
||||
|
||||
void build_check_c_o(const atf_tc_t *, const char *, const char *, const bool);
|
||||
bool build_check_c_o(const char *);
|
||||
bool build_check_c_o_srcdir(const atf_tc_t *, const char *);
|
||||
void header_check(const char *);
|
||||
void get_process_helpers_path(const atf_tc_t *, const bool,
|
||||
struct atf_fs_path *);
|
||||
|
43
atf-c/detail/version_helper.c
Normal file
43
atf-c/detail/version_helper.c
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2014 Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Google Inc. nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "bconfig.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
printf("%s\n", PACKAGE_VERSION);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
@ -843,11 +843,30 @@ BUILD_TC(use, "macros_h_test.c",
|
||||
"do not cause syntax errors when used",
|
||||
"Build of macros_h_test.c failed; some macros in atf-c/macros.h "
|
||||
"are broken");
|
||||
BUILD_TC_FAIL(detect_unused_tests, "unused_test.c",
|
||||
"Tests that defining an unused test case raises a warning (and thus "
|
||||
"an error)",
|
||||
"Build of unused_test.c passed; unused test cases are not properly "
|
||||
"detected");
|
||||
|
||||
ATF_TC(detect_unused_tests);
|
||||
ATF_TC_HEAD(detect_unused_tests, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr",
|
||||
"Tests that defining an unused test case raises a "
|
||||
"warning (and thus an error)");
|
||||
}
|
||||
ATF_TC_BODY(detect_unused_tests, tc)
|
||||
{
|
||||
const char* validate_compiler =
|
||||
"struct test_struct { int dummy; };\n"
|
||||
"#define define_unused static struct test_struct unused\n"
|
||||
"define_unused;\n";
|
||||
|
||||
atf_utils_create_file("compiler_test.c", "%s", validate_compiler);
|
||||
if (build_check_c_o("compiler_test.c"))
|
||||
atf_tc_expect_fail("Compiler does not raise a warning on an unused "
|
||||
"static global variable declared by a macro");
|
||||
|
||||
if (build_check_c_o_srcdir(tc, "unused_test.c"))
|
||||
atf_tc_fail("Build of unused_test.c passed; unused test cases are "
|
||||
"not properly detected");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
* Main.
|
||||
|
@ -43,10 +43,8 @@ require_pc()
|
||||
|
||||
check_version()
|
||||
{
|
||||
atf_check -s eq:0 -o save:stdout -e empty -x \
|
||||
"atf-version | head -n 1 | cut -d ' ' -f 4"
|
||||
ver1=$(cat stdout)
|
||||
echo "Version reported by atf-version: ${ver1}"
|
||||
ver1=$($(atf_get_srcdir)/detail/version_helper)
|
||||
echo "Version reported by builtin PACKAGE_VERSION: ${ver1}"
|
||||
|
||||
atf_check -s eq:0 -o save:stdout -e empty pkg-config --modversion "${1}"
|
||||
ver2=$(cat stdout)
|
||||
@ -59,7 +57,7 @@ atf_test_case version
|
||||
version_head()
|
||||
{
|
||||
atf_set "descr" "Checks that the version in atf-c is correct"
|
||||
atf_set "require.progs" "atf-version pkg-config"
|
||||
atf_set "require.progs" "pkg-config"
|
||||
}
|
||||
version_body()
|
||||
{
|
||||
|
@ -1,5 +0,0 @@
|
||||
Content-Type: application/X-atf-atffile; version="1"
|
||||
|
||||
prop: test-suite = atf
|
||||
|
||||
tp-glob: *_test
|
@ -1,5 +0,0 @@
|
||||
syntax("kyuafile", 1)
|
||||
|
||||
test_suite("atf")
|
||||
|
||||
atf_test_program{name="integration_test"}
|
@ -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,5 +0,0 @@
|
||||
Content-Type: application/X-atf-atffile; version="1"
|
||||
|
||||
prop: test-suite = atf
|
||||
|
||||
tp-glob: *_test
|
@ -1,6 +0,0 @@
|
||||
syntax("kyuafile", 1)
|
||||
|
||||
test_suite("atf")
|
||||
|
||||
atf_test_program{name="integration_test"}
|
||||
atf_test_program{name="reader_test"}
|
@ -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
|
@ -1,5 +0,0 @@
|
||||
Content-Type: application/X-atf-atffile; version="1"
|
||||
|
||||
prop: test-suite = atf
|
||||
|
||||
tp-glob: *_test
|
@ -1,13 +0,0 @@
|
||||
syntax("kyuafile", 1)
|
||||
|
||||
test_suite("atf")
|
||||
|
||||
atf_test_program{name="atffile_test"}
|
||||
atf_test_program{name="config_test"}
|
||||
atf_test_program{name="fs_test"}
|
||||
atf_test_program{name="integration_test"}
|
||||
atf_test_program{name="io_test"}
|
||||
atf_test_program{name="requirements_test"}
|
||||
atf_test_program{name="signals_test"}
|
||||
atf_test_program{name="test_program_test"}
|
||||
atf_test_program{name="user_test"}
|
@ -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
|
265
atf-run/fs.cpp
265
atf-run/fs.cpp
@ -1,265 +0,0 @@
|
||||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "bconfig.h"
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <unistd.h>
|
||||
}
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "atf-c++/detail/auto_array.hpp"
|
||||
#include "atf-c++/detail/process.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
|
||||
#include "fs.hpp"
|
||||
#include "user.hpp"
|
||||
|
||||
namespace impl = atf::atf_run;
|
||||
#define IMPL_NAME "atf::atf_run"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Auxiliary functions.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
static void cleanup_aux(const atf::fs::path&, dev_t, bool);
|
||||
static void cleanup_aux_dir(const atf::fs::path&, const atf::fs::file_info&,
|
||||
bool);
|
||||
static void do_unmount(const atf::fs::path&);
|
||||
|
||||
// The cleanup routines below are tricky: they are executed immediately after
|
||||
// a test case's death, and after we have forcibly killed any stale processes.
|
||||
// However, even if the processes are dead, this does not mean that the file
|
||||
// system we are scanning is stable. In particular, if the test case has
|
||||
// mounted file systems through fuse/puffs, the fact that the processes died
|
||||
// does not mean that the file system is truly unmounted.
|
||||
//
|
||||
// The code below attempts to cope with this by catching errors and either
|
||||
// ignoring them or retrying the actions on the same file/directory a few times
|
||||
// before giving up.
|
||||
static const int max_retries = 5;
|
||||
static const int retry_delay_in_seconds = 1;
|
||||
|
||||
// The erase parameter in this routine is to control nested mount points.
|
||||
// We want to descend into a mount point to unmount anything that is
|
||||
// mounted under it, but we do not want to delete any files while doing
|
||||
// this traversal. In other words, we erase files until we cross the
|
||||
// first mount point, and after that point we only scan and unmount.
|
||||
static
|
||||
void
|
||||
cleanup_aux(const atf::fs::path& p, dev_t parent_device, bool erase)
|
||||
{
|
||||
try {
|
||||
atf::fs::file_info fi(p);
|
||||
|
||||
if (fi.get_type() == atf::fs::file_info::dir_type)
|
||||
cleanup_aux_dir(p, fi, fi.get_device() == parent_device);
|
||||
|
||||
if (fi.get_device() != parent_device)
|
||||
do_unmount(p);
|
||||
|
||||
if (erase) {
|
||||
if (fi.get_type() == atf::fs::file_info::dir_type)
|
||||
atf::fs::rmdir(p);
|
||||
else
|
||||
atf::fs::remove(p);
|
||||
}
|
||||
} catch (const atf::system_error& e) {
|
||||
if (e.code() != ENOENT && e.code() != ENOTDIR)
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
cleanup_aux_dir(const atf::fs::path& p, const atf::fs::file_info& fi,
|
||||
bool erase)
|
||||
{
|
||||
if (erase && ((fi.get_mode() & S_IRWXU) != S_IRWXU)) {
|
||||
int retries = max_retries;
|
||||
retry_chmod:
|
||||
if (chmod(p.c_str(), fi.get_mode() | S_IRWXU) == -1) {
|
||||
if (retries > 0) {
|
||||
retries--;
|
||||
::sleep(retry_delay_in_seconds);
|
||||
goto retry_chmod;
|
||||
} else {
|
||||
throw atf::system_error(IMPL_NAME "::cleanup(" +
|
||||
p.str() + ")", "chmod(2) failed",
|
||||
errno);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::set< std::string > subdirs;
|
||||
{
|
||||
bool ok = false;
|
||||
int retries = max_retries;
|
||||
while (!ok) {
|
||||
INV(retries > 0);
|
||||
try {
|
||||
const atf::fs::directory d(p);
|
||||
subdirs = d.names();
|
||||
ok = true;
|
||||
} catch (const atf::system_error& e) {
|
||||
retries--;
|
||||
if (retries == 0)
|
||||
throw e;
|
||||
::sleep(retry_delay_in_seconds);
|
||||
}
|
||||
}
|
||||
INV(ok);
|
||||
}
|
||||
|
||||
for (std::set< std::string >::const_iterator iter = subdirs.begin();
|
||||
iter != subdirs.end(); iter++) {
|
||||
const std::string& name = *iter;
|
||||
if (name != "." && name != "..")
|
||||
cleanup_aux(p / name, fi.get_device(), erase);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
do_unmount(const atf::fs::path& in_path)
|
||||
{
|
||||
// At least, FreeBSD's unmount(2) requires the path to be absolute.
|
||||
// Let's make it absolute in all cases just to be safe that this does
|
||||
// not affect other systems.
|
||||
const atf::fs::path& abs_path = in_path.is_absolute() ?
|
||||
in_path : in_path.to_absolute();
|
||||
|
||||
#if defined(HAVE_UNMOUNT)
|
||||
int retries = max_retries;
|
||||
retry_unmount:
|
||||
if (unmount(abs_path.c_str(), 0) == -1) {
|
||||
if (errno == EBUSY && retries > 0) {
|
||||
retries--;
|
||||
::sleep(retry_delay_in_seconds);
|
||||
goto retry_unmount;
|
||||
} else {
|
||||
throw atf::system_error(IMPL_NAME "::cleanup(" + in_path.str() +
|
||||
")", "unmount(2) failed", errno);
|
||||
}
|
||||
}
|
||||
#else
|
||||
// We could use umount(2) instead if it was available... but
|
||||
// trying to do so under, e.g. Linux, is a nightmare because we
|
||||
// also have to update /etc/mtab to match what we did. It is
|
||||
// satf::fser to just leave the system-specific umount(8) tool deal
|
||||
// with it, at least for now.
|
||||
|
||||
const atf::fs::path prog("umount");
|
||||
atf::process::argv_array argv("umount", abs_path.c_str(), NULL);
|
||||
|
||||
atf::process::status s = atf::process::exec(prog, argv,
|
||||
atf::process::stream_inherit(), atf::process::stream_inherit());
|
||||
if (!s.exited() || s.exitstatus() != EXIT_SUCCESS)
|
||||
throw std::runtime_error("Call to unmount failed");
|
||||
#endif
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// The "temp_dir" class.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
impl::temp_dir::temp_dir(const atf::fs::path& p)
|
||||
{
|
||||
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(" +
|
||||
p.str() + ")", "mkdtemp(3) failed",
|
||||
errno);
|
||||
|
||||
m_path.reset(new atf::fs::path(buf.get()));
|
||||
}
|
||||
|
||||
impl::temp_dir::~temp_dir(void)
|
||||
{
|
||||
cleanup(*m_path);
|
||||
}
|
||||
|
||||
const atf::fs::path&
|
||||
impl::temp_dir::get_path(void)
|
||||
const
|
||||
{
|
||||
return *m_path;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Free functions.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
atf::fs::path
|
||||
impl::change_directory(const atf::fs::path& dir)
|
||||
{
|
||||
atf::fs::path olddir = get_current_dir();
|
||||
|
||||
if (olddir != dir) {
|
||||
if (::chdir(dir.c_str()) == -1)
|
||||
throw system_error(IMPL_NAME "::chdir(" + dir.str() + ")",
|
||||
"chdir(2) failed", errno);
|
||||
}
|
||||
|
||||
return olddir;
|
||||
}
|
||||
|
||||
void
|
||||
impl::cleanup(const atf::fs::path& p)
|
||||
{
|
||||
atf::fs::file_info fi(p);
|
||||
cleanup_aux(p, fi.get_device(), true);
|
||||
}
|
||||
|
||||
atf::fs::path
|
||||
impl::get_current_dir(void)
|
||||
{
|
||||
std::auto_ptr< char > cwd;
|
||||
#if defined(HAVE_GETCWD_DYN)
|
||||
cwd.reset(getcwd(NULL, 0));
|
||||
#else
|
||||
cwd.reset(getcwd(NULL, MAXPATHLEN));
|
||||
#endif
|
||||
if (cwd.get() == NULL)
|
||||
throw atf::system_error(IMPL_NAME "::get_current_dir()",
|
||||
"getcwd() failed", errno);
|
||||
|
||||
return atf::fs::path(cwd.get());
|
||||
}
|
@ -1,260 +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.
|
||||
//
|
||||
|
||||
extern "C" {
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
}
|
||||
|
||||
#include <cerrno>
|
||||
#include <fstream>
|
||||
|
||||
#include "atf-c++/macros.hpp"
|
||||
|
||||
#include "atf-c++/detail/exceptions.hpp"
|
||||
#include "atf-c++/detail/fs.hpp"
|
||||
|
||||
#include "fs.hpp"
|
||||
#include "user.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Auxiliary functions.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
static
|
||||
void
|
||||
create_file(const char *name)
|
||||
{
|
||||
std::ofstream os(name);
|
||||
os.close();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Test cases for the "temp_dir" class.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
ATF_TEST_CASE(temp_dir_raii);
|
||||
ATF_TEST_CASE_HEAD(temp_dir_raii)
|
||||
{
|
||||
set_md_var("descr", "Tests the RAII behavior of the temp_dir class");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(temp_dir_raii)
|
||||
{
|
||||
using atf::atf_run::temp_dir;
|
||||
|
||||
atf::fs::path t1("non-existent");
|
||||
atf::fs::path t2("non-existent");
|
||||
|
||||
{
|
||||
atf::fs::path tmpl("testdir.XXXXXX");
|
||||
temp_dir td1(tmpl);
|
||||
temp_dir td2(tmpl);
|
||||
t1 = td1.get_path();
|
||||
t2 = td2.get_path();
|
||||
ATF_REQUIRE(t1.str().find("XXXXXX") == std::string::npos);
|
||||
ATF_REQUIRE(t2.str().find("XXXXXX") == std::string::npos);
|
||||
ATF_REQUIRE(t1 != t2);
|
||||
ATF_REQUIRE(!atf::fs::exists(tmpl));
|
||||
ATF_REQUIRE( atf::fs::exists(t1));
|
||||
ATF_REQUIRE( atf::fs::exists(t2));
|
||||
|
||||
atf::fs::file_info fi1(t1);
|
||||
ATF_REQUIRE( fi1.is_owner_readable());
|
||||
ATF_REQUIRE( fi1.is_owner_writable());
|
||||
ATF_REQUIRE( fi1.is_owner_executable());
|
||||
ATF_REQUIRE(!fi1.is_group_readable());
|
||||
ATF_REQUIRE(!fi1.is_group_writable());
|
||||
ATF_REQUIRE(!fi1.is_group_executable());
|
||||
ATF_REQUIRE(!fi1.is_other_readable());
|
||||
ATF_REQUIRE(!fi1.is_other_writable());
|
||||
ATF_REQUIRE(!fi1.is_other_executable());
|
||||
|
||||
atf::fs::file_info fi2(t2);
|
||||
ATF_REQUIRE( fi2.is_owner_readable());
|
||||
ATF_REQUIRE( fi2.is_owner_writable());
|
||||
ATF_REQUIRE( fi2.is_owner_executable());
|
||||
ATF_REQUIRE(!fi2.is_group_readable());
|
||||
ATF_REQUIRE(!fi2.is_group_writable());
|
||||
ATF_REQUIRE(!fi2.is_group_executable());
|
||||
ATF_REQUIRE(!fi2.is_other_readable());
|
||||
ATF_REQUIRE(!fi2.is_other_writable());
|
||||
ATF_REQUIRE(!fi2.is_other_executable());
|
||||
}
|
||||
|
||||
ATF_REQUIRE(t1.str() != "non-existent");
|
||||
ATF_REQUIRE(!atf::fs::exists(t1));
|
||||
ATF_REQUIRE(t2.str() != "non-existent");
|
||||
ATF_REQUIRE(!atf::fs::exists(t2));
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Test cases for the free functions.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
ATF_TEST_CASE(cleanup);
|
||||
ATF_TEST_CASE_HEAD(cleanup)
|
||||
{
|
||||
set_md_var("descr", "Tests the cleanup function");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(cleanup)
|
||||
{
|
||||
using atf::atf_run::cleanup;
|
||||
|
||||
::mkdir("root", 0755);
|
||||
::mkdir("root/dir", 0755);
|
||||
::mkdir("root/dir/1", 0100);
|
||||
::mkdir("root/dir/2", 0644);
|
||||
create_file("root/reg");
|
||||
|
||||
atf::fs::path p("root");
|
||||
ATF_REQUIRE(atf::fs::exists(p));
|
||||
ATF_REQUIRE(atf::fs::exists(p / "dir"));
|
||||
ATF_REQUIRE(atf::fs::exists(p / "dir/1"));
|
||||
ATF_REQUIRE(atf::fs::exists(p / "dir/2"));
|
||||
ATF_REQUIRE(atf::fs::exists(p / "reg"));
|
||||
cleanup(p);
|
||||
ATF_REQUIRE(!atf::fs::exists(p));
|
||||
}
|
||||
|
||||
ATF_TEST_CASE(cleanup_eacces_on_root);
|
||||
ATF_TEST_CASE_HEAD(cleanup_eacces_on_root)
|
||||
{
|
||||
set_md_var("descr", "Tests the cleanup function");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(cleanup_eacces_on_root)
|
||||
{
|
||||
using atf::atf_run::cleanup;
|
||||
|
||||
::mkdir("aux", 0755);
|
||||
::mkdir("aux/root", 0755);
|
||||
ATF_REQUIRE(::chmod("aux", 0555) != -1);
|
||||
|
||||
try {
|
||||
cleanup(atf::fs::path("aux/root"));
|
||||
ATF_REQUIRE(atf::atf_run::is_root());
|
||||
} catch (const atf::system_error& e) {
|
||||
ATF_REQUIRE(!atf::atf_run::is_root());
|
||||
ATF_REQUIRE_EQ(EACCES, e.code());
|
||||
}
|
||||
}
|
||||
|
||||
ATF_TEST_CASE(cleanup_eacces_on_subdir);
|
||||
ATF_TEST_CASE_HEAD(cleanup_eacces_on_subdir)
|
||||
{
|
||||
set_md_var("descr", "Tests the cleanup function");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(cleanup_eacces_on_subdir)
|
||||
{
|
||||
using atf::atf_run::cleanup;
|
||||
|
||||
::mkdir("root", 0755);
|
||||
::mkdir("root/1", 0755);
|
||||
::mkdir("root/1/2", 0755);
|
||||
::mkdir("root/1/2/3", 0755);
|
||||
ATF_REQUIRE(::chmod("root/1/2", 0555) != -1);
|
||||
ATF_REQUIRE(::chmod("root/1", 0555) != -1);
|
||||
|
||||
const atf::fs::path p("root");
|
||||
cleanup(p);
|
||||
ATF_REQUIRE(!atf::fs::exists(p));
|
||||
}
|
||||
|
||||
ATF_TEST_CASE(change_directory);
|
||||
ATF_TEST_CASE_HEAD(change_directory)
|
||||
{
|
||||
set_md_var("descr", "Tests the change_directory function");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(change_directory)
|
||||
{
|
||||
using atf::atf_run::change_directory;
|
||||
using atf::atf_run::get_current_dir;
|
||||
|
||||
::mkdir("files", 0755);
|
||||
::mkdir("files/dir", 0755);
|
||||
create_file("files/reg");
|
||||
|
||||
const atf::fs::path old = get_current_dir();
|
||||
|
||||
ATF_REQUIRE_THROW(atf::system_error,
|
||||
change_directory(atf::fs::path("files/reg")));
|
||||
ATF_REQUIRE(get_current_dir() == old);
|
||||
|
||||
atf::fs::path old2 = change_directory(atf::fs::path("files"));
|
||||
ATF_REQUIRE(old2 == old);
|
||||
atf::fs::path old3 = change_directory(atf::fs::path("dir"));
|
||||
ATF_REQUIRE(old3 == old2 / "files");
|
||||
atf::fs::path old4 = change_directory(atf::fs::path("../.."));
|
||||
ATF_REQUIRE(old4 == old3 / "dir");
|
||||
ATF_REQUIRE(get_current_dir() == old);
|
||||
}
|
||||
|
||||
ATF_TEST_CASE(get_current_dir);
|
||||
ATF_TEST_CASE_HEAD(get_current_dir)
|
||||
{
|
||||
set_md_var("descr", "Tests the get_current_dir function");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(get_current_dir)
|
||||
{
|
||||
using atf::atf_run::change_directory;
|
||||
using atf::atf_run::get_current_dir;
|
||||
|
||||
::mkdir("files", 0755);
|
||||
::mkdir("files/dir", 0755);
|
||||
create_file("files/reg");
|
||||
|
||||
atf::fs::path curdir = get_current_dir();
|
||||
change_directory(atf::fs::path("."));
|
||||
ATF_REQUIRE(get_current_dir() == curdir);
|
||||
change_directory(atf::fs::path("files"));
|
||||
ATF_REQUIRE(get_current_dir() == curdir / "files");
|
||||
change_directory(atf::fs::path("dir"));
|
||||
ATF_REQUIRE(get_current_dir() == curdir / "files/dir");
|
||||
change_directory(atf::fs::path(".."));
|
||||
ATF_REQUIRE(get_current_dir() == curdir / "files");
|
||||
change_directory(atf::fs::path(".."));
|
||||
ATF_REQUIRE(get_current_dir() == curdir);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Main.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
ATF_INIT_TEST_CASES(tcs)
|
||||
{
|
||||
// Add the tests for the "temp_dir" class.
|
||||
ATF_ADD_TEST_CASE(tcs, temp_dir_raii);
|
||||
|
||||
// Add the tests for the free functions.
|
||||
ATF_ADD_TEST_CASE(tcs, cleanup);
|
||||
ATF_ADD_TEST_CASE(tcs, cleanup_eacces_on_root);
|
||||
ATF_ADD_TEST_CASE(tcs, cleanup_eacces_on_subdir);
|
||||
ATF_ADD_TEST_CASE(tcs, change_directory);
|
||||
ATF_ADD_TEST_CASE(tcs, get_current_dir);
|
||||
}
|
@ -724,7 +724,7 @@ const char* atf_check::m_description =
|
||||
"atf-check executes given command and analyzes its results.";
|
||||
|
||||
atf_check::atf_check(void) :
|
||||
app(m_description, "atf-check(1)", "atf(7)"),
|
||||
app(m_description, "atf-check(1)"),
|
||||
m_xflag(false)
|
||||
{
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ const char* atf_sh::m_description =
|
||||
"system sh(1) with the atf-sh library.";
|
||||
|
||||
atf_sh::atf_sh(void) :
|
||||
app(m_description, "atf-sh(1)", "atf(7)")
|
||||
app(m_description, "atf-sh(1)")
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ no_args_body()
|
||||
{
|
||||
cat >experr <<EOF
|
||||
atf-sh: ERROR: No test program provided
|
||||
atf-sh: Type \`atf-sh -h' for more details.
|
||||
atf-sh: See atf-sh(1) for usage details.
|
||||
EOF
|
||||
atf_check -s eq:1 -o ignore -e file:experr atf-sh
|
||||
}
|
||||
|
@ -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
|
15
bconfig.h.in
15
bconfig.h.in
@ -27,18 +27,9 @@
|
||||
/* 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
|
||||
|
||||
@ -60,15 +51,9 @@
|
||||
/* 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
|
||||
|
||||
|
@ -29,11 +29,11 @@
|
||||
|
||||
check_PROGRAMS = bootstrap/h_app_empty
|
||||
bootstrap_h_app_empty_SOURCES = bootstrap/h_app_empty.cpp
|
||||
bootstrap_h_app_empty_LDADD = $(ATF_CXX_LIBS)
|
||||
bootstrap_h_app_empty_LDADD = tools/libtools.a $(ATF_CXX_LIBS)
|
||||
|
||||
check_PROGRAMS += bootstrap/h_app_opts_args
|
||||
bootstrap_h_app_opts_args_SOURCES = bootstrap/h_app_opts_args.cpp
|
||||
bootstrap_h_app_opts_args_LDADD = $(ATF_CXX_LIBS)
|
||||
bootstrap_h_app_opts_args_LDADD = tools/libtools.a $(ATF_CXX_LIBS)
|
||||
|
||||
check_PROGRAMS += bootstrap/h_tp_basic_c
|
||||
bootstrap_h_tp_basic_c_SOURCES = bootstrap/h_tp_basic_c.c
|
||||
|
@ -29,9 +29,9 @@
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "atf-c++/detail/application.hpp"
|
||||
#include "tools/application.hpp"
|
||||
|
||||
class h_app_empty : public atf::application::app {
|
||||
class h_app_empty : public tools::application::app {
|
||||
static const char* m_description;
|
||||
|
||||
public:
|
||||
|
@ -30,10 +30,9 @@
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
#include "atf-c++/detail/application.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
#include "tools/application.hpp"
|
||||
|
||||
class h_app_opts_args : public atf::application::app {
|
||||
class h_app_opts_args : public tools::application::app {
|
||||
static const char* m_description;
|
||||
|
||||
std::string specific_args(void) const;
|
||||
@ -66,7 +65,7 @@ h_app_opts_args::options_set
|
||||
h_app_opts_args::specific_options(void)
|
||||
const
|
||||
{
|
||||
using atf::application::option;
|
||||
using tools::application::option;
|
||||
options_set opts;
|
||||
opts.insert(option('d', "", "Debug mode"));
|
||||
opts.insert(option('v', "level", "Verbosity level"));
|
||||
@ -86,7 +85,7 @@ h_app_opts_args::process_option(int ch, const char* arg)
|
||||
break;
|
||||
|
||||
default:
|
||||
UNREACHABLE;
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Signature of the current package.
|
||||
m4_define(AT_PACKAGE_NAME, Automated Testing Framework)
|
||||
m4_define(AT_PACKAGE_TARNAME, atf)
|
||||
m4_define(AT_PACKAGE_VERSION, 0.18)
|
||||
m4_define(AT_PACKAGE_STRING, Automated Testing Framework 0.18)
|
||||
m4_define(AT_PACKAGE_VERSION, 0.19)
|
||||
m4_define(AT_PACKAGE_STRING, Automated Testing Framework 0.19)
|
||||
m4_define(AT_PACKAGE_BUGREPORT, atf-devel@NetBSD.org)
|
||||
m4_define(ENABLE_TOOLS, yes)
|
||||
|
2487
bootstrap/testsuite
2487
bootstrap/testsuite
File diff suppressed because it is too large
Load Diff
@ -74,7 +74,7 @@ m4_include(bootstrap/t_test_program_list.at)
|
||||
m4_include(bootstrap/t_test_program_compare.at)
|
||||
m4_include(bootstrap/t_subr_atf_check.at)
|
||||
|
||||
m4_if([ENABLE_TOOLS], yes, [
|
||||
m4_if(ENABLE_TOOLS, yes, [
|
||||
m4_include(bootstrap/t_application_opts_args.at)
|
||||
m4_include(bootstrap/t_application_help.at)
|
||||
m4_include(bootstrap/t_atf_config.at)
|
||||
|
542
configure
vendored
542
configure
vendored
@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for Automated Testing Framework 0.18.
|
||||
# Generated by GNU Autoconf 2.69 for Automated Testing Framework 0.19.
|
||||
#
|
||||
# Report bugs to <atf-devel@NetBSD.org>.
|
||||
#
|
||||
@ -592,10 +592,10 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='Automated Testing Framework'
|
||||
PACKAGE_TARNAME='atf'
|
||||
PACKAGE_VERSION='0.18'
|
||||
PACKAGE_STRING='Automated Testing Framework 0.18'
|
||||
PACKAGE_VERSION='0.19'
|
||||
PACKAGE_STRING='Automated Testing Framework 0.19'
|
||||
PACKAGE_BUGREPORT='atf-devel@NetBSD.org'
|
||||
PACKAGE_URL='http://code.google.com/p/kyua/wiki/ATF'
|
||||
PACKAGE_URL='https://github.com/jmmv/atf/'
|
||||
|
||||
ac_unique_file="atf-c.h"
|
||||
# Factoring default headers for most tests.
|
||||
@ -683,8 +683,6 @@ NMEDIT
|
||||
DSYMUTIL
|
||||
MANIFEST_TOOL
|
||||
RANLIB
|
||||
ac_ct_AR
|
||||
AR
|
||||
DLLTOOL
|
||||
OBJDUMP
|
||||
LN_S
|
||||
@ -696,6 +694,7 @@ FGREP
|
||||
EGREP
|
||||
GREP
|
||||
SED
|
||||
LIBTOOL
|
||||
am__fastdepCC_FALSE
|
||||
am__fastdepCC_TRUE
|
||||
CCDEPMODE
|
||||
@ -713,7 +712,8 @@ CPPFLAGS
|
||||
LDFLAGS
|
||||
CFLAGS
|
||||
CC
|
||||
LIBTOOL
|
||||
ac_ct_AR
|
||||
AR
|
||||
AM_BACKSLASH
|
||||
AM_DEFAULT_VERBOSITY
|
||||
AM_DEFAULT_V
|
||||
@ -795,11 +795,11 @@ ac_subst_files=''
|
||||
ac_user_opts='
|
||||
enable_option_checking
|
||||
enable_silent_rules
|
||||
enable_dependency_tracking
|
||||
enable_shared
|
||||
enable_static
|
||||
with_pic
|
||||
enable_fast_install
|
||||
enable_dependency_tracking
|
||||
with_gnu_ld
|
||||
with_sysroot
|
||||
enable_libtool_lock
|
||||
@ -1368,7 +1368,7 @@ if test "$ac_init_help" = "long"; then
|
||||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures Automated Testing Framework 0.18 to adapt to many kinds of systems.
|
||||
\`configure' configures Automated Testing Framework 0.19 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@ -1439,7 +1439,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of Automated Testing Framework 0.18:";;
|
||||
short | recursive ) echo "Configuration of Automated Testing Framework 0.19:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@ -1449,14 +1449,14 @@ Optional Features:
|
||||
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
|
||||
--enable-silent-rules less verbose build output (undo: "make V=1")
|
||||
--disable-silent-rules verbose build output (undo: "make V=0")
|
||||
--enable-shared[=PKGS] build shared libraries [default=yes]
|
||||
--enable-static[=PKGS] build static libraries [default=yes]
|
||||
--enable-fast-install[=PKGS]
|
||||
optimize for fast installation [default=yes]
|
||||
--enable-dependency-tracking
|
||||
do not reject slow dependency extractors
|
||||
--disable-dependency-tracking
|
||||
speeds up one-time build
|
||||
--enable-shared[=PKGS] build shared libraries [default=yes]
|
||||
--enable-static[=PKGS] build static libraries [default=yes]
|
||||
--enable-fast-install[=PKGS]
|
||||
optimize for fast installation [default=yes]
|
||||
--disable-libtool-lock avoid locking (might break parallel builds)
|
||||
--enable-tools Enables the build of the deprecated ATF tools
|
||||
--enable-developer enable developer features
|
||||
@ -1503,7 +1503,7 @@ Use these variables to override the choices made by `configure' or to help
|
||||
it to find libraries and programs with nonstandard names/locations.
|
||||
|
||||
Report bugs to <atf-devel@NetBSD.org>.
|
||||
Automated Testing Framework home page: <http://code.google.com/p/kyua/wiki/ATF>.
|
||||
Automated Testing Framework home page: <https://github.com/jmmv/atf/>.
|
||||
_ACEOF
|
||||
ac_status=$?
|
||||
fi
|
||||
@ -1566,7 +1566,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
Automated Testing Framework configure 0.18
|
||||
Automated Testing Framework configure 0.19
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
@ -2130,7 +2130,7 @@ cat >config.log <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by Automated Testing Framework $as_me 0.18, which was
|
||||
It was created by Automated Testing Framework $as_me 0.19, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
@ -3116,7 +3116,7 @@ fi
|
||||
|
||||
# Define the identity of the package.
|
||||
PACKAGE='atf'
|
||||
VERSION='0.18'
|
||||
VERSION='0.19'
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
@ -3209,100 +3209,6 @@ END
|
||||
fi
|
||||
fi
|
||||
|
||||
case `pwd` in
|
||||
*\ * | *\ *)
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
|
||||
$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
macro_version='2.4.2'
|
||||
macro_revision='1.3337'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ltmain="$ac_aux_dir/ltmain.sh"
|
||||
|
||||
# Backslashify metacharacters that are still active within
|
||||
# double-quoted strings.
|
||||
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
|
||||
|
||||
# Same as above, but do not quote variable references.
|
||||
double_quote_subst='s/\(["`\\]\)/\\\1/g'
|
||||
|
||||
# Sed substitution to delay expansion of an escaped shell variable in a
|
||||
# double_quote_subst'ed string.
|
||||
delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
|
||||
|
||||
# Sed substitution to delay expansion of an escaped single quote.
|
||||
delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
|
||||
|
||||
# Sed substitution to avoid accidental globbing in evaled expressions
|
||||
no_glob_subst='s/\*/\\\*/g'
|
||||
|
||||
ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
|
||||
ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
|
||||
ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5
|
||||
$as_echo_n "checking how to print strings... " >&6; }
|
||||
# Test print first, because it will be a builtin if present.
|
||||
if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
|
||||
test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
|
||||
ECHO='print -r --'
|
||||
elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
|
||||
ECHO='printf %s\n'
|
||||
else
|
||||
# Use this function as a fallback that always works.
|
||||
func_fallback_echo ()
|
||||
{
|
||||
eval 'cat <<_LTECHO_EOF
|
||||
$1
|
||||
_LTECHO_EOF'
|
||||
}
|
||||
ECHO='func_fallback_echo'
|
||||
fi
|
||||
|
||||
# func_echo_all arg...
|
||||
# Invoke $ECHO with all args, space-separated.
|
||||
func_echo_all ()
|
||||
{
|
||||
$ECHO ""
|
||||
}
|
||||
|
||||
case "$ECHO" in
|
||||
printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
|
||||
$as_echo "printf" >&6; } ;;
|
||||
print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
|
||||
$as_echo "print -r" >&6; } ;;
|
||||
*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5
|
||||
$as_echo "cat" >&6; } ;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DEPDIR="${am__leading_dot}deps"
|
||||
|
||||
ac_config_commands="$ac_config_commands depfiles"
|
||||
@ -4342,6 +4248,272 @@ else
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if test -n "$ac_tool_prefix"; then
|
||||
for ac_prog in ar lib "link -lib"
|
||||
do
|
||||
# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
|
||||
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
||||
$as_echo_n "checking for $ac_word... " >&6; }
|
||||
if ${ac_cv_prog_AR+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
if test -n "$AR"; then
|
||||
ac_cv_prog_AR="$AR" # Let the user override the test.
|
||||
else
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
|
||||
ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
IFS=$as_save_IFS
|
||||
|
||||
fi
|
||||
fi
|
||||
AR=$ac_cv_prog_AR
|
||||
if test -n "$AR"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
|
||||
$as_echo "$AR" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
test -n "$AR" && break
|
||||
done
|
||||
fi
|
||||
if test -z "$AR"; then
|
||||
ac_ct_AR=$AR
|
||||
for ac_prog in ar lib "link -lib"
|
||||
do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
set dummy $ac_prog; ac_word=$2
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
||||
$as_echo_n "checking for $ac_word... " >&6; }
|
||||
if ${ac_cv_prog_ac_ct_AR+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
if test -n "$ac_ct_AR"; then
|
||||
ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
|
||||
else
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
|
||||
ac_cv_prog_ac_ct_AR="$ac_prog"
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
IFS=$as_save_IFS
|
||||
|
||||
fi
|
||||
fi
|
||||
ac_ct_AR=$ac_cv_prog_ac_ct_AR
|
||||
if test -n "$ac_ct_AR"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
|
||||
$as_echo "$ac_ct_AR" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
test -n "$ac_ct_AR" && break
|
||||
done
|
||||
|
||||
if test "x$ac_ct_AR" = x; then
|
||||
AR="false"
|
||||
else
|
||||
case $cross_compiling:$ac_tool_warned in
|
||||
yes:)
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
|
||||
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
|
||||
ac_tool_warned=yes ;;
|
||||
esac
|
||||
AR=$ac_ct_AR
|
||||
fi
|
||||
fi
|
||||
|
||||
: ${AR=ar}
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) interface" >&5
|
||||
$as_echo_n "checking the archiver ($AR) interface... " >&6; }
|
||||
if ${am_cv_ar_interface+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
ac_ext=c
|
||||
ac_cpp='$CPP $CPPFLAGS'
|
||||
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
|
||||
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
|
||||
ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
||||
|
||||
am_cv_ar_interface=ar
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
int some_variable = 0;
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&5'
|
||||
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5
|
||||
(eval $am_ar_try) 2>&5
|
||||
ac_status=$?
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
||||
test $ac_status = 0; }
|
||||
if test "$ac_status" -eq 0; then
|
||||
am_cv_ar_interface=ar
|
||||
else
|
||||
am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&5'
|
||||
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$am_ar_try\""; } >&5
|
||||
(eval $am_ar_try) 2>&5
|
||||
ac_status=$?
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
|
||||
test $ac_status = 0; }
|
||||
if test "$ac_status" -eq 0; then
|
||||
am_cv_ar_interface=lib
|
||||
else
|
||||
am_cv_ar_interface=unknown
|
||||
fi
|
||||
fi
|
||||
rm -f conftest.lib libconftest.a
|
||||
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
ac_ext=c
|
||||
ac_cpp='$CPP $CPPFLAGS'
|
||||
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
|
||||
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
|
||||
ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
||||
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface" >&5
|
||||
$as_echo "$am_cv_ar_interface" >&6; }
|
||||
|
||||
case $am_cv_ar_interface in
|
||||
ar)
|
||||
;;
|
||||
lib)
|
||||
# Microsoft lib, so override with the ar-lib wrapper script.
|
||||
# FIXME: It is wrong to rewrite AR.
|
||||
# But if we don't then we get into trouble of one sort or another.
|
||||
# A longer-term fix would be to have automake use am__AR in this case,
|
||||
# and then we could set am__AR="$am_aux_dir/ar-lib \$(AR)" or something
|
||||
# similar.
|
||||
AR="$am_aux_dir/ar-lib $AR"
|
||||
;;
|
||||
unknown)
|
||||
as_fn_error $? "could not determine $AR interface" "$LINENO" 5
|
||||
;;
|
||||
esac
|
||||
|
||||
case `pwd` in
|
||||
*\ * | *\ *)
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
|
||||
$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
macro_version='2.4.2'
|
||||
macro_revision='1.3337'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ltmain="$ac_aux_dir/ltmain.sh"
|
||||
|
||||
# Backslashify metacharacters that are still active within
|
||||
# double-quoted strings.
|
||||
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
|
||||
|
||||
# Same as above, but do not quote variable references.
|
||||
double_quote_subst='s/\(["`\\]\)/\\\1/g'
|
||||
|
||||
# Sed substitution to delay expansion of an escaped shell variable in a
|
||||
# double_quote_subst'ed string.
|
||||
delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
|
||||
|
||||
# Sed substitution to delay expansion of an escaped single quote.
|
||||
delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
|
||||
|
||||
# Sed substitution to avoid accidental globbing in evaled expressions
|
||||
no_glob_subst='s/\*/\\\*/g'
|
||||
|
||||
ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
|
||||
ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
|
||||
ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5
|
||||
$as_echo_n "checking how to print strings... " >&6; }
|
||||
# Test print first, because it will be a builtin if present.
|
||||
if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
|
||||
test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
|
||||
ECHO='print -r --'
|
||||
elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
|
||||
ECHO='printf %s\n'
|
||||
else
|
||||
# Use this function as a fallback that always works.
|
||||
func_fallback_echo ()
|
||||
{
|
||||
eval 'cat <<_LTECHO_EOF
|
||||
$1
|
||||
_LTECHO_EOF'
|
||||
}
|
||||
ECHO='func_fallback_echo'
|
||||
fi
|
||||
|
||||
# func_echo_all arg...
|
||||
# Invoke $ECHO with all args, space-separated.
|
||||
func_echo_all ()
|
||||
{
|
||||
$ECHO ""
|
||||
}
|
||||
|
||||
case "$ECHO" in
|
||||
printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
|
||||
$as_echo "printf" >&6; } ;;
|
||||
print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
|
||||
$as_echo "print -r" >&6; } ;;
|
||||
*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5
|
||||
$as_echo "cat" >&6; } ;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
|
||||
$as_echo_n "checking for a sed that does not truncate output... " >&6; }
|
||||
if ${ac_cv_path_SED+:} false; then :
|
||||
@ -5767,7 +5939,6 @@ test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
|
||||
|
||||
|
||||
|
||||
|
||||
if test -n "$ac_tool_prefix"; then
|
||||
for ac_prog in ar
|
||||
do
|
||||
@ -16787,97 +16958,6 @@ done
|
||||
|
||||
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether putenv is in std" >&5
|
||||
$as_echo_n "checking whether putenv is in std... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
#include <cstdio>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
std::putenv("a=b");
|
||||
return 0;
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_cxx_try_compile "$LINENO"; then :
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
|
||||
$as_echo "#define HAVE_PUTENV_IN_STD 1" >>confdefs.h
|
||||
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
|
||||
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether setenv is in std" >&5
|
||||
$as_echo_n "checking whether setenv is in std... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
#include <cstdio>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
std::setenv("a", "b");
|
||||
return 0;
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_cxx_try_compile "$LINENO"; then :
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
|
||||
$as_echo "#define HAVE_SETENV_IN_STD 1" >>confdefs.h
|
||||
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
|
||||
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether unsetenv is in std" >&5
|
||||
$as_echo_n "checking whether unsetenv is in std... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
#include <cstdio>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
std::unsetenv("a");
|
||||
return 0;
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_cxx_try_compile "$LINENO"; then :
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
|
||||
$as_echo "#define HAVE_UNSETENV_IN_STD 1" >>confdefs.h
|
||||
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
|
||||
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether basename takes a constant pointer" >&5
|
||||
$as_echo_n "checking whether basename takes a constant pointer... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
@ -16980,51 +17060,6 @@ $as_echo "#define HAVE_GETCWD_DYN 1" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
for ac_func in unmount
|
||||
do :
|
||||
ac_fn_cxx_check_func "$LINENO" "unmount" "ac_cv_func_unmount"
|
||||
if test "x$ac_cv_func_unmount" = xyes; then :
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_UNMOUNT 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether snprintf is in std" >&5
|
||||
$as_echo_n "checking whether snprintf is in std... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
#include <cstdio>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
char buf;
|
||||
std::snprintf(&buf, 1, "");
|
||||
return 0;
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_cxx_try_compile "$LINENO"; then :
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
|
||||
$as_echo "#define HAVE_SNPRINTF_IN_STD 1" >>confdefs.h
|
||||
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
|
||||
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the last valid signal" >&5
|
||||
$as_echo_n "checking for the last valid signal... " >&6; }
|
||||
@ -17419,7 +17454,7 @@ fi
|
||||
|
||||
|
||||
|
||||
ac_config_files="$ac_config_files Makefile atf-c/defs.h"
|
||||
ac_config_files="$ac_config_files Makefile atf-c/defs.h tools/defs.hpp"
|
||||
|
||||
cat >confcache <<\_ACEOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
@ -17967,7 +18002,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by Automated Testing Framework $as_me 0.18, which was
|
||||
This file was extended by Automated Testing Framework $as_me 0.19, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@ -18028,13 +18063,13 @@ Configuration commands:
|
||||
$config_commands
|
||||
|
||||
Report bugs to <atf-devel@NetBSD.org>.
|
||||
Automated Testing Framework home page: <http://code.google.com/p/kyua/wiki/ATF>."
|
||||
Automated Testing Framework home page: <https://github.com/jmmv/atf/>."
|
||||
|
||||
_ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
Automated Testing Framework config.status 0.18
|
||||
Automated Testing Framework config.status 0.19
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
@ -18545,6 +18580,7 @@ do
|
||||
"libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
|
||||
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
|
||||
"atf-c/defs.h") CONFIG_FILES="$CONFIG_FILES atf-c/defs.h" ;;
|
||||
"tools/defs.hpp") CONFIG_FILES="$CONFIG_FILES tools/defs.hpp" ;;
|
||||
|
||||
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
|
||||
esac
|
||||
|
@ -31,8 +31,8 @@ dnl -----------------------------------------------------------------------
|
||||
dnl Initialize the GNU build system.
|
||||
dnl -----------------------------------------------------------------------
|
||||
|
||||
AC_INIT([Automated Testing Framework], [0.18], [atf-devel@NetBSD.org], [atf],
|
||||
[http://code.google.com/p/kyua/wiki/ATF])
|
||||
AC_INIT([Automated Testing Framework], [0.19], [atf-devel@NetBSD.org], [atf],
|
||||
[https://github.com/jmmv/atf/])
|
||||
AC_PREREQ([2.65])
|
||||
AC_COPYRIGHT([Copyright (c) 2007-2012 The NetBSD Foundation, Inc.])
|
||||
AC_DEFINE([PACKAGE_COPYRIGHT],
|
||||
@ -48,6 +48,7 @@ AC_CANONICAL_TARGET
|
||||
|
||||
AM_INIT_AUTOMAKE([1.9 check-news foreign subdir-objects -Wall])
|
||||
|
||||
AM_PROG_AR
|
||||
LT_INIT
|
||||
|
||||
AC_ARG_ENABLE(tools,
|
||||
@ -90,7 +91,6 @@ 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>]])
|
||||
@ -218,7 +218,7 @@ dnl -----------------------------------------------------------------------
|
||||
dnl Finally, generate output.
|
||||
dnl -----------------------------------------------------------------------
|
||||
|
||||
AC_OUTPUT([Makefile atf-c/defs.h])
|
||||
AC_OUTPUT([Makefile atf-c/defs.h tools/defs.hpp])
|
||||
|
||||
if test ${enable_tools} = yes; then
|
||||
AC_MSG_WARN([Building the deprecated ATF tools (atf-run and atf-report);])
|
||||
|
@ -30,21 +30,4 @@
|
||||
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
|
||||
|
@ -123,8 +123,9 @@ The usefulness of the
|
||||
.Sq expected_*
|
||||
results comes when writing test cases that verify known failures caused,
|
||||
in general, due to programming errors (aka bugs).
|
||||
Whenever the faulty condition that the expectation is trying to convery is
|
||||
fixed, then the test case will be reported as
|
||||
Whenever the faulty condition that the
|
||||
.Sq expected_*
|
||||
result is trying to cover is fixed, then the test case will be reported as
|
||||
.Sq failed
|
||||
and the developer will have to adjust it to match its new condition.
|
||||
.Pp
|
||||
|
@ -38,35 +38,6 @@ AC_DEFUN([ATF_CHECK_IN_STD], [
|
||||
)
|
||||
])
|
||||
|
||||
AC_DEFUN([ATF_CHECK_STD_PUTENV], [
|
||||
ATF_CHECK_IN_STD([putenv],
|
||||
[#include <cstdio>],
|
||||
[std::putenv("a=b");]
|
||||
)
|
||||
])
|
||||
|
||||
AC_DEFUN([ATF_CHECK_STD_SETENV], [
|
||||
ATF_CHECK_IN_STD([setenv],
|
||||
[#include <cstdio>],
|
||||
[std::setenv("a", "b");]
|
||||
)
|
||||
])
|
||||
|
||||
AC_DEFUN([ATF_CHECK_STD_SNPRINTF], [
|
||||
ATF_CHECK_IN_STD([snprintf],
|
||||
[#include <cstdio>],
|
||||
[char buf;
|
||||
std::snprintf(&buf, 1, "");]
|
||||
)
|
||||
])
|
||||
|
||||
AC_DEFUN([ATF_CHECK_STD_UNSETENV], [
|
||||
ATF_CHECK_IN_STD([unsetenv],
|
||||
[#include <cstdio>],
|
||||
[std::unsetenv("a");]
|
||||
)
|
||||
])
|
||||
|
||||
AC_DEFUN([ATF_CHECK_STD_VSNPRINTF], [
|
||||
ATF_CHECK_IN_STD([vsnprintf],
|
||||
[#include <cstdarg>
|
||||
|
@ -29,8 +29,4 @@ dnl
|
||||
|
||||
AC_DEFUN([ATF_MODULE_ENV], [
|
||||
AC_CHECK_FUNCS([putenv setenv unsetenv])
|
||||
|
||||
ATF_CHECK_STD_PUTENV
|
||||
ATF_CHECK_STD_SETENV
|
||||
ATF_CHECK_STD_UNSETENV
|
||||
])
|
||||
|
@ -66,6 +66,4 @@ AC_DEFUN([ATF_MODULE_FS], [
|
||||
AC_DEFINE([HAVE_GETCWD_DYN], [1],
|
||||
[Define to 1 if getcwd(NULL, 0) works])
|
||||
fi
|
||||
|
||||
AC_CHECK_FUNCS([unmount])
|
||||
])
|
||||
|
@ -1,32 +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
|
||||
|
||||
AC_DEFUN([ATF_MODULE_SANITY], [
|
||||
ATF_CHECK_STD_SNPRINTF
|
||||
])
|
25
tools/Atffile
Normal file
25
tools/Atffile
Normal file
@ -0,0 +1,25 @@
|
||||
Content-Type: application/X-atf-atffile; version="1"
|
||||
|
||||
prop: test-suite = atf
|
||||
|
||||
tp: atf-config_test
|
||||
tp: atf-report_test
|
||||
tp: atf-run_test
|
||||
tp: application_test
|
||||
tp: atffile_test
|
||||
tp: auto_array_test
|
||||
tp: config_test
|
||||
tp: config_file_test
|
||||
tp: env_test
|
||||
tp: expand_test
|
||||
tp: fs_test
|
||||
tp: io_test
|
||||
tp: parser_test
|
||||
tp: process_test
|
||||
tp: reader_test
|
||||
tp: requirements_test
|
||||
tp: signals_test
|
||||
tp: test_program_test
|
||||
tp: text_test
|
||||
tp: ui_test
|
||||
tp: user_test
|
24
tools/Kyuafile
Normal file
24
tools/Kyuafile
Normal file
@ -0,0 +1,24 @@
|
||||
syntax("kyuafile", 1)
|
||||
|
||||
test_suite("atf")
|
||||
|
||||
atf_test_program{name="atf-config_test"}
|
||||
atf_test_program{name="atf-report_test"}
|
||||
atf_test_program{name="atf-run_test"}
|
||||
atf_test_program{name="application_test"}
|
||||
atf_test_program{name="atffile_test"}
|
||||
atf_test_program{name="auto_array_test"}
|
||||
atf_test_program{name="config_test"}
|
||||
atf_test_program{name="config_file_test"}
|
||||
atf_test_program{name="env_test"}
|
||||
atf_test_program{name="expand_test"}
|
||||
atf_test_program{name="fs_test"}
|
||||
atf_test_program{name="io_test"}
|
||||
atf_test_program{name="parser_test"}
|
||||
atf_test_program{name="process_test"}
|
||||
atf_test_program{name="reader_test"}
|
||||
atf_test_program{name="requirements_test"}
|
||||
atf_test_program{name="signals_test"}
|
||||
atf_test_program{name="test_program_test"}
|
||||
atf_test_program{name="text_test"}
|
||||
atf_test_program{name="ui_test"}
|
332
tools/Makefile.am.inc
Normal file
332
tools/Makefile.am.inc
Normal file
@ -0,0 +1,332 @@
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
TOOLS_CPPFLAGS = -I$(top_srcdir)/tools -I$(top_builddir)/tools
|
||||
TOOLS_LDADD = tools/libtools.a
|
||||
|
||||
noinst_LIBRARIES = tools/libtools.a
|
||||
tools_libtools_a_SOURCES = tools/application.cpp \
|
||||
tools/application.hpp \
|
||||
tools/atffile.cpp \
|
||||
tools/atffile.hpp \
|
||||
tools/auto_array.hpp \
|
||||
tools/config.cpp \
|
||||
tools/config.hpp \
|
||||
tools/config_file.cpp \
|
||||
tools/config_file.hpp \
|
||||
tools/env.cpp \
|
||||
tools/env.hpp \
|
||||
tools/exceptions.cpp \
|
||||
tools/exceptions.hpp \
|
||||
tools/expand.cpp \
|
||||
tools/expand.hpp \
|
||||
tools/fs.cpp \
|
||||
tools/fs.hpp \
|
||||
tools/io.cpp \
|
||||
tools/io.hpp \
|
||||
tools/parser.cpp \
|
||||
tools/parser.hpp \
|
||||
tools/process.cpp \
|
||||
tools/process.hpp \
|
||||
tools/reader.cpp \
|
||||
tools/reader.hpp \
|
||||
tools/requirements.cpp \
|
||||
tools/requirements.hpp \
|
||||
tools/signals.cpp \
|
||||
tools/signals.hpp \
|
||||
tools/test-program.cpp \
|
||||
tools/test-program.hpp \
|
||||
tools/test_helpers.hpp \
|
||||
tools/text.cpp \
|
||||
tools/text.hpp \
|
||||
tools/timers.cpp \
|
||||
tools/timers.hpp \
|
||||
tools/ui.cpp \
|
||||
tools/ui.hpp \
|
||||
tools/user.cpp \
|
||||
tools/user.hpp
|
||||
nodist_tools_libtools_a_SOURCES = tools/defs.hpp
|
||||
tools_libtools_a_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_PKGDATADIR=\"$(pkgdatadir)\"" \
|
||||
"-DATF_SHELL=\"$(ATF_SHELL)\"" \
|
||||
"-DATF_WORKDIR=\"$(ATF_WORKDIR)\"" \
|
||||
$(TOOLS_CPPFLAGS)
|
||||
|
||||
# XXX For some reason, the nodist line above does not work as expected.
|
||||
# Work this problem around.
|
||||
DIST_HOOKS += kill-defs-hpp
|
||||
kill-defs-hpp:
|
||||
rm -f $(distdir)/tools/defs.hpp
|
||||
|
||||
|
||||
|
||||
bin_PROGRAMS += tools/atf-config
|
||||
tools_atf_config_SOURCES = tools/atf-config.cpp
|
||||
tools_atf_config_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_atf_config_LDADD = $(TOOLS_LDADD)
|
||||
dist_man_MANS += tools/atf-config.1
|
||||
|
||||
bin_PROGRAMS += tools/atf-report
|
||||
tools_atf_report_SOURCES = tools/atf-report.cpp
|
||||
tools_atf_report_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_atf_report_LDADD = $(TOOLS_LDADD)
|
||||
dist_man_MANS += tools/atf-report.1
|
||||
|
||||
bin_PROGRAMS += tools/atf-run
|
||||
tools_atf_run_CPPFLAGS = $(TOOLS_CPPFLAGS) "-DGDB=\"$(GDB)\""
|
||||
tools_atf_run_SOURCES = tools/atf-run.cpp
|
||||
tools_atf_run_LDADD = $(TOOLS_LDADD)
|
||||
dist_man_MANS += tools/atf-run.1
|
||||
|
||||
bin_PROGRAMS += tools/atf-version
|
||||
tools_atf_version_SOURCES = tools/atf-version.cpp
|
||||
nodist_tools_atf_version_SOURCES = tools/revision.h
|
||||
tools_atf_version_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_atf_version_LDADD = $(TOOLS_LDADD)
|
||||
dist_man_MANS += tools/atf-version.1
|
||||
|
||||
EXTRA_DIST += tools/generate-revision.sh
|
||||
|
||||
BUILT_SOURCES += tools/revision.h
|
||||
CLEANFILES += tools/revision.h
|
||||
tools/revision.h: tools/revision.h.stamp
|
||||
@test -d tools || mkdir -p tools
|
||||
@cmp -s tools/revision.h tools/revision.h.stamp || \
|
||||
cp -p tools/revision.h.stamp tools/revision.h
|
||||
|
||||
CLEANFILES += tools/revision.h.stamp
|
||||
PHONY_TARGETS += tools/revision.h.stamp
|
||||
tools/revision.h.stamp:
|
||||
@test -d tools || mkdir -p tools
|
||||
@$(top_srcdir)/tools/generate-revision.sh \
|
||||
-g "$(GIT)" -r $(top_srcdir) -o tools/revision.h.stamp \
|
||||
-v $(PACKAGE_VERSION)
|
||||
|
||||
|
||||
|
||||
man_MANS += tools/atf.7
|
||||
CLEANFILES += tools/atf.7
|
||||
EXTRA_DIST += tools/atf.7.in
|
||||
|
||||
dist_man_MANS += tools/atf-formats.5
|
||||
|
||||
tools/atf.7: $(srcdir)/tools/atf.7.in
|
||||
test -d tools || mkdir -p tools
|
||||
sed -e 's#__DOCDIR__#$(docdir)#g' \
|
||||
-e 's#__TESTSDIR__#$(testsdir)#g' \
|
||||
<$(srcdir)/tools/atf.7.in >tools/atf.7.tmp
|
||||
mv tools/atf.7.tmp tools/atf.7
|
||||
|
||||
|
||||
|
||||
cssdir = $(atf_cssdir)
|
||||
css_DATA = tools/tests-results.css
|
||||
EXTRA_DIST += $(css_DATA)
|
||||
|
||||
dtddir = $(atf_dtddir)
|
||||
dtd_DATA = tools/tests-results.dtd
|
||||
EXTRA_DIST += $(dtd_DATA)
|
||||
|
||||
egdir = $(atf_egdir)
|
||||
eg_DATA = tools/sample/atf-run.hooks
|
||||
eg_DATA += tools/sample/common.conf
|
||||
EXTRA_DIST += $(eg_DATA)
|
||||
|
||||
hooksdir = $(pkgdatadir)
|
||||
hooks_DATA = tools/share/atf-run.hooks
|
||||
EXTRA_DIST += $(hooks_DATA)
|
||||
|
||||
xsldir = $(atf_xsldir)
|
||||
xsl_DATA = tools/tests-results.xsl
|
||||
EXTRA_DIST += $(xsl_DATA)
|
||||
|
||||
|
||||
|
||||
tests_tools_DATA = tools/Atffile tools/Kyuafile
|
||||
tests_toolsdir = $(pkgtestsdir)/tools
|
||||
EXTRA_DIST += $(tests_tools_DATA)
|
||||
|
||||
tests_tools_SCRIPTS = tools/atf-config_test
|
||||
CLEANFILES += tools/atf-config_test
|
||||
EXTRA_DIST += tools/atf-config_test.sh
|
||||
tools/atf-config_test: $(srcdir)/tools/atf-config_test.sh
|
||||
@test -d tools || mkdir -p tools
|
||||
@src="$(srcdir)/tools/atf-config_test.sh"; \
|
||||
dst="tools/atf-config_test"; $(BUILD_SH_TP)
|
||||
|
||||
tests_tools_SCRIPTS += tools/atf-report_test
|
||||
CLEANFILES += tools/atf-report_test
|
||||
EXTRA_DIST += tools/atf-report_test.sh
|
||||
tools/atf-report_test: $(srcdir)/tools/atf-report_test.sh
|
||||
@test -d tools || mkdir -p tools
|
||||
@src="$(srcdir)/tools/atf-report_test.sh"; \
|
||||
dst="tools/atf-report_test"; $(BUILD_SH_TP)
|
||||
|
||||
tests_tools_SCRIPTS += tools/atf-run_test
|
||||
CLEANFILES += tools/atf-run_test
|
||||
EXTRA_DIST += tools/atf-run_test.sh
|
||||
tools/atf-run_test: $(srcdir)/tools/atf-run_test.sh
|
||||
@test -d tools || mkdir -p tools
|
||||
@src="$(srcdir)/tools/atf-run_test.sh"; \
|
||||
dst="tools/atf-run_test"; $(BUILD_SH_TP)
|
||||
|
||||
tests_tools_PROGRAMS = tools/application_test
|
||||
tools_application_test_SOURCES = tools/application_test.cpp
|
||||
tools_application_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_application_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/atffile_test
|
||||
tools_atffile_test_SOURCES = tools/atffile_test.cpp
|
||||
tools_atffile_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_atffile_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/auto_array_test
|
||||
tools_auto_array_test_SOURCES = tools/auto_array_test.cpp
|
||||
tools_auto_array_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_auto_array_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/bad_metadata_helper
|
||||
tools_bad_metadata_helper_SOURCES = tools/bad_metadata_helper.c
|
||||
tools_bad_metadata_helper_LDADD = libatf-c.la
|
||||
|
||||
tests_tools_PROGRAMS += tools/config_test
|
||||
tools_config_test_SOURCES = tools/config_test.cpp
|
||||
tools_config_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_config_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/config_file_test
|
||||
tools_config_file_test_SOURCES = tools/config_file_test.cpp
|
||||
tools_config_file_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_config_file_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/env_test
|
||||
tools_env_test_SOURCES = tools/env_test.cpp
|
||||
tools_env_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_env_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/expand_test
|
||||
tools_expand_test_SOURCES = tools/expand_test.cpp
|
||||
tools_expand_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_expand_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/expect_helpers
|
||||
tools_expect_helpers_SOURCES = tools/expect_helpers.c
|
||||
tools_expect_helpers_LDADD = libatf-c.la
|
||||
|
||||
tests_tools_PROGRAMS += tools/fail_helper
|
||||
tools_fail_helper_SOURCES = tools/fail_helper.cpp
|
||||
tools_fail_helper_LDADD = $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/fs_test
|
||||
tools_fs_test_SOURCES = tools/fs_test.cpp
|
||||
tools_fs_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_fs_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/io_test
|
||||
tools_io_test_SOURCES = tools/io_test.cpp
|
||||
tools_io_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_io_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/misc_helpers
|
||||
tools_misc_helpers_SOURCES = tools/misc_helpers.cpp
|
||||
tools_misc_helpers_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_misc_helpers_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/parser_test
|
||||
tools_parser_test_SOURCES = tools/parser_test.cpp
|
||||
tools_parser_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_parser_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/process_test
|
||||
tools_process_test_SOURCES = tools/process_test.cpp
|
||||
tools_process_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_process_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/pass_helper
|
||||
tools_pass_helper_SOURCES = tools/pass_helper.cpp
|
||||
tools_pass_helper_LDADD = $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/process_helpers
|
||||
tools_process_helpers_SOURCES = tools/process_helpers.c
|
||||
|
||||
tests_tools_PROGRAMS += tools/reader_test
|
||||
tools_reader_test_SOURCES = tools/reader_test.cpp
|
||||
tools_reader_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_reader_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/requirements_test
|
||||
tools_requirements_test_SOURCES = tools/requirements_test.cpp
|
||||
tools_requirements_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_requirements_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/several_tcs_helper
|
||||
tools_several_tcs_helper_SOURCES = tools/several_tcs_helper.c
|
||||
tools_several_tcs_helper_LDADD = libatf-c.la
|
||||
|
||||
tests_tools_PROGRAMS += tools/signals_test
|
||||
tools_signals_test_SOURCES = tools/signals_test.cpp tools/signals.cpp
|
||||
tools_signals_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_signals_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/test_program_test
|
||||
tools_test_program_test_SOURCES = tools/test_program_test.cpp
|
||||
tools_test_program_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_test_program_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/text_test
|
||||
tools_text_test_SOURCES = tools/text_test.cpp tools/text.cpp
|
||||
tools_text_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_text_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/ui_test
|
||||
tools_ui_test_SOURCES = tools/ui_test.cpp tools/ui.cpp
|
||||
tools_ui_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_ui_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/user_test
|
||||
tools_user_test_SOURCES = tools/user_test.cpp tools/user.cpp
|
||||
tools_user_test_CPPFLAGS = $(TOOLS_CPPFLAGS)
|
||||
tools_user_test_LDADD = $(TOOLS_LDADD) $(ATF_CXX_LIBS)
|
||||
|
||||
tests_tools_PROGRAMS += tools/zero_tcs_helper
|
||||
tools_zero_tcs_helper_SOURCES = tools/zero_tcs_helper.c
|
||||
tools_zero_tcs_helper_LDADD = libatf-c.la
|
||||
|
||||
# vim: syntax=make:noexpandtab:shiftwidth=8:softtabstop=8
|
317
tools/application.cpp
Normal file
317
tools/application.cpp
Normal file
@ -0,0 +1,317 @@
|
||||
//
|
||||
// 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(HAVE_CONFIG_H)
|
||||
#include "bconfig.h"
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include <unistd.h>
|
||||
}
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include "application.hpp"
|
||||
#include "defs.hpp"
|
||||
#include "ui.hpp"
|
||||
|
||||
#if !defined(HAVE_VSNPRINTF_IN_STD)
|
||||
namespace std {
|
||||
using ::vsnprintf;
|
||||
}
|
||||
#endif // !defined(HAVE_VSNPRINTF_IN_STD)
|
||||
|
||||
namespace impl = tools::application;
|
||||
#define IMPL_NAME "tools::application"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// The "usage_error" class.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
impl::usage_error::usage_error(const char *fmt, ...)
|
||||
throw() :
|
||||
std::runtime_error("usage_error; message unformatted")
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
std::vsnprintf(m_text, sizeof(m_text), fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
impl::usage_error::~usage_error(void)
|
||||
throw()
|
||||
{
|
||||
}
|
||||
|
||||
const char*
|
||||
impl::usage_error::what(void)
|
||||
const throw()
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// The "application" class.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
impl::option::option(char ch,
|
||||
const std::string& a,
|
||||
const std::string& desc) :
|
||||
m_character(ch),
|
||||
m_argument(a),
|
||||
m_description(desc)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
impl::option::operator<(const impl::option& o)
|
||||
const
|
||||
{
|
||||
return m_character < o.m_character;
|
||||
}
|
||||
|
||||
impl::app::app(const std::string& description,
|
||||
const std::string& manpage,
|
||||
const std::string& global_manpage) :
|
||||
m_hflag(false),
|
||||
m_argc(-1),
|
||||
m_argv(NULL),
|
||||
m_prog_name(NULL),
|
||||
m_description(description),
|
||||
m_manpage(manpage),
|
||||
m_global_manpage(global_manpage)
|
||||
{
|
||||
}
|
||||
|
||||
impl::app::~app(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
impl::app::inited(void)
|
||||
{
|
||||
return m_argc != -1;
|
||||
}
|
||||
|
||||
impl::app::options_set
|
||||
impl::app::options(void)
|
||||
{
|
||||
options_set opts = specific_options();
|
||||
opts.insert(option('h', "", "Shows this help message"));
|
||||
return opts;
|
||||
}
|
||||
|
||||
std::string
|
||||
impl::app::specific_args(void)
|
||||
const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
impl::app::options_set
|
||||
impl::app::specific_options(void)
|
||||
const
|
||||
{
|
||||
return options_set();
|
||||
}
|
||||
|
||||
void
|
||||
impl::app::process_option(int ch ATF_DEFS_ATTRIBUTE_UNUSED,
|
||||
const char* arg ATF_DEFS_ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
impl::app::process_options(void)
|
||||
{
|
||||
assert(inited());
|
||||
|
||||
std::string optstr;
|
||||
#if defined(HAVE_GNU_GETOPT)
|
||||
optstr += '+'; // Turn on POSIX behavior.
|
||||
#endif
|
||||
optstr += ':';
|
||||
{
|
||||
options_set opts = options();
|
||||
for (options_set::const_iterator iter = opts.begin();
|
||||
iter != opts.end(); iter++) {
|
||||
const option& opt = (*iter);
|
||||
|
||||
optstr += opt.m_character;
|
||||
if (!opt.m_argument.empty())
|
||||
optstr += ':';
|
||||
}
|
||||
}
|
||||
|
||||
int ch;
|
||||
const int old_opterr = ::opterr;
|
||||
::opterr = 0;
|
||||
while ((ch = ::getopt(m_argc, m_argv, optstr.c_str())) != -1) {
|
||||
switch (ch) {
|
||||
case 'h':
|
||||
m_hflag = true;
|
||||
break;
|
||||
|
||||
case ':':
|
||||
throw usage_error("Option -%c requires an argument.",
|
||||
::optopt);
|
||||
|
||||
case '?':
|
||||
throw usage_error("Unknown option -%c.", ::optopt);
|
||||
|
||||
default:
|
||||
process_option(ch, ::optarg);
|
||||
}
|
||||
}
|
||||
m_argc -= ::optind;
|
||||
m_argv += ::optind;
|
||||
|
||||
// Clear getopt state just in case the test wants to use it.
|
||||
opterr = old_opterr;
|
||||
optind = 1;
|
||||
#if defined(HAVE_OPTRESET)
|
||||
optreset = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
impl::app::usage(std::ostream& os)
|
||||
{
|
||||
assert(inited());
|
||||
|
||||
std::string args = specific_args();
|
||||
if (!args.empty())
|
||||
args = " " + args;
|
||||
os << ui::format_text_with_tag(std::string(m_prog_name) + " [options]" +
|
||||
args, "Usage: ", false) << "\n\n"
|
||||
<< ui::format_text(m_description) << "\n\n";
|
||||
|
||||
options_set opts = options();
|
||||
assert(!opts.empty());
|
||||
os << "Available options:\n";
|
||||
size_t coldesc = 0;
|
||||
for (options_set::const_iterator iter = opts.begin();
|
||||
iter != opts.end(); iter++) {
|
||||
const option& opt = (*iter);
|
||||
|
||||
if (opt.m_argument.length() + 1 > coldesc)
|
||||
coldesc = opt.m_argument.length() + 1;
|
||||
}
|
||||
for (options_set::const_iterator iter = opts.begin();
|
||||
iter != opts.end(); iter++) {
|
||||
const option& opt = (*iter);
|
||||
|
||||
std::string tag = std::string(" -") + opt.m_character;
|
||||
if (opt.m_argument.empty())
|
||||
tag += " ";
|
||||
else
|
||||
tag += " " + opt.m_argument + " ";
|
||||
os << ui::format_text_with_tag(opt.m_description, tag, false,
|
||||
coldesc + 10) << "\n";
|
||||
}
|
||||
os << "\n";
|
||||
|
||||
std::string gmp;
|
||||
if (!m_global_manpage.empty())
|
||||
gmp = " and " + m_global_manpage;
|
||||
os << ui::format_text("For more details please see " + m_manpage +
|
||||
gmp + ".")
|
||||
<< "\n";
|
||||
}
|
||||
|
||||
int
|
||||
impl::app::run(int argc, char* const* argv)
|
||||
{
|
||||
assert(argc > 0);
|
||||
assert(argv != NULL);
|
||||
|
||||
m_argc = argc;
|
||||
m_argv = argv;
|
||||
|
||||
m_argv0 = m_argv[0];
|
||||
|
||||
m_prog_name = std::strrchr(m_argv[0], '/');
|
||||
if (m_prog_name == NULL)
|
||||
m_prog_name = m_argv[0];
|
||||
else
|
||||
m_prog_name++;
|
||||
|
||||
// Libtool workaround: if running from within the source tree (binaries
|
||||
// that are not installed yet), skip the "lt-" prefix added to files in
|
||||
// the ".libs" directory to show the real (not temporary) name.
|
||||
if (std::strncmp(m_prog_name, "lt-", 3) == 0)
|
||||
m_prog_name += 3;
|
||||
|
||||
const std::string bug =
|
||||
std::string("This is probably a bug in ") + m_prog_name +
|
||||
" or one of the libraries it uses. Please report this problem to "
|
||||
PACKAGE_BUGREPORT " and provide as many details as possible "
|
||||
"describing how you got to this condition.";
|
||||
|
||||
int errcode;
|
||||
try {
|
||||
int oldargc = m_argc;
|
||||
|
||||
process_options();
|
||||
|
||||
if (m_hflag) {
|
||||
if (oldargc != 2)
|
||||
throw usage_error("-h must be given alone.");
|
||||
|
||||
usage(std::cout);
|
||||
errcode = EXIT_SUCCESS;
|
||||
} else
|
||||
errcode = main();
|
||||
} catch (const usage_error& e) {
|
||||
std::cerr << ui::format_error(m_prog_name, e.what()) << "\n"
|
||||
<< ui::format_info(m_prog_name, std::string("Type `") +
|
||||
m_prog_name + " -h' for more details.")
|
||||
<< "\n";
|
||||
errcode = EXIT_FAILURE;
|
||||
} catch (const std::runtime_error& e) {
|
||||
std::cerr << ui::format_error(m_prog_name, std::string(e.what()))
|
||||
<< "\n";
|
||||
errcode = EXIT_FAILURE;
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << ui::format_error(m_prog_name, std::string("Caught "
|
||||
"unexpected error: ") + e.what() + "\n" + bug) << "\n";
|
||||
errcode = EXIT_FAILURE;
|
||||
} catch (...) {
|
||||
std::cerr << ui::format_error(m_prog_name, std::string("Caught "
|
||||
"unknown error\n") + bug) << "\n";
|
||||
errcode = EXIT_FAILURE;
|
||||
}
|
||||
return errcode;
|
||||
}
|
113
tools/application.hpp
Normal file
113
tools/application.hpp
Normal file
@ -0,0 +1,113 @@
|
||||
//
|
||||
// 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(TOOLS_APPLICATION_HPP)
|
||||
#define TOOLS_APPLICATION_HPP
|
||||
|
||||
#include <ostream>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
namespace tools {
|
||||
namespace application {
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// The "usage_error" class.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
class usage_error : public std::runtime_error {
|
||||
char m_text[4096];
|
||||
|
||||
public:
|
||||
usage_error(const char*, ...) throw();
|
||||
~usage_error(void) throw();
|
||||
|
||||
const char* what(void) const throw();
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// The "option" class.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
class option {
|
||||
char m_character;
|
||||
std::string m_argument;
|
||||
std::string m_description;
|
||||
|
||||
friend class app;
|
||||
|
||||
public:
|
||||
option(char, const std::string&, const std::string&);
|
||||
|
||||
bool operator<(const option&) const;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// The "app" class.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
class app {
|
||||
bool m_hflag;
|
||||
|
||||
void process_options(void);
|
||||
void usage(std::ostream&);
|
||||
|
||||
bool inited(void);
|
||||
|
||||
protected:
|
||||
typedef std::set< option > options_set;
|
||||
|
||||
int m_argc;
|
||||
char* const* m_argv;
|
||||
|
||||
const char* m_argv0;
|
||||
const char* m_prog_name;
|
||||
std::string m_description;
|
||||
std::string m_manpage, m_global_manpage;
|
||||
|
||||
options_set options(void);
|
||||
|
||||
// To be redefined.
|
||||
virtual std::string specific_args(void) const;
|
||||
virtual options_set specific_options(void) const;
|
||||
virtual void process_option(int, const char*);
|
||||
virtual int main(void) = 0;
|
||||
|
||||
public:
|
||||
app(const std::string&, const std::string&, const std::string&);
|
||||
virtual ~app(void);
|
||||
|
||||
int run(int, char* const*);
|
||||
};
|
||||
|
||||
} // namespace application
|
||||
} // namespace tools
|
||||
|
||||
#endif // !defined(TOOLS_APPLICATION_HPP)
|
94
tools/application_test.cpp
Normal file
94
tools/application_test.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
extern "C" {
|
||||
#include <unistd.h>
|
||||
}
|
||||
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
#include "application.hpp"
|
||||
|
||||
class getopt_app : public tools::application::app {
|
||||
public:
|
||||
getopt_app(void) : app("description", "manpage", "other") {}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Provide an option that is unknown to the application driver and
|
||||
// one that is, together with an argument that would be swallowed by
|
||||
// the test program option if it were recognized.
|
||||
int argc = 4;
|
||||
char arg1[] = "progname";
|
||||
char arg2[] = "-Z";
|
||||
char arg3[] = "-s";
|
||||
char arg4[] = "foo";
|
||||
char *const argv[] = { arg1, arg2, arg3, arg4, NULL };
|
||||
|
||||
int ch;
|
||||
bool zflag;
|
||||
|
||||
// Given that this obviously is an application, and that we used the
|
||||
// same driver to start, we can test getopt(3) right here without doing
|
||||
// any fancy stuff.
|
||||
zflag = false;
|
||||
while ((ch = ::getopt(argc, argv, ":Z")) != -1) {
|
||||
switch (ch) {
|
||||
case 'Z':
|
||||
zflag = true;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
default:
|
||||
if (optopt != 's')
|
||||
ATF_FAIL("Unexpected unknown option found");
|
||||
}
|
||||
}
|
||||
|
||||
ATF_REQUIRE(zflag);
|
||||
ATF_REQUIRE_EQ(1, argc - optind);
|
||||
ATF_REQUIRE_EQ(std::string("foo"), argv[optind]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
ATF_TEST_CASE_WITHOUT_HEAD(getopt);
|
||||
ATF_TEST_CASE_BODY(getopt)
|
||||
{
|
||||
int argc = 1;
|
||||
char arg1[] = "progname";
|
||||
char *const argv[] = { arg1, NULL };
|
||||
ATF_REQUIRE_EQ(0, getopt_app().run(argc, argv));
|
||||
}
|
||||
|
||||
ATF_INIT_TEST_CASES(tcs)
|
||||
{
|
||||
ATF_ADD_TEST_CASE(tcs, getopt);
|
||||
}
|
@ -32,16 +32,11 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
extern "C" {
|
||||
#include "atf-c/defs.h"
|
||||
}
|
||||
#include "application.hpp"
|
||||
#include "config.hpp"
|
||||
#include "defs.hpp"
|
||||
|
||||
#include "atf-c++/config.hpp"
|
||||
|
||||
#include "atf-c++/detail/application.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
|
||||
class atf_config : public atf::application::app {
|
||||
class atf_config : public tools::application::app {
|
||||
static const char* m_description;
|
||||
|
||||
bool m_tflag;
|
||||
@ -79,7 +74,7 @@ atf_config::process_option(int ch, const char* arg ATF_DEFS_ATTRIBUTE_UNUSED)
|
||||
break;
|
||||
|
||||
default:
|
||||
UNREACHABLE;
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,7 +89,7 @@ atf_config::options_set
|
||||
atf_config::specific_options(void)
|
||||
const
|
||||
{
|
||||
using atf::application::option;
|
||||
using tools::application::option;
|
||||
options_set opts;
|
||||
opts.insert(option('t', "", "Terse output: show values only"));
|
||||
return opts;
|
||||
@ -117,20 +112,20 @@ int
|
||||
atf_config::main(void)
|
||||
{
|
||||
if (m_argc < 1) {
|
||||
std::map< std::string, std::string > cv = atf::config::get_all();
|
||||
std::map< std::string, std::string > cv = tools::config::get_all();
|
||||
|
||||
for (std::map< std::string, std::string >::const_iterator iter =
|
||||
cv.begin(); iter != cv.end(); iter++)
|
||||
std::cout << format_var((*iter).first, (*iter).second) << "\n";
|
||||
} else {
|
||||
for (int i = 0; i < m_argc; i++) {
|
||||
if (!atf::config::has(m_argv[i]))
|
||||
if (!tools::config::has(m_argv[i]))
|
||||
throw std::runtime_error(std::string("Unknown variable `") +
|
||||
m_argv[i] + "'");
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_argc; i++) {
|
||||
std::cout << format_var(m_argv[i], atf::config::get(m_argv[i]))
|
||||
std::cout << format_var(m_argv[i], tools::config::get(m_argv[i]))
|
||||
<< "\n";
|
||||
}
|
||||
}
|
0
atf-config/integration_test.sh → tools/atf-config_test.sh
Normal file → Executable file
0
atf-config/integration_test.sh → tools/atf-config_test.sh
Normal file → Executable file
@ -41,20 +41,17 @@ extern "C" {
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "atf-c/defs.h"
|
||||
|
||||
#include "atf-c++/detail/application.hpp"
|
||||
#include "atf-c++/detail/fs.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
#include "atf-c++/detail/text.hpp"
|
||||
#include "atf-c++/detail/ui.hpp"
|
||||
|
||||
#include "application.hpp"
|
||||
#include "defs.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "reader.hpp"
|
||||
#include "text.hpp"
|
||||
#include "ui.hpp"
|
||||
|
||||
typedef std::auto_ptr< std::ostream > ostream_ptr;
|
||||
|
||||
static ostream_ptr
|
||||
open_outfile(const atf::fs::path& path)
|
||||
open_outfile(const tools::fs::path& path)
|
||||
{
|
||||
ostream_ptr osp;
|
||||
if (path.str() == "-")
|
||||
@ -128,7 +125,7 @@ class csv_writer : public writer {
|
||||
std::string m_tcname;
|
||||
|
||||
public:
|
||||
csv_writer(const atf::fs::path& p) :
|
||||
csv_writer(const tools::fs::path& p) :
|
||||
m_os(open_outfile(p))
|
||||
{
|
||||
}
|
||||
@ -223,8 +220,8 @@ class ticker_writer : public writer {
|
||||
void
|
||||
write_tp_start(const std::string& tp, size_t ntcs)
|
||||
{
|
||||
using atf::text::to_string;
|
||||
using atf::ui::format_text;
|
||||
using tools::text::to_string;
|
||||
using tools::ui::format_text;
|
||||
|
||||
m_tpname = tp;
|
||||
|
||||
@ -238,7 +235,7 @@ class ticker_writer : public writer {
|
||||
void
|
||||
write_tp_end(struct timeval* tv, const std::string& reason)
|
||||
{
|
||||
using atf::ui::format_text_with_tag;
|
||||
using tools::ui::format_text_with_tag;
|
||||
|
||||
m_curtp++;
|
||||
|
||||
@ -290,7 +287,7 @@ class ticker_writer : public writer {
|
||||
str = "Skipped: " + reason;
|
||||
m_tcs_skipped++;
|
||||
} else
|
||||
UNREACHABLE;
|
||||
std::abort();
|
||||
|
||||
// XXX Wrap text. format_text_with_tag does not currently allow
|
||||
// to specify the current column, which is needed because we have
|
||||
@ -304,8 +301,8 @@ class ticker_writer : public writer {
|
||||
write_expected_failures(const std::map< std::string, std::string >& xfails,
|
||||
std::ostream& os)
|
||||
{
|
||||
using atf::ui::format_text;
|
||||
using atf::ui::format_text_with_tag;
|
||||
using tools::ui::format_text;
|
||||
using tools::ui::format_text_with_tag;
|
||||
|
||||
os << format_text("Test cases for known bugs:") << "\n";
|
||||
|
||||
@ -322,10 +319,10 @@ class ticker_writer : public writer {
|
||||
void
|
||||
write_eof(void)
|
||||
{
|
||||
using atf::text::join;
|
||||
using atf::text::to_string;
|
||||
using atf::ui::format_text;
|
||||
using atf::ui::format_text_with_tag;
|
||||
using tools::text::join;
|
||||
using tools::text::to_string;
|
||||
using tools::ui::format_text;
|
||||
using tools::ui::format_text_with_tag;
|
||||
|
||||
if (!m_failed_tps.empty()) {
|
||||
(*m_os) << format_text("Failed (bogus) test programs:")
|
||||
@ -362,7 +359,7 @@ class ticker_writer : public writer {
|
||||
}
|
||||
|
||||
public:
|
||||
ticker_writer(const atf::fs::path& p) :
|
||||
ticker_writer(const tools::fs::path& p) :
|
||||
m_os(open_outfile(p))
|
||||
{
|
||||
}
|
||||
@ -473,7 +470,7 @@ class xml_writer : public writer {
|
||||
} else if (state == "skipped") {
|
||||
(*m_os) << "<skipped>" << elemval(reason) << "</skipped>\n";
|
||||
} else
|
||||
UNREACHABLE;
|
||||
std::abort();
|
||||
(*m_os) << "<tc-time>" << format_tv(tv) << "</tc-time>";
|
||||
(*m_os) << "</tc>\n";
|
||||
}
|
||||
@ -485,7 +482,7 @@ class xml_writer : public writer {
|
||||
}
|
||||
|
||||
public:
|
||||
xml_writer(const atf::fs::path& p) :
|
||||
xml_writer(const tools::fs::path& p) :
|
||||
m_os(open_outfile(p))
|
||||
{
|
||||
(*m_os) << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
|
||||
@ -507,7 +504,7 @@ public:
|
||||
//! raised by the parser, redirects it to multiple writers so that they
|
||||
//! can reformat it according to their output rules.
|
||||
//!
|
||||
class converter : public atf::atf_report::atf_tps_reader {
|
||||
class converter : public tools::atf_report::atf_tps_reader {
|
||||
typedef std::vector< writer* > outs_vector;
|
||||
outs_vector m_outs;
|
||||
|
||||
@ -586,7 +583,7 @@ class converter : public atf::atf_report::atf_tps_reader {
|
||||
|
||||
public:
|
||||
converter(std::istream& is) :
|
||||
atf::atf_report::atf_tps_reader(is)
|
||||
tools::atf_report::atf_tps_reader(is)
|
||||
{
|
||||
}
|
||||
|
||||
@ -598,7 +595,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
add_output(const std::string& fmt, const atf::fs::path& p)
|
||||
add_output(const std::string& fmt, const tools::fs::path& p)
|
||||
{
|
||||
if (fmt == "csv") {
|
||||
m_outs.push_back(new csv_writer(p));
|
||||
@ -615,10 +612,10 @@ public:
|
||||
// The "atf_report" class.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
class atf_report : public atf::application::app {
|
||||
class atf_report : public tools::application::app {
|
||||
static const char* m_description;
|
||||
|
||||
typedef std::pair< std::string, atf::fs::path > fmt_path_pair;
|
||||
typedef std::pair< std::string, tools::fs::path > fmt_path_pair;
|
||||
std::vector< fmt_path_pair > m_oflags;
|
||||
|
||||
void process_option(int, const char*);
|
||||
@ -651,14 +648,14 @@ atf_report::process_option(int ch, const char* arg)
|
||||
throw std::runtime_error("Syntax error in -o option");
|
||||
else {
|
||||
std::string fmt = str.substr(0, pos);
|
||||
atf::fs::path path = atf::fs::path(str.substr(pos + 1));
|
||||
tools::fs::path path = tools::fs::path(str.substr(pos + 1));
|
||||
m_oflags.push_back(fmt_path_pair(fmt, path));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
UNREACHABLE;
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
@ -666,7 +663,7 @@ atf_report::options_set
|
||||
atf_report::specific_options(void)
|
||||
const
|
||||
{
|
||||
using atf::application::option;
|
||||
using tools::application::option;
|
||||
options_set opts;
|
||||
opts.insert(option('o', "fmt:path", "Adds a new output file; multiple "
|
||||
"ones can be specified, and a - "
|
||||
@ -681,15 +678,15 @@ atf_report::main(void)
|
||||
throw std::runtime_error("No arguments allowed");
|
||||
|
||||
if (m_oflags.empty())
|
||||
m_oflags.push_back(fmt_path_pair("ticker", atf::fs::path("-")));
|
||||
m_oflags.push_back(fmt_path_pair("ticker", tools::fs::path("-")));
|
||||
|
||||
// Look for path duplicates.
|
||||
std::set< atf::fs::path > paths;
|
||||
std::set< tools::fs::path > paths;
|
||||
for (std::vector< fmt_path_pair >::const_iterator iter = m_oflags.begin();
|
||||
iter != m_oflags.end(); iter++) {
|
||||
atf::fs::path p = (*iter).second;
|
||||
if (p == atf::fs::path("/dev/stdout"))
|
||||
p = atf::fs::path("-");
|
||||
tools::fs::path p = (*iter).second;
|
||||
if (p == tools::fs::path("/dev/stdout"))
|
||||
p = tools::fs::path("-");
|
||||
if (paths.find(p) != paths.end())
|
||||
throw std::runtime_error("The file `" + p.str() + "' was "
|
||||
"specified more than once");
|
3
atf-report/integration_test.sh → tools/atf-report_test.sh
Normal file → Executable file
3
atf-report/integration_test.sh → tools/atf-report_test.sh
Normal file → Executable file
@ -105,7 +105,7 @@ default_body()
|
||||
atf_test_case expect
|
||||
expect_body()
|
||||
{
|
||||
ln -s "$(atf_get_srcdir)/../atf-run/expect_helpers" .
|
||||
ln -s "$(atf_get_srcdir)/expect_helpers" .
|
||||
cat >Atffile <<EOF
|
||||
Content-Type: application/X-atf-atffile; version="1"
|
||||
|
||||
@ -381,6 +381,7 @@ output_xml_space_head()
|
||||
}
|
||||
output_xml_space_body()
|
||||
{
|
||||
export TESTCASE=diff
|
||||
cp $(atf_get_srcdir)/misc_helpers .
|
||||
cat >Atffile <<EOF
|
||||
Content-Type: application/X-atf-atffile; version="1"
|
@ -40,6 +40,7 @@ extern "C" {
|
||||
}
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cerrno>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
@ -48,25 +49,24 @@ extern "C" {
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "atf-c++/detail/application.hpp"
|
||||
#include "atf-c++/config.hpp"
|
||||
#include "atf-c++/tests.hpp"
|
||||
|
||||
#include "atf-c++/detail/env.hpp"
|
||||
#include "atf-c++/detail/exceptions.hpp"
|
||||
#include "atf-c++/detail/fs.hpp"
|
||||
#include "atf-c++/detail/parser.hpp"
|
||||
#include "atf-c++/detail/process.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
#include "atf-c++/detail/text.hpp"
|
||||
|
||||
#include "application.hpp"
|
||||
#include "atffile.hpp"
|
||||
#include "config.hpp"
|
||||
#include "config_file.hpp"
|
||||
#include "env.hpp"
|
||||
#include "exceptions.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "parser.hpp"
|
||||
#include "process.hpp"
|
||||
#include "requirements.hpp"
|
||||
#include "test-program.hpp"
|
||||
#include "text.hpp"
|
||||
|
||||
namespace impl = atf::atf_run;
|
||||
namespace {
|
||||
|
||||
typedef std::map< std::string, std::string > vars_map;
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
#if defined(MAXCOMLEN)
|
||||
static const std::string::size_type max_core_name_length = MAXCOMLEN;
|
||||
@ -74,12 +74,12 @@ static const std::string::size_type max_core_name_length = MAXCOMLEN;
|
||||
static const std::string::size_type max_core_name_length = std::string::npos;
|
||||
#endif
|
||||
|
||||
class atf_run : public atf::application::app {
|
||||
class atf_run : public tools::application::app {
|
||||
static const char* m_description;
|
||||
|
||||
atf::tests::vars_map m_cmdline_vars;
|
||||
vars_map m_cmdline_vars;
|
||||
|
||||
static atf::tests::vars_map::value_type parse_var(const std::string&);
|
||||
static vars_map::value_type parse_var(const std::string&);
|
||||
|
||||
void process_option(int, const char*);
|
||||
std::string specific_args(void) const;
|
||||
@ -91,14 +91,17 @@ class atf_run : public atf::application::app {
|
||||
|
||||
size_t count_tps(std::vector< std::string >) const;
|
||||
|
||||
int run_test(const atf::fs::path&, impl::atf_tps_writer&,
|
||||
const atf::tests::vars_map&);
|
||||
int run_test_directory(const atf::fs::path&, impl::atf_tps_writer&);
|
||||
int run_test_program(const atf::fs::path&, impl::atf_tps_writer&,
|
||||
const atf::tests::vars_map&);
|
||||
int run_test(const tools::fs::path&, tools::test_program::atf_tps_writer&,
|
||||
const vars_map&);
|
||||
int run_test_directory(const tools::fs::path&,
|
||||
tools::test_program::atf_tps_writer&);
|
||||
int run_test_program(const tools::fs::path&,
|
||||
tools::test_program::atf_tps_writer&,
|
||||
const vars_map&);
|
||||
|
||||
impl::test_case_result get_test_case_result(const std::string&,
|
||||
const atf::process::status&, const atf::fs::path&) const;
|
||||
tools::test_program::test_case_result get_test_case_result(
|
||||
const std::string&, const tools::process::status&,
|
||||
const tools::fs::path&) const;
|
||||
|
||||
public:
|
||||
atf_run(void);
|
||||
@ -110,7 +113,7 @@ static void
|
||||
sanitize_gdb_env(void)
|
||||
{
|
||||
try {
|
||||
atf::env::unset("TERM");
|
||||
tools::env::unset("TERM");
|
||||
} catch (...) {
|
||||
// Just swallow exceptions here; they cannot propagate into C, which
|
||||
// is where this function is called from, and even if these exceptions
|
||||
@ -119,29 +122,30 @@ sanitize_gdb_env(void)
|
||||
}
|
||||
|
||||
static void
|
||||
dump_stacktrace(const atf::fs::path& tp, const atf::process::status& s,
|
||||
const atf::fs::path& workdir, impl::atf_tps_writer& w)
|
||||
dump_stacktrace(const tools::fs::path& tp, const tools::process::status& s,
|
||||
const tools::fs::path& workdir,
|
||||
tools::test_program::atf_tps_writer& w)
|
||||
{
|
||||
PRE(s.signaled() && s.coredump());
|
||||
assert(s.signaled() && s.coredump());
|
||||
|
||||
w.stderr_tc("Test program crashed; attempting to get stack trace");
|
||||
|
||||
const atf::fs::path corename = workdir /
|
||||
const tools::fs::path corename = workdir /
|
||||
(tp.leaf_name().substr(0, max_core_name_length) + ".core");
|
||||
if (!atf::fs::exists(corename)) {
|
||||
if (!tools::fs::exists(corename)) {
|
||||
w.stderr_tc("Expected file " + corename.str() + " not found");
|
||||
return;
|
||||
}
|
||||
|
||||
const atf::fs::path gdb(GDB);
|
||||
const atf::fs::path gdbout = workdir / "gdb.out";
|
||||
const atf::process::argv_array args(gdb.leaf_name().c_str(), "-batch",
|
||||
const tools::fs::path gdb(GDB);
|
||||
const tools::fs::path gdbout = workdir / "gdb.out";
|
||||
const tools::process::argv_array args(gdb.leaf_name().c_str(), "-batch",
|
||||
"-q", "-ex", "bt", tp.c_str(),
|
||||
corename.c_str(), NULL);
|
||||
atf::process::status status = atf::process::exec(
|
||||
tools::process::status status = tools::process::exec(
|
||||
gdb, args,
|
||||
atf::process::stream_redirect_path(gdbout),
|
||||
atf::process::stream_redirect_path(atf::fs::path("/dev/null")),
|
||||
tools::process::stream_redirect_path(gdbout),
|
||||
tools::process::stream_redirect_path(tools::fs::path("/dev/null")),
|
||||
sanitize_gdb_env);
|
||||
if (!status.exited() || status.exitstatus() != EXIT_SUCCESS) {
|
||||
w.stderr_tc("Execution of " GDB " failed");
|
||||
@ -177,7 +181,7 @@ atf_run::process_option(int ch, const char* arg)
|
||||
break;
|
||||
|
||||
default:
|
||||
UNREACHABLE;
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,7 +196,7 @@ atf_run::options_set
|
||||
atf_run::specific_options(void)
|
||||
const
|
||||
{
|
||||
using atf::application::option;
|
||||
using tools::application::option;
|
||||
options_set opts;
|
||||
opts.insert(option('v', "var=value", "Sets the configuration variable "
|
||||
"`var' to `value'; overrides "
|
||||
@ -206,7 +210,7 @@ atf_run::parse_vflag(const std::string& str)
|
||||
if (str.empty())
|
||||
throw std::runtime_error("-v requires a non-empty argument");
|
||||
|
||||
std::vector< std::string > ws = atf::text::split(str, "=");
|
||||
std::vector< std::string > ws = tools::text::split(str, "=");
|
||||
if (ws.size() == 1 && str[str.length() - 1] == '=') {
|
||||
m_cmdline_vars[ws[0]] = "";
|
||||
} else {
|
||||
@ -219,18 +223,18 @@ atf_run::parse_vflag(const std::string& str)
|
||||
}
|
||||
|
||||
int
|
||||
atf_run::run_test(const atf::fs::path& tp,
|
||||
impl::atf_tps_writer& w,
|
||||
const atf::tests::vars_map& config)
|
||||
atf_run::run_test(const tools::fs::path& tp,
|
||||
tools::test_program::atf_tps_writer& w,
|
||||
const vars_map& config)
|
||||
{
|
||||
atf::fs::file_info fi(tp);
|
||||
tools::fs::file_info fi(tp);
|
||||
|
||||
int errcode;
|
||||
if (fi.get_type() == atf::fs::file_info::dir_type)
|
||||
if (fi.get_type() == tools::fs::file_info::dir_type)
|
||||
errcode = run_test_directory(tp, w);
|
||||
else {
|
||||
const atf::tests::vars_map effective_config =
|
||||
impl::merge_configs(config, m_cmdline_vars);
|
||||
const vars_map effective_config =
|
||||
tools::config_file::merge_configs(config, m_cmdline_vars);
|
||||
|
||||
errcode = run_test_program(tp, w, effective_config);
|
||||
}
|
||||
@ -238,39 +242,38 @@ atf_run::run_test(const atf::fs::path& tp,
|
||||
}
|
||||
|
||||
int
|
||||
atf_run::run_test_directory(const atf::fs::path& tp,
|
||||
impl::atf_tps_writer& w)
|
||||
atf_run::run_test_directory(const tools::fs::path& tp,
|
||||
tools::test_program::atf_tps_writer& w)
|
||||
{
|
||||
impl::atffile af = impl::read_atffile(tp / "Atffile");
|
||||
tools::atffile af = tools::read_atffile(tp / "Atffile");
|
||||
|
||||
atf::tests::vars_map test_suite_vars;
|
||||
vars_map test_suite_vars;
|
||||
{
|
||||
atf::tests::vars_map::const_iterator iter =
|
||||
af.props().find("test-suite");
|
||||
INV(iter != af.props().end());
|
||||
test_suite_vars = impl::read_config_files((*iter).second);
|
||||
vars_map::const_iterator iter = af.props().find("test-suite");
|
||||
assert(iter != af.props().end());
|
||||
test_suite_vars = tools::config_file::read_config_files((*iter).second);
|
||||
}
|
||||
|
||||
bool ok = true;
|
||||
for (std::vector< std::string >::const_iterator iter = af.tps().begin();
|
||||
iter != af.tps().end(); iter++) {
|
||||
const bool result = run_test(tp / *iter, w,
|
||||
impl::merge_configs(af.conf(), test_suite_vars));
|
||||
tools::config_file::merge_configs(af.conf(), test_suite_vars));
|
||||
ok &= (result == EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
impl::test_case_result
|
||||
tools::test_program::test_case_result
|
||||
atf_run::get_test_case_result(const std::string& broken_reason,
|
||||
const atf::process::status& s,
|
||||
const atf::fs::path& resfile)
|
||||
const tools::process::status& s,
|
||||
const tools::fs::path& resfile)
|
||||
const
|
||||
{
|
||||
using atf::text::to_string;
|
||||
using impl::read_test_case_result;
|
||||
using impl::test_case_result;
|
||||
using tools::text::to_string;
|
||||
using tools::test_program::read_test_case_result;
|
||||
using tools::test_program::test_case_result;
|
||||
|
||||
if (!broken_reason.empty()) {
|
||||
test_case_result tcr;
|
||||
@ -343,7 +346,7 @@ atf_run::get_test_case_result(const std::string& broken_reason,
|
||||
tcr = read_test_case_result(resfile);
|
||||
} catch (const std::runtime_error&) {
|
||||
return test_case_result("failed", -1, "Test program received "
|
||||
"signal " + atf::text::to_string(s.termsig()) +
|
||||
"signal " + tools::text::to_string(s.termsig()) +
|
||||
(s.coredump() ? " (core dumped)" : ""));
|
||||
}
|
||||
|
||||
@ -358,53 +361,53 @@ atf_run::get_test_case_result(const std::string& broken_reason,
|
||||
" signal but got " + to_string(s.termsig()));
|
||||
} else {
|
||||
return test_case_result("failed", -1, "Test program received "
|
||||
"signal " + atf::text::to_string(s.termsig()) +
|
||||
"signal " + tools::text::to_string(s.termsig()) +
|
||||
(s.coredump() ? " (core dumped)" : "") + " and created a "
|
||||
"bogus results file");
|
||||
}
|
||||
}
|
||||
UNREACHABLE;
|
||||
std::abort();
|
||||
return test_case_result();
|
||||
}
|
||||
|
||||
int
|
||||
atf_run::run_test_program(const atf::fs::path& tp,
|
||||
impl::atf_tps_writer& w,
|
||||
const atf::tests::vars_map& config)
|
||||
atf_run::run_test_program(const tools::fs::path& tp,
|
||||
tools::test_program::atf_tps_writer& w,
|
||||
const vars_map& config)
|
||||
{
|
||||
int errcode = EXIT_SUCCESS;
|
||||
|
||||
impl::metadata md;
|
||||
tools::test_program::metadata md;
|
||||
try {
|
||||
md = impl::get_metadata(tp, config);
|
||||
} catch (const atf::parser::format_error& e) {
|
||||
md = tools::test_program::get_metadata(tp, config);
|
||||
} catch (const tools::parser::format_error& e) {
|
||||
w.start_tp(tp.str(), 0);
|
||||
w.end_tp("Invalid format for test case list: " + std::string(e.what()));
|
||||
return EXIT_FAILURE;
|
||||
} catch (const atf::parser::parse_errors& e) {
|
||||
const std::string reason = atf::text::join(e, "; ");
|
||||
} catch (const tools::parser::parse_errors& e) {
|
||||
const std::string reason = tools::text::join(e, "; ");
|
||||
w.start_tp(tp.str(), 0);
|
||||
w.end_tp("Invalid format for test case list: " + reason);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
impl::temp_dir resdir(atf::fs::path(atf::config::get("atf_workdir")) /
|
||||
"atf-run.XXXXXX");
|
||||
tools::fs::temp_dir resdir(
|
||||
tools::fs::path(tools::config::get("atf_workdir")) / "atf-run.XXXXXX");
|
||||
|
||||
w.start_tp(tp.str(), md.test_cases.size());
|
||||
if (md.test_cases.empty()) {
|
||||
w.end_tp("Bogus test program: reported 0 test cases");
|
||||
errcode = EXIT_FAILURE;
|
||||
} else {
|
||||
for (std::map< std::string, atf::tests::vars_map >::const_iterator iter
|
||||
for (std::map< std::string, vars_map >::const_iterator iter
|
||||
= md.test_cases.begin(); iter != md.test_cases.end(); iter++) {
|
||||
const std::string& tcname = (*iter).first;
|
||||
const atf::tests::vars_map& tcmd = (*iter).second;
|
||||
const vars_map& tcmd = (*iter).second;
|
||||
|
||||
w.start_tc(tcname);
|
||||
|
||||
try {
|
||||
const std::string& reqfail = impl::check_requirements(
|
||||
const std::string& reqfail = tools::check_requirements(
|
||||
tcmd, config);
|
||||
if (!reqfail.empty()) {
|
||||
w.end_tc("skipped", reqfail);
|
||||
@ -416,51 +419,53 @@ atf_run::run_test_program(const atf::fs::path& tp,
|
||||
continue;
|
||||
}
|
||||
|
||||
const std::pair< int, int > user = impl::get_required_user(
|
||||
const std::pair< int, int > user = tools::get_required_user(
|
||||
tcmd, config);
|
||||
|
||||
atf::fs::path resfile = resdir.get_path() / "tcr";
|
||||
INV(!atf::fs::exists(resfile));
|
||||
tools::fs::path resfile = resdir.get_path() / "tcr";
|
||||
assert(!tools::fs::exists(resfile));
|
||||
try {
|
||||
const bool has_cleanup = atf::text::to_bool(
|
||||
const bool has_cleanup = tools::text::to_bool(
|
||||
(*tcmd.find("has.cleanup")).second);
|
||||
|
||||
impl::temp_dir workdir(atf::fs::path(atf::config::get(
|
||||
tools::fs::temp_dir workdir(tools::fs::path(tools::config::get(
|
||||
"atf_workdir")) / "atf-run.XXXXXX");
|
||||
if (user.first != -1 && user.second != -1) {
|
||||
if (::chown(workdir.get_path().c_str(), user.first,
|
||||
user.second) == -1) {
|
||||
throw atf::system_error("chown(" +
|
||||
throw tools::system_error("chown(" +
|
||||
workdir.get_path().str() + ")", "chown(2) failed",
|
||||
errno);
|
||||
}
|
||||
resfile = workdir.get_path() / "tcr";
|
||||
}
|
||||
|
||||
std::pair< std::string, const atf::process::status > s =
|
||||
impl::run_test_case(tp, tcname, "body", tcmd, config,
|
||||
resfile, workdir.get_path(), w);
|
||||
std::pair< std::string, const tools::process::status > s =
|
||||
tools::test_program::run_test_case(
|
||||
tp, tcname, "body", tcmd, config,
|
||||
resfile, workdir.get_path(), w);
|
||||
if (s.second.signaled() && s.second.coredump())
|
||||
dump_stacktrace(tp, s.second, workdir.get_path(), w);
|
||||
if (has_cleanup)
|
||||
(void)impl::run_test_case(tp, tcname, "cleanup", tcmd,
|
||||
config, resfile, workdir.get_path(), w);
|
||||
(void)tools::test_program::run_test_case(
|
||||
tp, tcname, "cleanup", tcmd,
|
||||
config, resfile, workdir.get_path(), w);
|
||||
|
||||
// TODO: Force deletion of workdir.
|
||||
|
||||
impl::test_case_result tcr = get_test_case_result(s.first,
|
||||
s.second, resfile);
|
||||
tools::test_program::test_case_result tcr =
|
||||
get_test_case_result(s.first, s.second, resfile);
|
||||
|
||||
w.end_tc(tcr.state(), tcr.reason());
|
||||
if (tcr.state() == "failed")
|
||||
errcode = EXIT_FAILURE;
|
||||
} catch (...) {
|
||||
if (atf::fs::exists(resfile))
|
||||
atf::fs::remove(resfile);
|
||||
if (tools::fs::exists(resfile))
|
||||
tools::fs::remove(resfile);
|
||||
throw;
|
||||
}
|
||||
if (atf::fs::exists(resfile))
|
||||
atf::fs::remove(resfile);
|
||||
if (tools::fs::exists(resfile))
|
||||
tools::fs::remove(resfile);
|
||||
|
||||
}
|
||||
w.end_tp("");
|
||||
@ -477,11 +482,11 @@ atf_run::count_tps(std::vector< std::string > tps)
|
||||
|
||||
for (std::vector< std::string >::const_iterator iter = tps.begin();
|
||||
iter != tps.end(); iter++) {
|
||||
atf::fs::path tp(*iter);
|
||||
atf::fs::file_info fi(tp);
|
||||
tools::fs::path tp(*iter);
|
||||
tools::fs::file_info fi(tp);
|
||||
|
||||
if (fi.get_type() == atf::fs::file_info::dir_type) {
|
||||
impl::atffile af = impl::read_atffile(tp / "Atffile");
|
||||
if (fi.get_type() == tools::fs::file_info::dir_type) {
|
||||
tools::atffile af = tools::read_atffile(tp / "Atffile");
|
||||
std::vector< std::string > aux = af.tps();
|
||||
for (std::vector< std::string >::iterator i2 = aux.begin();
|
||||
i2 != aux.end(); i2++)
|
||||
@ -498,16 +503,16 @@ static
|
||||
void
|
||||
call_hook(const std::string& tool, const std::string& hook)
|
||||
{
|
||||
const atf::fs::path sh(atf::config::get("atf_shell"));
|
||||
const atf::fs::path hooks =
|
||||
atf::fs::path(atf::config::get("atf_pkgdatadir")) / (tool + ".hooks");
|
||||
const tools::fs::path sh(tools::config::get("atf_shell"));
|
||||
const tools::fs::path hooks =
|
||||
tools::fs::path(tools::config::get("atf_pkgdatadir")) / (tool + ".hooks");
|
||||
|
||||
const atf::process::status s =
|
||||
atf::process::exec(sh,
|
||||
atf::process::argv_array(sh.c_str(), hooks.c_str(),
|
||||
const tools::process::status s =
|
||||
tools::process::exec(sh,
|
||||
tools::process::argv_array(sh.c_str(), hooks.c_str(),
|
||||
hook.c_str(), NULL),
|
||||
atf::process::stream_inherit(),
|
||||
atf::process::stream_inherit());
|
||||
tools::process::stream_inherit(),
|
||||
tools::process::stream_inherit());
|
||||
|
||||
|
||||
if (!s.exited() || s.exitstatus() != EXIT_SUCCESS)
|
||||
@ -518,7 +523,7 @@ call_hook(const std::string& tool, const std::string& hook)
|
||||
int
|
||||
atf_run::main(void)
|
||||
{
|
||||
impl::atffile af = impl::read_atffile(atf::fs::path("Atffile"));
|
||||
tools::atffile af = tools::read_atffile(tools::fs::path("Atffile"));
|
||||
|
||||
std::vector< std::string > tps;
|
||||
tps = af.tps();
|
||||
@ -531,23 +536,22 @@ atf_run::main(void)
|
||||
}
|
||||
|
||||
// Read configuration data for this test suite.
|
||||
atf::tests::vars_map test_suite_vars;
|
||||
vars_map test_suite_vars;
|
||||
{
|
||||
atf::tests::vars_map::const_iterator iter =
|
||||
af.props().find("test-suite");
|
||||
INV(iter != af.props().end());
|
||||
test_suite_vars = impl::read_config_files((*iter).second);
|
||||
vars_map::const_iterator iter = af.props().find("test-suite");
|
||||
assert(iter != af.props().end());
|
||||
test_suite_vars = tools::config_file::read_config_files((*iter).second);
|
||||
}
|
||||
|
||||
impl::atf_tps_writer w(std::cout);
|
||||
tools::test_program::atf_tps_writer w(std::cout);
|
||||
call_hook("atf-run", "info_start_hook");
|
||||
w.ntps(count_tps(tps));
|
||||
|
||||
bool ok = true;
|
||||
for (std::vector< std::string >::const_iterator iter = tps.begin();
|
||||
iter != tps.end(); iter++) {
|
||||
const bool result = run_test(atf::fs::path(*iter), w,
|
||||
impl::merge_configs(af.conf(), test_suite_vars));
|
||||
const bool result = run_test(tools::fs::path(*iter), w,
|
||||
tools::config_file::merge_configs(af.conf(), test_suite_vars));
|
||||
ok &= (result == EXIT_SUCCESS);
|
||||
}
|
||||
|
0
atf-run/integration_test.sh → tools/atf-run_test.sh
Normal file → Executable file
0
atf-run/integration_test.sh → tools/atf-run_test.sh
Normal file → Executable file
@ -34,12 +34,11 @@
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
#include "atf-c++/detail/application.hpp"
|
||||
#include "atf-c++/detail/ui.hpp"
|
||||
|
||||
#include "application.hpp"
|
||||
#include "revision.h"
|
||||
#include "ui.hpp"
|
||||
|
||||
class atf_version : public atf::application::app {
|
||||
class atf_version : public tools::application::app {
|
||||
static const char* m_description;
|
||||
|
||||
public:
|
||||
@ -60,8 +59,8 @@ atf_version::atf_version(void) :
|
||||
int
|
||||
atf_version::main(void)
|
||||
{
|
||||
using atf::ui::format_text;
|
||||
using atf::ui::format_text_with_tag;
|
||||
using tools::ui::format_text;
|
||||
using tools::ui::format_text_with_tag;
|
||||
|
||||
std::cout << PACKAGE_STRING " (" PACKAGE_TARNAME "-" PACKAGE_VERSION
|
||||
")\n" PACKAGE_COPYRIGHT "\n\n";
|
@ -27,19 +27,24 @@
|
||||
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
|
||||
#include "atf-c/defs.h"
|
||||
|
||||
#include "atf-c++/detail/exceptions.hpp"
|
||||
#include "atf-c++/detail/expand.hpp"
|
||||
#include "atf-c++/detail/parser.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
|
||||
#include "atffile.hpp"
|
||||
#include "defs.hpp"
|
||||
#include "exceptions.hpp"
|
||||
#include "expand.hpp"
|
||||
#include "parser.hpp"
|
||||
|
||||
namespace impl = atf::atf_run;
|
||||
namespace detail = atf::atf_run::detail;
|
||||
namespace impl = tools;
|
||||
namespace detail = tools::detail;
|
||||
|
||||
namespace {
|
||||
|
||||
typedef std::map< std::string, std::string > vars_map;
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// The "atf_atffile" auxiliary parser.
|
||||
@ -47,22 +52,22 @@ namespace detail = atf::atf_run::detail;
|
||||
|
||||
namespace atf_atffile {
|
||||
|
||||
static const atf::parser::token_type eof_type = 0;
|
||||
static const atf::parser::token_type nl_type = 1;
|
||||
static const atf::parser::token_type text_type = 2;
|
||||
static const atf::parser::token_type colon_type = 3;
|
||||
static const atf::parser::token_type conf_type = 4;
|
||||
static const atf::parser::token_type dblquote_type = 5;
|
||||
static const atf::parser::token_type equal_type = 6;
|
||||
static const atf::parser::token_type hash_type = 7;
|
||||
static const atf::parser::token_type prop_type = 8;
|
||||
static const atf::parser::token_type tp_type = 9;
|
||||
static const atf::parser::token_type tp_glob_type = 10;
|
||||
static const tools::parser::token_type eof_type = 0;
|
||||
static const tools::parser::token_type nl_type = 1;
|
||||
static const tools::parser::token_type text_type = 2;
|
||||
static const tools::parser::token_type colon_type = 3;
|
||||
static const tools::parser::token_type conf_type = 4;
|
||||
static const tools::parser::token_type dblquote_type = 5;
|
||||
static const tools::parser::token_type equal_type = 6;
|
||||
static const tools::parser::token_type hash_type = 7;
|
||||
static const tools::parser::token_type prop_type = 8;
|
||||
static const tools::parser::token_type tp_type = 9;
|
||||
static const tools::parser::token_type tp_glob_type = 10;
|
||||
|
||||
class tokenizer : public atf::parser::tokenizer< std::istream > {
|
||||
class tokenizer : public tools::parser::tokenizer< std::istream > {
|
||||
public:
|
||||
tokenizer(std::istream& is, size_t curline) :
|
||||
atf::parser::tokenizer< std::istream >
|
||||
tools::parser::tokenizer< std::istream >
|
||||
(is, true, eof_type, nl_type, text_type, curline)
|
||||
{
|
||||
add_delim(':', colon_type);
|
||||
@ -120,20 +125,20 @@ detail::atf_atffile_reader::got_eof(void)
|
||||
void
|
||||
detail::atf_atffile_reader::read(void)
|
||||
{
|
||||
using atf::parser::parse_error;
|
||||
using tools::parser::parse_error;
|
||||
using namespace atf_atffile;
|
||||
|
||||
std::pair< size_t, atf::parser::headers_map > hml =
|
||||
atf::parser::read_headers(m_is, 1);
|
||||
atf::parser::validate_content_type(hml.second,
|
||||
std::pair< size_t, tools::parser::headers_map > hml =
|
||||
tools::parser::read_headers(m_is, 1);
|
||||
tools::parser::validate_content_type(hml.second,
|
||||
"application/X-atf-atffile", 1);
|
||||
|
||||
tokenizer tkz(m_is, hml.first);
|
||||
atf::parser::parser< tokenizer > p(tkz);
|
||||
tools::parser::parser< tokenizer > p(tkz);
|
||||
|
||||
for (;;) {
|
||||
try {
|
||||
atf::parser::token t =
|
||||
tools::parser::token t =
|
||||
p.expect(conf_type, hash_type, prop_type, tp_type,
|
||||
tp_glob_type, nl_type, eof_type,
|
||||
"conf, #, prop, tp, tp-glob, a new line or eof");
|
||||
@ -175,7 +180,7 @@ detail::atf_atffile_reader::read(void)
|
||||
} else if (t.type() == nl_type) {
|
||||
continue;
|
||||
} else
|
||||
UNREACHABLE;
|
||||
std::abort();
|
||||
|
||||
t = p.expect(nl_type, hash_type, eof_type,
|
||||
"new line or comment");
|
||||
@ -198,8 +203,8 @@ detail::atf_atffile_reader::read(void)
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
class reader : public detail::atf_atffile_reader {
|
||||
const atf::fs::directory& m_dir;
|
||||
atf::tests::vars_map m_conf, m_props;
|
||||
const tools::fs::directory& m_dir;
|
||||
vars_map m_conf, m_props;
|
||||
std::vector< std::string > m_tps;
|
||||
|
||||
void
|
||||
@ -207,7 +212,7 @@ class reader : public detail::atf_atffile_reader {
|
||||
{
|
||||
if (isglob) {
|
||||
std::vector< std::string > ms =
|
||||
atf::expand::expand_glob(name, m_dir.names());
|
||||
tools::expand::expand_glob(name, m_dir.names());
|
||||
// Cannot use m_tps.insert(iterator, begin, end) here because it
|
||||
// does not work under Solaris.
|
||||
for (std::vector< std::string >::const_iterator iter = ms.begin();
|
||||
@ -215,9 +220,9 @@ class reader : public detail::atf_atffile_reader {
|
||||
m_tps.push_back(*iter);
|
||||
} else {
|
||||
if (m_dir.find(name) == m_dir.end())
|
||||
throw atf::not_found_error< atf::fs::path >
|
||||
throw tools::not_found_error< tools::fs::path >
|
||||
("Cannot locate the " + name + " file",
|
||||
atf::fs::path(name));
|
||||
tools::fs::path(name));
|
||||
m_tps.push_back(name);
|
||||
}
|
||||
}
|
||||
@ -235,20 +240,20 @@ class reader : public detail::atf_atffile_reader {
|
||||
}
|
||||
|
||||
public:
|
||||
reader(std::istream& is, const atf::fs::directory& dir) :
|
||||
reader(std::istream& is, const tools::fs::directory& dir) :
|
||||
detail::atf_atffile_reader(is),
|
||||
m_dir(dir)
|
||||
{
|
||||
}
|
||||
|
||||
const atf::tests::vars_map&
|
||||
const vars_map&
|
||||
conf(void)
|
||||
const
|
||||
{
|
||||
return m_conf;
|
||||
}
|
||||
|
||||
const atf::tests::vars_map&
|
||||
const vars_map&
|
||||
props(void)
|
||||
const
|
||||
{
|
||||
@ -267,14 +272,14 @@ public:
|
||||
// The "atffile" class.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
impl::atffile::atffile(const atf::tests::vars_map& config_vars,
|
||||
impl::atffile::atffile(const vars_map& config_vars,
|
||||
const std::vector< std::string >& test_program_names,
|
||||
const atf::tests::vars_map& properties) :
|
||||
const vars_map& properties) :
|
||||
m_conf(config_vars),
|
||||
m_tps(test_program_names),
|
||||
m_props(properties)
|
||||
{
|
||||
PRE(properties.find("test-suite") != properties.end());
|
||||
assert(properties.find("test-suite") != properties.end());
|
||||
}
|
||||
|
||||
const std::vector< std::string >&
|
||||
@ -284,14 +289,14 @@ impl::atffile::tps(void)
|
||||
return m_tps;
|
||||
}
|
||||
|
||||
const atf::tests::vars_map&
|
||||
const vars_map&
|
||||
impl::atffile::conf(void)
|
||||
const
|
||||
{
|
||||
return m_conf;
|
||||
}
|
||||
|
||||
const atf::tests::vars_map&
|
||||
const vars_map&
|
||||
impl::atffile::props(void)
|
||||
const
|
||||
{
|
||||
@ -305,16 +310,16 @@ impl::atffile::props(void)
|
||||
// XXX Glob expansion and file existance checks certainly do not belong in
|
||||
// a *parser*. This needs to be taken out...
|
||||
impl::atffile
|
||||
impl::read_atffile(const atf::fs::path& filename)
|
||||
impl::read_atffile(const tools::fs::path& filename)
|
||||
{
|
||||
// Scan the directory where the atffile lives in to gather a list of
|
||||
// all possible test programs in it.
|
||||
fs::directory dir(filename.branch_path());
|
||||
tools::fs::directory dir(filename.branch_path());
|
||||
dir.erase(filename.leaf_name());
|
||||
fs::directory::iterator iter = dir.begin();
|
||||
tools::fs::directory::iterator iter = dir.begin();
|
||||
while (iter != dir.end()) {
|
||||
const std::string& name = (*iter).first;
|
||||
const fs::file_info& fi = (*iter).second;
|
||||
const tools::fs::file_info& fi = (*iter).second;
|
||||
|
||||
// Discard hidden files and non-executable ones so that they are
|
||||
// not candidates for glob matching.
|
||||
@ -328,7 +333,7 @@ impl::read_atffile(const atf::fs::path& filename)
|
||||
// Parse the atffile.
|
||||
std::ifstream is(filename.c_str());
|
||||
if (!is)
|
||||
throw atf::not_found_error< fs::path >
|
||||
throw tools::not_found_error< tools::fs::path >
|
||||
("Cannot open Atffile", filename);
|
||||
reader r(is, dir);
|
||||
r.read();
|
||||
@ -336,7 +341,7 @@ impl::read_atffile(const atf::fs::path& filename)
|
||||
|
||||
// Sanity checks.
|
||||
if (r.props().find("test-suite") == r.props().end())
|
||||
throw atf::not_found_error< std::string >
|
||||
throw tools::not_found_error< std::string >
|
||||
("Undefined property `test-suite'", "test-suite");
|
||||
|
||||
return atffile(r.conf(), r.tps(), r.props());
|
@ -27,18 +27,16 @@
|
||||
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#if !defined(_ATF_RUN_ATFFILE_HPP_)
|
||||
#define _ATF_RUN_ATFFILE_HPP_
|
||||
#if !defined(TOOLS_ATFFILE_HPP)
|
||||
#define TOOLS_ATFFILE_HPP
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atf-c++/tests.hpp"
|
||||
#include "fs.hpp"
|
||||
|
||||
#include "atf-c++/detail/fs.hpp"
|
||||
|
||||
namespace atf {
|
||||
namespace atf_run {
|
||||
namespace tools {
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// The "atf_atffile_reader" class.
|
||||
@ -69,27 +67,26 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
class atffile {
|
||||
atf::tests::vars_map m_conf;
|
||||
std::map< std::string, std::string > m_conf;
|
||||
std::vector< std::string > m_tps;
|
||||
atf::tests::vars_map m_props;
|
||||
std::map< std::string, std::string > m_props;
|
||||
|
||||
public:
|
||||
atffile(const atf::tests::vars_map&,
|
||||
atffile(const std::map< std::string, std::string >&,
|
||||
const std::vector< std::string >&,
|
||||
const atf::tests::vars_map&);
|
||||
const std::map< std::string, std::string >&);
|
||||
|
||||
const atf::tests::vars_map& conf(void) const;
|
||||
const std::map< std::string, std::string >& conf(void) const;
|
||||
const std::vector< std::string >& tps(void) const;
|
||||
const atf::tests::vars_map& props(void) const;
|
||||
const std::map< std::string, std::string >& props(void) const;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Free functions.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
atffile read_atffile(const fs::path&);
|
||||
atffile read_atffile(const tools::fs::path&);
|
||||
|
||||
} // namespace atf_run
|
||||
} // namespace atf
|
||||
} // namespace tools
|
||||
|
||||
#endif // !defined(_ATF_RUN_ATFFILE_HPP_)
|
||||
#endif // !defined(TOOLS_ATFFILE_HPP)
|
@ -36,14 +36,13 @@ extern "C" {
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
|
||||
#include "atf-c++/macros.hpp"
|
||||
|
||||
#include "atf-c++/detail/exceptions.hpp"
|
||||
#include "atf-c++/detail/test_helpers.hpp"
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
#include "atffile.hpp"
|
||||
#include "exceptions.hpp"
|
||||
#include "test_helpers.hpp"
|
||||
|
||||
namespace detail = atf::atf_run::detail;
|
||||
namespace detail = tools::detail;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Auxiliary functions.
|
||||
@ -51,6 +50,8 @@ namespace detail = atf::atf_run::detail;
|
||||
|
||||
namespace {
|
||||
|
||||
typedef std::map< std::string, std::string > vars_map;
|
||||
|
||||
static
|
||||
std::auto_ptr< std::ofstream >
|
||||
new_atffile(void)
|
||||
@ -497,17 +498,16 @@ ATF_TEST_CASE_BODY(atffile_54)
|
||||
ATF_TEST_CASE(atffile_getters);
|
||||
ATF_TEST_CASE_HEAD(atffile_getters) {}
|
||||
ATF_TEST_CASE_BODY(atffile_getters) {
|
||||
atf::tests::vars_map config_vars;
|
||||
vars_map config_vars;
|
||||
config_vars["config-var-1"] = "value 1";
|
||||
|
||||
std::vector< std::string > test_program_names;
|
||||
test_program_names.push_back("test-program-1");
|
||||
|
||||
atf::tests::vars_map properties;
|
||||
vars_map properties;
|
||||
properties["test-suite"] = "a test name";
|
||||
|
||||
const atf::atf_run::atffile atffile(config_vars, test_program_names,
|
||||
properties);
|
||||
const tools::atffile atffile(config_vars, test_program_names, properties);
|
||||
ATF_REQUIRE(config_vars == atffile.conf());
|
||||
ATF_REQUIRE(test_program_names == atffile.tps());
|
||||
ATF_REQUIRE(properties == atffile.props());
|
||||
@ -533,8 +533,8 @@ ATF_TEST_CASE_BODY(read_ok_simple) {
|
||||
touch_exec("tp-2");
|
||||
touch_exec("tp-3");
|
||||
|
||||
const atf::atf_run::atffile atffile = atf::atf_run::read_atffile(
|
||||
atf::fs::path("Atffile"));
|
||||
const tools::atffile atffile = tools::read_atffile(
|
||||
tools::fs::path("Atffile"));
|
||||
ATF_REQUIRE_EQ(2, atffile.conf().size());
|
||||
ATF_REQUIRE_EQ("value1", atffile.conf().find("var1")->second);
|
||||
ATF_REQUIRE_EQ("value2", atffile.conf().find("var2")->second);
|
||||
@ -564,8 +564,8 @@ ATF_TEST_CASE_BODY(read_ok_some_globs) {
|
||||
touch_exec("t_hello");
|
||||
touch_exec("zzzt_hello");
|
||||
|
||||
const atf::atf_run::atffile atffile = atf::atf_run::read_atffile(
|
||||
atf::fs::path("Atffile"));
|
||||
const tools::atffile atffile = tools::read_atffile(
|
||||
tools::fs::path("Atffile"));
|
||||
ATF_REQUIRE_EQ(5, atffile.tps().size());
|
||||
ATF_REQUIRE(is_in("foo", atffile.tps()));
|
||||
ATF_REQUIRE(is_in("bar", atffile.tps()));
|
||||
@ -580,9 +580,9 @@ ATF_TEST_CASE_BODY(read_missing_test_suite) {
|
||||
(*os).close();
|
||||
|
||||
try {
|
||||
(void)atf::atf_run::read_atffile(atf::fs::path("Atffile"));
|
||||
(void)tools::read_atffile(tools::fs::path("Atffile"));
|
||||
ATF_FAIL("Missing property 'test-suite' did not raise an error");
|
||||
} catch (const atf::not_found_error< std::string >& e) {
|
||||
} catch (const tools::not_found_error< std::string >& e) {
|
||||
ATF_REQUIRE_EQ("test-suite", e.get_value());
|
||||
}
|
||||
}
|
||||
@ -599,9 +599,9 @@ ATF_TEST_CASE_BODY(read_missing_test_program) {
|
||||
touch_exec("baz");
|
||||
|
||||
try {
|
||||
(void)atf::atf_run::read_atffile(atf::fs::path("Atffile"));
|
||||
(void)tools::read_atffile(tools::fs::path("Atffile"));
|
||||
ATF_FAIL("Missing file 'bar' did not raise an error");
|
||||
} catch (const atf::not_found_error< atf::fs::path >& e) {
|
||||
} catch (const tools::not_found_error< tools::fs::path >& e) {
|
||||
ATF_REQUIRE_EQ("bar", e.get_value().str());
|
||||
}
|
||||
}
|
179
tools/auto_array.hpp
Normal file
179
tools/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(TOOLS_AUTO_ARRAY_HPP)
|
||||
#define TOOLS_AUTO_ARRAY_HPP
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
namespace tools {
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// 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 tools
|
||||
|
||||
#endif // !defined(TOOLS_AUTO_ARRAY_HPP)
|
303
tools/auto_array_test.cpp
Normal file
303
tools/auto_array_test.cpp
Normal file
@ -0,0 +1,303 @@
|
||||
//
|
||||
// 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++.hpp>
|
||||
|
||||
#include "auto_array.hpp"
|
||||
#include "defs.hpp"
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Tests for the "auto_array" class.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
class test_array {
|
||||
public:
|
||||
int m_value;
|
||||
|
||||
static ssize_t m_nblocks;
|
||||
|
||||
static
|
||||
tools::auto_array< test_array >
|
||||
do_copy(tools::auto_array< test_array >& ta)
|
||||
{
|
||||
return tools::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 tools::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 tools::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 tools::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 tools::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 tools::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 tools::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 tools::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 tools::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 tools::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);
|
||||
}
|
135
tools/config.cpp
Normal file
135
tools/config.cpp
Normal file
@ -0,0 +1,135 @@
|
||||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include <cassert>
|
||||
#include <map>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "env.hpp"
|
||||
#include "text.hpp"
|
||||
|
||||
static std::map< std::string, std::string > m_variables;
|
||||
|
||||
static struct var {
|
||||
const char *name;
|
||||
const char *default_value;
|
||||
bool can_be_empty;
|
||||
} vars[] = {
|
||||
{ "ATF_ARCH", ATF_ARCH, false, },
|
||||
{ "ATF_BUILD_CC", ATF_BUILD_CC, false, },
|
||||
{ "ATF_BUILD_CFLAGS", ATF_BUILD_CFLAGS, true, },
|
||||
{ "ATF_BUILD_CPP", ATF_BUILD_CPP, false, },
|
||||
{ "ATF_BUILD_CPPFLAGS", ATF_BUILD_CPPFLAGS, true, },
|
||||
{ "ATF_BUILD_CXX", ATF_BUILD_CXX, false, },
|
||||
{ "ATF_BUILD_CXXFLAGS", ATF_BUILD_CXXFLAGS, true, },
|
||||
{ "ATF_CONFDIR", ATF_CONFDIR, false, },
|
||||
{ "ATF_INCLUDEDIR", ATF_INCLUDEDIR, false, },
|
||||
{ "ATF_LIBDIR", ATF_LIBDIR, false, },
|
||||
{ "ATF_LIBEXECDIR", ATF_LIBEXECDIR, false, },
|
||||
{ "ATF_MACHINE", ATF_MACHINE, false, },
|
||||
{ "ATF_PKGDATADIR", ATF_PKGDATADIR, false, },
|
||||
{ "ATF_SHELL", ATF_SHELL, false, },
|
||||
{ "ATF_WORKDIR", ATF_WORKDIR, false, },
|
||||
{ NULL, NULL, false, },
|
||||
};
|
||||
|
||||
//
|
||||
// Adds all predefined standard build-time variables to the m_variables
|
||||
// map, considering the values a user may have provided in the environment.
|
||||
//
|
||||
// Can only be called once during the program's lifetime.
|
||||
//
|
||||
static
|
||||
void
|
||||
init_variables(void)
|
||||
{
|
||||
assert(m_variables.empty());
|
||||
|
||||
for (struct var* v = vars; v->name != NULL; v++) {
|
||||
const std::string varname = tools::text::to_lower(v->name);
|
||||
|
||||
if (tools::env::has(v->name)) {
|
||||
const std::string envval = tools::env::get(v->name);
|
||||
if (envval.empty() && !v->can_be_empty)
|
||||
m_variables[varname] = v->default_value;
|
||||
else
|
||||
m_variables[varname] = envval;
|
||||
} else {
|
||||
m_variables[varname] = v->default_value;
|
||||
}
|
||||
}
|
||||
|
||||
assert(!m_variables.empty());
|
||||
}
|
||||
|
||||
const std::string&
|
||||
tools::config::get(const std::string& varname)
|
||||
{
|
||||
if (m_variables.empty())
|
||||
init_variables();
|
||||
|
||||
assert(has(varname));
|
||||
return m_variables[varname];
|
||||
}
|
||||
|
||||
const std::map< std::string, std::string >&
|
||||
tools::config::get_all(void)
|
||||
{
|
||||
if (m_variables.empty())
|
||||
init_variables();
|
||||
|
||||
return m_variables;
|
||||
}
|
||||
|
||||
bool
|
||||
tools::config::has(const std::string& varname)
|
||||
{
|
||||
if (m_variables.empty())
|
||||
init_variables();
|
||||
|
||||
return m_variables.find(varname) != m_variables.end();
|
||||
}
|
||||
|
||||
namespace tools {
|
||||
namespace config {
|
||||
//
|
||||
// Auxiliary function for the t_config test program so that it can
|
||||
// revert the configuration's global status to an empty state and
|
||||
// do new tests from there on.
|
||||
//
|
||||
// Ideally this shouldn't be part of the production library... but
|
||||
// this is so small that it does not matter.
|
||||
//
|
||||
void
|
||||
__reinit(void)
|
||||
{
|
||||
m_variables.clear();
|
||||
}
|
||||
} // namespace config
|
||||
} // namespace tools
|
75
tools/config.hpp
Normal file
75
tools/config.hpp
Normal file
@ -0,0 +1,75 @@
|
||||
//
|
||||
// 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(TOOLS_CONFIG_HPP)
|
||||
#define TOOLS_CONFIG_HPP
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace tools {
|
||||
|
||||
namespace config {
|
||||
|
||||
//!
|
||||
//! \brief Gets a build-time configuration variable's value.
|
||||
//!
|
||||
//! Given the name of a build-time configuration variable, returns its
|
||||
//! textual value. The user is free to override these by setting their
|
||||
//! corresponding environment variables. Therefore always use this
|
||||
//! interface to get the value of these variables.
|
||||
//!
|
||||
//! \pre The variable must exist.
|
||||
//!
|
||||
const std::string& get(const std::string&);
|
||||
|
||||
//!
|
||||
//! \brief Returns all the build-time configuration variables.
|
||||
//!
|
||||
//! Returns a name to value map containing all build-time configuration
|
||||
//! variables.
|
||||
//!
|
||||
const std::map< std::string, std::string >& get_all(void);
|
||||
|
||||
//!
|
||||
//! \brief Checks whether a build-time configuration variable exists.
|
||||
//!
|
||||
//! Given the name of a build-time configuration variable, checks
|
||||
//! whether it is defined and returns a boolean indicating this
|
||||
//! condition. The program only has to use this function to sanity-check
|
||||
//! a variable name provided by the user. Otherwise it can assume that
|
||||
//! the variables are defined.
|
||||
//!
|
||||
bool has(const std::string&);
|
||||
|
||||
} // namespace config
|
||||
|
||||
} // namespace tools
|
||||
|
||||
#endif // !defined(TOOLS_CONFIG_HPP)
|
@ -27,38 +27,37 @@
|
||||
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
#include "atf-c/defs.h"
|
||||
|
||||
#include "atf-c++/config.hpp"
|
||||
|
||||
#include "atf-c++/detail/env.hpp"
|
||||
#include "atf-c++/detail/fs.hpp"
|
||||
#include "atf-c++/detail/sanity.hpp"
|
||||
#include "atf-c++/detail/parser.hpp"
|
||||
|
||||
#include "config.hpp"
|
||||
#include "config_file.hpp"
|
||||
#include "defs.hpp"
|
||||
#include "env.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "parser.hpp"
|
||||
|
||||
namespace impl = atf::atf_run;
|
||||
namespace detail = atf::atf_run::detail;
|
||||
namespace impl = tools::config_file;
|
||||
namespace detail = tools::config_file::detail;
|
||||
|
||||
namespace {
|
||||
|
||||
typedef std::map< std::string, std::string > vars_map;
|
||||
|
||||
namespace atf_config {
|
||||
|
||||
static const atf::parser::token_type eof_type = 0;
|
||||
static const atf::parser::token_type nl_type = 1;
|
||||
static const atf::parser::token_type text_type = 2;
|
||||
static const atf::parser::token_type dblquote_type = 3;
|
||||
static const atf::parser::token_type equal_type = 4;
|
||||
static const atf::parser::token_type hash_type = 5;
|
||||
static const tools::parser::token_type eof_type = 0;
|
||||
static const tools::parser::token_type nl_type = 1;
|
||||
static const tools::parser::token_type text_type = 2;
|
||||
static const tools::parser::token_type dblquote_type = 3;
|
||||
static const tools::parser::token_type equal_type = 4;
|
||||
static const tools::parser::token_type hash_type = 5;
|
||||
|
||||
class tokenizer : public atf::parser::tokenizer< std::istream > {
|
||||
class tokenizer : public tools::parser::tokenizer< std::istream > {
|
||||
public:
|
||||
tokenizer(std::istream& is, size_t curline) :
|
||||
atf::parser::tokenizer< std::istream >
|
||||
tools::parser::tokenizer< std::istream >
|
||||
(is, true, eof_type, nl_type, text_type, curline)
|
||||
{
|
||||
add_delim('=', equal_type);
|
||||
@ -70,7 +69,7 @@ public:
|
||||
} // namespace atf_config
|
||||
|
||||
class config_reader : public detail::atf_config_reader {
|
||||
atf::tests::vars_map m_vars;
|
||||
vars_map m_vars;
|
||||
|
||||
void
|
||||
got_var(const std::string& var, const std::string& name)
|
||||
@ -84,7 +83,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
const atf::tests::vars_map&
|
||||
const vars_map&
|
||||
get_vars(void)
|
||||
const
|
||||
{
|
||||
@ -104,8 +103,8 @@ merge_maps(std::map< K, V >& dest, const std::map< K, V >& src)
|
||||
|
||||
static
|
||||
void
|
||||
merge_config_file(const atf::fs::path& config_path,
|
||||
atf::tests::vars_map& config)
|
||||
merge_config_file(const tools::fs::path& config_path,
|
||||
vars_map& config)
|
||||
{
|
||||
std::ifstream is(config_path.c_str());
|
||||
if (is) {
|
||||
@ -116,13 +115,13 @@ merge_config_file(const atf::fs::path& config_path,
|
||||
}
|
||||
|
||||
static
|
||||
std::vector< atf::fs::path >
|
||||
std::vector< tools::fs::path >
|
||||
get_config_dirs(void)
|
||||
{
|
||||
std::vector< atf::fs::path > dirs;
|
||||
dirs.push_back(atf::fs::path(atf::config::get("atf_confdir")));
|
||||
if (atf::env::has("HOME"))
|
||||
dirs.push_back(atf::fs::path(atf::env::get("HOME")) / ".atf");
|
||||
std::vector< tools::fs::path > dirs;
|
||||
dirs.push_back(tools::fs::path(tools::config::get("atf_confdir")));
|
||||
if (tools::env::has("HOME"))
|
||||
dirs.push_back(tools::fs::path(tools::env::get("HOME")) / ".atf");
|
||||
return dirs;
|
||||
}
|
||||
|
||||
@ -152,22 +151,22 @@ detail::atf_config_reader::got_eof(void)
|
||||
void
|
||||
detail::atf_config_reader::read(void)
|
||||
{
|
||||
using atf::parser::parse_error;
|
||||
using tools::parser::parse_error;
|
||||
using namespace atf_config;
|
||||
|
||||
std::pair< size_t, atf::parser::headers_map > hml =
|
||||
atf::parser::read_headers(m_is, 1);
|
||||
atf::parser::validate_content_type(hml.second,
|
||||
std::pair< size_t, tools::parser::headers_map > hml =
|
||||
tools::parser::read_headers(m_is, 1);
|
||||
tools::parser::validate_content_type(hml.second,
|
||||
"application/X-atf-config", 1);
|
||||
|
||||
tokenizer tkz(m_is, hml.first);
|
||||
atf::parser::parser< tokenizer > p(tkz);
|
||||
tools::parser::parser< tokenizer > p(tkz);
|
||||
|
||||
for (;;) {
|
||||
try {
|
||||
atf::parser::token t = p.expect(eof_type, hash_type, text_type,
|
||||
nl_type,
|
||||
"eof, #, new line or text");
|
||||
tools::parser::token t = p.expect(eof_type, hash_type, text_type,
|
||||
nl_type,
|
||||
"eof, #, new line or text");
|
||||
if (t.type() == eof_type)
|
||||
break;
|
||||
|
||||
@ -189,7 +188,7 @@ detail::atf_config_reader::read(void)
|
||||
}
|
||||
} else if (t.type() == nl_type) {
|
||||
} else
|
||||
UNREACHABLE;
|
||||
std::abort();
|
||||
} catch (const parse_error& pe) {
|
||||
p.add_error(pe);
|
||||
p.reset(nl_type);
|
||||
@ -199,22 +198,22 @@ detail::atf_config_reader::read(void)
|
||||
ATF_PARSER_CALLBACK(p, got_eof());
|
||||
}
|
||||
|
||||
atf::tests::vars_map
|
||||
impl::merge_configs(const atf::tests::vars_map& lower,
|
||||
const atf::tests::vars_map& upper)
|
||||
vars_map
|
||||
impl::merge_configs(const vars_map& lower,
|
||||
const vars_map& upper)
|
||||
{
|
||||
atf::tests::vars_map merged = lower;
|
||||
vars_map merged = lower;
|
||||
merge_maps(merged, upper);
|
||||
return merged;
|
||||
}
|
||||
|
||||
atf::tests::vars_map
|
||||
vars_map
|
||||
impl::read_config_files(const std::string& test_suite_name)
|
||||
{
|
||||
atf::tests::vars_map config;
|
||||
vars_map config;
|
||||
|
||||
const std::vector< atf::fs::path > dirs = get_config_dirs();
|
||||
for (std::vector< atf::fs::path >::const_iterator iter = dirs.begin();
|
||||
const std::vector< tools::fs::path > dirs = get_config_dirs();
|
||||
for (std::vector< tools::fs::path >::const_iterator iter = dirs.begin();
|
||||
iter != dirs.end(); iter++) {
|
||||
merge_config_file((*iter) / "common.conf", config);
|
||||
merge_config_file((*iter) / (test_suite_name + ".conf"), config);
|
@ -27,13 +27,15 @@
|
||||
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#if !defined(TOOLS_CONFIG_FILE_HPP)
|
||||
#define TOOLS_CONFIG_FILE_HPP
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atf-c++/tests.hpp"
|
||||
|
||||
namespace atf {
|
||||
namespace atf_run {
|
||||
namespace tools {
|
||||
namespace config_file {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@ -53,9 +55,12 @@ public:
|
||||
|
||||
} // namespace detail
|
||||
|
||||
atf::tests::vars_map merge_configs(const atf::tests::vars_map&,
|
||||
const atf::tests::vars_map&);
|
||||
atf::tests::vars_map read_config_files(const std::string&);
|
||||
std::map< std::string, std::string > merge_configs(
|
||||
const std::map< std::string, std::string >&,
|
||||
const std::map< std::string, std::string >&);
|
||||
std::map< std::string, std::string > read_config_files(const std::string&);
|
||||
|
||||
} // namespace atf_run
|
||||
} // namespace atf
|
||||
} // namespace config_file
|
||||
} // namespace tools
|
||||
|
||||
#endif // !defined(TOOLS_CONFIG_FILE_HPP)
|
@ -27,17 +27,21 @@
|
||||
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "atf-c++/detail/env.hpp"
|
||||
#include "atf-c++/detail/test_helpers.hpp"
|
||||
#include "atf-c++/config.hpp"
|
||||
#include "atf-c++/macros.hpp"
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "config_file.hpp"
|
||||
#include "env.hpp"
|
||||
#include "test_helpers.hpp"
|
||||
|
||||
namespace impl = atf::atf_run;
|
||||
namespace detail = atf::atf_run::detail;
|
||||
namespace impl = tools::config_file;
|
||||
namespace detail = tools::config_file::detail;
|
||||
|
||||
using atf::tests::vars_map;
|
||||
namespace {
|
||||
|
||||
typedef std::map< std::string, std::string > vars_map;
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace atf {
|
||||
namespace config {
|
||||
@ -361,7 +365,7 @@ ATF_TEST_CASE_BODY(merge_configs_mixed) {
|
||||
ATF_TEST_CASE(read_config_files_none);
|
||||
ATF_TEST_CASE_HEAD(read_config_files_none) {}
|
||||
ATF_TEST_CASE_BODY(read_config_files_none) {
|
||||
atf::env::set("ATF_CONFDIR", ".");
|
||||
tools::env::set("ATF_CONFDIR", ".");
|
||||
atf::config::__reinit();
|
||||
ATF_REQUIRE(vars_map() == impl::read_config_files("test-suite"));
|
||||
}
|
221
tools/config_test.cpp
Normal file
221
tools/config_test.cpp
Normal file
@ -0,0 +1,221 @@
|
||||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
|
||||
// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
||||
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
#include <atf-c++.hpp>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "env.hpp"
|
||||
#include "exceptions.hpp"
|
||||
|
||||
static const char *test_value = "env-value";
|
||||
|
||||
static struct varnames {
|
||||
const char *lc;
|
||||
const char *uc;
|
||||
bool can_be_empty;
|
||||
} all_vars[] = {
|
||||
{ "atf_arch", "ATF_ARCH", false },
|
||||
{ "atf_build_cc", "ATF_BUILD_CC", false },
|
||||
{ "atf_build_cflags", "ATF_BUILD_CFLAGS", true },
|
||||
{ "atf_build_cpp", "ATF_BUILD_CPP", false },
|
||||
{ "atf_build_cppflags", "ATF_BUILD_CPPFLAGS", true },
|
||||
{ "atf_build_cxx", "ATF_BUILD_CXX", false },
|
||||
{ "atf_build_cxxflags", "ATF_BUILD_CXXFLAGS", true },
|
||||
{ "atf_confdir", "ATF_CONFDIR", false },
|
||||
{ "atf_includedir", "ATF_INCLUDEDIR", false },
|
||||
{ "atf_libdir", "ATF_LIBDIR", false },
|
||||
{ "atf_libexecdir", "ATF_LIBEXECDIR", false },
|
||||
{ "atf_machine", "ATF_MACHINE", false },
|
||||
{ "atf_pkgdatadir", "ATF_PKGDATADIR", false },
|
||||
{ "atf_shell", "ATF_SHELL", false },
|
||||
{ "atf_workdir", "ATF_WORKDIR", false },
|
||||
{ NULL, NULL, false }
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Auxiliary functions.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
namespace tools {
|
||||
namespace config {
|
||||
void __reinit(void);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
set_env_var(const char* name, const char* val)
|
||||
{
|
||||
try {
|
||||
tools::env::set(name, val);
|
||||
} catch (const tools::system_error&) {
|
||||
ATF_FAIL(std::string("set_env_var(") + name + ", " + val +
|
||||
") failed");
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
unset_env_var(const char* name)
|
||||
{
|
||||
try {
|
||||
tools::env::unset(name);
|
||||
} catch (const tools::system_error&) {
|
||||
ATF_FAIL(std::string("unset_env_var(") + name + ") failed");
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
size_t
|
||||
all_vars_count(void)
|
||||
{
|
||||
size_t count = 0;
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++)
|
||||
count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
unset_all(void)
|
||||
{
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++)
|
||||
unset_env_var(v->uc);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
compare_one(const char* var, const char* expvalue)
|
||||
{
|
||||
std::cout << "Checking that " << var << " is set to " << expvalue << "\n";
|
||||
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++) {
|
||||
if (std::strcmp(v->lc, var) == 0)
|
||||
ATF_REQUIRE_EQ(tools::config::get(v->lc), test_value);
|
||||
else
|
||||
ATF_REQUIRE(tools::config::get(v->lc) != test_value);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Test cases for the free functions.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
ATF_TEST_CASE(get);
|
||||
ATF_TEST_CASE_HEAD(get)
|
||||
{
|
||||
set_md_var("descr", "Tests the config::get function");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(get)
|
||||
{
|
||||
// Unset all known environment variables and make sure the built-in
|
||||
// values do not match the bogus value we will use for testing.
|
||||
unset_all();
|
||||
tools::config::__reinit();
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++)
|
||||
ATF_REQUIRE(tools::config::get(v->lc) != test_value);
|
||||
|
||||
// Test the behavior of empty values.
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++) {
|
||||
unset_all();
|
||||
if (!tools::config::get(v->lc).empty()) {
|
||||
set_env_var(v->uc, "");
|
||||
tools::config::__reinit();
|
||||
if (v->can_be_empty)
|
||||
ATF_REQUIRE(tools::config::get(v->lc).empty());
|
||||
else
|
||||
ATF_REQUIRE(!tools::config::get(v->lc).empty());
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the ATF_ARCH variable is recognized.
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++) {
|
||||
unset_all();
|
||||
set_env_var(v->uc, test_value);
|
||||
tools::config::__reinit();
|
||||
compare_one(v->lc, test_value);
|
||||
}
|
||||
}
|
||||
|
||||
ATF_TEST_CASE(get_all);
|
||||
ATF_TEST_CASE_HEAD(get_all)
|
||||
{
|
||||
set_md_var("descr", "Tests the config::get_all function");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(get_all)
|
||||
{
|
||||
tools::config::__reinit();
|
||||
|
||||
// Check that the valid variables, and only those, are returned.
|
||||
std::map< std::string, std::string > vars = tools::config::get_all();
|
||||
ATF_REQUIRE_EQ(vars.size(), all_vars_count());
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++)
|
||||
ATF_REQUIRE(vars.find(v->lc) != vars.end());
|
||||
}
|
||||
|
||||
ATF_TEST_CASE(has);
|
||||
ATF_TEST_CASE_HEAD(has)
|
||||
{
|
||||
set_md_var("descr", "Tests the config::has function");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(has)
|
||||
{
|
||||
tools::config::__reinit();
|
||||
|
||||
// Check for all the variables that must exist.
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++)
|
||||
ATF_REQUIRE(tools::config::has(v->lc));
|
||||
|
||||
// Same as above, but using uppercase (which is incorrect).
|
||||
for (const struct varnames* v = all_vars; v->lc != NULL; v++)
|
||||
ATF_REQUIRE(!tools::config::has(v->uc));
|
||||
|
||||
// Check for some other variables that cannot exist.
|
||||
ATF_REQUIRE(!tools::config::has("foo"));
|
||||
ATF_REQUIRE(!tools::config::has("BAR"));
|
||||
ATF_REQUIRE(!tools::config::has("atf_foo"));
|
||||
ATF_REQUIRE(!tools::config::has("ATF_BAR"));
|
||||
ATF_REQUIRE(!tools::config::has("atf_shel"));
|
||||
ATF_REQUIRE(!tools::config::has("atf_shells"));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Main.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
ATF_INIT_TEST_CASES(tcs)
|
||||
{
|
||||
// Add the test cases for the free functions.
|
||||
ATF_ADD_TEST_CASE(tcs, has);
|
||||
ATF_ADD_TEST_CASE(tcs, get);
|
||||
ATF_ADD_TEST_CASE(tcs, get_all);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Automated Testing Framework (atf)
|
||||
//
|
||||
// Copyright (c) 2007 The NetBSD Foundation, Inc.
|
||||
// Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
@ -27,18 +27,11 @@
|
||||
// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
|
||||
#include "atf-c++/macros.hpp"
|
||||
#if !defined(TOOLS_DEFS_HPP)
|
||||
#define TOOLS_DEFS_HPP
|
||||
|
||||
ATF_TEST_CASE(main);
|
||||
ATF_TEST_CASE_HEAD(main)
|
||||
{
|
||||
set_md_var("descr", "Helper test case that always passes");
|
||||
}
|
||||
ATF_TEST_CASE_BODY(main)
|
||||
{
|
||||
}
|
||||
#define ATF_DEFS_ATTRIBUTE_FORMAT_PRINTF(a, b) @ATTRIBUTE_FORMAT_PRINTF@
|
||||
#define ATF_DEFS_ATTRIBUTE_NORETURN @ATTRIBUTE_NORETURN@
|
||||
#define ATF_DEFS_ATTRIBUTE_UNUSED @ATTRIBUTE_UNUSED@
|
||||
|
||||
ATF_INIT_TEST_CASES(tcs)
|
||||
{
|
||||
ATF_ADD_TEST_CASE(tcs, main);
|
||||
}
|
||||
#endif /* !defined(TOOLS_DEFS_HPP) */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user