diff options
147 files changed, 3019 insertions, 6883 deletions
diff --git a/contrib/kyua/.cirrus.yml b/contrib/kyua/.cirrus.yml deleted file mode 100644 index 855693b34fa1..000000000000 --- a/contrib/kyua/.cirrus.yml +++ /dev/null @@ -1,25 +0,0 @@ -env: - ARCH: amd64 - -task: - matrix: - - name: 14.0-RELEASE - freebsd_instance: - image_family: freebsd-14-0 - - name: 14.0-STABLE - freebsd_instance: - image_family: freebsd-14-0-snap - - name: 13.2-RELEASE - freebsd_instance: - image_family: freebsd-13-2 - - name: 13.2-STABLE - freebsd_instance: - image_family: freebsd-13-2-snap - env: - DO: distcheck - install_script: - - sed -i.bak -e 's,pkg+http://pkg.FreeBSD.org/\${ABI}/quarterly,pkg+http://pkg.FreeBSD.org/\${ABI}/latest,' /etc/pkg/FreeBSD.conf - - ASSUME_ALWAYS_YES=yes pkg bootstrap -f - - pkg install -y autoconf automake atf lutok pkgconf sqlite3 - script: - - ./admin/travis-build.sh diff --git a/contrib/kyua/.gitignore b/contrib/kyua/.gitignore deleted file mode 100644 index d7f1a180d6fb..000000000000 --- a/contrib/kyua/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -*.a -*.o -*_helpers -*_inttest -*_test -*~ - -.deps -.dirstamp -Doxyfile -Makefile -Makefile.in -aclocal.m4 -api-docs -autom4te.cache -config.h -config.h.in -config.log -config.status -configure -kyua -local-kyua -stamp-h1 diff --git a/contrib/kyua/.travis.yml b/contrib/kyua/.travis.yml deleted file mode 100644 index 619dceaf3d2d..000000000000 --- a/contrib/kyua/.travis.yml +++ /dev/null @@ -1,49 +0,0 @@ -language: cpp -sudo: required - -before_install: - - ./admin/travis-install-deps.sh - -matrix: - include: - - os: linux - dist: xenial - compiler: clang - env: ARCH=amd64 DO=distcheck AS_ROOT=no - - os: linux - dist: xenial - compiler: gcc - env: ARCH=amd64 DO=distcheck AS_ROOT=no - - os: linux - dist: xenial - compiler: clang - env: ARCH=amd64 DO=apidocs - - os: linux - dist: xenial - compiler: clang - env: ARCH=amd64 DO=style - - os: linux - dist: xenial - compiler: clang - env: ARCH=amd64 DO=distcheck AS_ROOT=yes UNPRIVILEGED_USER=no - - os: linux - dist: xenial - compiler: clang - env: ARCH=amd64 DO=distcheck AS_ROOT=yes UNPRIVILEGED_USER=yes - # TODO(ngie): reenable i386; the libraries were not available in the - # Ubuntu Xenial x86_64 docker image. - #- os: linux - # dist: xenial - # compiler: clang - # env: ARCH=i386 DO=distcheck AS_ROOT=no - #- os: linux - # dist: xenial - # compiler: gcc - # env: ARCH=i386 DO=distcheck AS_ROOT=no - -script: - - ./admin/travis-build.sh - -notifications: - email: - - kyua-log@googlegroups.com diff --git a/contrib/kyua/Doxyfile.in b/contrib/kyua/Doxyfile.in index e28d82f8999a..ac1dbf3398b6 100644 --- a/contrib/kyua/Doxyfile.in +++ b/contrib/kyua/Doxyfile.in @@ -45,7 +45,6 @@ JAVADOC_AUTOBRIEF = YES MACRO_EXPANSION = YES OUTPUT_DIRECTORY = @top_builddir@/api-docs OUTPUT_LANGUAGE = English -PREDEFINED += "KYUA_DEFS_NORETURN=" PREDEFINED += "KYUA_DEFS_FORMAT_PRINTF(x, y)=" PROJECT_NAME = "@PACKAGE_NAME@" PROJECT_NUMBER = @VERSION@ diff --git a/contrib/kyua/FREEBSD-Xlist b/contrib/kyua/FREEBSD-Xlist new file mode 100644 index 000000000000..06fef93a4024 --- /dev/null +++ b/contrib/kyua/FREEBSD-Xlist @@ -0,0 +1,12 @@ +*/*/Makefile* +*/Makefile* +*/*.m4 +*/*.pc.in +INSTALL.md +Makefile* +aclocal.m4 +admin/ +config.h.in +bootstrap/ +configure* +m4/ diff --git a/contrib/kyua/INSTALL.md b/contrib/kyua/INSTALL.md deleted file mode 100644 index d3dcab49cb74..000000000000 --- a/contrib/kyua/INSTALL.md +++ /dev/null @@ -1,268 +0,0 @@ -Installation instructions -========================= - -Kyua uses the GNU Automake, GNU Autoconf and GNU Libtool utilities as -its build system. These are used only when compiling the application -from the source code package. If you want to install Kyua from a binary -package, you do not need to read this document. - -For the impatient: - - $ ./configure - $ make - $ make check - Gain root privileges - # make install - Drop root privileges - $ make installcheck - -Or alternatively, install as a regular user into your home directory: - - $ ./configure --prefix ~/local - $ make - $ make check - $ make install - $ make installcheck - - -Dependencies ------------- - -To build and use Kyua successfully you need: - -* A standards-compliant C and C++ complier. -* Lutok 0.4. -* pkg-config. -* SQLite 3.6.22. - -To build the Kyua tests, you optionally need: - -* The Automated Testing Framework (ATF), version 0.15 or greater. This - is required if you want to create a distribution file. - -If you are building Kyua from the code on the repository, you will also -need the following tools: - -* GNU Autoconf. -* GNU Automake. -* GNU Libtool. - - -Regenerating the build system ------------------------------ - -This is not necessary if you are building from a formal release -distribution file. - -On the other hand, if you are building Kyua from code extracted from the -repository, you must first regenerate the files used by the build -system. You will also need to do this if you modify `configure.ac`, -`Makefile.am` or any of the other build system files. To do this, simply -run: - - $ autoreconf -i -s - -If ATF is installed in a different prefix than Autoconf, you will also -need to tell autoreconf where the ATF M4 macros are located. Otherwise, -the configure script will be incomplete and will show confusing syntax -errors mentioning, for example, `ATF_CHECK_SH`. To fix this, you have -to run autoreconf in the following manner, replacing `<atf-prefix>` with -the appropriate path: - - $ autoreconf -i -s -I <atf-prefix>/share/aclocal - - -General build procedure ------------------------ - -To build and install the source package, you must follow these steps: - -1. Configure the sources to adapt to your operating system. This is - done using the `configure` script located on the sources' top - directory, and it is usually invoked without arguments unless you - want to change the installation prefix. More details on this - procedure are given on a later section. - -2. Build the sources to generate the binaries and scripts. Simply run - `make` on the sources' top directory after configuring them. No - problems should arise. - -3. Check that the built programs work by running `make check`. You do - not need to be root to do this, but if you are not, some checks will - be skipped. - -4. Install the program by running `make install`. You may need to - become root to issue this step. - -5. Issue any manual installation steps that may be required. These are - described later in their own section. - -6. Check that the installed programs work by running `make - installcheck`. You do not need to be root to do this, but if you are - not, some checks will be skipped. - - -Configuration flags -------------------- - -The most common, standard flags given to `configure` are: - -* `--prefix=directory`: - **Possible values:** Any path. - **Default:** `/usr/local`. - - Specifies where the program (binaries and all associated files) will - be installed. - -* `--sysconfdir=directory`: - **Possible values:** Any path. - **Default:** `/usr/local/etc`. - - Specifies where the installed programs will look for configuration - files. `/kyua` will be appended to the given path unless - `KYUA_CONFSUBDIR` is redefined as explained later on. - -* `--help`: - - Shows information about all available flags and exits immediately, - without running any configuration tasks. - -The following environment variables are specific to Kyua's `configure` -script: - -* `GDB`: - **Possible values:** empty, absolute path to GNU GDB. - **Default:** empty. - - Specifies the path to the GNU GDB binary that Kyua will use to gather a - stack trace of a crashing test program. If empty, the configure script - will try to find a suitable binary for you and, if not found, Kyua will - attempt to do the search at run time. - -* `KYUA_ARCHITECTURE`: - **Possible values:** name of a CPU architecture (e.g. `x86_64`, `powerpc`). - **Default:** autodetected; typically the output of `uname -p`. - - Specifies the name of the CPU architecture on which Kyua will run. - This value is used at run-time to determine tests that are not - applicable to the host system. - -* `KYUA_CONFSUBDIR`: - **Possible values:** empty, a relative path. - **Default:** `kyua`. - - Specifies the subdirectory of the configuration directory (given by - the `--sysconfdir` argument) under which Kyua will search for its - configuration files. - -* `KYUA_CONFIG_FILE_FOR_CHECK`: - **Possible values:** none, an absolute path to an existing file. - **Default:** none. - - Specifies the `kyua.conf` configuration file to use when running any - of the `check`, `installcheck` or `distcheck` targets on this source - tree. This setting is exclusively used to customize the test runs of - Kyua itself and has no effect whatsoever on the built product. - -* `KYUA_MACHINE`: - **Possible values:** name of a machine type (e.g. `amd64`, `macppc`). - **Default:** autodetected; typically the output of `uname -m`. - - Specifies the name of the machine type on which Kyua will run. This - value is used at run-time to determine tests that are not applicable - to the host system. - -* `KYUA_TMPDIR`: - **Possible values:** an absolute path to a temporary directory. - **Default:** `/tmp`. - - Specifies the path that Kyua will use to create temporary directories - in by default. - -The following flags are specific to Kyua's `configure` script: - -* `--enable-developer`: - **Possible values:** `yes`, `no`. - **Default:** `yes` in Git `HEAD` builds; `no` in formal releases. - - Enables several features useful for development, such as the inclusion - of debugging symbols in all objects or the enforcement of compilation - warnings. - - The compiler will be executed with an exhaustive collection of warning - detection features regardless of the value of this flag. However, such - warnings are only fatal when `--enable-developer` is `yes`. - -* `--with-atf`: - **Possible values:** `yes`, `no`, `auto`. - **Default:** `auto`. - - Enables usage of ATF to build (and later install) the tests. - - Setting this to `yes` causes the configure script to look for ATF - unconditionally and abort if not found. Setting this to `auto` lets - configure perform the best decision based on availability of ATF. - Setting this to `no` explicitly disables ATF usage. - - When support for tests is enabled, the build process will generate the - test programs and will later install them into the tests tree. - Running `make check` or `make installcheck` from within the source - directory will cause these tests to be run with Kyua. - -* `--with-doxygen`: - **Possible values:** `yes`, `no`, `auto` or a path. - **Default:** `auto`. - - Enables usage of Doxygen to generate documentation for internal APIs. - This documentation is *not* installed and is only provided to help the - developer of this package. Therefore, enabling or disabling Doxygen - causes absolutely no differences on the files installed by this - package. - - Setting this to `yes` causes the configure script to look for Doxygen - unconditionally and abort if not found. Setting this to `auto` lets - configure perform the best decision based on availability of Doxygen. - Setting this to `no` explicitly disables Doxygen usage. And, lastly, - setting this to a path forces configure to use a specific Doxygen - binary, which must exist. - - -Post-installation steps ------------------------ - -Copy the `Kyuafile.top` file installed in the examples directory to the -root of your tests hierarchy and name it `Kyuafile`. For example: - - # cp /usr/local/share/kyua/examples/Kyuafile.top \ - /usr/local/tests/Kyuafile - -This will allow you to simply go into `/usr/tests` and run the tests -from there. - - -Run the tests! --------------- - -Lastly, after a successful installation, you should periodically run the -tests from the final location to ensure things remain stable. Do so as -follows: - - $ cd /usr/local/kyua && kyua test - -The following configuration variables are specific to the 'kyua' test -suite and can be given to Kyua with arguments of the form -`-v test_suites.kyua.<variable_name>=<value>`: - -* `run_coredump_tests`: - **Possible values:** `true` or `false`. - **Default:** `true`. - - Avoids running tests that crash subprocesses on purpose to make them - dump core. Such tests are particularly slow on macOS, and it is - sometimes handy to disable them for quicker development iteration. - -If you see any tests fail, do not hesitate to report them in: - - https://github.com/jmmv/kyua/issues/ - -Thank you! diff --git a/contrib/kyua/Makefile.am b/contrib/kyua/Makefile.am deleted file mode 100644 index d7f3cd27e73b..000000000000 --- a/contrib/kyua/Makefile.am +++ /dev/null @@ -1,186 +0,0 @@ -# Copyright 2010 The Kyua Authors. -# 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. - -ACLOCAL_AMFLAGS = -I m4 - -CHECK_BOOTSTRAP_DEPS = -CHECK_KYUA_DEPS = -CHECK_LOCAL = -CLEAN_TARGETS = -DIST_HOOKS = -PHONY_TARGETS = -CLEANFILES = - -EXTRA_DIST = -noinst_DATA = -noinst_LIBRARIES = -noinst_SCRIPTS = - -doc_DATA = AUTHORS CONTRIBUTING.md CONTRIBUTORS LICENSE NEWS.md -noinst_DATA += INSTALL.md README.md -EXTRA_DIST += $(doc_DATA) INSTALL.md README.md - -if WITH_ATF -tests_topdir = $(pkgtestsdir) - -tests_top_DATA = Kyuafile -EXTRA_DIST += $(tests_top_DATA) -endif - -include admin/Makefile.am.inc -include bootstrap/Makefile.am.inc -include cli/Makefile.am.inc -include doc/Makefile.am.inc -include drivers/Makefile.am.inc -include engine/Makefile.am.inc -include examples/Makefile.am.inc -include integration/Makefile.am.inc -include misc/Makefile.am.inc -include model/Makefile.am.inc -include store/Makefile.am.inc -include utils/Makefile.am.inc - -bin_PROGRAMS = kyua -kyua_SOURCES = main.cpp -kyua_CXXFLAGS = $(CLI_CFLAGS) $(ENGINE_CFLAGS) $(UTILS_CFLAGS) -kyua_LDADD = $(CLI_LIBS) $(ENGINE_LIBS) $(UTILS_LIBS) - -CHECK_ENVIRONMENT = KYUA_CONFDIR="/non-existent" \ - KYUA_DOCDIR="$(abs_top_srcdir)" \ - KYUA_EXAMPLESDIR="$(abs_top_srcdir)/examples" \ - KYUA_MISCDIR="$(abs_top_srcdir)/misc" \ - KYUA_STOREDIR="$(abs_top_srcdir)/store" \ - KYUA_STORETESTDATADIR="$(abs_top_srcdir)/store" \ - PATH="$(abs_top_builddir):$${PATH}" -INSTALLCHECK_ENVIRONMENT = KYUA_CONFDIR="/non-existent" \ - PATH="$(prefix)/bin:$${PATH}" - -# Generate local-kyua, a wrapper shell script to run the just-built 'kyua' -# binary by pointing it to the possibly not-yet-installed data files in the -# build tree. -noinst_SCRIPTS += local-kyua -CLEANFILES += local-kyua local-kyua.tmp -local-kyua: Makefile - $(AM_V_GEN)echo '#!/bin/sh' >local-kyua.tmp; \ - echo 'env $(CHECK_ENVIRONMENT) $(TESTS_ENVIRONMENT)' \ - '"$(abs_top_builddir)/kyua" \ - --config='$(KYUA_CONFIG_FILE_FOR_CHECK)' \ - "$${@}"' >>local-kyua.tmp; \ - chmod +x local-kyua.tmp; \ - mv -f local-kyua.tmp local-kyua - -if WITH_ATF -CHECK_LOCAL += dump-ulimits check-kyua -PHONY_TARGETS += check-kyua -check-kyua: $(CHECK_KYUA_DEPS) - @failed=no; \ - ./local-kyua test \ - --kyuafile='$(top_srcdir)/Kyuafile' --build-root='$(top_builddir)' \ - || failed=yes; \ - if [ "$${failed}" = yes ]; then \ - ./local-kyua report --results-file='$(abs_top_srcdir)' \ - --verbose --results-filter=broken,failed; \ - exit 1; \ - fi - -installcheck-local: dump-ulimits installcheck-kyua -PHONY_TARGETS += installcheck-kyua -installcheck-kyua: - @failed=no; \ - cd $(pkgtestsdir) && $(INSTALLCHECK_ENVIRONMENT) $(TESTS_ENVIRONMENT) \ - kyua --config='$(KYUA_CONFIG_FILE_FOR_CHECK)' test \ - || failed=yes; \ - if [ "$${failed}" = yes ]; then \ - cd $(pkgtestsdir) && $(INSTALLCHECK_ENVIRONMENT) \ - $(TESTS_ENVIRONMENT) \ - kyua --config='$(KYUA_CONFIG_FILE_FOR_CHECK)' report \ - --verbose --results-filter=broken,failed; \ - exit 1; \ - fi - -# TODO(jmmv): kyua should probably be recording this information itself as part -# of the execution context, just as we record environment variables. -PHONY_TARGETS += dump-ulimits -dump-ulimits: - @echo "Resource limits:" - @{ \ - ulimit -a | sed -e 's,$$, (soft),'; \ - ulimit -a -H | sed -e 's,$$, (hard),'; \ - } | sort | sed -e 's,^, ,' - @echo -else -DIST_HOOKS += forbid-dist -PHONY_TARGETS += forbid-dist -forbid-dist: - @echo "Sorry; cannot make dist without atf." - @false -endif -check-local: $(CHECK_LOCAL) - -if WITH_DOXYGEN -# Runs doxygen on the source tree and validates the contents of the docstrings. -# We do not do this by default, even if doxygen has been enabled, because this -# step takes a long time. Instead, we just rely on a Travis CI build to catch -# inconsistencies. -PHONY_TARGETS += check-api-docs -check-api-docs: api-docs/api-docs.tag - @$(AWK) -f $(srcdir)/admin/check-api-docs.awk api-docs/doxygen.out - -api-docs/api-docs.tag: $(builddir)/Doxyfile $(SOURCES) - @$(MKDIR_P) api-docs - @rm -f api-docs/doxygen.out api-docs/doxygen.out.tmp - $(AM_V_GEN)$(DOXYGEN) $(builddir)/Doxyfile \ - >api-docs/doxygen.out.tmp 2>&1 && \ - mv api-docs/doxygen.out.tmp api-docs/doxygen.out - -CLEAN_TARGETS += clean-api-docs -clean-api-docs: - rm -rf api-docs -endif - -# Replace Automake's builtin check-news functionality so that we can validate -# the NEWS.md file instead of NEWS. -DIST_HOOKS += check-news -PHONY_TARGETS += check-news -check-news: - @case "$$(sed 15q "$(srcdir)/NEWS.md")" in \ - *"$(VERSION)"*) : ;; \ - *) \ - echo "NEWS.md not updated; not releasing" 1>&2; \ - exit 1 \ - ;; \ - esac - -clean-local: $(CLEAN_TARGETS) -dist-hook: $(DIST_HOOKS) - -PHONY_TARGETS += clean-all -clean-all: - GIT="$(GIT)" $(SH) $(srcdir)/admin/clean-all.sh - -.PHONY: $(PHONY_TARGETS) diff --git a/contrib/kyua/NEWS.md b/contrib/kyua/NEWS index 304cfe94695a..c794e6e60092 100644 --- a/contrib/kyua/NEWS.md +++ b/contrib/kyua/NEWS @@ -1,17 +1,119 @@ -Major changes between releases -============================== +# Major changes between releases +## Changes in version 0.15.0 -Changes in version 0.14 ------------------------ +**Released on 2026/10/07.** -**NOT RELEASED YET; STILL UNDER DEVELOPMENT.** +### Bugfixes -* Explicitly require C++11 language features when compiling Kyua. +* #265: Null cleanups +* #271: kyua: Try harder to delete directories. +* #300: Implement utils::config::positive_int_node::deep_copy +### Developer Workflow Changes -Changes in version 0.13 ------------------------ +* #254: Add initial GitHub Actions support for kyua +* #288: [CI] remove legacy CI scripts and files +* #291: Remove Travis CI config +* #298: Add sanitizers and code coverage support +* #301: Add FreeBSD CI support via vmactions +* #305: Automate uploading release assets + +### Feature Enhancements + +* #203: Add GoogleTest support +* #230: Do not count skipped as passed in test cmd +* #260: Support require.diskspace ATF metadata +* #261: Pass unprivileged user config prop to ATF using all known names +* #266: Add "kyua debug -p" option +* #270: Add required_kmods metadata +* #272: Make "test" command actually report about workdir cleanup issues +* #273: Make "debug -p" skip writing stdout/stderr to tmp files +* #277: kyua-debug: Add -P option +* #290: Require C++-20 in order to build kyua +* #307: Upstream multiple items from FreeBSD + +### Documentation + +* #258: kyuafile.5: Add ATF metadata mapping reference +* #275: kyua manuals: Correct --results-file short form +* #279: docs: Standardize document description tone + +### Miscellaneous + +* #264: Switch from std::auto_ptr<> to std::unique_ptr<> +* #269: Fix cmd_about_test:topic__version test case +* #297: Reduce overall lutok dependency +* #312: Replace KYUA_ATTRIBUTE_{NORETURN,UNUSED}} with C++ attributes +* #318: utils::fs: remove umount(8) support + +**Full Changelog**: https://github.com/freebsd/lutok/compare/kyua-0.14.1...kyua-0.15.0 + +## Changes in version 0.14.1 + +**Released on March 29th, 2025.** + +* Issue #263: fix release tarball by relying on `make dist`. + +* Document ATF to Kyua mappings for metadata properties. + +* Support `require.diskspace` ATF metadata property. + +* Support backwards compatible `unprivileged_user` metadata property for ease + of use dealing with ATF vs Kyua. + +* Fix building from source by tracking `utils/process/Kyuafile.in` and + `engine/execenv/execenv_fwd.hpp` with automake. + +## Changes in version 0.14 + +**Released on December 31st, 2024.** + +* Replace `--with-atf` with `--enable-atf`. The latter must be specified + to enable ATF support and the Kyua tests by proxy. + +* Require newer versions of ATF (0.21) and Lutok (0.5). This is being done + as part of a multi-phase deprecation of pre-C++11 environments. + +* Vendor the ATF m4 files from the freebsd/atf repo. + +* Translate `is_exclusive` metadata to its ATF counterpart. + +* Issue #236: fix accidental test forkbomb in specific user environments + with `integration` tests by avoiding infinite recursion calling kyua. + +* Fix the build on Ubuntu 24.04. + +- execenv support added. This FreeBSD-specific feature allows tests to be + executed in jails. + +* Issue #169: Remove deprecated `readdir_r` use. + +* Fix build issue on more recent versions of MacOS. + +* Fix build issue on IllumOS. + +* Fix issues with PID reuse in testcases. + +* Escape characters captured from stderr and stdout in HTML output. + +* `integration/cmd_report_test:verbose`: fix regular expression used in + tests which would break in certain user environments. + +* Add Cirrus CI support for testing Kyua on FreeBSD. + +* Remove `UTILS_UNUSED_PARAM` macro. + +* Fix document rendering with newer versions of doxygen. + +* Issue #152: explicitly require C++11 language features when compiling Kyua. + Remove `std::shared_ptr` compatibility header, `utils/shared_ptr.hpp`. + +* Fix `igor` and `mandoc -Tlint` reported issues with generated manpages. + +* Issue #167: fix typos in kyua(1) manpage. + +## Changes in version 0.13 **Released on August 26th, 2016.** @@ -36,8 +138,7 @@ Changes in version 0.13 timers to control test deadlines. -Changes in version 0.12 ------------------------ +## Changes in version 0.12 **Released on November 22nd, 2015.** @@ -129,8 +230,7 @@ parallelization possibilities. Markdown for better formatting online. -Changes in version 0.11 ------------------------ +## Changes in version 0.11 **Released on October 23rd, 2014.** @@ -211,8 +311,7 @@ Changes in version 0.11 examples. -Changes in version 0.10 ------------------------ +## Changes in version 0.10 **Experimental version released on August 14th, 2014.** @@ -232,8 +331,7 @@ Changes in version 0.10 prevent triggering a core dump that made the test fail in some platforms. -Changes in kyua-cli version 0.9 -------------------------------- +## Changes in kyua-cli version 0.9 **Experimental version released on August 8th, 2014.** @@ -276,8 +374,7 @@ Changes in more detail: files. -Changes in kyua-testers version 0.3 ------------------------------------ +## Changes in kyua-testers version 0.3 **Experimental version released on August 8th, 2014.** @@ -293,8 +390,7 @@ Changes in kyua-testers version 0.3 handle test programs that report a pass but exit with a non-zero code. -Changes in kyua-cli version 0.8 -------------------------------- +## Changes in kyua-cli version 0.8 **Experimental version released on December 7th, 2013.** @@ -310,8 +406,7 @@ Changes in kyua-cli version 0.8 the addition of new testers or the selective installation of them. -Changes in kyua-testers version 0.2 ------------------------------------ +## Changes in kyua-testers version 0.2 **Experimental version released on December 7th, 2013.** @@ -326,8 +421,7 @@ Changes in kyua-testers version 0.2 own session instead of just to their own process group. -Changes in kyua-cli version 0.7 -------------------------------- +## Changes in kyua-cli version 0.7 **Experimental version released on October 18th, 2013.** @@ -347,8 +441,7 @@ Changes in kyua-cli version 0.7 LTS, which appears stuck in 1.11.1. -Changes in kyua-cli version 0.6 -------------------------------- +## Changes in kyua-cli version 0.6 **Experimental version released on February 22nd, 2013.** @@ -412,8 +505,7 @@ Changes in kyua-cli version 0.6 executables. -Changes in kyua-testers version 0.1 ------------------------------------ +## Changes in kyua-testers version 0.1 **Experimental version released on February 19th, 2013.** @@ -430,8 +522,7 @@ of `kyua-cli`, which means that the overall build times of Kyua are now reduced. -Changes in kyua-cli version 0.5 -------------------------------- +## Changes in kyua-cli version 0.5 **Experimental version released on July 10th, 2012.** @@ -454,8 +545,7 @@ Changes in kyua-cli version 0.5 from the repository. -Changes in kyua-cli version 0.4 -------------------------------- +## Changes in kyua-cli version 0.4 **Experimental version released on June 6th, 2012.** @@ -497,8 +587,7 @@ Changes in kyua-cli version 0.4 such tree. -Changes in kyua-cli version 0.3 -------------------------------- +## Changes in kyua-cli version 0.3 **Experimental version released on February 24th, 2012.** @@ -533,8 +622,7 @@ Changes in kyua-cli version 0.3 failing test. -Changes in kyua-cli version 0.2 -------------------------------- +## Changes in kyua-cli version 0.2 **Experimental version released on August 24th, 2011.** @@ -599,8 +687,7 @@ Without further ado, here comes the itemized list of changes: and Ubuntu 10.04.1 LTS. (Issues #20, #21, #26.) -Changes in kyua-cli version 0.1 -------------------------------- +## Changes in kyua-cli version 0.1 **Experimental version released on June 23rd, 2011.** diff --git a/contrib/kyua/README.md b/contrib/kyua/README.md index eb34c0fd4550..e42d6da35377 100644 --- a/contrib/kyua/README.md +++ b/contrib/kyua/README.md @@ -1,5 +1,4 @@ -Welcome to the Kyua project! -============================ +# Welcome to the Kyua project! Kyua is a **testing framework** for infrastructure software, originally designed to equip BSD-based operating systems with a test suite. This @@ -16,7 +15,7 @@ on a production machine. Kyua is **able to execute test programs written with a plethora of testing libraries and languages**. The library of choice is -[ATF](https://github.com/jmmv/atf/), for which Kyua was originally +[ATF](https://github.com/freebsd/atf/), for which Kyua was originally designed, but simple, framework-less test programs and TAP-compliant test programs can also be executed through Kyua. @@ -26,25 +25,23 @@ This is not an official Google product. [Read more about Kyua in the About wiki page.](../../wiki/About) -Download --------- +## Download -The latest version of Kyua is 0.13 and was released on August 26th, 2016. +The latest version of Kyua is 0.14.1 and was released on March 29th, 2025. -Download: [kyua-0.13](../../releases/tag/kyua-0.13). +Download: [kyua-0.14.1](../../releases/tag/kyua-0.14.1). -See the [release notes](NEWS.md) for information about the changes in this +See the [release notes](NEWS) for information about the changes in this and all previous releases. -Installation ------------- +## Installation You are encouraged to install binary packages for your operating system wherever available: -* Fedora 20 and above: install the `kyua-cli` package with `yum install - kyua-cli`. +* Fedora 20 and above: install the `kyua` package with `dnf install + kyua`. * FreeBSD 10.0 and above: install the `kyua` package with `pkg install kyua`. @@ -52,7 +49,7 @@ wherever available: * OpenBSD with packages: install the `kyua` package with `pkg_add kyua`. -* OS X (with Homebrew): install the `kyua` package with `brew install kyua`. +* macOS (with Homebrew): install the `kyua` package with `brew install kyua`. Should you want to build and install Kyua from the source tree provided here, follow the instructions in the @@ -60,11 +57,10 @@ here, follow the instructions in the You should also install the ATF libraries to assist in the development of test programs. To that end, see the -[ATF project page](https://github.com/jmmv/atf/). +[ATF project page](https://github.com/freebsd/atf/). -Contributing ------------- +## Contributing Want to contribute? Great! But please first read the guidelines provided in [CONTRIBUTING.md](CONTRIBUTING.md). @@ -74,11 +70,10 @@ the [list of copyright holders](AUTHORS) and the [list of individuals](CONTRIBUTORS). -Support -------- +## Support Please use the [kyua-discuss mailing list](https://groups.google.com/forum/#!forum/kyua-discuss) for any support inquiries. -*Homepage:* https://github.com/jmmv/kyua/ +*Homepage:* https://github.com/freebsd/kyua/ diff --git a/contrib/kyua/admin/.gitignore b/contrib/kyua/admin/.gitignore deleted file mode 100644 index 1b34cbb4e096..000000000000 --- a/contrib/kyua/admin/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -ar-lib -compile -depcomp -install-sh -mdate-sh -missing diff --git a/contrib/kyua/admin/Makefile.am.inc b/contrib/kyua/admin/Makefile.am.inc deleted file mode 100644 index 7d02b0e611c3..000000000000 --- a/contrib/kyua/admin/Makefile.am.inc +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2015 The Kyua Authors. -# 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. - -PHONY_TARGETS += check-style -check-style: - @$(srcdir)/admin/check-style.sh \ - -b "$(abs_top_builddir)" \ - -s "$(abs_top_srcdir)" \ - -t "$(PACKAGE_TARNAME)" - -EXTRA_DIST += admin/check-style-common.awk \ - admin/check-style-cpp.awk \ - admin/check-style-make.awk \ - admin/check-style-man.awk \ - admin/check-style-shell.awk \ - admin/check-style.sh diff --git a/contrib/kyua/admin/build-bintray-dist.sh b/contrib/kyua/admin/build-bintray-dist.sh deleted file mode 100755 index 99cd439892c5..000000000000 --- a/contrib/kyua/admin/build-bintray-dist.sh +++ /dev/null @@ -1,131 +0,0 @@ -#! /bin/sh -# Copyright 2017 The Kyua Authors. -# 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. - -# \file admin/build-bintray-dist.sh -# Builds a full Kyua installation under /usr/local for Ubuntu. -# -# This script is used to create the bintray distribution packages in lieu -# of real Debian packages for Kyua. The result of this script is a -# tarball that provides the contents of /usr/local for Kyua. - -set -e -x - -err() { - echo "${@}" 1>&2 - exit 1 -} - -install_deps() { - sudo apt-get update -qq - - local pkgsuffix= - local packages= - packages="${packages} autoconf" - packages="${packages} automake" - packages="${packages} clang" - packages="${packages} g++" - packages="${packages} gdb" - packages="${packages} git" - packages="${packages} libtool" - packages="${packages} make" - if [ "${ARCH?}" = i386 ]; then - pkgsuffix=:i386 - packages="${packages} gcc-multilib" - packages="${packages} g++-multilib" - fi - packages="${packages} liblua5.2-0${pkgsuffix}" - packages="${packages} liblua5.2-dev${pkgsuffix}" - packages="${packages} libsqlite3-0${pkgsuffix}" - packages="${packages} libsqlite3-dev${pkgsuffix}" - packages="${packages} pkg-config${pkgsuffix}" - packages="${packages} sqlite3" - sudo apt-get install -y ${packages} -} - -install_from_github() { - local name="${1}"; shift - local release="${1}"; shift - - local distname="${name}-${release}" - - local baseurl="https://github.com/jmmv/${name}" - wget --no-check-certificate \ - "${baseurl}/releases/download/${distname}/${distname}.tar.gz" - tar -xzvf "${distname}.tar.gz" - - local archflags= - [ "${ARCH?}" != i386 ] || archflags=-m32 - - cd "${distname}" - ./configure \ - --disable-developer \ - --without-atf \ - --without-doxygen \ - CC="${CC?}" \ - CFLAGS="${archflags}" \ - CPPFLAGS="-I/usr/local/include" \ - CXX="${CXX?}" \ - CXXFLAGS="${archflags}" \ - LDFLAGS="-L/usr/local/lib -Wl,-R/usr/local/lib" \ - PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" - make - sudo make install - cd - - - rm -rf "${distname}" "${distname}.tar.gz" -} - -main() { - [ "${ARCH+set}" = set ] || err "ARCH must be set in the environment" - [ "${CC+set}" = set ] || err "CC must be set in the environment" - [ "${CXX+set}" = set ] || err "CXX must be set in the environment" - - [ ! -f /root/local.tgz ] || err "/root/local.tgz already exists" - tar -czf /root/local.tgz /usr/local - restore() { - rm -rf /usr/local - tar -xz -C / -f /root/local.tgz - rm /root/local.tgz - } - trap restore EXIT - rm -rf /usr/local - mkdir /usr/local - - install_deps - install_from_github atf 0.21 - install_from_github lutok 0.4 - install_from_github kyua 0.13 - - local version="$(lsb_release -rs | cut -d . -f 1-2 | tr . -)" - local name="$(date +%Y%m%d)-usr-local-kyua" - name="${name}-ubuntu-${version}-${ARCH?}-${CC?}.tar.gz" - tar -czf "${name}" /usr/local -} - -main "${@}" diff --git a/contrib/kyua/admin/check-api-docs.awk b/contrib/kyua/admin/check-api-docs.awk deleted file mode 100644 index 358e3d54c177..000000000000 --- a/contrib/kyua/admin/check-api-docs.awk +++ /dev/null @@ -1,72 +0,0 @@ -#! /bin/sh -# Copyright 2015 The Kyua Authors. -# 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. - -BEGIN { - failed = 0 -} - -# Skip empty lines. -/^$/ {next} - -# Skip lines that do not directly reference a file. -/^[^\/]/ {next} - -# Ignore known problems. As far as I can tell, all the cases listed here are -# well-documented in the code but Doxygen fails, for some reason or another, to -# properly locate the docstrings. -/engine\/kyuafile\.cpp.*no matching class member/ {next} -/engine\/scheduler\.hpp.*Member setup\(void\).*friend/ {next} -/engine\/scheduler\.hpp.*Member wait_any\(void\)/ {next} -/utils\/optional\.ipp.*no matching file member/ {next} -/utils\/optional\.hpp.*Member make_optional\(const T &\)/ {next} -/utils\/config\/nodes\.hpp.*Member set_lua\(lutok::state &, const int\)/ {next} -/utils\/config\/nodes\.hpp.*Member push_lua\(lutok::state &\)/ {next} -/utils\/config\/nodes\.hpp.*Member set_string\(const std::string &\)/ {next} -/utils\/config\/nodes\.hpp.*Member to_string\(void\)/ {next} -/utils\/config\/nodes\.hpp.*Member is_set\(void\)/ {next} -/utils\/process\/executor\.hpp.*Member spawn\(Hook.*\)/ {next} -/utils\/process\/executor\.hpp.*Member spawn_followup\(Hook.*\)/ {next} -/utils\/process\/executor\.hpp.*Member setup\(void\).*friend/ {next} -/utils\/signals\/timer\.hpp.*Member detail::invoke_do_fired.*friend/ {next} -/utils\/stacktrace_test\.cpp.*no matching class member/ {next} - -# Dump any other problems and account for the failure. -{ - failed = 1 - print -} - -END { - if (failed) { - print "ERROR: Unexpected docstring problems encountered" - exit 1 - } else { - exit 0 - } -} diff --git a/contrib/kyua/admin/check-style-common.awk b/contrib/kyua/admin/check-style-common.awk deleted file mode 100644 index 39516d00d4e5..000000000000 --- a/contrib/kyua/admin/check-style-common.awk +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright 2015 The Kyua Authors. -# 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. - -function warn(msg) { - print FILENAME "[" FNR "]: " msg > "/dev/stderr" - error = 1 -} - -BEGIN { - skip = 0 - error = 0 -} - -/CHECK_STYLE_DISABLE/ { - skip = 1 - next -} - -/CHECK_STYLE_ENABLE/ { - skip = 0 - next -} - -/CHECK_STYLE_(ENABLE|DISABLE)/ { - next -} - -{ - if (skip) - next - - if (length > 80 && NF > 1) - warn("Line too long to fit on screen") -} - -/^ *\t+/ { - if (! match(FILENAME, "Makefile")) - warn("Tab character used for indentation"); -} - -/[ \t]+$/ { - warn("Trailing spaces or tabs"); -} - -/^#![^ ]/ { - warn("Missing space after #!"); -} - -END { - if (skip) - warn("Missing CHECK_STYLE_ENABLE"); - if (error) - exit 1 -} diff --git a/contrib/kyua/admin/check-style-cpp.awk b/contrib/kyua/admin/check-style-cpp.awk deleted file mode 100644 index 126789ca9262..000000000000 --- a/contrib/kyua/admin/check-style-cpp.awk +++ /dev/null @@ -1,87 +0,0 @@ -# Copyright 2015 The Kyua Authors. -# 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. - -function warn(msg) { - print FILENAME "[" FNR "]: " msg > "/dev/stderr" - error = 1 -} - -BEGIN { - skip = 0 - error = 0 -} - -/CHECK_STYLE_DISABLE/ { - skip = 1 - next -} - -/CHECK_STYLE_ENABLE/ { - skip = 0 - next -} - -/CHECK_STYLE_(ENABLE|DISABLE)/ { - next -} - -{ - if (skip) - next -} - -/#ifdef/ { - warn("Undesired usage of #ifdef; use #if defined()") -} - -/#ifndef/ { - warn("Undesired usage of #ifndef; use #if !defined()") -} - -/assert[ \t]*\(/ { - warn("Use the macros in sanity.hpp instead of assert"); -} - -/#.*include.*assert/ { - warn("Do not include assert.h nor cassert"); -} - -/std::endl/ { - warn("Use \\n instead of std::endl"); -} - -/\/\*/ && ! /\*\// { - warn("Do not use multi-line C-style comments"); -} - -END { - if (skip) - warn("Missing CHECK_STYLE_ENABLE"); - if (error) - exit 1 -} diff --git a/contrib/kyua/admin/check-style-make.awk b/contrib/kyua/admin/check-style-make.awk deleted file mode 100644 index 9a6c532e7131..000000000000 --- a/contrib/kyua/admin/check-style-make.awk +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright 2015 The Kyua Authors. -# 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. - -function warn(msg) { - print FILENAME "[" FNR "]: " msg > "/dev/stderr" - error = 1 -} - -BEGIN { - skip = 0 - error = 0 -} - -/CHECK_STYLE_DISABLE/ { - skip = 1 - next -} - -/CHECK_STYLE_ENABLE/ { - skip = 0 - next -} - -/CHECK_STYLE_(ENABLE|DISABLE)/ { - next -} - -{ - if (skip) - next -} - -/^\t *\t/ { - warn("Continuation lines must use a single tab"); -} - -/mkdir.*-p/ { - warn("Use $(MKDIR_P) instead of mkdir -p"); -} - -END { - if (skip) - warn("Missing CHECK_STYLE_ENABLE"); - if (error) - exit 1 -} diff --git a/contrib/kyua/admin/check-style-man.awk b/contrib/kyua/admin/check-style-man.awk deleted file mode 100644 index 5c4a2c261b96..000000000000 --- a/contrib/kyua/admin/check-style-man.awk +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright 2015 The Kyua Authors. -# 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. - -function warn(msg) { - print FILENAME "[" FNR "]: " msg > "/dev/stderr" - error = 1 -} - -BEGIN { - skip = 0 - error = 0 -} - -/CHECK_STYLE_DISABLE|^\.Bd/ { - skip = 1 - next -} - -/CHECK_STYLE_ENABLE|^\.Ed/ { - skip = 0 - next -} - -/CHECK_STYLE_(ENABLE|DISABLE)/ { - next -} - -/^\.\\"/ { - next -} - -{ - if (skip) - next -} - -/\.\.|e\.g\.|i\.e\./ { - next -} - -END { - if (skip) - warn("Missing CHECK_STYLE_ENABLE"); - if (error) - exit 1 -} diff --git a/contrib/kyua/admin/check-style-shell.awk b/contrib/kyua/admin/check-style-shell.awk deleted file mode 100644 index 43d3472cb45b..000000000000 --- a/contrib/kyua/admin/check-style-shell.awk +++ /dev/null @@ -1,95 +0,0 @@ -# Copyright 2015 The Kyua Authors. -# 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. - -function warn(msg) { - print FILENAME "[" FNR "]: " msg > "/dev/stderr" - error = 1 -} - -BEGIN { - skip = 0 - error = 0 -} - -/CHECK_STYLE_DISABLE/ { - skip = 1 - next -} - -/CHECK_STYLE_ENABLE/ { - skip = 0 - next -} - -/CHECK_STYLE_(ENABLE|DISABLE)/ { - next -} - -{ - if (skip) - next -} - -/^[ \t]*#/ { - next -} - -/[$ \t]+_[a-zA-Z0-9]+=/ { - warn("Variable should not start with an underline") -} - -/[^\\]\$[^0-9!'"$?@#*{}(|\/,]+/ { - warn("Missing braces around variable name") -} - -/=(""|'')/ { - warn("Assignment to the empty string does not need quotes"); -} - -/basename[ \t]+/ { - warn("Use parameter expansion instead of basename"); -} - -/if[ \t]+(test|![ \t]+test)/ { - warn("Use [ instead of test"); -} - -/[ \t]+(test|\[).*==/ { - warn("test(1)'s == operator is not portable"); -} - -/if.*;[ \t]*fi$/ { - warn("Avoid using a single-line if conditional"); -} - -END { - if (skip) - warn("Missing CHECK_STYLE_ENABLE"); - if (error) - exit 1 -} diff --git a/contrib/kyua/admin/check-style.sh b/contrib/kyua/admin/check-style.sh deleted file mode 100755 index 696f9247a74a..000000000000 --- a/contrib/kyua/admin/check-style.sh +++ /dev/null @@ -1,170 +0,0 @@ -#! /bin/sh -# Copyright 2011 The Kyua Authors. -# 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. - -# \file admin/check-style.sh -# -# Sanity checks the coding style of all source files in the project tree. - -ProgName="${0##*/}" - - -# Prints an error message and exits. -# -# \param ... Parts of the error message; concatenated using a space as the -# separator. -err() { - echo "${ProgName}:" "${@}" 1>&2 - exit 1 -} - - -# Locates all source files within the project directory. -# -# We require the project to have been configured in a directory that is separate -# from the source tree. This is to allow us to easily filter out build -# artifacts from our search. -# -# \param srcdir Absolute path to the source directory. -# \param builddir Absolute path to the build directory. -# \param tarname Basename of the project's tar file, to skip possible distfile -# directories. -find_sources() { - local srcdir="${1}"; shift - local builddir="${1}"; shift - local tarname="${1}"; shift - - ( - cd "${srcdir}" - find . -type f -a \ - \! -path "*/.git/*" \ - \! -path "*/.deps/*" \ - \! -path "*/autom4te.cache/*" \ - \! -path "*/${tarname}-[0-9]*/*" \ - \! -path "*/${builddir##*/}/*" \ - \! -name "Makefile.in" \ - \! -name "aclocal.m4" \ - \! -name "config.h.in" \ - \! -name "configure" \ - \! -name "testsuite" - ) -} - - -# Prints the style rules applicable to a given file. -# -# \param file Path to the source file. -guess_rules() { - local file="${1}"; shift - - case "${file}" in - */ax_cxx_compile_stdcxx.m4) ;; - */ltmain.sh) ;; - *Makefile*) echo common make ;; - *.[0-9]) echo common man ;; - *.cpp|*.hpp) echo common cpp ;; - *.sh) echo common shell ;; - *) echo common ;; - esac -} - - -# Validates a given file against the rules that apply to it. -# -# \param srcdir Absolute path to the source directory. -# \param file Name of the file to validate relative to srcdir. -# -# \return 0 if the file is valid; 1 otherwise, in which case the style -# violations are printed to the output. -check_file() { - local srcdir="${1}"; shift - local file="${1}"; shift - - local err=0 - for rule in $(guess_rules "${file}"); do - awk -f "${srcdir}/admin/check-style-${rule}.awk" \ - "${srcdir}/${file}" || err=1 - done - - return ${err} -} - - -# Entry point. -main() { - local builddir=. - local srcdir=. - local tarname=UNKNOWN - - local arg - while getopts :b:s:t: arg; do - case "${arg}" in - b) - builddir="${OPTARG}" - ;; - - s) - srcdir="${OPTARG}" - ;; - - t) - tarname="${OPTARG}" - ;; - - \?) - err "Unknown option -${OPTARG}" - ;; - esac - done - shift $(expr ${OPTIND} - 1) - - srcdir="$(cd "${srcdir}" && pwd -P)" - builddir="$(cd "${builddir}" && pwd -P)" - [ "${srcdir}" != "${builddir}" ] || \ - err "srcdir and builddir cannot match; reconfigure the package" \ - "in a separate directory" - - local sources - if [ ${#} -gt 0 ]; then - sources="${@}" - else - sources="$(find_sources "${srcdir}" "${builddir}" "${tarname}")" - fi - - local ok=0 - for file in ${sources}; do - local file="$(echo ${file} | sed -e "s,\\./,,")" - - check_file "${srcdir}" "${file}" || ok=1 - done - - return "${ok}" -} - - -main "${@}" diff --git a/contrib/kyua/admin/clean-all.sh b/contrib/kyua/admin/clean-all.sh deleted file mode 100755 index bc02f1e811f4..000000000000 --- a/contrib/kyua/admin/clean-all.sh +++ /dev/null @@ -1,90 +0,0 @@ -#! /bin/sh -# Copyright 2010 The Kyua Authors. -# 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. - -Prog_Name=${0##*/} - -if [ ! -f ./main.cpp ]; then - echo "${Prog_Name}: must be run from the source top directory" 1>&2 - exit 1 -fi - -if [ ! -f configure ]; then - echo "${Prog_Name}: configure not found; nothing to clean?" 1>&2 - exit 1 -fi - -[ -f Makefile ] || ./configure -make distclean - -# Top-level directory. -rm -f Makefile.in -rm -f aclocal.m4 -rm -rf autom4te.cache -rm -f config.h.in -rm -f configure -rm -f mkinstalldirs -rm -f kyua-*.tar.gz - -# admin directory. -rm -f admin/ar-lib -rm -f admin/compile -rm -f admin/config.guess -rm -f admin/config.sub -rm -f admin/depcomp -rm -f admin/install-sh -rm -f admin/ltmain.sh -rm -f admin/mdate-sh -rm -f admin/missing - -# bootstrap directory. -rm -f bootstrap/package.m4 -rm -f bootstrap/testsuite - -# doc directory. -rm -f doc/*.info -rm -f doc/stamp-vti -rm -f doc/version.texi - -# m4 directory. -rm -f m4/libtool.m4 -rm -f m4/lt*.m4 - -# Files and directories spread all around the tree. -find . -name '#*' | xargs rm -rf -find . -name '*~' | xargs rm -rf -find . -name .deps | xargs rm -rf -find . -name .gdb_history | xargs rm -rf -find . -name .libs | xargs rm -rf -find . -name .tmp | xargs rm -rf - -# Show remaining files. -if [ -n "${GIT}" ]; then - echo ">>> untracked and ignored files" - "${GIT}" status --porcelain --ignored | grep -E '^(\?\?|!!)' || true -fi diff --git a/contrib/kyua/admin/travis-build.sh b/contrib/kyua/admin/travis-build.sh deleted file mode 100755 index 0ccf1cc41efb..000000000000 --- a/contrib/kyua/admin/travis-build.sh +++ /dev/null @@ -1,98 +0,0 @@ -#! /bin/sh -# Copyright 2014 The Kyua Authors. -# 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. - -set -e -x - -run_autoreconf() { - if [ -d /usr/local/share/aclocal ]; then - autoreconf -isv -I/usr/local/share/aclocal - else - autoreconf -isv - fi -} - -do_apidocs() { - run_autoreconf || return 1 - ./configure --with-doxygen || return 1 - make check-api-docs -} - -do_distcheck() { - run_autoreconf || return 1 - ./configure || return 1 - - sudo sysctl -w "kernel.core_pattern=core.%p" - - local archflags= - [ "${ARCH?}" != i386 ] || archflags=-m32 - - cat >kyua.conf <<EOF -syntax(2) - --- We do not know how many CPUs the test machine has. However, parallelizing --- the execution of our tests to _any_ degree speeds up the time it takes to --- complete a test run because many of our tests are blocking. -parallelism = 4 -EOF - [ "${UNPRIVILEGED_USER:-no}" = no ] || \ - echo "unprivileged_user = 'nobody'" >>kyua.conf - - local f= - f="${f} CFLAGS='${archflags}'" - f="${f} CPPFLAGS='-I/usr/local/include'" - f="${f} CXXFLAGS='${archflags}'" - f="${f} LDFLAGS='-L/usr/local/lib -Wl,-R/usr/local/lib'" - f="${f} PKG_CONFIG_PATH='/usr/local/lib/pkgconfig'" - f="${f} KYUA_CONFIG_FILE_FOR_CHECK=$(pwd)/kyua.conf" - if [ "${AS_ROOT:-no}" = yes ]; then - sudo -H PATH="${PATH}" make distcheck DISTCHECK_CONFIGURE_FLAGS="${f}" - else - make distcheck DISTCHECK_CONFIGURE_FLAGS="${f}" - fi -} - -do_style() { - run_autoreconf || return 1 - mkdir build - cd build - ../configure || return 1 - make check-style -} - -main() { - if [ -z "${DO}" ]; then - echo "DO must be defined" 1>&2 - exit 1 - fi - for step in ${DO}; do - "do_${DO}" || exit 1 - done -} - -main "${@}" diff --git a/contrib/kyua/admin/travis-install-deps.sh b/contrib/kyua/admin/travis-install-deps.sh deleted file mode 100755 index 9341c43895b1..000000000000 --- a/contrib/kyua/admin/travis-install-deps.sh +++ /dev/null @@ -1,83 +0,0 @@ -#! /bin/sh -# Copyright 2014 The Kyua Authors. -# 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. - -set -e -x - -install_deps() { - local pkgsuffix= - local packages= - if [ "${ARCH?}" = i386 ]; then - pkgsuffix=:i386 - packages="${packages} gcc-multilib" - packages="${packages} g++-multilib" - sudo dpkg --add-architecture i386 - fi - packages="${packages} gdb" - packages="${packages} liblua5.2-0${pkgsuffix}" - packages="${packages} liblua5.2-dev${pkgsuffix}" - packages="${packages} libsqlite3-0${pkgsuffix}" - packages="${packages} libsqlite3-dev${pkgsuffix}" - packages="${packages} pkg-config${pkgsuffix}" - packages="${packages} sqlite3" - sudo apt-get update -qq - sudo apt-get install -y ${packages} -} - -install_kyua() { - local name="20190321-usr-local-kyua-ubuntu-16-04-${ARCH?}-${CC?}.tar.gz" - wget -O "${name}" "http://dl.bintray.com/ngie-eign/kyua/${name}" || return 1 - sudo tar -xzvp -C / -f "${name}" - rm -f "${name}" -} - -do_apidocs() { - sudo apt-get install -y doxygen -} - -do_distcheck() { - : -} - -do_style() { - : -} - -main() { - if [ -z "${DO}" ]; then - echo "DO must be defined" 1>&2 - exit 1 - fi - install_deps - install_kyua - for step in ${DO}; do - "do_${DO}" || exit 1 - done -} - -main "${@}" diff --git a/contrib/kyua/bootstrap/.gitignore b/contrib/kyua/bootstrap/.gitignore deleted file mode 100644 index effaef8e6b4a..000000000000 --- a/contrib/kyua/bootstrap/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -atconfig -package.m4 -testsuite -testsuite.log diff --git a/contrib/kyua/bootstrap/Kyuafile b/contrib/kyua/bootstrap/Kyuafile deleted file mode 100644 index 0f161b2d66eb..000000000000 --- a/contrib/kyua/bootstrap/Kyuafile +++ /dev/null @@ -1,5 +0,0 @@ -syntax(2) - -test_suite("kyua") - -plain_test_program{name="testsuite"} diff --git a/contrib/kyua/bootstrap/Makefile.am.inc b/contrib/kyua/bootstrap/Makefile.am.inc deleted file mode 100644 index 0dbf26002ce9..000000000000 --- a/contrib/kyua/bootstrap/Makefile.am.inc +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright 2010 The Kyua Authors. -# 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 WITH_ATF -tests_bootstrapdir = $(pkgtestsdir)/bootstrap - -tests_bootstrap_DATA = bootstrap/Kyuafile -EXTRA_DIST += $(tests_bootstrap_DATA) - -DISTCLEANFILES = bootstrap/atconfig \ - bootstrap/testsuite.lineno \ - bootstrap/testsuite.log - -distclean-local: distclean-testsuite -distclean-testsuite: - -rm -rf bootstrap/testsuite.dir - -EXTRA_DIST += bootstrap/Kyuafile \ - bootstrap/testsuite \ - bootstrap/package.m4 \ - bootstrap/testsuite.at - -tests_bootstrap_PROGRAMS = bootstrap/atf_helpers -bootstrap_atf_helpers_SOURCES = bootstrap/atf_helpers.cpp -bootstrap_atf_helpers_CXXFLAGS = $(ATF_CXX_CFLAGS) -bootstrap_atf_helpers_LDADD = $(ATF_CXX_LIBS) - -tests_bootstrap_PROGRAMS += bootstrap/plain_helpers -bootstrap_plain_helpers_SOURCES = bootstrap/plain_helpers.cpp -bootstrap_plain_helpers_CXXFLAGS = $(UTILS_CFLAGS) - -tests_bootstrap_SCRIPTS = bootstrap/testsuite -@target_srcdir@bootstrap/package.m4: $(top_srcdir)/configure.ac - $(AM_V_GEN){ \ - echo '# Signature of the current package.'; \ - echo 'm4_define(AT_PACKAGE_NAME, @PACKAGE_NAME@)'; \ - echo 'm4_define(AT_PACKAGE_TARNAME, @PACKAGE_TARNAME@)'; \ - echo 'm4_define(AT_PACKAGE_VERSION, @PACKAGE_VERSION@)'; \ - echo 'm4_define(AT_PACKAGE_STRING, @PACKAGE_STRING@)'; \ - echo 'm4_define(AT_PACKAGE_BUGREPORT, @PACKAGE_BUGREPORT@)'; \ - } >$(srcdir)/bootstrap/package.m4 - -@target_srcdir@bootstrap/testsuite: $(srcdir)/bootstrap/testsuite.at \ - @target_srcdir@bootstrap/package.m4 - $(AM_V_GEN)autom4te --language=Autotest -I $(srcdir) \ - -I $(srcdir)/bootstrap \ - $(srcdir)/bootstrap/testsuite.at -o $@.tmp; \ - mv $@.tmp $@ - -CHECK_LOCAL += check-bootstrap -PHONY_TARGETS += check-bootstrap -check-bootstrap: @target_srcdir@bootstrap/testsuite $(check_PROGRAMS) \ - $(CHECK_BOOTSTRAP_DEPS) - cd bootstrap && $(CHECK_ENVIRONMENT) $(TESTS_ENVIRONMENT) \ - ./testsuite - -if !TARGET_SRCDIR_EMPTY -CHECK_BOOTSTRAP_DEPS += copy-bootstrap-testsuite -CHECK_KYUA_DEPS += copy-bootstrap-testsuite -PHONY_TARGETS += copy-bootstrap-testsuite -copy-bootstrap-testsuite: - cp -f @target_srcdir@bootstrap/testsuite bootstrap/testsuite -CLEANFILES += bootstrap/testsuite -endif -endif diff --git a/contrib/kyua/bootstrap/plain_helpers.cpp b/contrib/kyua/bootstrap/plain_helpers.cpp deleted file mode 100644 index 7de629a99d4d..000000000000 --- a/contrib/kyua/bootstrap/plain_helpers.cpp +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2010 The Kyua Authors. -// 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. - -#include <cstdlib> -#include <cstring> -#include <iostream> - -#include "utils/defs.hpp" -#include "utils/test_utils.ipp" - - -namespace { - - -/// Prints a fake but valid test case list and then aborts. -/// -/// \param argv The original arguments of the program. -/// -/// \return Nothing because this dies before returning. -static int -helper_abort_test_cases_list(int /* argc */, char** argv) -{ - for (const char* const* arg = argv; *arg != NULL; arg++) { - if (std::strcmp(*arg, "-l") == 0) { - std::cout << "Content-Type: application/X-atf-tp; " - "version=\"1\"\n\n"; - std::cout << "ident: foo\n"; - } - } - utils::abort_without_coredump(); -} - - -/// Just returns without printing anything as the test case list. -/// -/// \return Always 0, as required for test programs. -static int -helper_empty_test_cases_list(int /* argc */, char** /* argv */) -{ - return EXIT_SUCCESS; -} - - -/// Prints a correctly-formatted test case list but empty. -/// -/// \param argv The original arguments of the program. -/// -/// \return Always 0, as required for test programs. -static int -helper_zero_test_cases(int /* argc */, char** argv) -{ - for (const char* const* arg = argv; *arg != NULL; arg++) { - if (std::strcmp(*arg, "-l") == 0) - std::cout << "Content-Type: application/X-atf-tp; " - "version=\"1\"\n\n"; - } - return EXIT_SUCCESS; -} - - -/// Mapping of the name of a helper to its implementation. -struct helper { - /// The name of the helper, as will be provided by the user on the CLI. - const char* name; - - /// A pointer to the function implementing the helper. - int (*hook)(int, char**); -}; - - -/// NULL-terminated table mapping helper names to their implementations. -static const helper helpers[] = { - { "abort_test_cases_list", helper_abort_test_cases_list, }, - { "empty_test_cases_list", helper_empty_test_cases_list, }, - { "zero_test_cases", helper_zero_test_cases, }, - { NULL, NULL, }, -}; - - -} // anonymous namespace - - -/// Entry point to the ATF-less helpers. -/// -/// The caller must select a helper to execute by defining the HELPER -/// environment variable to the name of the desired helper. Think of this main -/// method as a subprogram dispatcher, to avoid having many individual helper -/// binaries. -/// -/// \todo Maybe we should really have individual helper binaries. It would -/// avoid a significant amount of complexity here and in the tests, at the -/// expense of some extra files and extra build logic. -/// -/// \param argc The user argument count; delegated to the helper. -/// \param argv The user arguments; delegated to the helper. -/// -/// \return The exit code of the helper, which depends on the requested helper. -int -main(int argc, char** argv) -{ - const char* command = std::getenv("HELPER"); - if (command == NULL) { - std::cerr << "Usage error: HELPER must be set to a helper name\n"; - std::exit(EXIT_FAILURE); - } - - const struct helper* iter = helpers; - for (; iter->name != NULL && std::strcmp(iter->name, command) != 0; iter++) - ; - if (iter->name == NULL) { - std::cerr << "Usage error: unknown command " << command << "\n"; - std::exit(EXIT_FAILURE); - } - - return iter->hook(argc, argv); -} diff --git a/contrib/kyua/bootstrap/testsuite.at b/contrib/kyua/bootstrap/testsuite.at deleted file mode 100644 index 10200a67a5ca..000000000000 --- a/contrib/kyua/bootstrap/testsuite.at +++ /dev/null @@ -1,200 +0,0 @@ -dnl Copyright 2010 The Kyua Authors. -dnl All rights reserved. -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions are -dnl met: -dnl -dnl * Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl * Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. -dnl * Neither the name of Google Inc. nor the names of its contributors -dnl may be used to endorse or promote products derived from this software -dnl without specific prior written permission. -dnl -dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -AT_INIT([bootstrapping tests]) - - -m4_define([GUESS_TOPDIR], { - old=$(pwd) - cd "$(dirname ${as_myself})" - # We need to locate a build product, not a source file, because the - # test suite may be run outside of the source tree (think distcheck). - while test $(pwd) != '/' -a ! -e bootstrap/plain_helpers; do - cd .. - done - topdir=$(pwd) - cd ${old} - echo ${topdir} -}) - - -m4_define([CREATE_ATF_HELPERS], [ - AT_DATA([Kyuafile], [ -syntax(2) -test_suite("bootstrap") -atf_test_program{name="atf_helpers"} -]) - ln -s $(GUESS_TOPDIR)/bootstrap/atf_helpers atf_helpers -]) -m4_define([RUN_ATF_HELPERS], - [HOME=$(pwd) TESTS="$1" kyua --config=none \ - test --results-file=bootstrap.db $2]) - - -m4_define([CREATE_PLAIN_HELPERS], [ - AT_DATA([Kyuafile], [ -syntax(2) -test_suite("bootstrap") -atf_test_program{name="plain_helpers"} -]) - ln -s $(GUESS_TOPDIR)/bootstrap/plain_helpers plain_helpers -]) -m4_define([RUN_PLAIN_HELPER], - [HOME=$(pwd) HELPER="$1" kyua --config=none \ - test --results-file=bootstrap.db]) - - -AT_SETUP([test program crashes in test list]) -AT_TESTED([kyua]) - -CREATE_PLAIN_HELPERS -AT_CHECK([RUN_PLAIN_HELPER([abort_test_cases_list])], [1], [stdout], []) -re='plain_helpers:__test_cases_list__.*broken.*Test program received signal' -AT_CHECK([grep "${re}" stdout], [0], [ignore], []) - -AT_CLEANUP - - -AT_SETUP([test program prints an empty test list]) -AT_TESTED([kyua]) - -CREATE_PLAIN_HELPERS -AT_CHECK([RUN_PLAIN_HELPER([empty_test_cases_list])], [1], [stdout], []) -re="plain_helpers:__test_cases_list__.*broken.*Invalid header.*got ''" -AT_CHECK([grep "${re}" stdout], [0], [ignore], []) - -AT_CLEANUP - - -AT_SETUP([test program with zero test cases]) -AT_TESTED([kyua]) - -CREATE_PLAIN_HELPERS -AT_CHECK([RUN_PLAIN_HELPER([zero_test_cases])], [1], [stdout], []) -re='plain_helpers:__test_cases_list__.*broken.*No test cases' -AT_CHECK([grep "${re}" stdout], [0], [ignore], []) - -AT_CLEANUP - - -AT_SETUP([run test case that passes]) -AT_TESTED([kyua]) - -CREATE_ATF_HELPERS -AT_CHECK([RUN_ATF_HELPERS([passes])], [0], [stdout], []) -AT_CHECK([grep "atf_helpers:fails" stdout], [1], [], []) -AT_CHECK([grep "atf_helpers:passes.*passed" stdout], [0], [ignore], []) -AT_CHECK([grep "atf_helpers:skips" stdout], [1], [], []) - -AT_CLEANUP - - -AT_SETUP([run test case that fails]) -AT_TESTED([kyua]) - -CREATE_ATF_HELPERS -AT_CHECK([RUN_ATF_HELPERS([fails])], [1], [stdout], []) -AT_CHECK([grep "atf_helpers:fails.*failed.*Failed on purpose" stdout], - [0], [ignore], []) -AT_CHECK([grep "atf_helpers:passes" stdout], [1], [], []) -AT_CHECK([grep "atf_helpers:skips" stdout], [1], [], []) - -AT_CLEANUP - - -AT_SETUP([run test case that skips]) -AT_TESTED([kyua]) - -CREATE_ATF_HELPERS -AT_CHECK([RUN_ATF_HELPERS([skips])], [0], [stdout], []) -AT_CHECK([grep "atf_helpers:fails" stdout], [1], [], []) -AT_CHECK([grep "atf_helpers:passes" stdout], [1], [], []) -AT_CHECK([grep "atf_helpers:skips.*skipped.*Skipped on purpose" stdout], - [0], [ignore], []) - -AT_CLEANUP - - -AT_SETUP([run two test cases, success]) -AT_TESTED([kyua]) - -CREATE_ATF_HELPERS -AT_CHECK([RUN_ATF_HELPERS([passes skips])], [0], [stdout], []) -AT_CHECK([grep "atf_helpers:fails" stdout], [1], [], []) -AT_CHECK([grep "atf_helpers:passes.*passed" stdout], [0], [ignore], []) -AT_CHECK([grep "atf_helpers:skips.*skipped.*Skipped on purpose" stdout], - [0], [ignore], []) - -AT_CLEANUP - - -AT_SETUP([run two test cases, failure]) -AT_TESTED([kyua]) - -CREATE_ATF_HELPERS -AT_CHECK([RUN_ATF_HELPERS([fails passes])], [1], [stdout], []) -AT_CHECK([grep "atf_helpers:fails.*failure.*Failed on purpose" stdout], - [1], [], []) -AT_CHECK([grep "atf_helpers:passes.*passed" stdout], [0], [ignore], []) -AT_CHECK([grep "atf_helpers:skips" stdout], [1], [], []) - -AT_CLEANUP - - -AT_SETUP([run mixed test cases]) -AT_TESTED([kyua]) - -CREATE_ATF_HELPERS -AT_CHECK([RUN_ATF_HELPERS([fails passes skips])], [1], [stdout], []) -AT_CHECK([grep "atf_helpers:fails.*failure.*Failed on purpose" stdout], - [1], [], []) -AT_CHECK([grep "atf_helpers:passes.*passed" stdout], [0], [ignore], []) -AT_CHECK([grep "atf_helpers:skips.*skipped.*Skipped on purpose" stdout], - [0], [ignore], []) - -AT_CLEANUP - - -AT_SETUP([run tests from build directories]) -AT_TESTED([kyua]) - -CREATE_ATF_HELPERS -AT_CHECK([mkdir src], [0], [], []) -AT_CHECK([mv Kyuafile src], [0], [], []) -AT_CHECK([mkdir obj], [0], [], []) -AT_CHECK([mv atf_helpers obj], [0], [], []) -AT_CHECK([RUN_ATF_HELPERS([fails passes skips], - [--kyuafile=src/Kyuafile --build-root=obj])], - [1], [stdout], []) -AT_CHECK([grep "atf_helpers:fails.*failure.*Failed on purpose" stdout], - [1], [], []) -AT_CHECK([grep "atf_helpers:passes.*passed" stdout], [0], [ignore], []) -AT_CHECK([grep "atf_helpers:skips.*skipped.*Skipped on purpose" stdout], - [0], [ignore], []) - -AT_CLEANUP diff --git a/contrib/kyua/cli/Makefile.am.inc b/contrib/kyua/cli/Makefile.am.inc deleted file mode 100644 index 27872088a1b7..000000000000 --- a/contrib/kyua/cli/Makefile.am.inc +++ /dev/null @@ -1,123 +0,0 @@ -# Copyright 2010 The Kyua Authors. -# 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. - -CLI_CFLAGS = $(DRIVERS_CFLAGS) -CLI_LIBS = libcli.a $(DRIVERS_LIBS) - -noinst_LIBRARIES += libcli.a -libcli_a_SOURCES = cli/cmd_about.cpp -libcli_a_SOURCES += cli/cmd_about.hpp -libcli_a_SOURCES += cli/cmd_config.cpp -libcli_a_SOURCES += cli/cmd_config.hpp -libcli_a_SOURCES += cli/cmd_db_exec.cpp -libcli_a_SOURCES += cli/cmd_db_exec.hpp -libcli_a_SOURCES += cli/cmd_db_migrate.cpp -libcli_a_SOURCES += cli/cmd_db_migrate.hpp -libcli_a_SOURCES += cli/cmd_debug.cpp -libcli_a_SOURCES += cli/cmd_debug.hpp -libcli_a_SOURCES += cli/cmd_help.cpp -libcli_a_SOURCES += cli/cmd_help.hpp -libcli_a_SOURCES += cli/cmd_list.cpp -libcli_a_SOURCES += cli/cmd_list.hpp -libcli_a_SOURCES += cli/cmd_report.cpp -libcli_a_SOURCES += cli/cmd_report.hpp -libcli_a_SOURCES += cli/cmd_report_html.cpp -libcli_a_SOURCES += cli/cmd_report_html.hpp -libcli_a_SOURCES += cli/cmd_report_junit.cpp -libcli_a_SOURCES += cli/cmd_report_junit.hpp -libcli_a_SOURCES += cli/cmd_test.cpp -libcli_a_SOURCES += cli/cmd_test.hpp -libcli_a_SOURCES += cli/common.cpp -libcli_a_SOURCES += cli/common.hpp -libcli_a_SOURCES += cli/common.ipp -libcli_a_SOURCES += cli/config.cpp -libcli_a_SOURCES += cli/config.hpp -libcli_a_SOURCES += cli/main.cpp -libcli_a_SOURCES += cli/main.hpp -libcli_a_CPPFLAGS = -DKYUA_CONFDIR="\"$(kyua_confdir)\"" -libcli_a_CPPFLAGS += -DKYUA_DOCDIR="\"$(docdir)\"" -libcli_a_CPPFLAGS += -DKYUA_MISCDIR="\"$(miscdir)\"" -libcli_a_CPPFLAGS += $(DRIVERS_CFLAGS) -libcli_a_LIBADD = libutils.a - -if WITH_ATF -tests_clidir = $(pkgtestsdir)/cli - -tests_cli_DATA = cli/Kyuafile -EXTRA_DIST += $(tests_cli_DATA) - -tests_cli_PROGRAMS = cli/cmd_about_test -cli_cmd_about_test_SOURCES = cli/cmd_about_test.cpp -cli_cmd_about_test_CXXFLAGS = $(CLI_CFLAGS) $(ATF_CXX_CFLAGS) -cli_cmd_about_test_LDADD = $(CLI_LIBS) $(ATF_CXX_LIBS) - -tests_cli_PROGRAMS += cli/cmd_config_test -cli_cmd_config_test_SOURCES = cli/cmd_config_test.cpp -cli_cmd_config_test_CXXFLAGS = $(CLI_CFLAGS) $(ATF_CXX_CFLAGS) -cli_cmd_config_test_LDADD = $(CLI_LIBS) $(ATF_CXX_LIBS) - -tests_cli_PROGRAMS += cli/cmd_db_exec_test -cli_cmd_db_exec_test_SOURCES = cli/cmd_db_exec_test.cpp -cli_cmd_db_exec_test_CXXFLAGS = $(CLI_CFLAGS) $(ATF_CXX_CFLAGS) -cli_cmd_db_exec_test_LDADD = $(CLI_LIBS) $(ATF_CXX_LIBS) - -tests_cli_PROGRAMS += cli/cmd_debug_test -cli_cmd_debug_test_SOURCES = cli/cmd_debug_test.cpp -cli_cmd_debug_test_CXXFLAGS = $(CLI_CFLAGS) $(ATF_CXX_CFLAGS) -cli_cmd_debug_test_LDADD = $(CLI_LIBS) $(ATF_CXX_LIBS) - -tests_cli_PROGRAMS += cli/cmd_help_test -cli_cmd_help_test_SOURCES = cli/cmd_help_test.cpp -cli_cmd_help_test_CXXFLAGS = $(CLI_CFLAGS) $(ATF_CXX_CFLAGS) -cli_cmd_help_test_LDADD = $(CLI_LIBS) $(ATF_CXX_LIBS) - -tests_cli_PROGRAMS += cli/cmd_list_test -cli_cmd_list_test_SOURCES = cli/cmd_list_test.cpp -cli_cmd_list_test_CXXFLAGS = $(CLI_CFLAGS) $(ATF_CXX_CFLAGS) -cli_cmd_list_test_LDADD = $(CLI_LIBS) $(ATF_CXX_LIBS) - -tests_cli_PROGRAMS += cli/cmd_test_test -cli_cmd_test_test_SOURCES = cli/cmd_test_test.cpp -cli_cmd_test_test_CXXFLAGS = $(CLI_CFLAGS) $(ATF_CXX_CFLAGS) -cli_cmd_test_test_LDADD = $(CLI_LIBS) $(ATF_CXX_LIBS) - -tests_cli_PROGRAMS += cli/common_test -cli_common_test_SOURCES = cli/common_test.cpp -cli_common_test_CXXFLAGS = $(CLI_CFLAGS) $(ATF_CXX_CFLAGS) -cli_common_test_LDADD = $(CLI_LIBS) $(ATF_CXX_LIBS) - -tests_cli_PROGRAMS += cli/config_test -cli_config_test_SOURCES = cli/config_test.cpp -cli_config_test_CXXFLAGS = $(CLI_CFLAGS) $(ATF_CXX_CFLAGS) -cli_config_test_LDADD = $(CLI_LIBS) $(ATF_CXX_LIBS) - -tests_cli_PROGRAMS += cli/main_test -cli_main_test_SOURCES = cli/main_test.cpp -cli_main_test_CXXFLAGS = $(CLI_CFLAGS) $(ATF_CXX_CFLAGS) -cli_main_test_LDADD = $(CLI_LIBS) $(ATF_CXX_LIBS) -endif diff --git a/contrib/kyua/cli/cmd_debug.cpp b/contrib/kyua/cli/cmd_debug.cpp index 8ad52afb73a6..f5e48572407e 100644 --- a/contrib/kyua/cli/cmd_debug.cpp +++ b/contrib/kyua/cli/cmd_debug.cpp @@ -33,6 +33,7 @@ extern "C" { } #include <cstdlib> +#include <cstring> #include <iostream> #include "cli/common.ipp" @@ -105,7 +106,7 @@ public: { if (::chdir(_eh.work_directory().c_str()) == -1) { std::cerr << "execute: chdir() errors: " - << strerror(errno) << ".\n"; + << std::strerror(errno) << ".\n"; std::exit(EXIT_FAILURE); } @@ -154,14 +155,14 @@ public: _ui->out("The test failed and paused right before its cleanup " "routine."); _ui->out(F("Test work dir: %s") % eh.work_directory().str()); - _ui->out("Press <Enter> to continue..."); + _ui->out("Press any key to continue..."); (void) std::cin.get(); } } else if (_cmdline.has_option(pause_before_cleanup_option .long_name())) { _ui->out("The test paused right before its cleanup routine."); _ui->out(F("Test work dir: %s") % eh.work_directory().str()); - _ui->out("Press <Enter> to continue..."); + _ui->out("Press any key to continue..."); (void) std::cin.get(); } }; diff --git a/contrib/kyua/cli/main.cpp b/contrib/kyua/cli/main.cpp index ad679f0949b3..ca15a06a999a 100644 --- a/contrib/kyua/cli/main.cpp +++ b/contrib/kyua/cli/main.cpp @@ -57,6 +57,7 @@ extern "C" { #include "cli/common.ipp" #include "cli/config.hpp" #include "engine/atf.hpp" +#include "engine/googletest.hpp" #include "engine/plain.hpp" #include "engine/scheduler.hpp" #include "engine/tap.hpp" @@ -104,6 +105,9 @@ register_scheduler_interfaces(void) "atf", std::shared_ptr< scheduler::interface >( new engine::atf_interface())); scheduler::register_interface( + "googletest", std::shared_ptr< scheduler::interface >( + new engine::googletest_interface())); + scheduler::register_interface( "plain", std::shared_ptr< scheduler::interface >( new engine::plain_interface())); scheduler::register_interface( diff --git a/contrib/kyua/config.h b/contrib/kyua/config.h new file mode 100644 index 000000000000..d2e8728dde38 --- /dev/null +++ b/contrib/kyua/config.h @@ -0,0 +1,139 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to the optind value to reset getopt processing */ +#define GETOPT_OPTIND_RESET_VALUE 1 + +/* define if the compiler supports basic C++20 syntax */ +#define HAVE_CXX20 1 + +/* Define to 1 if you have the <dlfcn.h> header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if getcwd(NULL, 0) works */ +#define HAVE_GETCWD_DYN 1 + +/* Define to 1 if getopt allows a + sign for POSIX behavior */ +/* #undef HAVE_GETOPT_GNU */ + +/* Define to 1 if getopt has optreset */ +#define HAVE_GETOPT_WITH_OPTRESET 1 + +/* Define to 1 if you have the <inttypes.h> header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the 'putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define to 1 if you have the 'setenv' function. */ +#define HAVE_SETENV 1 + +/* Define to 1 if you have the 'statfs' function. */ +#define HAVE_STATFS 1 + +/* Define to 1 if you have the 'statvfs' function. */ +#define HAVE_STATVFS 1 + +/* Define to 1 if you have the <stdint.h> header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the <stdio.h> header file. */ +#define HAVE_STDIO_H 1 + +/* Define to 1 if you have the <stdlib.h> header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the <strings.h> header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the <string.h> header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the 'sysctlbyname' function. */ +#define HAVE_SYSCTLBYNAME 1 + +/* Define to 1 if you have the <sys/mount.h> header file. */ +#define HAVE_SYS_MOUNT_H 1 + +/* Define to 1 if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the <sys/statvfs.h> header file. */ +#define HAVE_SYS_STATVFS_H 1 + +/* Define to 1 if you have the <sys/stat.h> header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the <sys/sysctl.h> header file. */ +#define HAVE_SYS_SYSCTL_H 1 + +/* Define to 1 if you have the <sys/types.h> header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the <sys/vfs.h> header file. */ +/* #undef HAVE_SYS_VFS_H */ + +/* Define to 1 if you have the <termios.h> header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the 'umount' function. */ +/* #undef HAVE_UMOUNT */ + +/* Define to 1 if you have the <unistd.h> header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the 'unmount' function. */ +#define HAVE_UNMOUNT 1 + +/* Define to 1 if you have the 'unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define to 1 if your lchmod works */ +#define HAVE_WORKING_LCHMOD 1 + +/* Name of the system architecture (aka processor type) */ +/* #undef KYUA_ARCHITECTURE */ + +/* Name of the system platform (aka machine name) */ +/* #undef KYUA_PLATFORM */ + +/* Define to the last valid signal number */ +#define LAST_SIGNO 128 + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* Define to the name of the sysctl MIB */ +#define MEMORY_QUERY_SYSCTL_MIB "hw.usermem" + +/* Define to the memory query type */ +#define MEMORY_QUERY_TYPE "sysctlbyname" + +/* Name of package */ +#define PACKAGE "kyua" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "freebsd-testing@FreeBSD.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "Kyua" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "Kyua 0.15.0" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "kyua" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "https://github.com/freebsd/kyua/" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "0.15.0" + +/* Define to 1 if all of the C89 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#define VERSION "0.15.0" diff --git a/contrib/kyua/configure.ac b/contrib/kyua/configure.ac deleted file mode 100644 index a0df977c5226..000000000000 --- a/contrib/kyua/configure.ac +++ /dev/null @@ -1,173 +0,0 @@ -dnl Copyright 2010 The Kyua Authors. -dnl All rights reserved. -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions are -dnl met: -dnl -dnl * Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl * Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. -dnl * Neither the name of Google Inc. nor the names of its contributors -dnl may be used to endorse or promote products derived from this software -dnl without specific prior written permission. -dnl -dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -AC_INIT([Kyua], [0.14], [kyua-discuss@googlegroups.com], [kyua], - [https://github.com/jmmv/kyua/]) -AC_PREREQ([2.65]) - - -AC_COPYRIGHT([Copyright 2010 The Kyua Authors.]) -AC_CONFIG_AUX_DIR([admin]) -AC_CONFIG_FILES([Doxyfile Makefile utils/defs.hpp]) -AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_MACRO_DIR([m4]) -AC_CONFIG_SRCDIR([main.cpp]) -AC_CONFIG_TESTDIR([bootstrap]) - - -AM_INIT_AUTOMAKE([1.9 foreign subdir-objects -Wall]) - - -AC_LANG([C++]) -AC_PROG_CXX -AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory]) -m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) -KYUA_DEVELOPER_MODE([C++]) -KYUA_ATTRIBUTE_NORETURN -KYUA_ATTRIBUTE_PURE -KYUA_ATTRIBUTE_UNUSED -KYUA_FS_MODULE -KYUA_GETOPT -KYUA_LAST_SIGNO -KYUA_MEMORY -AC_CHECK_FUNCS([putenv setenv unsetenv]) -AC_CHECK_HEADERS([termios.h]) - - -AC_PROG_RANLIB - - -m4_ifndef([PKG_CHECK_MODULES], - [m4_fatal([Cannot find pkg.m4; see the INSTALL document for help])]) - -m4_ifndef([ATF_CHECK_CXX], - [m4_fatal([Cannot find atf-c++.m4; see the INSTALL document for help])]) -ATF_CHECK_CXX([>= 0.17]) -m4_ifndef([ATF_CHECK_SH], - [m4_fatal([Cannot find atf-sh.m4; see the INSTALL document for help])]) -ATF_CHECK_SH([>= 0.15]) -m4_ifndef([ATF_ARG_WITH], - [m4_fatal([Cannot find atf-common.m4; see the INSTALL document for help])]) -ATF_ARG_WITH - -PKG_CHECK_MODULES([LUTOK], [lutok >= 0.4], - [], - AC_MSG_ERROR([lutok (0.4 or newer) is required])) -PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.6.22], - [], - AC_MSG_ERROR([sqlite3 (3.6.22 or newer) is required])) -KYUA_DOXYGEN -AC_PATH_PROG([GDB], [gdb]) -test -n "${GDB}" || GDB=gdb -AC_PATH_PROG([GIT], [git]) - - -KYUA_UNAME_ARCHITECTURE -KYUA_UNAME_PLATFORM - - -AC_ARG_VAR([KYUA_CONFSUBDIR], - [Subdirectory of sysconfdir under which to look for files]) -if test x"${KYUA_CONFSUBDIR-unset}" = x"unset"; then - KYUA_CONFSUBDIR=kyua -else - case ${KYUA_CONFSUBDIR} in - /*) - AC_MSG_ERROR([KYUA_CONFSUBDIR must hold a relative path]) - ;; - *) - ;; - esac -fi -if test x"${KYUA_CONFSUBDIR}" = x""; then - AC_SUBST(kyua_confdir, \${sysconfdir}) -else - AC_SUBST(kyua_confdir, \${sysconfdir}/${KYUA_CONFSUBDIR}) -fi - - -dnl Allow the caller of 'make check', 'make installcheck' and 'make distcheck' -dnl on the Kyua source tree to override the configuration file passed to our -dnl own test runs. This is for the development of Kyua only and the value of -dnl this setting has no effect on the built product in any way. If we go -dnl through great extents in validating the value of this setting, it is to -dnl minimize the chance of false test run negatives later on. -AC_ARG_VAR([KYUA_CONFIG_FILE_FOR_CHECK], - [kyua.conf file to use at 'make (|dist|install)check' time]) -case "${KYUA_CONFIG_FILE_FOR_CHECK-none}" in -none) - KYUA_CONFIG_FILE_FOR_CHECK=none - ;; -/*) - if test -f "${KYUA_CONFIG_FILE_FOR_CHECK}"; then - : # All good! - else - AC_MSG_ERROR([KYUA_CONFIG_FILE_FOR_CHECK file does not exist]) - fi - ;; -*) - AC_MSG_ERROR([KYUA_CONFIG_FILE_FOR_CHECK must hold an absolute path]) - ;; -esac - - -AC_ARG_VAR([KYUA_TMPDIR], - [Path to the directory in which to place work directories]) -case "${KYUA_TMPDIR:-unset}" in - unset) - KYUA_TMPDIR=/tmp - ;; - /*) - ;; - *) - AC_MSG_ERROR([KYUA_TMPDIR must be an absolute path]) - ;; -esac - - -AC_SUBST(examplesdir, \${pkgdatadir}/examples) -AC_SUBST(luadir, \${pkgdatadir}/lua) -AC_SUBST(miscdir, \${pkgdatadir}/misc) -AC_SUBST(pkgtestsdir, \${testsdir}/kyua) -AC_SUBST(storedir, \${pkgdatadir}/store) -AC_SUBST(testsdir, \${exec_prefix}/tests) - - -dnl BSD make(1) doesn't deal with targets specified as './foo' well: they -dnl need to be specified as 'foo'. The following hack is to workaround this -dnl issue. -if test "${srcdir}" = .; then - target_srcdir= -else - target_srcdir="${srcdir}/" -fi -AM_CONDITIONAL(TARGET_SRCDIR_EMPTY, [test -z "${target_srcdir}"]) -AC_SUBST([target_srcdir]) - - -AC_OUTPUT diff --git a/contrib/kyua/doc/.gitignore b/contrib/kyua/doc/.gitignore deleted file mode 100644 index ecaaf27b9262..000000000000 --- a/contrib/kyua/doc/.gitignore +++ /dev/null @@ -1,14 +0,0 @@ -kyua-about.1 -kyua-config.1 -kyua-db-exec.1 -kyua-db-migrate.1 -kyua-debug.1 -kyua-help.1 -kyua-list.1 -kyua-report-html.1 -kyua-report-junit.1 -kyua-report.1 -kyua-test.1 -kyua.1 -kyua.conf.5 -kyuafile.5 diff --git a/contrib/kyua/doc/Makefile.am.inc b/contrib/kyua/doc/Makefile.am.inc deleted file mode 100644 index 638191218bcc..000000000000 --- a/contrib/kyua/doc/Makefile.am.inc +++ /dev/null @@ -1,152 +0,0 @@ -# Copyright 2011 The Kyua Authors. -# 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. - -BUILD_MANPAGE = \ - $(MKDIR_P) doc; \ - $(SHELL) $(srcdir)/doc/manbuild.sh \ - -v "CONFDIR=$(kyua_confdir)" \ - -v "DOCDIR=$(docdir)" \ - -v "EGDIR=$(examplesdir)" \ - -v "MISCDIR=$(miscdir)" \ - -v "PACKAGE=$(PACKAGE_TARNAME)" \ - -v "STOREDIR=$(storedir)" \ - -v "TESTSDIR=$(testsdir)" \ - -v "VERSION=$(PACKAGE_VERSION)" \ - "$(srcdir)/doc/$${name}.in" "doc/$${name}" - -DIST_MAN_DEPS = doc/manbuild.sh \ - doc/build-root.mdoc \ - doc/results-file-flag-read.mdoc \ - doc/results-file-flag-write.mdoc \ - doc/results-files.mdoc \ - doc/results-files-report-example.mdoc \ - doc/test-filters.mdoc \ - doc/test-isolation.mdoc -MAN_DEPS = $(DIST_MAN_DEPS) Makefile -EXTRA_DIST += $(DIST_MAN_DEPS) - -man_MANS = doc/kyua-about.1 -CLEANFILES += doc/kyua-about.1 -EXTRA_DIST += doc/kyua-about.1.in -doc/kyua-about.1: $(srcdir)/doc/kyua-about.1.in $(MAN_DEPS) - $(AM_V_GEN)name=kyua-about.1; $(BUILD_MANPAGE) - -man_MANS += doc/kyua-config.1 -CLEANFILES += doc/kyua-config.1 -EXTRA_DIST += doc/kyua-config.1.in -doc/kyua-config.1: $(srcdir)/doc/kyua-config.1.in $(MAN_DEPS) - $(AM_V_GEN)name=kyua-config.1; $(BUILD_MANPAGE) - -man_MANS += doc/kyua-db-exec.1 -CLEANFILES += doc/kyua-db-exec.1 -EXTRA_DIST += doc/kyua-db-exec.1.in -doc/kyua-db-exec.1: $(srcdir)/doc/kyua-db-exec.1.in $(MAN_DEPS) - $(AM_V_GEN)name=kyua-db-exec.1; $(BUILD_MANPAGE) - -man_MANS += doc/kyua-db-migrate.1 -CLEANFILES += doc/kyua-db-migrate.1 -EXTRA_DIST += doc/kyua-db-migrate.1.in -doc/kyua-db-migrate.1: $(srcdir)/doc/kyua-db-migrate.1.in $(MAN_DEPS) - $(AM_V_GEN)name=kyua-db-migrate.1; $(BUILD_MANPAGE) - -man_MANS += doc/kyua-debug.1 -CLEANFILES += doc/kyua-debug.1 -EXTRA_DIST += doc/kyua-debug.1.in -doc/kyua-debug.1: $(srcdir)/doc/kyua-debug.1.in $(MAN_DEPS) - $(AM_V_GEN)name=kyua-debug.1; $(BUILD_MANPAGE) - -man_MANS += doc/kyua-help.1 -CLEANFILES += doc/kyua-help.1 -EXTRA_DIST += doc/kyua-help.1.in -doc/kyua-help.1: $(srcdir)/doc/kyua-help.1.in $(MAN_DEPS) - $(AM_V_GEN)name=kyua-help.1; $(BUILD_MANPAGE) - -man_MANS += doc/kyua-list.1 -CLEANFILES += doc/kyua-list.1 -EXTRA_DIST += doc/kyua-list.1.in -doc/kyua-list.1: $(srcdir)/doc/kyua-list.1.in $(MAN_DEPS) - $(AM_V_GEN)name=kyua-list.1; $(BUILD_MANPAGE) - -man_MANS += doc/kyua-report-html.1 -CLEANFILES += doc/kyua-report-html.1 -EXTRA_DIST += doc/kyua-report-html.1.in -doc/kyua-report-html.1: $(srcdir)/doc/kyua-report-html.1.in $(MAN_DEPS) - $(AM_V_GEN)name=kyua-report-html.1; $(BUILD_MANPAGE) - -man_MANS += doc/kyua-report-junit.1 -CLEANFILES += doc/kyua-report-junit.1 -EXTRA_DIST += doc/kyua-report-junit.1.in -doc/kyua-report-junit.1: $(srcdir)/doc/kyua-report-junit.1.in $(MAN_DEPS) - $(AM_V_GEN)name=kyua-report-junit.1; $(BUILD_MANPAGE) - -man_MANS += doc/kyua-report.1 -CLEANFILES += doc/kyua-report.1 -EXTRA_DIST += doc/kyua-report.1.in -doc/kyua-report.1: $(srcdir)/doc/kyua-report.1.in $(MAN_DEPS) - $(AM_V_GEN)name=kyua-report.1; $(BUILD_MANPAGE) - -man_MANS += doc/kyua-test.1 -CLEANFILES += doc/kyua-test.1 -EXTRA_DIST += doc/kyua-test.1.in -doc/kyua-test.1: $(srcdir)/doc/kyua-test.1.in $(MAN_DEPS) - $(AM_V_GEN)name=kyua-test.1; $(BUILD_MANPAGE) - -man_MANS += doc/kyua.1 -CLEANFILES += doc/kyua.1 -EXTRA_DIST += doc/kyua.1.in -doc/kyua.1: $(srcdir)/doc/kyua.1.in $(MAN_DEPS) - $(AM_V_GEN)name=kyua.1; $(BUILD_MANPAGE) - -man_MANS += doc/kyua.conf.5 -CLEANFILES += doc/kyua.conf.5 -EXTRA_DIST += doc/kyua.conf.5.in -doc/kyua.conf.5: $(srcdir)/doc/kyua.conf.5.in $(MAN_DEPS) - $(AM_V_GEN)name=kyua.conf.5; $(BUILD_MANPAGE) - -man_MANS += doc/kyuafile.5 -CLEANFILES += doc/kyuafile.5 -EXTRA_DIST += doc/kyuafile.5.in -doc/kyuafile.5: $(srcdir)/doc/kyuafile.5.in $(MAN_DEPS) - $(AM_V_GEN)name=kyuafile.5; $(BUILD_MANPAGE) - -if WITH_ATF -EXTRA_DIST += doc/Kyuafile - -noinst_SCRIPTS += doc/manbuild_test -CLEANFILES += doc/manbuild_test -EXTRA_DIST += doc/manbuild_test.sh -doc/manbuild_test: $(srcdir)/doc/manbuild_test.sh Makefile - $(AM_V_GEN)$(MKDIR_P) doc; \ - echo "#! $(ATF_SH)" >doc/manbuild_test.tmp; \ - echo "# AUTOMATICALLY GENERATED FROM Makefile" \ - >>doc/manbuild_test.tmp; \ - sed -e 's,__MANBUILD__,$(abs_srcdir)/doc/manbuild.sh,g' \ - <$(srcdir)/doc/manbuild_test.sh >>doc/manbuild_test.tmp; \ - mv doc/manbuild_test.tmp doc/manbuild_test; \ - chmod +x doc/manbuild_test -endif diff --git a/contrib/kyua/doc/kyua-about.1.in b/contrib/kyua/doc/kyua-about.1.in index 1ea134810e65..91e4dd5c2fa9 100644 --- a/contrib/kyua/doc/kyua-about.1.in +++ b/contrib/kyua/doc/kyua-about.1.in @@ -30,7 +30,7 @@ .Os .Sh NAME .Nm "kyua about" -.Nd Shows detailed authors, license, and version information +.Nd show detailed authors, license, and version information .Sh SYNOPSIS .Nm .Op Ar authors | license | version diff --git a/contrib/kyua/doc/kyua-config.1.in b/contrib/kyua/doc/kyua-config.1.in index 9c13ce06505e..ae08ad9e013a 100644 --- a/contrib/kyua/doc/kyua-config.1.in +++ b/contrib/kyua/doc/kyua-config.1.in @@ -30,7 +30,7 @@ .Os .Sh NAME .Nm "kyua config" -.Nd Inspects the values of the loaded configuration +.Nd inspect the values of the loaded configuration .Sh SYNOPSIS .Nm .Op Ar variable1 .. variableN diff --git a/contrib/kyua/doc/kyua-db-exec.1.in b/contrib/kyua/doc/kyua-db-exec.1.in index 2e3bada4f849..ee04229b037d 100644 --- a/contrib/kyua/doc/kyua-db-exec.1.in +++ b/contrib/kyua/doc/kyua-db-exec.1.in @@ -30,7 +30,7 @@ .Os .Sh NAME .Nm "kyua db-exec" -.Nd Executes a SQL statement in a results file +.Nd execute a SQL statement in a results file .Sh SYNOPSIS .Nm .Op Fl -no-headers diff --git a/contrib/kyua/doc/kyua-db-migrate.1.in b/contrib/kyua/doc/kyua-db-migrate.1.in index 4a1852aafd36..379d9662d4c8 100644 --- a/contrib/kyua/doc/kyua-db-migrate.1.in +++ b/contrib/kyua/doc/kyua-db-migrate.1.in @@ -30,7 +30,7 @@ .Os .Sh NAME .Nm "kyua db-migrate" -.Nd Upgrades the schema of an existing results file +.Nd upgrade the schema of an existing results file .Sh SYNOPSIS .Nm .Op Fl -results-file Ar file diff --git a/contrib/kyua/doc/kyua-debug.1.in b/contrib/kyua/doc/kyua-debug.1.in index a28c82dc270f..c49875592e62 100644 --- a/contrib/kyua/doc/kyua-debug.1.in +++ b/contrib/kyua/doc/kyua-debug.1.in @@ -25,12 +25,12 @@ .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.Dd July 22, 2026 +.Dd April 18, 2026 .Dt KYUA-DEBUG 1 .Os .Sh NAME .Nm "kyua debug" -.Nd Executes a single test case with facilities for debugging +.Nd execute a single test case with facilities for debugging .Sh SYNOPSIS .Nm .Op Fl -build-root Ar path diff --git a/contrib/kyua/doc/kyua-help.1.in b/contrib/kyua/doc/kyua-help.1.in index 2c4f2bc3859e..e9ffc673927d 100644 --- a/contrib/kyua/doc/kyua-help.1.in +++ b/contrib/kyua/doc/kyua-help.1.in @@ -30,7 +30,7 @@ .Os .Sh NAME .Nm "kyua help" -.Nd Shows usage information +.Nd show usage information .Sh SYNOPSIS .Nm .Op Ar command diff --git a/contrib/kyua/doc/kyua-list.1.in b/contrib/kyua/doc/kyua-list.1.in index 5774354d9236..da0dae1480fb 100644 --- a/contrib/kyua/doc/kyua-list.1.in +++ b/contrib/kyua/doc/kyua-list.1.in @@ -30,7 +30,7 @@ .Os .Sh NAME .Nm "kyua list" -.Nd Lists test cases and their metadata +.Nd list test cases and their metadata .Sh SYNOPSIS .Nm .Op Fl -build-root Ar path diff --git a/contrib/kyua/doc/kyua-report-html.1.in b/contrib/kyua/doc/kyua-report-html.1.in index 3ff044ca8d30..98c00cdfd378 100644 --- a/contrib/kyua/doc/kyua-report-html.1.in +++ b/contrib/kyua/doc/kyua-report-html.1.in @@ -30,7 +30,7 @@ .Os .Sh NAME .Nm "kyua report-html" -.Nd Generates an HTML report with the results of a test suite run +.Nd generate an HTML report with the results of a test suite run .Sh SYNOPSIS .Nm .Op Fl -force diff --git a/contrib/kyua/doc/kyua-report-junit.1.in b/contrib/kyua/doc/kyua-report-junit.1.in index 508ea30a3f6e..a3b954cb8f26 100644 --- a/contrib/kyua/doc/kyua-report-junit.1.in +++ b/contrib/kyua/doc/kyua-report-junit.1.in @@ -30,7 +30,7 @@ .Os .Sh NAME .Nm "kyua report-junit" -.Nd Generates a JUnit report with the results of a test suite run +.Nd generate a JUnit report with the results of a test suite run .Sh SYNOPSIS .Nm .Op Fl -output Ar path diff --git a/contrib/kyua/doc/kyua-report.1.in b/contrib/kyua/doc/kyua-report.1.in index a3e4d75456cf..feeb3e7338be 100644 --- a/contrib/kyua/doc/kyua-report.1.in +++ b/contrib/kyua/doc/kyua-report.1.in @@ -30,7 +30,7 @@ .Os .Sh NAME .Nm "kyua report" -.Nd Generates reports with the results of a test suite run +.Nd generate reports with the results of a test suite run .Sh SYNOPSIS .Nm .Op Fl -output Ar path diff --git a/contrib/kyua/doc/kyua-test.1.in b/contrib/kyua/doc/kyua-test.1.in index 07db6cf461c2..7caf0edf79b0 100644 --- a/contrib/kyua/doc/kyua-test.1.in +++ b/contrib/kyua/doc/kyua-test.1.in @@ -30,7 +30,7 @@ .Os .Sh NAME .Nm "kyua test" -.Nd Runs tests +.Nd run tests .Sh SYNOPSIS .Nm .Op Fl -build-root Ar path diff --git a/contrib/kyua/doc/kyua.1.in b/contrib/kyua/doc/kyua.1.in index 4a3ab7852b11..118da35d23dd 100644 --- a/contrib/kyua/doc/kyua.1.in +++ b/contrib/kyua/doc/kyua.1.in @@ -30,7 +30,7 @@ .Os .Sh NAME .Nm kyua -.Nd Testing framework for infrastructure software +.Nd testing framework for infrastructure software .Sh SYNOPSIS .Nm .Op Fl -config Ar file @@ -280,13 +280,13 @@ The first step in reporting a bug is to check if there already is a similar bug in the database. You can check what issues are currently in the database by going to: .Bd -literal -offset indent -https://github.com/jmmv/kyua/issues/ +https://github.com/freebsd/kyua/issues/ .Ed .Pp If there is no existing issue that describes an issue similar to the one you are experiencing, you can open a new one by visiting: .Bd -literal -offset indent -https://github.com/jmmv/kyua/issues/new/ +https://github.com/freebsd/kyua/issues/new/ .Ed .Pp When doing so, please include as much detail as possible. diff --git a/contrib/kyua/doc/kyua.conf.5.in b/contrib/kyua/doc/kyua.conf.5.in index 7188bb8888c3..b939aedc3221 100644 --- a/contrib/kyua/doc/kyua.conf.5.in +++ b/contrib/kyua/doc/kyua.conf.5.in @@ -30,7 +30,7 @@ .Os .Sh NAME .Nm kyua.conf -.Nd Configuration file for the kyua tool +.Nd configuration file for the kyua tool .Sh SYNOPSIS .Fn syntax "int version" .Pp diff --git a/contrib/kyua/doc/kyuafile.5.in b/contrib/kyua/doc/kyuafile.5.in index eddb8f92cb86..ae4b8ebfa3fe 100644 --- a/contrib/kyua/doc/kyuafile.5.in +++ b/contrib/kyua/doc/kyuafile.5.in @@ -25,12 +25,12 @@ .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.Dd March 23, 2024 +.Dd November 29, 2024 .Dt KYUAFILE 5 .Os .Sh NAME .Nm Kyuafile -.Nd Test suite description files +.Nd test suite description files .Sh SYNOPSIS .Fn atf_test_program "string name" "[string metadata]" .Fn current_kyuafile @@ -40,6 +40,7 @@ .Fn fs.files "string path" .Fn fs.is_absolute "string path" .Fn fs.join "string path" "string path" +.Fn googletest_test_program "string name" "[string metadata]" .Fn include "string path" .Fn plain_test_program "string name" "[string metadata]" .Fn syntax "int version" @@ -124,6 +125,16 @@ Any metadata properties defined by the test cases themselves override the metadata values defined here. The mapping to ATF metadata naming for each property is provided below. .Pp +.Em Google Test test programs +are those that use the Google Test test infrastructure. +They can be registered with the +.Fn googletest_test_program +table constructor. +This function takes the +.Fa name +of the test program, and a collection of optional metadata settings for the +test program. +.Pp .Em Plain test programs are those that return 0 on success and non-0 on failure; in general, most test programs (even those that use fancy unit-testing libraries) behave this way and @@ -300,7 +311,6 @@ Supported platforms: .Pp ATF: .Va require.kmods -(appends to the list declared at the Kyuafile level instead of overwriting it) .It Va required_memory Amount of physical memory that the test needs to run successfully. .Pp @@ -459,6 +469,9 @@ syntax(2) test_suite('second') +googletest_test_program{name='dont_run_as_root_test', + required_user='unprivileged'} + plain_test_program{name='legacy_test', allowed_architectures='amd64 i386', required_files='/bin/ls', diff --git a/contrib/kyua/drivers/Makefile.am.inc b/contrib/kyua/drivers/Makefile.am.inc deleted file mode 100644 index 0bd5a08209de..000000000000 --- a/contrib/kyua/drivers/Makefile.am.inc +++ /dev/null @@ -1,72 +0,0 @@ -# Copyright 2011 The Kyua Authors. -# 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. - -DRIVERS_CFLAGS = $(ENGINE_CFLAGS) $(STORE_CFLAGS) $(MODEL_CFLAGS) \ - $(UTILS_CFLAGS) -DRIVERS_LIBS = libdrivers.a $(ENGINE_LIBS) $(STORE_LIBS) $(MODEL_LIBS) \ - $(UTILS_LIBS) - -noinst_LIBRARIES += libdrivers.a -libdrivers_a_CPPFLAGS = $(DRIVERS_CFLAGS) -libdrivers_a_SOURCES = drivers/debug_test.cpp -libdrivers_a_SOURCES += drivers/debug_test.hpp -libdrivers_a_SOURCES += drivers/list_tests.cpp -libdrivers_a_SOURCES += drivers/list_tests.hpp -libdrivers_a_SOURCES += drivers/report_junit.cpp -libdrivers_a_SOURCES += drivers/report_junit.hpp -libdrivers_a_SOURCES += drivers/run_tests.cpp -libdrivers_a_SOURCES += drivers/run_tests.hpp -libdrivers_a_SOURCES += drivers/scan_results.cpp -libdrivers_a_SOURCES += drivers/scan_results.hpp - -if WITH_ATF -tests_driversdir = $(pkgtestsdir)/drivers - -tests_drivers_DATA = drivers/Kyuafile -EXTRA_DIST += $(tests_drivers_DATA) - -tests_drivers_PROGRAMS = drivers/list_tests_helpers -drivers_list_tests_helpers_SOURCES = drivers/list_tests_helpers.cpp -drivers_list_tests_helpers_CXXFLAGS = $(ATF_CXX_CFLAGS) -drivers_list_tests_helpers_LDADD = $(ATF_CXX_LIBS) - -tests_drivers_PROGRAMS += drivers/list_tests_test -drivers_list_tests_test_SOURCES = drivers/list_tests_test.cpp -drivers_list_tests_test_CXXFLAGS = $(DRIVERS_CFLAGS) $(ATF_CXX_CFLAGS) -drivers_list_tests_test_LDADD = $(DRIVERS_LIBS) $(ATF_CXX_LIBS) - -tests_drivers_PROGRAMS += drivers/report_junit_test -drivers_report_junit_test_SOURCES = drivers/report_junit_test.cpp -drivers_report_junit_test_CXXFLAGS = $(DRIVERS_CFLAGS) $(ATF_CXX_CFLAGS) -drivers_report_junit_test_LDADD = $(DRIVERS_LIBS) $(ATF_CXX_LIBS) - -tests_drivers_PROGRAMS += drivers/scan_results_test -drivers_scan_results_test_SOURCES = drivers/scan_results_test.cpp -drivers_scan_results_test_CXXFLAGS = $(DRIVERS_CFLAGS) $(ATF_CXX_CFLAGS) -drivers_scan_results_test_LDADD = $(DRIVERS_LIBS) $(ATF_CXX_LIBS) -endif diff --git a/contrib/kyua/engine/Kyuafile b/contrib/kyua/engine/Kyuafile index 1baa63bc9118..5337dc19817a 100644 --- a/contrib/kyua/engine/Kyuafile +++ b/contrib/kyua/engine/Kyuafile @@ -8,6 +8,9 @@ atf_test_program{name="atf_result_test"} atf_test_program{name="config_test"} atf_test_program{name="exceptions_test"} atf_test_program{name="filters_test"} +atf_test_program{name="googletest_test"} +atf_test_program{name="googletest_list_test"} +atf_test_program{name="googletest_result_test"} atf_test_program{name="kyuafile_test"} atf_test_program{name="plain_test"} atf_test_program{name="requirements_test"} diff --git a/contrib/kyua/engine/Makefile.am.inc b/contrib/kyua/engine/Makefile.am.inc deleted file mode 100644 index baa7fe0bb8a0..000000000000 --- a/contrib/kyua/engine/Makefile.am.inc +++ /dev/null @@ -1,155 +0,0 @@ -# Copyright 2010 The Kyua Authors. -# 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. - -ENGINE_CFLAGS = $(STORE_CFLAGS) $(MODEL_CFLAGS) $(UTILS_CFLAGS) -ENGINE_LIBS = libengine.a $(STORE_LIBS) $(MODEL_LIBS) $(UTILS_LIBS) - -noinst_LIBRARIES += libengine.a -libengine_a_CPPFLAGS = $(STORE_CFLAGS) $(UTILS_CFLAGS) -libengine_a_SOURCES = engine/atf.cpp -libengine_a_SOURCES += engine/atf.hpp -libengine_a_SOURCES += engine/atf_list.cpp -libengine_a_SOURCES += engine/atf_list.hpp -libengine_a_SOURCES += engine/atf_result.cpp -libengine_a_SOURCES += engine/atf_result.hpp -libengine_a_SOURCES += engine/atf_result_fwd.hpp -libengine_a_SOURCES += engine/config.cpp -libengine_a_SOURCES += engine/config.hpp -libengine_a_SOURCES += engine/config_fwd.hpp -libengine_a_SOURCES += engine/exceptions.cpp -libengine_a_SOURCES += engine/exceptions.hpp -libengine_a_SOURCES += engine/filters.cpp -libengine_a_SOURCES += engine/filters.hpp -libengine_a_SOURCES += engine/filters_fwd.hpp -libengine_a_SOURCES += engine/kyuafile.cpp -libengine_a_SOURCES += engine/kyuafile.hpp -libengine_a_SOURCES += engine/kyuafile_fwd.hpp -libengine_a_SOURCES += engine/plain.cpp -libengine_a_SOURCES += engine/plain.hpp -libengine_a_SOURCES += engine/requirements.cpp -libengine_a_SOURCES += engine/requirements.hpp -libengine_a_SOURCES += engine/scanner.cpp -libengine_a_SOURCES += engine/scanner.hpp -libengine_a_SOURCES += engine/scanner_fwd.hpp -libengine_a_SOURCES += engine/tap.cpp -libengine_a_SOURCES += engine/tap.hpp -libengine_a_SOURCES += engine/tap_parser.cpp -libengine_a_SOURCES += engine/tap_parser.hpp -libengine_a_SOURCES += engine/tap_parser_fwd.hpp -libengine_a_SOURCES += engine/scheduler.cpp -libengine_a_SOURCES += engine/scheduler.hpp -libengine_a_SOURCES += engine/scheduler_fwd.hpp - -if WITH_ATF -tests_enginedir = $(pkgtestsdir)/engine - -tests_engine_DATA = engine/Kyuafile -EXTRA_DIST += $(tests_engine_DATA) - -tests_engine_PROGRAMS = engine/atf_helpers -engine_atf_helpers_SOURCES = engine/atf_helpers.cpp -engine_atf_helpers_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -engine_atf_helpers_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_engine_PROGRAMS += engine/atf_test -engine_atf_test_SOURCES = engine/atf_test.cpp -engine_atf_test_CXXFLAGS = $(ENGINE_CFLAGS) $(ATF_CXX_CFLAGS) -engine_atf_test_LDADD = $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_engine_PROGRAMS += engine/atf_list_test -engine_atf_list_test_SOURCES = engine/atf_list_test.cpp -engine_atf_list_test_CXXFLAGS = $(ENGINE_CFLAGS) $(ATF_CXX_CFLAGS) -engine_atf_list_test_LDADD = $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_engine_PROGRAMS += engine/atf_result_test -engine_atf_result_test_SOURCES = engine/atf_result_test.cpp -engine_atf_result_test_CXXFLAGS = $(ENGINE_CFLAGS) $(ATF_CXX_CFLAGS) -engine_atf_result_test_LDADD = $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_engine_PROGRAMS += engine/config_test -engine_config_test_SOURCES = engine/config_test.cpp -engine_config_test_CXXFLAGS = $(ENGINE_CFLAGS) $(ATF_CXX_CFLAGS) -engine_config_test_LDADD = $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_engine_PROGRAMS += engine/exceptions_test -engine_exceptions_test_SOURCES = engine/exceptions_test.cpp -engine_exceptions_test_CXXFLAGS = $(ENGINE_CFLAGS) $(ATF_CXX_CFLAGS) -engine_exceptions_test_LDADD = $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_engine_PROGRAMS += engine/filters_test -engine_filters_test_SOURCES = engine/filters_test.cpp -engine_filters_test_CXXFLAGS = $(ENGINE_CFLAGS) $(ATF_CXX_CFLAGS) -engine_filters_test_LDADD = $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_engine_PROGRAMS += engine/kyuafile_test -engine_kyuafile_test_SOURCES = engine/kyuafile_test.cpp -engine_kyuafile_test_CXXFLAGS = $(ENGINE_CFLAGS) $(ATF_CXX_CFLAGS) -engine_kyuafile_test_LDADD = $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_engine_PROGRAMS += engine/plain_helpers -engine_plain_helpers_SOURCES = engine/plain_helpers.cpp -engine_plain_helpers_CXXFLAGS = $(UTILS_CFLAGS) -engine_plain_helpers_LDADD = $(UTILS_LIBS) - -tests_engine_PROGRAMS += engine/plain_test -engine_plain_test_SOURCES = engine/plain_test.cpp -engine_plain_test_CXXFLAGS = $(ENGINE_CFLAGS) $(ATF_CXX_CFLAGS) -engine_plain_test_LDADD = $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_engine_PROGRAMS += engine/requirements_test -engine_requirements_test_SOURCES = engine/requirements_test.cpp -engine_requirements_test_CXXFLAGS = $(ENGINE_CFLAGS) $(UTILS_TEST_CFLAGS) \ - $(ATF_CXX_CFLAGS) -engine_requirements_test_LDADD = $(ENGINE_LIBS) $(UTILS_TEST_LIBS) \ - $(ATF_CXX_LIBS) - -tests_engine_PROGRAMS += engine/scanner_test -engine_scanner_test_SOURCES = engine/scanner_test.cpp -engine_scanner_test_CXXFLAGS = $(ENGINE_CFLAGS) $(ATF_CXX_CFLAGS) -engine_scanner_test_LDADD = $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_engine_PROGRAMS += engine/tap_helpers -engine_tap_helpers_SOURCES = engine/tap_helpers.cpp -engine_tap_helpers_CXXFLAGS = $(UTILS_CFLAGS) -engine_tap_helpers_LDADD = $(UTILS_LIBS) - -tests_engine_PROGRAMS += engine/tap_test -engine_tap_test_SOURCES = engine/tap_test.cpp -engine_tap_test_CXXFLAGS = $(ENGINE_CFLAGS) $(ATF_CXX_CFLAGS) -engine_tap_test_LDADD = $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_engine_PROGRAMS += engine/tap_parser_test -engine_tap_parser_test_SOURCES = engine/tap_parser_test.cpp -engine_tap_parser_test_CXXFLAGS = $(ENGINE_CFLAGS) $(ATF_CXX_CFLAGS) -engine_tap_parser_test_LDADD = $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_engine_PROGRAMS += engine/scheduler_test -engine_scheduler_test_SOURCES = engine/scheduler_test.cpp -engine_scheduler_test_CXXFLAGS = $(ENGINE_CFLAGS) $(ATF_CXX_CFLAGS) -engine_scheduler_test_LDADD = $(ENGINE_LIBS) $(ATF_CXX_LIBS) -endif diff --git a/contrib/kyua/engine/atf.hpp b/contrib/kyua/engine/atf.hpp index 34ddc2413235..b9821e5fb7a7 100644 --- a/contrib/kyua/engine/atf.hpp +++ b/contrib/kyua/engine/atf.hpp @@ -40,23 +40,24 @@ namespace engine { /// Implementation of the scheduler interface for atf test programs. class atf_interface : public engine::scheduler::interface { public: - void exec_list(const model::test_program&, - const utils::config::properties_map&) const UTILS_NORETURN; + void exec_list [[noreturn]] ( + const model::test_program&, + const utils::config::properties_map&) const; model::test_cases_map parse_list( const utils::optional< utils::process::status >&, const utils::fs::path&, const utils::fs::path&) const; - void exec_test(const model::test_program&, const std::string&, - const utils::config::properties_map&, - const utils::fs::path&) const - UTILS_NORETURN; + void exec_test [[noreturn]] ( + const model::test_program&, const std::string&, + const utils::config::properties_map&, + const utils::fs::path&) const; - void exec_cleanup(const model::test_program&, const std::string&, - const utils::config::properties_map&, - const utils::fs::path&) const - UTILS_NORETURN; + void exec_cleanup [[noreturn]]( + const model::test_program&, const std::string&, + const utils::config::properties_map&, + const utils::fs::path&) const; model::test_result compute_result( const utils::optional< utils::process::status >&, diff --git a/contrib/kyua/engine/atf_result.cpp b/contrib/kyua/engine/atf_result.cpp index f99b28f9e96e..e8a20dafd558 100644 --- a/contrib/kyua/engine/atf_result.cpp +++ b/contrib/kyua/engine/atf_result.cpp @@ -625,13 +625,21 @@ engine::calculate_atf_result(const optional< process::status >& body_status, try { result = atf_result::load(results_file); } catch (const engine::format_error& error) { - result = atf_result(atf_result::broken, error.what()); + if (body_status) { + result = atf_result(atf_result::broken, + F("Error: %s. Test case %s") % + error.what() % + format_status(body_status.get())); + } else { + // The test case timed out. apply() handles this case later. + } } catch (const std::runtime_error& error) { - if (body_status) + if (body_status) { result = atf_result( - atf_result::broken, F("Premature exit; test case %s") % + atf_result::broken, + F("Error: Premature exit. Test case %s") % format_status(body_status.get())); - else { + } else { // The test case timed out. apply() handles this case later. } } diff --git a/contrib/kyua/engine/atf_result_test.cpp b/contrib/kyua/engine/atf_result_test.cpp index 8ec61dc3c07e..91938e02ebb2 100644 --- a/contrib/kyua/engine/atf_result_test.cpp +++ b/contrib/kyua/engine/atf_result_test.cpp @@ -664,7 +664,7 @@ ATF_TEST_CASE_BODY(calculate_atf_result__missing_file) const status body_status = status::fake_exited(EXIT_SUCCESS); const model::test_result expected( model::test_result_broken, - "Premature exit; test case exited with code 0"); + "Error: Premature exit. Test case exited with code 0"); ATF_REQUIRE_EQ(expected, engine::calculate_atf_result( utils::make_optional(body_status), fs::path("foo"))); } @@ -677,8 +677,9 @@ ATF_TEST_CASE_BODY(calculate_atf_result__bad_file) const status body_status = status::fake_exited(EXIT_SUCCESS); atf::utils::create_file("foo", "invalid\n"); - const model::test_result expected(model::test_result_broken, - "Unknown test result 'invalid'"); + const model::test_result expected( + model::test_result_broken, + "Error: Unknown test result 'invalid'. Test case exited with code 0"); ATF_REQUIRE_EQ(expected, engine::calculate_atf_result( utils::make_optional(body_status), fs::path("foo"))); } diff --git a/contrib/kyua/engine/atf_test.cpp b/contrib/kyua/engine/atf_test.cpp index 9fe7797f4362..5f9b8c59663e 100644 --- a/contrib/kyua/engine/atf_test.cpp +++ b/contrib/kyua/engine/atf_test.cpp @@ -310,7 +310,7 @@ ATF_TEST_CASE_BODY(test__body_only__crashes) const model::test_result exp_result( model::test_result_broken, - F("Premature exit; test case received signal %s (core dumped)") % + F("Error: Empty test result or no new line. Test case received signal %s (core dumped)") % SIGABRT); run_one(this, "crash", exp_result); } diff --git a/contrib/kyua/engine/config.cpp b/contrib/kyua/engine/config.cpp index d53e9936ba91..bf027ce88306 100644 --- a/contrib/kyua/engine/config.cpp +++ b/contrib/kyua/engine/config.cpp @@ -82,7 +82,7 @@ set_defaults(config::tree& tree) for (auto em : execenv::execenvs()) if (em->is_supported()) supported.insert(em->name()); - supported.insert(execenv::default_execenv_name); + supported.insert(DEFAULT_EXECENV_NAME); tree.set< config::strings_set_node >("execenvs", supported); // TODO(jmmv): Automatically derive this from the number of CPUs in the @@ -244,7 +244,7 @@ engine::empty_config(void) // Tests of Kyua itself tend to use an empty config, i.e. default // execution environment is used. Let's allow it. std::set< std::string > supported; - supported.insert(engine::execenv::default_execenv_name); + supported.insert(DEFAULT_EXECENV_NAME); tree.set< config::strings_set_node >("execenvs", supported); return tree; diff --git a/contrib/kyua/engine/execenv/execenv.cpp b/contrib/kyua/engine/execenv/execenv.cpp index b043bcda52cb..663e293a33a7 100644 --- a/contrib/kyua/engine/execenv/execenv.cpp +++ b/contrib/kyua/engine/execenv/execenv.cpp @@ -35,9 +35,6 @@ namespace execenv = engine::execenv; using utils::none; -const char* execenv::default_execenv_name = "host"; - - /// List of registered execution environments, except default host one. /// /// Use register_execenv() to add an entry to this global list. diff --git a/contrib/kyua/engine/execenv/execenv.hpp b/contrib/kyua/engine/execenv/execenv.hpp index e667ff205d85..d167196c7e98 100644 --- a/contrib/kyua/engine/execenv/execenv.hpp +++ b/contrib/kyua/engine/execenv/execenv.hpp @@ -32,6 +32,7 @@ #if !defined(ENGINE_EXECENV_EXECENV_HPP) #define ENGINE_EXECENV_EXECENV_HPP +#include "engine/execenv/execenv_fwd.hpp" #include "model/test_program.hpp" #include "utils/optional.ipp" #include "utils/process/operations_fwd.hpp" @@ -43,9 +44,6 @@ namespace engine { namespace execenv { -extern const char* default_execenv_name; - - /// Abstract interface of an execution environment. class interface { protected: @@ -85,7 +83,7 @@ public: /// scheduler::interface::exec_test() or exec_cleanup(). /// /// \param args The arguments to pass to the binary. - virtual void exec(const args_vector& args) const UTILS_NORETURN = 0; + virtual void exec [[noreturn]] (const args_vector& args) const = 0; }; diff --git a/contrib/kyua/engine/execenv/execenv_fwd.hpp b/contrib/kyua/engine/execenv/execenv_fwd.hpp new file mode 100644 index 000000000000..ddbb2c3bb40f --- /dev/null +++ b/contrib/kyua/engine/execenv/execenv_fwd.hpp @@ -0,0 +1,44 @@ +// Copyright 2024 The Kyua Authors. +// 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. + +/// \file engine/execenv/execenv_fwd.hpp +/// Forward declarations for engine/execenv/execenv.hpp + +#if !defined(ENGINE_EXECENV_EXECENV_FWD_HPP) +#define ENGINE_EXECENV_EXECENV_FWD_HPP + +#define DEFAULT_EXECENV_NAME "host" + +namespace engine { +namespace execenv { + + +} // namespace execenv +} // namespace engine + +#endif // !defined(ENGINE_EXECENV_EXECENV_FWD_HPP) diff --git a/contrib/kyua/engine/execenv/execenv_host.hpp b/contrib/kyua/engine/execenv/execenv_host.hpp index 2742366cfd6f..3276ad210574 100644 --- a/contrib/kyua/engine/execenv/execenv_host.hpp +++ b/contrib/kyua/engine/execenv/execenv_host.hpp @@ -53,7 +53,7 @@ public: void init() const; void cleanup() const; - void exec(const args_vector& args) const UTILS_NORETURN; + void exec [[noreturn]] (const args_vector& args) const; }; diff --git a/contrib/kyua/engine/googletest.cpp b/contrib/kyua/engine/googletest.cpp new file mode 100644 index 000000000000..e050410ba1f5 --- /dev/null +++ b/contrib/kyua/engine/googletest.cpp @@ -0,0 +1,219 @@ +// Copyright 2024 The Kyua Authors. +// 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. + +#include "engine/googletest.hpp" + +extern "C" { +#include <unistd.h> +} + +#include <cerrno> +#include <cstdlib> +#include <fstream> + +#include "engine/googletest_list.hpp" +#include "engine/googletest_result.hpp" +#include "engine/exceptions.hpp" +#include "model/test_case.hpp" +#include "model/test_program.hpp" +#include "model/test_result.hpp" +#include "utils/defs.hpp" +#include "utils/env.hpp" +#include "utils/format/macros.hpp" +#include "utils/fs/path.hpp" +#include "utils/logging/macros.hpp" +#include "utils/optional.ipp" +#include "utils/process/exceptions.hpp" +#include "utils/process/operations.hpp" +#include "utils/process/status.hpp" +#include "utils/stream.hpp" + +namespace config = utils::config; +namespace fs = utils::fs; +namespace process = utils::process; + +using utils::optional; + + +namespace { + + +/// Basename of the file containing the result written by the googletest +/// testcase. +/// +/// TODO: Use more structured output format someday, like the googletest's JSON +/// or XML format to avoid dealing with upstream formatting changes, as there's +/// no guarantee that the output format (which is more or less custom/freeform) +/// won't change in the future, making compatibility with all versions +/// potentially difficult to scrape for. +/// +/// Using either format will require pulling in a third party library and +/// understanding the schema of the format. As it stands in 1.9.0, +/// googletest doesn't document this expectation very well and instead seems +/// to rely on third-party solutions for doing structured output via the +/// listener interfaces. + + +/// Magic numbers returned by exec_list when exec(2) fails. +enum list_exit_code { + exit_eacces = 90, + exit_enoent, + exit_enoexec, +}; + + +} // anonymous namespace + + +/// Executes a test program's list operation. +/// +/// This method is intended to be called within a subprocess and is expected +/// to terminate execution either by exec(2)ing the test program or by +/// exiting with a failure. +/// +/// \param test_program The test program to execute. +void +engine::googletest_interface::exec_list( + const model::test_program& test_program, + const config::properties_map& /*vars*/) const +{ + const process::args_vector args{ + "--gtest_color=no", + "--gtest_list_tests", + }; + + try { + process::exec_unsafe(test_program.absolute_path(), args); + } catch (const process::system_error& e) { + if (e.original_errno() == EACCES) + ::_exit(exit_eacces); + else if (e.original_errno() == ENOENT) + ::_exit(exit_enoent); + else if (e.original_errno() == ENOEXEC) + ::_exit(exit_enoexec); + throw; + } +} + + +/// Computes the test cases list of a test program. +/// +/// \param status The termination status of the subprocess used to execute +/// the exec_test() method or none if the test timed out. +/// \param stdout_path Path to the file containing the stdout of the test. +/// +/// \return A list of test cases. +/// +/// \throw error If there is a problem parsing the test case list. +model::test_cases_map +engine::googletest_interface::parse_list( + const optional< process::status >& status, + const fs::path& stdout_path, + const fs::path& /* stderr_path */) const +{ + if (!status) + throw engine::error("Test case list timed out"); + if (status.get().exited()) { + const int exitstatus = status.get().exitstatus(); + if (exitstatus == EXIT_SUCCESS) { + // Nothing to do; fall through. + } else if (exitstatus == exit_eacces) { + throw engine::error("Permission denied to run test program"); + } else if (exitstatus == exit_enoent) { + throw engine::error("Cannot find test program"); + } else if (exitstatus == exit_enoexec) { + throw engine::error("Invalid test program format"); + } else { + throw engine::error("Test program did not exit cleanly; exited " + "with status: " + std::to_string(exitstatus)); + } + } else { + throw engine::error("Test program received signal"); + } + + std::ifstream input(stdout_path.c_str()); + if (!input) + throw engine::load_error(stdout_path, "Cannot open file for read"); + const model::test_cases_map test_cases = parse_googletest_list(input); + + return test_cases; +} + + +/// Executes a test case of the test program. +/// +/// This method is intended to be called within a subprocess and is expected +/// to terminate execution either by exec(2)ing the test program or by +/// exiting with a failure. +/// +/// \param test_program The test program to execute. +/// \param test_case_name Name of the test case to invoke. +/// \param vars User-provided variables to pass to the test program. +void +engine::googletest_interface::exec_test( + const model::test_program& test_program, + const std::string& test_case_name, + const config::properties_map& vars, + const fs::path& /* control_directory */) const +{ + for (config::properties_map::const_iterator iter = vars.begin(); + iter != vars.end(); ++iter) { + utils::setenv(F("TEST_ENV_%s") % (*iter).first, (*iter).second); + } + + process::args_vector args{ + "--gtest_color=no", + F("--gtest_filter=%s") % (test_case_name) + }; + process::exec(test_program.absolute_path(), args); + __builtin_unreachable(); +} + + +/// Computes the result of a test case based on its termination status. +/// +/// \param status The termination status of the subprocess used to execute +/// the exec_test() method or none if the test timed out. +/// \param stdout_path Path to the file containing the stdout of the +/// test. +/// +/// \return A test result. +model::test_result +engine::googletest_interface::compute_result( + const optional< process::status >& status, + const fs::path& /* control_directory */, + const fs::path& stdout_path, + const fs::path& /* stderr_path */) const +{ + if (!status) { + return model::test_result(model::test_result_broken, + "Test case body timed out"); + } + + return calculate_googletest_result(status, stdout_path); +} diff --git a/contrib/kyua/engine/googletest.hpp b/contrib/kyua/engine/googletest.hpp new file mode 100644 index 000000000000..9628f994a066 --- /dev/null +++ b/contrib/kyua/engine/googletest.hpp @@ -0,0 +1,68 @@ +// Copyright 2024 The Kyua Authors. +// 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. + +/// \file engine/googletest.hpp +/// Execution engine for test programs that implement the googletest interface. + +#if !defined(ENGINE_GOOGLETEST_HPP) +#define ENGINE_GOOGLETEST_HPP + +#include "engine/scheduler.hpp" + +namespace engine { + + +/// Implementation of the scheduler interface for googletest test programs. +class googletest_interface : public engine::scheduler::interface { +public: + void exec_list [[noreturn]] ( + const model::test_program&, + const utils::config::properties_map&) const; + + model::test_cases_map parse_list( + const utils::optional< utils::process::status >&, + const utils::fs::path&, + const utils::fs::path&) const; + + void exec_test [[noreturn]] ( + const model::test_program&, const std::string&, + const utils::config::properties_map&, + const utils::fs::path&) const; + + model::test_result compute_result( + const utils::optional< utils::process::status >&, + const utils::fs::path&, + const utils::fs::path&, + const utils::fs::path&) const; +}; + + +} // namespace engine + + +#endif // !defined(ENGINE_GOOGLETEST_HPP) diff --git a/contrib/kyua/engine/googletest_helpers.cpp b/contrib/kyua/engine/googletest_helpers.cpp new file mode 100644 index 000000000000..129a08a89b7c --- /dev/null +++ b/contrib/kyua/engine/googletest_helpers.cpp @@ -0,0 +1,330 @@ +// Copyright 2024 The Kyua Authors. +// 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. + +extern "C" { +#include <sys/stat.h> + +#include <getopt.h> +#include <signal.h> +#include <unistd.h> + +extern char** environ; +} + +#include <cstdlib> +#include <cstring> +#include <fstream> +#include <iostream> + +#include "utils/env.hpp" +#include "utils/cmdline/options.hpp" +#include "utils/cmdline/parser.ipp" +#include "utils/format/containers.ipp" +#include "utils/format/macros.hpp" +#include "utils/fs/path.hpp" +#include "utils/optional.ipp" +#include "utils/test_utils.ipp" + +namespace cmdline = utils::cmdline; +namespace fs = utils::fs; + +using cmdline::base_option; +using cmdline::bool_option; +using cmdline::parse; +using cmdline::parsed_cmdline; +using cmdline::string_option; + +namespace fs = utils::fs; + +namespace { + + +/// Prefix for all testcases. +const char *test_suite = "Suite."; + + +/// Logs an error message and exits the test with an error code. +/// +/// \param str The error message to log. +static void +fail(const std::string& str) +{ + std::cerr << str << '\n'; + std::exit(EXIT_FAILURE); +} + + +/// A test scenario that validates the TEST_ENV_* variables. +static void +test_check_configuration_variables(void) +{ + std::set< std::string > vars; + char** iter; + for (iter = environ; *iter != NULL; ++iter) { + if (std::strstr(*iter, "TEST_ENV_") == *iter) { + vars.insert(*iter); + } + } + + std::set< std::string > exp_vars{ + "TEST_ENV_first=some value", + "TEST_ENV_second=some other value" + }; + + if (vars == exp_vars) { + std::cout << +"Note: Google Test filter = Suite.check_configuration_variables\n" +"[==========] Running 1 test from 1 test case.\n" +"[----------] Global test environment set-up.\n" +"[----------] 1 test from Suite\n" +"[ RUN ] Suite.check_configuration_variables\n" +"[ OK ] Suite.check_configuration_variables (0 ms)\n" +"[----------] 1 test from PassFailTest (0 ms total)\n" +"\n" +"[----------] Global test environment tear-down\n" +"[==========] 1 test from 1 test case ran. (1 ms total)\n" +"[ PASSED ] 1 test.\n" + ; + } else { + std::cout << +"Note: Google Test filter = Suite.Fails\n" +"[==========] Running 1 test from 1 test case.\n" +"[----------] Global test environment set-up.\n" +"[----------] 1 test from PassFailTest\n" +"[ RUN ] Suite.check_configuration_variables\n" +"pass_fail_demo.cc:12: Failure\n" +"Expected equality of these values:\n" +" false\n" +" true\n" +"[ FAILED ] Suite.check_configuration_variables (0 ms)\n" +"[----------] 1 test from Suite (0 ms total)\n" +"\n" +"[----------] Global test environment tear-down\n" +"[==========] 1 test from 1 test case ran. (0 ms total)\n" +"[ PASSED ] 0 tests.\n" +"[ FAILED ] 1 test, listed below:\n" +"[ FAILED ] Suite.check_configuration_variables\n" +"\n" +" 1 FAILED TEST\n" + << F(" Expected: %s\nFound: %s\n") % exp_vars % vars; + std::exit(EXIT_FAILURE); + } +} + + +/// A test scenario that triggers a crash via abort in order to generate a +/// core dump. +static void +test_crash(void) +{ + std::abort(); +} + + +/// A test scenario that reports some tests as failed. +static void +test_fail(void) +{ + std::cout << ( +"Note: Google Test filter = Suite.fail\n" +"[==========] Running 1 test from 1 test suite.\n" +"[----------] Global test environment set-up.\n" +"[----------] 1 test from Suite\n" +"[ RUN ] Suite.fail\n" +"gtest_macros_demo.cc:4: Failure\n" +"Failed\n" +"with a reason\n" +"[ FAILED ] Suite.fail (0 ms)\n" +"[----------] 1 test from Suite (0 ms total)\n" +"\n" +"[----------] Global test environment tear-down\n" +"[==========] 1 test from 1 test suite ran. (0 ms total)\n" +"[ PASSED ] 0 tests.\n" +"[ FAILED ] 1 test, listed below:\n" +"[ FAILED ] Suite.fail\n" +"\n" +" 1 FAILED TEST\n" + ); + std::exit(EXIT_FAILURE); +} + + +/// A test scenario that passes. +static void +test_pass(void) +{ + std::cout << ( +"Note: Google Test filter = Suite.pass\n" +"[==========] Running 1 test from 1 test suite.\n" +"[----------] Global test environment set-up.\n" +"[----------] 1 test from Suite\n" +"[ RUN ] Suite.pass\n" +"[ OK ] Suite.pass (0 ms)\n" +"[----------] 1 test from Suite (0 ms total)\n" +"\n" +"[----------] Global test environment tear-down\n" +"[==========] 1 test from 1 test suite ran. (0 ms total)\n" +"[ PASSED ] 1 test.\n" + ); +} + + +/// A test scenario that passes but then exits with non-zero. +static void +test_pass_but_exit_failure(void) +{ + std::cout << ( +"Note: Google Test filter = Suite.pass_but_exit_failure\n" +"[==========] Running 1 test from 1 test suite.\n" +"[----------] Global test environment set-up.\n" +"[----------] 1 test from Suite\n" +"[ RUN ] Suite.pass_but_exit_failure\n" +"[ OK ] Suite.pass_but_exit_failure (0 ms)\n" +"[----------] 1 test from Suite (0 ms total)\n" +"\n" +"[----------] Global test environment tear-down\n" +"[==========] 1 test from 1 test suite ran. (0 ms total)\n" +"[ PASSED ] 1 test.\n" + ); + + std::exit(70); +} + + +/// A test scenario that times out. +/// +/// Note that the timeout is defined in the Kyuafile, as the TAP interface has +/// no means for test programs to specify this by themselves. +static void +test_timeout(void) +{ + std::cout << ( +"Note: Google Test filter = Suite.incomplete\n" +"[==========] Running 1 test from 1 test suite.\n" +"[----------] Global test environment set-up.\n" +"[----------] 1 test from Suite\n" +"[ RUN ] Suite.incomplete\n" + ); + + ::sleep(10); + const fs::path control_dir = fs::path(utils::getenv("CONTROL_DIR").get()); + std::ofstream file((control_dir / "cookie").c_str()); + if (!file) + fail("Failed to create the control cookie"); + file.close(); +} + + +/// Prints out program usage and exits with a non-zero exit code. +static void +usage(const char* argv0) { + std::cout << "usage: " << argv0 << " " + << "[--gtest_color=(auto|yes|no)] " + << "[--gtest_filter=POSITIVE_PATTERNS] " + << "[--gtest_list_tests]" + << "\n\n" + << "This program mocks a googletest test program." + << "\n"; + std::exit(EXIT_FAILURE); +} + + +} // anonymous namespace + + +/// Entry point to the test program. +/// +/// The caller can select which test scenario to run by modifying the program's +/// basename on disk (either by a copy or by a hard link). +/// +/// \todo It may be worth to split this binary into separate, smaller binaries, +/// one for every "test scenario". We use this program as a dispatcher for +/// different "main"s, the only reason being to keep the amount of helper test +/// programs to a minimum. However, putting this each function in its own +/// binary could simplify many other things. +/// +/// \param argc The number of CLI arguments. +/// \param argv The CLI arguments themselves. These are not used because +/// Kyua will not pass any arguments to the plain test program. +int +main(int argc, char** argv) +{ + using scenario_fn_t = void (*)(void); + + char *argv0 = argv[0]; + + std::map<std::string, scenario_fn_t> scenarios{ + { "check_configuration_variables", test_check_configuration_variables }, + { "crash", test_crash }, + { "fail", test_fail }, + { "pass", test_pass }, + { "pass_but_exit_failure", test_pass_but_exit_failure }, + { "timeout", test_timeout } + }; + + const bool_option gtest_list_tests_opt( + "gtest_list_tests", "List tests"); + const string_option gtest_color_opt( + "gtest_color", "Enable/disable color support", "auto"); + const string_option gtest_filter_opt( + "gtest_filter", "", "POSITIVE_PATTERNS"); + + std::vector<const base_option*> options; + /// Ignore `--gtest_color=*`. + options.push_back(>est_color_opt); + options.push_back(>est_filter_opt); + options.push_back(>est_list_tests_opt); + + const parsed_cmdline cmdline = parse(argc, argv, options); + INV(cmdline.arguments().empty()); + + if (cmdline.has_option("gtest_list_tests")) { + std::cout << test_suite << "\n"; + for (auto it = scenarios.begin(); it != scenarios.end(); it++) { + std::cout << " " << it->first << "\n"; + } + return EXIT_SUCCESS; + } + + INV(cmdline.has_option("gtest_filter")); + + auto gtest_filter_arg = cmdline.get_option<string_option>("gtest_filter"); + INV(gtest_filter_arg.find_first_of(test_suite) == 0); + auto testcase = gtest_filter_arg.erase(0, strlen(test_suite)); + + auto scenario = scenarios.find(testcase); + if (scenario == scenarios.end()) { + /// Mimic googletest test programs by printing out a usage message when + /// a test cannot be found. + usage(argv0); + } + + scenario->second(); + + return EXIT_SUCCESS; +} diff --git a/contrib/kyua/engine/googletest_list.cpp b/contrib/kyua/engine/googletest_list.cpp new file mode 100644 index 000000000000..f231cb9e7021 --- /dev/null +++ b/contrib/kyua/engine/googletest_list.cpp @@ -0,0 +1,111 @@ +// Copyright 2024 The Kyua Authors. +// 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. + +#include "engine/googletest_list.hpp" + +#include <fstream> +#include <regex> +#include <string> +#include <utility> + +#include "engine/exceptions.hpp" +#include "model/metadata.hpp" +#include "model/test_case.hpp" +#include "utils/config/exceptions.hpp" +#include "utils/format/macros.hpp" + +namespace config = utils::config; +namespace fs = utils::fs; + + +namespace { + +/// A regular expression that should match either a test suite or a test case. +const std::string name_expr = "([[:alpha:][:digit:]_]+[[:alpha:][:digit:]_/]*)"; + +/// The separator between a test suite and a test case. +const std::string testsuite_testcase_separator = "."; + +} // anonymous namespace + + +/// Parses the googletest list of test cases from an open stream. +/// +/// \param input The stream to read from. +/// +/// \return The collection of parsed test cases. +/// +/// \throw format_error If there is any problem in the input data. +model::test_cases_map +engine::parse_googletest_list(std::istream& input) +{ + std::string line, test_suite; + + // TODO: These were moved here from the anonymous namespace because of a + // Doxygen bug that's reproducible with the version used by Travis CI. + // + /// A complete regular expression representing a line with a test case + /// definition, e,g., " TestCase", " TestCase/0", or + /// " TestCase/0 # GetParam() = 4". + const std::regex testcase_re( + " " + name_expr + "([[:space:]]+# GetParam\\(\\) = .+)?"); + + /// A complete regular expression representing a line with a test suite + /// definition, e,g., * "TestSuite.", "TestSuite/Prefix.", or + /// "TestSuite/Prefix. # TypeParam = .+". + const std::regex testsuite_re( + name_expr + "\\.([[:space:]]+# TypeParam = .+)?"); + // END TODO + + model::test_cases_map_builder test_cases_builder; + while (std::getline(input, line).good()) { + std::smatch match; + if (std::regex_match(line, match, testcase_re)) { + if (test_suite.empty()) { + throw format_error("Invalid testcase definition: not preceded " + "by a test suite definition"); + } + std::string test_case(match[1]); + test_cases_builder.add(test_suite + test_case); + } else if (std::regex_match(line, match, testsuite_re)) { + test_suite = std::string(match[1]) + + testsuite_testcase_separator; + } else { + // Ignore the line; something might have used output a diagnostic + // message to stdout, e.g., gtest_main. + } + } + const model::test_cases_map test_cases = test_cases_builder.build(); + if (test_cases.empty()) { + // The scheduler interface also checks for the presence of at least one + // test case. However, because the atf format itself requires one test + // case to be always present, we check for this condition here as well. + throw format_error("No test cases"); + } + return test_cases; +} diff --git a/contrib/kyua/bootstrap/atf_helpers.cpp b/contrib/kyua/engine/googletest_list.hpp index 6a31b4ced994..2c9d9e0faf4a 100644 --- a/contrib/kyua/bootstrap/atf_helpers.cpp +++ b/contrib/kyua/engine/googletest_list.hpp @@ -1,4 +1,4 @@ -// Copyright 2010 The Kyua Authors. +// Copyright 2024 The Kyua Authors. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -26,46 +26,25 @@ // (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 <cstdlib> -#include <string> +/// \file engine/atf_list.hpp +/// Parser of googletest test case lists. -#include <atf-c++.hpp> +#if !defined(ENGINE_GOOGLETEST_LIST_HPP) +#define ENGINE_GOOGLETEST_LIST_HPP +#include <istream> -ATF_TEST_CASE_WITHOUT_HEAD(fails); -ATF_TEST_CASE_BODY(fails) -{ - fail("Failed on purpose"); -} +#include "model/metadata_fwd.hpp" +#include "model/test_case_fwd.hpp" +#include "model/types.hpp" +#include "utils/fs/path_fwd.hpp" +namespace engine { -ATF_TEST_CASE_WITHOUT_HEAD(passes); -ATF_TEST_CASE_BODY(passes) -{ -} +model::test_cases_map parse_googletest_list(std::istream&); -ATF_TEST_CASE_WITHOUT_HEAD(skips); -ATF_TEST_CASE_BODY(skips) -{ - skip("Skipped on purpose"); -} +} // namespace engine -ATF_INIT_TEST_CASES(tcs) -{ - std::string enabled; - - const char* tests = std::getenv("TESTS"); - if (tests == NULL) - enabled = "fails passes skips"; - else - enabled = tests; - - if (enabled.find("fails") != std::string::npos) - ATF_ADD_TEST_CASE(tcs, fails); - if (enabled.find("passes") != std::string::npos) - ATF_ADD_TEST_CASE(tcs, passes); - if (enabled.find("skips") != std::string::npos) - ATF_ADD_TEST_CASE(tcs, skips); -} +#endif // !defined(ENGINE_GOOGLETEST_LIST_HPP) diff --git a/contrib/kyua/engine/googletest_list_test.cpp b/contrib/kyua/engine/googletest_list_test.cpp new file mode 100644 index 000000000000..5052c2f133ad --- /dev/null +++ b/contrib/kyua/engine/googletest_list_test.cpp @@ -0,0 +1,208 @@ +// Copyright 2024 The Kyua Authors. +// 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. + +#include "engine/googletest_list.hpp" + +#include <sstream> +#include <string> + +#include <atf-c++.hpp> + +#include "engine/exceptions.hpp" +#include "model/metadata.hpp" +#include "model/test_case.hpp" +#include "model/types.hpp" +#include "utils/datetime.hpp" +#include "utils/format/containers.ipp" +#include "utils/fs/path.hpp" +#include "utils/units.hpp" + +namespace datetime = utils::datetime; +namespace fs = utils::fs; +namespace units = utils::units; + + +ATF_TEST_CASE_WITHOUT_HEAD(parse_googletest_list__invalid_testcase_definition); +ATF_TEST_CASE_BODY(parse_googletest_list__invalid_testcase_definition) +{ + std::istringstream input1(" \n"); + + ATF_REQUIRE_THROW_RE(engine::format_error, "No test cases", + engine::parse_googletest_list(input1)); + + std::istringstream input2(" TestcaseWithoutSuite\n"); + ATF_REQUIRE_THROW_RE(engine::format_error, + "Invalid testcase definition: not preceded by a test suite definition", + engine::parse_googletest_list(input2)); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(parse_googletest_list__invalid_testsuite_definition); +ATF_TEST_CASE_BODY(parse_googletest_list__invalid_testsuite_definition) +{ + std::istringstream input1("\n"); + ATF_REQUIRE_THROW_RE(engine::format_error, "No test cases", + engine::parse_googletest_list(input1)); + + std::istringstream input2( +"TestSuiteWithoutSeparator\n" + ); + ATF_REQUIRE_THROW_RE(engine::format_error, "No test cases", + engine::parse_googletest_list(input2)); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(parse_googletest_list__no_test_cases); +ATF_TEST_CASE_BODY(parse_googletest_list__no_test_cases) +{ + std::istringstream input(""); + ATF_REQUIRE_THROW_RE(engine::format_error, "No test cases", + engine::parse_googletest_list(input)); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(parse_googletest_list__one_test_case); +ATF_TEST_CASE_BODY(parse_googletest_list__one_test_case) +{ + std::istringstream input( +"TestSuite.\n" +" TestCase\n" + ); + const model::test_cases_map tests = engine::parse_googletest_list(input); + + const model::test_cases_map exp_tests = model::test_cases_map_builder() + .add("TestSuite.TestCase").build(); + ATF_REQUIRE_EQ(exp_tests, tests); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(parse_googletest_list__one_parameterized_test_case); +ATF_TEST_CASE_BODY(parse_googletest_list__one_parameterized_test_case) +{ + std::istringstream input( +"TestSuite.\n" +" TestCase/0 # GetParam() = 'c'\n" + ); + const model::test_cases_map tests = engine::parse_googletest_list(input); + + const model::test_cases_map exp_tests = model::test_cases_map_builder() + .add("TestSuite.TestCase/0").build(); + ATF_REQUIRE_EQ(exp_tests, tests); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(parse_googletest_list__one_parameterized_test_suite); +ATF_TEST_CASE_BODY(parse_googletest_list__one_parameterized_test_suite) +{ + std::string text = +"TestSuite/0. # TypeParam = int\n" +" TestCase\n" + ; + std::istringstream input(text); + const model::test_cases_map tests = engine::parse_googletest_list(input); + + const model::test_cases_map exp_tests = model::test_cases_map_builder() + .add("TestSuite/0.TestCase").build(); + ATF_REQUIRE_EQ(exp_tests, tests); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(parse_googletest_list__one_parameterized_test_case_and_test_suite); +ATF_TEST_CASE_BODY(parse_googletest_list__one_parameterized_test_case_and_test_suite) +{ + std::string text = +"TestSuite/0. # TypeParam = int\n" +" TestCase/0 # GetParam() = \"herp\"\n" +" TestCase/1 # GetParam() = \"derp\"\n" + ; + std::istringstream input(text); + const model::test_cases_map tests = engine::parse_googletest_list(input); + + const model::test_cases_map exp_tests = model::test_cases_map_builder() + .add("TestSuite/0.TestCase/0") + .add("TestSuite/0.TestCase/1") + .build(); + ATF_REQUIRE_EQ(exp_tests, tests); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(parse_googletest_list__many_test_cases); +ATF_TEST_CASE_BODY(parse_googletest_list__many_test_cases) +{ + std::string text = +"FirstTestSuite.\n" +" ATestCase\n" +"SecondTestSuite.\n" +" AnotherTestCase\n" +"ThirdTestSuite.\n" +" _\n" +"FourthTestSuite/0. # TypeParam = std::list<int>\n" +" TestCase\n" +"FourthTestSuite/1. # TypeParam = std::list<int>\n" +" TestCase\n" +"FifthTestSuite.\n" +" TestCase/0 # GetParam() = 0\n" +" TestCase/1 # GetParam() = (1, 2, 3)\n" +" TestCase/2 # GetParam() = \"developers. developers\"\n" +"SixthTestSuite/0. # TypeParam = std::map<std::basic_string, int>\n" +" TestCase/0 # GetParam() = 0\n" +" TestCase/1 # GetParam() = (1, 2, 3)\n" + ; + std::istringstream input(text); + const model::test_cases_map tests = engine::parse_googletest_list(input); + + const model::test_cases_map exp_tests = model::test_cases_map_builder() + .add("FirstTestSuite.ATestCase", model::metadata_builder() + .build()) + .add("SecondTestSuite.AnotherTestCase", model::metadata_builder() + .build()) + .add("ThirdTestSuite._") + .add("FourthTestSuite/0.TestCase") + .add("FourthTestSuite/1.TestCase") + .add("FifthTestSuite.TestCase/0") + .add("FifthTestSuite.TestCase/1") + .add("FifthTestSuite.TestCase/2") + .add("SixthTestSuite/0.TestCase/0") + .add("SixthTestSuite/0.TestCase/1") + .build(); + ATF_REQUIRE_EQ(exp_tests, tests); +} + + +ATF_INIT_TEST_CASES(tcs) +{ + ATF_ADD_TEST_CASE(tcs, parse_googletest_list__invalid_testcase_definition); + ATF_ADD_TEST_CASE(tcs, parse_googletest_list__invalid_testsuite_definition); + ATF_ADD_TEST_CASE(tcs, parse_googletest_list__no_test_cases); + ATF_ADD_TEST_CASE(tcs, parse_googletest_list__one_test_case); + ATF_ADD_TEST_CASE(tcs, parse_googletest_list__one_parameterized_test_case); + ATF_ADD_TEST_CASE(tcs, parse_googletest_list__one_parameterized_test_suite); + ATF_ADD_TEST_CASE(tcs, + parse_googletest_list__one_parameterized_test_case_and_test_suite); + ATF_ADD_TEST_CASE(tcs, parse_googletest_list__many_test_cases); +} diff --git a/contrib/kyua/engine/googletest_result.cpp b/contrib/kyua/engine/googletest_result.cpp new file mode 100644 index 000000000000..a1fc1f72da4d --- /dev/null +++ b/contrib/kyua/engine/googletest_result.cpp @@ -0,0 +1,528 @@ +// Copyright 2024 The Kyua Authors. +// 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. + +#include "engine/googletest_result.hpp" + +#include <cstdlib> +#include <fstream> +#include <regex> +#include <utility> + +#include "engine/exceptions.hpp" +#include "model/test_result.hpp" +#include "utils/fs/path.hpp" +#include "utils/format/macros.hpp" +#include "utils/optional.ipp" +#include "utils/process/status.hpp" +#include "utils/sanity.hpp" +#include "utils/text/exceptions.hpp" +#include "utils/text/operations.ipp" + +namespace fs = utils::fs; +namespace process = utils::process; +namespace text = utils::text; + +using utils::none; +using utils::optional; + + +namespace { + +/// Internal string for specifying invalid output. +const std::string invalid_output_message = "invalid output"; + +/// Regular expression for disabled tests line. +const std::regex disabled_re( + R"RE((YOU HAVE [[:digit:]]+ DISABLED TESTS?))RE" +); + +/// Regular expression for starting sentinel of results block. +const std::regex starting_sentinel_re( + R"(\[[[:space:]]+RUN[[:space:]]+\][[:space:]]+[A-Za-z0-9]+\.[A-Za-z0-9]+)" +); + +/// Regular expression for ending sentinel of results block. +const std::regex ending_sentinel_re( + R"RE(\[[[:space:]]+(FAILED|OK|SKIPPED)[[:space:]]+\])RE" +); + +/// Parses a test result that does not accept a reason. +/// +/// \param status The result status name. +/// \param rest The rest of the line after the status name. +/// +/// \return An object representing the test result. +/// +/// \throw format_error If the result is invalid (i.e. rest is invalid). +/// +/// \pre status must be "successful". +static engine::googletest_result +parse_without_reason(const std::string& status, const std::string& rest) +{ + if (!rest.empty()) + throw engine::format_error(F("%s cannot have a reason") % status); + + if (status == "skipped") + return engine::googletest_result(engine::googletest_result::skipped); + else { + INV(status == "successful"); + return engine::googletest_result(engine::googletest_result::successful); + } +} + + +/// Parses a test result that needs a reason. +/// +/// \param status The result status name. +/// \param rest The rest of the line after the status name. +/// +/// \return An object representing the test result. +/// +/// \throw format_error If the result is invalid (i.e. rest is invalid). +/// +/// \pre status must be one of "broken", "disabled", "failed", or "skipped". +static engine::googletest_result +parse_with_reason(const std::string& status, const std::string& rest) +{ + using engine::googletest_result; + + INV(!rest.empty()); + + if (status == "broken") + return googletest_result(googletest_result::broken, rest); + else if (status == "disabled") + return googletest_result(googletest_result::disabled, rest); + else if (status == "failed") + return googletest_result(googletest_result::failed, rest); + else if (status == "skipped") + return googletest_result(googletest_result::skipped, rest); + else + PRE_MSG(false, "Unexpected status"); +} + + +/// Formats the termination status of a process to be used with validate_result. +/// +/// \param status The status to format. +/// +/// \return A string describing the status. +static std::string +format_status(const process::status& status) +{ + if (status.exited()) + return F("exited with code %s") % status.exitstatus(); + else if (status.signaled()) + return F("received signal %s%s") % status.termsig() % + (status.coredump() ? " (core dumped)" : ""); + else + return F("terminated in an unknown manner"); +} + + +} // anonymous namespace + + +/// Constructs a raw result with a type. +/// +/// The reason is left uninitialized. +/// +/// \param type_ The type of the result. +engine::googletest_result::googletest_result(const types type_) : + _type(type_) +{ +} + + +/// Constructs a raw result with a type and a reason. +/// +/// \param type_ The type of the result. +/// \param reason_ The reason for the result. +engine::googletest_result::googletest_result( + const types type_, + const std::string& reason_) : + _type(type_), _reason(reason_) +{ +} + + +/// Parses an input stream to extract a test result. +/// +/// If the parsing fails for any reason, the test result is 'broken' and it +/// contains the reason for the parsing failure. Test cases that report results +/// in an inconsistent state cannot be trusted (e.g. the test program code may +/// have a bug), and thus why they are reported as broken instead of just failed +/// (which is a legitimate result for a test case). +/// +/// \param input The stream to read from. +/// +/// \return A generic representation of the result of the test case. +/// +/// \throw format_error If the input is invalid. +engine::googletest_result +engine::googletest_result::parse(std::istream& input) +{ + std::vector<std::string> lines; + + do { + std::string line; + std::getline(input, line, '\n'); + if (!input.eof()) + line.push_back('\n'); + lines.push_back(line); + } while (input.good()); + + bool capture_context = false; + bool valid_output = false; + std::string context, status; + + for (auto& line: lines) { + std::smatch matches; + + if (regex_search(line, matches, disabled_re)) { + context = matches[1]; + status = "disabled"; + valid_output = true; + break; + } + if (regex_search(line, matches, starting_sentinel_re)) { + capture_context = true; + context = ""; + continue; + } + if (regex_search(line, matches, ending_sentinel_re)) { + std::string googletest_res = matches[1]; + if (googletest_res == "OK") { + context = ""; + status = "successful"; + } else if (googletest_res == "FAILED") { + status = "failed"; + } else { + INV(googletest_res == "SKIPPED"); + status = "skipped"; + } + capture_context = false; + valid_output = true; + } + if (capture_context) { + context += line; + } + } + if (!valid_output) { + context = invalid_output_message; + status = "broken"; + } + if (status == "skipped" && context.empty()) + context = bogus_googletest_skipped_nul_message; + if (context.empty()) + return parse_without_reason(status, context); + else + return parse_with_reason(status, context); +} + + +/// Loads a test case result from a file. +/// +/// \param file The file to parse. +/// +/// \return The parsed test case result if all goes well. +/// +/// \throw std::runtime_error If the file does not exist. +/// \throw engine::format_error If the contents of the file are bogus. +engine::googletest_result +engine::googletest_result::load(const fs::path& file) +{ + std::ifstream input(file.c_str()); + if (!input) + throw std::runtime_error("Cannot open results file"); + else + return parse(input); +} + + +/// Gets the type of the result. +/// +/// \return A result type. +engine::googletest_result::types +engine::googletest_result::type(void) const +{ + return _type; +} + + +/// Gets the optional reason of the result. +/// +/// \return The reason of the result if present; none otherwise. +const optional< std::string >& +engine::googletest_result::reason(void) const +{ + return _reason; +} + + +/// Checks whether the result should be reported as good or not. +/// +/// \return True if the result can be considered "good", false otherwise. +bool +engine::googletest_result::good(void) const +{ + switch (_type) { + case googletest_result::disabled: + case googletest_result::skipped: + case googletest_result::successful: + return true; + + case googletest_result::broken: + case googletest_result::failed: + return false; + + default: + UNREACHABLE; + } +} + + +/// Reinterprets a raw result based on the termination status of the test case. +/// +/// This reinterpretation ensures that the termination conditions of the program +/// match what is expected of the paticular result reported by the test program. +/// If such conditions do not match, the test program is considered bogus and is +/// thus reported as broken. +/// +/// This is just a helper function for calculate_result(); the real result of +/// the test case cannot be inferred from apply() only. +/// +/// \param status The exit status of the test program, or none if the test +/// program timed out. +/// +/// \result The adjusted result. The original result is transformed into broken +/// if the exit status of the program does not match our expectations. +engine::googletest_result +engine::googletest_result::apply(const optional< process::status >& status) + const +{ + if (!status) { + return *this; + } + + auto check_status = [&status](bool expect_pass) -> bool { + if (!status.get().exited()) { + return false; + } + auto exit_status = status.get().exitstatus(); + if (expect_pass) { + return exit_status == EXIT_SUCCESS; + } else { + return exit_status == EXIT_FAILURE; + } + }; + + switch (_type) { + case googletest_result::broken: + return *this; + + case googletest_result::disabled: + if (check_status(true)) { + return *this; + } + return googletest_result(googletest_result::broken, + "Disabled test case should have reported success but " + + format_status(status.get())); + + case googletest_result::failed: + if (check_status(false)) { + return *this; + } + return googletest_result(googletest_result::broken, + "Failed test case should have reported failure but " + + format_status(status.get())); + + case googletest_result::skipped: + if (check_status(true)) { + return *this; + } + return googletest_result(googletest_result::broken, + "Skipped test case should have reported success but " + + format_status(status.get())); + + case googletest_result::successful: + if (check_status(true)) { + return *this; + } + return googletest_result(googletest_result::broken, + "Passed test case should have reported success but " + + format_status(status.get())); + } + + UNREACHABLE; +} + + +/// Converts an internal result to the interface-agnostic representation. +/// +/// \return A generic result instance representing this result. +model::test_result +engine::googletest_result::externalize(void) const +{ + switch (_type) { + case googletest_result::broken: + return model::test_result(model::test_result_broken, _reason.get()); + + case googletest_result::disabled: + return model::test_result(model::test_result_skipped, _reason.get()); + + case googletest_result::failed: + return model::test_result(model::test_result_failed, _reason.get()); + + case googletest_result::skipped: + return model::test_result(model::test_result_skipped, _reason.get()); + + case googletest_result::successful: + return model::test_result(model::test_result_passed); + + default: + UNREACHABLE; + } +} + + +/// Compares two raw results for equality. +/// +/// \param other The result to compare to. +/// +/// \return True if the two raw results are equal; false otherwise. +bool +engine::googletest_result::operator==(const googletest_result& other) const +{ + return _type == other._type && + _reason == other._reason; +} + + +/// Compares two raw results for inequality. +/// +/// \param other The result to compare to. +/// +/// \return True if the two raw results are different; false otherwise. +bool +engine::googletest_result::operator!=(const googletest_result& other) const +{ + return !(*this == other); +} + + +/// Injects the object into a stream. +/// +/// \param output The stream into which to inject the object. +/// \param object The object to format. +/// +/// \return The output stream. +std::ostream& +engine::operator<<(std::ostream& output, const googletest_result& object) +{ + std::string result_name; + switch (object.type()) { + case googletest_result::broken: result_name = "broken"; break; + case googletest_result::disabled: result_name = "disabled"; break; + case googletest_result::failed: result_name = "failed"; break; + case googletest_result::skipped: result_name = "skipped"; break; + case googletest_result::successful: result_name = "successful"; break; + } + + const optional< std::string >& reason = object.reason(); + + output << F("model::test_result{type=%s, reason=%s}") + % text::quote(result_name, '\'') + % (reason ? text::quote(reason.get(), '\'') : "none"); + + return output; +} + + +/// Calculates the user-visible result of a test case. +/// +/// This function needs to perform magic to ensure that what the test case +/// reports as its result is what the user should really see: i.e. it adjusts +/// the reported status of the test to the exit conditions of its body and +/// cleanup parts. +/// +/// \param body_status The termination status of the process that executed +/// the body of the test. None if the body timed out. +/// \param results_file The path to the results file that the test case body is +/// supposed to have created. +/// +/// \return The calculated test case result. +model::test_result +engine::calculate_googletest_result( + const optional< process::status >& body_status, + const fs::path& results_file) +{ + using engine::googletest_result; + + googletest_result result(googletest_result::broken, "Unknown result"); + try { + result = googletest_result::load(results_file); + /// atf_result.cpp handles this by side-effect by setting a broken + /// result with "", which results in a std::runtime_error throw from + /// atf_result::parse(..). googletest_result::parse doesn't do that and + /// instead returns a broken result with a reason of + /// `invalid_output_message`, so that case needs to be tested for after + /// the fact to make sure the reason why `invalid_output_message` was + /// because of a program that crashed or failed. + if (result.type() == googletest_result::broken && body_status) { + const optional< std::string >& reason = result.reason(); + if (reason && reason.get() == invalid_output_message) { + result = googletest_result( + googletest_result::broken, + F("Error: Premature exit. Test case %s") % + format_status(body_status.get())); + } + } + } catch (const engine::format_error& error) { + if (body_status) + result = googletest_result(googletest_result::broken, + F("Error: %s. Test case %s") % + error.what() % + format_status(body_status.get())); + else { + // The test case timed out. apply() handles this case later. + } + } catch (const std::runtime_error& error) { + if (body_status) + result = googletest_result( + googletest_result::broken, + F("Error: Premature exit. Test case %s") % + format_status(body_status.get())); + else { + // The test case timed out. apply() handles this case later. + } + } + + result = result.apply(body_status); + + return result.externalize(); +} diff --git a/contrib/kyua/engine/googletest_result.hpp b/contrib/kyua/engine/googletest_result.hpp new file mode 100644 index 000000000000..325995be3221 --- /dev/null +++ b/contrib/kyua/engine/googletest_result.hpp @@ -0,0 +1,111 @@ +// Copyright 2024 The Kyua Authors. +// 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. + +/// \file engine/googletest_result.hpp +/// Functions and types to process the results of googletest-based test cases. + +#if !defined(ENGINE_GOOGLETEST_RESULT_HPP) +#define ENGINE_GOOGLETEST_RESULT_HPP + +#include "engine/googletest_result_fwd.hpp" + +#include <istream> +#include <ostream> + +#include "model/test_result_fwd.hpp" +#include "utils/optional.hpp" +#include "utils/fs/path_fwd.hpp" +#include "utils/process/status_fwd.hpp" + +namespace engine { + + +/// Internal representation of the raw result files of googletest-based tests. +/// +/// This class is used exclusively to represent the transient result files read +/// from test cases before generating the "public" version of the result. This +/// class should actually not be exposed in the header files, but it is for +/// testing purposes only. +class googletest_result { +public: + /// List of possible types for the test case result. + enum types { + broken, + disabled, + failed, + skipped, + successful, + }; + +private: + /// The test case result. + types _type; + + /// A description of the test case result. + /// + /// Should always be present except for the passed type and sometimes with + /// the skipped type. + utils::optional< std::string > _reason; + +public: + googletest_result(const types); + googletest_result(const types, const std::string&); + + static googletest_result parse(std::istream&); + static googletest_result load(const utils::fs::path&); + + types type(void) const; + const utils::optional< std::string >& reason(void) const; + + bool good(void) const; + googletest_result apply( + const utils::optional< utils::process::status >&) const; + model::test_result externalize(void) const; + + bool operator==(const googletest_result&) const; + bool operator!=(const googletest_result&) const; +}; + + +std::ostream& operator<<(std::ostream&, const googletest_result&); + + +model::test_result calculate_googletest_result( + const utils::optional< utils::process::status >&, + const utils::fs::path&); + + +/// A bogus identifier for nul reasons provided by the test writer. +/// +/// TODO: Support nul messages with skipped results in the schema, etc. +const std::string bogus_googletest_skipped_nul_message = "\n"; + + +} // namespace engine + +#endif // !defined(ENGINE_GOOGLETEST_RESULT_HPP) diff --git a/contrib/kyua/engine/googletest_result_fwd.hpp b/contrib/kyua/engine/googletest_result_fwd.hpp new file mode 100644 index 000000000000..6f41c75a0b3f --- /dev/null +++ b/contrib/kyua/engine/googletest_result_fwd.hpp @@ -0,0 +1,43 @@ +// Copyright 2024 The Kyua Authors. +// 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. + +/// \file engine/googletest_result_fwd.hpp +/// Forward declarations for engine/googletest_result.hpp + +#if !defined(ENGINE_GOOGLETEST_RESULT_FWD_HPP) +#define ENGINE_GOOGLETEST_RESULT_FWD_HPP + +namespace engine { + + +class googletest_result; + + +} // namespace engine + +#endif // !defined(ENGINE_GOOGLETEST_RESULT_FWD_HPP) diff --git a/contrib/kyua/engine/googletest_result_test.cpp b/contrib/kyua/engine/googletest_result_test.cpp new file mode 100644 index 000000000000..90bc2cc62b7d --- /dev/null +++ b/contrib/kyua/engine/googletest_result_test.cpp @@ -0,0 +1,427 @@ +// Copyright 2024 The Kyua Authors. +// 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. + +#include "engine/googletest_result.hpp" + +extern "C" { +#include <signal.h> +} + +#include <cstdlib> +#include <fstream> +#include <sstream> +#include <stdexcept> + +#include <atf-c++.hpp> + +#include "engine/exceptions.hpp" +#include "model/test_result.hpp" +#include "utils/format/macros.hpp" +#include "utils/fs/path.hpp" +#include "utils/process/status.hpp" + +namespace fs = utils::fs; +namespace process = utils::process; + +using utils::none; +using utils::optional; + + +namespace { + + +/// Performs a test for results::parse() that should succeed. +/// +/// \param exp_type The expected type of the result. +/// \param exp_reason The expected reason describing the result, if any. +/// \param text The literal input to parse; can include multiple lines. +static void +parse_ok_test(const engine::googletest_result::types& exp_type, + const char* exp_reason, const char* text) +{ + std::istringstream input(text); + const engine::googletest_result actual = + engine::googletest_result::parse(input); + ATF_REQUIRE_EQ(exp_type, actual.type()); + if (exp_reason != NULL) { + ATF_REQUIRE(actual.reason()); + ATF_REQUIRE_EQ(exp_reason, actual.reason().get()); + } else { + ATF_REQUIRE(!actual.reason()); + } +} + + +/// Wrapper around parse_ok_test to define a test case. +/// +/// \param name The name of the test case; will be prefixed with +/// "googletest_result__parse__". +/// \param exp_type The expected type of the result. +/// \param exp_reason The expected reason describing the result, if any. +/// \param input The literal input to parse. +#define PARSE(name, exp_type, exp_reason, input) \ + ATF_TEST_CASE_WITHOUT_HEAD(googletest_result__parse__ ## name); \ + ATF_TEST_CASE_BODY(googletest_result__parse__ ## name) \ + { \ + parse_ok_test(exp_type, exp_reason, input); \ + } + + +} // anonymous namespace + + +PARSE(broken, + engine::googletest_result::broken, "invalid output", + "invalid input"); + +const char disabled_context[] = ( +"YOU HAVE 1 DISABLED TEST" +); + +const char disabled_message[] = ( +"[==========] Running 0 tests from 0 test cases.\n" +"[==========] 0 tests from 0 test cases ran. (0 ms total)\n" +"[ PASSED ] 0 tests.\n" +"\n" +" YOU HAVE 1 DISABLED TEST\n" +"\n" +"\n" +); + +PARSE(disabled, + engine::googletest_result::disabled, disabled_context, + disabled_message); + +const char failed_context[] = ( +"pass_fail_demo.cc:8: Failure\n" +"Expected equality of these values:\n" +" false\n" +" true\n" +); + +const char failed_message[] = ( +"Note: Google Test filter = PassFailTest.Fails\n" +"[==========] Running 1 test from 1 test case.\n" +"[----------] Global test environment set-up.\n" +"[----------] 1 test from PassFailTest\n" +"[ RUN ] PassFailTest.Fails\n" +"pass_fail_demo.cc:8: Failure\n" +"Expected equality of these values:\n" +" false\n" +" true\n" +"[ FAILED ] PassFailTest.Fails (0 ms)\n" +"[----------] 1 test from PassFailTest (0 ms total)\n" +"\n" +"[----------] Global test environment tear-down\n" +"[==========] 1 test from 1 test case ran. (0 ms total)\n" +"[ PASSED ] 0 tests.\n" +"[ FAILED ] 1 test, listed below:\n" +"[ FAILED ] PassFailTest.Fails\n" +"\n" +" 1 FAILED TEST\n" +); + +PARSE(failed, + engine::googletest_result::failed, failed_context, + failed_message); + +const char skipped_message[] = ( +"Note: Google Test filter = SkipTest.DoesSkip\n" +"[==========] Running 1 test from 1 test suite.\n" +"[----------] Global test environment set-up.\n" +"[----------] 1 test from SkipTest\n" +"[ RUN ] SkipTest.DoesSkip\n" +"[ SKIPPED ] SkipTest.DoesSkip (0 ms)\n" +"[----------] 1 test from SkipTest (0 ms total)\n" +"\n" +"[----------] Global test environment tear-down\n" +"[==========] 1 test from 1 test suite ran. (0 ms total)\n" +"[ PASSED ] 0 tests.\n" +"[ SKIPPED ] 1 test, listed below:\n" +"[ SKIPPED ] SkipTest.DoesSkip\n" +); + +PARSE(skipped, + engine::googletest_result::skipped, + engine::bogus_googletest_skipped_nul_message.c_str(), + skipped_message +); + +const char skipped_with_reason_context[] = ( +"This is a reason\n" +); + +const char skipped_with_reason_message[] = ( +"Note: Google Test filter = SkipTest.SkipWithReason\n" +"[==========] Running 1 test from 1 test suite.\n" +"[----------] Global test environment set-up.\n" +"[----------] 1 test from SkipTest\n" +"[ RUN ] SkipTest.SkipWithReason\n" +"This is a reason\n" +"[ SKIPPED ] SkipTest.SkipWithReason (0 ms)\n" +"[----------] 1 test from SkipTest (0 ms total)\n" +"\n" +"[----------] Global test environment tear-down\n" +"[==========] 1 test from 1 test suite ran. (0 ms total)\n" +"[ PASSED ] 0 tests.\n" +"[ SKIPPED ] 1 test, listed below:\n" +"[ SKIPPED ] SkipTest.SkipWithReason\n" +); + +PARSE(skipped_with_reason, + engine::googletest_result::skipped, skipped_with_reason_context, + skipped_with_reason_message); + +const char successful_message[] = ( +"Note: Google Test filter = PassFailTest.Passes\n" +"[==========] Running 1 test from 1 test case.\n" +"[----------] Global test environment set-up.\n" +"[----------] 1 test from PassFailTest\n" +"[ RUN ] PassFailTest.Passes\n" +"[ OK ] PassFailTest.Passes (0 ms)\n" +"[----------] 1 test from PassFailTest (0 ms total)\n" +"\n" +"[----------] Global test environment tear-down\n" +"[==========] 1 test from 1 test case ran. (0 ms total)\n" +"[ PASSED ] 1 test.\n" +); + +PARSE(successful, + engine::googletest_result::successful, NULL, + successful_message); + +const char successful_message2[] = ( +"Note: Google Test filter = ValuesTest.ValuesWorks\n" +"[==========] Running 1 test from 1 test case.\n" +"[----------] Global test environment set-up.\n" +"[----------] 1 test from ValuesTest\n" +"[ RUN ] ValuesTest.ValuesWorks\n" +"[ OK ] ValuesTest.ValuesWorks (0 ms)\n" +"[----------] 1 test from ValuesTest (0 ms total)\n" +" \n" +"[----------] Global test environment tear-down\n" +"[==========] 1 test from 1 test case ran. (0 ms total)\n" +"[ PASSED ] 1 test.\n" +); + +PARSE(successful2, + engine::googletest_result::successful, NULL, + successful_message2); + +const char successful_parameterized_message[] = ( +"Note: Google Test filter = RangeZeroToFive/ParamDerivedTest/0\n" +"[==========] Running 5 tests from 1 test case.\n" +"[----------] Global test environment set-up.\n" +"[----------] 5 tests from RangeZeroToFive/ParamDerivedTest\n" +"[ RUN ] RangeZeroToFive/ParamDerivedTest.SeesSequence/0\n" +"[ OK ] RangeZeroToFive/ParamDerivedTest.SeesSequence/0 (0 ms)\n" +"[----------] 1 test from RangeZeroToFive/ParamDerivedTest/0 (0 ms total)\n" +"\n" +"[----------] Global test environment tear-down\n" +"[==========] 1 tests from 1 test case ran. (0 ms total)\n" +"[ PASSED ] 1 tests.\n" +); + +PARSE(successful_parameterized, + engine::googletest_result::successful, NULL, + successful_parameterized_message); + +const char successful_message_with_reason[] = ( +"Note: Google Test filter = PassFailTest.PassesWithReason\n" +"[==========] Running 1 test from 1 test suite.\n" +"[----------] Global test environment set-up.\n" +"[----------] 1 test from PassFailTest\n" +"[ RUN ] PassFailTest.PassesWithReason\n" +"This is a reason\n" +"[ OK ] PassFailTest.PassesWithReason (0 ms)\n" +"[----------] 1 test from PassFailTest (0 ms total)\n" +"\n" +"[----------] Global test environment tear-down\n" +"[==========] 1 test from 1 test suite ran. (0 ms total)\n" +"[ PASSED ] 1 tests.\n" +); + +PARSE(successful_with_reason, + engine::googletest_result::successful, NULL, + successful_message_with_reason); + +ATF_TEST_CASE_WITHOUT_HEAD(googletest_result__load__ok); +ATF_TEST_CASE_BODY(googletest_result__load__ok) +{ + std::ofstream output("result.txt"); + ATF_REQUIRE(output); + output << skipped_with_reason_message; + output.close(); + + const engine::googletest_result result = engine::googletest_result::load( + utils::fs::path("result.txt")); + ATF_REQUIRE_EQ(engine::googletest_result::skipped, result.type()); + ATF_REQUIRE(result.reason()); + ATF_REQUIRE_EQ(skipped_with_reason_context, result.reason().get()); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(googletest_result__load__missing_file); +ATF_TEST_CASE_BODY(googletest_result__load__missing_file) +{ + ATF_REQUIRE_THROW_RE( + std::runtime_error, "Cannot open", + engine::googletest_result::load(utils::fs::path("result.txt"))); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(googletest_result__apply__broken); +ATF_TEST_CASE_BODY(googletest_result__apply__broken) +{ + const process::status status = process::status::fake_exited(EXIT_FAILURE); + const engine::googletest_result broken(engine::googletest_result::broken, + "The reason"); + ATF_REQUIRE_EQ(broken, broken.apply(utils::make_optional(status))); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(googletest_result__apply__disabled); +ATF_TEST_CASE_BODY(googletest_result__apply__disabled) +{ + const process::status status = process::status::fake_exited(EXIT_SUCCESS); + const engine::googletest_result disabled( + engine::googletest_result::disabled, "The reason"); + ATF_REQUIRE_EQ(disabled, disabled.apply(utils::make_optional(status))); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(googletest_result__apply__failed); +ATF_TEST_CASE_BODY(googletest_result__apply__failed) +{ + const process::status status = process::status::fake_exited(EXIT_FAILURE); + const engine::googletest_result failed(engine::googletest_result::failed, + "The reason"); + ATF_REQUIRE_EQ(failed, failed.apply(utils::make_optional(status))); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(googletest_result__apply__skipped); +ATF_TEST_CASE_BODY(googletest_result__apply__skipped) +{ + const process::status status = process::status::fake_exited(EXIT_SUCCESS); + const engine::googletest_result skipped(engine::googletest_result::skipped, + "The reason"); + ATF_REQUIRE_EQ(skipped, skipped.apply(utils::make_optional(status))); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(googletest_result__apply__successful); +ATF_TEST_CASE_BODY(googletest_result__apply__successful) +{ + const process::status status = process::status::fake_exited(EXIT_SUCCESS); + const engine::googletest_result + successful(engine::googletest_result::successful); + ATF_REQUIRE_EQ(successful, successful.apply(utils::make_optional(status))); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(googletest_result__externalize__broken); +ATF_TEST_CASE_BODY(googletest_result__externalize__broken) +{ + const engine::googletest_result raw(engine::googletest_result::broken, + "The reason"); + const model::test_result expected(model::test_result_broken, + "The reason"); + ATF_REQUIRE(expected == raw.externalize()); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(googletest_result__externalize__disabled); +ATF_TEST_CASE_BODY(googletest_result__externalize__disabled) +{ + const engine::googletest_result raw(engine::googletest_result::disabled, + "The reason"); + const model::test_result expected(model::test_result_skipped, + "The reason"); + ATF_REQUIRE(expected == raw.externalize()); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(googletest_result__externalize__failed); +ATF_TEST_CASE_BODY(googletest_result__externalize__failed) +{ + const engine::googletest_result raw(engine::googletest_result::failed, + "The reason"); + const model::test_result expected(model::test_result_failed, + "The reason"); + ATF_REQUIRE(expected == raw.externalize()); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(googletest_result__externalize__skipped); +ATF_TEST_CASE_BODY(googletest_result__externalize__skipped) +{ + const engine::googletest_result raw(engine::googletest_result::skipped, + "The reason"); + const model::test_result expected(model::test_result_skipped, + "The reason"); + ATF_REQUIRE(expected == raw.externalize()); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(googletest_result__externalize__successful); +ATF_TEST_CASE_BODY(googletest_result__externalize__successful) +{ + const engine::googletest_result raw(engine::googletest_result::successful); + const model::test_result expected(model::test_result_passed); + ATF_REQUIRE_EQ(expected, raw.externalize()); +} + + +ATF_INIT_TEST_CASES(tcs) +{ + ATF_ADD_TEST_CASE(tcs, googletest_result__parse__broken); + ATF_ADD_TEST_CASE(tcs, googletest_result__parse__disabled); + ATF_ADD_TEST_CASE(tcs, googletest_result__parse__failed); + ATF_ADD_TEST_CASE(tcs, googletest_result__parse__skipped); + ATF_ADD_TEST_CASE(tcs, googletest_result__parse__skipped_with_reason); + ATF_ADD_TEST_CASE(tcs, googletest_result__parse__successful); + ATF_ADD_TEST_CASE(tcs, googletest_result__parse__successful2); + ATF_ADD_TEST_CASE(tcs, googletest_result__parse__successful_parameterized); + ATF_ADD_TEST_CASE(tcs, googletest_result__parse__successful_with_reason); + + ATF_ADD_TEST_CASE(tcs, googletest_result__load__ok); + ATF_ADD_TEST_CASE(tcs, googletest_result__load__missing_file); + + ATF_ADD_TEST_CASE(tcs, googletest_result__apply__broken); + ATF_ADD_TEST_CASE(tcs, googletest_result__apply__disabled); + ATF_ADD_TEST_CASE(tcs, googletest_result__apply__failed); + ATF_ADD_TEST_CASE(tcs, googletest_result__apply__skipped); + ATF_ADD_TEST_CASE(tcs, googletest_result__apply__successful); + + ATF_ADD_TEST_CASE(tcs, googletest_result__externalize__broken); + ATF_ADD_TEST_CASE(tcs, googletest_result__externalize__disabled); + ATF_ADD_TEST_CASE(tcs, googletest_result__externalize__failed); + ATF_ADD_TEST_CASE(tcs, googletest_result__externalize__skipped); + ATF_ADD_TEST_CASE(tcs, googletest_result__externalize__successful); +} diff --git a/contrib/kyua/engine/googletest_test.cpp b/contrib/kyua/engine/googletest_test.cpp new file mode 100644 index 000000000000..3af4d6801e70 --- /dev/null +++ b/contrib/kyua/engine/googletest_test.cpp @@ -0,0 +1,361 @@ +// Copyright 2024 The Kyua Authors. +// 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. + +#include "engine/googletest.hpp" + +extern "C" { +#include <sys/stat.h> + +#include <signal.h> +} + +#include <atf-c++.hpp> + +#include "engine/config.hpp" +#include "engine/scheduler.hpp" +#include "model/metadata.hpp" +#include "model/test_case.hpp" +#include "model/test_program_fwd.hpp" +#include "model/test_result.hpp" +#include "utils/config/tree.ipp" +#include "utils/datetime.hpp" +#include "utils/env.hpp" +#include "utils/format/containers.ipp" +#include "utils/format/macros.hpp" +#include "utils/fs/operations.hpp" +#include "utils/fs/path.hpp" +#include "utils/optional.ipp" +#include "utils/stacktrace.hpp" +#include "utils/test_utils.ipp" + +namespace config = utils::config; +namespace datetime = utils::datetime; +namespace fs = utils::fs; +namespace scheduler = engine::scheduler; + +using utils::none; + + +namespace { + + +/// Prefix for all testcases. +const std::string test_suite = "Suite."; + + +/// Runs one googletest test program and checks its result. +/// +/// \param program_name Basename of the test program to run. +/// \param root Path to the base of the test suite. +/// \param user_config User-provided configuration. +/// +/// \return The list of loaded test cases. +static model::test_cases_map +list(const char* program_name, + const fs::path& root, + config::tree user_config = engine::empty_config()) +{ + scheduler::scheduler_handle handle = scheduler::setup(); + + const scheduler::lazy_test_program program( + "googletest", fs::path(program_name), root, "the-suite", + model::metadata_builder().build(), user_config, handle); + + const model::test_cases_map test_cases = handle.list_tests( + &program, user_config); + + handle.cleanup(); + + return test_cases; +} + + +/// Runs a bogus test program and checks the error result. +/// +/// \param exp_error Expected error string to find. +/// \param program_name Basename of the test program to run. +/// \param root Path to the base of the test suite. +static void +check_list_fail(const char* exp_error, + const char* program_name, + const fs::path& root) +{ + const model::test_cases_map test_cases = list( + program_name, root); + + ATF_REQUIRE_EQ(1, test_cases.size()); + const model::test_case& test_case = test_cases.begin()->second; + ATF_REQUIRE_EQ("__test_cases_list__", test_case.name()); + ATF_REQUIRE(test_case.fake_result()); + ATF_REQUIRE_MATCH(exp_error, + test_case.fake_result().get().reason()); +} + + +/// Runs one googletest test program and checks its result. +/// +/// \param tc Pointer to the calling test case, to obtain srcdir. +/// \param test_case_name Name of the "test case" to select from the helper +/// program. +/// \param exp_result The expected result. +/// \param metadata The test case metadata. +/// \param user_config User-provided configuration. +static void +run_one(const atf::tests::tc* tc, const char* test_case_name, + const model::test_result& exp_result, + const model::metadata& metadata = model::metadata_builder().build(), + config::tree user_config = engine::empty_config()) +{ + scheduler::scheduler_handle handle = scheduler::setup(); + + const std::string test_name = test_suite + std::string(test_case_name); + + const model::test_program_ptr program(new scheduler::lazy_test_program( + "googletest", fs::path("googletest_helpers"), + fs::path(tc->get_config_var("srcdir")), + "the-suite", metadata, user_config, handle)); + + (void)handle.spawn_test(program, test_name.c_str(), user_config); + + scheduler::result_handle_ptr result_handle = handle.wait_any(); + const scheduler::test_result_handle* test_result_handle = + dynamic_cast< const scheduler::test_result_handle* >( + result_handle.get()); + atf::utils::cat_file(result_handle->stdout_file().str(), "stdout: "); + atf::utils::cat_file(result_handle->stderr_file().str(), "stderr: "); + ATF_REQUIRE_EQ(exp_result, test_result_handle->test_result()); + result_handle->cleanup(); + result_handle.reset(); + + handle.cleanup(); +} + + +} // anonymous namespace + + +ATF_TEST_CASE_WITHOUT_HEAD(list__ok); +ATF_TEST_CASE_BODY(list__ok) +{ + const model::test_cases_map test_cases = list( + "googletest_helpers", fs::path(get_config_var("srcdir"))); + + const model::test_cases_map exp_test_cases = model::test_cases_map_builder() + .add(test_suite + "check_configuration_variables") + .add(test_suite + "crash") + .add(test_suite + "fail") + .add(test_suite + "pass") + .add(test_suite + "pass_but_exit_failure") + .add(test_suite + "timeout", model::metadata_builder() + .build()) + .build(); + ATF_REQUIRE_EQ(exp_test_cases, test_cases); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(list__current_directory); +ATF_TEST_CASE_BODY(list__current_directory) +{ + const fs::path helpers = + fs::path(get_config_var("srcdir")) / "googletest_helpers"; + ATF_REQUIRE(::symlink(helpers.c_str(), "googletest_helpers") != -1); + const model::test_cases_map test_cases = list( + "googletest_helpers", fs::path(".")); + + const model::test_cases_map exp_test_cases = model::test_cases_map_builder() + .add(test_suite + "check_configuration_variables") + .add(test_suite + "crash") + .add(test_suite + "fail") + .add(test_suite + "pass") + .add(test_suite + "pass_but_exit_failure") + .add(test_suite + "timeout", model::metadata_builder() + .build()) + .build(); + ATF_REQUIRE_EQ(exp_test_cases, test_cases); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(list__relative_path); +ATF_TEST_CASE_BODY(list__relative_path) +{ + const fs::path helpers = + fs::path(get_config_var("srcdir")) / "googletest_helpers"; + ATF_REQUIRE(::mkdir("dir1", 0755) != -1); + ATF_REQUIRE(::mkdir("dir1/dir2", 0755) != -1); + ATF_REQUIRE_EQ(::symlink(helpers.c_str(), + "dir1/dir2/googletest_helpers"), 0); + const model::test_cases_map test_cases = list( + "dir2/googletest_helpers", fs::path("dir1")); + + const model::test_cases_map exp_test_cases = model::test_cases_map_builder() + .add(test_suite + "check_configuration_variables") + .add(test_suite + "crash") + .add(test_suite + "fail") + .add(test_suite + "pass") + .add(test_suite + "pass_but_exit_failure") + .add(test_suite + "timeout", model::metadata_builder() + .build()) + .build(); + ATF_REQUIRE_EQ(exp_test_cases, test_cases); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(list__missing_test_program); +ATF_TEST_CASE_BODY(list__missing_test_program) +{ + check_list_fail("Cannot find test program", "non-existent", + fs::current_path()); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(list__not_a_test_program); +ATF_TEST_CASE_BODY(list__not_a_test_program) +{ + atf::utils::create_file("not-valid", "garbage\n"); + ATF_REQUIRE_EQ(::chmod("not-valid", 0755), 0); + check_list_fail("Invalid test program format", "not-valid", + fs::current_path()); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(list__no_permissions); +ATF_TEST_CASE_BODY(list__no_permissions) +{ + atf::utils::create_file("not-executable", "garbage\n"); + check_list_fail("Permission denied to run test program", + "not-executable", fs::current_path()); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(list__abort); +ATF_TEST_CASE_BODY(list__abort) +{ + atf::utils::create_file("kills_self", "#!/bin/sh\nkill -2 $$\n"); + ATF_REQUIRE_EQ(::chmod("kills_self", 0755), 0); + check_list_fail("Test program received signal", "kills_self", + fs::current_path()); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(list__empty); +ATF_TEST_CASE_BODY(list__empty) +{ + atf::utils::create_file("empty_list", "#!/bin/sh\n"); + ATF_REQUIRE_EQ(::chmod("empty_list", 0755), 0); + check_list_fail("No test cases", "empty_list", fs::current_path()); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(test__body_only__passes); +ATF_TEST_CASE_BODY(test__body_only__passes) +{ + const model::test_result exp_result(model::test_result_passed); + run_one(this, "pass", exp_result); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(test__body_only__fails); +ATF_TEST_CASE_BODY(test__body_only__fails) +{ + const std::string failure_message = ( +"gtest_macros_demo.cc:4: Failure\n" +"Failed\n" +"with a reason\n" +); + const model::test_result exp_result(model::test_result_failed, + failure_message); + run_one(this, "fail", exp_result); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(test__body_only__crashes); +ATF_TEST_CASE_BODY(test__body_only__crashes) +{ + utils::prepare_coredump_test(this); + + const model::test_result exp_result( + model::test_result_broken, + F("Error: Premature exit. Test case received signal %s (core dumped)") % + SIGABRT); + run_one(this, "crash", exp_result); +} + + +ATF_TEST_CASE(test__body_only__times_out); +ATF_TEST_CASE_HEAD(test__body_only__times_out) +{ + set_md_var("timeout", "60"); +} +ATF_TEST_CASE_BODY(test__body_only__times_out) +{ + config::tree user_config = engine::empty_config(); + utils::setenv("CONTROL_DIR", fs::current_path().str()); + const model::metadata metadata = model::metadata_builder() + .set_timeout(datetime::delta(1, 0)).build(); + const model::test_result exp_result( + model::test_result_broken, "Test case body timed out"); + run_one(this, "timeout", exp_result, metadata, user_config); + + ATF_REQUIRE(!atf::utils::file_exists("cookie")); +} + + +ATF_TEST_CASE_WITHOUT_HEAD(test__body_only__configuration_variables); +ATF_TEST_CASE_BODY(test__body_only__configuration_variables) +{ + config::tree user_config = engine::empty_config(); + user_config.set_string("test_suites.the-suite.first", "some value"); + user_config.set_string("test_suites.the-suite.second", "some other value"); + + const model::test_result exp_result(model::test_result_passed); + run_one(this, "check_configuration_variables", exp_result, + model::metadata_builder().build(), user_config); +} + + +ATF_INIT_TEST_CASES(tcs) +{ + scheduler::register_interface( + "googletest", std::shared_ptr< scheduler::interface >( + new engine::googletest_interface())); + + ATF_ADD_TEST_CASE(tcs, list__ok); + ATF_ADD_TEST_CASE(tcs, list__current_directory); + ATF_ADD_TEST_CASE(tcs, list__relative_path); + ATF_ADD_TEST_CASE(tcs, list__missing_test_program); + ATF_ADD_TEST_CASE(tcs, list__not_a_test_program); + ATF_ADD_TEST_CASE(tcs, list__no_permissions); + ATF_ADD_TEST_CASE(tcs, list__abort); + ATF_ADD_TEST_CASE(tcs, list__empty); + + ATF_ADD_TEST_CASE(tcs, test__body_only__passes); + ATF_ADD_TEST_CASE(tcs, test__body_only__fails); + ATF_ADD_TEST_CASE(tcs, test__body_only__crashes); + ATF_ADD_TEST_CASE(tcs, test__body_only__times_out); + ATF_ADD_TEST_CASE(tcs, test__body_only__configuration_variables); +} diff --git a/contrib/kyua/engine/kyuafile.hpp b/contrib/kyua/engine/kyuafile.hpp index 161f4305f4d1..a785f0462f5b 100644 --- a/contrib/kyua/engine/kyuafile.hpp +++ b/contrib/kyua/engine/kyuafile.hpp @@ -34,11 +34,6 @@ #include "engine/kyuafile_fwd.hpp" -#include <string> -#include <vector> - -#include <lutok/state.hpp> - #include "engine/scheduler_fwd.hpp" #include "model/test_program_fwd.hpp" #include "utils/config/tree_fwd.hpp" diff --git a/contrib/kyua/engine/kyuafile_test.cpp b/contrib/kyua/engine/kyuafile_test.cpp index d95f28c71acb..cd11e4cca491 100644 --- a/contrib/kyua/engine/kyuafile_test.cpp +++ b/contrib/kyua/engine/kyuafile_test.cpp @@ -27,19 +27,11 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "engine/kyuafile.hpp" - +#include <memory> extern "C" { #include <unistd.h> } - -#include <stdexcept> -#include <typeinfo> - #include <atf-c++.hpp> -#include <lutok/operations.hpp> -#include <lutok/state.ipp> -#include <lutok/test_utils.hpp> - #include "engine/atf.hpp" #include "engine/exceptions.hpp" #include "engine/plain.hpp" diff --git a/contrib/kyua/engine/plain.hpp b/contrib/kyua/engine/plain.hpp index ee5f3e746781..60bffec9bf04 100644 --- a/contrib/kyua/engine/plain.hpp +++ b/contrib/kyua/engine/plain.hpp @@ -40,18 +40,19 @@ namespace engine { /// Implementation of the scheduler interface for plain test programs. class plain_interface : public engine::scheduler::interface { public: - void exec_list(const model::test_program&, - const utils::config::properties_map&) const UTILS_NORETURN; + void exec_list [[noreturn]] ( + const model::test_program&, + const utils::config::properties_map&) const; model::test_cases_map parse_list( const utils::optional< utils::process::status >&, const utils::fs::path&, const utils::fs::path&) const; - void exec_test(const model::test_program&, const std::string&, - const utils::config::properties_map&, - const utils::fs::path&) const - UTILS_NORETURN; + void exec_test [[noreturn]] ( + const model::test_program&, const std::string&, + const utils::config::properties_map&, + const utils::fs::path&) const; model::test_result compute_result( const utils::optional< utils::process::status >&, diff --git a/contrib/kyua/engine/requirements.cpp b/contrib/kyua/engine/requirements.cpp index d5838b83f33a..7fc5522cffc2 100644 --- a/contrib/kyua/engine/requirements.cpp +++ b/contrib/kyua/engine/requirements.cpp @@ -112,7 +112,7 @@ check_execenv(const std::string& execenv, const config::tree& user_config) { std::string name = execenv; if (name.empty()) - name = engine::execenv::default_execenv_name; // if test claims nothing + name = DEFAULT_EXECENV_NAME; // if test claims nothing std::set< std::string > execenvs; try { @@ -274,7 +274,7 @@ static std::vector< std::shared_ptr< engine::reqs_checker > > _reqs_checkers; } // anonymous namespace -const std::vector< std::shared_ptr< engine::reqs_checker > > +std::vector< std::shared_ptr< engine::reqs_checker > > engine::reqs_checkers() { return _reqs_checkers; diff --git a/contrib/kyua/engine/requirements.hpp b/contrib/kyua/engine/requirements.hpp index 92e80c5122aa..671123060ce4 100644 --- a/contrib/kyua/engine/requirements.hpp +++ b/contrib/kyua/engine/requirements.hpp @@ -32,7 +32,9 @@ #if !defined(ENGINE_REQUIREMENTS_HPP) #define ENGINE_REQUIREMENTS_HPP +#include <memory> #include <string> +#include <vector> #include "model/metadata_fwd.hpp" #include "utils/config/tree_fwd.hpp" @@ -68,7 +70,7 @@ void register_reqs_checker(const std::shared_ptr< reqs_checker > checker); /// Returns the list of registered extra requirement checkers. /// /// \return A vector of pointers to extra requirement checkers. -const std::vector< std::shared_ptr< reqs_checker > > reqs_checkers(); +std::vector< std::shared_ptr< reqs_checker > > reqs_checkers(); } // namespace engine diff --git a/contrib/kyua/engine/scheduler.cpp b/contrib/kyua/engine/scheduler.cpp index d04fc1dfbd3d..6e19a1598f8c 100644 --- a/contrib/kyua/engine/scheduler.cpp +++ b/contrib/kyua/engine/scheduler.cpp @@ -1653,8 +1653,8 @@ scheduler::generate_config(const config::tree& user_config, if (user_config.is_set("unprivileged_user")) { const passwd::user& user = user_config.lookup< engine::user_node >("unprivileged_user"); - // The property is duplicated using both ATF and Kyua naming styles - // for better UX. + // The property is duplicated using both ATF and Kyua naming styles + // for better UX. props["unprivileged-user"] = user.name; props["unprivileged_user"] = user.name; } diff --git a/contrib/kyua/engine/scheduler.hpp b/contrib/kyua/engine/scheduler.hpp index 508a0c0cbfd9..0e241172f1e7 100644 --- a/contrib/kyua/engine/scheduler.hpp +++ b/contrib/kyua/engine/scheduler.hpp @@ -98,9 +98,9 @@ public: /// /// \param test_program The test program to execute. /// \param vars User-provided variables to pass to the test program. - virtual void exec_list(const model::test_program& test_program, - const utils::config::properties_map& vars) - const UTILS_NORETURN = 0; + virtual void exec_list [[noreturn]] ( + const model::test_program& test_program, + const utils::config::properties_map& vars) const = 0; /// Computes the test cases list of a test program. /// @@ -126,11 +126,11 @@ public: /// \param vars User-provided variables to pass to the test program. /// \param control_directory Directory where the interface may place control /// files. - virtual void exec_test(const model::test_program& test_program, - const std::string& test_case_name, - const utils::config::properties_map& vars, - const utils::fs::path& control_directory) - const UTILS_NORETURN = 0; + virtual void exec_test [[noreturn]] ( + const model::test_program& test_program, + const std::string& test_case_name, + const utils::config::properties_map& vars, + const utils::fs::path& control_directory) const = 0; /// Executes a test cleanup routine of the test program. /// @@ -143,11 +143,11 @@ public: /// \param vars User-provided variables to pass to the test program. /// \param control_directory Directory where the interface may place control /// files. - virtual void exec_cleanup(const model::test_program& test_program, - const std::string& test_case_name, - const utils::config::properties_map& vars, - const utils::fs::path& control_directory) - const UTILS_NORETURN; + virtual void exec_cleanup [[noreturn]]( + const model::test_program& test_program, + const std::string& test_case_name, + const utils::config::properties_map& vars, + const utils::fs::path& control_directory) const; /// Computes the result of a test case based on its termination status. /// diff --git a/contrib/kyua/engine/scheduler_test.cpp b/contrib/kyua/engine/scheduler_test.cpp index d91c448f2e5e..93e7627f291a 100644 --- a/contrib/kyua/engine/scheduler_test.cpp +++ b/contrib/kyua/engine/scheduler_test.cpp @@ -131,7 +131,7 @@ class mock_interface : public scheduler::interface { /// /// \param exit_code Exit code. void - do_exit(const int exit_code) const UTILS_NORETURN + do_exit [[noreturn]] (const int exit_code) const { std::cout.flush(); std::cerr.flush(); @@ -140,7 +140,7 @@ class mock_interface : public scheduler::interface { /// Executes a test case that creates various files and then fails. void - exec_create_files_and_fail(void) const UTILS_NORETURN + exec_create_files_and_fail [[noreturn]] (void) const { std::cerr << "This should not be clobbered\n"; atf::utils::create_file("first file", ""); @@ -155,7 +155,7 @@ class mock_interface : public scheduler::interface { /// This is intended to validate that the test runs in an empty directory, /// separate from any control files that the scheduler may have created. void - exec_delete_all(void) const UTILS_NORETURN + exec_delete_all [[noreturn]] (void) const { const int exit_code = ::system("rm *") == -1 ? EXIT_FAILURE : EXIT_SUCCESS; @@ -170,14 +170,14 @@ class mock_interface : public scheduler::interface { /// /// \param exit_code Exit status to terminate the program with. void - exec_exit(const int exit_code) const UTILS_NORETURN + exec_exit [[noreturn]] (const int exit_code) const { do_exit(exit_code); } /// Executes a test case that just fails. void - exec_fail(void) const UTILS_NORETURN + exec_fail [[noreturn]] (void) const { std::cerr << "This should not be clobbered\n"; ::kill(::getpid(), SIGTERM); @@ -191,10 +191,10 @@ class mock_interface : public scheduler::interface { /// number. /// \param vars User-provided variables to pass to the test program. void - exec_print_params(const model::test_program& test_program, - const std::string& test_case_name, - const config::properties_map& vars) const - UTILS_NORETURN + exec_print_params [[noreturn]] ( + const model::test_program& test_program, + const std::string& test_case_name, + const config::properties_map& vars) const { std::cout << F("Test program: %s\n") % test_program.relative_path(); std::cout << F("Test case: %s\n") % test_case_name; @@ -218,9 +218,9 @@ public: /// \param test_program The test program to execute. /// \param vars User-provided variables to pass to the test program. void - exec_list(const model::test_program& test_program, - const config::properties_map& vars) - const UTILS_NORETURN + exec_list [[noreturn]] ( + const model::test_program& test_program, + const config::properties_map& vars) const { const std::string name = test_program.absolute_path().leaf_name(); diff --git a/contrib/kyua/engine/tap.hpp b/contrib/kyua/engine/tap.hpp index b46bf28f0240..51ad76231eaf 100644 --- a/contrib/kyua/engine/tap.hpp +++ b/contrib/kyua/engine/tap.hpp @@ -40,18 +40,19 @@ namespace engine { /// Implementation of the scheduler interface for tap test programs. class tap_interface : public engine::scheduler::interface { public: - void exec_list(const model::test_program&, - const utils::config::properties_map&) const UTILS_NORETURN; + void exec_list [[noreturn]] ( + const model::test_program&, + const utils::config::properties_map&) const; model::test_cases_map parse_list( const utils::optional< utils::process::status >&, const utils::fs::path&, const utils::fs::path&) const; - void exec_test(const model::test_program&, const std::string&, - const utils::config::properties_map&, - const utils::fs::path&) const - UTILS_NORETURN; + void exec_test [[noreturn]] ( + const model::test_program&, const std::string&, + const utils::config::properties_map&, + const utils::fs::path&) const; model::test_result compute_result( const utils::optional< utils::process::status >&, diff --git a/contrib/kyua/examples/Makefile.am.inc b/contrib/kyua/examples/Makefile.am.inc deleted file mode 100644 index 3c9b27dae6a9..000000000000 --- a/contrib/kyua/examples/Makefile.am.inc +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2011 The Kyua Authors. -# 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. - -dist_examples_DATA = examples/Kyuafile.top -dist_examples_DATA += examples/kyua.conf - -if WITH_ATF -tests_examplesdir = $(pkgtestsdir)/examples - -tests_examples_DATA = examples/Kyuafile -EXTRA_DIST += $(tests_examples_DATA) - -tests_examples_PROGRAMS = examples/syntax_test -examples_syntax_test_SOURCES = examples/syntax_test.cpp -examples_syntax_test_CPPFLAGS = -DKYUA_EXAMPLESDIR="\"$(examplesdir)\"" -examples_syntax_test_CXXFLAGS = $(ENGINE_CFLAGS) $(UTILS_CFLAGS) \ - $(ATF_CXX_CFLAGS) -examples_syntax_test_LDADD = $(ENGINE_LIBS) $(UTILS_LIBS) \ - $(ATF_CXX_LIBS) -endif diff --git a/contrib/kyua/integration/Makefile.am.inc b/contrib/kyua/integration/Makefile.am.inc deleted file mode 100644 index cf9ad86d5730..000000000000 --- a/contrib/kyua/integration/Makefile.am.inc +++ /dev/null @@ -1,150 +0,0 @@ -# Copyright 2011 The Kyua Authors. -# 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 WITH_ATF -tests_integrationdir = $(pkgtestsdir)/integration - -tests_integration_DATA = integration/Kyuafile -EXTRA_DIST += $(tests_integration_DATA) - -ATF_SH_BUILD = \ - $(MKDIR_P) integration; \ - echo "\#! $(ATF_SH)" >integration/$${name}; \ - echo "\# AUTOMATICALLY GENERATED FROM Makefile" >>integration/$${name}; \ - if [ -n "$${substs}" ]; then \ - cat $(srcdir)/integration/utils.sh $(srcdir)/integration/$${name}.sh \ - | sed "$${substs}" >>integration/$${name}; \ - else \ - cat $(srcdir)/integration/utils.sh $(srcdir)/integration/$${name}.sh \ - >>integration/$${name}; \ - fi; \ - chmod +x integration/$${name} - -ATF_SH_DEPS = \ - $(srcdir)/integration/utils.sh \ - Makefile - -EXTRA_DIST += integration/utils.sh - -tests_integration_SCRIPTS = integration/cmd_about_test -CLEANFILES += integration/cmd_about_test -EXTRA_DIST += integration/cmd_about_test.sh -integration/cmd_about_test: $(srcdir)/integration/cmd_about_test.sh \ - $(ATF_SH_DEPS) - $(AM_V_GEN)name="cmd_about_test"; \ - substs='s,__KYUA_DOCDIR__,$(docdir),g'; \ - $(ATF_SH_BUILD) - -tests_integration_SCRIPTS += integration/cmd_config_test -CLEANFILES += integration/cmd_config_test -EXTRA_DIST += integration/cmd_config_test.sh -integration/cmd_config_test: $(srcdir)/integration/cmd_config_test.sh \ - $(ATF_SH_DEPS) - $(AM_V_GEN)name="cmd_config_test"; \ - $(ATF_SH_BUILD) - -tests_integration_SCRIPTS += integration/cmd_db_exec_test -CLEANFILES += integration/cmd_db_exec_test -EXTRA_DIST += integration/cmd_db_exec_test.sh -integration/cmd_db_exec_test: $(srcdir)/integration/cmd_db_exec_test.sh \ - $(ATF_SH_DEPS) - $(AM_V_GEN)name="cmd_db_exec_test"; \ - $(ATF_SH_BUILD) - -tests_integration_SCRIPTS += integration/cmd_db_migrate_test -CLEANFILES += integration/cmd_db_migrate_test -EXTRA_DIST += integration/cmd_db_migrate_test.sh -integration/cmd_db_migrate_test: $(srcdir)/integration/cmd_db_migrate_test.sh \ - $(ATF_SH_DEPS) - $(AM_V_GEN)name="cmd_db_migrate_test"; \ - substs='s,__KYUA_STOREDIR__,$(storedir),g'; \ - substs="$${substs};s,__KYUA_STORETESTDATADIR__,$(tests_storedir),g"; \ - $(ATF_SH_BUILD) - -tests_integration_SCRIPTS += integration/cmd_debug_test -CLEANFILES += integration/cmd_debug_test -EXTRA_DIST += integration/cmd_debug_test.sh -integration/cmd_debug_test: $(srcdir)/integration/cmd_debug_test.sh \ - $(ATF_SH_DEPS) - $(AM_V_GEN)name="cmd_debug_test"; \ - $(ATF_SH_BUILD) - -tests_integration_SCRIPTS += integration/cmd_help_test -CLEANFILES += integration/cmd_help_test -EXTRA_DIST += integration/cmd_help_test.sh -integration/cmd_help_test: $(srcdir)/integration/cmd_help_test.sh $(ATF_SH_DEPS) - $(AM_V_GEN)name="cmd_help_test"; \ - $(ATF_SH_BUILD) - -tests_integration_SCRIPTS += integration/cmd_list_test -CLEANFILES += integration/cmd_list_test -EXTRA_DIST += integration/cmd_list_test.sh -integration/cmd_list_test: $(srcdir)/integration/cmd_list_test.sh $(ATF_SH_DEPS) - $(AM_V_GEN)name="cmd_list_test"; \ - $(ATF_SH_BUILD) - -tests_integration_SCRIPTS += integration/cmd_report_test -CLEANFILES += integration/cmd_report_test -EXTRA_DIST += integration/cmd_report_test.sh -integration/cmd_report_test: $(srcdir)/integration/cmd_report_test.sh \ - $(ATF_SH_DEPS) - $(AM_V_GEN)name="cmd_report_test"; \ - $(ATF_SH_BUILD) - -tests_integration_SCRIPTS += integration/cmd_report_html_test -CLEANFILES += integration/cmd_report_html_test -EXTRA_DIST += integration/cmd_report_html_test.sh -integration/cmd_report_html_test: \ - $(srcdir)/integration/cmd_report_html_test.sh $(ATF_SH_DEPS) - $(AM_V_GEN)name="cmd_report_html_test"; \ - $(ATF_SH_BUILD) - -tests_integration_SCRIPTS += integration/cmd_report_junit_test -CLEANFILES += integration/cmd_report_junit_test -EXTRA_DIST += integration/cmd_report_junit_test.sh -integration/cmd_report_junit_test: \ - $(srcdir)/integration/cmd_report_junit_test.sh $(ATF_SH_DEPS) - $(AM_V_GEN)name="cmd_report_junit_test"; \ - $(ATF_SH_BUILD) - -tests_integration_SCRIPTS += integration/cmd_test_test -CLEANFILES += integration/cmd_test_test -EXTRA_DIST += integration/cmd_test_test.sh -integration/cmd_test_test: $(srcdir)/integration/cmd_test_test.sh $(ATF_SH_DEPS) - $(AM_V_GEN)name="cmd_test_test"; \ - $(ATF_SH_BUILD) - -tests_integration_SCRIPTS += integration/global_test -CLEANFILES += integration/global_test -EXTRA_DIST += integration/global_test.sh -integration/global_test: $(srcdir)/integration/global_test.sh $(ATF_SH_DEPS) - $(AM_V_GEN)name="global_test"; \ - $(ATF_SH_BUILD) -endif - -include integration/helpers/Makefile.am.inc diff --git a/contrib/kyua/integration/cmd_about_test.sh b/contrib/kyua/integration/cmd_about_test.sh index 06d5da5ac4c2..8714e7619dbd 100644 --- a/contrib/kyua/integration/cmd_about_test.sh +++ b/contrib/kyua/integration/cmd_about_test.sh @@ -119,7 +119,7 @@ topic__version_body() { local lines="$(wc -l stdout | awk '{ print $1 }')" [ "${lines}" -eq 1 ] || atf_fail "Version query returned more than one line" - grep -E '^kyua (.*) [0-9]+\.[0-9]+$' stdout || \ + grep -E '^kyua (.*) [0-9]+\.[0-9]+(\.[0-9]+)?$' stdout || \ atf_fail "Invalid version message" } diff --git a/contrib/kyua/integration/cmd_report_test.sh b/contrib/kyua/integration/cmd_report_test.sh index 1fc1932d3c47..66ea235c31b0 100644 --- a/contrib/kyua/integration/cmd_report_test.sh +++ b/contrib/kyua/integration/cmd_report_test.sh @@ -217,7 +217,7 @@ verbose_body() { # Switch to the current directory using its physical location and update # HOME accordingly. Otherwise, the test below where we compare the value # of HOME in the output might fail if the path to HOME contains a symlink - # (as is the case in OS X when HOME points to the temporary directory.) + # (as is the case in macOS when HOME points to the temporary directory.) local real_cwd="$(pwd -P)" cd "${real_cwd}" HOME="${real_cwd}" diff --git a/contrib/kyua/integration/cmd_test_test.sh b/contrib/kyua/integration/cmd_test_test.sh index 4c2fe863a4f5..bfc53a0e7fbb 100644 --- a/contrib/kyua/integration/cmd_test_test.sh +++ b/contrib/kyua/integration/cmd_test_test.sh @@ -224,8 +224,8 @@ EOF # CHECK_STYLE_DISABLE cat >expout <<EOF -bogus_test_cases:die -> broken: Premature exit; test case received signal 9 [S.UUUs] -bogus_test_cases:exit -> broken: Premature exit; test case exited with code 0 [S.UUUs] +bogus_test_cases:die -> broken: Error: Empty test result or no new line. Test case received signal 9 [S.UUUs] +bogus_test_cases:exit -> broken: Error: Empty test result or no new line. Test case exited with code 0 [S.UUUs] bogus_test_cases:pass -> passed [S.UUUs] Results file id is $(utils_results_id) diff --git a/contrib/kyua/integration/helpers/.gitignore b/contrib/kyua/integration/helpers/.gitignore deleted file mode 100644 index 11634bcfeb85..000000000000 --- a/contrib/kyua/integration/helpers/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -bad_test_program -bogus_test_cases -config -dump_env -expect_all_pass -expect_some_fail -interrupts -metadata -race -simple_all_pass -simple_some_fail diff --git a/contrib/kyua/integration/helpers/Makefile.am.inc b/contrib/kyua/integration/helpers/Makefile.am.inc deleted file mode 100644 index d835aba51c67..000000000000 --- a/contrib/kyua/integration/helpers/Makefile.am.inc +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright 2011 The Kyua Authors. -# 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 WITH_ATF -tests_integration_helpersdir = $(pkgtestsdir)/integration/helpers - -tests_integration_helpers_PROGRAMS = integration/helpers/bad_test_program -integration_helpers_bad_test_program_SOURCES = \ - integration/helpers/bad_test_program.cpp - -tests_integration_helpers_PROGRAMS += integration/helpers/bogus_test_cases -integration_helpers_bogus_test_cases_SOURCES = \ - integration/helpers/bogus_test_cases.cpp -integration_helpers_bogus_test_cases_CXXFLAGS = $(ATF_CXX_CFLAGS) -integration_helpers_bogus_test_cases_LDADD = $(ATF_CXX_LIBS) - -tests_integration_helpers_PROGRAMS += integration/helpers/config -integration_helpers_config_SOURCES = integration/helpers/config.cpp -integration_helpers_config_CXXFLAGS = $(ATF_CXX_CFLAGS) -integration_helpers_config_LDADD = $(ATF_CXX_LIBS) - -tests_integration_helpers_PROGRAMS += integration/helpers/dump_env -integration_helpers_dump_env_SOURCES = integration/helpers/dump_env.cpp -integration_helpers_dump_env_CXXFLAGS = $(UTILS_CFLAGS) -integration_helpers_dump_env_LDADD = $(UTILS_LIBS) - -tests_integration_helpers_PROGRAMS += integration/helpers/expect_all_pass -integration_helpers_expect_all_pass_SOURCES = \ - integration/helpers/expect_all_pass.cpp -integration_helpers_expect_all_pass_CXXFLAGS = $(ATF_CXX_CFLAGS) -integration_helpers_expect_all_pass_LDADD = $(ATF_CXX_LIBS) - -tests_integration_helpers_PROGRAMS += integration/helpers/expect_some_fail -integration_helpers_expect_some_fail_SOURCES = \ - integration/helpers/expect_some_fail.cpp -integration_helpers_expect_some_fail_CXXFLAGS = $(ATF_CXX_CFLAGS) -integration_helpers_expect_some_fail_LDADD = $(ATF_CXX_LIBS) - -tests_integration_helpers_PROGRAMS += integration/helpers/interrupts -integration_helpers_interrupts_SOURCES = integration/helpers/interrupts.cpp -integration_helpers_interrupts_CXXFLAGS = $(ATF_CXX_CFLAGS) -integration_helpers_interrupts_LDADD = $(ATF_CXX_LIBS) - -tests_integration_helpers_PROGRAMS += integration/helpers/metadata -integration_helpers_metadata_SOURCES = integration/helpers/metadata.cpp -integration_helpers_metadata_CXXFLAGS = $(ATF_CXX_CFLAGS) -integration_helpers_metadata_LDADD = $(ATF_CXX_LIBS) - -tests_integration_helpers_PROGRAMS += integration/helpers/race -integration_helpers_race_SOURCES = integration/helpers/race.cpp -integration_helpers_race_CXXFLAGS = $(UTILS_CFLAGS) -integration_helpers_race_LDADD = $(UTILS_LIBS) - -tests_integration_helpers_PROGRAMS += integration/helpers/simple_all_pass -integration_helpers_simple_all_pass_SOURCES = \ - integration/helpers/simple_all_pass.cpp -integration_helpers_simple_all_pass_CXXFLAGS = $(ATF_CXX_CFLAGS) -integration_helpers_simple_all_pass_LDADD = $(ATF_CXX_LIBS) - -tests_integration_helpers_PROGRAMS += integration/helpers/simple_some_fail -integration_helpers_simple_some_fail_SOURCES = \ - integration/helpers/simple_some_fail.cpp -integration_helpers_simple_some_fail_CXXFLAGS = $(ATF_CXX_CFLAGS) -integration_helpers_simple_some_fail_LDADD = $(ATF_CXX_LIBS) -endif diff --git a/contrib/kyua/integration/utils.sh b/contrib/kyua/integration/utils.sh index d1462a5a9b01..b4696bb9a776 100644 --- a/contrib/kyua/integration/utils.sh +++ b/contrib/kyua/integration/utils.sh @@ -106,19 +106,22 @@ utils_cp_helper() { # Kyua with the deterministic strings. This is to be used by tests that # validate the 'test' and 'report' subcommands. utils_install_times_wrapper() { - [ ! -x kyua ] || return - cat >kyua <<EOF -#! /bin/sh + local DUMMY_KYUA_BINDIR=$(pwd) + local DUMMY_KYUA_BIN="$DUMMY_KYUA_BINDIR/kyua" + + [ ! -x "$DUMMY_KYUA_BIN" ] || return -PATH=${PATH} + local ORIG_KYUA_BIN=$(which kyua) + cat >"$DUMMY_KYUA_BIN" <<EOF +#! /bin/sh -kyua "\${@}" >kyua.tmpout +$ORIG_KYUA_BIN "\${@}" >kyua.tmpout result=\${?} cat kyua.tmpout | ${utils_strip_times} exit \${result} EOF - chmod +x kyua - PATH="$(pwd):${PATH}" + chmod +x "$DUMMY_KYUA_BIN" + export PATH="$DUMMY_KYUA_BINDIR:${PATH}" } @@ -130,13 +133,16 @@ EOF # execution so that the output can be verified. For these reasons, this is to # be used exclusively by tests that validate the 'test' subcommand. utils_install_stable_test_wrapper() { - [ ! -x kyua ] || return - cat >kyua <<EOF -#! /bin/sh + local DUMMY_KYUA_BINDIR=$(pwd) + local DUMMY_KYUA_BIN="$DUMMY_KYUA_BINDIR/kyua" + + [ ! -x "$DUMMY_KYUA_BIN" ] || return -PATH=${PATH} + local ORIG_KYUA_BIN=$(which kyua) + cat >"$DUMMY_KYUA_BIN" <<EOF +#! /bin/sh -kyua "\${@}" >kyua.tmpout +$ORIG_KYUA_BIN "\${@}" >kyua.tmpout result=\${?} cat kyua.tmpout | ${utils_strip_times} >kyua.tmpout2 @@ -147,8 +153,8 @@ cat kyua.tmpout3 kyua.tmpout4 exit \${result} EOF - chmod +x kyua - PATH="$(pwd):${PATH}" + chmod +x "$DUMMY_KYUA_BIN" + export PATH="$DUMMY_KYUA_BINDIR:${PATH}" } diff --git a/contrib/kyua/m4/ax_cxx_compile_stdcxx.m4 b/contrib/kyua/m4/ax_cxx_compile_stdcxx.m4 deleted file mode 100644 index 43087b2e6889..000000000000 --- a/contrib/kyua/m4/ax_cxx_compile_stdcxx.m4 +++ /dev/null @@ -1,951 +0,0 @@ -# =========================================================================== -# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) -# -# DESCRIPTION -# -# Check for baseline language coverage in the compiler for the specified -# version of the C++ standard. If necessary, add switches to CXX and -# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard) -# or '14' (for the C++14 standard). -# -# The second argument, if specified, indicates whether you insist on an -# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. -# -std=c++11). If neither is specified, you get whatever works, with -# preference for an extended mode. -# -# The third argument, if specified 'mandatory' or if left unspecified, -# indicates that baseline support for the specified C++ standard is -# required and that the macro should error out if no mode with that -# support is found. If specified 'optional', then configuration proceeds -# regardless, after defining HAVE_CXX${VERSION} if and only if a -# supporting mode is found. -# -# LICENSE -# -# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com> -# Copyright (c) 2012 Zack Weinberg <zackw@panix.com> -# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu> -# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com> -# Copyright (c) 2015 Paul Norman <penorman@mac.com> -# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu> -# Copyright (c) 2016, 2018 Krzesimir Nowak <qdlacz@gmail.com> -# Copyright (c) 2019 Enji Cooper <yaneurabeya@gmail.com> -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 11 - -dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro -dnl (serial version number 13). - -AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl - m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], - [$1], [14], [ax_cxx_compile_alternatives="14 1y"], - [$1], [17], [ax_cxx_compile_alternatives="17 1z"], - [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl - m4_if([$2], [], [], - [$2], [ext], [], - [$2], [noext], [], - [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl - m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], - [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], - [$3], [optional], [ax_cxx_compile_cxx$1_required=false], - [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) - AC_LANG_PUSH([C++])dnl - ac_success=no - - m4_if([$2], [noext], [], [dnl - if test x$ac_success = xno; then - for alternative in ${ax_cxx_compile_alternatives}; do - switch="-std=gnu++${alternative}" - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) - AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, - $cachevar, - [ac_save_CXX="$CXX" - CXX="$CXX $switch" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], - [eval $cachevar=yes], - [eval $cachevar=no]) - CXX="$ac_save_CXX"]) - if eval test x\$$cachevar = xyes; then - CXX="$CXX $switch" - if test -n "$CXXCPP" ; then - CXXCPP="$CXXCPP $switch" - fi - ac_success=yes - break - fi - done - fi]) - - m4_if([$2], [ext], [], [dnl - if test x$ac_success = xno; then - dnl HP's aCC needs +std=c++11 according to: - dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf - dnl Cray's crayCC needs "-h std=c++11" - for alternative in ${ax_cxx_compile_alternatives}; do - for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) - AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, - $cachevar, - [ac_save_CXX="$CXX" - CXX="$CXX $switch" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], - [eval $cachevar=yes], - [eval $cachevar=no]) - CXX="$ac_save_CXX"]) - if eval test x\$$cachevar = xyes; then - CXX="$CXX $switch" - if test -n "$CXXCPP" ; then - CXXCPP="$CXXCPP $switch" - fi - ac_success=yes - break - fi - done - if test x$ac_success = xyes; then - break - fi - done - fi]) - AC_LANG_POP([C++]) - if test x$ax_cxx_compile_cxx$1_required = xtrue; then - if test x$ac_success = xno; then - AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.]) - fi - fi - if test x$ac_success = xno; then - HAVE_CXX$1=0 - AC_MSG_NOTICE([No compiler with C++$1 support was found]) - else - HAVE_CXX$1=1 - AC_DEFINE(HAVE_CXX$1,1, - [define if the compiler supports basic C++$1 syntax]) - fi - AC_SUBST(HAVE_CXX$1) -]) - - -dnl Test body for checking C++11 support - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], - _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 -) - - -dnl Test body for checking C++14 support - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], - _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 -) - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], - _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 -) - -dnl Tests for new features in C++11 - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ - -// If the compiler admits that it is not ready for C++11, why torture it? -// Hopefully, this will speed up the test. - -#ifndef __cplusplus - -#error "This is not a C++ compiler" - -#elif __cplusplus < 201103L - -#error "This is not a C++11 compiler" - -#else - -namespace cxx11 -{ - - namespace test_static_assert - { - - template <typename T> - struct check - { - static_assert(sizeof(int) <= sizeof(T), "not big enough"); - }; - - } - - namespace test_final_override - { - - struct Base - { - virtual ~Base() {} - virtual void f() {} - }; - - struct Derived : public Base - { - virtual ~Derived() override {} - virtual void f() override {} - }; - - } - - namespace test_double_right_angle_brackets - { - - template < typename T > - struct check {}; - - typedef check<void> single_type; - typedef check<check<void>> double_type; - typedef check<check<check<void>>> triple_type; - typedef check<check<check<check<void>>>> quadruple_type; - - } - - namespace test_decltype - { - - int - f() - { - int a = 1; - decltype(a) b = 2; - return a + b; - } - - } - - namespace test_type_deduction - { - - template < typename T1, typename T2 > - struct is_same - { - static const bool value = false; - }; - - template < typename T > - struct is_same<T, T> - { - static const bool value = true; - }; - - template < typename T1, typename T2 > - auto - add(T1 a1, T2 a2) -> decltype(a1 + a2) - { - return a1 + a2; - } - - int - test(const int c, volatile int v) - { - static_assert(is_same<int, decltype(0)>::value == true, ""); - static_assert(is_same<int, decltype(c)>::value == false, ""); - static_assert(is_same<int, decltype(v)>::value == false, ""); - auto ac = c; - auto av = v; - auto sumi = ac + av + 'x'; - auto sumf = ac + av + 1.0; - static_assert(is_same<int, decltype(ac)>::value == true, ""); - static_assert(is_same<int, decltype(av)>::value == true, ""); - static_assert(is_same<int, decltype(sumi)>::value == true, ""); - static_assert(is_same<int, decltype(sumf)>::value == false, ""); - static_assert(is_same<int, decltype(add(c, v))>::value == true, ""); - return (sumf > 0.0) ? sumi : add(c, v); - } - - } - - namespace test_noexcept - { - - int f() { return 0; } - int g() noexcept { return 0; } - - static_assert(noexcept(f()) == false, ""); - static_assert(noexcept(g()) == true, ""); - - } - - namespace test_constexpr - { - - template < typename CharT > - unsigned long constexpr - strlen_c_r(const CharT *const s, const unsigned long acc) noexcept - { - return *s ? strlen_c_r(s + 1, acc + 1) : acc; - } - - template < typename CharT > - unsigned long constexpr - strlen_c(const CharT *const s) noexcept - { - return strlen_c_r(s, 0UL); - } - - static_assert(strlen_c("") == 0UL, ""); - static_assert(strlen_c("1") == 1UL, ""); - static_assert(strlen_c("example") == 7UL, ""); - static_assert(strlen_c("another\0example") == 7UL, ""); - - } - - namespace test_rvalue_references - { - - template < int N > - struct answer - { - static constexpr int value = N; - }; - - answer<1> f(int&) { return answer<1>(); } - answer<2> f(const int&) { return answer<2>(); } - answer<3> f(int&&) { return answer<3>(); } - - void - test() - { - int i = 0; - const int c = 0; - static_assert(decltype(f(i))::value == 1, ""); - static_assert(decltype(f(c))::value == 2, ""); - static_assert(decltype(f(0))::value == 3, ""); - } - - } - - namespace test_uniform_initialization - { - - struct test - { - static const int zero {}; - static const int one {1}; - }; - - static_assert(test::zero == 0, ""); - static_assert(test::one == 1, ""); - - } - - namespace test_lambdas - { - - void - test1() - { - auto lambda1 = [](){}; - auto lambda2 = lambda1; - lambda1(); - lambda2(); - } - - int - test2() - { - auto a = [](int i, int j){ return i + j; }(1, 2); - auto b = []() -> int { return '0'; }(); - auto c = [=](){ return a + b; }(); - auto d = [&](){ return c; }(); - auto e = [a, &b](int x) mutable { - const auto identity = [](int y){ return y; }; - for (auto i = 0; i < a; ++i) - a += b--; - return x + identity(a + b); - }(0); - return a + b + c + d + e; - } - - int - test3() - { - const auto nullary = [](){ return 0; }; - const auto unary = [](int x){ return x; }; - using nullary_t = decltype(nullary); - using unary_t = decltype(unary); - const auto higher1st = [](nullary_t f){ return f(); }; - const auto higher2nd = [unary](nullary_t f1){ - return [unary, f1](unary_t f2){ return f2(unary(f1())); }; - }; - return higher1st(nullary) + higher2nd(nullary)(unary); - } - - } - - namespace test_variadic_templates - { - - template <int...> - struct sum; - - template <int N0, int... N1toN> - struct sum<N0, N1toN...> - { - static constexpr auto value = N0 + sum<N1toN...>::value; - }; - - template <> - struct sum<> - { - static constexpr auto value = 0; - }; - - static_assert(sum<>::value == 0, ""); - static_assert(sum<1>::value == 1, ""); - static_assert(sum<23>::value == 23, ""); - static_assert(sum<1, 2>::value == 3, ""); - static_assert(sum<5, 5, 11>::value == 21, ""); - static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); - - } - - // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae - // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function - // because of this. - namespace test_template_alias_sfinae - { - - struct foo {}; - - template<typename T> - using member = typename T::member_type; - - template<typename T> - void func(...) {} - - template<typename T> - void func(member<T>*) {} - - void test(); - - void test() { func<foo>(0); } - - } - -} // namespace cxx11 - -#endif // __cplusplus >= 201103L - -]]) - - -dnl Tests for new features in C++14 - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ - -// If the compiler admits that it is not ready for C++14, why torture it? -// Hopefully, this will speed up the test. - -#ifndef __cplusplus - -#error "This is not a C++ compiler" - -#elif __cplusplus < 201402L - -#error "This is not a C++14 compiler" - -#else - -namespace cxx14 -{ - - namespace test_polymorphic_lambdas - { - - int - test() - { - const auto lambda = [](auto&&... args){ - const auto istiny = [](auto x){ - return (sizeof(x) == 1UL) ? 1 : 0; - }; - const int aretiny[] = { istiny(args)... }; - return aretiny[0]; - }; - return lambda(1, 1L, 1.0f, '1'); - } - - } - - namespace test_binary_literals - { - - constexpr auto ivii = 0b0000000000101010; - static_assert(ivii == 42, "wrong value"); - - } - - namespace test_generalized_constexpr - { - - template < typename CharT > - constexpr unsigned long - strlen_c(const CharT *const s) noexcept - { - auto length = 0UL; - for (auto p = s; *p; ++p) - ++length; - return length; - } - - static_assert(strlen_c("") == 0UL, ""); - static_assert(strlen_c("x") == 1UL, ""); - static_assert(strlen_c("test") == 4UL, ""); - static_assert(strlen_c("another\0test") == 7UL, ""); - - } - - namespace test_lambda_init_capture - { - - int - test() - { - auto x = 0; - const auto lambda1 = [a = x](int b){ return a + b; }; - const auto lambda2 = [a = lambda1(x)](){ return a; }; - return lambda2(); - } - - } - - namespace test_digit_separators - { - - constexpr auto ten_million = 100'000'000; - static_assert(ten_million == 100000000, ""); - - } - - namespace test_return_type_deduction - { - - auto f(int& x) { return x; } - decltype(auto) g(int& x) { return x; } - - template < typename T1, typename T2 > - struct is_same - { - static constexpr auto value = false; - }; - - template < typename T > - struct is_same<T, T> - { - static constexpr auto value = true; - }; - - int - test() - { - auto x = 0; - static_assert(is_same<int, decltype(f(x))>::value, ""); - static_assert(is_same<int&, decltype(g(x))>::value, ""); - return x; - } - - } - -} // namespace cxx14 - -#endif // __cplusplus >= 201402L - -]]) - - -dnl Tests for new features in C++17 - -m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ - -// If the compiler admits that it is not ready for C++17, why torture it? -// Hopefully, this will speed up the test. - -#ifndef __cplusplus - -#error "This is not a C++ compiler" - -#elif __cplusplus < 201703L - -#error "This is not a C++17 compiler" - -#else - -#include <initializer_list> -#include <utility> -#include <type_traits> - -namespace cxx17 -{ - - namespace test_constexpr_lambdas - { - - constexpr int foo = [](){return 42;}(); - - } - - namespace test::nested_namespace::definitions - { - - } - - namespace test_fold_expression - { - - template<typename... Args> - int multiply(Args... args) - { - return (args * ... * 1); - } - - template<typename... Args> - bool all(Args... args) - { - return (args && ...); - } - - } - - namespace test_extended_static_assert - { - - static_assert (true); - - } - - namespace test_auto_brace_init_list - { - - auto foo = {5}; - auto bar {5}; - - static_assert(std::is_same<std::initializer_list<int>, decltype(foo)>::value); - static_assert(std::is_same<int, decltype(bar)>::value); - } - - namespace test_typename_in_template_template_parameter - { - - template<template<typename> typename X> struct D; - - } - - namespace test_fallthrough_nodiscard_maybe_unused_attributes - { - - int f1() - { - return 42; - } - - [[nodiscard]] int f2() - { - [[maybe_unused]] auto unused = f1(); - - switch (f1()) - { - case 17: - f1(); - [[fallthrough]]; - case 42: - f1(); - } - return f1(); - } - - } - - namespace test_extended_aggregate_initialization - { - - struct base1 - { - int b1, b2 = 42; - }; - - struct base2 - { - base2() { - b3 = 42; - } - int b3; - }; - - struct derived : base1, base2 - { - int d; - }; - - derived d1 {{1, 2}, {}, 4}; // full initialization - derived d2 {{}, {}, 4}; // value-initialized bases - - } - - namespace test_general_range_based_for_loop - { - - struct iter - { - int i; - - int& operator* () - { - return i; - } - - const int& operator* () const - { - return i; - } - - iter& operator++() - { - ++i; - return *this; - } - }; - - struct sentinel - { - int i; - }; - - bool operator== (const iter& i, const sentinel& s) - { - return i.i == s.i; - } - - bool operator!= (const iter& i, const sentinel& s) - { - return !(i == s); - } - - struct range - { - iter begin() const - { - return {0}; - } - - sentinel end() const - { - return {5}; - } - }; - - void f() - { - range r {}; - - for (auto i : r) - { - [[maybe_unused]] auto v = i; - } - } - - } - - namespace test_lambda_capture_asterisk_this_by_value - { - - struct t - { - int i; - int foo() - { - return [*this]() - { - return i; - }(); - } - }; - - } - - namespace test_enum_class_construction - { - - enum class byte : unsigned char - {}; - - byte foo {42}; - - } - - namespace test_constexpr_if - { - - template <bool cond> - int f () - { - if constexpr(cond) - { - return 13; - } - else - { - return 42; - } - } - - } - - namespace test_selection_statement_with_initializer - { - - int f() - { - return 13; - } - - int f2() - { - if (auto i = f(); i > 0) - { - return 3; - } - - switch (auto i = f(); i + 4) - { - case 17: - return 2; - - default: - return 1; - } - } - - } - - namespace test_template_argument_deduction_for_class_templates - { - - template <typename T1, typename T2> - struct pair - { - pair (T1 p1, T2 p2) - : m1 {p1}, - m2 {p2} - {} - - T1 m1; - T2 m2; - }; - - void f() - { - [[maybe_unused]] auto p = pair{13, 42u}; - } - - } - - namespace test_non_type_auto_template_parameters - { - - template <auto n> - struct B - {}; - - B<5> b1; - B<'a'> b2; - - } - - namespace test_structured_bindings - { - - int arr[2] = { 1, 2 }; - std::pair<int, int> pr = { 1, 2 }; - - auto f1() -> int(&)[2] - { - return arr; - } - - auto f2() -> std::pair<int, int>& - { - return pr; - } - - struct S - { - int x1 : 2; - volatile double y1; - }; - - S f3() - { - return {}; - } - - auto [ x1, y1 ] = f1(); - auto& [ xr1, yr1 ] = f1(); - auto [ x2, y2 ] = f2(); - auto& [ xr2, yr2 ] = f2(); - const auto [ x3, y3 ] = f3(); - - } - - namespace test_exception_spec_type_system - { - - struct Good {}; - struct Bad {}; - - void g1() noexcept; - void g2(); - - template<typename T> - Bad - f(T*, T*); - - template<typename T1, typename T2> - Good - f(T1*, T2*); - - static_assert (std::is_same_v<Good, decltype(f(g1, g2))>); - - } - - namespace test_inline_variables - { - - template<class T> void f(T) - {} - - template<class T> inline T g(T) - { - return T{}; - } - - template<> inline void f<>(int) - {} - - template<> int g<>(int) - { - return 5; - } - - } - -} // namespace cxx17 - -#endif // __cplusplus < 201703L - -]]) diff --git a/contrib/kyua/m4/compiler-features.m4 b/contrib/kyua/m4/compiler-features.m4 deleted file mode 100644 index 840f292383d5..000000000000 --- a/contrib/kyua/m4/compiler-features.m4 +++ /dev/null @@ -1,122 +0,0 @@ -dnl Copyright 2010 The Kyua Authors. -dnl All rights reserved. -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions are -dnl met: -dnl -dnl * Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl * Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. -dnl * Neither the name of Google Inc. nor the names of its contributors -dnl may be used to endorse or promote products derived from this software -dnl without specific prior written permission. -dnl -dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -dnl -dnl KYUA_ATTRIBUTE_NORETURN -dnl -dnl Checks if the current compiler has a way to mark functions that do not -dnl return and defines ATTRIBUTE_NORETURN to the appropriate string. -dnl -AC_DEFUN([KYUA_ATTRIBUTE_NORETURN], [ - dnl This check is overly simple and should be fixed. For example, - dnl Sun's cc does support the noreturn attribute but CC (the C++ - dnl compiler) does not. And in that case, CC just raises a warning - dnl during compilation, not an error. - AC_CACHE_CHECK( - [whether __attribute__((noreturn)) is supported], - [kyua_cv_attribute_noreturn], [ - AC_RUN_IFELSE([AC_LANG_PROGRAM([], [ -#if ((__GNUC__ == 2 && __GNUC_MINOR__ >= 5) || __GNUC__ > 2) - return 0; -#else - return 1; -#endif - ])], - [kyua_cv_attribute_noreturn=yes], - [kyua_cv_attribute_noreturn=no]) - ]) - if test "${kyua_cv_attribute_noreturn}" = yes; then - attribute_value="__attribute__((noreturn))" - else - attribute_value="" - fi - AC_SUBST([ATTRIBUTE_NORETURN], [${attribute_value}]) -]) - - -dnl -dnl KYUA_ATTRIBUTE_PURE -dnl -dnl Checks if the current compiler has a way to mark functions as pure. -dnl -AC_DEFUN([KYUA_ATTRIBUTE_PURE], [ - AC_CACHE_CHECK( - [whether __attribute__((__pure__)) is supported], - [kyua_cv_attribute_pure], [ - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([ -static int function(int, int) __attribute__((__pure__)); - -static int -function(int a, int b) -{ - return a + b; -}], [ - return function(3, 4); -])], - [kyua_cv_attribute_pure=yes], - [kyua_cv_attribute_pure=no]) - ]) - if test "${kyua_cv_attribute_pure}" = yes; then - attribute_value="__attribute__((__pure__))" - else - attribute_value="" - fi - AC_SUBST([ATTRIBUTE_PURE], [${attribute_value}]) -]) - - -dnl -dnl KYUA_ATTRIBUTE_UNUSED -dnl -dnl Checks if the current compiler has a way to mark parameters as unused -dnl so that the -Wunused-parameter warning can be avoided. -dnl -AC_DEFUN([KYUA_ATTRIBUTE_UNUSED], [ - AC_CACHE_CHECK( - [whether __attribute__((__unused__)) is supported], - [kyua_cv_attribute_unused], [ - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([ -static void -function(int a __attribute__((__unused__))) -{ -}], [ - function(3); - return 0; -])], - [kyua_cv_attribute_unused=yes], - [kyua_cv_attribute_unused=no]) - ]) - if test "${kyua_cv_attribute_unused}" = yes; then - attribute_value="__attribute__((__unused__))" - else - attribute_value="" - fi - AC_SUBST([ATTRIBUTE_UNUSED], [${attribute_value}]) -]) diff --git a/contrib/kyua/m4/compiler-flags.m4 b/contrib/kyua/m4/compiler-flags.m4 deleted file mode 100644 index f8dd555118d4..000000000000 --- a/contrib/kyua/m4/compiler-flags.m4 +++ /dev/null @@ -1,169 +0,0 @@ -dnl Copyright 2010 The Kyua Authors. -dnl All rights reserved. -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions are -dnl met: -dnl -dnl * Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl * Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. -dnl * Neither the name of Google Inc. nor the names of its contributors -dnl may be used to endorse or promote products derived from this software -dnl without specific prior written permission. -dnl -dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -dnl \file compiler-flags.m4 -dnl -dnl Macros to check for the existence of compiler flags. The macros in this -dnl file support both C and C++. -dnl -dnl Be aware that, in order to detect a flag accurately, we may need to enable -dnl strict warning checking in the compiler (i.e. enable -Werror). Some -dnl compilers, e.g. Clang, report unknown -W flags as warnings unless -Werror is -dnl selected. This fact would confuse the flag checks below because we would -dnl conclude that a flag is valid while in reality it is not. To resolve this, -dnl the macros below will pass -Werror to the compiler along with any other flag -dnl being checked. - - -dnl Checks for a compiler flag and sets a result variable. -dnl -dnl This is an auxiliary macro for the implementation of _KYUA_FLAG. -dnl -dnl \param 1 The shell variable containing the compiler name. Used for -dnl reporting purposes only. C or CXX. -dnl \param 2 The shell variable containing the flags for the compiler. -dnl CFLAGS or CXXFLAGS. -dnl \param 3 The name of the compiler flag to check for. -dnl \param 4 The shell variable to set with the result of the test. Will -dnl be set to 'yes' if the flag is valid, 'no' otherwise. -dnl \param 5 Additional, optional flags to pass to the C compiler while -dnl looking for the flag in $3. We use this here to pass -Werror to the -dnl flag checks (unless we are checking for -Werror already). -AC_DEFUN([_KYUA_FLAG_AUX], [ - if test x"${$4-unset}" = xunset; then - AC_MSG_CHECKING(whether ${$1} supports $3) - saved_flags="${$2}" - $4=no - $2="${$2} $5 $3" - # The inclusion of a header file in the test program below is needed - # because some compiler flags that we test for may actually not be - # compatible with other flags, and such compatibility checks are - # performed within the system header files. - # - # As an example, if we are testing for -D_FORTIFY_SOURCE=2 and the - # compilation is being done with -O2, Linux's /usr/include/features.h - # will abort the compilation of our code later on. By including a - # generic header file here that pulls in features.h we ensure that - # this test is accurate for the build stage. - AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [return 0;])], - AC_MSG_RESULT(yes) - $4=yes, - AC_MSG_RESULT(no)) - $2="${saved_flags}" - fi -]) - - -dnl Checks for a compiler flag and appends it to a result variable. -dnl -dnl \param 1 The shell variable containing the compiler name. Used for -dnl reporting purposes only. CC or CXX. -dnl \param 2 The shell variable containing the flags for the compiler. -dnl CFLAGS or CXXFLAGS. -dnl \param 3 The name of the compiler flag to check for. -dnl \param 4 The shell variable to which to append $3 if the flag is valid. -AC_DEFUN([_KYUA_FLAG], [ - _KYUA_FLAG_AUX([$1], [$2], [-Werror], [kyua_$1_has_werror]) - if test "$3" = "-Werror"; then - found=${kyua_$1_has_werror} - else - found=unset - if test ${kyua_$1_has_werror} = yes; then - _KYUA_FLAG_AUX([$1], [$2], [$3], [found], [-Werror]) - else - _KYUA_FLAG_AUX([$1], [$2], [$3], [found], []) - fi - fi - if test ${found} = yes; then - $4="${$4} $3" - fi -]) - - -dnl Checks for a C compiler flag and appends it to a variable. -dnl -dnl \pre The current language is C. -dnl -dnl \param 1 The name of the compiler flag to check for. -dnl \param 2 The shell variable to which to append $1 if the flag is valid. -AC_DEFUN([KYUA_CC_FLAG], [ - AC_LANG_ASSERT([C]) - _KYUA_FLAG([CC], [CFLAGS], [$1], [$2]) -]) - - -dnl Checks for a C++ compiler flag and appends it to a variable. -dnl -dnl \pre The current language is C++. -dnl -dnl \param 1 The name of the compiler flag to check for. -dnl \param 2 The shell variable to which to append $1 if the flag is valid. -AC_DEFUN([KYUA_CXX_FLAG], [ - AC_LANG_ASSERT([C++]) - _KYUA_FLAG([CXX], [CXXFLAGS], [$1], [$2]) -]) - - -dnl Checks for a set of C compiler flags and appends them to CFLAGS. -dnl -dnl The checks are performed independently and only when all the checks are -dnl done, the output variable is modified. -dnl -dnl \param 1 Whitespace-separated list of C flags to check. -AC_DEFUN([KYUA_CC_FLAGS], [ - AC_LANG_PUSH([C]) - valid_cflags= - for f in $1; do - KYUA_CC_FLAG(${f}, valid_cflags) - done - if test -n "${valid_cflags}"; then - CFLAGS="${CFLAGS} ${valid_cflags}" - fi - AC_LANG_POP([C]) -]) - - -dnl Checks for a set of C++ compiler flags and appends them to CXXFLAGS. -dnl -dnl The checks are performed independently and only when all the checks are -dnl done, the output variable is modified. -dnl -dnl \pre The current language is C++. -dnl -dnl \param 1 Whitespace-separated list of C flags to check. -AC_DEFUN([KYUA_CXX_FLAGS], [ - AC_LANG_PUSH([C++]) - valid_cxxflags= - for f in $1; do - KYUA_CXX_FLAG(${f}, valid_cxxflags) - done - if test -n "${valid_cxxflags}"; then - CXXFLAGS="${CXXFLAGS} ${valid_cxxflags}" - fi - AC_LANG_POP([C++]) -]) diff --git a/contrib/kyua/m4/developer-mode.m4 b/contrib/kyua/m4/developer-mode.m4 deleted file mode 100644 index ad946056f63c..000000000000 --- a/contrib/kyua/m4/developer-mode.m4 +++ /dev/null @@ -1,112 +0,0 @@ -dnl Copyright 2010 The Kyua Authors. -dnl All rights reserved. -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions are -dnl met: -dnl -dnl * Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl * Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. -dnl * Neither the name of Google Inc. nor the names of its contributors -dnl may be used to endorse or promote products derived from this software -dnl without specific prior written permission. -dnl -dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -dnl \file developer-mode.m4 -dnl -dnl "Developer mode" is a mode in which the build system reports any -dnl build-time warnings as fatal errors. This helps in minimizing the -dnl amount of trivial coding problems introduced in the code. -dnl Unfortunately, this is not bullet-proof due to the wide variety of -dnl compilers available and their different warning diagnostics. -dnl -dnl When developer mode support is added to a package, the compilation will -dnl gain a bunch of extra warning diagnostics. These will NOT be enforced -dnl unless developer mode is enabled. -dnl -dnl Developer mode is enabled when the user requests it through the -dnl configure command line, or when building from the repository. The -dnl latter is to minimize the risk of committing new code with warnings -dnl into the tree. - - -dnl Adds "developer mode" support to the package. -dnl -dnl This macro performs the actual definition of the --enable-developer -dnl flag and implements all of its logic. See the file-level comment for -dnl details as to what this implies. -AC_DEFUN([KYUA_DEVELOPER_MODE], [ - m4_foreach([language], [$1], [m4_set_add([languages], language)]) - - AC_ARG_ENABLE( - [developer], - AS_HELP_STRING([--enable-developer], [enable developer features]),, - [if test -d "${srcdir}/.git"; then - AC_MSG_NOTICE([building from HEAD; developer mode autoenabled]) - enable_developer=yes - else - enable_developer=no - fi]) - - # - # The following warning flags should also be enabled but cannot be. - # Reasons given below. - # - # -Wold-style-cast: Raises errors when using TIOCGWINSZ, at least under - # Mac OS X. This is due to the way _IOR is defined. - # - - try_c_cxx_flags="-D_FORTIFY_SOURCE=2 \ - -Wall \ - -Wcast-qual \ - -Wextra \ - -Wpointer-arith \ - -Wredundant-decls \ - -Wreturn-type \ - -Wshadow \ - -Wsign-compare \ - -Wswitch \ - -Wwrite-strings" - - try_c_flags="-Wmissing-prototypes \ - -Wno-traditional \ - -Wstrict-prototypes" - - try_cxx_flags="-Wabi \ - -Wctor-dtor-privacy \ - -Wno-deprecated \ - -Wno-non-template-friend \ - -Wno-pmf-conversions \ - -Wnon-virtual-dtor \ - -Woverloaded-virtual \ - -Wreorder \ - -Wsign-promo \ - -Wsynth" - - if test ${enable_developer} = yes; then - try_werror=yes - try_c_cxx_flags="${try_c_cxx_flags} -g -Werror" - else - try_werror=no - try_c_cxx_flags="${try_c_cxx_flags} -DNDEBUG" - fi - - m4_set_contains([languages], [C], - [KYUA_CC_FLAGS(${try_c_cxx_flags} ${try_c_flags})]) - m4_set_contains([languages], [C++], - [KYUA_CXX_FLAGS(${try_c_cxx_flags} ${try_cxx_flags})]) -]) diff --git a/contrib/kyua/m4/doxygen.m4 b/contrib/kyua/m4/doxygen.m4 deleted file mode 100644 index 24fd2a408f88..000000000000 --- a/contrib/kyua/m4/doxygen.m4 +++ /dev/null @@ -1,62 +0,0 @@ -dnl Copyright 2010 The Kyua Authors. -dnl All rights reserved. -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions are -dnl met: -dnl -dnl * Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl * Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. -dnl * Neither the name of Google Inc. nor the names of its contributors -dnl may be used to endorse or promote products derived from this software -dnl without specific prior written permission. -dnl -dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -dnl -dnl KYUA_DOXYGEN -dnl -dnl Adds a --with-doxygen flag to the configure script and, when Doxygen support -dnl is requested by the user, sets DOXYGEN to the path of the Doxygen binary and -dnl enables the WITH_DOXYGEN Automake conditional. -dnl -AC_DEFUN([KYUA_DOXYGEN], [ - AC_ARG_WITH([doxygen], - AS_HELP_STRING([--with-doxygen], - [build documentation for internal APIs]), - [], - [with_doxygen=auto]) - - if test "${with_doxygen}" = yes; then - AC_PATH_PROG([DOXYGEN], [doxygen], []) - if test -z "${DOXYGEN}"; then - AC_MSG_ERROR([Doxygen explicitly requested but not found]) - fi - elif test "${with_doxygen}" = auto; then - AC_PATH_PROG([DOXYGEN], [doxygen], []) - elif test "${with_doxygen}" = no; then - DOXYGEN= - else - AC_MSG_CHECKING([for doxygen]) - DOXYGEN="${with_doxygen}" - AC_MSG_RESULT([${DOXYGEN}]) - if test ! -x "${DOXYGEN}"; then - AC_MSG_ERROR([Doxygen binary ${DOXYGEN} is not executable]) - fi - fi - AM_CONDITIONAL([WITH_DOXYGEN], [test -n "${DOXYGEN}"]) - AC_SUBST([DOXYGEN]) -]) diff --git a/contrib/kyua/m4/fs.m4 b/contrib/kyua/m4/fs.m4 deleted file mode 100644 index 7cb103eb1370..000000000000 --- a/contrib/kyua/m4/fs.m4 +++ /dev/null @@ -1,125 +0,0 @@ -dnl Copyright 2011 The Kyua Authors. -dnl All rights reserved. -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions are -dnl met: -dnl -dnl * Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl * Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. -dnl * Neither the name of Google Inc. nor the names of its contributors -dnl may be used to endorse or promote products derived from this software -dnl without specific prior written permission. -dnl -dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -dnl \file m4/fs.m4 -dnl File system related checks. -dnl -dnl The macros in this file check for features required in the utils/fs -dnl module. The global KYUA_FS_MODULE macro will call all checks required -dnl for the library. - - -dnl KYUA_FS_GETCWD_DYN -dnl -dnl Checks whether getcwd(NULL, 0) works; i.e. if getcwd(3) can dynamically -dnl allocate the output buffer to fit the whole current path. -AC_DEFUN([KYUA_FS_GETCWD_DYN], [ - AC_CACHE_CHECK( - [whether getcwd(NULL, 0) works], - [kyua_cv_getcwd_dyn], [ - AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdlib.h> -#include <unistd.h> -], [ - char *cwd = getcwd(NULL, 0); - return (cwd != NULL) ? EXIT_SUCCESS : EXIT_FAILURE; -])], - [kyua_cv_getcwd_dyn=yes], - [kyua_cv_getcwd_dyn=no]) - ]) - if test "${kyua_cv_getcwd_dyn}" = yes; then - AC_DEFINE_UNQUOTED([HAVE_GETCWD_DYN], [1], - [Define to 1 if getcwd(NULL, 0) works]) - fi -]) - - -dnl KYUA_FS_LCHMOD -dnl -dnl Checks whether lchmod(3) exists and if it works. Some systems, such as -dnl Ubuntu 10.04.1 LTS, provide a lchmod(3) stub that is not implemented yet -dnl allows programs to compile cleanly (albeit for a warning). It would be -dnl nice to detect if lchmod(3) works at run time to prevent side-effects of -dnl this test but doing so means we will keep receiving a noisy compiler -dnl warning. -AC_DEFUN([KYUA_FS_LCHMOD], [ - AC_CACHE_CHECK( - [for a working lchmod], - [kyua_cv_lchmod_works], [ - AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <sys/stat.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -], [ - int fd = open("conftest.txt", O_WRONLY | O_CREAT | O_TRUNC, 0644); - if (fd == -1) { - perror("creation of conftest.txt failed"); - return EXIT_FAILURE; - } - - return lchmod("conftest.txt", 0640) != -1 ? EXIT_SUCCESS : EXIT_FAILURE; -])], - [kyua_cv_lchmod_works=yes], - [kyua_cv_lchmod_works=no]) - ]) - rm -f conftest.txt - if test "${kyua_cv_lchmod_works}" = yes; then - AC_DEFINE_UNQUOTED([HAVE_WORKING_LCHMOD], [1], - [Define to 1 if your lchmod works]) - fi -]) - - -dnl KYUA_FS_UNMOUNT -dnl -dnl Detect the correct method to unmount a file system. -AC_DEFUN([KYUA_FS_UNMOUNT], [ - AC_CHECK_FUNCS([unmount], [have_unmount2=yes], [have_unmount2=no]) - if test "${have_unmount2}" = no; then - have_umount8=yes - AC_PATH_PROG([UMOUNT], [umount], [have_umount8=no]) - if test "${have_umount8}" = yes; then - AC_DEFINE_UNQUOTED([UMOUNT], ["${UMOUNT}"], - [Set to the path of umount(8)]) - else - AC_MSG_ERROR([Don't know how to unmount a file system]) - fi - fi -]) - - -dnl KYUA_FS_MODULE -dnl -dnl Performs all checks needed by the utils/fs library. -AC_DEFUN([KYUA_FS_MODULE], [ - AC_CHECK_HEADERS([sys/mount.h sys/statvfs.h sys/vfs.h]) - AC_CHECK_FUNCS([statfs statvfs]) - KYUA_FS_GETCWD_DYN - KYUA_FS_LCHMOD - KYUA_FS_UNMOUNT -]) diff --git a/contrib/kyua/m4/getopt.m4 b/contrib/kyua/m4/getopt.m4 deleted file mode 100644 index f58635330704..000000000000 --- a/contrib/kyua/m4/getopt.m4 +++ /dev/null @@ -1,213 +0,0 @@ -dnl Copyright 2010 The Kyua Authors. -dnl All rights reserved. -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions are -dnl met: -dnl -dnl * Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl * Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. -dnl * Neither the name of Google Inc. nor the names of its contributors -dnl may be used to endorse or promote products derived from this software -dnl without specific prior written permission. -dnl -dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -dnl Checks if getopt(3) supports a + sign to enforce POSIX correctness. -dnl -dnl In the GNU implementation of getopt(3), we need to pass a + sign at -dnl the beginning of the options string to request POSIX behavior. -dnl -dnl Defines HAVE_GETOPT_GNU if a + sign is supported. -AC_DEFUN([_KYUA_GETOPT_GNU], [ - AC_CACHE_CHECK( - [whether getopt allows a + sign for POSIX behavior optreset], - [kyua_cv_getopt_gnu], [ - AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdlib.h> -#include <string.h> -#include <unistd.h>], [ - int argc = 4; - char* argv@<:@5@:>@ = { - strdup("conftest"), - strdup("-+"), - strdup("-a"), - strdup("bar"), - NULL - }; - int ch; - int seen_a = 0, seen_plus = 0; - - while ((ch = getopt(argc, argv, "+a:")) != -1) { - switch (ch) { - case 'a': - seen_a = 1; - break; - - case '+': - seen_plus = 1; - break; - - case '?': - default: - ; - } - } - - return (seen_a && !seen_plus) ? EXIT_SUCCESS : EXIT_FAILURE; -])], - [kyua_cv_getopt_gnu=yes], - [kyua_cv_getopt_gnu=no]) - ]) - if test "${kyua_cv_getopt_gnu}" = yes; then - AC_DEFINE([HAVE_GETOPT_GNU], [1], - [Define to 1 if getopt allows a + sign for POSIX behavior]) - fi -]) - -dnl Checks if optreset exists to reset the processing of getopt(3) options. -dnl -dnl getopt(3) has an optreset global variable to reset internal state -dnl before calling getopt(3) again. However, optreset is not standard and -dnl is only present in the BSD versions of getopt(3). -dnl -dnl Defines HAVE_GETOPT_WITH_OPTRESET if optreset exists. -AC_DEFUN([_KYUA_GETOPT_WITH_OPTRESET], [ - AC_CACHE_CHECK( - [whether getopt has optreset], - [kyua_cv_getopt_optreset], [ - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ -#include <stdlib.h> -#include <unistd.h> - -int -main(void) -{ - optreset = 1; - return EXIT_SUCCESS; -} -])], - [kyua_cv_getopt_optreset=yes], - [kyua_cv_getopt_optreset=no]) - ]) - if test "${kyua_cv_getopt_optreset}" = yes; then - AC_DEFINE([HAVE_GETOPT_WITH_OPTRESET], [1], - [Define to 1 if getopt has optreset]) - fi -]) - - -dnl Checks the value to pass to optind to reset getopt(3) processing. -dnl -dnl The standard value to pass to optind to reset the processing of command -dnl lines with getopt(3) is 1. However, the GNU extensions to getopt_long(3) -dnl are not properly reset unless optind is set to 0, causing crashes later -dnl on and incorrect option processing behavior. -dnl -dnl Sets the GETOPT_OPTIND_RESET_VALUE macro to the integer value that has to -dnl be passed to optind to reset option processing. -AC_DEFUN([_KYUA_GETOPT_OPTIND_RESET_VALUE], [ - AC_CACHE_CHECK( - [for the optind value to reset getopt processing], - [kyua_cv_getopt_optind_reset_value], [ - AC_RUN_IFELSE([AC_LANG_SOURCE([ -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -static void -first_pass(void) -{ - int argc, ch, flag; - char* argv@<:@5@:>@; - - argc = 4; - argv@<:@0@:>@ = strdup("progname"); - argv@<:@1@:>@ = strdup("-a"); - argv@<:@2@:>@ = strdup("foo"); - argv@<:@3@:>@ = strdup("bar"); - argv@<:@4@:>@ = NULL; - - flag = 0; - while ((ch = getopt(argc, argv, "+:a")) != -1) { - switch (ch) { - case 'a': - flag = 1; - break; - default: - break; - } - } - if (!flag) { - exit(EXIT_FAILURE); - } -} - -static void -second_pass(void) -{ - int argc, ch, flag; - char* argv@<:@5@:>@; - - argc = 4; - argv@<:@0@:>@ = strdup("progname"); - argv@<:@1@:>@ = strdup("-b"); - argv@<:@2@:>@ = strdup("foo"); - argv@<:@3@:>@ = strdup("bar"); - argv@<:@4@:>@ = NULL; - - flag = 0; - while ((ch = getopt(argc, argv, "b")) != -1) { - switch (ch) { - case 'b': - flag = 1; - break; - default: - break; - } - } - if (!flag) { - exit(EXIT_FAILURE); - } -} - -int -main(void) -{ - /* We do two passes in two different functions to prevent the reuse of - * variables and, specially, to force the use of two different argument - * vectors. */ - first_pass(); - optind = 0; - second_pass(); - return EXIT_SUCCESS; -} -])], - [kyua_cv_getopt_optind_reset_value=0], - [kyua_cv_getopt_optind_reset_value=1]) - ]) - AC_DEFINE_UNQUOTED([GETOPT_OPTIND_RESET_VALUE], - [${kyua_cv_getopt_optind_reset_value}], - [Define to the optind value to reset getopt processing]) -]) - - -dnl Wrapper macro to detect all getopt(3) necessary features. -AC_DEFUN([KYUA_GETOPT], [ - _KYUA_GETOPT_GNU - _KYUA_GETOPT_OPTIND_RESET_VALUE - _KYUA_GETOPT_WITH_OPTRESET -]) diff --git a/contrib/kyua/m4/memory.m4 b/contrib/kyua/m4/memory.m4 deleted file mode 100644 index 3d9a83a20ab5..000000000000 --- a/contrib/kyua/m4/memory.m4 +++ /dev/null @@ -1,122 +0,0 @@ -dnl Copyright 2012 The Kyua Authors. -dnl All rights reserved. -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions are -dnl met: -dnl -dnl * Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl * Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. -dnl * Neither the name of Google Inc. nor the names of its contributors -dnl may be used to endorse or promote products derived from this software -dnl without specific prior written permission. -dnl -dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -dnl \file m4/memory.m4 -dnl -dnl Macros to configure the utils::memory module. - - -dnl Entry point to detect all features needed by utils::memory. -dnl -dnl This looks for a mechanism to check the available physical memory in the -dnl system. -AC_DEFUN([KYUA_MEMORY], [ - memory_query=unknown - memory_mib=none - - _KYUA_SYSCTLBYNAME([have_sysctlbyname=yes], [have_sysctlbyname=no]) - if test "${have_sysctlbyname}" = yes; then - _KYUA_SYSCTL_MIB([hw.usermem64], [hw_usermem64], - [memory_mib="hw.usermem64"], []) - if test "${memory_mib}" = none; then - _KYUA_SYSCTL_MIB([hw.usermem], [hw_usermem], - [memory_mib="hw.usermem"], []) - fi - if test "${memory_mib}" != none; then - memory_query=sysctlbyname - fi - fi - - if test "${memory_query}" = unknown; then - AC_MSG_WARN([Don't know how to query the amount of physical memory]) - AC_MSG_WARN([The test case's require.memory property will not work]) - fi - - AC_DEFINE_UNQUOTED([MEMORY_QUERY_TYPE], ["${memory_query}"], - [Define to the memory query type]) - AC_DEFINE_UNQUOTED([MEMORY_QUERY_SYSCTL_MIB], ["${memory_mib}"], - [Define to the name of the sysctl MIB]) -]) - - -dnl Detects the availability of the sysctlbyname(3) function. -dnl -dnl \param action_if_found Code to run if the function is found. -dnl \param action_if_not_found Code to run if the function is not found. -AC_DEFUN([_KYUA_SYSCTLBYNAME], [ - AC_CHECK_HEADERS([sys/types.h sys/sysctl.h]) dnl Darwin 11.2 - AC_CHECK_HEADERS([sys/param.h sys/sysctl.h]) dnl NetBSD 6.0 - - AC_CHECK_FUNCS([sysctlbyname], [$1], [$2]) -]) - - -dnl Looks for a specific sysctl MIB. -dnl -dnl \pre sysctlbyname(3) must be present in the system. -dnl -dnl \param mib_name The name of the MIB to check for. -dnl \param flat_mib_name The name of the MIB as a shell variable, for use in -dnl cache variable names. This should be automatically computed with -dnl m4_bpatsubst or similar, but my inability to make the code readable -dnl made me add this parameter instead. -dnl \param action_if_found Code to run if the MIB is found. -dnl \param action_if_not_found Code to run if the MIB is not found. -AC_DEFUN([_KYUA_SYSCTL_MIB], [ - AC_CACHE_CHECK( - [if the $1 sysctl MIB exists], - [kyua_cv_sysctl_$2], [ - AC_RUN_IFELSE([AC_LANG_PROGRAM([ -#if defined(HAVE_SYS_TYPES_H) -# include <sys/types.h> -#endif -#if defined(HAVE_SYS_PARAM_H) -# include <sys/param.h> -#endif -#if defined(HAVE_SYS_SYSCTL_H) -# include <sys/sysctl.h> -#endif -#include <stdint.h> -#include <stdlib.h> -], [ - int64_t memory; - size_t memory_length = sizeof(memory); - if (sysctlbyname("$1", &memory, &memory_length, NULL, 0) == -1) - return EXIT_FAILURE; - else - return EXIT_SUCCESS; -])], - [kyua_cv_sysctl_$2=yes], - [kyua_cv_sysctl_$2=no]) - ]) - if test "${kyua_cv_sysctl_$2}" = yes; then - m4_default([$3], [:]) - else - m4_default([$4], [:]) - fi -]) diff --git a/contrib/kyua/m4/signals.m4 b/contrib/kyua/m4/signals.m4 deleted file mode 100644 index 8e8b56e1eb73..000000000000 --- a/contrib/kyua/m4/signals.m4 +++ /dev/null @@ -1,92 +0,0 @@ -dnl Copyright 2010 The Kyua Authors. -dnl All rights reserved. -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions are -dnl met: -dnl -dnl * Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl * Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. -dnl * Neither the name of Google Inc. nor the names of its contributors -dnl may be used to endorse or promote products derived from this software -dnl without specific prior written permission. -dnl -dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -dnl -dnl KYUA_LAST_SIGNO -dnl -dnl Detect the last valid signal number. -dnl -AC_DEFUN([KYUA_LAST_SIGNO], [ - AC_CACHE_CHECK( - [for the last valid signal], - [kyua_cv_signals_lastno], [ - AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <err.h> -#include <errno.h> -#include <signal.h> -#include <stdio.h> -#include <stdio.h> -#include <stdlib.h>], [ - static const int max_signals = 256; - int i; - FILE *f; - - i = 0; - while (i < max_signals) { - i++; - if (i != SIGKILL && i != SIGSTOP) { - struct sigaction sa; - int ret; - - sa.sa_handler = SIG_DFL; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - - ret = sigaction(i, &sa, NULL); - if (ret == -1) { - warn("sigaction(%d) failed", i); - if (errno == EINVAL) { - i--; - break; - } else - err(EXIT_FAILURE, "sigaction failed"); - } - } - } - if (i == max_signals) - errx(EXIT_FAILURE, "too many signals"); - - f = fopen("conftest.cnt", "w"); - if (f == NULL) - err(EXIT_FAILURE, "failed to open file"); - - fprintf(f, "%d\n", i); - fclose(f); - - return EXIT_SUCCESS; -])], - [if test ! -f conftest.cnt; then - kyua_cv_signals_lastno=15 - else - kyua_cv_signals_lastno=$(cat conftest.cnt) - rm -f conftest.cnt - fi], - [kyua_cv_signals_lastno=15]) - ]) - AC_DEFINE_UNQUOTED([LAST_SIGNO], [${kyua_cv_signals_lastno}], - [Define to the last valid signal number]) -]) diff --git a/contrib/kyua/m4/uname.m4 b/contrib/kyua/m4/uname.m4 deleted file mode 100644 index bcb3d0d39a71..000000000000 --- a/contrib/kyua/m4/uname.m4 +++ /dev/null @@ -1,63 +0,0 @@ -dnl Copyright 2010 The Kyua Authors. -dnl All rights reserved. -dnl -dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions are -dnl met: -dnl -dnl * Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl * Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. -dnl * Neither the name of Google Inc. nor the names of its contributors -dnl may be used to endorse or promote products derived from this software -dnl without specific prior written permission. -dnl -dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -dnl -dnl KYUA_UNAME_ARCHITECTURE -dnl -dnl Checks for the current architecture name (aka processor type) and defines -dnl the KYUA_ARCHITECTURE macro to its value. -dnl -AC_DEFUN([KYUA_UNAME_ARCHITECTURE], [ - AC_MSG_CHECKING([for architecture name]) - AC_ARG_VAR([KYUA_ARCHITECTURE], - [Name of the system architecture (aka processor type)]) - if test x"${KYUA_ARCHITECTURE-unset}" = x"unset"; then - KYUA_ARCHITECTURE="$(uname -p)" - fi - AC_DEFINE_UNQUOTED([KYUA_ARCHITECTURE], "${KYUA_ARCHITECTURE}", - [Name of the system architecture (aka processor type)]) - AC_MSG_RESULT([${KYUA_ARCHITECTURE}]) -]) - -dnl -dnl KYUA_UNAME_PLATFORM -dnl -dnl Checks for the current platform name (aka machine name) and defines -dnl the KYUA_PLATFORM macro to its value. -dnl -AC_DEFUN([KYUA_UNAME_PLATFORM], [ - AC_MSG_CHECKING([for platform name]) - AC_ARG_VAR([KYUA_PLATFORM], - [Name of the system platform (aka machine name)]) - if test x"${KYUA_PLATFORM-unset}" = x"unset"; then - KYUA_PLATFORM="$(uname -m)" - fi - AC_DEFINE_UNQUOTED([KYUA_PLATFORM], "${KYUA_PLATFORM}", - [Name of the system platform (aka machine name)]) - AC_MSG_RESULT([${KYUA_PLATFORM}]) -]) diff --git a/contrib/kyua/misc/Makefile.am.inc b/contrib/kyua/misc/Makefile.am.inc deleted file mode 100644 index e235c7ee364e..000000000000 --- a/contrib/kyua/misc/Makefile.am.inc +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2011 The Kyua Authors. -# 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. - -dist_misc_DATA = misc/context.html -dist_misc_DATA += misc/index.html -dist_misc_DATA += misc/report.css -dist_misc_DATA += misc/test_result.html diff --git a/contrib/kyua/model/Makefile.am.inc b/contrib/kyua/model/Makefile.am.inc deleted file mode 100644 index 2bd33914f680..000000000000 --- a/contrib/kyua/model/Makefile.am.inc +++ /dev/null @@ -1,89 +0,0 @@ -# Copyright 2014 The Kyua Authors. -# 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. - -MODEL_CFLAGS = $(UTILS_CFLAGS) -MODEL_LIBS = libmodel.a $(UTILS_LIBS) - -noinst_LIBRARIES += libmodel.a -libmodel_a_CPPFLAGS = $(UTILS_CFLAGS) -libmodel_a_SOURCES = model/context.cpp -libmodel_a_SOURCES += model/context.hpp -libmodel_a_SOURCES += model/context_fwd.hpp -libmodel_a_SOURCES += model/exceptions.cpp -libmodel_a_SOURCES += model/exceptions.hpp -libmodel_a_SOURCES += model/metadata.cpp -libmodel_a_SOURCES += model/metadata.hpp -libmodel_a_SOURCES += model/metadata_fwd.hpp -libmodel_a_SOURCES += model/test_case.cpp -libmodel_a_SOURCES += model/test_case.hpp -libmodel_a_SOURCES += model/test_case_fwd.hpp -libmodel_a_SOURCES += model/test_program.cpp -libmodel_a_SOURCES += model/test_program.hpp -libmodel_a_SOURCES += model/test_program_fwd.hpp -libmodel_a_SOURCES += model/test_result.cpp -libmodel_a_SOURCES += model/test_result.hpp -libmodel_a_SOURCES += model/test_result_fwd.hpp -libmodel_a_SOURCES += model/types.hpp - -if WITH_ATF -tests_modeldir = $(pkgtestsdir)/model - -tests_model_DATA = model/Kyuafile -EXTRA_DIST += $(tests_model_DATA) - -tests_model_PROGRAMS = model/context_test -model_context_test_SOURCES = model/context_test.cpp -model_context_test_CXXFLAGS = $(MODEL_CFLAGS) $(ATF_CXX_CFLAGS) -model_context_test_LDADD = $(MODEL_LIBS) $(ATF_CXX_LIBS) - -tests_model_PROGRAMS += model/exceptions_test -model_exceptions_test_SOURCES = model/exceptions_test.cpp -model_exceptions_test_CXXFLAGS = $(MODEL_CFLAGS) $(ATF_CXX_CFLAGS) -model_exceptions_test_LDADD = $(MODEL_LIBS) $(ATF_CXX_LIBS) - -tests_model_PROGRAMS += model/metadata_test -model_metadata_test_SOURCES = model/metadata_test.cpp -model_metadata_test_CXXFLAGS = $(MODEL_CFLAGS) $(ATF_CXX_CFLAGS) -model_metadata_test_LDADD = $(MODEL_LIBS) $(ATF_CXX_LIBS) - -tests_model_PROGRAMS += model/test_case_test -model_test_case_test_SOURCES = model/test_case_test.cpp -model_test_case_test_CXXFLAGS = $(MODEL_CFLAGS) $(ATF_CXX_CFLAGS) -model_test_case_test_LDADD = $(MODEL_LIBS) $(ATF_CXX_LIBS) - -tests_model_PROGRAMS += model/test_program_test -model_test_program_test_SOURCES = model/test_program_test.cpp -model_test_program_test_CXXFLAGS = $(MODEL_CFLAGS) $(ATF_CXX_CFLAGS) -model_test_program_test_LDADD = $(MODEL_LIBS) $(ATF_CXX_LIBS) - -tests_model_PROGRAMS += model/test_result_test -model_test_result_test_SOURCES = model/test_result_test.cpp -model_test_result_test_CXXFLAGS = $(MODEL_CFLAGS) $(ATF_CXX_CFLAGS) -model_test_result_test_LDADD = $(MODEL_LIBS) $(ATF_CXX_LIBS) - -endif diff --git a/contrib/kyua/model/README b/contrib/kyua/model/README deleted file mode 100644 index cf13a82b7338..000000000000 --- a/contrib/kyua/model/README +++ /dev/null @@ -1,11 +0,0 @@ -This directory contains the classes that form the data model of Kyua. - -The classes in this directory are intended to be pure data types without -any complex logic. As such, they are simple containers and support the -common operations you would expect from them: in particular, comparisons -and formatting for debugging purposes. - -All the classes in the data model have to have an on-disk representation -provided by the store module; if they don't, they don't belong in the -model. Some of these classes may also have special behavior at run-time, -and this is provided by the engine module. diff --git a/contrib/kyua/model/metadata.cpp b/contrib/kyua/model/metadata.cpp index 708a01667bbb..8bb071163c10 100644 --- a/contrib/kyua/model/metadata.cpp +++ b/contrib/kyua/model/metadata.cpp @@ -30,7 +30,7 @@ #include <memory> -#include "engine/execenv/execenv.hpp" +#include "engine/execenv/execenv_fwd.hpp" #include "model/exceptions.hpp" #include "model/types.hpp" #include "utils/config/exceptions.hpp" @@ -255,8 +255,8 @@ init_tree(config::tree& tree) tree.define< config::strings_set_node >("required_configs"); tree.define< bytes_node >("required_disk_space"); tree.define< paths_set_node >("required_files"); - tree.define< config::strings_set_node >("required_kmods"); tree.define< bytes_node >("required_memory"); + tree.define< config::strings_set_node >("required_kmods"); tree.define< paths_set_node >("required_programs"); tree.define< user_node >("required_user"); tree.define< delta_node >("timeout"); @@ -282,8 +282,8 @@ set_defaults(config::tree& tree) model::strings_set()); tree.set< bytes_node >("required_disk_space", units::bytes(0)); tree.set< paths_set_node >("required_files", model::paths_set()); - tree.set< config::strings_set_node >("required_kmods", model::strings_set()); tree.set< bytes_node >("required_memory", units::bytes(0)); + tree.set< config::strings_set_node >("required_kmods", model::strings_set()); tree.set< paths_set_node >("required_programs", model::paths_set()); tree.set< user_node >("required_user", ""); // TODO(jmmv): We shouldn't be setting a default timeout like this. See @@ -522,7 +522,7 @@ bool model::metadata::has_execenv(void) const { const std::string& name = execenv(); - return !name.empty() && name != engine::execenv::default_execenv_name; + return !name.empty() && name != DEFAULT_EXECENV_NAME; } @@ -585,6 +585,20 @@ model::metadata::required_files(void) const } +/// Returns the amount of memory required by the test. +/// +/// \return Number of bytes, or 0 if this does not apply. +const units::bytes& +model::metadata::required_memory(void) const +{ + if (_pimpl->props.is_set("required_memory")) { + return _pimpl->props.lookup< bytes_node >("required_memory"); + } else { + return get_defaults().lookup< bytes_node >("required_memory"); + } +} + + /// Returns the list of kernel modules needed by the test. /// /// \return Set of kernel module names. @@ -601,20 +615,6 @@ model::metadata::required_kmods(void) const } -/// Returns the amount of memory required by the test. -/// -/// \return Number of bytes, or 0 if this does not apply. -const units::bytes& -model::metadata::required_memory(void) const -{ - if (_pimpl->props.is_set("required_memory")) { - return _pimpl->props.lookup< bytes_node >("required_memory"); - } else { - return get_defaults().lookup< bytes_node >("required_memory"); - } -} - - /// Returns the list of programs needed by the test. /// /// \return Set of paths. @@ -1059,21 +1059,6 @@ model::metadata_builder::set_required_files(const model::paths_set& files) } -/// Sets the list of required kernel modules. -/// -/// \param vars Set of kernel module names. -/// -/// \return A reference to this builder. -/// -/// \throw model::error If the value is invalid. -model::metadata_builder& -model::metadata_builder::set_required_kmods(const model::strings_set& kmods) -{ - set< config::strings_set_node >(_pimpl->props, "required_kmods", kmods); - return *this; -} - - /// Sets the amount of memory required by the test. /// /// \param bytes Number of bytes. diff --git a/contrib/kyua/os/freebsd/execenv_jail.hpp b/contrib/kyua/os/freebsd/execenv_jail.hpp index e6d2c2e42497..73365316dae1 100644 --- a/contrib/kyua/os/freebsd/execenv_jail.hpp +++ b/contrib/kyua/os/freebsd/execenv_jail.hpp @@ -56,7 +56,7 @@ public: void init() const; void cleanup() const; - void exec(const args_vector& args) const UTILS_NORETURN; + void exec [[noreturn]] (const args_vector& args) const; }; diff --git a/contrib/kyua/os/freebsd/execenv_jail_stub.cpp b/contrib/kyua/os/freebsd/execenv_jail_stub.cpp index 9425618e2b5a..4634f4ef80c9 100644 --- a/contrib/kyua/os/freebsd/execenv_jail_stub.cpp +++ b/contrib/kyua/os/freebsd/execenv_jail_stub.cpp @@ -35,7 +35,7 @@ using utils::process::args_vector; -static inline void requires_freebsd(void) UTILS_NORETURN; +static inline void requires_freebsd [[noreturn]] (void); static inline void requires_freebsd(void) diff --git a/contrib/kyua/os/freebsd/main.cpp b/contrib/kyua/os/freebsd/main.cpp index 30f1a3fa7142..700284b64b78 100644 --- a/contrib/kyua/os/freebsd/main.cpp +++ b/contrib/kyua/os/freebsd/main.cpp @@ -34,12 +34,7 @@ #include "engine/requirements.hpp" #include "os/freebsd/reqs_checker_kmods.hpp" -#include "engine/prepare/prepare.hpp" -#include "os/freebsd/prepare_kmods.hpp" - namespace execenv = engine::execenv; -namespace prepare = engine::prepare; - /// FreeBSD related features initialization. /// @@ -64,9 +59,6 @@ freebsd::main(const int, const char* const* const) new freebsd::reqs_checker_kmods() ) ); - - prepare::register_handler( - std::shared_ptr< prepare::handler >(new freebsd::prepare_kmods())); #endif return 0; diff --git a/contrib/kyua/os/freebsd/reqs_checker_kmods.cpp b/contrib/kyua/os/freebsd/reqs_checker_kmods.cpp index 3ae3446a7815..ce17caeaeb8d 100644 --- a/contrib/kyua/os/freebsd/reqs_checker_kmods.cpp +++ b/contrib/kyua/os/freebsd/reqs_checker_kmods.cpp @@ -31,7 +31,7 @@ #include "model/metadata.hpp" extern "C" { -#include "libutil.h" +#include <libutil.h> } std::string diff --git a/contrib/kyua/os/freebsd/utils/jail.hpp b/contrib/kyua/os/freebsd/utils/jail.hpp index 5b972155cd25..44730493a7d0 100644 --- a/contrib/kyua/os/freebsd/utils/jail.hpp +++ b/contrib/kyua/os/freebsd/utils/jail.hpp @@ -51,9 +51,10 @@ public: const std::string& test_case_name); void create(const std::string& jail_name, const std::string& jail_params); - void exec(const std::string& jail_name, - const fs::path& program, - const args_vector& args) throw() UTILS_NORETURN; + void exec [[noreturn]] ( + const std::string& jail_name, + const fs::path& program, + const args_vector& args) throw(); void remove(const std::string& jail_name); }; diff --git a/contrib/kyua/store/Makefile.am.inc b/contrib/kyua/store/Makefile.am.inc deleted file mode 100644 index 13c7c70a10d9..000000000000 --- a/contrib/kyua/store/Makefile.am.inc +++ /dev/null @@ -1,145 +0,0 @@ -# Copyright 2010 The Kyua Authors. -# 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. - -STORE_CFLAGS = $(MODEL_CFLAGS) $(UTILS_CFLAGS) -STORE_LIBS = libstore.a $(MODEL_LIBS) $(UTILS_LIBS) - -noinst_LIBRARIES += libstore.a -libstore_a_CPPFLAGS = -DKYUA_STOREDIR=\"$(storedir)\" -libstore_a_CPPFLAGS += $(UTILS_CFLAGS) -libstore_a_SOURCES = store/dbtypes.cpp -libstore_a_SOURCES += store/dbtypes.hpp -libstore_a_SOURCES += store/exceptions.cpp -libstore_a_SOURCES += store/exceptions.hpp -libstore_a_SOURCES += store/layout.cpp -libstore_a_SOURCES += store/layout.hpp -libstore_a_SOURCES += store/layout_fwd.hpp -libstore_a_SOURCES += store/metadata.cpp -libstore_a_SOURCES += store/metadata.hpp -libstore_a_SOURCES += store/metadata_fwd.hpp -libstore_a_SOURCES += store/migrate.cpp -libstore_a_SOURCES += store/migrate.hpp -libstore_a_SOURCES += store/read_backend.cpp -libstore_a_SOURCES += store/read_backend.hpp -libstore_a_SOURCES += store/read_backend_fwd.hpp -libstore_a_SOURCES += store/read_transaction.cpp -libstore_a_SOURCES += store/read_transaction.hpp -libstore_a_SOURCES += store/read_transaction_fwd.hpp -libstore_a_SOURCES += store/write_backend.cpp -libstore_a_SOURCES += store/write_backend.hpp -libstore_a_SOURCES += store/write_backend_fwd.hpp -libstore_a_SOURCES += store/write_transaction.cpp -libstore_a_SOURCES += store/write_transaction.hpp -libstore_a_SOURCES += store/write_transaction_fwd.hpp - -dist_store_DATA = store/migrate_v1_v2.sql -dist_store_DATA += store/migrate_v2_v3.sql -dist_store_DATA += store/schema_v3.sql - -if WITH_ATF -tests_storedir = $(pkgtestsdir)/store - -tests_store_DATA = store/Kyuafile -tests_store_DATA += store/schema_v1.sql -tests_store_DATA += store/schema_v2.sql -tests_store_DATA += store/testdata_v1.sql -tests_store_DATA += store/testdata_v2.sql -tests_store_DATA += store/testdata_v3_1.sql -tests_store_DATA += store/testdata_v3_2.sql -tests_store_DATA += store/testdata_v3_3.sql -tests_store_DATA += store/testdata_v3_4.sql -EXTRA_DIST += $(tests_store_DATA) - -tests_store_PROGRAMS = store/dbtypes_test -store_dbtypes_test_SOURCES = store/dbtypes_test.cpp -store_dbtypes_test_CXXFLAGS = $(STORE_CFLAGS) $(ENGINE_CFLAGS) \ - $(ATF_CXX_CFLAGS) -store_dbtypes_test_LDADD = $(STORE_LIBS) $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_store_PROGRAMS += store/exceptions_test -store_exceptions_test_SOURCES = store/exceptions_test.cpp -store_exceptions_test_CXXFLAGS = $(STORE_CFLAGS) $(ENGINE_CFLAGS) \ - $(ATF_CXX_CFLAGS) -store_exceptions_test_LDADD = $(STORE_LIBS) $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_store_PROGRAMS += store/layout_test -store_layout_test_SOURCES = store/layout_test.cpp -store_layout_test_CXXFLAGS = $(STORE_CFLAGS) $(ENGINE_CFLAGS) $(ATF_CXX_CFLAGS) -store_layout_test_LDADD = $(STORE_LIBS) $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_store_PROGRAMS += store/metadata_test -store_metadata_test_SOURCES = store/metadata_test.cpp -store_metadata_test_CXXFLAGS = $(STORE_CFLAGS) $(ENGINE_CFLAGS) \ - $(ATF_CXX_CFLAGS) -store_metadata_test_LDADD = $(STORE_LIBS) $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_store_PROGRAMS += store/migrate_test -store_migrate_test_SOURCES = store/migrate_test.cpp -store_migrate_test_CPPFLAGS = -DKYUA_STOREDIR=\"$(storedir)\" -store_migrate_test_CXXFLAGS = $(STORE_CFLAGS) $(ENGINE_CFLAGS) $(ATF_CXX_CFLAGS) -store_migrate_test_LDADD = $(STORE_LIBS) $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_store_PROGRAMS += store/read_backend_test -store_read_backend_test_SOURCES = store/read_backend_test.cpp -store_read_backend_test_CXXFLAGS = $(STORE_CFLAGS) $(ENGINE_CFLAGS) \ - $(ATF_CXX_CFLAGS) -store_read_backend_test_LDADD = $(STORE_LIBS) $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_store_PROGRAMS += store/read_transaction_test -store_read_transaction_test_SOURCES = store/read_transaction_test.cpp -store_read_transaction_test_CXXFLAGS = $(STORE_CFLAGS) $(ENGINE_CFLAGS) \ - $(ATF_CXX_CFLAGS) -store_read_transaction_test_LDADD = $(STORE_LIBS) $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_store_PROGRAMS += store/schema_inttest -store_schema_inttest_SOURCES = store/schema_inttest.cpp -store_schema_inttest_CPPFLAGS = -DKYUA_STORETESTDATADIR=\"$(tests_storedir)\" -store_schema_inttest_CXXFLAGS = $(STORE_CFLAGS) $(ENGINE_CFLAGS) \ - $(ATF_CXX_CFLAGS) -store_schema_inttest_LDADD = $(STORE_LIBS) $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_store_PROGRAMS += store/transaction_test -store_transaction_test_SOURCES = store/transaction_test.cpp -store_transaction_test_CXXFLAGS = $(STORE_CFLAGS) $(ENGINE_CFLAGS) \ - $(ATF_CXX_CFLAGS) -store_transaction_test_LDADD = $(STORE_LIBS) $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_store_PROGRAMS += store/write_backend_test -store_write_backend_test_SOURCES = store/write_backend_test.cpp -store_write_backend_test_CPPFLAGS = -DKYUA_STOREDIR=\"$(storedir)\" -store_write_backend_test_CXXFLAGS = $(STORE_CFLAGS) $(ENGINE_CFLAGS) \ - $(ATF_CXX_CFLAGS) -store_write_backend_test_LDADD = $(STORE_LIBS) $(ENGINE_LIBS) $(ATF_CXX_LIBS) - -tests_store_PROGRAMS += store/write_transaction_test -store_write_transaction_test_SOURCES = store/write_transaction_test.cpp -store_write_transaction_test_CXXFLAGS = $(STORE_CFLAGS) $(ENGINE_CFLAGS) \ - $(ATF_CXX_CFLAGS) -store_write_transaction_test_LDADD = $(STORE_LIBS) $(ENGINE_LIBS) \ - $(ATF_CXX_LIBS) -endif diff --git a/contrib/kyua/store/write_transaction_test.cpp b/contrib/kyua/store/write_transaction_test.cpp index 984e328dcdae..1ddb8b0f92c3 100644 --- a/contrib/kyua/store/write_transaction_test.cpp +++ b/contrib/kyua/store/write_transaction_test.cpp @@ -137,7 +137,7 @@ ATF_TEST_CASE_BODY(commit__fail) backend.database().exec( "CREATE TABLE foo (" "a REFERENCES env_vars(var_name) DEFERRABLE INITIALLY DEFERRED)"); - backend.database().exec("INSERT INTO foo VALUES (\"WHAT\")"); + backend.database().exec("INSERT INTO foo VALUES ('WHAT')"); ATF_REQUIRE_THROW(store::error, tx.commit()); } // If the code attempts to maintain any state regarding the already-put diff --git a/contrib/kyua/utils/.gitignore b/contrib/kyua/utils/.gitignore deleted file mode 100644 index b33d720f27a4..000000000000 --- a/contrib/kyua/utils/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -defs.hpp -stacktrace_helper diff --git a/contrib/kyua/utils/Makefile.am.inc b/contrib/kyua/utils/Makefile.am.inc deleted file mode 100644 index d6690bdbecde..000000000000 --- a/contrib/kyua/utils/Makefile.am.inc +++ /dev/null @@ -1,133 +0,0 @@ -# Copyright 2010 The Kyua Authors. -# 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. - -UTILS_CFLAGS = -UTILS_LIBS = libutils.a - -noinst_LIBRARIES += libutils.a -libutils_a_CPPFLAGS = -DGDB=\"$(GDB)\" -libutils_a_SOURCES = utils/auto_array.hpp -libutils_a_SOURCES += utils/auto_array.ipp -libutils_a_SOURCES += utils/auto_array_fwd.hpp -libutils_a_SOURCES += utils/datetime.cpp -libutils_a_SOURCES += utils/datetime.hpp -libutils_a_SOURCES += utils/datetime_fwd.hpp -libutils_a_SOURCES += utils/env.hpp -libutils_a_SOURCES += utils/env.cpp -libutils_a_SOURCES += utils/memory.hpp -libutils_a_SOURCES += utils/memory.cpp -libutils_a_SOURCES += utils/noncopyable.hpp -libutils_a_SOURCES += utils/optional.hpp -libutils_a_SOURCES += utils/optional_fwd.hpp -libutils_a_SOURCES += utils/optional.ipp -libutils_a_SOURCES += utils/passwd.cpp -libutils_a_SOURCES += utils/passwd.hpp -libutils_a_SOURCES += utils/passwd_fwd.hpp -libutils_a_SOURCES += utils/sanity.cpp -libutils_a_SOURCES += utils/sanity.hpp -libutils_a_SOURCES += utils/sanity_fwd.hpp -libutils_a_SOURCES += utils/stacktrace.cpp -libutils_a_SOURCES += utils/stacktrace.hpp -libutils_a_SOURCES += utils/stream.cpp -libutils_a_SOURCES += utils/stream.hpp -libutils_a_SOURCES += utils/units.cpp -libutils_a_SOURCES += utils/units.hpp -libutils_a_SOURCES += utils/units_fwd.hpp -nodist_libutils_a_SOURCES = utils/defs.hpp - -EXTRA_DIST += utils/test_utils.ipp - -if WITH_ATF -tests_utilsdir = $(pkgtestsdir)/utils - -tests_utils_DATA = utils/Kyuafile -EXTRA_DIST += $(tests_utils_DATA) - -tests_utils_PROGRAMS = utils/auto_array_test -utils_auto_array_test_SOURCES = utils/auto_array_test.cpp -utils_auto_array_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_auto_array_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_PROGRAMS += utils/datetime_test -utils_datetime_test_SOURCES = utils/datetime_test.cpp -utils_datetime_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_datetime_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_PROGRAMS += utils/env_test -utils_env_test_SOURCES = utils/env_test.cpp -utils_env_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_env_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_PROGRAMS += utils/memory_test -utils_memory_test_SOURCES = utils/memory_test.cpp -utils_memory_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_memory_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_PROGRAMS += utils/optional_test -utils_optional_test_SOURCES = utils/optional_test.cpp -utils_optional_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_optional_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_PROGRAMS += utils/passwd_test -utils_passwd_test_SOURCES = utils/passwd_test.cpp -utils_passwd_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_passwd_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_PROGRAMS += utils/sanity_test -utils_sanity_test_SOURCES = utils/sanity_test.cpp -utils_sanity_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_sanity_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_PROGRAMS += utils/stacktrace_helper -utils_stacktrace_helper_SOURCES = utils/stacktrace_helper.cpp - -tests_utils_PROGRAMS += utils/stacktrace_test -utils_stacktrace_test_SOURCES = utils/stacktrace_test.cpp -utils_stacktrace_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_stacktrace_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_PROGRAMS += utils/stream_test -utils_stream_test_SOURCES = utils/stream_test.cpp -utils_stream_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_stream_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_PROGRAMS += utils/units_test -utils_units_test_SOURCES = utils/units_test.cpp -utils_units_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_units_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) -endif - -include utils/cmdline/Makefile.am.inc -include utils/config/Makefile.am.inc -include utils/format/Makefile.am.inc -include utils/fs/Makefile.am.inc -include utils/logging/Makefile.am.inc -include utils/process/Makefile.am.inc -include utils/signals/Makefile.am.inc -include utils/sqlite/Makefile.am.inc -include utils/text/Makefile.am.inc diff --git a/contrib/kyua/utils/cmdline/Makefile.am.inc b/contrib/kyua/utils/cmdline/Makefile.am.inc deleted file mode 100644 index 65081cbeafee..000000000000 --- a/contrib/kyua/utils/cmdline/Makefile.am.inc +++ /dev/null @@ -1,96 +0,0 @@ -# Copyright 2010 The Kyua Authors. -# 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. - -libutils_a_SOURCES += utils/cmdline/base_command.cpp -libutils_a_SOURCES += utils/cmdline/base_command.hpp -libutils_a_SOURCES += utils/cmdline/base_command_fwd.hpp -libutils_a_SOURCES += utils/cmdline/base_command.ipp -libutils_a_SOURCES += utils/cmdline/commands_map.hpp -libutils_a_SOURCES += utils/cmdline/commands_map_fwd.hpp -libutils_a_SOURCES += utils/cmdline/commands_map.ipp -libutils_a_SOURCES += utils/cmdline/exceptions.cpp -libutils_a_SOURCES += utils/cmdline/exceptions.hpp -libutils_a_SOURCES += utils/cmdline/globals.cpp -libutils_a_SOURCES += utils/cmdline/globals.hpp -libutils_a_SOURCES += utils/cmdline/options.cpp -libutils_a_SOURCES += utils/cmdline/options.hpp -libutils_a_SOURCES += utils/cmdline/options_fwd.hpp -libutils_a_SOURCES += utils/cmdline/parser.cpp -libutils_a_SOURCES += utils/cmdline/parser.hpp -libutils_a_SOURCES += utils/cmdline/parser_fwd.hpp -libutils_a_SOURCES += utils/cmdline/parser.ipp -libutils_a_SOURCES += utils/cmdline/ui.cpp -libutils_a_SOURCES += utils/cmdline/ui.hpp -libutils_a_SOURCES += utils/cmdline/ui_fwd.hpp -# The following two files are only supposed to be used from test code. They -# should not be bundled into libutils.a, but doing so simplifies the build -# significantly. -libutils_a_SOURCES += utils/cmdline/ui_mock.hpp -libutils_a_SOURCES += utils/cmdline/ui_mock.cpp - -if WITH_ATF -tests_utils_cmdlinedir = $(pkgtestsdir)/utils/cmdline - -tests_utils_cmdline_DATA = utils/cmdline/Kyuafile -EXTRA_DIST += $(tests_utils_cmdline_DATA) - -tests_utils_cmdline_PROGRAMS = utils/cmdline/base_command_test -utils_cmdline_base_command_test_SOURCES = utils/cmdline/base_command_test.cpp -utils_cmdline_base_command_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_cmdline_base_command_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_cmdline_PROGRAMS += utils/cmdline/commands_map_test -utils_cmdline_commands_map_test_SOURCES = utils/cmdline/commands_map_test.cpp -utils_cmdline_commands_map_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_cmdline_commands_map_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_cmdline_PROGRAMS += utils/cmdline/exceptions_test -utils_cmdline_exceptions_test_SOURCES = utils/cmdline/exceptions_test.cpp -utils_cmdline_exceptions_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_cmdline_exceptions_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_cmdline_PROGRAMS += utils/cmdline/globals_test -utils_cmdline_globals_test_SOURCES = utils/cmdline/globals_test.cpp -utils_cmdline_globals_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_cmdline_globals_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_cmdline_PROGRAMS += utils/cmdline/options_test -utils_cmdline_options_test_SOURCES = utils/cmdline/options_test.cpp -utils_cmdline_options_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_cmdline_options_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_cmdline_PROGRAMS += utils/cmdline/parser_test -utils_cmdline_parser_test_SOURCES = utils/cmdline/parser_test.cpp -utils_cmdline_parser_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_cmdline_parser_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_cmdline_PROGRAMS += utils/cmdline/ui_test -utils_cmdline_ui_test_SOURCES = utils/cmdline/ui_test.cpp -utils_cmdline_ui_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_cmdline_ui_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) -endif diff --git a/contrib/kyua/utils/config/Makefile.am.inc b/contrib/kyua/utils/config/Makefile.am.inc deleted file mode 100644 index 7c276ec4e798..000000000000 --- a/contrib/kyua/utils/config/Makefile.am.inc +++ /dev/null @@ -1,87 +0,0 @@ -# Copyright 2012 The Kyua Authors. -# 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. - -UTILS_CFLAGS += $(LUTOK_CFLAGS) -UTILS_LIBS += $(LUTOK_LIBS) - -libutils_a_CPPFLAGS += $(LUTOK_CFLAGS) -libutils_a_SOURCES += utils/config/exceptions.cpp -libutils_a_SOURCES += utils/config/exceptions.hpp -libutils_a_SOURCES += utils/config/keys.cpp -libutils_a_SOURCES += utils/config/keys.hpp -libutils_a_SOURCES += utils/config/keys_fwd.hpp -libutils_a_SOURCES += utils/config/lua_module.cpp -libutils_a_SOURCES += utils/config/lua_module.hpp -libutils_a_SOURCES += utils/config/nodes.cpp -libutils_a_SOURCES += utils/config/nodes.hpp -libutils_a_SOURCES += utils/config/nodes.ipp -libutils_a_SOURCES += utils/config/nodes_fwd.hpp -libutils_a_SOURCES += utils/config/parser.cpp -libutils_a_SOURCES += utils/config/parser.hpp -libutils_a_SOURCES += utils/config/parser_fwd.hpp -libutils_a_SOURCES += utils/config/tree.cpp -libutils_a_SOURCES += utils/config/tree.hpp -libutils_a_SOURCES += utils/config/tree.ipp -libutils_a_SOURCES += utils/config/tree_fwd.hpp - -if WITH_ATF -tests_utils_configdir = $(pkgtestsdir)/utils/config - -tests_utils_config_DATA = utils/config/Kyuafile -EXTRA_DIST += $(tests_utils_config_DATA) - -tests_utils_config_PROGRAMS = utils/config/exceptions_test -utils_config_exceptions_test_SOURCES = utils/config/exceptions_test.cpp -utils_config_exceptions_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_config_exceptions_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_config_PROGRAMS += utils/config/keys_test -utils_config_keys_test_SOURCES = utils/config/keys_test.cpp -utils_config_keys_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_config_keys_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_config_PROGRAMS += utils/config/lua_module_test -utils_config_lua_module_test_SOURCES = utils/config/lua_module_test.cpp -utils_config_lua_module_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_config_lua_module_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_config_PROGRAMS += utils/config/nodes_test -utils_config_nodes_test_SOURCES = utils/config/nodes_test.cpp -utils_config_nodes_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_config_nodes_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_config_PROGRAMS += utils/config/parser_test -utils_config_parser_test_SOURCES = utils/config/parser_test.cpp -utils_config_parser_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_config_parser_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_config_PROGRAMS += utils/config/tree_test -utils_config_tree_test_SOURCES = utils/config/tree_test.cpp -utils_config_tree_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_config_tree_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) -endif diff --git a/contrib/kyua/utils/config/nodes.cpp b/contrib/kyua/utils/config/nodes.cpp index 2747c11989ad..a257a69c347b 100644 --- a/contrib/kyua/utils/config/nodes.cpp +++ b/contrib/kyua/utils/config/nodes.cpp @@ -153,7 +153,7 @@ config::detail::inner_node::combine_into(const tree_key& key, } catch (const std::bad_cast& unused_e) { throw config::bad_combination_error( key, "'%s' is an inner node in the base tree but a leaf node in " - "the overrides treee"); + "the overrides tree"); } } @@ -227,8 +227,10 @@ config::detail::inner_node::lookup_rw(const tree_key& key, if (child_iter == _children.end()) { if (_dynamic) { base_node* const child = (key_pos == key.size() - 1) ? - static_cast< base_node* >(new_node()) : - static_cast< base_node* >(new dynamic_inner_node()); + dynamic_cast< base_node* >(new_node()) : + dynamic_cast< base_node* >(new dynamic_inner_node()); + // The types for `new_node` + INV_MSG(child != nullptr, "check the return type for the function called"); _children.insert(children_map::value_type(key[key_pos], child)); child_iter = _children.find(key[key_pos]); } else { @@ -530,6 +532,18 @@ config::positive_int_node::validate(const value_type& new_value) const /// /// \return A dynamically-allocated node. config::detail::base_node* +config::positive_int_node::deep_copy(void) const +{ + std::unique_ptr< positive_int_node > new_node(new positive_int_node()); + new_node->_value = _value; + return new_node.release(); +} + + +/// Copies the node. +/// +/// \return A dynamically-allocated node. +config::detail::base_node* config::string_node::deep_copy(void) const { std::unique_ptr< string_node > new_node(new string_node()); diff --git a/contrib/kyua/utils/config/nodes.hpp b/contrib/kyua/utils/config/nodes.hpp index 6b766ff5d8f7..0d64cbda9d4e 100644 --- a/contrib/kyua/utils/config/nodes.hpp +++ b/contrib/kyua/utils/config/nodes.hpp @@ -181,6 +181,8 @@ public: /// A leaf node that holds a positive non-zero integer value. class positive_int_node : public int_node { virtual void validate(const value_type&) const; +public: + virtual base_node* deep_copy(void) const; }; diff --git a/contrib/kyua/utils/config/nodes_test.cpp b/contrib/kyua/utils/config/nodes_test.cpp index e762d3aac38c..1bc3ad743db6 100644 --- a/contrib/kyua/utils/config/nodes_test.cpp +++ b/contrib/kyua/utils/config/nodes_test.cpp @@ -85,7 +85,8 @@ ATF_TEST_CASE_BODY(bool_node__deep_copy) config::bool_node node; node.set(true); config::detail::base_node* raw_copy = node.deep_copy(); - config::bool_node* copy = static_cast< config::bool_node* >(raw_copy); + config::bool_node* copy = dynamic_cast< config::bool_node* >(raw_copy); + ATF_REQUIRE(copy != nullptr); ATF_REQUIRE(copy->value()); copy->set(false); ATF_REQUIRE(node.value()); @@ -192,7 +193,8 @@ ATF_TEST_CASE_BODY(int_node__deep_copy) config::int_node node; node.set(5); config::detail::base_node* raw_copy = node.deep_copy(); - config::int_node* copy = static_cast< config::int_node* >(raw_copy); + config::int_node* copy = dynamic_cast< config::int_node* >(raw_copy); + ATF_REQUIRE(copy != nullptr); ATF_REQUIRE_EQ(5, copy->value()); copy->set(10); ATF_REQUIRE_EQ(5, node.value()); @@ -302,8 +304,9 @@ ATF_TEST_CASE_BODY(positive_int_node__deep_copy) config::positive_int_node node; node.set(5); config::detail::base_node* raw_copy = node.deep_copy(); - config::positive_int_node* copy = static_cast< config::positive_int_node* >( + config::positive_int_node* copy = dynamic_cast< config::positive_int_node* >( raw_copy); + ATF_REQUIRE(copy != nullptr); ATF_REQUIRE_EQ(5, copy->value()); copy->set(10); ATF_REQUIRE_EQ(5, node.value()); @@ -419,7 +422,8 @@ ATF_TEST_CASE_BODY(string_node__deep_copy) config::string_node node; node.set("first"); config::detail::base_node* raw_copy = node.deep_copy(); - config::string_node* copy = static_cast< config::string_node* >(raw_copy); + config::string_node* copy = dynamic_cast< config::string_node* >(raw_copy); + ATF_REQUIRE(copy != nullptr); ATF_REQUIRE_EQ("first", copy->value()); copy->set("second"); ATF_REQUIRE_EQ("first", node.value()); @@ -523,7 +527,8 @@ ATF_TEST_CASE_BODY(strings_set_node__deep_copy) node.set(value); config::detail::base_node* raw_copy = node.deep_copy(); config::strings_set_node* copy = - static_cast< config::strings_set_node* >(raw_copy); + dynamic_cast< config::strings_set_node* >(raw_copy); + ATF_REQUIRE(copy != nullptr); value.insert("bar"); ATF_REQUIRE_EQ(1, copy->value().size()); copy->set(value); diff --git a/contrib/kyua/utils/defs.hpp.in b/contrib/kyua/utils/defs.hpp.in index 62fc50d0e525..88207c90aa58 100644 --- a/contrib/kyua/utils/defs.hpp.in +++ b/contrib/kyua/utils/defs.hpp.in @@ -34,24 +34,17 @@ #if !defined(UTILS_DEFS_HPP) #define UTILS_DEFS_HPP - -/// Attribute to mark a function as non-returning. -#define UTILS_NORETURN @ATTRIBUTE_NORETURN@ - +extern "C" { +#include <inttypes.h> +} /// Attribute to mark a function as pure. #define UTILS_PURE @ATTRIBUTE_PURE@ - -/// Attribute to mark an entity as unused. -#define UTILS_UNUSED @ATTRIBUTE_UNUSED@ - - /// Unconstifies a pointer. /// /// \param type The target type of the conversion. /// \param ptr The pointer to be unconstified. -#define UTILS_UNCONST(type, ptr) ((type*)(unsigned long)(const void*)(ptr)) - +#define UTILS_UNCONST(type, ptr) ((type*)(uintptr_t)(const void*)(ptr)) #endif // !defined(UTILS_DEFS_HPP) diff --git a/contrib/kyua/utils/format/Makefile.am.inc b/contrib/kyua/utils/format/Makefile.am.inc deleted file mode 100644 index a37fc4057079..000000000000 --- a/contrib/kyua/utils/format/Makefile.am.inc +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2010 The Kyua Authors. -# 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. - -libutils_a_SOURCES += utils/format/containers.hpp -libutils_a_SOURCES += utils/format/containers.ipp -libutils_a_SOURCES += utils/format/exceptions.cpp -libutils_a_SOURCES += utils/format/exceptions.hpp -libutils_a_SOURCES += utils/format/formatter.cpp -libutils_a_SOURCES += utils/format/formatter.hpp -libutils_a_SOURCES += utils/format/formatter_fwd.hpp -libutils_a_SOURCES += utils/format/formatter.ipp -libutils_a_SOURCES += utils/format/macros.hpp - -if WITH_ATF -tests_utils_formatdir = $(pkgtestsdir)/utils/format - -tests_utils_format_DATA = utils/format/Kyuafile -EXTRA_DIST += $(tests_utils_format_DATA) - -tests_utils_format_PROGRAMS = utils/format/containers_test -utils_format_containers_test_SOURCES = utils/format/containers_test.cpp -utils_format_containers_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_format_containers_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_format_PROGRAMS += utils/format/exceptions_test -utils_format_exceptions_test_SOURCES = utils/format/exceptions_test.cpp -utils_format_exceptions_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_format_exceptions_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_format_PROGRAMS += utils/format/formatter_test -utils_format_formatter_test_SOURCES = utils/format/formatter_test.cpp -utils_format_formatter_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_format_formatter_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) -endif diff --git a/contrib/kyua/utils/fs/Makefile.am.inc b/contrib/kyua/utils/fs/Makefile.am.inc deleted file mode 100644 index 2acdadafa79b..000000000000 --- a/contrib/kyua/utils/fs/Makefile.am.inc +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright 2010 The Kyua Authors. -# 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. - -UTILS_CFLAGS += $(LUTOK_CFLAGS) -UTILS_LIBS += $(LUTOK_LIBS) - -libutils_a_CPPFLAGS += $(LUTOK_CFLAGS) -libutils_a_SOURCES += utils/fs/auto_cleaners.cpp -libutils_a_SOURCES += utils/fs/auto_cleaners.hpp -libutils_a_SOURCES += utils/fs/auto_cleaners_fwd.hpp -libutils_a_SOURCES += utils/fs/directory.cpp -libutils_a_SOURCES += utils/fs/directory.hpp -libutils_a_SOURCES += utils/fs/directory_fwd.hpp -libutils_a_SOURCES += utils/fs/exceptions.cpp -libutils_a_SOURCES += utils/fs/exceptions.hpp -libutils_a_SOURCES += utils/fs/lua_module.cpp -libutils_a_SOURCES += utils/fs/lua_module.hpp -libutils_a_SOURCES += utils/fs/operations.cpp -libutils_a_SOURCES += utils/fs/operations.hpp -libutils_a_SOURCES += utils/fs/path.cpp -libutils_a_SOURCES += utils/fs/path.hpp -libutils_a_SOURCES += utils/fs/path_fwd.hpp - -if WITH_ATF -tests_utils_fsdir = $(pkgtestsdir)/utils/fs - -tests_utils_fs_DATA = utils/fs/Kyuafile -EXTRA_DIST += $(tests_utils_fs_DATA) - -tests_utils_fs_PROGRAMS = utils/fs/auto_cleaners_test -utils_fs_auto_cleaners_test_SOURCES = utils/fs/auto_cleaners_test.cpp -utils_fs_auto_cleaners_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_fs_auto_cleaners_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_fs_PROGRAMS += utils/fs/directory_test -utils_fs_directory_test_SOURCES = utils/fs/directory_test.cpp -utils_fs_directory_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_fs_directory_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_fs_PROGRAMS += utils/fs/exceptions_test -utils_fs_exceptions_test_SOURCES = utils/fs/exceptions_test.cpp -utils_fs_exceptions_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_fs_exceptions_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_fs_PROGRAMS += utils/fs/lua_module_test -utils_fs_lua_module_test_SOURCES = utils/fs/lua_module_test.cpp -utils_fs_lua_module_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_fs_lua_module_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_fs_PROGRAMS += utils/fs/operations_test -utils_fs_operations_test_SOURCES = utils/fs/operations_test.cpp -utils_fs_operations_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_fs_operations_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_fs_PROGRAMS += utils/fs/path_test -utils_fs_path_test_SOURCES = utils/fs/path_test.cpp -utils_fs_path_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_fs_path_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) -endif diff --git a/contrib/kyua/utils/fs/directory.cpp b/contrib/kyua/utils/fs/directory.cpp index b73741aa544d..622d4c607f2c 100644 --- a/contrib/kyua/utils/fs/directory.cpp +++ b/contrib/kyua/utils/fs/directory.cpp @@ -32,6 +32,7 @@ extern "C" { #include <sys/types.h> #include <dirent.h> +#include <limits.h> } #include <cerrno> @@ -128,9 +129,6 @@ struct utils::fs::detail::directory_iterator::impl : utils::noncopyable { ::DIR* _dirp; /// Custom representation of the directory entry. - /// - /// We must keep this as a pointer so that we can support the common - /// operators (* and ->) over iterators. std::unique_ptr< directory_entry > _entry; /// Constructs an iterator pointing to the "end" of the directory. @@ -191,12 +189,9 @@ struct utils::fs::detail::directory_iterator::impl : utils::noncopyable { { ::dirent* result; - errno = 0; - if ((result = ::readdir(_dirp)) == NULL && errno != 0) { - const int original_errno = errno; - throw fs::system_error(F("readdir(%s) failed") % _path, - original_errno); - } + // TODO(ngie): use `std::filesystem::directory_iterator` once the + // minimum C++ standard is C++20. + result = ::readdir(_dirp); if (result == NULL) { _entry.reset(); close(); diff --git a/contrib/kyua/utils/fs/operations.cpp b/contrib/kyua/utils/fs/operations.cpp index 185d164b88d7..2b80fe317b94 100644 --- a/contrib/kyua/utils/fs/operations.cpp +++ b/contrib/kyua/utils/fs/operations.cpp @@ -104,51 +104,11 @@ static enum os_type current_os = ; -/// Specifies if a real unmount(2) is available. -/// -/// We use this as a constant instead of a macro so that we can compile both -/// versions of the unmount code unconditionally. This is a way to prevent -/// compilation bugs going unnoticed for long. -static const bool have_unmount2 = -#if defined(HAVE_UNMOUNT) - true; -#else - false; -#endif - - -#if !defined(UMOUNT) -/// Fake replacement value to the path to umount(8). -# define UMOUNT "do-not-use-this-value" -#else -# if defined(HAVE_UNMOUNT) -# error "umount(8) detected when unmount(2) is also available" -# endif -#endif - - -#if !defined(HAVE_UNMOUNT) -/// Fake unmount(2) function for systems without it. -/// -/// This is only provided to allow our code to compile in all platforms -/// regardless of whether they actually have an unmount(2) or not. -/// -/// \return -1 to indicate error, although this should never happen. -static int -unmount(const char* /* path */, - const int /* flags */) -{ - PRE(false); - return -1; -} -#endif - - /// Error code returned by subprocess to indicate a controlled failure. const int exit_known_error = 123; -static void run_mount_tmpfs(const fs::path&, const uint64_t) UTILS_NORETURN; +static void run_mount_tmpfs [[noreturn]] (const fs::path&, const uint64_t); /// Executes 'mount -t tmpfs' (or a similar variant). @@ -230,72 +190,30 @@ run_mount_tmpfs(const fs::path& mount_point, const uint64_t size) } -/// Unmounts a file system using unmount(2). +/// Unmounts a file system using unmount(2) or umount(2). /// -/// \pre unmount(2) must be available; i.e. have_unmount2 must be true. +/// This is a thin wrapper around the filesystem implementation for the actual +/// underlying system call which implements filesystem unmounting function. /// /// \param mount_point The file system to unmount. /// -/// \throw fs::system_error If the call to unmount(2) fails. +/// \throw fs::system_error The unmount operation fails. static void -unmount_with_unmount2(const fs::path& mount_point) +unmount_impl(const fs::path& mount_point) { - PRE(have_unmount2); - if (::unmount(mount_point.c_str(), 0) == -1) { - const int original_errno = errno; - throw fs::system_error(F("unmount(%s) failed") % mount_point, - original_errno); - } -} - - -/// Unmounts a file system using umount(8). -/// -/// \pre umount(2) must not be available; i.e. have_unmount2 must be false. -/// -/// \param mount_point The file system to unmount. -/// -/// \throw fs::error If the execution of umount(8) fails. -static void -unmount_with_umount8(const fs::path& mount_point) -{ - PRE(!have_unmount2); - - const pid_t pid = ::fork(); - if (pid == -1) { - const int original_errno = errno; - throw fs::system_error("Cannot fork to execute unmount tool", - original_errno); - } else if (pid == 0) { - const int ret = ::execlp(UMOUNT, "umount", mount_point.c_str(), NULL); - INV(ret == -1); - std::cerr << "Failed to exec " UMOUNT "\n"; - std::exit(EXIT_FAILURE); - } - - int status; -retry: - if (::waitpid(pid, &status, 0) == -1) { - const int original_errno = errno; - if (errno == EINTR) - goto retry; - throw fs::system_error("Failed to wait for unmount subprocess", - original_errno); - } - - if (WIFEXITED(status)) { - if (WEXITSTATUS(status) == EXIT_SUCCESS) - return; - else - throw fs::error(F("Failed to unmount %s; returned exit code %s") - % mount_point % WEXITSTATUS(status)); - } else - throw fs::error(F("Failed to unmount %s; unmount tool received signal") - % mount_point); +#if defined(HAVE_UNMOUNT) + if (::unmount(mount_point.c_str(), 0) == 0) + return; +#elif defined(HAVE_UMOUNT) + if (::umount(mount_point.c_str()) == 0) + return; +#endif + const int original_errno = errno; + throw fs::system_error(F("unmount(%s) failed") % mount_point, + original_errno); } - /// Stats a file, without following links. /// /// \param path The file to stat. @@ -788,11 +706,7 @@ fs::unmount(const fs::path& in_mount_point) int retries = unmount_retries; retry: try { - if (have_unmount2) { - unmount_with_unmount2(mount_point); - } else { - unmount_with_umount8(mount_point); - } + unmount_impl(mount_point); } catch (const fs::system_error& error) { if (error.original_errno() == EBUSY && retries > 0) { LW(F("%s busy; unmount retries left %s") % mount_point % retries); diff --git a/contrib/kyua/utils/logging/Makefile.am.inc b/contrib/kyua/utils/logging/Makefile.am.inc deleted file mode 100644 index 7d88f16859d7..000000000000 --- a/contrib/kyua/utils/logging/Makefile.am.inc +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright 2011 The Kyua Authors. -# 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. - -UTILS_CFLAGS += $(LUTOK_CFLAGS) -UTILS_LIBS += $(LUTOK_LIBS) - -libutils_a_CPPFLAGS += $(LUTOK_CFLAGS) -libutils_a_SOURCES += utils/logging/macros.hpp -libutils_a_SOURCES += utils/logging/operations.cpp -libutils_a_SOURCES += utils/logging/operations.hpp -libutils_a_SOURCES += utils/logging/operations_fwd.hpp - -if WITH_ATF -tests_utils_loggingdir = $(pkgtestsdir)/utils/logging - -tests_utils_logging_DATA = utils/logging/Kyuafile -EXTRA_DIST += $(tests_utils_logging_DATA) - -tests_utils_logging_PROGRAMS = utils/logging/macros_test -utils_logging_macros_test_SOURCES = utils/logging/macros_test.cpp -utils_logging_macros_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_logging_macros_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_logging_PROGRAMS += utils/logging/operations_test -utils_logging_operations_test_SOURCES = utils/logging/operations_test.cpp -utils_logging_operations_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_logging_operations_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) -endif diff --git a/contrib/kyua/utils/process/.gitignore b/contrib/kyua/utils/process/.gitignore deleted file mode 100644 index fb3291b39e0c..000000000000 --- a/contrib/kyua/utils/process/.gitignore +++ /dev/null @@ -1 +0,0 @@ -helpers diff --git a/contrib/kyua/utils/process/Kyuafile b/contrib/kyua/utils/process/Kyuafile index 37ab662982d5..92e62cfac6fc 100644 --- a/contrib/kyua/utils/process/Kyuafile +++ b/contrib/kyua/utils/process/Kyuafile @@ -6,7 +6,6 @@ atf_test_program{name="child_test"} atf_test_program{name="deadline_killer_test"} atf_test_program{name="exceptions_test"} atf_test_program{name="executor_test"} -atf_test_program{name="executor_pid_test"} atf_test_program{name="fdstream_test"} atf_test_program{name="isolation_test"} atf_test_program{name="operations_test"} diff --git a/contrib/kyua/utils/process/Makefile.am.inc b/contrib/kyua/utils/process/Makefile.am.inc deleted file mode 100644 index 5ce894091a53..000000000000 --- a/contrib/kyua/utils/process/Makefile.am.inc +++ /dev/null @@ -1,118 +0,0 @@ -# Copyright 2010 The Kyua Authors. -# 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. - -libutils_a_SOURCES += utils/process/child.cpp -libutils_a_SOURCES += utils/process/child.hpp -libutils_a_SOURCES += utils/process/child.ipp -libutils_a_SOURCES += utils/process/child_fwd.hpp -libutils_a_SOURCES += utils/process/deadline_killer.cpp -libutils_a_SOURCES += utils/process/deadline_killer.hpp -libutils_a_SOURCES += utils/process/deadline_killer_fwd.hpp -libutils_a_SOURCES += utils/process/exceptions.cpp -libutils_a_SOURCES += utils/process/exceptions.hpp -libutils_a_SOURCES += utils/process/executor.cpp -libutils_a_SOURCES += utils/process/executor.hpp -libutils_a_SOURCES += utils/process/executor.ipp -libutils_a_SOURCES += utils/process/executor_fwd.hpp -libutils_a_SOURCES += utils/process/fdstream.cpp -libutils_a_SOURCES += utils/process/fdstream.hpp -libutils_a_SOURCES += utils/process/fdstream_fwd.hpp -libutils_a_SOURCES += utils/process/isolation.cpp -libutils_a_SOURCES += utils/process/isolation.hpp -libutils_a_SOURCES += utils/process/operations.cpp -libutils_a_SOURCES += utils/process/operations.hpp -libutils_a_SOURCES += utils/process/operations_fwd.hpp -libutils_a_SOURCES += utils/process/status.cpp -libutils_a_SOURCES += utils/process/status.hpp -libutils_a_SOURCES += utils/process/status_fwd.hpp -libutils_a_SOURCES += utils/process/system.cpp -libutils_a_SOURCES += utils/process/system.hpp -libutils_a_SOURCES += utils/process/systembuf.cpp -libutils_a_SOURCES += utils/process/systembuf.hpp -libutils_a_SOURCES += utils/process/systembuf_fwd.hpp - -if WITH_ATF -tests_utils_processdir = $(pkgtestsdir)/utils/process - -tests_utils_process_DATA = utils/process/Kyuafile -EXTRA_DIST += $(tests_utils_process_DATA) - -tests_utils_process_PROGRAMS = utils/process/child_test -utils_process_child_test_SOURCES = utils/process/child_test.cpp -utils_process_child_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_process_child_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_process_PROGRAMS += utils/process/deadline_killer_test -utils_process_deadline_killer_test_SOURCES = \ - utils/process/deadline_killer_test.cpp -utils_process_deadline_killer_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_process_deadline_killer_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_process_PROGRAMS += utils/process/exceptions_test -utils_process_exceptions_test_SOURCES = utils/process/exceptions_test.cpp -utils_process_exceptions_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_process_exceptions_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_process_PROGRAMS += utils/process/executor_test -utils_process_executor_test_SOURCES = utils/process/executor_test.cpp -utils_process_executor_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_process_executor_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_process_PROGRAMS += utils/process/executor_pid_test -utils_process_executor_pid_test_SOURCES = utils/process/executor_pid_test.cpp -utils_process_executor_pid_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_process_executor_pid_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_process_PROGRAMS += utils/process/fdstream_test -utils_process_fdstream_test_SOURCES = utils/process/fdstream_test.cpp -utils_process_fdstream_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_process_fdstream_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_process_PROGRAMS += utils/process/isolation_test -utils_process_isolation_test_SOURCES = utils/process/isolation_test.cpp -utils_process_isolation_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_process_isolation_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_process_PROGRAMS += utils/process/helpers -utils_process_helpers_SOURCES = utils/process/helpers.cpp - -tests_utils_process_PROGRAMS += utils/process/operations_test -utils_process_operations_test_SOURCES = utils/process/operations_test.cpp -utils_process_operations_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_process_operations_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_process_PROGRAMS += utils/process/status_test -utils_process_status_test_SOURCES = utils/process/status_test.cpp -utils_process_status_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_process_status_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_process_PROGRAMS += utils/process/systembuf_test -utils_process_systembuf_test_SOURCES = utils/process/systembuf_test.cpp -utils_process_systembuf_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_process_systembuf_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) -endif diff --git a/contrib/kyua/utils/process/child.hpp b/contrib/kyua/utils/process/child.hpp index fbe32311a05b..bddf4b67fe0b 100644 --- a/contrib/kyua/utils/process/child.hpp +++ b/contrib/kyua/utils/process/child.hpp @@ -64,8 +64,8 @@ namespace process { namespace detail { -void report_error_and_abort(void) UTILS_NORETURN; -void report_error_and_abort(const std::runtime_error&) UTILS_NORETURN; +void report_error_and_abort [[noreturn]] (void); +void report_error_and_abort [[noreturn]] (const std::runtime_error&); } // namespace detail diff --git a/contrib/kyua/utils/process/child_test.cpp b/contrib/kyua/utils/process/child_test.cpp index 68911ae04660..79fa4d782b38 100644 --- a/contrib/kyua/utils/process/child_test.cpp +++ b/contrib/kyua/utils/process/child_test.cpp @@ -255,7 +255,7 @@ open_fail(const char* path, const int flags, ...) throw() /// /// \return Always -1. template< int Errno > -static pid_t +static int pipe_fail(int* /* fildes */) throw() { errno = Errno; diff --git a/contrib/kyua/utils/process/executor.cpp b/contrib/kyua/utils/process/executor.cpp index bddbeee7605f..c1ea3d088c34 100644 --- a/contrib/kyua/utils/process/executor.cpp +++ b/contrib/kyua/utils/process/executor.cpp @@ -693,6 +693,8 @@ struct utils::process::executor::executor_handle::impl : utils::noncopyable { executor::exit_handle reap(const pid_t original_pid) { + PRE(original_pid > 0); + const exec_handles_map::iterator iter = all_exec_handles.find( original_pid); exec_handle& data = (*iter).second; diff --git a/contrib/kyua/utils/process/executor_pid_test.cpp b/contrib/kyua/utils/process/executor_pid_test.cpp deleted file mode 100644 index 22e0b90ba14b..000000000000 --- a/contrib/kyua/utils/process/executor_pid_test.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright (c) 2022 Dell Inc. - * Author: Eric van Gyzen - * - * 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 AUTHOR 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 AUTHOR 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 0 - -1. Run some "bad" tests that prevent kyua from removing the work directory. - We use "chflags uunlink". Mounting a file system from an md(4) device - is another common use case. -2. Fork a lot, nearly wrapping the PID number space, so step 3 will re-use - a PID from step 1. Running the entire FreeBSD test suite is a more - realistic scenario for this step. -3. Run some more tests. If the stars align, the bug is not fixed yet, and - kyua is built with debugging, kyua will abort with the following messages. - Without debugging, the tests in step 3 will reuse the context from step 1, - including stdout, stderr, and working directory, which are still populated - with stuff from step 1. When I found this bug, step 3 was - __test_cases_list__, which expects a certain format in stdout and failed - when it found something completely unrelated. -4. You can clean up with: chflags -R nouunlink /tmp/kyua.*; rm -rf /tmp/kyua.* - -$ cc -o pid_wrap -latf-c pid_wrap.c -$ kyua test -pid_wrap:leak_0 -> passed [0.001s] -pid_wrap:leak_1 -> passed [0.001s] -pid_wrap:leak_2 -> passed [0.001s] -pid_wrap:leak_3 -> passed [0.001s] -pid_wrap:leak_4 -> passed [0.001s] -pid_wrap:leak_5 -> passed [0.001s] -pid_wrap:leak_6 -> passed [0.001s] -pid_wrap:leak_7 -> passed [0.001s] -pid_wrap:leak_8 -> passed [0.001s] -pid_wrap:leak_9 -> passed [0.001s] -pid_wrap:pid_wrap -> passed [1.113s] -pid_wrap:pid_wrap_0 -> passed [0.001s] -pid_wrap:pid_wrap_1 -> passed [0.001s] -pid_wrap:pid_wrap_2 -> passed [0.001s] -pid_wrap:pid_wrap_3 -> *** /usr/src/main/contrib/kyua/utils/process/executor.cpp:779: Invariant check failed: PID 60876 already in all_exec_handles; not properly cleaned up or reused too fast -*** Fatal signal 6 received -*** Log file is /home/vangyzen/.kyua/logs/kyua.20221006-193544.log -*** Please report this problem to kyua-discuss@googlegroups.com detailing what you were doing before the crash happened; if possible, include the log file mentioned above -Abort trap (core dumped) - -#endif - -#include <sys/stat.h> - -#include <atf-c++.hpp> - -#include <fcntl.h> -#include <signal.h> -#include <unistd.h> - -#include <cerrno> -#include <cstring> - -void -leak_work_dir() -{ - int fd; - - ATF_REQUIRE((fd = open("unforgettable", O_CREAT|O_EXCL|O_WRONLY, 0600)) - >= 0); - ATF_REQUIRE_EQ(0, fchflags(fd, UF_NOUNLINK)); - ATF_REQUIRE_EQ(0, close(fd)); -} - -void -wrap_pids() -{ - pid_t begin, current, target; - bool wrapped; - - begin = getpid(); - target = begin - 15; - if (target <= 1) { - target += 99999; // PID_MAX - wrapped = true; - } else { - wrapped = false; - } - - ATF_REQUIRE(signal(SIGCHLD, SIG_IGN) != SIG_ERR); - - do { - current = vfork(); - if (current == 0) { - _exit(0); - } - ATF_REQUIRE(current != -1); - if (current < begin) { - wrapped = true; - } - } while (!wrapped || current < target); -} - -void -test_work_dir_reuse() -{ - // If kyua is built with debugging, it would abort here before the fix. -} - -void -clean_up() -{ - (void)system("chflags -R nouunlink ../.."); -} - -ATF_TEST_CASE_WITHOUT_HEAD(leak_0); -ATF_TEST_CASE_BODY(leak_0) { leak_work_dir(); } -ATF_TEST_CASE_WITHOUT_HEAD(leak_1); -ATF_TEST_CASE_BODY(leak_1) { leak_work_dir(); } -ATF_TEST_CASE_WITHOUT_HEAD(leak_2); -ATF_TEST_CASE_BODY(leak_2) { leak_work_dir(); } -ATF_TEST_CASE_WITHOUT_HEAD(leak_3); -ATF_TEST_CASE_BODY(leak_3) { leak_work_dir(); } -ATF_TEST_CASE_WITHOUT_HEAD(leak_4); -ATF_TEST_CASE_BODY(leak_4) { leak_work_dir(); } -ATF_TEST_CASE_WITHOUT_HEAD(leak_5); -ATF_TEST_CASE_BODY(leak_5) { leak_work_dir(); } -ATF_TEST_CASE_WITHOUT_HEAD(leak_6); -ATF_TEST_CASE_BODY(leak_6) { leak_work_dir(); } -ATF_TEST_CASE_WITHOUT_HEAD(leak_7); -ATF_TEST_CASE_BODY(leak_7) { leak_work_dir(); } -ATF_TEST_CASE_WITHOUT_HEAD(leak_8); -ATF_TEST_CASE_BODY(leak_8) { leak_work_dir(); } -ATF_TEST_CASE_WITHOUT_HEAD(leak_9); -ATF_TEST_CASE_BODY(leak_9) { leak_work_dir(); } - -ATF_TEST_CASE_WITHOUT_HEAD(pid_wrap); -ATF_TEST_CASE_BODY(pid_wrap) { wrap_pids(); } - -ATF_TEST_CASE_WITHOUT_HEAD(pid_wrap_0); -ATF_TEST_CASE_BODY(pid_wrap_0) { test_work_dir_reuse(); } -ATF_TEST_CASE_WITHOUT_HEAD(pid_wrap_1); -ATF_TEST_CASE_BODY(pid_wrap_1) { test_work_dir_reuse(); } -ATF_TEST_CASE_WITHOUT_HEAD(pid_wrap_2); -ATF_TEST_CASE_BODY(pid_wrap_2) { test_work_dir_reuse(); } -ATF_TEST_CASE_WITHOUT_HEAD(pid_wrap_3); -ATF_TEST_CASE_BODY(pid_wrap_3) { test_work_dir_reuse(); } -ATF_TEST_CASE_WITHOUT_HEAD(pid_wrap_4); -ATF_TEST_CASE_BODY(pid_wrap_4) { test_work_dir_reuse(); } -ATF_TEST_CASE_WITHOUT_HEAD(pid_wrap_5); -ATF_TEST_CASE_BODY(pid_wrap_5) { test_work_dir_reuse(); } -ATF_TEST_CASE_WITHOUT_HEAD(pid_wrap_6); -ATF_TEST_CASE_BODY(pid_wrap_6) { test_work_dir_reuse(); } -ATF_TEST_CASE_WITHOUT_HEAD(pid_wrap_7); -ATF_TEST_CASE_BODY(pid_wrap_7) { test_work_dir_reuse(); } -ATF_TEST_CASE_WITHOUT_HEAD(pid_wrap_8); -ATF_TEST_CASE_BODY(pid_wrap_8) { test_work_dir_reuse(); } -ATF_TEST_CASE_WITHOUT_HEAD(pid_wrap_9); -ATF_TEST_CASE_BODY(pid_wrap_9) { test_work_dir_reuse(); } - -ATF_TEST_CASE_WITHOUT_HEAD(really_clean_up); -ATF_TEST_CASE_BODY(really_clean_up) { clean_up(); } - -ATF_INIT_TEST_CASES(tcs) -{ - ATF_ADD_TEST_CASE(tcs, leak_0); - ATF_ADD_TEST_CASE(tcs, leak_1); - ATF_ADD_TEST_CASE(tcs, leak_2); - ATF_ADD_TEST_CASE(tcs, leak_3); - ATF_ADD_TEST_CASE(tcs, leak_4); - ATF_ADD_TEST_CASE(tcs, leak_5); - ATF_ADD_TEST_CASE(tcs, leak_6); - ATF_ADD_TEST_CASE(tcs, leak_7); - ATF_ADD_TEST_CASE(tcs, leak_8); - ATF_ADD_TEST_CASE(tcs, leak_9); - - ATF_ADD_TEST_CASE(tcs, pid_wrap); - - ATF_ADD_TEST_CASE(tcs, pid_wrap_0); - ATF_ADD_TEST_CASE(tcs, pid_wrap_1); - ATF_ADD_TEST_CASE(tcs, pid_wrap_2); - ATF_ADD_TEST_CASE(tcs, pid_wrap_3); - ATF_ADD_TEST_CASE(tcs, pid_wrap_4); - ATF_ADD_TEST_CASE(tcs, pid_wrap_5); - ATF_ADD_TEST_CASE(tcs, pid_wrap_6); - ATF_ADD_TEST_CASE(tcs, pid_wrap_7); - ATF_ADD_TEST_CASE(tcs, pid_wrap_8); - ATF_ADD_TEST_CASE(tcs, pid_wrap_9); - - ATF_ADD_TEST_CASE(tcs, really_clean_up); -} diff --git a/contrib/kyua/utils/process/executor_test.cpp b/contrib/kyua/utils/process/executor_test.cpp index 13ae69bd44ed..b52730b5c71c 100644 --- a/contrib/kyua/utils/process/executor_test.cpp +++ b/contrib/kyua/utils/process/executor_test.cpp @@ -80,7 +80,7 @@ using utils::optional; static const datetime::delta infinite_timeout(1000000, 0); -static void do_exit(const int) UTILS_NORETURN; +static void do_exit [[noreturn]] (const int); /// Terminates a subprocess without invoking destructors. @@ -118,8 +118,7 @@ public: /// Runs the subprocess. void - operator()(const fs::path& /* control_directory */) - UTILS_NORETURN + operator() [[noreturn]] (const fs::path& /* control_directory */) { std::cout << "Creating cookie: " << _cookie_name << " (stdout)\n"; std::cerr << "Creating cookie: " << _cookie_name << " (stderr)\n"; @@ -129,7 +128,7 @@ public: }; -static void child_delete_all(const fs::path&) UTILS_NORETURN; +static void child_delete_all [[noreturn]] (const fs::path&); /// Subprocess that deletes all files in the current directory. @@ -155,7 +154,7 @@ child_delete_all(const fs::path& control_directory) } -static void child_dump_unprivileged_user(const fs::path&) UTILS_NORETURN; +static void child_dump_unprivileged_user [[noreturn]] (const fs::path&); /// Subprocess that dumps user configuration. @@ -183,15 +182,14 @@ public: /// Runs the subprocess. void - operator()(const fs::path& /* control_directory */) - UTILS_NORETURN + operator() [[noreturn]] (const fs::path& /* control_directory */) { do_exit(_exit_code); } }; -static void child_pause(const fs::path&) UTILS_NORETURN; +static void child_pause [[noreturn]] (const fs::path&); /// Subprocess that just blocks. @@ -207,7 +205,7 @@ child_pause(const fs::path& /* control_directory */) } -static void child_print(const fs::path&) UTILS_NORETURN; +static void child_print [[noreturn]] (const fs::path&); /// Subprocess that writes to stdout and stderr. @@ -236,8 +234,7 @@ public: /// Runs the subprocess. void - operator()(const fs::path& /* control_directory */) - UTILS_NORETURN + operator() [[noreturn]] (const fs::path& /* control_directory */) { ::sleep(_seconds); do_exit(EXIT_SUCCESS); @@ -245,7 +242,7 @@ public: }; -static void child_spawn_blocking_child(const fs::path&) UTILS_NORETURN; +static void child_spawn_blocking_child [[noreturn]] (const fs::path&); /// Subprocess that spawns a subchild that gets stuck. @@ -278,7 +275,7 @@ child_spawn_blocking_child( } -static void child_validate_isolation(const fs::path&) UTILS_NORETURN; +static void child_validate_isolation [[noreturn]] (const fs::path&); /// Subprocess that checks if isolate_child() has been called. diff --git a/contrib/kyua/utils/process/isolation.cpp b/contrib/kyua/utils/process/isolation.cpp index 90dd08d5772d..3b2ecaa3e992 100644 --- a/contrib/kyua/utils/process/isolation.cpp +++ b/contrib/kyua/utils/process/isolation.cpp @@ -67,7 +67,7 @@ const int process::exit_isolation_failure = 124; namespace { -static void fail(const std::string&, const int) UTILS_NORETURN; +static void fail [[noreturn]] (const std::string&, const int); /// Fails the process with an errno-based error message. diff --git a/contrib/kyua/utils/process/operations.cpp b/contrib/kyua/utils/process/operations.cpp index abcc49f2a443..284b5e0e998a 100644 --- a/contrib/kyua/utils/process/operations.cpp +++ b/contrib/kyua/utils/process/operations.cpp @@ -31,7 +31,6 @@ extern "C" { #include <sys/types.h> #include <sys/wait.h> - #include <signal.h> #include <unistd.h> } @@ -164,7 +163,7 @@ process::exec_unsafe(const fs::path& program, const args_vector& args) argv[1 + args.size()] = NULL; const int ret = ::execv(program.c_str(), - (char* const*)(unsigned long)(const void*)argv); + UTILS_UNCONST(char* const, argv)); original_errno = errno; INV(ret == -1); std::cerr << "Failed to execute " << program << ": " diff --git a/contrib/kyua/utils/process/operations.hpp b/contrib/kyua/utils/process/operations.hpp index 773f9d38bb74..781d7d84af8e 100644 --- a/contrib/kyua/utils/process/operations.hpp +++ b/contrib/kyua/utils/process/operations.hpp @@ -42,10 +42,10 @@ namespace utils { namespace process { -void exec(const utils::fs::path&, const args_vector&) throw() UTILS_NORETURN; -void exec_unsafe(const utils::fs::path&, const args_vector&) UTILS_NORETURN; +void exec [[noreturn]] (const utils::fs::path&, const args_vector&) throw(); +void exec_unsafe [[noreturn]] (const utils::fs::path&, const args_vector&); void terminate_group(const int); -void terminate_self_with(const status&) UTILS_NORETURN; +void terminate_self_with [[noreturn]] (const status&); status wait(const int); status wait_any(void); diff --git a/contrib/kyua/utils/process/operations_test.cpp b/contrib/kyua/utils/process/operations_test.cpp index d30dc890abd2..863e0937fe0a 100644 --- a/contrib/kyua/utils/process/operations_test.cpp +++ b/contrib/kyua/utils/process/operations_test.cpp @@ -117,7 +117,7 @@ child_exit(void) } -static void suspend(void) UTILS_NORETURN; +static void suspend [[noreturn]] (void); /// Blocks a subprocess from running indefinitely. @@ -132,7 +132,7 @@ suspend(void) } -static void write_loop(const int) UTILS_NORETURN; +static void write_loop [[noreturn]] (const int); /// Provides an infinite stream of data in a subprocess. diff --git a/contrib/kyua/utils/sanity.hpp b/contrib/kyua/utils/sanity.hpp index 6b126f984999..d4bde12e8060 100644 --- a/contrib/kyua/utils/sanity.hpp +++ b/contrib/kyua/utils/sanity.hpp @@ -49,8 +49,8 @@ namespace utils { -void sanity_failure(const assert_type, const char*, const size_t, - const std::string&) UTILS_NORETURN; +void sanity_failure [[noreturn]]( + const assert_type, const char*, const size_t, const std::string&); void install_crash_handlers(const std::string&); diff --git a/contrib/kyua/utils/signals/Makefile.am.inc b/contrib/kyua/utils/signals/Makefile.am.inc deleted file mode 100644 index b01089c80fea..000000000000 --- a/contrib/kyua/utils/signals/Makefile.am.inc +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright 2010 The Kyua Authors. -# 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. - -libutils_a_SOURCES += utils/signals/exceptions.cpp -libutils_a_SOURCES += utils/signals/exceptions.hpp -libutils_a_SOURCES += utils/signals/interrupts.cpp -libutils_a_SOURCES += utils/signals/interrupts.hpp -libutils_a_SOURCES += utils/signals/interrupts_fwd.hpp -libutils_a_SOURCES += utils/signals/misc.cpp -libutils_a_SOURCES += utils/signals/misc.hpp -libutils_a_SOURCES += utils/signals/programmer.cpp -libutils_a_SOURCES += utils/signals/programmer.hpp -libutils_a_SOURCES += utils/signals/programmer_fwd.hpp -libutils_a_SOURCES += utils/signals/timer.cpp -libutils_a_SOURCES += utils/signals/timer.hpp -libutils_a_SOURCES += utils/signals/timer_fwd.hpp - -if WITH_ATF -tests_utils_signalsdir = $(pkgtestsdir)/utils/signals - -tests_utils_signals_DATA = utils/signals/Kyuafile -EXTRA_DIST += $(tests_utils_signals_DATA) - -tests_utils_signals_PROGRAMS = utils/signals/exceptions_test -utils_signals_exceptions_test_SOURCES = utils/signals/exceptions_test.cpp -utils_signals_exceptions_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_signals_exceptions_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_signals_PROGRAMS += utils/signals/interrupts_test -utils_signals_interrupts_test_SOURCES = utils/signals/interrupts_test.cpp -utils_signals_interrupts_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_signals_interrupts_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_signals_PROGRAMS += utils/signals/misc_test -utils_signals_misc_test_SOURCES = utils/signals/misc_test.cpp -utils_signals_misc_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_signals_misc_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_signals_PROGRAMS += utils/signals/programmer_test -utils_signals_programmer_test_SOURCES = utils/signals/programmer_test.cpp -utils_signals_programmer_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_signals_programmer_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_signals_PROGRAMS += utils/signals/timer_test -utils_signals_timer_test_SOURCES = utils/signals/timer_test.cpp -utils_signals_timer_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_signals_timer_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) -endif diff --git a/contrib/kyua/utils/signals/misc_test.cpp b/contrib/kyua/utils/signals/misc_test.cpp index 3b6d57325ee1..398cf50c4c2b 100644 --- a/contrib/kyua/utils/signals/misc_test.cpp +++ b/contrib/kyua/utils/signals/misc_test.cpp @@ -51,7 +51,7 @@ namespace signals = utils::signals; namespace { -static void program_reset_raise(void) UTILS_NORETURN; +static void program_reset_raise [[noreturn]] (void); /// Body of a subprocess that tests the signals::reset function. diff --git a/contrib/kyua/utils/sqlite/Makefile.am.inc b/contrib/kyua/utils/sqlite/Makefile.am.inc deleted file mode 100644 index 6064a641c14f..000000000000 --- a/contrib/kyua/utils/sqlite/Makefile.am.inc +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright 2011 The Kyua Authors. -# 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. - -UTILS_CFLAGS += $(SQLITE3_CFLAGS) -UTILS_LIBS += $(SQLITE3_LIBS) - -libutils_a_CPPFLAGS += $(SQLITE3_CFLAGS) -libutils_a_SOURCES += utils/sqlite/c_gate.cpp -libutils_a_SOURCES += utils/sqlite/c_gate.hpp -libutils_a_SOURCES += utils/sqlite/c_gate_fwd.hpp -libutils_a_SOURCES += utils/sqlite/database.cpp -libutils_a_SOURCES += utils/sqlite/database.hpp -libutils_a_SOURCES += utils/sqlite/database_fwd.hpp -libutils_a_SOURCES += utils/sqlite/exceptions.cpp -libutils_a_SOURCES += utils/sqlite/exceptions.hpp -libutils_a_SOURCES += utils/sqlite/statement.cpp -libutils_a_SOURCES += utils/sqlite/statement.hpp -libutils_a_SOURCES += utils/sqlite/statement_fwd.hpp -libutils_a_SOURCES += utils/sqlite/statement.ipp -libutils_a_SOURCES += utils/sqlite/transaction.cpp -libutils_a_SOURCES += utils/sqlite/transaction.hpp -libutils_a_SOURCES += utils/sqlite/transaction_fwd.hpp - -if WITH_ATF -tests_utils_sqlitedir = $(pkgtestsdir)/utils/sqlite - -tests_utils_sqlite_DATA = utils/sqlite/Kyuafile -EXTRA_DIST += $(tests_utils_sqlite_DATA) - -tests_utils_sqlite_PROGRAMS = utils/sqlite/c_gate_test -utils_sqlite_c_gate_test_SOURCES = utils/sqlite/c_gate_test.cpp \ - utils/sqlite/test_utils.hpp -utils_sqlite_c_gate_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_sqlite_c_gate_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_sqlite_PROGRAMS += utils/sqlite/database_test -utils_sqlite_database_test_SOURCES = utils/sqlite/database_test.cpp \ - utils/sqlite/test_utils.hpp -utils_sqlite_database_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_sqlite_database_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_sqlite_PROGRAMS += utils/sqlite/exceptions_test -utils_sqlite_exceptions_test_SOURCES = utils/sqlite/exceptions_test.cpp -utils_sqlite_exceptions_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_sqlite_exceptions_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_sqlite_PROGRAMS += utils/sqlite/statement_test -utils_sqlite_statement_test_SOURCES = utils/sqlite/statement_test.cpp \ - utils/sqlite/test_utils.hpp -utils_sqlite_statement_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_sqlite_statement_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_sqlite_PROGRAMS += utils/sqlite/transaction_test -utils_sqlite_transaction_test_SOURCES = utils/sqlite/transaction_test.cpp -utils_sqlite_transaction_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_sqlite_transaction_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) -endif diff --git a/contrib/kyua/utils/sqlite/database.hpp b/contrib/kyua/utils/sqlite/database.hpp index ca91a6a360c6..6c6f259fba07 100644 --- a/contrib/kyua/utils/sqlite/database.hpp +++ b/contrib/kyua/utils/sqlite/database.hpp @@ -43,6 +43,7 @@ extern "C" { #include <cstddef> #include <memory> +#include <string> #include "utils/fs/path_fwd.hpp" #include "utils/optional_fwd.hpp" diff --git a/contrib/kyua/utils/sqlite/test_utils.hpp b/contrib/kyua/utils/sqlite/test_utils.hpp index bf35d209a164..ba6b720b57ed 100644 --- a/contrib/kyua/utils/sqlite/test_utils.hpp +++ b/contrib/kyua/utils/sqlite/test_utils.hpp @@ -97,7 +97,7 @@ static const char* create_test_table_sql = "INSERT INTO test (prime) VALUES (3);\n"; -static void create_test_table(::sqlite3*) UTILS_UNUSED; +[[maybe_unused]] void create_test_table(::sqlite3*); /// Creates a 'test' table in a database. @@ -118,7 +118,7 @@ create_test_table(::sqlite3* db) } -static void verify_test_table(::sqlite3*) UTILS_UNUSED; +[[maybe_unused]] void verify_test_table(::sqlite3*); /// Verifies that the specified database contains the 'test' table. diff --git a/contrib/kyua/utils/stacktrace.cpp b/contrib/kyua/utils/stacktrace.cpp index 11636b31959f..30d8459c98c3 100644 --- a/contrib/kyua/utils/stacktrace.cpp +++ b/contrib/kyua/utils/stacktrace.cpp @@ -77,7 +77,7 @@ const char* utils::builtin_gdb = GDB; /// Maximum time the external GDB process is allowed to run for. -datetime::delta utils::gdb_timeout(60, 0); +datetime::delta utils::gdb_timeout(300, 0); namespace { diff --git a/contrib/kyua/utils/stacktrace_test.cpp b/contrib/kyua/utils/stacktrace_test.cpp index ca87e7087f5a..e3b170755764 100644 --- a/contrib/kyua/utils/stacktrace_test.cpp +++ b/contrib/kyua/utils/stacktrace_test.cpp @@ -94,7 +94,7 @@ public: /// Runs the binary. void - operator()(void) const UTILS_NORETURN + operator() [[noreturn]] (void) const { atf::utils::copy_file(_binary.str(), _copy_name.str()); @@ -106,15 +106,14 @@ public: /// /// This interface is exposed to support passing crash_me to the executor. void - operator()(const fs::path& /* control_directory */) const - UTILS_NORETURN + operator() [[noreturn]] (const fs::path& /* control_directory */) const { (*this)(); // Delegate to ensure the two entry points remain in sync. } }; -static void child_exit(const fs::path&) UTILS_NORETURN; +static void child_exit [[noreturn]] (const fs::path&); /// Subprocess that exits cleanly. @@ -125,7 +124,7 @@ child_exit(const fs::path& /* control_directory */) } -static void child_pause(const fs::path&) UTILS_NORETURN; +static void child_pause [[noreturn]] (const fs::path&); /// Subprocess that just blocks. diff --git a/contrib/kyua/utils/test_utils.ipp b/contrib/kyua/utils/test_utils.ipp index f21d0f4cc172..60b92adf5463 100644 --- a/contrib/kyua/utils/test_utils.ipp +++ b/contrib/kyua/utils/test_utils.ipp @@ -67,7 +67,7 @@ avoid_coredump_on_crash(void) } -inline void abort_without_coredump(void) UTILS_NORETURN; +inline void abort_without_coredump [[noreturn]] (void); /// Aborts execution and tries to not dump core. diff --git a/contrib/kyua/utils/text/Makefile.am.inc b/contrib/kyua/utils/text/Makefile.am.inc deleted file mode 100644 index d474ae191bf5..000000000000 --- a/contrib/kyua/utils/text/Makefile.am.inc +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright 2012 The Kyua Authors. -# 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. - -libutils_a_SOURCES += utils/text/exceptions.cpp -libutils_a_SOURCES += utils/text/exceptions.hpp -libutils_a_SOURCES += utils/text/operations.cpp -libutils_a_SOURCES += utils/text/operations.hpp -libutils_a_SOURCES += utils/text/operations.ipp -libutils_a_SOURCES += utils/text/regex.cpp -libutils_a_SOURCES += utils/text/regex.hpp -libutils_a_SOURCES += utils/text/regex_fwd.hpp -libutils_a_SOURCES += utils/text/table.cpp -libutils_a_SOURCES += utils/text/table.hpp -libutils_a_SOURCES += utils/text/table_fwd.hpp -libutils_a_SOURCES += utils/text/templates.cpp -libutils_a_SOURCES += utils/text/templates.hpp -libutils_a_SOURCES += utils/text/templates_fwd.hpp - -if WITH_ATF -tests_utils_textdir = $(pkgtestsdir)/utils/text - -tests_utils_text_DATA = utils/text/Kyuafile -EXTRA_DIST += $(tests_utils_text_DATA) - -tests_utils_text_PROGRAMS = utils/text/exceptions_test -utils_text_exceptions_test_SOURCES = utils/text/exceptions_test.cpp -utils_text_exceptions_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_text_exceptions_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_text_PROGRAMS += utils/text/operations_test -utils_text_operations_test_SOURCES = utils/text/operations_test.cpp -utils_text_operations_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_text_operations_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_text_PROGRAMS += utils/text/regex_test -utils_text_regex_test_SOURCES = utils/text/regex_test.cpp -utils_text_regex_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_text_regex_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_text_PROGRAMS += utils/text/table_test -utils_text_table_test_SOURCES = utils/text/table_test.cpp -utils_text_table_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_text_table_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) - -tests_utils_text_PROGRAMS += utils/text/templates_test -utils_text_templates_test_SOURCES = utils/text/templates_test.cpp -utils_text_templates_test_CXXFLAGS = $(UTILS_CFLAGS) $(ATF_CXX_CFLAGS) -utils_text_templates_test_LDADD = $(UTILS_LIBS) $(ATF_CXX_LIBS) -endif diff --git a/contrib/kyua/utils/text/operations.ipp b/contrib/kyua/utils/text/operations.ipp index 511cd6840a08..eb29a0a5e8b7 100644 --- a/contrib/kyua/utils/text/operations.ipp +++ b/contrib/kyua/utils/text/operations.ipp @@ -31,6 +31,7 @@ #include "utils/text/operations.hpp" +#include <string> #include <sstream> #include "utils/text/exceptions.hpp" diff --git a/contrib/kyua/utils/text/regex.cpp b/contrib/kyua/utils/text/regex.cpp index b078ba88f6b4..86b41cc872aa 100644 --- a/contrib/kyua/utils/text/regex.cpp +++ b/contrib/kyua/utils/text/regex.cpp @@ -47,8 +47,8 @@ namespace text = utils::text; namespace { -static void throw_regex_error(const int, const ::regex_t*, const std::string&) - UTILS_NORETURN; +static void throw_regex_error [[noreturn]] ( + const int, const ::regex_t*, const std::string&); /// Constructs and raises a regex_error. diff --git a/contrib/kyua/utils/text/regex.hpp b/contrib/kyua/utils/text/regex.hpp index b3d20c246735..d4981dfca3c6 100644 --- a/contrib/kyua/utils/text/regex.hpp +++ b/contrib/kyua/utils/text/regex.hpp @@ -36,6 +36,7 @@ #include <cstddef> #include <memory> +#include <string> namespace utils { |
