Date: Mon, 18 Nov 2013 18:03:52 +0000 (UTC) From: Mark Murray <markm@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r258315 - in projects/random_number_generator: . contrib/atf contrib/atf/admin contrib/atf/atf-c contrib/atf/atf-c++ contrib/atf/atf-c++/detail contrib/atf/atf-c/detail contrib/atf/atf-... Message-ID: <201311181803.rAII3qrg013224@svn.freebsd.org>
index | next in thread | raw e-mail
Author: markm Date: Mon Nov 18 18:03:52 2013 New Revision: 258315 URL: http://svnweb.freebsd.org/changeset/base/258315 Log: MFC - tracking commit Added: projects/random_number_generator/contrib/atf/atf-c++/detail/auto_array.hpp - copied unchanged from r258314, head/contrib/atf/atf-c++/detail/auto_array.hpp projects/random_number_generator/contrib/atf/atf-c++/detail/auto_array_test.cpp - copied unchanged from r258314, head/contrib/atf/atf-c++/detail/auto_array_test.cpp projects/random_number_generator/contrib/atf/atf-c++/noncopyable.hpp - copied unchanged from r258314, head/contrib/atf/atf-c++/noncopyable.hpp projects/random_number_generator/contrib/atf/atf-c++/utils.cpp - copied unchanged from r258314, head/contrib/atf/atf-c++/utils.cpp projects/random_number_generator/lib/libc/iconv/iconv-internal.h - copied unchanged from r258314, head/lib/libc/iconv/iconv-internal.h projects/random_number_generator/lib/libc/iconv/iconv_compat.c - copied unchanged from r258314, head/lib/libc/iconv/iconv_compat.c projects/random_number_generator/lib/libc_nonshared/ - copied from r258314, head/lib/libc_nonshared/ projects/random_number_generator/release/amd64/pkg-stage.conf - copied unchanged from r258314, head/release/amd64/pkg-stage.conf projects/random_number_generator/release/i386/pkg-stage.conf - copied unchanged from r258314, head/release/i386/pkg-stage.conf projects/random_number_generator/release/scripts/pkg-stage.sh - copied unchanged from r258314, head/release/scripts/pkg-stage.sh projects/random_number_generator/share/examples/tests/ - copied from r258314, head/share/examples/tests/ projects/random_number_generator/share/tests/ - copied from r258314, head/share/tests/ Deleted: projects/random_number_generator/contrib/atf/Atffile projects/random_number_generator/contrib/atf/Makefile.am projects/random_number_generator/contrib/atf/Makefile.in projects/random_number_generator/contrib/atf/admin/ projects/random_number_generator/contrib/atf/atf-c++/Atffile projects/random_number_generator/contrib/atf/atf-c++/Makefile.am.inc projects/random_number_generator/contrib/atf/atf-c++/detail/Atffile projects/random_number_generator/contrib/atf/atf-c++/detail/Makefile.am.inc projects/random_number_generator/contrib/atf/atf-c/Atffile projects/random_number_generator/contrib/atf/atf-c/Makefile.am.inc projects/random_number_generator/contrib/atf/atf-c/detail/Atffile projects/random_number_generator/contrib/atf/atf-c/detail/Makefile.am.inc projects/random_number_generator/contrib/atf/atf-c/detail/test_helpers_test.c projects/random_number_generator/contrib/atf/atf-config/ projects/random_number_generator/contrib/atf/atf-report/ projects/random_number_generator/contrib/atf/atf-run/ projects/random_number_generator/contrib/atf/atf-sh/Atffile projects/random_number_generator/contrib/atf/atf-sh/Makefile.am.inc projects/random_number_generator/contrib/atf/atf-version/ projects/random_number_generator/contrib/atf/bconfig.h.in projects/random_number_generator/contrib/atf/configure projects/random_number_generator/contrib/atf/configure.ac projects/random_number_generator/contrib/atf/doc/Makefile.am.inc projects/random_number_generator/contrib/atf/doc/atf-formats.5 projects/random_number_generator/contrib/atf/doc/atf.7.in projects/random_number_generator/contrib/atf/test-programs/Atffile projects/random_number_generator/contrib/atf/test-programs/Makefile.am.inc projects/random_number_generator/contrib/atf/test-programs/fork_test.sh Modified: projects/random_number_generator/Makefile.inc1 projects/random_number_generator/ObsoleteFiles.inc projects/random_number_generator/contrib/atf/FREEBSD-Xlist projects/random_number_generator/contrib/atf/FREEBSD-upgrade projects/random_number_generator/contrib/atf/NEWS projects/random_number_generator/contrib/atf/atf-c++.hpp projects/random_number_generator/contrib/atf/atf-c++/atf-c++-api.3 projects/random_number_generator/contrib/atf/atf-c++/check.hpp projects/random_number_generator/contrib/atf/atf-c++/check_test.cpp projects/random_number_generator/contrib/atf/atf-c++/detail/Kyuafile projects/random_number_generator/contrib/atf/atf-c++/detail/parser.hpp projects/random_number_generator/contrib/atf/atf-c++/detail/process.cpp projects/random_number_generator/contrib/atf/atf-c++/detail/process.hpp projects/random_number_generator/contrib/atf/atf-c++/detail/test_helpers.cpp projects/random_number_generator/contrib/atf/atf-c++/detail/test_helpers.hpp projects/random_number_generator/contrib/atf/atf-c++/macros_test.cpp projects/random_number_generator/contrib/atf/atf-c++/pkg_config_test.sh projects/random_number_generator/contrib/atf/atf-c++/tests.cpp projects/random_number_generator/contrib/atf/atf-c++/tests.hpp projects/random_number_generator/contrib/atf/atf-c++/utils.hpp projects/random_number_generator/contrib/atf/atf-c++/utils_test.cpp projects/random_number_generator/contrib/atf/atf-c.h projects/random_number_generator/contrib/atf/atf-c/atf-c-api.3 projects/random_number_generator/contrib/atf/atf-c/check_test.c projects/random_number_generator/contrib/atf/atf-c/detail/Kyuafile projects/random_number_generator/contrib/atf/atf-c/detail/process_test.c projects/random_number_generator/contrib/atf/atf-c/detail/sanity_test.c projects/random_number_generator/contrib/atf/atf-c/detail/test_helpers.c projects/random_number_generator/contrib/atf/atf-c/detail/test_helpers.h projects/random_number_generator/contrib/atf/atf-c/macros.h projects/random_number_generator/contrib/atf/atf-c/macros_test.c projects/random_number_generator/contrib/atf/atf-c/pkg_config_test.sh projects/random_number_generator/contrib/atf/atf-c/utils.c projects/random_number_generator/contrib/atf/atf-c/utils.h projects/random_number_generator/contrib/atf/atf-c/utils_test.c projects/random_number_generator/contrib/atf/atf-sh/atf-check.cpp projects/random_number_generator/contrib/atf/atf-sh/atf-check_test.sh projects/random_number_generator/contrib/atf/atf-sh/atf-sh-api.3 projects/random_number_generator/contrib/atf/atf-sh/atf-sh.1 projects/random_number_generator/contrib/atf/atf-sh/atf_check_test.sh projects/random_number_generator/contrib/atf/atf-sh/misc_helpers.sh projects/random_number_generator/contrib/atf/bconfig.h projects/random_number_generator/contrib/atf/test-programs/Kyuafile projects/random_number_generator/contrib/atf/test-programs/c_helpers.c projects/random_number_generator/contrib/atf/test-programs/cpp_helpers.cpp projects/random_number_generator/contrib/atf/test-programs/sh_helpers.sh projects/random_number_generator/etc/mtree/BSD.tests.dist projects/random_number_generator/include/iconv.h projects/random_number_generator/lib/Makefile projects/random_number_generator/lib/atf/libatf-c++/Makefile projects/random_number_generator/lib/atf/libatf-c++/tests/Makefile projects/random_number_generator/lib/atf/libatf-c/tests/Makefile projects/random_number_generator/lib/atf/tests/test-programs/Makefile projects/random_number_generator/lib/libc/iconv/Makefile.inc projects/random_number_generator/lib/libc/iconv/Symbol.map projects/random_number_generator/lib/libc/iconv/iconv.c projects/random_number_generator/lib/libc/libc.ldscript projects/random_number_generator/release/Makefile projects/random_number_generator/release/release.sh projects/random_number_generator/share/Makefile projects/random_number_generator/share/examples/Makefile projects/random_number_generator/share/mk/atf.test.mk projects/random_number_generator/share/mk/plain.test.mk projects/random_number_generator/sys/arm/arm/pmap-v6.c projects/random_number_generator/sys/boot/forth/beastie.4th projects/random_number_generator/sys/boot/forth/loader.4th projects/random_number_generator/sys/boot/forth/loader.4th.8 projects/random_number_generator/sys/boot/forth/loader.rc projects/random_number_generator/sys/boot/forth/menu.rc projects/random_number_generator/sys/boot/i386/loader/loader.rc projects/random_number_generator/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c projects/random_number_generator/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_userhold.c projects/random_number_generator/sys/cddl/contrib/opensolaris/uts/common/sys/fasttrap.h projects/random_number_generator/sys/conf/files.powerpc projects/random_number_generator/sys/dev/drm2/drm.h projects/random_number_generator/sys/dev/drm2/drmP.h projects/random_number_generator/sys/dev/drm2/drm_drv.c projects/random_number_generator/sys/dev/drm2/drm_ioctl.c projects/random_number_generator/sys/kern/kern_exit.c projects/random_number_generator/sys/kern/kern_sig.c projects/random_number_generator/sys/netinet/in.c projects/random_number_generator/sys/netinet/tcp_subr.c projects/random_number_generator/sys/ofed/drivers/net/mlx4/en_netdev.c projects/random_number_generator/sys/powerpc/aim/mmu_oea64.c projects/random_number_generator/sys/powerpc/aim/trap.c projects/random_number_generator/sys/powerpc/booke/trap.c projects/random_number_generator/sys/powerpc/include/pcb.h projects/random_number_generator/sys/powerpc/include/trap.h projects/random_number_generator/sys/powerpc/ofw/ofw_syscons.c projects/random_number_generator/sys/powerpc/powermac/macio.c projects/random_number_generator/sys/powerpc/powermac/uninorth.c projects/random_number_generator/sys/powerpc/powermac/uninorthpci.c projects/random_number_generator/sys/powerpc/powermac/uninorthvar.h projects/random_number_generator/sys/powerpc/powerpc/exec_machdep.c projects/random_number_generator/sys/powerpc/powerpc/fpu.c projects/random_number_generator/sys/powerpc/powerpc/swtch32.S projects/random_number_generator/sys/sys/param.h projects/random_number_generator/tools/build/mk/OptionalObsoleteFiles.inc projects/random_number_generator/tools/tools/umastat/umastat.c projects/random_number_generator/usr.sbin/bsdconfig/packages/packages projects/random_number_generator/usr.sbin/bsdconfig/share/media/cdrom.subr projects/random_number_generator/usr.sbin/bsdconfig/share/media/http.subr projects/random_number_generator/usr.sbin/bsdconfig/share/packages/index.subr projects/random_number_generator/usr.sbin/bsdconfig/share/packages/packages.subr Directory Properties: projects/random_number_generator/ (props changed) projects/random_number_generator/contrib/atf/ (props changed) projects/random_number_generator/lib/libc/ (props changed) projects/random_number_generator/sys/ (props changed) projects/random_number_generator/sys/boot/ (props changed) projects/random_number_generator/sys/cddl/contrib/opensolaris/ (props changed) projects/random_number_generator/sys/conf/ (props changed) Modified: projects/random_number_generator/Makefile.inc1 ============================================================================== --- projects/random_number_generator/Makefile.inc1 Mon Nov 18 17:52:18 2013 (r258314) +++ projects/random_number_generator/Makefile.inc1 Mon Nov 18 18:03:52 2013 (r258315) @@ -1475,11 +1475,13 @@ _startup_libs+= lib/csu/${MACHINE_CPUARC _startup_libs+= gnu/lib/libgcc _startup_libs+= lib/libcompiler_rt _startup_libs+= lib/libc +_startup_libs+= lib/libc_nonshared .if ${MK_LIBCPLUSPLUS} != "no" _startup_libs+= lib/libcxxrt .endif gnu/lib/libgcc__L: lib/libc__L +gnu/lib/libgcc__L: lib/libc_nonshared__L .if ${MK_LIBCPLUSPLUS} != "no" lib/libcxxrt__L: gnu/lib/libgcc__L .endif Modified: projects/random_number_generator/ObsoleteFiles.inc ============================================================================== --- projects/random_number_generator/ObsoleteFiles.inc Mon Nov 18 17:52:18 2013 (r258314) +++ projects/random_number_generator/ObsoleteFiles.inc Mon Nov 18 18:03:52 2013 (r258315) @@ -44,6 +44,9 @@ OLD_FILES+=usr/share/man/man2/extattr_ge # 20131107: example files removed OLD_FILES+=usr/share/examples/libusb20/aux.c OLD_FILES+=usr/share/examples/libusb20/aux.h +# 20131105: tzdata 2013h import +OLD_FILES+=usr/share/zoneinfo/America/Shiprock +OLD_FILES+=usr/share/zoneinfo/Antarctica/South_Pole # 20131103: WITH_LIBICONV_COMPAT removal OLD_FILES+=usr/include/_libiconv_compat.h OLD_FILES+=usr/lib/libiconv.a @@ -79,8 +82,14 @@ OLD_FILES+=etc/keys/pkg/trusted/pkg.free # 20131028: ng_fec(4) removed OLD_FILES+=usr/include/netgraph/ng_fec.h OLD_FILES+=usr/share/man/man4/ng_fec.4.gz +# 20131027: header moved +OLD_FILES+=usr/include/net/pf_mtag.h # 20131023: remove never used iscsi directory OLD_DIRS+=usr/share/examples/iscsi +# 20131021: isf(4) removed +OLD_FILES+=usr/sbin/isfctl +OLD_FILES+=usr/share/man/man4/isf.4.gz +OLD_FILES+=usr/share/man/man8/isfctl.8.gz # 20131014: libbsdyml becomes private OLD_FILES+=usr/lib/libbsdyml.a OLD_FILES+=usr/lib/libbsdyml.so Modified: projects/random_number_generator/contrib/atf/FREEBSD-Xlist ============================================================================== --- projects/random_number_generator/contrib/atf/FREEBSD-Xlist Mon Nov 18 17:52:18 2013 (r258314) +++ projects/random_number_generator/contrib/atf/FREEBSD-Xlist Mon Nov 18 18:03:52 2013 (r258315) @@ -1,8 +1,21 @@ +*/*/Atffile +*/*/Makefile* +*/Atffile +*/Makefile* +Atffile +INSTALL +Makefile* +aclocal.m4 +admin/ +atf-*/atf-*.m4 +atf-*/atf-*.pc.in +atf-config/ +atf-report/ +atf-run/ +atf-version/ +bconfig.h.in bootstrap/ -config.log -config.status -libtool -Makefile -stamp-h1 -*/*/.deps/ -*/.deps/ +configure* +doc/atf-formats.5 +doc/atf.7.in +m4/ Modified: projects/random_number_generator/contrib/atf/FREEBSD-upgrade ============================================================================== --- projects/random_number_generator/contrib/atf/FREEBSD-upgrade Mon Nov 18 17:52:18 2013 (r258314) +++ projects/random_number_generator/contrib/atf/FREEBSD-upgrade Mon Nov 18 18:03:52 2013 (r258315) @@ -1,28 +1,48 @@ $FreeBSD$ -atf +This document contains a collection of notes specific to the import +of atf into head. These notes are built on the instructions in +the FreeBSD Subversion Primer that detail how to deal with vendor +branches and you are supposed to follow those: -The source code is hosted on GoogleCode as a subcomponent of the Kyua project: + http://www.freebsd.org/doc/en/articles/committers-guide/subversion-primer.html - http://code.google.com/p/kyua/downloads/list - -For the contrib directory, the sources were initially prepared like so: - - ./configure --prefix=/ --exec-prefix=/usr --datarootdir=/usr/share +The ATF source code is hosted on Google Code as a subcomponent of the +Kyua project: -For the contrib directory, files and directories were pruned by: - -sh -c 'for F in `cat FREEBSD-Xlist`; do rm -rf ./$F ; done' + http://code.google.com/p/kyua/downloads/list -You may check if there are any new files that we don't need. +and is imported into the atf vendor branch (see base/vendor/atf/). -The instructions for importing new release and merging to HEAD can be found -at FreeBSD wiki: +To merge the vendor branch into head do something like this: - http://wiki.freebsd.org/SubversionPrimer/VendorImports + cd .../base/head/contrib/atf + svn merge --accept=postpone \ + svn+ssh://svn.freebsd.org/base/vendor/atf/dist . + svn remove --force $(cat FREEBSD-Xlist) + +and resolve any conflicts that may arise at this point. + +Once this is done, you must regenerate bconfig.h. The recommended way +of doing so is by using the release files already imported into the +vendor branch (which is a good justification for importing the verbatim +sources in the first place so that this step is reproducible). You can +use a set of commands similar to the following: + + mkdir /tmp/atf + cd /tmp/atf + .../vendor/atf/dist/configure \ + --prefix=/ \ + --exec-prefix=/usr \ + --datarootdir=/usr/share + cp bconfig.h .../base/head/contrib/atf/ + +Please do NOT run './configure' straight from the 'dist' directory of +the vendor branch as you easily risk committing build products into the +tree. -To make local changes to atf, simply patch and commit to the trunk -branch (aka HEAD). Never make local changes on the vendor branch. +Lastly, with the list of old and new files in this import, make sure +to udpate the reachover Makefiles accordingly. -gcooper@FreeBSD.org -5-August-2012 +Test the build (keeping in mind the WITH_TESTS/WITHOUT_TESTS knobs) and, +if all looks good, you are ready to commit all the changes in one go. Modified: projects/random_number_generator/contrib/atf/NEWS ============================================================================== --- projects/random_number_generator/contrib/atf/NEWS Mon Nov 18 17:52:18 2013 (r258314) +++ projects/random_number_generator/contrib/atf/NEWS Mon Nov 18 18:03:52 2013 (r258315) @@ -2,6 +2,58 @@ Major changes between releases =========================================================================== +Changes in version 0.18 +*********************** + +Experimental version released on November 16th, 2013. + +* Issue 45: Added require.memory support in atf-run for FreeBSD. + +* Fixed an issue with the handling of cin with libc++. + +* Issue 64: Fixed various mandoc formatting warnings. + +* NetBSD PR bin/48284: Made atf-check flush its progress message to + stdout so that an interrupted test case always shows the last message + being executed. + +* NetBSD PR bin/48285: Fixed atf_check examples in atf-sh-api(3). + + +Changes in version 0.17 +*********************** + +Experimental version released on February 14th, 2013. + +* Added the atf_utils_cat_file, atf_utils_compare_file, + atf_utils_copy_file, atf_utils_create_file, atf_utils_file_exists, + atf_utils_fork, atf_utils_grep_file, atf_utils_grep_string, + atf_utils_readline, atf_utils_redirect and atf_utils_wait utility + functions to atf-c-api. Documented the already-public + atf_utils_free_charpp function. + +* Added the cat_file, compare_file, copy_file, create_file, file_exists, + fork, grep_collection, grep_file, grep_string, redirect and wait + functions to the atf::utils namespace of atf-c++-api. These are + wrappers around the same functions added to the atf-c-api library. + +* Added the ATF_CHECK_MATCH, ATF_CHECK_MATCH_MSG, ATF_REQUIRE_MATCH and + ATF_REQUIRE_MATCH_MSG macros to atf-c to simplify the validation of a + string against a regular expression. + +* Miscellaneous fixes for manpage typos and compilation problems with + clang. + +* Added caching of the results of those configure tests that rely on + executing a test program. This should help crossbuild systems by + providing a mechanism to pre-specify what the results should be. + +* PR bin/45690: Make atf-report convert any non-printable characters to + a plain-text representation (matching their corresponding hexadecimal + entities) in XML output files. This is to prevent the output of test + cases from breaking xsltproc later. + + Changes in version 0.16 *********************** Modified: projects/random_number_generator/contrib/atf/atf-c++.hpp ============================================================================== --- projects/random_number_generator/contrib/atf/atf-c++.hpp Mon Nov 18 17:52:18 2013 (r258314) +++ projects/random_number_generator/contrib/atf/atf-c++.hpp Mon Nov 18 18:03:52 2013 (r258315) @@ -31,5 +31,6 @@ #define _ATF_CXX_HPP_ #include <atf-c++/macros.hpp> +#include <atf-c++/utils.hpp> #endif // !defined(_ATF_CXX_HPP_) Modified: projects/random_number_generator/contrib/atf/atf-c++/atf-c++-api.3 ============================================================================== --- projects/random_number_generator/contrib/atf/atf-c++/atf-c++-api.3 Mon Nov 18 17:52:18 2013 (r258314) +++ projects/random_number_generator/contrib/atf/atf-c++/atf-c++-api.3 Mon Nov 18 18:03:52 2013 (r258315) @@ -26,10 +26,11 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd January 21, 2012 +.Dd November 15, 2013 .Dt ATF-C++-API 3 .Os .Sh NAME +.Nm atf-c++-api , .Nm ATF_ADD_TEST_CASE , .Nm ATF_CHECK_ERRNO , .Nm ATF_FAIL , @@ -52,6 +53,17 @@ .Nm ATF_TEST_CASE_USE , .Nm ATF_TEST_CASE_WITH_CLEANUP , .Nm ATF_TEST_CASE_WITHOUT_HEAD , +.Nm atf::utils::cat_file , +.Nm atf::utils::compare_file , +.Nm atf::utils::copy_file , +.Nm atf::utils::create_file , +.Nm atf::utils::file_exists , +.Nm atf::utils::fork , +.Nm atf::utils::grep_collection , +.Nm atf::utils::grep_file , +.Nm atf::utils::grep_string , +.Nm atf::utils::redirect , +.Nm atf::utils::wait .Nd C++ API to write ATF-based test programs .Sh SYNOPSIS .In atf-c++.hpp @@ -77,18 +89,64 @@ .Fn ATF_TEST_CASE_USE "name" .Fn ATF_TEST_CASE_WITH_CLEANUP "name" .Fn ATF_TEST_CASE_WITHOUT_HEAD "name" +.Ft void +.Fo atf::utils::cat_file +.Fa "const std::string& path" +.Fa "const std::string& prefix" +.Fc +.Ft bool +.Fo atf::utils::compare_file +.Fa "const std::string& path" +.Fa "const std::string& contents" +.Fc +.Ft void +.Fo atf::utils::copy_file +.Fa "const std::string& source" +.Fa "const std::string& destination" +.Fc +.Ft void +.Fo atf::utils::create_file +.Fa "const std::string& path" +.Fa "const std::string& contents" +.Fc +.Ft void +.Fo atf::utils::file_exists +.Fa "const std::string& path" +.Fc +.Ft pid_t +.Fo atf::utils::fork +.Fa "void" +.Fc +.Ft bool +.Fo atf::utils::grep_collection +.Fa "const std::string& regexp" +.Fa "const Collection& collection" +.Fc +.Ft bool +.Fo atf::utils::grep_file +.Fa "const std::string& regexp" +.Fa "const std::string& path" +.Fc +.Ft bool +.Fo atf::utils::grep_string +.Fa "const std::string& regexp" +.Fa "const std::string& path" +.Fc +.Ft void +.Fo atf::utils::redirect +.Fa "const int fd" +.Fa "const std::string& path" +.Fc +.Ft void +.Fo atf::utils::wait +.Fa "const pid_t pid" +.Fa "const int expected_exit_status" +.Fa "const std::string& expected_stdout" +.Fa "const std::string& expected_stderr" +.Fc .Sh DESCRIPTION -ATF provides a mostly-macro-based programming interface to implement test -programs in C or C++. -This interface is backed by a C++ implementation, but this fact is -hidden from the developer as much as possible through the use of -macros to simplify programming. -However, the use of C++ is not hidden everywhere and while you can -implement test cases without knowing anything at all about the object model -underneath the provided calls, you might need some minimum notions of the -language in very specific circumstances. -.Pp -C++-based test programs always follow this template: +ATF provides a C++ programming interface to implement test programs. +C++-based test programs follow this template: .Bd -literal -offset indent extern "C" { .Ns ... C-specific includes go here ... @@ -205,7 +263,7 @@ The first parameter of this macro matche former call. .Ss Header definitions The test case's header can define the meta-data by using the -.Fn set +.Fn set_md_var method, which takes two parameters: the first one specifies the meta-data variable to be set and the second one specifies its value. Both of them are strings. @@ -348,7 +406,7 @@ in the collection. .Fn ATF_REQUIRE_THROW takes the name of an exception and a statement and raises a failure if the statement does not throw the specified exception. -.Fn ATF_REQUIRE_THROW_EQ +.Fn ATF_REQUIRE_THROW_RE takes the name of an exception, a regular expresion and a statement and raises a failure if the statement does not throw the specified exception and if the message of the exception does not match the regular expression. @@ -362,6 +420,163 @@ variable and, second, a boolean expressi means that a call failed and .Va errno has to be checked against the first value. +.Ss Utility functions +The following functions are provided as part of the +.Nm +API to simplify the creation of a variety of tests. +In particular, these are useful to write tests for command-line interfaces. +.Pp +.Ft void +.Fo atf::utils::cat_file +.Fa "const std::string& path" +.Fa "const std::string& prefix" +.Fc +.Bd -ragged -offset indent +Prints the contents of +.Fa path +to the standard output, prefixing every line with the string in +.Fa prefix . +.Ed +.Pp +.Ft bool +.Fo atf::utils::compare_file +.Fa "const std::string& path" +.Fa "const std::string& contents" +.Fc +.Bd -ragged -offset indent +Returns true if the given +.Fa path +matches exactly the expected inlined +.Fa contents . +.Ed +.Pp +.Ft void +.Fo atf::utils::copy_file +.Fa "const std::string& source" +.Fa "const std::string& destination" +.Fc +.Bd -ragged -offset indent +Copies the file +.Fa source +to +.Fa destination . +The permissions of the file are preserved during the code. +.Ed +.Pp +.Ft void +.Fo atf::utils::create_file +.Fa "const std::string& path" +.Fa "const std::string& contents" +.Fc +.Bd -ragged -offset indent +Creates +.Fa file +with the text given in +.Fa contents . +.Ed +.Pp +.Ft void +.Fo atf::utils::file_exists +.Fa "const std::string& path" +.Fc +.Bd -ragged -offset indent +Checks if +.Fa path +exists. +.Ed +.Pp +.Ft pid_t +.Fo atf::utils::fork +.Fa "void" +.Fc +.Bd -ragged -offset indent +Forks a process and redirects the standard output and standard error of the +child to files for later validation with +.Fn atf::utils::wait . +Fails the test case if the fork fails, so this does not return an error. +.Ed +.Pp +.Ft bool +.Fo atf::utils::grep_collection +.Fa "const std::string& regexp" +.Fa "const Collection& collection" +.Fc +.Bd -ragged -offset indent +Searches for the regular expression +.Fa regexp +in any of the strings contained in the +.Fa collection . +This is a template that accepts any one-dimensional container of strings. +.Ed +.Pp +.Ft bool +.Fo atf::utils::grep_file +.Fa "const std::string& regexp" +.Fa "const std::string& path" +.Fc +.Bd -ragged -offset indent +Searches for the regular expression +.Fa regexp +in the file +.Fa path . +The variable arguments are used to construct the regular expression. +.Ed +.Pp +.Ft bool +.Fo atf::utils::grep_string +.Fa "const std::string& regexp" +.Fa "const std::string& str" +.Fc +.Bd -ragged -offset indent +Searches for the regular expression +.Fa regexp +in the string +.Fa str . +.Ed +.Ft void +.Fo atf::utils::redirect +.Fa "const int fd" +.Fa "const std::string& path" +.Fc +.Bd -ragged -offset indent +Redirects the given file descriptor +.Fa fd +to the file +.Fa path . +This function exits the process in case of an error and does not properly mark +the test case as failed. +As a result, it should only be used in subprocesses of the test case; specially +those spawned by +.Fn atf::utils::fork . +.Ed +.Pp +.Ft void +.Fo atf::utils::wait +.Fa "const pid_t pid" +.Fa "const int expected_exit_status" +.Fa "const std::string& expected_stdout" +.Fa "const std::string& expected_stderr" +.Fc +.Bd -ragged -offset indent +Waits and validates the result of a subprocess spawned with +.Fn atf::utils::wait . +The validation involves checking that the subprocess exited cleanly and returned +the code specified in +.Fa expected_exit_status +and that its standard output and standard error match the strings given in +.Fa expected_stdout +and +.Fa expected_stderr . +.Pp +If any of the +.Fa expected_stdout +or +.Fa expected_stderr +strings are prefixed with +.Sq save: , +then they specify the name of the file into which to store the stdout or stderr +of the subprocess, and no comparison is performed. +.Ed .Sh EXAMPLES The following shows a complete test program with a single test case that validates the addition operator: @@ -371,7 +586,7 @@ validates the addition operator: ATF_TEST_CASE(addition); ATF_TEST_CASE_HEAD(addition) { - set("descr", "Sample tests for the addition operator"); + set_md_var("descr", "Sample tests for the addition operator"); } ATF_TEST_CASE_BODY(addition) { @@ -387,7 +602,7 @@ ATF_TEST_CASE_BODY(addition) ATF_TEST_CASE(open_failure); ATF_TEST_CASE_HEAD(open_failure) { - set("descr", "Sample tests for the open function"); + set_md_var("descr", "Sample tests for the open function"); } ATF_TEST_CASE_BODY(open_failure) { @@ -397,7 +612,7 @@ ATF_TEST_CASE_BODY(open_failure) ATF_TEST_CASE(known_bug); ATF_TEST_CASE_HEAD(known_bug) { - set("descr", "Reproduces a known bug"); + set_md_var("descr", "Reproduces a known bug"); } ATF_TEST_CASE_BODY(known_bug) { Modified: projects/random_number_generator/contrib/atf/atf-c++/check.hpp ============================================================================== --- projects/random_number_generator/contrib/atf/atf-c++/check.hpp Mon Nov 18 17:52:18 2013 (r258314) +++ projects/random_number_generator/contrib/atf/atf-c++/check.hpp Mon Nov 18 18:03:52 2013 (r258315) @@ -39,7 +39,7 @@ extern "C" { #include <string> #include <vector> -#include <atf-c++/utils.hpp> +#include <atf-c++/noncopyable.hpp> namespace atf { @@ -60,7 +60,7 @@ namespace check { //! of executing arbitrary command and manages files containing //! its output. //! -class check_result : utils::noncopyable { +class check_result : noncopyable { //! //! \brief Internal representation of a result. //! Modified: projects/random_number_generator/contrib/atf/atf-c++/check_test.cpp ============================================================================== --- projects/random_number_generator/contrib/atf/atf-c++/check_test.cpp Mon Nov 18 17:52:18 2013 (r258314) +++ projects/random_number_generator/contrib/atf/atf-c++/check_test.cpp Mon Nov 18 18:03:52 2013 (r258315) @@ -193,15 +193,15 @@ ATF_TEST_CASE_BODY(build_c_o) { ATF_TEST_CASE_USE(h_build_c_o_ok); run_h_tc< ATF_TEST_CASE_NAME(h_build_c_o_ok) >(); - ATF_REQUIRE(grep_file("stdout", "-o test.o")); - ATF_REQUIRE(grep_file("stdout", "-c test.c")); + ATF_REQUIRE(atf::utils::grep_file("-o test.o", "stdout")); + ATF_REQUIRE(atf::utils::grep_file("-c test.c", "stdout")); ATF_TEST_CASE_USE(h_build_c_o_fail); run_h_tc< ATF_TEST_CASE_NAME(h_build_c_o_fail) >(); - ATF_REQUIRE(grep_file("stdout", "-o test.o")); - ATF_REQUIRE(grep_file("stdout", "-c test.c")); - ATF_REQUIRE(grep_file("stderr", "test.c")); - ATF_REQUIRE(grep_file("stderr", "UNDEFINED_SYMBOL")); + ATF_REQUIRE(atf::utils::grep_file("-o test.o", "stdout")); + ATF_REQUIRE(atf::utils::grep_file("-c test.c", "stdout")); + ATF_REQUIRE(atf::utils::grep_file("test.c", "stderr")); + ATF_REQUIRE(atf::utils::grep_file("UNDEFINED_SYMBOL", "stderr")); } ATF_TEST_CASE(build_cpp); @@ -213,16 +213,16 @@ ATF_TEST_CASE_BODY(build_cpp) { ATF_TEST_CASE_USE(h_build_cpp_ok); run_h_tc< ATF_TEST_CASE_NAME(h_build_cpp_ok) >(); - ATF_REQUIRE(grep_file("stdout", "-o.*test.p")); - ATF_REQUIRE(grep_file("stdout", "test.c")); - ATF_REQUIRE(grep_file("test.p", "foo bar")); + ATF_REQUIRE(atf::utils::grep_file("-o.*test.p", "stdout")); + ATF_REQUIRE(atf::utils::grep_file("test.c", "stdout")); + ATF_REQUIRE(atf::utils::grep_file("foo bar", "test.p")); ATF_TEST_CASE_USE(h_build_cpp_fail); run_h_tc< ATF_TEST_CASE_NAME(h_build_cpp_fail) >(); - ATF_REQUIRE(grep_file("stdout", "-o test.p")); - ATF_REQUIRE(grep_file("stdout", "test.c")); - ATF_REQUIRE(grep_file("stderr", "test.c")); - ATF_REQUIRE(grep_file("stderr", "non-existent.h")); + ATF_REQUIRE(atf::utils::grep_file("-o test.p", "stdout")); + ATF_REQUIRE(atf::utils::grep_file("test.c", "stdout")); + ATF_REQUIRE(atf::utils::grep_file("test.c", "stderr")); + ATF_REQUIRE(atf::utils::grep_file("non-existent.h", "stderr")); } ATF_TEST_CASE(build_cxx_o); @@ -234,15 +234,15 @@ ATF_TEST_CASE_BODY(build_cxx_o) { ATF_TEST_CASE_USE(h_build_cxx_o_ok); run_h_tc< ATF_TEST_CASE_NAME(h_build_cxx_o_ok) >(); - ATF_REQUIRE(grep_file("stdout", "-o test.o")); - ATF_REQUIRE(grep_file("stdout", "-c test.cpp")); + ATF_REQUIRE(atf::utils::grep_file("-o test.o", "stdout")); + ATF_REQUIRE(atf::utils::grep_file("-c test.cpp", "stdout")); ATF_TEST_CASE_USE(h_build_cxx_o_fail); run_h_tc< ATF_TEST_CASE_NAME(h_build_cxx_o_fail) >(); - ATF_REQUIRE(grep_file("stdout", "-o test.o")); - ATF_REQUIRE(grep_file("stdout", "-c test.cpp")); - ATF_REQUIRE(grep_file("stderr", "test.cpp")); - ATF_REQUIRE(grep_file("stderr", "UNDEFINED_SYMBOL")); + ATF_REQUIRE(atf::utils::grep_file("-o test.o", "stdout")); + ATF_REQUIRE(atf::utils::grep_file("-c test.cpp", "stdout")); + ATF_REQUIRE(atf::utils::grep_file("test.cpp", "stderr")); + ATF_REQUIRE(atf::utils::grep_file("UNDEFINED_SYMBOL", "stderr")); } ATF_TEST_CASE(exec_cleanup); Modified: projects/random_number_generator/contrib/atf/atf-c++/detail/Kyuafile ============================================================================== --- projects/random_number_generator/contrib/atf/atf-c++/detail/Kyuafile Mon Nov 18 17:52:18 2013 (r258314) +++ projects/random_number_generator/contrib/atf/atf-c++/detail/Kyuafile Mon Nov 18 18:03:52 2013 (r258315) @@ -3,6 +3,7 @@ syntax("kyuafile", 1) test_suite("atf") atf_test_program{name="application_test"} +atf_test_program{name="auto_array_test"} atf_test_program{name="env_test"} atf_test_program{name="exceptions_test"} atf_test_program{name="expand_test"} Copied: projects/random_number_generator/contrib/atf/atf-c++/detail/auto_array.hpp (from r258314, head/contrib/atf/atf-c++/detail/auto_array.hpp) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/random_number_generator/contrib/atf/atf-c++/detail/auto_array.hpp Mon Nov 18 18:03:52 2013 (r258315, copy of r258314, head/contrib/atf/atf-c++/detail/auto_array.hpp) @@ -0,0 +1,179 @@ +// +// Automated Testing Framework (atf) +// +// Copyright (c) 2007 The NetBSD Foundation, Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND +// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +#if !defined(_ATF_CXX_AUTO_ARRAY_HPP_) +#define _ATF_CXX_AUTO_ARRAY_HPP_ + +#include <cstddef> + +namespace atf { + +// ------------------------------------------------------------------------ +// The "auto_array" class. +// ------------------------------------------------------------------------ + +template< class T > +struct auto_array_ref { + T* m_ptr; + + explicit auto_array_ref(T*); +}; + +template< class T > +auto_array_ref< T >::auto_array_ref(T* ptr) : + m_ptr(ptr) +{ +} + +template< class T > +class auto_array { + T* m_ptr; + +public: + auto_array(T* = NULL) throw(); + auto_array(auto_array< T >&) throw(); + auto_array(auto_array_ref< T >) throw(); + ~auto_array(void) throw(); + + T* get(void) throw(); + const T* get(void) const throw(); + T* release(void) throw(); + void reset(T* = NULL) throw(); + + auto_array< T >& operator=(auto_array< T >&) throw(); + auto_array< T >& operator=(auto_array_ref< T >) throw(); + + T& operator[](int) throw(); + operator auto_array_ref< T >(void) throw(); +}; + +template< class T > +auto_array< T >::auto_array(T* ptr) + throw() : + m_ptr(ptr) +{ +} + +template< class T > +auto_array< T >::auto_array(auto_array< T >& ptr) + throw() : + m_ptr(ptr.release()) +{ +} + +template< class T > +auto_array< T >::auto_array(auto_array_ref< T > ref) + throw() : + m_ptr(ref.m_ptr) +{ +} + +template< class T > +auto_array< T >::~auto_array(void) + throw() +{ + if (m_ptr != NULL) + delete [] m_ptr; +} + +template< class T > +T* +auto_array< T >::get(void) + throw() +{ + return m_ptr; +} + +template< class T > +const T* +auto_array< T >::get(void) + const throw() +{ + return m_ptr; +} + +template< class T > +T* +auto_array< T >::release(void) + throw() +{ + T* ptr = m_ptr; + m_ptr = NULL; + return ptr; +} + +template< class T > +void +auto_array< T >::reset(T* ptr) + throw() +{ + if (m_ptr != NULL) + delete [] m_ptr; + m_ptr = ptr; +} + +template< class T > +auto_array< T >& +auto_array< T >::operator=(auto_array< T >& ptr) + throw() +{ + reset(ptr.release()); + return *this; +} + +template< class T > +auto_array< T >& +auto_array< T >::operator=(auto_array_ref< T > ref) + throw() +{ + if (m_ptr != ref.m_ptr) { + delete [] m_ptr; + m_ptr = ref.m_ptr; + } + return *this; +} + +template< class T > +T& +auto_array< T >::operator[](int pos) + throw() +{ + return m_ptr[pos]; +} + +template< class T > +auto_array< T >::operator auto_array_ref< T >(void) + throw() +{ + return auto_array_ref< T >(release()); +} + +} // namespace atf + +#endif // !defined(_ATF_CXX_AUTO_ARRAY_HPP_) Copied: projects/random_number_generator/contrib/atf/atf-c++/detail/auto_array_test.cpp (from r258314, head/contrib/atf/atf-c++/detail/auto_array_test.cpp) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/random_number_generator/contrib/atf/atf-c++/detail/auto_array_test.cpp Mon Nov 18 18:03:52 2013 (r258315, copy of r258314, head/contrib/atf/atf-c++/detail/auto_array_test.cpp) @@ -0,0 +1,304 @@ +// +// Automated Testing Framework (atf) +// +// Copyright (c) 2007 The NetBSD Foundation, Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND +// CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +// IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +extern "C" { +#include <sys/types.h> +} + +#include <iostream> + +#include "atf-c/defs.h" + +#include "../macros.hpp" + +#include "auto_array.hpp" + +// ------------------------------------------------------------------------ +// Tests for the "auto_array" class. +// ------------------------------------------------------------------------ + +class test_array { +public: + int m_value; + + static ssize_t m_nblocks; + + static + atf::auto_array< test_array > + do_copy(atf::auto_array< test_array >& ta) + { + return atf::auto_array< test_array >(ta); + } + + void* operator new(size_t size ATF_DEFS_ATTRIBUTE_UNUSED) + { + ATF_FAIL("New called but should have been new[]"); + return new int(5); + } + + void* operator new[](size_t size) + { + m_nblocks++; + void* mem = ::operator new(size); + std::cout << "Allocated 'test_array' object " << mem << "\n"; + return mem; + } + + void operator delete(void* mem ATF_DEFS_ATTRIBUTE_UNUSED) + { + ATF_FAIL("Delete called but should have been delete[]"); + } + + void operator delete[](void* mem) + { + std::cout << "Releasing 'test_array' object " << mem << "\n"; + if (m_nblocks == 0) + ATF_FAIL("Unbalanced delete[]"); + m_nblocks--; + ::operator delete(mem); + } +}; + +ssize_t test_array::m_nblocks = 0; + +ATF_TEST_CASE(auto_array_scope); +ATF_TEST_CASE_HEAD(auto_array_scope) +{ + set_md_var("descr", "Tests the automatic scope handling in the " + "auto_array smart pointer class"); +} +ATF_TEST_CASE_BODY(auto_array_scope) +{ + using atf::auto_array; + + ATF_REQUIRE_EQ(test_array::m_nblocks, 0); + { + auto_array< test_array > t(new test_array[10]); + ATF_REQUIRE_EQ(test_array::m_nblocks, 1); + } + ATF_REQUIRE_EQ(test_array::m_nblocks, 0); +} + +ATF_TEST_CASE(auto_array_copy); +ATF_TEST_CASE_HEAD(auto_array_copy) +{ + set_md_var("descr", "Tests the auto_array smart pointer class' copy " + "constructor"); +} +ATF_TEST_CASE_BODY(auto_array_copy) +{ + using atf::auto_array; + + ATF_REQUIRE_EQ(test_array::m_nblocks, 0); + { + auto_array< test_array > t1(new test_array[10]); + ATF_REQUIRE_EQ(test_array::m_nblocks, 1); + + { + auto_array< test_array > t2(t1); + ATF_REQUIRE_EQ(test_array::m_nblocks, 1); + } + ATF_REQUIRE_EQ(test_array::m_nblocks, 0); + } + ATF_REQUIRE_EQ(test_array::m_nblocks, 0); +} + +ATF_TEST_CASE(auto_array_copy_ref); +ATF_TEST_CASE_HEAD(auto_array_copy_ref) +{ + set_md_var("descr", "Tests the auto_array smart pointer class' copy " + "constructor through the auxiliary auto_array_ref object"); +} +ATF_TEST_CASE_BODY(auto_array_copy_ref) +{ + using atf::auto_array; + + ATF_REQUIRE_EQ(test_array::m_nblocks, 0); + { + auto_array< test_array > t1(new test_array[10]); + ATF_REQUIRE_EQ(test_array::m_nblocks, 1); + + { + auto_array< test_array > t2 = test_array::do_copy(t1); + ATF_REQUIRE_EQ(test_array::m_nblocks, 1); + } + ATF_REQUIRE_EQ(test_array::m_nblocks, 0); + } + ATF_REQUIRE_EQ(test_array::m_nblocks, 0); +} + +ATF_TEST_CASE(auto_array_get); +ATF_TEST_CASE_HEAD(auto_array_get) +{ + set_md_var("descr", "Tests the auto_array smart pointer class' get " + "method"); +} +ATF_TEST_CASE_BODY(auto_array_get) +{ + using atf::auto_array; + + test_array* ta = new test_array[10]; + auto_array< test_array > t(ta); + ATF_REQUIRE_EQ(t.get(), ta); +} + +ATF_TEST_CASE(auto_array_release); +ATF_TEST_CASE_HEAD(auto_array_release) +{ + set_md_var("descr", "Tests the auto_array smart pointer class' release " + "method"); +} +ATF_TEST_CASE_BODY(auto_array_release) +{ + using atf::auto_array; + + test_array* ta1 = new test_array[10]; + { + auto_array< test_array > t(ta1); + ATF_REQUIRE_EQ(test_array::m_nblocks, 1); *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201311181803.rAII3qrg013224>
