diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 00000000..32bbade0 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,44 @@ +--- +name: Bug Report +about: There are no bugs here. But just in case... + +--- +# Bug Report +Thank you for filing a bug report! The more information you +can give us about your development environment, toolchain, +actions leading up to the bug, or any other contextual +information, the faster we'll be able to verify and diagnose +what went wrong. + +At a minimun, please be sure to include the library version +you were working with. If you were trying to compile it from +source, please be sure to specify the compiler, compiler +version, operating system, operating system version, the +build system you used to generate the project, and whether +you were building from a source distribution or from version +control. + +If you have no idea what any or all of the above terms mean, +you are always welcome to submit a bug report anyways, but +please remember the Fundamental Theorem of Bug Report +Submissions: + + > The amount of information in a bug report is directly + proportional to its resolution speed. + +## Checklist +Please do your best to include the following items with your +bug report. + +### The Bare Minimum +Remember that this is the **minimum** required information. +More is always more helpful. + + - [ ] [libcheck](https://github.com/libcheck/check) version + - [ ] Operating system + - [ ] Compiler + +## Additional Information +Please be sure to include any additional information you +think may be helpful in helping us diagnose, understand, or +replicate the problem. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..0086358d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: true diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 00000000..5fab1030 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,210 @@ +name: linux + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build_linux_autotools_default_args: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install doc packages + run: sudo apt-get install -y texlive texinfo texi2html doxygen + - name: create configure + run: autoreconf -i + - name: configure default + run: ./configure + - name: make + run: make + - name: make check + run: make check + - name: make install + run: sudo make install + + build_linux_autotools_other_args: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install doc packages + run: sudo apt-get install -y texlive texinfo texi2html doxygen + - name: create configure + run: autoreconf -i + - name: configure default + run: ./configure --disable-fork --disable-subunit --enable-snprintf-replacement --enable-timer-replacement + - name: make + run: make + - name: make check + run: make check + - name: make install + run: sudo make install + + build_linux_autotools_gcc: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: create configure + run: autoreconf -i + - name: configure gcc + run: ./configure CC=gcc --enable-snprintf-replacement --enable-timer-replacement --disable-build-docs --disable-timeout-tests + - name: make + run: make + - name: make check + run: make check + + build_linux_autotools_clang: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: create configure + run: autoreconf -i + - name: configure clang + run: ./configure CC=clang --enable-snprintf-replacement --enable-timer-replacement --disable-build-docs --disable-timeout-tests + - name: make + run: make + + build_linux_autotools_crosscompile_mingw32: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install doc packages + run: sudo apt-get install -y gcc-mingw-w64 + - name: create configure + run: autoreconf -i + - name: configure clang + run: ./configure --disable-build-docs --host=x86_64-w64-mingw32 --disable-static --disable-subunit + - name: make + run: make + + + build_linux_autotools_prereleasecheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install doc packages + run: sudo apt-get install -y texlive texinfo texi2html doxygen + - name: create configure + run: autoreconf -i + - name: configure default + run: ./configure + - name: make prereleasecheck + run: make prereleasecheck + + build_linux_autotools_docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install doc packages + run: sudo apt-get install -y texlive texinfo texi2html doxygen + - name: create configure + run: autoreconf -i + - name: configure default + run: ./configure + - name: make docs + run: make doc/check_html + - name: make doxygen + run: make doc/doxygen + + build_linux_autotools_example: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install doc packages + run: sudo apt-get install -y texlive texinfo texi2html doxygen + - name: create configure + run: autoreconf -i + - name: configure default + run: ./configure + - name: make + run: make + - name: make install + run: sudo make install + - name: create configure example + working-directory: doc/example + run: autoreconf -i + - name: configure example + working-directory: doc/example + run: ./configure + - name: build example + working-directory: doc/example + run: make + - name: test example + working-directory: doc/example + run: make check + + build_linux_cmake: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: cmake cversion + run: cmake --version + - name: create configs + run: cmake . + - name: make + run: make + - name: unit tests + run: ctest -V + - name: make install + run: sudo make install + + build_linux_scanbuild: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install scan-build packages + run: sudo apt-get install -y clang-tools + - name: create configure + run: autoreconf -i + - name: configure + run: scan-build ./configure --enable-timer-replacement --disable-build-docs + - name: make + run: scan-build -o clang make + - name: check for issues + run: | + if [ -n "$(find clang -type f)" ]; then + echo "scan-build found potential issues" + find clang -type f -print -exec cat \{} \; + exit 1 + fi + + build_linux_cmake_project_usage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: run test + run: | + cmake --version || exit 1 + project_dir="project_cmake" + install_dir="${PWD}/install_cmake" + build_dir="${PWD}/build_cmake" + + # For FetchContent we copy everything to a subdir. + # Otherwise the copying would be recursive and forever. + echo "setup project dir" + mkdir "$project_dir" || exit 1 + find . -maxdepth 1 -print | grep -v -E "^(\.|\./${project_dir})\$" | grep -v '^\./\.git.*$' | xargs cp -R -t "$project_dir" || exit 1 + + # For find_package we need the project built and installed + echo "build and install" + mkdir "$build_dir" && cd "$build_dir" || exit 1 + cmake -D BUILD_TESTING=OFF -D CMAKE_INSTALL_PREFIX="${install_dir}" ../project_cmake || exit 1 + make && make install || exit 1 + cd .. || exit 1 + + echo "test fetch content" + cp -R tests/cmake_project_usage_test . || exit 1 + proj_dir="$PWD/${project_dir}" + build_dir="build_fetch_content" + mkdir $build_dir && cd $build_dir || exit 1 + INCLUDE_CHECK_WITH='FetchContent' INCLUDE_CHECK_FROM="file://${proj_dir}" cmake -D CMAKE_BUILD_TYPE=Debug ../cmake_project_usage_test || exit 1 + make && src/tests.test || exit 1 + cd .. || exit 1 + + echo "test find package" + build_dir='build_find_package_config' + mkdir $build_dir && cd $build_dir || exit 1 + INCLUDE_CHECK_WITH='find_package_config' Check_ROOT="${install_dir}" cmake -D CMAKE_BUILD_TYPE=Debug ../cmake_project_usage_test || exit 1 + make && src/tests.test || exit 1 + cd .. || exit 1 diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml new file mode 100644 index 00000000..5fbc801a --- /dev/null +++ b/.github/workflows/osx.yml @@ -0,0 +1,151 @@ +name: osx + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build_osx_autotools_default_args: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + # Brew may not have permission to install its packages + - name: change brew install folder permissions + run: sudo chmod -R a+rwx /usr/local/share/ || mkdir -p /usr/local/share/ -m a+rwx + - name: install maxtex + run: brew install --cask mactex + - name: install doc programs + run: brew install texi2html doxygen + - name: install automake + run: brew install automake + - name: install pkg-config + run: brew install pkgconfig + - name: create configure + run: autoreconf -i + - name: configure + run: ./configure --disable-timeout-tests + - name: make + run: make + - name: make check + run: make check + - name: make install + run: sudo make install + + build_osx_autotools_other_args: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + # Brew may not have permission to install its packages + - name: change brew install folder permissions + run: sudo chmod -R a+rwx /usr/local/share/ || mkdir -p /usr/local/share/ -m a+rwx + - name: install maxtex + run: brew install --cask mactex + - name: install doc programs + run: brew install texi2html doxygen + - name: install automake + run: brew install automake + - name: install pkg-config + run: brew install pkgconfig + - name: create configure + run: autoreconf -i + - name: configure with args + run: ./configure --disable-fork --disable-subunit --enable-snprintf-replacement --enable-timer-replacement --disable-timeout-tests + - name: make + run: make + - name: make check + run: make check + - name: make install + run: sudo make install + + build_osx_autotools_gcc: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + # Brew may not have permission to install its packages + - name: change brew install folder permissions + run: sudo chmod -R a+rwx /usr/local/share/ || mkdir -p /usr/local/share/ -m a+rwx + - name: install automake + run: brew install automake + - name: install pkg-config + run: brew install pkgconfig + - name: create configure + run: autoreconf -i + - name: configure gcc + run: ./configure CC=gcc --enable-snprintf-replacement --enable-timer-replacement --disable-build-docs --disable-timeout-tests + - name: make + run: make + - name: make check + run: make check + + build_osx_autotools_clang: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + # Brew may not have permission to install its packages + - name: change brew install folder permissions + run: sudo chmod -R a+rwx /usr/local/share/ || mkdir -p /usr/local/share/ -m a+rwx + - name: install automake + run: brew install automake + - name: install pkg-config + run: brew install pkgconfig + - name: create configure + run: autoreconf -i + - name: configure clang + run: ./configure CC=clang --enable-snprintf-replacement --enable-timer-replacement --disable-build-docs --disable-timeout-tests + - name: make + run: make + - name: make check + run: make check + + build_osx_autotools_example: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + # Brew may not have permission to install its packages + - name: change brew install folder permissions + run: sudo chmod -R a+rwx /usr/local/share/ || mkdir -p /usr/local/share/ -m a+rwx + - name: install maxtex + run: brew install --cask mactex + - name: install doc programs + run: brew install texi2html doxygen + - name: install automake + run: brew install automake + - name: install pkg-config + run: brew install pkgconfig + - name: create configure + run: autoreconf -i + - name: configure + run: ./configure + - name: make + run: make + - name: make install + run: sudo make install + - name: create configure example + working-directory: doc/example + run: autoreconf -i + - name: configure example + working-directory: doc/example + run: ./configure + - name: build example + working-directory: doc/example + run: make + - name: test example + working-directory: doc/example + run: make check + + build_osx_cmake: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - name: cmake cversion + run: cmake --version + - name: create configs + run: cmake . -D CHECK_ENABLE_TIMEOUT_TESTS=0 + - name: make + run: make + - name: unit tests + run: ctest -V + - name: make install + run: sudo make install diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 00000000..364dfef1 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,110 @@ +name: windows + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build_windows_vs16_cmake: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: microsoft/setup-msbuild@v1.0.0 + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + - name: echo MSBuild + run: msbuild -version + - name: mkdir build + run: mkdir build + - name: cmake configure + working-directory: build + run: cmake -G "Visual Studio 16 2019" -DCMAKE_INSTALL_PREFIX=%P% -DCMAKE_BUILD_TYPE=Debug .. + - name: vs build + working-directory: build + run: msbuild /p:Platform=x64 "ALL_BUILD.vcxproj" + - name: vs test + working-directory: build + run: msbuild /p:Platform=x64 "RUN_TESTS.vcxproj" + + build_windows_msvc_cmake: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: ilammy/msvc-dev-cmd@v1 + - name: mkdir build + run: mkdir build + - name: cmake configure + working-directory: build + run: cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%P% -DCMAKE_BUILD_TYPE=Debug .. + - name: nmake + working-directory: build + run: nmake + - name: nmake test + working-directory: build + run: nmake test VERBOSE=1 CTEST_OUTPUT_ON_FAILURE=TRUE + + build_windows_mingw32_cmake: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: mkdir build + run: mkdir build + - name: cmake configure + working-directory: build + run: cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX=%P% -DCMAKE_BUILD_TYPE=Debug .. + - name: mingw32-make + working-directory: build + run: mingw32-make +# TODO(#259): The floating point tests currently fail because the expected +# formatting for some floating values is wrong. When Check's tests are fixed +# to be more flexible enable this. +# - name: test +# working-directory: build +# run: tests\check_check.exe + + build_windows_mingw64msys_autotools: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: add mingw to path + run: echo "::add-path::C:\msys64\mingw64\bin" + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + - name: add mingw to path + run: echo "::add-path::C:\msys64\usr\bin" + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + - name: autoreconf + run: bash -c "autoreconf -i" + - name: configure + run: bash -c "./configure" + - name: make + run: bash -c "make" + - name: test + run: bash -c "tests/check_check" + + build_windows_msys2_autotools: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: autoreconf + run: C:\msys64\msys2_shell.cmd -defterm -mingw64 -no-start -full-path -here -c "autoreconf -i" + - name: configure + run: C:\msys64\msys2_shell.cmd -defterm -mingw64 -no-start -full-path -here -c "./configure" + - name: make + run: C:\msys64\msys2_shell.cmd -defterm -mingw64 -no-start -full-path -here -c "make" + - name: test + run: C:\msys64\msys2_shell.cmd -defterm -mingw64 -no-start -full-path -here -c "tests/check_check" + + build_windows_msys2_cmake: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: cmake + run: C:\msys64\msys2_shell.cmd -defterm -mingw64 -no-start -full-path -here -c "cmake -G 'MSYS Makefiles' ." + - name: make + run: C:\msys64\msys2_shell.cmd -defterm -mingw64 -no-start -full-path -here -c "make" + - name: test + run: C:\msys64\msys2_shell.cmd -defterm -mingw64 -no-start -full-path -here -c "tests/check_check" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cc73fc92..00000000 --- a/.travis.yml +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (C) 2016 Branden Archer -# Copyright (C) 2016 Joshua D. Boyd -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA. - - -language: c - -os: - - linux - - osx - -compiler: - - gcc - - clang - -env: - - USE_CMAKE=YES - - USE_CMAKE=NO - -addons: - apt: - packages: - - texinfo - -matrix: - exclude: - # There have been sporadic unit test failures with - # timeout tests on OSX using CMake. Until these are - # resolved, skipping these tests. - - os: osx - env: USE_CMAKE=YES - -script: - - mkdir build - - cd build - - if [ $USE_CMAKE == 'YES' ] ; then cmake .. ; fi - - if [ $USE_CMAKE == 'NO' ] ; then pushd .. ; autoreconf -i ; popd; fi - - if [ $USE_CMAKE == 'NO' ] ; then ../configure ; fi - - make - - if [ $USE_CMAKE == 'YES' ] ; then ctest -V ; fi - - if [ $USE_CMAKE == 'NO' ] ; then make check ; fi diff --git a/AUTHORS b/AUTHORS index 229c8d18..4b880b66 100644 --- a/AUTHORS +++ b/AUTHORS @@ -121,6 +121,8 @@ Contributors: test source code compliance to C89/C90 standard, substitution functions for floating point functions missing in older C standard libraries) + Mikko Koivunalho + (Improved CMake build, bug fixes in libcheck and libcompat) Anybody who has contributed code to Check or Check's build system is considered an author. Submit a pull request of this file or send diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d66a5d6..2ee580bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ # # Copyright (C) 2011 Mateusz Loskot # Copyright (C) 2001, 2002 Arien Malec +# Copyright (C) 2020 Mikko Koivunalho # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -19,10 +20,43 @@ # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # -project(check C) +cmake_minimum_required(VERSION 3.13 FATAL_ERROR) -cmake_minimum_required(VERSION 2.8 FATAL_ERROR) -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include(CheckCCompilerFlag) + +# Detect if Check is being used in another build as a subproject +# probably with command FetchContent*(). +set(THIS_IS_SUBPROJECT FALSE) +if(DEFINED PROJECT_NAME) + set(THIS_IS_SUBPROJECT TRUE) + message(STATUS "Turned off installing because Check is a subproject.") + message(STATUS "Turned off building tests because Check is a subproject.") +endif() + +if(POLICY CMP0090) + # export(PACKAGE) does not populate package registry by default. (NEW) + cmake_policy(SET CMP0090 NEW) +endif() +if(POLICY CMP0076) + # target_sources() leaves relative source file paths unmodified. (OLD) + cmake_policy(SET CMP0076 OLD) +endif() +project(Check + DESCRIPTION "Unit Testing Framework for C" + LANGUAGES C) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") + +############################################################################### +# Set build features + +# Set CMAKE_BUILD_TYPE to Debug if source directory is a Git repository +# or user does not override on the command line +include(BuildType) + +############################################################################### +# Configure a project for testing with CTest/CDash +include(CTest) macro(extract_version file setting_name) file(STRINGS ${file} VERSION_NUMBER REGEX "^${setting_name}") @@ -34,27 +68,53 @@ extract_version(configure.ac CHECK_MAJOR_VERSION) extract_version(configure.ac CHECK_MINOR_VERSION) extract_version(configure.ac CHECK_MICRO_VERSION) -set(CHECK_VERSION - "${CHECK_MAJOR_VERSION}.${CHECK_MINOR_VERSION}.${CHECK_MICRO_VERSION}") +set(PROJECT_VERSION_MAJOR ${CHECK_MAJOR_VERSION}) +set(PROJECT_VERSION_MINOR ${CHECK_MINOR_VERSION}) +set(PROJECT_VERSION_PATCH ${CHECK_MICRO_VERSION}) +set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") -set(MEMORY_LEAKING_TESTS_ENABLED 1) +############################################################################### +# Provides install directory variables as defined by the GNU Coding Standards. +include(GNUInstallDirs) ############################################################################### -# Set build features -set(CMAKE_BUILD_TYPE Debug) +# Follow ISO C99 standard +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_C_EXTENSIONS ON) # Use GNU extensions and POSIX standard ############################################################################### # Option option(CHECK_ENABLE_TESTS - "Enable the compilation and running of Check's unit tests" ON) - + "Deprecated: Enable the compilation and running of Check's unit tests" ON) +if(NOT CHECK_ENABLE_TESTS) + message(DEPRECATION "The option CHECK_ENABLE_TESTS is deprecated. Use option BUILD_TESTING.") + # TODO Remove this option by Check 0.15.0! +endif(NOT CHECK_ENABLE_TESTS) + +option(CHECK_ENABLE_GCOV + "Turn on test coverage" OFF) +if (CHECK_ENABLE_GCOV AND NOT ${CMAKE_C_COMPILER_ID} MATCHES "GNU") + message(FATAL_ERROR "Code Coverage (gcov) only works if GNU compiler is used!") +endif (CHECK_ENABLE_GCOV AND NOT ${CMAKE_C_COMPILER_ID} MATCHES "GNU") + +option(ENABLE_MEMORY_LEAKING_TESTS + "Enable certain memory leaking tests only if valgrind is not used in testing" ON) + +option(CHECK_ENABLE_TIMEOUT_TESTS + "Enable Check's timeout related unit tests" ON) +if(CHECK_ENABLE_TIMEOUT_TESTS) + add_definitions(-DTIMEOUT_TESTS_ENABLED=1) +else(CHECK_ENABLE_TIMEOUT_TESTS) + add_definitions(-DTIMEOUT_TESTS_ENABLED=0) +endif(CHECK_ENABLE_TIMEOUT_TESTS) ############################################################################### # Check system and architecture if(WIN32) if(MSVC60) - set(WINVER 0x0400) + set(WINVER 0x0400) else() - set(WINVER 0x0500) + set(WINVER 0x0600) endif() set(_WIN32_WINNT ${WINVER}) endif(WIN32) @@ -103,6 +163,11 @@ ck_check_include_file("string.h" HAVE_STRING_H) ck_check_include_file("strings.h" HAVE_STRINGS_H) ck_check_include_file("sys/time.h" HAVE_SYS_TIME_H) ck_check_include_file("time.h" HAVE_TIME_H) +ck_check_include_file("unistd.h" HAVE_UNISTD_H) +ck_check_include_file("pthread.h" HAVE_PTHREAD) + +# check if we have windows.h on native windows environments +ck_check_include_file("windows.h" HAVE_WINDOWS_H) ############################################################################### # Check functions @@ -120,6 +185,11 @@ check_function_exists(strdup HAVE_DECL_STRDUP) check_function_exists(strsignal HAVE_DECL_STRSIGNAL) check_function_exists(_getpid HAVE__GETPID) check_function_exists(_strdup HAVE__STRDUP) +check_function_exists(alarm HAVE_DECL_ALARM) +if (HAVE_WINDOWS_H) + check_function_exists(InitOnceBeginInitialize HAVE_INIT_ONCE_BEGIN_INITIALIZE) + check_function_exists(InitOnceComplete HAVE_INIT_ONCE_COMPLETE) +endif() if (HAVE_REGEX_H) check_function_exists(regcomp HAVE_REGCOMP) check_function_exists(regexec HAVE_REGEXEC) @@ -132,38 +202,54 @@ check_symbol_exists(snprintf stdio.h HAVE_SNPRINTF_SYMBOL) check_symbol_exists(vsnprintf stdio.h HAVE_VSNPRINTF_SYMBOL) if(NOT HAVE_SNPRINTF_FUNCTION AND NOT HAVE_SNPRINTF_SYMBOL) - add_definitions(-Dsnprintf=rpl_snprintf) - set(snprintf rpl_snprintf) - add_definitions(-Dvsnprintf=rpl_vsnprintf) - set(vsnprintf rpl_vsnprintf) + add_definitions(-Dsnprintf=rpl_snprintf) + set(snprintf rpl_snprintf) + add_definitions(-Dvsnprintf=rpl_vsnprintf) + set(vsnprintf rpl_vsnprintf) else(NOT HAVE_SNPRINTF_FUNCTION AND NOT HAVE_SNPRINTF_SYMBOL) - set(HAVE_SNPRINTF 1) - add_definitions(-DHAVE_SNPRINTF=1) - set(HAVE_VSNPRINTF 1) - add_definitions(-DHAVE_VSNPRINTF=1) + set(HAVE_SNPRINTF 1) + add_definitions(-DHAVE_SNPRINTF=1) + set(HAVE_VSNPRINTF 1) + add_definitions(-DHAVE_VSNPRINTF=1) endif(NOT HAVE_SNPRINTF_FUNCTION AND NOT HAVE_SNPRINTF_SYMBOL) if(HAVE_FORK) - add_definitions(-DHAVE_FORK=1) - set(HAVE_FORK 1) + add_definitions(-DHAVE_FORK=1) + set(HAVE_FORK 1) else(HAVE_FORK) - add_definitions(-DHAVE_FORK=0) - set(HAVE_FORK 0) + add_definitions(-DHAVE_FORK=0) + set(HAVE_FORK 0) endif(HAVE_FORK) if(HAVE_MKSTEMP) - add_definitions(-DHAVE_MKSTEMP=1) - set(HAVE_MKSTEMP 1) + add_definitions(-DHAVE_MKSTEMP=1) + set(HAVE_MKSTEMP 1) else(HAVE_MKSTEMP) - add_definitions(-DHAVE_MKSTEMP=0) - set(HAVE_MKSTEMP 0) + add_definitions(-DHAVE_MKSTEMP=0) + set(HAVE_MKSTEMP 0) endif(HAVE_MKSTEMP) +if(HAVE_DECL_ALARM) + add_definitions(-DHAVE_DECL_ALARM=1) + set(HAVE_DECL_ALARM 1) +else(HAVE_DECL_ALARM) + add_definitions(-DHAVE_DECL_ALARM=0) + set(HAVE_DECL_ALARM 0) +endif(HAVE_DECL_ALARM) + if(HAVE_REGEX_H AND HAVE_REGCOMP AND HAVE_REGEXEC) - add_definitions(-DHAVE_REGEX=1) - set(HAVE_REGEX 1) - add_definitions(-DENABLE_REGEX=1) - set(ENABLE_REGEX 1) + add_definitions(-DHAVE_REGEX=1) + set(HAVE_REGEX 1) + add_definitions(-DENABLE_REGEX=1) + set(ENABLE_REGEX 1) +endif() + +if (HAVE_PTHREAD) + check_c_compiler_flag("-pthread" HAVE_PTHREADS_FLAG) + if (HAVE_PTHREADS_FLAG) + add_definitions("-pthread") + add_link_options("-pthread") + endif() endif() @@ -184,39 +270,39 @@ check_symbol_exists(INT64_MIN "${headers}" HAVE_INT64_MIN) check_symbol_exists(UINT32_MAX "${headers}" HAVE_UINT32_MAX) check_symbol_exists(UINT64_MAX "${headers}" HAVE_UINT64_MAX) check_symbol_exists(SIZE_MAX "${headers}" HAVE_SIZE_MAX) -check_symbol_exists(SSIZE_MAX "limits.h" HAVE_SSIZE_MAX) +check_symbol_exists(SSIZE_MAX "limits.h" HAVE_SSIZE_MAX) ############################################################################### # Check struct members # Check for tv_sec in struct timeval if(NOT HAVE_SYS_TIME_H) - if(MSVC) - check_struct_member("struct timeval" tv_sec "Winsock2.h" HAVE_STRUCT_TIMEVAL_TV_SEC) - check_struct_member("struct timeval" tv_usec "Winsock2.h" HAVE_STRUCT_TIMEVAL_TV_USEC) - check_struct_member("struct timespec" tv_sec "Winsock2.h" HAVE_WINSOCK2_H_STRUCT_TIMESPEC_TV_SEC) - check_struct_member("struct timespec" tv_sec "time.h" HAVE_TIME_H_STRUCT_TIMESPEC_TV_SEC) - check_struct_member("struct itimerspec" it_value "Winsock2.h" HAVE_STRUCT_ITIMERSPEC_IT_VALUE) - - if(NOT HAVE_WINSOCK2_H_STRUCT_TIMESPEC_TV_SEC AND NOT HAVE_TIME_H_STRUCT_TIMESPEC_TV_SEC) - add_definitions(-DSTRUCT_TIMESPEC_DEFINITION_MISSING=1) - set(STRUCT_TIMESPEC_DEFINITION_MISSING 1) - endif(NOT HAVE_WINSOCK2_H_STRUCT_TIMESPEC_TV_SEC AND NOT HAVE_TIME_H_STRUCT_TIMESPEC_TV_SEC) - - if(NOT HAVE_STRUCT_ITIMERSPEC_IT_VALUE) - add_definitions(-DSTRUCT_ITIMERSPEC_DEFINITION_MISSING=1) - set(STRUCT_ITIMERSPEC_DEFINITION_MISSING 1) - endif(NOT HAVE_STRUCT_ITIMERSPEC_IT_VALUE) - endif(MSVC) + if(MSVC) + check_struct_member("struct timeval" tv_sec "Winsock2.h" HAVE_STRUCT_TIMEVAL_TV_SEC) + check_struct_member("struct timeval" tv_usec "Winsock2.h" HAVE_STRUCT_TIMEVAL_TV_USEC) + check_struct_member("struct timespec" tv_sec "Winsock2.h" HAVE_WINSOCK2_H_STRUCT_TIMESPEC_TV_SEC) + check_struct_member("struct timespec" tv_sec "time.h" HAVE_TIME_H_STRUCT_TIMESPEC_TV_SEC) + check_struct_member("struct itimerspec" it_value "Winsock2.h" HAVE_STRUCT_ITIMERSPEC_IT_VALUE) + + if(NOT HAVE_WINSOCK2_H_STRUCT_TIMESPEC_TV_SEC AND NOT HAVE_TIME_H_STRUCT_TIMESPEC_TV_SEC) + add_definitions(-DSTRUCT_TIMESPEC_DEFINITION_MISSING=1) + set(STRUCT_TIMESPEC_DEFINITION_MISSING 1) + endif(NOT HAVE_WINSOCK2_H_STRUCT_TIMESPEC_TV_SEC AND NOT HAVE_TIME_H_STRUCT_TIMESPEC_TV_SEC) + + if(NOT HAVE_STRUCT_ITIMERSPEC_IT_VALUE) + add_definitions(-DSTRUCT_ITIMERSPEC_DEFINITION_MISSING=1) + set(STRUCT_ITIMERSPEC_DEFINITION_MISSING 1) + endif(NOT HAVE_STRUCT_ITIMERSPEC_IT_VALUE) + endif(MSVC) endif(NOT HAVE_SYS_TIME_H) # OSX has sys/time.h, but it still lacks itimerspec if(HAVE_SYS_TIME_H) - check_struct_member("struct itimerspec" it_value "sys/time.h" HAVE_STRUCT_ITIMERSPEC_IT_VALUE) - if(NOT HAVE_STRUCT_ITIMERSPEC_IT_VALUE) - add_definitions(-DSTRUCT_ITIMERSPEC_DEFINITION_MISSING=1) - set(STRUCT_ITIMERSPEC_DEFINITION_MISSING 1) - endif(NOT HAVE_STRUCT_ITIMERSPEC_IT_VALUE) + check_struct_member("struct itimerspec" it_value "sys/time.h" HAVE_STRUCT_ITIMERSPEC_IT_VALUE) + if(NOT HAVE_STRUCT_ITIMERSPEC_IT_VALUE) + add_definitions(-DSTRUCT_ITIMERSPEC_DEFINITION_MISSING=1) + set(STRUCT_ITIMERSPEC_DEFINITION_MISSING 1) + endif(NOT HAVE_STRUCT_ITIMERSPEC_IT_VALUE) endif(HAVE_SYS_TIME_H) ############################################################################### @@ -298,46 +384,120 @@ unset(CMAKE_EXTRA_INCLUDE_FILES) check_library_exists(m floor "" HAVE_LIBM) if (HAVE_LIBM) - set (LIBM "m") + set (LIBM "m") endif (HAVE_LIBM) check_library_exists(rt clock_gettime "" HAVE_LIBRT) if (HAVE_LIBRT) - set(LIBRT "rt") - ADD_DEFINITIONS(-DHAVE_LIBRT=1) + set(LIBRT "rt") + ADD_DEFINITIONS(-DHAVE_LIBRT=1) endif (HAVE_LIBRT) check_library_exists(subunit subunit_test_start "" HAVE_SUBUNIT) if (HAVE_SUBUNIT) - set(SUBUNIT "subunit") - set(ENABLE_SUBUNIT 1) - add_definitions(-DENABLE_SUBUNIT=1) + set(SUBUNIT "subunit") + set(ENABLE_SUBUNIT 1) + add_definitions(-DENABLE_SUBUNIT=1) else(HAVE_SUBUNIT) - set(ENABLE_SUBUNIT 0) - add_definitions(-DENABLE_SUBUNIT=0) + set(ENABLE_SUBUNIT 0) + add_definitions(-DENABLE_SUBUNIT=0) endif (HAVE_SUBUNIT) ############################################################################### -# Generate "config.h" from "cmake/config.h.cmake" +# Generate "config.h" from "cmake/config.h.in" configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) + # Param @ONLY not used on purpose! include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) add_definitions(-DHAVE_CONFIG_H) set(CONFIG_HEADER ${CMAKE_CURRENT_BINARY_DIR}/config.h) + +############################################################################### +# Generate "check_stdint.h" from "cmake/check_stdint.h.in" +# +# The corresponding GNU Autotools build of this project +# has m4 macro `m4/ax_create_stdint_h.m4` to create +# the file `check_stdint.h` from scratch. +# Include file `stdint.h` was introduced in C99 ANSI standard but +# many compilers were lacking behind or still are and +# have not implemented C99 or their `stdint.h` is not compatible. +# Therefore the m4 macro was needed to create the required datatypes. +# +# When converting to CMake we also want to abandon the m4 macros. +# configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_stdint.h.in - ${CMAKE_CURRENT_BINARY_DIR}/check_stdint.h) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/check_stdint.h DESTINATION include) + ${CMAKE_CURRENT_BINARY_DIR}/check_stdint.h @ONLY) +if(NOT THIS_IS_SUBPROJECT) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/check_stdint.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +endif() + +############################################################################### +# Generate "check.pc", the package config (pkgconfig) file for libtool +if(NOT THIS_IS_SUBPROJECT) + set(prefix_save "${PREFIX}") + set(prefix "${CMAKE_INSTALL_PREFIX}") + set(exec_prefix "\${prefix}") + set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) + set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) + set(VERSION "${PROJECT_VERSION}") + + if (HAVE_SUBUNIT) + set(LIBSUBUNIT_PC "libsubunit") + else (HAVE_SUBINIT) + set(LIBSUBUNIT_PC "") + endif (HAVE_SUBUNIT) + + if (CHECK_ENABLE_GCOV) + set(GCOV_LIBS "-lgcov") + else (CHECK_ENABLE_GCOV) + set(GCOV_LIBS "") + endif (CHECK_ENABLE_GCOV) + + set(PTHREAD_LIBS "-pthread") + set(LIBS "") + + if (HAVE_LIBM) + set(LIBS "${LIBS} -lm") + endif (HAVE_LIBM) + + if (HAVE_LIBRT) + set(LIBS "${LIBS} -lrt") + endif (HAVE_LIBRT) + + set(PTHREAD_CFLAGS "-pthread") + + configure_file(check.pc.in check.pc @ONLY) + + unset(PTHREAD_CFLAGS) + unset(LIBS) + unset(PTHREAD_LIBS) + unset(GCOV_LIBS) + unset(LIBSUBUNIT_PC) + unset(VERSION) + unset(includedir) + unset(libdir) + unset(exec_prefix) + set(PREFIX "${prefix_save}") + + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/check.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig + ) +endif() ############################################################################### # Subdirectories +add_subdirectory(doc) add_subdirectory(lib) add_subdirectory(src) +add_subdirectory(checkmk) ############################################################################### # Unit tests -if (CHECK_ENABLE_TESTS) +if(BUILD_TESTING AND NOT THIS_IS_SUBPROJECT) add_subdirectory(tests) - enable_testing() add_test(NAME check_check COMMAND check_check) add_test(NAME check_check_export COMMAND check_check_export) @@ -366,3 +526,56 @@ if (CHECK_ENABLE_TESTS) COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_set_max_msg_size.sh) endif(UNIX OR MINGW OR MSYS) endif() + +############################################################################### +# Export project, prepare a config and config-version files +if(NOT THIS_IS_SUBPROJECT) + string(TOLOWER ${PROJECT_NAME} EXPORT_NAME) + include(CMakePackageConfigHelpers) + configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${EXPORT_NAME}-config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/cmake/${EXPORT_NAME}-config.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/${EXPORT_NAME}/cmake + ) + write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/cmake/${EXPORT_NAME}-config-version.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion + ) + + export(EXPORT check-targets + FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/${EXPORT_NAME}-targets.cmake" + NAMESPACE "${PROJECT_NAME}::" + ) + + install(EXPORT check-targets + NAMESPACE "${PROJECT_NAME}::" + FILE "${EXPORT_NAME}-targets.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${EXPORT_NAME} + ) + install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/cmake/${EXPORT_NAME}-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/cmake/${EXPORT_NAME}-config-version.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${EXPORT_NAME} + ) +endif() + +# Store the current build directory in the CMake user package registry. +# This helps dependent projects use a package from the current +# project’s build tree, i.e. without installing it. + +# In CMake 3.14 and below the export(PACKAGE) command populated +# the user package registry by default and users needed to set +# the CMAKE_EXPORT_NO_PACKAGE_REGISTRY to disable it, +# e.g. in automated build and packaging environments. Since +# the user package registry is stored outside the build tree, +# this side effect should not be enabled by default. +# Therefore CMake 3.15 and above prefer that export(PACKAGE) does nothing +# unless an explicit CMAKE_EXPORT_PACKAGE_REGISTRY variable is set. +if(NOT THIS_IS_SUBPROJECT) + export(PACKAGE "${PROJECT_NAME}") +endif() + +# vim: shiftwidth=2:softtabstop=2:tabstop=2:expandtab:autoindent + diff --git a/HACKING b/HACKING index e0cd7f27..4f4ed8df 100644 --- a/HACKING +++ b/HACKING @@ -15,6 +15,14 @@ are three-fold: 3) it reduces the number of decisions that must be made +Doxygen Reference for Development +================ + +You can use `doc/doxygen-devel` target to generate a verbose doxygen reference. +Resulting documentation will be placed into `doc/doxygen-devel`. This option +needs graphviz installed to render call graphs. If graphviz is not found they +won't be rendered. + Release Process =============== @@ -141,40 +149,16 @@ $ git push github gh-pages:gh-pages Automatic building of pull requests =============== -The GitHub project is configured to build pull requests either when -asked or automatically. This is done using the GitHub Pull Request -Builder Plugin. Documentation here: - - https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin - -When a new pull request is opened in the project and the author of the pull request -isn't white-listed, builder will ask "Can one of the admins verify this patch?". - -An admin can add one of the following comments to the pull request: - "ok to test" to accept this pull request for testing - "test this please" for a one time test run - "add to whitelist" to add the author to the whitelist - -If the build fails for other various reasons you can rebuild. - - "retest this please" to start a new build - -When a build is triggered a job on the Jenkins instance will start: - - https://check.ci.cloudbees.com/job/github-merge-builder/ - -When complete, a comment will be added to the pull request, informing -of the result. - -An admin can be added to the Jenkins instance by adding a username -to the "Admin list" setting under the "GitHub Pull Request Builder" -section here: +The GitHub project is configured to build requests automatically. +This is done using GitHub Actions and AppVeyor. GitHub Actions is +configured to build and test against Linux, macOS, and Windows, using +the configurations under: - https://check.ci.cloudbees.com/configure + .github/workflows -This works because there is a user in the libcheck organization, -"check-builder", which the Jenkins instance uses to install a -git hook and push comments to pull requests. +AppVeyor builds and tests Check for Windows, using the configuration +in appveyor.yml. These are started automatically on pull requests, +and the results are reported in the pull request when finished. Using gcov diff --git a/Makefile.am b/Makefile.am index 27d2531e..f04c0e0d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,13 @@ ## run tests after everything else -SUBDIRS = lib src doc . checkmk tests +if MAKE_DOCS +OPTIONAL_DOC_TARGET = doc +else +OPTIONAL_DOC_TARGET = +endif + +SUBDIRS = lib src $(OPTIONAL_DOC_TARGET) . checkmk tests ## FIXME: maybe we don't need this line @@ -20,6 +26,7 @@ include_HEADERS = check_stdint.h EXTRA_DIST = check.pc.in $(m4data_DATA) xml/check_unittest.xslt \ CMakeLists.txt src/CMakeLists.txt tests/CMakeLists.txt lib/CMakeLists.txt \ + checkmk/CMakeLists.txt \ cmake ## install docs @@ -47,6 +54,9 @@ doc/check_html: doc/doxygen: $(MAKE) -C doc doxygen +doc/doxygen-devel: + $(MAKE) -C doc doxygen-devel + # check we can do a clean build, including docs. # perhaps we should check for out of date (svn st -u) and modified files. prereleasecheck: doc/check_html doc/doxygen diff --git a/NEWS b/NEWS index 6cdebd7f..a6e06589 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,88 @@ -In Development: -# Mentioning Check 0.12.0 for now, to fix distcheck target until next release +Fri Aug 7, 2020: Released Check 0.15.2 + based on hash 4ed1ae13fdfd3033a83c06a6abd9276128944074 + +* Fix fail* APIs, regression from 0.15.1 + Issue #298 + + +Sun July 19, 2020: Released Check 0.15.1 + based on hash db3ef470271e6e011f2cd1f5231a50375568bb46 + +* Fix warning in ptr macros with pointer to integer cast + Issue #284 + +* Fix various warnings in Check's unit tests + Issue #283 + +* Replace gnu_printf with printf in format __attribute__ + Issue #282 + +* Fix warnings from Check's macros: "warning: too many arguments for format" + Issue #274 + +* Fix format specifiers that do not match the argument types + Issue #271 + + +Sun June 21, 2020: Released Check 0.15.0 + based on hash 18d83fb9bab41b7bfb6535ed44c131004d01d5ad + +* Define CK_ATTRIBUTE_FORMAT for GCC >= 2.95.3, to make use of + ‘gnu_printf’ format attribute + Issue #249 + +* Refactor tests to fix signed - unsigned conversions + Issue #249 + +* Refactor some Check internals to use proper interger types + Issue #250 + +* Implement missing mutual exclusion for Windows hosts + Issue #257 + + +Sun Jan 26, 2020: Released Check 0.14.0 + based on hash 0076ec62f71d33b5b54530f8471b4c99f50638d7 + +* Add support for FetchContent in CMake + Issue #238 + +* Rename CMake project from 'check' to 'Check' + Issue #232 + +* Fix for checking for wrong tool when building docs in Autotools + Issue #231 + +* Fix compiler warning with printf format + Issue #233 + + +Sat Oct 20, 2019: Released Check 0.13.0 + based on hash 2b18886a9a9d3bab44917a550d12128ad7e2c197 + +* configure: optional build documentation + Issue #206 (GitHub) + +* missing in some files + Issue #196 and Issue #186 (GitHub) + +* Various documentation improvements + +* END_TEST is now optional, as how START_TEST works has been redone + Issue #158 + +* Various CMake related changes: + - Support exporting Check to other projects with CMake 3 + Issue #185 + - Shared library support for Visual Studio + Issue #220 + - Fix wrong library filename + Issue #226 + - Add support for CMake package registry + Issue #227 + - CMake build type can now be debug or release + Issue #228 + - Add checkmk to CMake build. Fri Oct 20, 2017: Released Check 0.12.0 diff --git a/README.md b/README.md index 966c97fa..9a339bdb 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,20 @@ -# About Check +
-[![Travis Build Status](https://travis-ci.org/libcheck/check.svg?branch=master)](https://travis-ci.org/libcheck/check) -[![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/github/libcheck/check?svg=true)](https://ci.appveyor.com/project/libcheck/check/branch/master) +# Check +[![Linux Build Status](https://github.com/libcheck/check/workflows/linux/badge.svg)](https://github.com/libcheck/check/actions?query=workflow%3Alinux) +[![OSX Build Status](https://github.com/libcheck/check/workflows/osx/badge.svg)](https://github.com/libcheck/check/actions?query=workflow%3Aosx) +[![Windows Build Status](https://github.com/libcheck/check/workflows/windows/badge.svg)](https://github.com/libcheck/check/actions?query=workflow%3Awindows) + +
+ +## Table of Contents + * [About](#about) + * [Installing](#installing) + * [Linking](#linking) + * [Packaging](#packaging) + +## About Check is a unit testing framework for C. It features a simple interface for defining unit tests, putting little in the way of the @@ -14,7 +26,7 @@ source code editors and IDEs. See https://libcheck.github.io/check for more information, including a tutorial. The tutorial is also available as `info check`. -# Installation +## Installing Check has the following dependencies: @@ -28,21 +40,23 @@ Check has the following dependencies: The versions specified may be higher than those actually needed. -## autoconf +### autoconf $ autoreconf --install $ ./configure $ make $ make check $ make install + $ sudo ldconfig in this directory to set everything up. autoreconf calls all of the necessary tools for you, like autoconf, automake, autoheader, etc. If you ever change something during development, run autoreconf again (without --install), and it will perform the minimum set of actions -necessary. +necessary. Check is installed to `/usr/local/lib` by default. ldconfig rebuilds +the linker cache so that newly installed library file is included in the cache. -## cmake +### cmake $ mkdir build $ cd build @@ -50,9 +64,19 @@ necessary. $ make $ CTEST_OUTPUT_ON_FAILURE=1 make test -# Linking against Check +## Linking Check uses variadic macros in check.h, and the strict C90 options for gcc will complain about this. In gcc 4.0 and above you can turn this off explicitly with `-Wno-variadic-macros`. In a future API it would be nice to eliminate these macros. + +## Packaging + +Check is available packaged for the following operating systems: + +
+ +[![Packaging status](https://repology.org/badge/vertical-allrepos/check.svg)](https://repology.org/project/check/versions) + +
diff --git a/TODO b/TODO index 7236c698..3045d3f6 100644 --- a/TODO +++ b/TODO @@ -3,7 +3,7 @@ TODO The following are considered bugs in Check. If you have a fix, please post it as a pull request on GitHub at - https://github.com/libcheck/check/pulls +https://github.com/libcheck/check/pulls Bug fixing is considered more important than feature requests at this point. Please check the GitHub issue tracker before submitting. @@ -20,14 +20,15 @@ Documentation [ ] * Document pkg-config usage, note that old macro usage is not recommended. [0.9.9] * Document selective running of tests with CK_RUN_SUITE and CK_RUN_CASE environment variables. +[ ] * Update tutorial to match with the API changes: TTest* instead of TFun. Interface ========= [ ] * Change check not to clobber things in the global namespace. Prepend CHECK_ to all constants, check_ to all exported symbols, - and _check to all internal functions. Currently fail() is - causing a problem. Deprecate the old API in a nice way. + and _check to all internal functions. Currently fail() is + causing a problem. Deprecate the old API in a nice way. Build issues: ============= @@ -38,9 +39,9 @@ Build issues: [0.9.4] * Convert Check to use Libtool [ ] * Figure out if we need stamp-h.in or not [ ] * use AC_CONFIG_MACRO_DIR([m4]) and create an m4/ dir for check.m4 - aclocaldir = $(datadir)/aclocal - aclocal_DATA = mymacro.m4 myothermacro.m4 - ACLOCAL_AMFLAGS = -I m4 # put in top-level Makefile.am + aclocaldir = $(datadir)/aclocal + aclocal_DATA = mymacro.m4 myothermacro.m4 + ACLOCAL_AMFLAGS = -I m4 # put in top-level Makefile.am [ ] * Fix overriding CFLAGS in configure.ac [ ] * Use AC_DEFINE to define version number stuff? [ ] * Change MICRO to ALPHA? probably not @@ -55,13 +56,20 @@ Build issues: [ ] * use stricter CFLAGS for compiling Check [ ] * use ax_cflags_gcc_option to add to CFLAGS to Check [ ] * prune unused checks from configure.ac +[ ] * Add option BUILD_DOCUMENTATION to CMake (Github #217). +[ ] * Missing function check in CMake creates def HAVE_FOO=0. + There should be no HAVE_FOO (Github #195). +[ ] * CMake and Autotools should check if compiler supports __attribute__ ((format (a, b, c))) + to decide if CK_ATTRIBUTE_FORMAT can be defined + https://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html + Check source code: ============ -[ ] * Eliminate abbreviations like nf for number_failed +[0.13.0] * Eliminate abbreviations like nf for number_failed [0.9.13] * Run indent on everything, make sure it works well. -[ ] * Fix START_TEST/END_TEST to look like valid C code. +[0.13.0] * Fix START_TEST/END_TEST to look like valid C code. [ ] * Document things way more. [ ] * Create check.h automatically using makeheaders.c (not sure) [ ] * Eliminate check_ prefix from files in src/ ... not needed @@ -90,6 +98,10 @@ Packaging [0.9.2] * Get Check into Debian Sid [0.9.4] * Eliminate .deb and .rpm packaging for vendors --- not necessary +Website +======= +[ ] * Fix: NEWS tab causes download (Github #1) + The following enhancements are being considered for Check. Please @@ -119,20 +131,20 @@ Unit test writing [ ] * Autoproduce unit testing framework from header files [ ] * Count the number of START_TEST macros and check that each function is added to some suite; issue a warning message otherwise. Maybe the - best way to do this is to put each function onto a list or + best way to do this is to put each function onto a list or table as its defined, and then remove it once its added somewhere. Then, when finished, print out what remains on the list / in the table. This might require some ugly macro hackery... [ ] * Better macro for START_TEST. It would be nice to pass in - three separate arguments, something like: + three separate arguments, something like: 1) a numeric ID for the tests function 2) the exact name of the function being tested 3) the name of the feature in (2) being tested for [ ] * Find a way to create setup/teardown macros such that global - variables aren't necessary, and they're really just blocks - that get added at the beginning and ending of tests. + variables aren't necessary, and they're really just blocks + that get added at the beginning and ending of tests. [ ] * Some mechanism to profile execution times, and assert that the time - a test takes to complete scales according to some big-O notation. + a test takes to complete scales according to some big-O notation. [ ] * Fork entire test cases, and then fork individual tests from within each test case, so that unchecked fixtures can in fact do unsafe things without bringing down the entire test diff --git a/appveyor.yml b/appveyor.yml index ec46360c..ec6d03cb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -109,7 +109,10 @@ before_build: # the MinGW builds - set PATH=%PATH:C:\Program Files\Git\usr\bin;=% - if %platform%==msvc call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" - - if %platform%==msvc cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%P% + - if %platform%==msvc mkdir build + - if %platform%==msvc chdir build + - if %platform%==msvc cmake --version + - if %platform%==msvc cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=%P% -DCMAKE_BUILD_TYPE=Debug .. - if %platform%==vs ( set "makecommand=Visual Studio" ) @@ -154,12 +157,18 @@ before_build: - if %arch%==ARM ( set "makecommand=%makecommand% ARM" ) - - if %platform%==vs cmake -G "%makecommand%" -DCMAKE_INSTALL_PREFIX=%P% + - if %platform%==vs mkdir build + - if %platform%==vs chdir build + - if %platform%==vs cmake --version + - if %platform%==vs cmake -G "%makecommand%" -DCMAKE_INSTALL_PREFIX=%P% -DCMAKE_BUILD_TYPE=Debug .. - if %platform%==cygwin set PATH=C:\cygwin\bin;%PATH% - if %platform%==cygwin bash -c "autoreconf -i" - if %platform%==cygwin bash -c "./configure" - if %platform%==mingw32 set PATH=C:\MinGW\bin;%PATH% - - if %platform%==mingw32 cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX=%P% + - if %platform%==mingw32 mkdir build + - if %platform%==mingw32 chdir build + - if %platform%==mingw32 cmake --version + - if %platform%==mingw32 cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX=%P% -DCMAKE_BUILD_TYPE=Debug .. - if %platform%==mingw64msys set PATH=C:\msys64\mingw64\bin;C:\msys64\usr\bin;%PATH% - if %platform%==mingw64msys bash -c "autoreconf -i" - if %platform%==mingw64msys bash -c "./configure" diff --git a/checkmk/CMakeLists.txt b/checkmk/CMakeLists.txt new file mode 100644 index 00000000..cd201308 --- /dev/null +++ b/checkmk/CMakeLists.txt @@ -0,0 +1,43 @@ +# +# Check: a unit test framework for C +# Copyright (C) 2020 Mikko Koivunalho +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + +set(conf_file "checkmk.in" FILEPATH) +set(configure_input "Generated from ${conf_file} by configure.") +find_program(AWK_PATH awk) + +configure_file(checkmk.in checkmk @ONLY) + +file(COPY doc/checkmk.1 DESTINATION man/man1) + +option(INSTALL_CHECKMK "Install checkmk" ON) +if(INSTALL_CHECKMK AND NOT THIS_IS_SUBPROJECT) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/checkmk + DESTINATION ${CMAKE_INSTALL_BINDIR} + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + ) + install( + DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR} + ) +endif() + +# vim: shiftwidth=2:softtabstop=2:tabstop=2:expandtab:autoindent + diff --git a/checkmk/doc/checkmk.1 b/checkmk/doc/checkmk.1 index 3c7033d1..281707ea 100644 --- a/checkmk/doc/checkmk.1 +++ b/checkmk/doc/checkmk.1 @@ -69,7 +69,7 @@ to edit, and could result in the fixes being overwritten when the output files are regenerated. .PP #line directives are automatically -supressed when the input file is provided on standard input +suppressed when the input file is provided on standard input instead of as a command-line argument. .SH "BASIC EXAMPLE" .PP diff --git a/cmake/BuildType.cmake b/cmake/BuildType.cmake new file mode 100644 index 00000000..4326c7c7 --- /dev/null +++ b/cmake/BuildType.cmake @@ -0,0 +1,15 @@ +# Set a default build type if none was specified +set(default_build_type "Release") +if(EXISTS "${CMAKE_SOURCE_DIR}/.git") + set(default_build_type "Debug") +endif() + +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to '${default_build_type}' as none was specified.") + set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE + STRING "Choose the type of build." FORCE) + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() + diff --git a/cmake/check-config.cmake.in b/cmake/check-config.cmake.in new file mode 100644 index 00000000..82620719 --- /dev/null +++ b/cmake/check-config.cmake.in @@ -0,0 +1,3 @@ +@PACKAGE_INIT@ +include("${CMAKE_CURRENT_LIST_DIR}/@EXPORT_NAME@-targets.cmake") + diff --git a/cmake/check_stdint.h.in b/cmake/check_stdint.h.in index ab467c1f..13f284a9 100644 --- a/cmake/check_stdint.h.in +++ b/cmake/check_stdint.h.in @@ -1,6 +1,41 @@ +/*-*- mode:C; -*- */ +/* + * Check: a unit test framework for C + * + * Copyright (C) 2013 Branden Archer + * Copyright (C) 2019 Mikko Johannes Koivunalho + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + #ifndef _CHECK_CHECK_STDINT_H #define _CHECK_CHECK_STDINT_H 1 +#ifndef _GENERATED_STDINT_H +#define _GENERATED_STDINT_H "@PROJECT_NAME@ @PROJECT_VERSION@" +/* generated using CMake @CMAKE_VERSION@ from file cmake/check_stdint.h.in */ + +/* Imported CMake variables created during build. */ +#cmakedefine HAVE_STDINT_H 1 + #ifdef HAVE_STDINT_H +#define _STDINT_HAVE_STDINT_H 1 #include -#endif -#endif +#undef HAVE_STDINT_H +#endif /* defined HAVE_STDINT_H */ + +/* Define only once */ +#endif /* _GENERATED_STDINT_H */ +#endif /* _CHECK_CHECK_STDINT_H */ diff --git a/cmake/config.h.in b/cmake/config.h.in index aaa447f9..cea2f3b3 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -300,6 +300,21 @@ typedef uint64_t uintmax_t; /* Define to 1 if you have the header file. */ #cmakedefine HAVE_TIME_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H 1 + +/* Define to 1 if you have header file. */ +#cmakedefine HAVE_WINDOWS_H 1 + +/* Define to 1 if you have header file. */ +#cmakedefine HAVE_SYNCHAPI_H 1 + +/* Define to 1 if you have the 'InitOnceBeginInitialize' function. */ +#cmakedefine HAVE_INIT_ONCE_BEGIN_INITIALIZE 1 + +/* Define to 1 if you have the 'InitOnceComplete' function. */ +#cmakedefine HAVE_INIT_ONCE_COMPLETE 1 + /* Define to 1 if the system has the type `unsigned long long'. */ #cmakedefine HAVE_UNSIGNED_LONG_LONG 1 @@ -318,6 +333,9 @@ typedef uint64_t uintmax_t; /* Define to 1 if you have the `_strdup' function. */ #cmakedefine HAVE__STRDUP 1 +/* Define 1 if you have pthread support. */ +#cmakedefine HAVE_PTHREAD 1 + /* Version number of Check */ #cmakedefine CHECK_VERSION "${CHECK_MAJOR_VERSION}.${CHECK_MINOR_VERSION}.${CHECK_MICRO_VERSION}" diff --git a/configure.ac b/configure.ac index 929fcf3e..9c57a9c1 100644 --- a/configure.ac +++ b/configure.ac @@ -4,10 +4,10 @@ # Prelude. AC_PREREQ([2.59]) -AC_INIT([Check], [0.12.0], [check-devel at lists dot sourceforge dot net]) +AC_INIT([Check], [0.15.2], [check-devel at lists dot sourceforge dot net]) CHECK_MAJOR_VERSION=0 -CHECK_MINOR_VERSION=12 -CHECK_MICRO_VERSION=0 +CHECK_MINOR_VERSION=15 +CHECK_MICRO_VERSION=2 CHECK_VERSION=$CHECK_MAJOR_VERSION.$CHECK_MINOR_VERSION.$CHECK_MICRO_VERSION # unique source file --- primitive safety check @@ -33,6 +33,11 @@ AC_SUBST(CHECK_MINOR_VERSION) AC_SUBST(CHECK_MICRO_VERSION) AC_SUBST(CHECK_VERSION) +# The PROJECT_VERSION variable definition is required for +# compatibility with the CMake configuration interface. +# +AC_SUBST([PROJECT_VERSION], $CHECK_VERSION) + # Configure options. # allow `./configure --enable-silent-rules' and `make V=0' m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([no])]) @@ -72,6 +77,15 @@ AC_HELP_STRING([--enable-timeout-tests], *) AC_MSG_ERROR(bad value ${enableval} for --enable-timeout-tests) ;; esac], [enable_timeout_tests=true ]) +AC_ARG_ENABLE(build-docs, +AC_HELP_STRING([--enable-build-docs], + [turn on building documentation @<:@default=yes@:>@]), +[case "${enableval}" in + yes) enable_build_docs=true ;; + no) enable_build_docs=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-build-docs) ;; +esac], [enable_build_docs=true ]) + AM_CONDITIONAL(NO_TIMEOUT_TESTS, test x"$enable_timeout_tests" = "xfalse") AC_ARG_ENABLE(subunit, @@ -171,12 +185,19 @@ esac AC_CHECK_PROGS(GCOV, gcov, false) AC_CHECK_PROGS(LCOV, lcov, false) AC_CHECK_PROGS(GENHTML, genhtml, false) -AC_CHECK_PROGS(TEX, tex, false) -if test "$TEX" = "false"; then - # Make it [somewhat] clear to maintainers that tex is missing. Not an error - # though because 'make install' (which users need) does not build the docs - # anyway. - AC_MSG_WARN(tex not installed: cannot rebuild HTML documentation.) + +if test "xtrue" = x"$enable_build_docs"; then + AC_CHECK_PROGS(MAKEINFO, makeinfo, false) + if test "$MAKEINFO" = "false"; then + # Make it [somewhat] clear to maintainers that makeinfo is missing. Not an error + # though because 'make install' (which users need) does not build the docs + # anyway. + AC_MSG_WARN(makeinfo not installed: cannot rebuild HTML documentation.) + fi + + AM_CONDITIONAL(MAKE_DOCS, [test x"$MAKEINFO" != "xfalse"]) +else + AM_CONDITIONAL(MAKE_DOCS, [false]) fi AC_CHECK_PROGS(FILTERDIFF, filterdiff, false) if test "$FILTERDIFF" = "false"; then @@ -188,6 +209,12 @@ fi AM_CONDITIONAL(USE_FILTERDIFF, [test x"$FILTERDIFF" = x"filterdiff"]) +AC_CHECK_PROGS(GRAPHVIZ, dot, false) +# If graphviz doesn't exist 'make doc/doxygen-devel' will skip rendering graphs +# and inform the developer about it. This target is optional and it aims +# developers of libcheck, not users. +AM_CONDITIONAL(USE_GRAPHVIZ, [test x"$GRAPHVIZ" = x"dot"]) + # Checks for pthread implementation. ACX_PTHREAD CC="$PTHREAD_CC" @@ -249,6 +276,16 @@ AM_CONDITIONAL(SUBUNIT, test x"$enable_subunit" != "xfalse") # Check for POSIX regular expressions support. AC_CHECK_HEADERS([regex.h], HAVE_REGEX_H=1, HAVE_REGEX_H=0) +# Check if we have the windows headers for Init Once API +AC_CHECK_HEADERS([windows.h], HAVE_WINDOWS_H=1, HAVE_WINDOWS_H=0) +AC_SUBST(HAVE_WINDOWS_H) + +# Check if we have the One-Time Initialization API +AC_CHECK_FUNCS([InitOnceBeginInitialize], HAVE_INIT_ONCE_BEGIN_INITIALIZE=1, HAVE_INIT_ONCE_BEGIN_INITIALIZE=0) +AC_CHECK_FUNCS([InitOnceComplete], HAVE_INIT_ONCE_COMPLETE=1, HAVE_INIT_ONCE_COMPLETE=0) +AC_SUBST(HAVE_INIT_ONCE_BEGIN_INITIALIZE) +AC_SUBST(HAVE_INIT_ONCE_COMPLETE) + if test "x$HAVE_REGEX_H" = "x1"; then AC_CHECK_FUNCS([regcomp regexec], HAVE_REGEX=1, HAVE_REGEX=0) else @@ -354,15 +391,22 @@ AS_IF([test "x$AWK_PATH" = 'x*NO AWK*'], # Output files AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_FILES([check.pc - Makefile - checkmk/Makefile - doc/Makefile - lib/Makefile - src/check.h - src/Makefile - tests/Makefile - tests/test_vars]) +AC_CONFIG_FILES([ + check.pc + Makefile + checkmk/Makefile + doc/Makefile + doc/man/Makefile + doc/man/man3/Makefile + doc/man/man3/suite_create.3 + doc/man/man7/Makefile + doc/man/man7/libcheck.7 + lib/Makefile + src/check.h + src/Makefile + tests/Makefile + tests/test_vars +]) AC_OUTPUT @@ -427,4 +471,11 @@ else fi echo "POSIX regular expressions ............ $result" +if test "xtrue" = x"$enable_build_docs"; then + result="yes" +else + result="no" +fi +echo "build docs ........................... $result" + echo "==========================================" diff --git a/doc/.cvsignore b/doc/.cvsignore deleted file mode 100644 index f6773c8e..00000000 --- a/doc/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -Makefile -Makefile.in -tutorial.sgml -tutorial*.html diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 00000000..bb988c16 --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,23 @@ +# +# Check: a unit test framework for C +# Copyright (C) 2020 Jose Fernando Lopez Fernandez +# +# This library is free software; you can redistribute +# it and/or modify it under the terms of the GNU Lesser +# General Public License as published by the Free Software +# Foundation; either version 2.1 of the License, or (at +# your option) any later version. +# +# This library is distributed in the hope that it will +# be useful, but WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU Lesser General Public +# License for more details. +# +# You should have received a copy of the GNU Lesser General +# Public License along with this library; if not, write +# to the Free Software Foundation, Inc., 51 Franklin St, +# Fifth Floor, Boston, MA 02110-1301 USA +# + +ADD_SUBDIRECTORY(man) diff --git a/doc/Makefile.am b/doc/Makefile.am index 27109720..953acaaf 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,5 +1,7 @@ ## Process this file with automake to produce Makefile.in +SUBDIRS = man + info_TEXINFOS = check.texi check_TEXINFOS = fdl.texi @@ -9,6 +11,16 @@ check_html: $(srcdir)/check.texi doxygen: doxygen $(srcdir)/doxygen.conf +## if graphviz does not exist disable graph generation +if USE_GRAPHVIZ +doxygen-devel: + doxygen $(srcdir)/doxygen-devel.conf +else +doxygen-devel: + ( cat $(srcdir)/doxygen-devel.conf; echo "HAVE_DOT = NO" ) | doxygen - + @ >&2 echo "graphviz not found, graphs will not be rendered." +endif + ## we need to include several diffs as we evolve the example in the ## tutorial. this means we'll generate them from the example source. diff --git a/doc/check.texi b/doc/check.texi index 21748f86..f6852bc4 100644 --- a/doc/check.texi +++ b/doc/check.texi @@ -28,7 +28,7 @@ entitled ``@acronym{GNU} Free Documentation License.'' @dircategory Software development @direntry -* Check: (check)Introduction. +* Check: (check). A unit testing framework for C. @end direntry @titlepage @@ -2241,6 +2241,30 @@ Officially CMake is supported only for Windows. Documentation for using CMake is forthcoming. In the meantime, look at the example CMake project in Check's @file{doc/examples} directory. +If you are using CMake version 3 or above, importing Check into your project +is easier than in earlier versions. If you have installed Check +as a CMake library, you should have the following files: + +@verbatim +${INSTALL_PREFIX}/lib/cmake/check/check-config.cmake and +${INSTALL_PREFIX}/lib/cmake/check/check-config-version.cmake and +@end verbatim + +If you haven't installed Check into a system directory, you have to tell +your CMake build how to find it: + +@verbatim +cmake -Dcheck_ROOT=${INSTALL_PREFIX} + +Then use Check in your @file{CMakeLists.txt} like this: + +@verbatim +find_package(check REQUIRED CONFIG) + +add_executable(myproj.test myproj.test.c) +target_link_libraries(myproj.test Check::check) +add_test(NAME MyProj COMMAND myproj.test) +@end verbatim @node Conclusion and References, Environment Variable Reference, Supported Build Systems, Top diff --git a/doc/doxygen-devel.conf b/doc/doxygen-devel.conf new file mode 100644 index 00000000..1c75444b --- /dev/null +++ b/doc/doxygen-devel.conf @@ -0,0 +1,1781 @@ +# Doxyfile 1.7.6.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" "). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need +# to put quotes around the project name if it contains spaces. + +PROJECT_NAME = "Check" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = "Unit testing framework for C" + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = doxygen-devel + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the +# itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields will be shown inline in the documentation +# of the scope in which they are defined (i.e. file, namespace, or group +# documentation), provided this scope is documented. If set to NO (the default), +# structs, classes, and unions are shown on a separate page (for HTML and Man +# pages) or section (for LaTeX and RTF). + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +SYMBOL_CACHE_SIZE = 0 + +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given +# their name and scope. Since this can be an expensive process and often the +# same symbol appear multiple times in the code, doxygen keeps a cache of +# pre-resolved symbols. If the cache is too small doxygen will become slower. +# If the cache is too large, memory is wasted. The cache size is given by this +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = YES + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# feature you need bibtex and perl available in the search path. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = ../src/ + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = _* GCC_VERSION* CK_ATTRIBUTE* CK_EXPORT CK_DLL_EXP CHECK_* NULL check_*_version fail* + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = YES + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# style sheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set +# GENERATE_TREEVIEW to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you +# could consider to set DISABLE_INDEX to NO when enabling this option. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the +# mathjax.org site, so you can quickly see the result without installing +# MathJax, but it is strongly recommended to install a local copy of MathJax +# before deployment. + +MATHJAX_RELPATH = http://www.mathjax.org/mathjax + +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# names that should be enabled during MathJax rendering. + +MATHJAX_EXTENSIONS = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4 + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# http://en.wikipedia.org/wiki/BibTeX for more info. + +LATEX_BIB_STYLE = plain + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = YES + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# set the path where dot can find it. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = YES + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = YES + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible in IE 9+ (other browsers do not have this requirement). + +DOT_IMAGE_FORMAT = png + +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible. Older versions of IE do not have SVG support. + +INTERACTIVE_SVG = NO + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = YES + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/doc/example/.cvsignore b/doc/example/.cvsignore deleted file mode 100644 index 282522db..00000000 --- a/doc/example/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/doc/example/cmake/FindCheck.cmake b/doc/example/cmake/FindCheck.cmake index 4392d889..b6d1a864 100644 --- a/doc/example/cmake/FindCheck.cmake +++ b/doc/example/cmake/FindCheck.cmake @@ -20,12 +20,12 @@ INCLUDE( FindPkgConfig ) # Take care about check.pc settings -PKG_SEARCH_MODULE( CHECK check ) +PKG_SEARCH_MODULE( CHECK Check ) # Look for CHECK include dir and libraries IF( NOT CHECK_FOUND ) IF ( CHECK_INSTALL_DIR ) - MESSAGE ( STATUS "Using override CHECK_INSTALL_DIR to find check" ) + MESSAGE ( STATUS "Using override CHECK_INSTALL_DIR to find Check" ) SET ( CHECK_INCLUDE_DIR "${CHECK_INSTALL_DIR}/include" ) SET ( CHECK_INCLUDE_DIRS "${CHECK_INCLUDE_DIR}" ) FIND_LIBRARY( CHECK_LIBRARY NAMES check PATHS "${CHECK_INSTALL_DIR}/lib" ) diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt new file mode 100644 index 00000000..0275e648 --- /dev/null +++ b/doc/man/CMakeLists.txt @@ -0,0 +1,28 @@ +# +# Check: a unit test framework for C +# Copyright (C) 2020 Jose Fernando Lopez Fernandez +# +# This library is free software; you can redistribute +# it and/or modify it under the terms of the GNU Lesser +# General Public License as published by the Free Software +# Foundation; either version 2.1 of the License, or (at +# your option) any later version. +# +# This library is distributed in the hope that it will +# be useful, but WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU Lesser General Public +# License for more details. +# +# You should have received a copy of the GNU Lesser General +# Public License along with this library; if not, write +# to the Free Software Foundation, Inc., 51 Franklin St, +# Fifth Floor, Boston, MA 02110-1301 USA +# + +# Process each of the following man page directories once we +# have successfully configured the necessary variable(s) +# defined above. +# +ADD_SUBDIRECTORY(man3) +ADD_SUBDIRECTORY(man7) diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am new file mode 100644 index 00000000..583cbaef --- /dev/null +++ b/doc/man/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = man3 man7 diff --git a/doc/man/man3/CMakeLists.txt b/doc/man/man3/CMakeLists.txt new file mode 100644 index 00000000..f3f543d3 --- /dev/null +++ b/doc/man/man3/CMakeLists.txt @@ -0,0 +1,82 @@ +# +# Check: a unit test framework for C +# Copyright (C) 2020 Jose Fernando Lopez Fernandez +# +# This library is free software; you can redistribute +# it and/or modify it under the terms of the GNU Lesser +# General Public License as published by the Free Software +# Foundation; either version 2.1 of the License, or (at +# your option) any later version. +# +# This library is distributed in the hope that it will +# be useful, but WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU Lesser General Public +# License for more details. +# +# You should have received a copy of the GNU Lesser General +# Public License along with this library; if not, write +# to the Free Software Foundation, Inc., 51 Franklin St, +# Fifth Floor, Boston, MA 02110-1301 USA +# + +# Define the library's section 3 man pages. +# +SET(MAN3_PAGES + suite_create.3 +) + +# Configure all of the section 3 man pages defined above. +# +# This command will process each of the man pages, setting +# the project version and build date automatically. +# +FOREACH(MAN3_PAGE ${MAN3_PAGES}) + # Configure the man pages. + # + # The configuration of each man page involves only the + # addition of the library version number defined in the + # configure.ac file to each man page. + # + CONFIGURE_FILE(${MAN3_PAGE}.in ${MAN3_PAGE} @ONLY) + + # Install Section 3 Man Pages (Library Calls) + # + # This directive describes what, where, how, and when the + # section 3 man pages should be installed. Specifically, the + # ${CMAKE_INSTALL_MANDIR} variable provided by the + # GNUInstallDirs module specifies the system-specific man + # page installation directory, the permissions set the + # desired installed file(s) permissions, the configurations + # directive specifies that this directive applies for both + # Debug and Release configurations, and the component + # directive allows for the installation of only those items + # belonging to the docs component. + # + # For example, to install only the 'docs' component, the + # following command can be used after generating the project + # build files. + # + # $ cmake --install . --component docs + # + # This example assumes the project build files were + # generated in the current working directory. + # + INSTALL( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/${MAN3_PAGE} + DESTINATION + ${CMAKE_INSTALL_MANDIR}/man3 + PERMISSIONS + OWNER_READ + OWNER_WRITE + GROUP_READ + WORLD_READ + CONFIGURATIONS + Debug + Release + COMPONENT + docs + OPTIONAL + ) +ENDFOREACH() diff --git a/doc/man/man3/Makefile.am b/doc/man/man3/Makefile.am new file mode 100644 index 00000000..5a5b05cd --- /dev/null +++ b/doc/man/man3/Makefile.am @@ -0,0 +1 @@ +dist_man_MANS = suite_create.3 diff --git a/doc/man/man3/suite_create.3.in b/doc/man/man3/suite_create.3.in new file mode 100644 index 00000000..80c743b0 --- /dev/null +++ b/doc/man/man3/suite_create.3.in @@ -0,0 +1,36 @@ +.\" Copyright (c) LibCheck, 2001-2020. +.\" +.\" Permission is granted to copy, distribute and/or +.\" modify this document under the terms of the GNU +.\" Free Documentation License, Version 1.3 or any later +.\" version published by the Free Software Foundation; with +.\" no Invariant Sections, no Front-Cover Texts, and no +.\" Back-Cover Texts. A copy of the license is included in +.\" the section entitled "GNU Free Documentation License". +.\" +.TH "suite_create" "3" "" "@PROJECT_VERSION@" "LibCheck" +.SH "PROLOG" +This manual page is part of the Check Programmer's Manual. +Additional information may be found at the Check Library +home page, at https://libcheck.github.io/check/. +.SH "NAME" +suite_create +\(em create test case container object +.SH "SYNOPSIS" +.LP +.nf +#include +.P +Suite* suite_create(const char *name); +.SH "DESCRIPTION" +The +\fIsuite_create\fR() +function returns a pointer to a heap-allocated test suite +object. +.SH "RETURN VALUE" +Upon successful completion, the +\fIsuite_create\fR() +function returns a pointer containing the address of the +heap-allocated test suite object. Otherwise, the function +prints an error message to standard error indicating that +something went wrong, and then returns a NULL pointer. diff --git a/doc/man/man7/CMakeLists.txt b/doc/man/man7/CMakeLists.txt new file mode 100644 index 00000000..0f5980d8 --- /dev/null +++ b/doc/man/man7/CMakeLists.txt @@ -0,0 +1,82 @@ +# +# Check: a unit test framework for C +# Copyright (C) 2020 Jose Fernando Lopez Fernandez +# +# This library is free software; you can redistribute +# it and/or modify it under the terms of the GNU Lesser +# General Public License as published by the Free Software +# Foundation; either version 2.1 of the License, or (at +# your option) any later version. +# +# This library is distributed in the hope that it will +# be useful, but WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. See the GNU Lesser General Public +# License for more details. +# +# You should have received a copy of the GNU Lesser General +# Public License along with this library; if not, write +# to the Free Software Foundation, Inc., 51 Franklin St, +# Fifth Floor, Boston, MA 02110-1301 USA +# + +# Define the library's section 7 man pages. +# +SET(MAN7_PAGES + libcheck.7 +) + +# Configure all of the section 7 man pages defined above. +# +# This command will process each of the man pages, setting +# the project version and build date automatically. +# +FOREACH(MAN7_PAGE ${MAN7_PAGES}) + # Configure the man pages. + # + # The configuration of each man page involves only the + # addition of the library version number defined in the + # configure.ac file to each man page. + # + CONFIGURE_FILE(${MAN7_PAGE}.in ${MAN7_PAGE} @ONLY) + + # Install Section 7 Man Pages (Overview, Conventions, ...) + # + # This directive describes what, where, how, and when the + # section 7 man pages should be installed. Specifically, the + # ${CMAKE_INSTALL_MANDIR} variable provided by the + # GNUInstallDirs module specifies the system-specific man + # page installation directory, the permissions set the + # desired installed file(s) permissions, the configurations + # directive specifies that this directive applies for both + # Debug and Release configurations, and the component + # directive allows for the installation of only those items + # belonging to the docs component. + # + # For example, to install only the 'docs' component, the + # following command can be used after generating the project + # build files. + # + # $ cmake --install . --component docs + # + # This example assumes the project build files were + # generated in the current working directory. + # + INSTALL( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/${MAN7_PAGE} + DESTINATION + ${CMAKE_INSTALL_MANDIR}/man7 + PERMISSIONS + OWNER_READ + OWNER_WRITE + GROUP_READ + WORLD_READ + CONFIGURATIONS + Debug + Release + COMPONENT + docs + OPTIONAL + ) +ENDFOREACH() diff --git a/doc/man/man7/Makefile.am b/doc/man/man7/Makefile.am new file mode 100644 index 00000000..58df7f3a --- /dev/null +++ b/doc/man/man7/Makefile.am @@ -0,0 +1 @@ +dist_man_MANS = libcheck.7 diff --git a/doc/man/man7/libcheck.7.in b/doc/man/man7/libcheck.7.in new file mode 100644 index 00000000..b3c2e414 --- /dev/null +++ b/doc/man/man7/libcheck.7.in @@ -0,0 +1,26 @@ +.\" Copyright (c) LibCheck, 2001-2020. +.\" +.\" Permission is granted to copy, distribute and/or +.\" modify this document under the terms of the GNU +.\" Free Documentation License, Version 1.3 or any later +.\" version published by the Free Software Foundation; with +.\" no Invariant Sections, no Front-Cover Texts, and no +.\" Back-Cover Texts. A copy of the license is included in +.\" the section entitled "GNU Free Documentation License". +.\" +.TH "libcheck" "7" "" "@PROJECT_VERSION@" "LibCheck" +.SH "PROLOG" +This manual page is part of the Check Programmer's Manual. +Additional information may be found at the Check Library +home page, at https://libcheck.github.io/check/. +.SH "NAME" +libcheck +\(em unit testing framework for C +.SH "DESCRIPTION" +Check is a unit testing framework for C. It features a +simple interface for defining unit tests, putting little in +the way of the developer. Tests are run in a separate +address space, so Check can catch both assertion failures +and code errors that cause segmentation faults or other +signals. The output from unit tests can be used within +source code editors and IDEs. diff --git a/index.html b/index.html index 59d8e3ce..023386d7 100644 --- a/index.html +++ b/index.html @@ -56,7 +56,7 @@

Latest Check Release

-Oct 20, 2017: Check 0.12.0 +August 7, 2020: Check 0.15.2 is now available for download. Check is available under the LGPL license. New features available in this release are listed on the NEWS page. @@ -72,7 +72,6 @@

About Project

  • OpenCSW BuildBot
  • - diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index fabfdf25..38cbc53e 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -1,6 +1,7 @@ # # Check: a unit test framework for C # Copyright (C) 2011 Mateusz Loskot +# Copyright (C) 2020 Mikko Koivunalho # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -62,14 +63,17 @@ if(NOT HAVE_DECL_STRSIGNAL) set(SOURCES ${SOURCES} strsignal.c) endif(NOT HAVE_DECL_STRSIGNAL) +if(NOT HAVE_DECL_ALARM) + set(SOURCES ${SOURCES} alarm.c) +endif(NOT HAVE_DECL_ALARM) + +if (NOT HAVE_PTHREAD) + set(SOURCES ${SOURCES} pthread_mutex.c) +endif() set(HEADERS libcompat.h) add_library(compat STATIC ${SOURCES} ${HEADERS}) -install(TARGETS compat - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) +# vim: shiftwidth=2:softtabstop=2:tabstop=2:expandtab:autoindent -install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/libcompat.h DESTINATION include) diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c index e2ee0b1f..eef9f8ee 100644 --- a/lib/gettimeofday.c +++ b/lib/gettimeofday.c @@ -32,7 +32,7 @@ int gettimeofday(struct timeval *tv, void *tz) #if defined(_MSC_VER) union { - __int64 ns100; /*time since 1 Jan 1601 in 100ns units */ + __int64 ns100; /* time since 1 Jan 1601 in 100ns units */ FILETIME ft; } now; @@ -41,7 +41,7 @@ int gettimeofday(struct timeval *tv, void *tz) tv->tv_sec = (long)((now.ns100 - EPOCHFILETIME) / 10000000LL); return (0); #else - // Return that there is no implementation of this on the system + /* Return that there is no implementation of this on the system */ errno = ENOSYS; return -1; #endif /* _MSC_VER */ diff --git a/lib/libcompat.h b/lib/libcompat.h index 9ec6eb81..b5983d70 100644 --- a/lib/libcompat.h +++ b/lib/libcompat.h @@ -25,26 +25,55 @@ #include #endif -#if defined(__GNUC__) && defined(__GNUC_MINOR__) -#define GCC_VERSION_AT_LEAST(major, minor) \ +/** + * __GNUC_PATCHLEVEL__ is new to GCC 3.0; + * it is also present in the widely-used development snapshots leading up to 3.0 + * (which identify themselves as GCC 2.96 or 2.97, depending on which snapshot you have). + * + * https://stackoverflow.com/questions/1936719/what-are-the-gcc-predefined-macros-for-the-compilers-version-number/1936745#1936745 + */ + +#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) +#define GCC_VERSION_AT_LEAST(major, minor, patch) \ +((__GNUC__ > (major)) || \ + (__GNUC__ == (major) && __GNUC_MINOR__ > (minor)) || \ + (__GNUC__ == (major) && __GNUC_MINOR__ == (minor) && __GNUC_PATCHLEVEL__ >= (patch)) ) +#elif defined(__GNUC__) && defined(__GNUC_MINOR__) +#define GCC_VERSION_AT_LEAST(major, minor, patch) \ ((__GNUC__ > (major)) || \ (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) #else -#define GCC_VERSION_AT_LEAST(major, minor) 0 +#define GCC_VERSION_AT_LEAST(major, minor, patch) 0 #endif -#if GCC_VERSION_AT_LEAST(2,95) +#if GCC_VERSION_AT_LEAST(2,95,3) #define CK_ATTRIBUTE_UNUSED __attribute__ ((unused)) +#define CK_ATTRIBUTE_FORMAT(a, b, c) __attribute__ ((format (a, b, c))) #else #define CK_ATTRIBUTE_UNUSED +#define CK_ATTRIBUTE_FORMAT(a, b, c) #endif /* GCC 2.95 */ -#if GCC_VERSION_AT_LEAST(2,5) +#if GCC_VERSION_AT_LEAST(2,5,0) #define CK_ATTRIBUTE_NORETURN __attribute__ ((noreturn)) #else #define CK_ATTRIBUTE_NORETURN #endif /* GCC 2.5 */ +#if GCC_VERSION_AT_LEAST(4,7,4) && (__STDC_VERSION__ >= 199901L) +/* Operator _Pragma introduced in C99 */ +#define CK_DIAGNOSTIC_STRINGIFY(x) #x +#define CK_DIAGNOSTIC_HELPER1(y) CK_DIAGNOSTIC_STRINGIFY(GCC diagnostic ignored y) +#define CK_DIAGNOSTIC_HELPER2(z) CK_DIAGNOSTIC_HELPER1(#z) +#define CK_DIAGNOSTIC_PUSH_IGNORE(w) \ + _Pragma("GCC diagnostic push") \ + _Pragma(CK_DIAGNOSTIC_HELPER2(w)) +#define CK_DIAGNOSTIC_POP(w) _Pragma ("GCC diagnostic pop") +#else +#define CK_DIAGNOSTIC_PUSH_IGNORE(w) +#define CK_DIAGNOSTIC_POP(w) +#endif /* GCC 4.7.4 */ + /* * Used for MSVC to create the export attribute * CK_DLL_EXP is defined during the compilation of the library @@ -60,6 +89,23 @@ #include /* getpid */ #endif /* _MSC_VER */ +/* + * On some not so old version of Visual Studio (< 2015), or with mingw-w64 not + * supporting POSIX printf family function, use the size prefix specifiers + * in msvcrt.dll. See the following link for the list of the size prefix + * specifiers: + * https://docs.microsoft.com/en-us/cpp/c-runtime-library/format-specification-syntax-printf-and-wprintf-functions?view=vs-2019 + */ +#ifdef _WIN32 +#define CK_FMT_ZU "%Iu" +#define CK_FMT_ZD "%Id" +#define CK_FMT_TD "%Id" +#else +#define CK_FMT_ZU "%zu" +#define CK_FMT_ZD "%zd" +#define CK_FMT_TD "%td" +#endif + /* defines size_t */ #include @@ -113,9 +159,31 @@ extern int fpclassify(double d); #include #endif +#if defined(HAVE_INIT_ONCE_BEGIN_INITIALIZE) && defined(HAVE_INIT_ONCE_COMPLETE) +#define HAVE_WIN32_INIT_ONCE 1 +#endif + /* declares pthread_create and friends */ -#ifdef HAVE_PTHREAD +#if defined HAVE_PTHREAD #include +#elif defined HAVE_WIN32_INIT_ONCE +typedef void pthread_mutexattr_t; + +typedef struct +{ + INIT_ONCE init; + HANDLE mutex; +} pthread_mutex_t; + +#define PTHREAD_MUTEX_INITIALIZER { \ + INIT_ONCE_STATIC_INIT, \ + NULL, \ +} + +int pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *attr); +int pthread_mutex_destroy(pthread_mutex_t *mutex); +int pthread_mutex_lock(pthread_mutex_t *mutex); +int pthread_mutex_unlock(pthread_mutex_t *mutex); #endif #ifdef HAVE_STDINT_H diff --git a/lib/pthread_mutex.c b/lib/pthread_mutex.c new file mode 100644 index 00000000..abc9c182 --- /dev/null +++ b/lib/pthread_mutex.c @@ -0,0 +1,70 @@ +/* + * Check: a unit test framework for C + * Copyright (C) 2020 Wander Lairson Costa + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + +#include "libcompat.h" + +#ifdef HAVE_WIN32_INIT_ONCE + +static int mutex_init(pthread_mutex_t *mutex) +{ + BOOL pending; + int ret = 0; + + if (!InitOnceBeginInitialize(&mutex->init, 0, &pending, NULL)) + return -1; + + if (pending) + { + mutex->mutex = CreateMutexW(NULL, FALSE, NULL); + if (!mutex->mutex) + ret = -1; + } + + InitOnceComplete(&mutex->init, 0, NULL); + + return ret; +} + +int pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *attr) +{ + InitOnceInitialize(&mutex->init); + return mutex_init(mutex); +} + +int pthread_mutex_destroy(pthread_mutex_t *mutex) +{ + return CloseHandle(mutex->mutex) ? 0 : -1; +} + +int pthread_mutex_lock(pthread_mutex_t *mutex) +{ + if (mutex_init(mutex) != 0) + return -1; + + return WaitForSingleObject(mutex->mutex, INFINITE) != WAIT_OBJECT_0 + ? -1 : 0; +} + +int pthread_mutex_unlock(pthread_mutex_t *mutex) +{ + return ReleaseMutex(mutex->mutex) ? 0 : -1; +} + +#endif diff --git a/lib/snprintf.c b/lib/snprintf.c index b91b65c6..09fc0217 100644 --- a/lib/snprintf.c +++ b/lib/snprintf.c @@ -170,7 +170,6 @@ #if TEST_SNPRINTF #include /* For pow(3), NAN, and INFINITY. */ -#include /* For strcmp(3). */ #if defined(__NetBSD__) || \ defined(__FreeBSD__) || \ defined(__OpenBSD__) || \ @@ -263,6 +262,7 @@ #if !HAVE_SNPRINTF || !HAVE_VSNPRINTF #include /* For NULL, size_t, vsnprintf(3), and vasprintf(3). */ +#include /* For strcmp(3) and memset(3). */ #ifdef VA_START #undef VA_START #endif /* defined(VA_START) */ @@ -484,7 +484,12 @@ static UINTMAX_T cast(LDOUBLE); static UINTMAX_T myround(LDOUBLE); static LDOUBLE mypow10(int); +#if HAVE_VSNPRINTF +/* errno is imported from when available. + * Otherwise we declare it ourselves. + **/ extern int errno; +#endif int rpl_vsnprintf(char *str, size_t size, const char *format, va_list args) @@ -1071,6 +1076,10 @@ fmtflt(char *str, size_t *len, size_t size, LDOUBLE fvalue, int width, struct lconv *lc = localeconv(); #endif /* HAVE_LOCALECONV && HAVE_LCONV_DECIMAL_POINT */ + /* Initialize with memset because `var[n]={0}` is not supported by C90. */ + memset(iconvert, '\0', MAX_CONVERT_LENGTH); + memset(fconvert, '\0', MAX_CONVERT_LENGTH); + /* * AIX' man page says the default is 0, but C99 and at least Solaris' * and NetBSD's man pages say the default is 6, and sprintf(3) on AIX diff --git a/src/.cvsignore b/src/.cvsignore deleted file mode 100644 index 25ee911f..00000000 --- a/src/.cvsignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -Makefile -Makefile.in -libcheck.a -check.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dae28fc6..5787b599 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,7 @@ # Check: a unit test framework for C # Copyright (C) 2011 Mateusz Loskot # Copyright (C) 2001, 2002 Arien Malec +# Copyright (C) 2020 Mikko Koivunalho # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -30,7 +31,7 @@ set(SOURCES check_run.c check_str.c) -set(HEADERS +set(HEADERS ${CONFIG_HEADER} ${CMAKE_CURRENT_BINARY_DIR}/check.h check.h.in @@ -43,23 +44,158 @@ set(HEADERS check_print.h check_str.h) -configure_file(check.h.in check.h) +configure_file(check.h.in check.h @ONLY) -# Enable finding check.h -include_directories(${CMAKE_CURRENT_BINARY_DIR}) +# To maintain compatibility with the Autotools installation +# we specifically create both shared and static libraries +# as that is what Autotools script has been doing. +# Normally CMake would create the system's native default library type. add_library(check STATIC ${SOURCES} ${HEADERS}) -target_link_libraries(check ${LIBM} ${LIBRT} ${SUBUNIT}) +add_library(Check::check ALIAS check) + + +# We would like to create an OBJECT library but currently they are +# too unreliable and cumbersome, +# especially with target_link_libraries and install(EXPORT... +# https://stackoverflow.com/questions/38832528/transitive-target-include-directories-on-object-libraries +# So we instead do the work twice. +add_library(checkShared SHARED ${SOURCES} ${HEADERS}) +add_library(Check::checkShared ALIAS checkShared) + +# Add parts of libcompat as required +target_sources(check PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/fpclassify.c) +target_sources(checkShared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/fpclassify.c) + +if (NOT HAVE_LIBRT) + target_sources(check PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/clock_gettime.c) + target_sources(check PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/timer_create.c) + target_sources(check PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/timer_delete.c) + target_sources(check PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/timer_settime.c) + target_sources(checkShared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/clock_gettime.c) + target_sources(checkShared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/timer_create.c) + target_sources(checkShared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/timer_delete.c) + target_sources(checkShared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/timer_settime.c) +endif(NOT HAVE_LIBRT) + +if(NOT HAVE_GETLINE) + target_sources(check PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/getline.c) + target_sources(checkShared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/getline.c) +endif(NOT HAVE_GETLINE) + +if(NOT HAVE_GETTIMEOFDAY) + target_sources(check PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/gettimeofday.c) + target_sources(checkShared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/gettimeofday.c) +endif(NOT HAVE_GETTIMEOFDAY) + +if(NOT HAVE_DECL_LOCALTIME_R) + target_sources(check PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/localtime_r.c) + target_sources(checkShared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/localtime_r.c) +endif(NOT HAVE_DECL_LOCALTIME_R) + +if(NOT HAVE_MALLOC) + target_sources(check PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/malloc.c) + target_sources(checkShared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/malloc.c) +endif(NOT HAVE_MALLOC) + +if(NOT HAVE_REALLOC) + target_sources(check PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/realloc.c) + target_sources(checkShared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/realloc.c) +endif(NOT HAVE_REALLOC) + +if(NOT HAVE_SNPRINTF) + target_sources(check PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/snprintf.c) + target_sources(checkShared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/snprintf.c) +endif(NOT HAVE_SNPRINTF) + +if(NOT HAVE_DECL_STRDUP AND NOT HAVE__STRDUP) + target_sources(check PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/strdup.c) + target_sources(checkShared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/strdup.c) +endif(NOT HAVE_DECL_STRDUP AND NOT HAVE__STRDUP) + +if(NOT HAVE_DECL_STRSIGNAL) + target_sources(check PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/strsignal.c) + target_sources(checkShared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/strsignal.c) +endif(NOT HAVE_DECL_STRSIGNAL) + +if(NOT HAVE_DECL_ALARM) + target_sources(check PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/alarm.c) + target_sources(checkShared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/alarm.c) +endif(NOT HAVE_DECL_ALARM) + +if(NOT HAVE_PTHREAD) + target_sources(check PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/pthread_mutex.c) + target_sources(checkShared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../lib/pthread_mutex.c) +endif() + +# Include libraries if available +if (HAVE_LIBM) + target_link_libraries(check PUBLIC m) + target_link_libraries(checkShared PUBLIC m) +endif (HAVE_LIBM) +if (HAVE_LIBRT) + target_link_libraries(check PUBLIC rt) + target_link_libraries(checkShared PUBLIC rt) +endif (HAVE_LIBRT) +if (HAVE_SUBUNIT) + target_link_libraries(check PUBLIC subunit) + target_link_libraries(checkShared PUBLIC subunit) +endif (HAVE_SUBUNIT) if(MSVC) - add_definitions(-DCK_DLL_EXP=_declspec\(dllexport\)) + target_compile_definitions(checkShared + PRIVATE "CK_DLL_EXP=_declspec(dllexport)" + INTERFACE "CK_DLL_EXP=_declspec(dllimport)" + ) +endif (MSVC) + +# More configuration for exporting + +set(LIBRARY_OUTPUT_NAME "check") +list(APPEND public_headers "${CMAKE_CURRENT_BINARY_DIR}/check.h") +list(APPEND public_headers "${CMAKE_CURRENT_BINARY_DIR}/../check_stdint.h") + +set_target_properties(check PROPERTIES + OUTPUT_NAME ${LIBRARY_OUTPUT_NAME} + PUBLIC_HEADER "${public_headers}" +) + +if (MSVC) + # "On Windows you should probably give each library a different name, + # since there is a ".lib" file for both shared and static". + # https://stackoverflow.com/a/2152157/4716395 + # "Dynamic-Link Library" (DLL) is Microsoft terminology. + # So we call it this: + set(LIBRARY_OUTPUT_NAME "checkDynamic") endif (MSVC) +set_target_properties(checkShared PROPERTIES + OUTPUT_NAME ${LIBRARY_OUTPUT_NAME} + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + PUBLIC_HEADER "${public_headers}" +) +target_include_directories(check + PUBLIC + $ + $ + $ +) +target_include_directories(checkShared + PUBLIC + $ + $ + $ +) + +if(NOT THIS_IS_SUBPROJECT) + install(TARGETS check checkShared + EXPORT check-targets + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) +endif() -install(TARGETS check - EXPORT check - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) +# vim: shiftwidth=2:softtabstop=2:tabstop=2:expandtab:autoindent -install(FILES ${CMAKE_BINARY_DIR}/src/check.h DESTINATION include) -install(EXPORT check DESTINATION cmake) diff --git a/src/check.c b/src/check.c index e42636ed..89df3451 100644 --- a/src/check.c +++ b/src/check.c @@ -26,6 +26,10 @@ #include #include +#if defined(HAVE_FORK) && HAVE_FORK==1 +#include +#endif /* HAVE_FORK */ + #include "check.h" #include "check_error.h" #include "check_list.h" @@ -50,7 +54,7 @@ int check_micro_version = CHECK_MICRO_VERSION; const char* current_test_name = NULL; -static int non_pass(int val); +static int non_pass(enum test_result); static Fixture *fixture_create(SFun fun, int ischecked); static void tcase_add_fixture(TCase * tc, SFun setup, SFun teardown, int ischecked); @@ -74,7 +78,6 @@ Suite *suite_create(const char *name) int suite_tcase(Suite * s, const char *tcname) { List *l; - TCase *tc; if(s == NULL) return 0; @@ -82,7 +85,7 @@ int suite_tcase(Suite * s, const char *tcname) l = s->tclst; for(check_list_front(l); !check_list_at_end(l); check_list_advance(l)) { - tc = (TCase *)check_list_val(l); + TCase *tc = (TCase *)check_list_val(l); if(strcmp(tcname, tc->name) == 0) return 1; } @@ -171,15 +174,15 @@ List *tag_string_to_list(const char *tags_string) if (NULL == tags_string) { - return list; + return list; } tags = strdup(tags_string); tag = strtok(tags, " "); while (tag) { - check_list_add_end(list, strdup(tag)); - tag = strtok(NULL, " "); + check_list_add_end(list, strdup(tag)); + tag = strtok(NULL, " "); } free(tags); return list; @@ -190,8 +193,8 @@ void tcase_set_tags(TCase * tc, const char *tags_orig) /* replace any pre-existing list */ if (tc->tags) { - check_list_apply(tc->tags, free); - check_list_free(tc->tags); + check_list_apply(tc->tags, free); + check_list_free(tc->tags); } tc->tags = tag_string_to_list(tags_orig); } @@ -218,21 +221,21 @@ unsigned int tcase_matching_tag(TCase *tc, List *check_for) if (NULL == check_for) { - return 0; + return 0; } for(check_list_front(check_for); !check_list_at_end(check_for); check_list_advance(check_for)) { - for(check_list_front(tc->tags); !check_list_at_end(tc->tags); - check_list_advance(tc->tags)) - { - if (0 == strcmp((const char *)check_list_val(tc->tags), - (const char *)check_list_val(check_for))) - { - return 1; - } - } + for(check_list_front(tc->tags); !check_list_at_end(tc->tags); + check_list_advance(tc->tags)) + { + if (0 == strcmp((const char *)check_list_val(tc->tags), + (const char *)check_list_val(check_for))) + { + return 1; + } + } } return 0; } @@ -247,21 +250,21 @@ void suite_add_tcase(Suite * s, TCase * tc) check_list_add_end(s->tclst, tc); } -void _tcase_add_test(TCase * tc, TFun fn, const char *name, int _signal, - int allowed_exit_value, int start, int end) +void _tcase_add_test(TCase * tc, const TTest * ttest, + int _signal, int allowed_exit_value, + int start, int end) { TF *tf; - if(tc == NULL || fn == NULL || name == NULL) + if(tc == NULL || ttest == NULL) return; tf = (TF *)emalloc(sizeof(TF)); /* freed in tcase_free */ - tf->fn = fn; + tf->ttest = ttest; tf->loop_start = start; tf->loop_end = end; tf->signal = _signal; /* 0 means no signal expected */ tf->allowed_exit_value = (WEXITSTATUS_MASK & allowed_exit_value); /* 0 is default successful exit */ - tf->name = name; check_list_add_end(tc->tflst, tf); } @@ -351,7 +354,7 @@ void tcase_fn_start(const char *fname, const char *file, const char* tcase_name(void) { - return current_test_name; + return current_test_name; } void _mark_point(const char *file, int line) @@ -359,25 +362,24 @@ void _mark_point(const char *file, int line) send_loc_info(file, line); } -void _ck_assert_failed(const char *file, int line, const char *expr, ...) +void _ck_assert_failed(const char *file, int line, const char *expr, + const char *msg, ...) { - const char *msg; - va_list ap; char buf[BUFSIZ]; const char *to_send; send_loc_info(file, line); - va_start(ap, expr); - msg = (const char *)va_arg(ap, char *); - /* * If a message was passed, format it with vsnprintf. * Otherwise, print the expression as is. */ if(msg != NULL) { + va_list ap; + va_start(ap, msg); vsnprintf(buf, BUFSIZ, msg, ap); + va_end(ap); to_send = buf; } else @@ -385,7 +387,6 @@ void _ck_assert_failed(const char *file, int line, const char *expr, ...) to_send = expr; } - va_end(ap); send_failure_info(to_send); if(cur_fork_status() == CK_FORK) { @@ -438,7 +439,6 @@ void srunner_add_suite(SRunner * sr, Suite * s) void srunner_free(SRunner * sr) { List *l; - TestResult *tr; if(sr == NULL) return; @@ -454,7 +454,7 @@ void srunner_free(SRunner * sr) l = sr->resultlst; for(check_list_front(l); !check_list_at_end(l); check_list_advance(l)) { - tr = (TestResult *)check_list_val(l); + TestResult *tr = (TestResult *)check_list_val(l); tr_free(tr); } check_list_free(sr->resultlst); @@ -510,7 +510,7 @@ TestResult **srunner_results(SRunner * sr) return trarray; } -static int non_pass(int val) +static int non_pass(enum test_result val) { return val != CK_PASS; } @@ -601,8 +601,6 @@ clockid_t check_get_clockid() { static clockid_t clockid = -1; - if(clockid == -1) - { /* * Only check if we have librt available. Otherwise, the clockid * will be ignored anyway, as the clock_gettime() and @@ -611,21 +609,20 @@ clockid_t check_get_clockid() * will result in an assert(0). */ #ifdef HAVE_LIBRT - timer_t timerid; + timer_t timerid; - if(timer_create(CLOCK_MONOTONIC, NULL, &timerid) == 0) - { - timer_delete(timerid); - clockid = CLOCK_MONOTONIC; - } - else - { - clockid = CLOCK_REALTIME; - } -#else + if(timer_create(CLOCK_MONOTONIC, NULL, &timerid) == 0) + { + timer_delete(timerid); clockid = CLOCK_MONOTONIC; -#endif } + else + { + clockid = CLOCK_REALTIME; + } +#else + clockid = CLOCK_MONOTONIC; +#endif return clockid; } diff --git a/src/check.h.in b/src/check.h.in index 9e03d206..49fbda5e 100644 --- a/src/check.h.in +++ b/src/check.h.in @@ -41,26 +41,68 @@ CK_CPPSTART #endif -#if defined(__GNUC__) && defined(__GNUC_MINOR__) -#define GCC_VERSION_AT_LEAST(major, minor) \ +/** + * __GNUC_PATCHLEVEL__ is new to GCC 3.0; + * it is also present in the widely-used development snapshots leading up to 3.0 + * (which identify themselves as GCC 2.96 or 2.97, depending on which snapshot you have). + * + * https://stackoverflow.com/questions/1936719/what-are-the-gcc-predefined-macros-for-the-compilers-version-number/1936745#1936745 + */ + +#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) +#define GCC_VERSION_AT_LEAST(major, minor, patch) \ +((__GNUC__ > (major)) || \ + (__GNUC__ == (major) && __GNUC_MINOR__ > (minor)) || \ + (__GNUC__ == (major) && __GNUC_MINOR__ == (minor) && __GNUC_PATCHLEVEL__ >= (patch)) ) +#elif defined(__GNUC__) && defined(__GNUC_MINOR__) +#define GCC_VERSION_AT_LEAST(major, minor, patch) \ ((__GNUC__ > (major)) || \ (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) #else -#define GCC_VERSION_AT_LEAST(major, minor) 0 +#define GCC_VERSION_AT_LEAST(major, minor, patch) 0 #endif -#if GCC_VERSION_AT_LEAST(2,95) +#if GCC_VERSION_AT_LEAST(2,95,3) #define CK_ATTRIBUTE_UNUSED __attribute__ ((unused)) +#define CK_ATTRIBUTE_FORMAT(a, b, c) __attribute__ ((format (a, b, c))) + +/* We use a private snprintf implementation that does not support the Windows + * format strings of %I64u or similar and instead support the C99 and GNU format + * format strings like %llu and %zu. Let the compiler know this. */ +#ifdef _WIN32 +#define CK_ATTRIBUTE_FORMAT_PRINTF gnu_printf +#else +#define CK_ATTRIBUTE_FORMAT_PRINTF printf +#endif + #else #define CK_ATTRIBUTE_UNUSED +#define CK_ATTRIBUTE_FORMAT(a, b, c) +#define CK_ATTRIBUTE_FORMAT_PRINTF printf #endif /* GCC 2.95 */ -#if GCC_VERSION_AT_LEAST(2,5) +#if GCC_VERSION_AT_LEAST(2,5,0) #define CK_ATTRIBUTE_NORETURN __attribute__ ((noreturn)) #else #define CK_ATTRIBUTE_NORETURN #endif /* GCC 2.5 */ +#if GCC_VERSION_AT_LEAST(4,7,4) && (__STDC_VERSION__ >= 199901L) +/* Operator _Pragma introduced in C99 */ +#define CK_DIAGNOSTIC_STRINGIFY(x) #x +#define CK_DIAGNOSTIC_HELPER1(y) CK_DIAGNOSTIC_STRINGIFY(GCC diagnostic ignored y) +#define CK_DIAGNOSTIC_HELPER2(z) CK_DIAGNOSTIC_HELPER1(#z) +#define CK_DIAGNOSTIC_PUSH_IGNORE(w) \ + _Pragma("GCC diagnostic push") \ + _Pragma(CK_DIAGNOSTIC_HELPER2(w)) +#define CK_DIAGNOSTIC_POP(w) _Pragma ("GCC diagnostic pop") +#else +#define CK_DIAGNOSTIC_PUSH_IGNORE(w) +#define CK_DIAGNOSTIC_POP(w) +#endif /* GCC 4.7.4 */ + +#undef GCC_VERSION_AT_LEAST + #include #if defined(_MSC_VER) @@ -78,6 +120,15 @@ CK_CPPSTART * Used for MSVC to create the export attribute * CK_DLL_EXP is defined during the compilation of the library * on the command line. + * + * This definition is only used when building or linking to + * the shared library, i.e. libcheck.so. When building the library + * the value must be "_declspec(dllexport)". + * When linking with the library, the value must be "_declspec(dllimport)" + * + * This is only used with Microsoft Visual C. In other systems + * the value is empty. In MSVC the value is empty when linking with + * a static library. */ #ifndef CK_DLL_EXP #define CK_DLL_EXP @@ -121,6 +172,16 @@ typedef void (*SFun) (void); */ typedef struct Suite Suite; +/** + * Type for a test, which wraps a test function + */ +typedef struct TTest { + const char *name; + TFun fn; + const char *file; + int line; +} TTest; + /** * Creates a test suite with the given name. * @@ -214,8 +275,8 @@ CK_DLL_EXP void CK_EXPORT tcase_set_tags(TCase * tc, * * @since 0.9.2 * */ -#define tcase_add_test_raise_signal(tc,tf,signal) \ - _tcase_add_test((tc),(tf),"" # tf "",(signal), 0, 0, 1) +#define tcase_add_test_raise_signal(tc,ttest,signal) \ + _tcase_add_test((tc),(ttest),(signal), 0, 0, 1) /** * Add a test function with an expected exit value to a test case @@ -229,8 +290,8 @@ CK_DLL_EXP void CK_EXPORT tcase_set_tags(TCase * tc, * * @since 0.9.7 */ -#define tcase_add_exit_test(tc, tf, expected_exit_value) \ - _tcase_add_test((tc),(tf),"" # tf "",0,(expected_exit_value),0,1) +#define tcase_add_exit_test(tc, ttest, expected_exit_value) \ + _tcase_add_test((tc),(ttest),0,(expected_exit_value),0,1) /** * Add a looping test function to a test case @@ -246,8 +307,8 @@ CK_DLL_EXP void CK_EXPORT tcase_set_tags(TCase * tc, * * @since 0.9.4 */ -#define tcase_add_loop_test(tc,tf,s,e) \ - _tcase_add_test((tc),(tf),"" # tf "",0,0,(s),(e)) +#define tcase_add_loop_test(tc,ttest,s,e) \ + _tcase_add_test((tc),(ttest),0,0,(s),(e)) /** * Add a looping test function with signal handling to a test case @@ -267,8 +328,8 @@ CK_DLL_EXP void CK_EXPORT tcase_set_tags(TCase * tc, * * @since 0.9.5 */ -#define tcase_add_loop_test_raise_signal(tc,tf,signal,s,e) \ - _tcase_add_test((tc),(tf),"" # tf "",(signal),0,(s),(e)) +#define tcase_add_loop_test_raise_signal(tc,ttest,signal,s,e) \ + _tcase_add_test((tc),(ttest),(signal),0,(s),(e)) /** * Add a looping test function with an expected exit value to a test case @@ -288,16 +349,15 @@ CK_DLL_EXP void CK_EXPORT tcase_set_tags(TCase * tc, * * @since 0.9.7 */ -#define tcase_add_loop_exit_test(tc,tf,expected_exit_value,s,e) \ - _tcase_add_test((tc),(tf),"" # tf "",0,(expected_exit_value),(s),(e)) +#define tcase_add_loop_exit_test(tc,ttest,expected_exit_value,s,e) \ + _tcase_add_test((tc),(ttest),0,(expected_exit_value),(s),(e)) /* Add a test function to a test case (function version -- use this when the macro won't work */ -CK_DLL_EXP void CK_EXPORT _tcase_add_test(TCase * tc, TFun tf, - const char *fname, int _signal, - int allowed_exit_value, int start, - int end); +CK_DLL_EXP void CK_EXPORT _tcase_add_test(TCase * tc, const TTest * ttest, + int _signal, int allowed_exit_value, + int start, int end); /** * Add unchecked fixture setup/teardown functions to a test case @@ -400,23 +460,27 @@ CK_DLL_EXP const char* CK_EXPORT tcase_name(void); * @since 0.6.0 */ #define START_TEST(__testname)\ -static void __testname (int _i CK_ATTRIBUTE_UNUSED)\ -{\ - tcase_fn_start (""# __testname, __FILE__, __LINE__); +static void __testname ## _fn (int _i CK_ATTRIBUTE_UNUSED);\ +static const TTest __testname ## _ttest = {""# __testname, __testname ## _fn, __FILE__, __LINE__};\ +static const TTest * __testname = & __testname ## _ttest;\ +static void __testname ## _fn (int _i CK_ATTRIBUTE_UNUSED) /** * End a unit test * * @since 0.6.0 */ -#define END_TEST } +#define END_TEST /* * Fail the test case unless expr is false * * This call is deprecated. */ -#define fail_unless ck_assert_msg +#define fail_unless(expr, ...) \ + (expr) ? \ + _mark_point(__FILE__, __LINE__) : \ + _ck_assert_failed(__FILE__, __LINE__, "Assertion '"#expr"' failed" , ## __VA_ARGS__, NULL) /* * Fail the test case if expr is false @@ -438,7 +502,7 @@ static void __testname (int _i CK_ATTRIBUTE_UNUSED)\ * * This call is deprecated. */ -#define fail ck_abort_msg +#define fail(...) _ck_assert_failed(__FILE__, __LINE__, "Failed" , ## __VA_ARGS__, NULL) /* * This is called whenever an assertion fails. @@ -450,11 +514,12 @@ static void __testname (int _i CK_ATTRIBUTE_UNUSED)\ */ #if @HAVE_FORK@ CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line, - const char *expr, - ...) CK_ATTRIBUTE_NORETURN; + const char *expr, const char *msg, + ...) CK_ATTRIBUTE_NORETURN CK_ATTRIBUTE_FORMAT(CK_ATTRIBUTE_FORMAT_PRINTF, 4, 5); #else CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line, - const char *expr, ...); + const char *expr, const char *msg, + ...) CK_ATTRIBUTE_FORMAT(CK_ATTRIBUTE_FORMAT_PRINTF, 4, 5); #endif /** @@ -484,7 +549,7 @@ CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line, #define ck_assert_msg(expr, ...) \ (expr) ? \ _mark_point(__FILE__, __LINE__) : \ - _ck_assert_failed(__FILE__, __LINE__, "Assertion '"#expr"' failed" , ## __VA_ARGS__, NULL) + _ck_assert_failed(__FILE__, __LINE__, "Assertion '"#expr"' failed" , ## __VA_ARGS__) /** * Unconditionally fail the test @@ -503,7 +568,7 @@ CK_DLL_EXP void CK_EXPORT _ck_assert_failed(const char *file, int line, * * @since 0.9.6 */ -#define ck_abort_msg(...) _ck_assert_failed(__FILE__, __LINE__, "Failed" , ## __VA_ARGS__, NULL) +#define ck_abort_msg(...) _ck_assert_failed(__FILE__, __LINE__, "Failed" , ## __VA_ARGS__) /* Signed and unsigned integer comparison macros with improved output compared to ck_assert(). */ /* OP may be any comparison operator. */ @@ -1429,7 +1494,7 @@ do { \ /** * Check two strings to determine if 0==strcmp(X,Y) * - * If X or Y is NULL the test failes. + * If X or Y is NULL the test fails. * If not 0==strcmp(X,Y), the test fails. * * @param X string @@ -1674,7 +1739,7 @@ do { \ #define _ck_assert_ptr(X, OP, Y) do { \ const void* _ck_x = (X); \ const void* _ck_y = (Y); \ - ck_assert_msg(_ck_x OP _ck_y, "Assertion '%s' failed: %s == %#x, %s == %#x", #X" "#OP" "#Y, #X, _ck_x, #Y, _ck_y); \ + ck_assert_msg(_ck_x OP _ck_y, "Assertion '%s' failed: %s == %#lx, %s == %#lx", #X" "#OP" "#Y, #X, (unsigned long)(uintptr_t)_ck_x, #Y, (unsigned long)(uintptr_t)_ck_y); \ } while (0) /* Pointer against NULL comparison macros with improved output @@ -1683,9 +1748,9 @@ do { \ #define _ck_assert_ptr_null(X, OP) do { \ const void* _ck_x = (X); \ ck_assert_msg(_ck_x OP NULL, \ - "Assertion '%s' failed: %s == %#x", \ + "Assertion '%s' failed: %s == %#lx", \ #X" "#OP" NULL", \ - #X, _ck_x); \ + #X, (unsigned long)(uintptr_t)_ck_x); \ } while (0) /** diff --git a/src/check_error.c b/src/check_error.c index 865e7d5c..56a7537d 100644 --- a/src/check_error.c +++ b/src/check_error.c @@ -61,7 +61,7 @@ void *emalloc(size_t n) p = malloc(n); if(p == NULL) - eprintf("malloc of %u bytes failed:", __FILE__, __LINE__ - 2, n); + eprintf("malloc of " CK_FMT_ZU " bytes failed:", __FILE__, __LINE__ - 2, n); return p; } @@ -71,6 +71,6 @@ void *erealloc(void *ptr, size_t n) p = realloc(ptr, n); if(p == NULL) - eprintf("realloc of %u bytes failed:", __FILE__, __LINE__ - 2, n); + eprintf("realloc of " CK_FMT_ZU " bytes failed:", __FILE__, __LINE__ - 2, n); return p; } diff --git a/src/check_error.h b/src/check_error.h index c2c8d34e..0dc5bb9f 100644 --- a/src/check_error.h +++ b/src/check_error.h @@ -31,7 +31,7 @@ extern jmp_buf error_jmp_buffer; /* Print error message and die If fmt ends in colon, include system error information */ void eprintf(const char *fmt, const char *file, int line, - ...) CK_ATTRIBUTE_NORETURN; + ...) CK_ATTRIBUTE_NORETURN CK_ATTRIBUTE_FORMAT(printf, 1, 4); /* malloc or die */ void *emalloc(size_t n); void *erealloc(void *, size_t n); diff --git a/src/check_impl.h b/src/check_impl.h index bddd1868..f4e8c590 100644 --- a/src/check_impl.h +++ b/src/check_impl.h @@ -36,10 +36,9 @@ typedef struct TF { - TFun fn; + const TTest * ttest; int loop_start; int loop_end; - const char *name; int signal; signed char allowed_exit_value; } TF; diff --git a/src/check_log.c b/src/check_log.c index 2af83210..08446610 100644 --- a/src/check_log.c +++ b/src/check_log.c @@ -152,7 +152,7 @@ void log_test_start(SRunner * sr, TCase * tc, TF * tfun) { char buffer[100]; - snprintf(buffer, 99, "%s:%s", tc->name, tfun->name); + snprintf(buffer, 99, "%s:%s", tc->name, tfun->ttest->name); srunner_send_evt(sr, buffer, CLSTART_T); } @@ -164,12 +164,11 @@ void log_test_end(SRunner * sr, TestResult * tr) static void srunner_send_evt(SRunner * sr, void *obj, enum cl_event evt) { List *l; - Log *lg; l = sr->loglst; for(check_list_front(l); !check_list_at_end(l); check_list_advance(l)) { - lg = (Log *)check_list_val(l); + Log *lg = (Log *)check_list_val(l); fflush(lg->lfile); lg->lfun(sr, lg->lfile, lg->mode, obj, evt); fflush(lg->lfile); @@ -290,11 +289,11 @@ void xml_lfun(SRunner * sr CK_ATTRIBUTE_UNUSED, FILE * file, { case CLINITLOG_SR: fprintf(file, - "\n" - "\n" - "\n" - " %s\n", t); + "\n" + "\n" + "\n" + " %s\n", t); break; case CLENDLOG_SR: { @@ -305,8 +304,8 @@ void xml_lfun(SRunner * sr CK_ATTRIBUTE_UNUSED, FILE * file, clock_gettime(check_get_clockid(), &ts_end); duration = (unsigned long)DIFF_IN_USEC(ts_start, ts_end); fprintf(file, - " %lu.%06lu\n" - "\n", + " %lu.%06lu\n" + "\n", duration / US_PER_SEC, duration % US_PER_SEC); } break; @@ -315,8 +314,8 @@ void xml_lfun(SRunner * sr CK_ATTRIBUTE_UNUSED, FILE * file, case CLSTART_S: s = (Suite *)obj; fprintf(file, - " \n" - " "); + " <suite>\n" + " <title>"); fprint_xml_esc(file, s->name); fprintf(file, "\n"); break; diff --git a/src/check_pack.c b/src/check_pack.c index 0fe1774c..16893cf9 100644 --- a/src/check_pack.c +++ b/src/check_pack.c @@ -19,10 +19,14 @@ */ #include "../lib/libcompat.h" +#include "config.h" #include #include #include +#include +#include +#include "check_stdint.h" /* Need SIZE_MAX */ #include "check.h" #include "check_error.h" @@ -31,12 +35,15 @@ #include "check_pack.h" #ifndef HAVE_PTHREAD -#define pthread_mutex_lock(arg) -#define pthread_mutex_unlock(arg) #define pthread_cleanup_push(f, a) { #define pthread_cleanup_pop(e) } #endif +#ifndef PTHREAD_MUTEX_INITIALIZER +#define pthread_mutex_lock(mutex) +#define pthread_mutex_unlock(mutex) +#endif + /* Maximum size for one message in the message stream. */ static size_t ck_max_msg_size = 0; #ifndef DEFAULT_MAX_MSG_SIZE @@ -61,7 +68,7 @@ static size_t get_max_msg_size(void) size_t value = 0; char *env = getenv("CK_MAX_MSG_SIZE"); if (env) - value = (size_t)strtoul(env, NULL, 10); // Cast in case size_t != unsigned long. + value = (size_t)strtoul(env, NULL, 10); /* Cast in case size_t != unsigned long. */ if (value == 0) value = ck_max_msg_size; if (value == 0) @@ -69,19 +76,20 @@ static size_t get_max_msg_size(void) return value; } -/* typedef an unsigned int that has at least 4 bytes */ +/* typedef an unsigned int that has exactly 4 bytes, as required by pack_int() */ typedef uint32_t ck_uint32; +#define CK_UINT32_MAX UINT32_MAX -static void pack_int(char **buf, int val); -static int upack_int(char **buf); +static void pack_int(char **buf, ck_uint32 val); +static ck_uint32 upack_int(char **buf); static void pack_str(char **buf, const char *str); static char *upack_str(char **buf); -static int pack_ctx(char **buf, CtxMsg * cmsg); -static int pack_loc(char **buf, LocMsg * lmsg); -static int pack_fail(char **buf, FailMsg * fmsg); -static int pack_duration(char **buf, DurationMsg * fmsg); +static size_t pack_ctx(char **buf, CtxMsg * cmsg); +static size_t pack_loc(char **buf, LocMsg * lmsg); +static size_t pack_fail(char **buf, FailMsg * fmsg); +static size_t pack_duration(char **buf, DurationMsg * fmsg); static void upack_ctx(char **buf, CtxMsg * cmsg); static void upack_loc(char **buf, LocMsg * lmsg); static void upack_fail(char **buf, FailMsg * fmsg); @@ -91,14 +99,14 @@ static void check_type(int type, const char *file, int line); static enum ck_msg_type upack_type(char **buf); static void pack_type(char **buf, enum ck_msg_type type); -static int read_buf(FILE * fdes, int size, char *buf); -static int get_result(char *buf, RcvMsg * rmsg); +static size_t read_buf(FILE * fdes, size_t size, char *buf); +static size_t get_result(char *buf, RcvMsg * rmsg); static void rcvmsg_update_ctx(RcvMsg * rmsg, enum ck_result_ctx ctx); static void rcvmsg_update_loc(RcvMsg * rmsg, const char *file, int line); static RcvMsg *rcvmsg_create(void); void rcvmsg_free(RcvMsg * rmsg); -typedef int (*pfun) (char **, CheckMsg *); +typedef size_t (*pfun) (char **, CheckMsg *); typedef void (*upfun) (char **, CheckMsg *); static pfun pftab[] = { @@ -117,6 +125,8 @@ static upfun upftab[] = { int pack(enum ck_msg_type type, char **buf, CheckMsg * msg) { + size_t len; + if(buf == NULL) return -1; if(msg == NULL) @@ -124,12 +134,17 @@ int pack(enum ck_msg_type type, char **buf, CheckMsg * msg) check_type(type, __FILE__, __LINE__); - return pftab[type] (buf, msg); + len = pftab[type] (buf, msg); + if(len > (size_t) INT_MAX) + eprintf("Value of len (" CK_FMT_ZU ") too big, max allowed %u\n", + __FILE__, __LINE__ - 3, len, INT_MAX); + return (int) len; } int upack(char *buf, CheckMsg * msg, enum ck_msg_type *type) { char *obuf; + ptrdiff_t diff; if(buf == NULL) return -1; @@ -142,10 +157,17 @@ int upack(char *buf, CheckMsg * msg, enum ck_msg_type *type) upftab[*type] (&buf, msg); - return buf - obuf; + diff = buf - obuf; + if(diff > (ptrdiff_t) INT_MAX) + eprintf("Value of diff (" CK_FMT_TD ") too big, max allowed %d\n", + __FILE__, __LINE__ - 3, diff, INT_MAX); + if(diff > (ptrdiff_t) INT_MAX || diff < (ptrdiff_t) INT_MIN) + eprintf("Value of diff (" CK_FMT_TD ") too small, min allowed %d\n", + __FILE__, __LINE__ - 6, diff, INT_MIN); + return (int) diff; } -static void pack_int(char **buf, int val) +static void pack_int(char **buf, ck_uint32 val) { unsigned char *ubuf = (unsigned char *)*buf; ck_uint32 uval = val; @@ -158,7 +180,7 @@ static void pack_int(char **buf, int val) *buf += 4; } -static int upack_int(char **buf) +static ck_uint32 upack_int(char **buf) { unsigned char *ubuf = (unsigned char *)*buf; ck_uint32 uval; @@ -169,19 +191,22 @@ static int upack_int(char **buf) *buf += 4; - return (int)uval; + return uval; } static void pack_str(char **buf, const char *val) { - int strsz; + size_t strsz; if(val == NULL) strsz = 0; else strsz = strlen(val); + if(strsz > CK_UINT32_MAX) + eprintf("Value of strsz (" CK_FMT_ZU ") too big, max allowed %u\n", + __FILE__, __LINE__, strsz, CK_UINT32_MAX); - pack_int(buf, strsz); + pack_int(buf, (ck_uint32) strsz); if(strsz > 0) { @@ -193,9 +218,9 @@ static void pack_str(char **buf, const char *val) static char *upack_str(char **buf) { char *val; - int strsz; + size_t strsz; - strsz = upack_int(buf); + strsz = (size_t) upack_int(buf); if(strsz > 0) { @@ -215,78 +240,97 @@ static char *upack_str(char **buf) static void pack_type(char **buf, enum ck_msg_type type) { - pack_int(buf, (int)type); + pack_int(buf, (ck_uint32) type); } static enum ck_msg_type upack_type(char **buf) { +CK_DIAGNOSTIC_PUSH_IGNORE(-Wbad-function-cast) return (enum ck_msg_type)upack_int(buf); +CK_DIAGNOSTIC_POP() } -static int pack_ctx(char **buf, CtxMsg * cmsg) +static size_t pack_ctx(char **buf, CtxMsg * cmsg) { char *ptr; - int len; + size_t len; len = 4 + 4; *buf = ptr = (char *)emalloc(len); pack_type(&ptr, CK_MSG_CTX); - pack_int(&ptr, (int)cmsg->ctx); + pack_int(&ptr, (ck_uint32) cmsg->ctx); return len; } static void upack_ctx(char **buf, CtxMsg * cmsg) { +CK_DIAGNOSTIC_PUSH_IGNORE(-Wbad-function-cast) cmsg->ctx = (enum ck_result_ctx)upack_int(buf); +CK_DIAGNOSTIC_POP() } -static int pack_duration(char **buf, DurationMsg * cmsg) +static size_t pack_duration(char **buf, DurationMsg * cmsg) { char *ptr; - int len; + size_t len; len = 4 + 4; *buf = ptr = (char *)emalloc(len); pack_type(&ptr, CK_MSG_DURATION); - pack_int(&ptr, cmsg->duration); + if((size_t) cmsg->duration > (size_t) CK_UINT32_MAX) + eprintf("Value of cmsg->duration (%d) too big to pack, max allowed %u\n", + __FILE__, __LINE__, cmsg->duration, CK_UINT32_MAX); + pack_int(&ptr, (ck_uint32) cmsg->duration); return len; } static void upack_duration(char **buf, DurationMsg * cmsg) { - cmsg->duration = upack_int(buf); + ck_uint32 duration = upack_int(buf); + if(duration > INT_MAX) + eprintf("Unpacked value (%u) too big for cmsg->duration, max allowed %d\n", + __FILE__, __LINE__ - 3, duration, INT_MAX); + cmsg->duration = (int) duration; } -static int pack_loc(char **buf, LocMsg * lmsg) +static size_t pack_loc(char **buf, LocMsg * lmsg) { char *ptr; - int len; + size_t len; len = 4 + 4 + (lmsg->file ? strlen(lmsg->file) : 0) + 4; *buf = ptr = (char *)emalloc(len); pack_type(&ptr, CK_MSG_LOC); pack_str(&ptr, lmsg->file); - pack_int(&ptr, lmsg->line); + if((size_t) lmsg->line > (size_t) CK_UINT32_MAX) + eprintf("Value of lmsg->line (%d) too big, max allowed %u\n", + __FILE__, __LINE__, lmsg->line, CK_UINT32_MAX); + pack_int(&ptr, (ck_uint32) lmsg->line); return len; } static void upack_loc(char **buf, LocMsg * lmsg) { + ck_uint32 line; lmsg->file = upack_str(buf); - lmsg->line = upack_int(buf); + line = upack_int(buf); + if(line > INT_MAX) + eprintf("Unpacked value (%u) too big for lmsg->line, max allowed %d\n", + __FILE__, __LINE__ - 3, line, INT_MAX); + lmsg->line = (int) line; } -static int pack_fail(char **buf, FailMsg * fmsg) +static size_t pack_fail(char **buf, FailMsg * fmsg) { char *ptr; - int len; + size_t len; len = 4 + 4 + (fmsg->msg ? strlen(fmsg->msg) : 0); *buf = ptr = (char *)emalloc(len); @@ -308,40 +352,45 @@ static void check_type(int type, const char *file, int line) eprintf("Bad message type arg %d", file, line, type); } -#ifdef HAVE_PTHREAD +#ifdef PTHREAD_MUTEX_INITIALIZER static pthread_mutex_t ck_mutex_lock = PTHREAD_MUTEX_INITIALIZER; + static void ppack_cleanup(void *mutex) { pthread_mutex_unlock((pthread_mutex_t *)mutex); } +#else +#define ppack_cleanup(mutex) #endif void ppack(FILE * fdes, enum ck_msg_type type, CheckMsg * msg) { char *buf = NULL; int n; - ssize_t r; + size_t r; n = pack(type, &buf, msg); + if(n < 0) + eprintf("pack failed", __FILE__, __LINE__ - 2); /* Keep it on the safe side to not send too much data. */ - if(n > get_max_msg_size()) - eprintf("Message string too long", __FILE__, __LINE__ - 2); + if((size_t) n > get_max_msg_size()) + eprintf("Message string too long", __FILE__, __LINE__ - 5); pthread_cleanup_push(ppack_cleanup, &ck_mutex_lock); pthread_mutex_lock(&ck_mutex_lock); - r = fwrite(buf, 1, n, fdes); + r = fwrite(buf, 1, (size_t) n, fdes); fflush(fdes); pthread_mutex_unlock(&ck_mutex_lock); pthread_cleanup_pop(0); - if(r != n) - eprintf("Error in call to fwrite:", __FILE__, __LINE__ - 2); + if(r != (size_t) n) + eprintf("Error in call to fwrite:", __FILE__, __LINE__ - 5); free(buf); } -static int read_buf(FILE * fdes, int size, char *buf) +static size_t read_buf(FILE * fdes, size_t size, char *buf) { - int n; + size_t n; n = fread(buf, 1, size, fdes); @@ -353,15 +402,17 @@ static int read_buf(FILE * fdes, int size, char *buf) return n; } -static int get_result(char *buf, RcvMsg * rmsg) +static size_t get_result(char *buf, RcvMsg * rmsg) { enum ck_msg_type type; CheckMsg msg; - int n; + ptrdiff_t n; + size_t msgsz; n = upack(buf, &msg, &type); - if(n == -1) + if(n < 0) eprintf("Error in call to upack", __FILE__, __LINE__ - 2); + msgsz = (size_t) n; if(type == CK_MSG_CTX) { @@ -403,7 +454,7 @@ static int get_result(char *buf, RcvMsg * rmsg) else check_type(type, __FILE__, __LINE__); - return n; + return msgsz; } static void reset_rcv_test(RcvMsg * rmsg) @@ -468,7 +519,7 @@ static void rcvmsg_update_loc(RcvMsg * rmsg, const char *file, int line) RcvMsg *punpack(FILE * fdes) { - int nread, nparse, n; + size_t nread, nparse; char *buf; RcvMsg *rmsg; @@ -483,17 +534,17 @@ RcvMsg *punpack(FILE * fdes) while(nparse > 0) { /* Parse one message */ - n = get_result(buf, rmsg); + size_t n = get_result(buf, rmsg); + if ( ((ssize_t) nparse - (ssize_t) n) < 0) /* casting necessary to be able to get proper negative integers */ + eprintf("Error in call to get_result", __FILE__, __LINE__ - 5); nparse -= n; - if (nparse < 0) - eprintf("Error in call to get_result", __FILE__, __LINE__ - 3); /* Move remaining data in buffer to the beginning */ memmove(buf, buf + n, nparse); /* If EOF has not been seen */ if(nread > 0) { /* Read more data into empty space at end of the buffer */ - nread = read_buf(fdes, n, buf + nparse); + nread = read_buf(fdes, (size_t) n, buf + nparse); nparse += nread; } } diff --git a/src/check_print.c b/src/check_print.c index 35f13b64..a9f3aea4 100644 --- a/src/check_print.c +++ b/src/check_print.c @@ -128,6 +128,9 @@ void fprint_xml_esc(FILE * file, const char *str) case '&': fputs("&", file); break; + default: + /* Program cannot reach here */ + break; } } /* printable ASCII */ diff --git a/src/check_run.c b/src/check_run.c index da1f40f1..5f160e50 100644 --- a/src/check_run.c +++ b/src/check_run.c @@ -29,6 +29,10 @@ #include #include +#if defined(HAVE_FORK) && HAVE_FORK==1 +# include +#endif + #include "check.h" #include "check_error.h" #include "check_list.h" @@ -60,8 +64,8 @@ static void srunner_run_init(SRunner * sr, enum print_output print_mode); static void srunner_run_end(SRunner * sr, enum print_output print_mode); static void srunner_iterate_suites(SRunner * sr, const char *sname, const char *tcname, - const char *include_tags, - const char *exclude_tags, + const char *include_tags, + const char *exclude_tags, enum print_output print_mode); static void srunner_iterate_tcase_tfuns(SRunner * sr, TCase * tc); static void srunner_add_failure(SRunner * sr, TestResult * tf); @@ -162,8 +166,8 @@ static void srunner_run_end(SRunner * sr, static void srunner_iterate_suites(SRunner * sr, const char *sname, const char *tcname, - const char *include_tags, - const char *exclude_tags, + const char *include_tags, + const char *exclude_tags, enum print_output CK_ATTRIBUTE_UNUSED print_mode) { @@ -200,20 +204,20 @@ static void srunner_iterate_suites(SRunner * sr, { continue; } - if (include_tags != NULL) - { - if (!tcase_matching_tag(tc, include_tag_lst)) - { - continue; - } - } - if (exclude_tags != NULL) - { - if (tcase_matching_tag(tc, exclude_tag_lst)) - { - continue; - } - } + if (include_tags != NULL) + { + if (!tcase_matching_tag(tc, include_tag_lst)) + { + continue; + } + } + if (exclude_tags != NULL) + { + if (tcase_matching_tag(tc, exclude_tag_lst)) + { + continue; + } + } srunner_run_tcase(sr, tc); } @@ -287,7 +291,6 @@ static TestResult * srunner_run_setup(List * fixture_list, enum fork_status fork const char * test_name, const char * setup_name) { TestResult *tr = NULL; - Fixture *setup_fixture; if(fork_usage == CK_FORK) { @@ -297,7 +300,7 @@ static TestResult * srunner_run_setup(List * fixture_list, enum fork_status fork for(check_list_front(fixture_list); !check_list_at_end(fixture_list); check_list_advance(fixture_list)) { - setup_fixture = (Fixture *)check_list_val(fixture_list); + Fixture *setup_fixture = (Fixture *)check_list_val(fixture_list); if(fork_usage == CK_NOFORK) { @@ -357,12 +360,10 @@ static TestResult *tcase_run_checked_setup(SRunner * sr, TCase * tc) static void srunner_run_teardown(List * fixture_list, enum fork_status fork_usage) { - Fixture * fixture; - for(check_list_front(fixture_list); !check_list_at_end(fixture_list); check_list_advance(fixture_list)) { - fixture = (Fixture *)check_list_val(fixture_list); + Fixture *fixture = (Fixture *)check_list_val(fixture_list); send_ctx_info(CK_CTX_TEARDOWN); if(fork_usage == CK_NOFORK) @@ -415,11 +416,12 @@ static TestResult *tcase_run_tfun_nofork(SRunner * sr, TCase * tc, TF * tfun, clock_gettime(check_get_clockid(), &ts_start); if(0 == setjmp(error_jmp_buffer)) { - tfun->fn(i); + tcase_fn_start(tfun->ttest->name, tfun->ttest->file, tfun->ttest->line); + tfun->ttest->fn(i); } clock_gettime(check_get_clockid(), &ts_end); tcase_run_checked_teardown(tc); - return receive_result_info_nofork(tc->name, tfun->name, i, + return receive_result_info_nofork(tc->name, tfun->ttest->name, i, DIFF_IN_USEC(ts_start, ts_end)); } @@ -478,7 +480,6 @@ static TestResult *tcase_run_tfun_fork(SRunner * sr, TCase * tc, TF * tfun, timer_t timerid; struct itimerspec timer_spec; - TestResult *tr; pid = fork(); @@ -486,12 +487,14 @@ static TestResult *tcase_run_tfun_fork(SRunner * sr, TCase * tc, TF * tfun, eprintf("Error in call to fork:", __FILE__, __LINE__ - 2); if(pid == 0) { + TestResult *tr; setpgid(0, 0); group_pid = getpgrp(); tr = tcase_run_checked_setup(sr, tc); free(tr); clock_gettime(check_get_clockid(), &ts_start); - tfun->fn(i); + tcase_fn_start(tfun->ttest->name, tfun->ttest->file, tfun->ttest->line); + tfun->ttest->fn(i); clock_gettime(check_get_clockid(), &ts_end); tcase_run_checked_teardown(tc); send_duration_info(DIFF_IN_USEC(ts_start, ts_end)); @@ -535,7 +538,7 @@ static TestResult *tcase_run_tfun_fork(SRunner * sr, TCase * tc, TF * tfun, killpg(pid, SIGKILL); /* Kill remaining processes. */ - return receive_result_info_fork(tc->name, tfun->name, i, status, + return receive_result_info_fork(tc->name, tfun->ttest->name, i, status, tfun->signal, tfun->allowed_exit_value); } @@ -766,8 +769,8 @@ void srunner_run_all(SRunner * sr, enum print_output print_mode) } void srunner_run_tagged(SRunner * sr, const char *sname, const char *tcname, - const char *include_tags, const char *exclude_tags, - enum print_output print_mode) + const char *include_tags, const char *exclude_tags, + enum print_output print_mode) { #if defined(HAVE_SIGACTION) && defined(HAVE_FORK) static struct sigaction sigalarm_old_action; @@ -781,11 +784,11 @@ void srunner_run_tagged(SRunner * sr, const char *sname, const char *tcname, if(!tcname) tcname = getenv("CK_RUN_CASE"); if(!sname) - sname = getenv("CK_RUN_SUITE"); + sname = getenv("CK_RUN_SUITE"); if(!include_tags) - include_tags = getenv("CK_INCLUDE_TAGS"); + include_tags = getenv("CK_INCLUDE_TAGS"); if(!exclude_tags) - exclude_tags = getenv("CK_EXCLUDE_TAGS"); + exclude_tags = getenv("CK_EXCLUDE_TAGS"); if(sr == NULL) return; @@ -809,7 +812,7 @@ void srunner_run_tagged(SRunner * sr, const char *sname, const char *tcname, #endif /* HAVE_SIGACTION && HAVE_FORK */ srunner_run_init(sr, print_mode); srunner_iterate_suites(sr, sname, tcname, include_tags, exclude_tags, - print_mode); + print_mode); srunner_run_end(sr, print_mode); #if defined(HAVE_SIGACTION) && defined(HAVE_FORK) sigaction(SIGALRM, &sigalarm_old_action, NULL); diff --git a/src/check_str.c b/src/check_str.c index 2ae093fd..8dabdcc6 100644 --- a/src/check_str.c +++ b/src/check_str.c @@ -77,7 +77,6 @@ char *sr_stat_str(SRunner * sr) char *ck_strdup_printf(const char *fmt, ...) { /* Guess we need no more than 100 bytes. */ - int n; size_t size = 100; char *p; va_list ap; @@ -86,6 +85,7 @@ char *ck_strdup_printf(const char *fmt, ...) while(1) { + int n; /* Try to print in the allocated space. */ va_start(ap, fmt); n = vsnprintf(p, size, fmt, ap); diff --git a/src/check_str.h b/src/check_str.h index b26eae2b..5f52e61f 100644 --- a/src/check_str.h +++ b/src/check_str.h @@ -21,6 +21,8 @@ #ifndef CHECK_STR_H #define CHECK_STR_H +#include "../lib/libcompat.h" + /* Return a string representation of the given TestResult. Return value has been malloc'd, and must be freed by the caller */ char *tr_str(TestResult * tr); @@ -37,6 +39,6 @@ char *tr_short_str(TestResult * tr); */ char *sr_stat_str(SRunner * sr); -char *ck_strdup_printf(const char *fmt, ...); +char *ck_strdup_printf(const char *fmt, ...) CK_ATTRIBUTE_FORMAT(printf, 1, 2); #endif /* CHECK_STR_H */ diff --git a/tests/.cvsignore b/tests/.cvsignore deleted file mode 100644 index 430904f2..00000000 --- a/tests/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.deps -Makefile -Makefile.in -check_check -check_stress -ex_log_output -ex_output -test.log diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b3d7ab7e..ecb533b8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -38,9 +38,13 @@ if(WIN32) endif(WIN32) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test_vars.in - ${CMAKE_CURRENT_BINARY_DIR}/test_vars) + ${CMAKE_CURRENT_BINARY_DIR}/test_vars @ONLY) -include(CTest) +if(ENABLE_MEMORY_LEAKING_TESTS) + add_definitions(-DMEMORY_LEAKING_TESTS_ENABLED=1) +else(ENABLE_MEMORY_LEAKING_TESTS) + add_definitions(-DMEMORY_LEAKING_TESTS_ENABLED=0) +endif(ENABLE_MEMORY_LEAKING_TESTS) set(CHECK_CHECK_SOURCES check_check_exit.c @@ -59,7 +63,7 @@ set(CHECK_CHECK_SOURCES check_list.c) set(CHECK_CHECK_HEADERS check_check.h) add_executable(check_check ${CHECK_CHECK_HEADERS} ${CHECK_CHECK_SOURCES}) -target_link_libraries(check_check check compat) +target_link_libraries(check_check check) set(CHECK_CHECK_EXPORT_SOURCES check_check_sub.c @@ -72,20 +76,35 @@ set(CHECK_CHECK_EXPORT_HEADERS check_check.h) add_executable(check_check_export ${CHECK_CHECK_EXPORT_HEADERS} ${CHECK_CHECK_EXPORT_SOURCES}) -target_link_libraries(check_check_export check compat) +target_link_libraries(check_check_export check) set(EX_OUTPUT_SOURCES ex_output.c) add_executable(ex_output ${EX_OUTPUT_SOURCES}) -target_link_libraries(ex_output check compat) +target_link_libraries(ex_output check) set(CHECK_NOFORK_SOURCES check_nofork.c) add_executable(check_nofork ${CHECK_NOFORK_SOURCES}) -target_link_libraries(check_nofork check compat) +target_link_libraries(check_nofork check) set(CHECK_NOFORK_TEARDOWN_SOURCES check_nofork_teardown.c) add_executable(check_nofork_teardown ${CHECK_NOFORK_TEARDOWN_SOURCES}) -target_link_libraries(check_nofork_teardown check compat) +target_link_libraries(check_nofork_teardown check) set(CHECK_SET_MAX_MSG_SIZE_SOURCES check_set_max_msg_size.c) add_executable(check_set_max_msg_size ${CHECK_SET_MAX_MSG_SIZE_SOURCES}) -target_link_libraries(check_set_max_msg_size check compat) +target_link_libraries(check_set_max_msg_size check) + +set(CHECK_MEM_LEAKS_SOURCES + check_mem_leaks.c + check_check_log.c + check_check_limit.c + check_check_fixture.c + check_check_fork.c + check_check_exit.c + check_check_selective.c + check_check_sub.c + check_check_master.c + check_check_tags.c +) +add_executable(check_mem_leaks ${CHECK_MEM_LEAKS_SOURCES}) +target_link_libraries(check_mem_leaks check) diff --git a/tests/check_check.h b/tests/check_check.h index 32e49bc6..d828ee01 100644 --- a/tests/check_check.h +++ b/tests/check_check.h @@ -96,6 +96,6 @@ void record_failure_line_num(const int line); * * If there are no more lines to read, -1 is returned. */ -int get_next_failure_line_num(FILE * file); +long get_next_failure_line_num(FILE * file); #endif /* CHECK_CHECK_H */ diff --git a/tests/check_check_export_main.c b/tests/check_check_export_main.c index 0d035819..6026f7c9 100644 --- a/tests/check_check_export_main.c +++ b/tests/check_check_export_main.c @@ -27,7 +27,7 @@ int main (void) { - int n; + int number_failed; SRunner *sr; fork_setup(); @@ -40,7 +40,7 @@ int main (void) srunner_run_all (sr, CK_VERBOSE); cleanup(); fork_teardown(); - n = srunner_ntests_failed(sr); + number_failed = srunner_ntests_failed(sr); srunner_free(sr); - return (n == 0) ? EXIT_SUCCESS : EXIT_FAILURE; + return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/check_check_fixture.c b/tests/check_check_fixture.c index a82dd014..19451e21 100644 --- a/tests/check_check_fixture.c +++ b/tests/check_check_fixture.c @@ -93,7 +93,7 @@ START_TEST(test_setup_failure_msg) snprintf(errm, sizeof(errm), "Bad setup tr msg (%s)", trm); - ck_abort_msg (errm); + ck_abort_msg("%s", errm); } free(trm); } @@ -217,7 +217,7 @@ START_TEST(test_ch_setup_fail) snprintf(errm, sizeof(errm), "Bad failed checked setup tr msg (%s)", trm); - ck_abort_msg (errm); + ck_abort_msg("%s", errm); } free(trm); free(tr); @@ -348,7 +348,7 @@ START_TEST(test_ch_setup_sig) snprintf(errm, sizeof(errm), "Msg was (%s)", trm); - ck_abort_msg (errm); + ck_abort_msg("%s", errm); } free(trm); srunner_free(sr); @@ -440,7 +440,7 @@ START_TEST(test_ch_teardown_fail) snprintf(errm, sizeof(errm), "Bad failed checked teardown tr msg (%s)", trm); - ck_abort_msg (errm); + ck_abort_msg("%s", errm); } free(trm); free(tr); @@ -486,7 +486,7 @@ START_TEST(test_ch_teardown_fail_nofork) snprintf(errm, sizeof(errm), "Bad failed checked teardown tr msg (%s)", trm); - ck_abort_msg (errm); + ck_abort_msg("%s", errm); } free(trm); free(tr); @@ -542,7 +542,7 @@ START_TEST(test_ch_teardown_sig) snprintf(errm, sizeof(errm), "Bad msg (%s)", trm); - ck_abort_msg (errm); + ck_abort_msg("%s", errm); } free(trm); srunner_free(sr); diff --git a/tests/check_check_main.c b/tests/check_check_main.c index 33914931..7788be5c 100644 --- a/tests/check_check_main.c +++ b/tests/check_check_main.c @@ -27,7 +27,7 @@ int main (void) { - int n; + int number_failed; SRunner *sr; fork_setup(); @@ -56,7 +56,7 @@ int main (void) cleanup(); fork_teardown(); teardown_fixture(); - n = srunner_ntests_failed(sr); + number_failed = srunner_ntests_failed(sr); srunner_free(sr); - return (n == 0) ? EXIT_SUCCESS : EXIT_FAILURE; + return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/check_check_master.c b/tests/check_check_master.c index 5aedc793..2056e84a 100644 --- a/tests/check_check_master.c +++ b/tests/check_check_master.c @@ -43,10 +43,10 @@ char * line_num_failures_file_name = NULL; enum ck_test_msg_type_t { #if ENABLE_REGEX - // For tests with different output on different platforms + /* For tests with different output on different platforms */ CK_MSG_REGEXP, #endif - // Simple text + /* Simple text */ CK_MSG_TEXT }; @@ -134,7 +134,7 @@ static master_test_t master_tests[] = { { "Simple Tests", "test_ck_assert_float_ge", CK_FAILURE, CK_MSG_TEXT, "Assertion 'x >= y' failed: x == 2.5, y == 3" }, { "Simple Tests", "test_ck_assert_float_ge_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion '2%d >= 3%f' failed: 2%d == 0, 3%f == 1" }, { "Simple Tests", "test_ck_assert_float_with_expr", CK_PASS, CK_MSG_TEXT, "Passed" }, - { "Simple Tests", "test_ck_assert_float_eq_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) < t' failed: x == 0.001, y == 0.003, t == 0.001" }, + { "Simple Tests", "test_ck_assert_float_eq_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) < t' failed: x == 0.001, y == 0.003, t == 0.000990099" }, { "Simple Tests", "test_ck_assert_float_eq_tol_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(2%f - 3%d) < 2%p' failed: 3%d == 1, 2%f == 0, 2%p == 0" }, { "Simple Tests", "test_ck_assert_float_ne_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) >= t' failed: x == 0.001, y == 0.002, t == 0.01" }, { "Simple Tests", "test_ck_assert_float_ne_tol_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(3%f - 3%d) >= 3%p' failed: 3%d == 1, 3%f == 1, 3%p == 1" }, @@ -174,7 +174,7 @@ static master_test_t master_tests[] = { { "Simple Tests", "test_ck_assert_double_ge", CK_FAILURE, CK_MSG_TEXT, "Assertion 'x >= y' failed: x == 2.5, y == 3" }, { "Simple Tests", "test_ck_assert_double_ge_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion '2%d >= 3%f' failed: 2%d == 0, 3%f == 1" }, { "Simple Tests", "test_ck_assert_double_with_expr", CK_PASS, CK_MSG_TEXT, "Passed" }, - { "Simple Tests", "test_ck_assert_double_eq_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) < t' failed: x == 0.001, y == 0.002, t == 0.001" }, + { "Simple Tests", "test_ck_assert_double_eq_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) < t' failed: x == 0.001, y == 0.002, t == 0.000990099" }, { "Simple Tests", "test_ck_assert_double_eq_tol_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(2%f - 3%d) < 2%p' failed: 3%d == 1, 2%f == 0, 2%p == 0" }, { "Simple Tests", "test_ck_assert_double_ne_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) >= t' failed: x == 0.001, y == 0.002, t == 0.01" }, { "Simple Tests", "test_ck_assert_double_ne_tol_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(3%f - 3%d) >= 3%p' failed: 3%d == 1, 3%f == 1, 3%p == 1" }, @@ -214,7 +214,7 @@ static master_test_t master_tests[] = { { "Simple Tests", "test_ck_assert_ldouble_ge", CK_FAILURE, CK_MSG_TEXT, "Assertion 'x >= y' failed: x == 2.5, y == 3" }, { "Simple Tests", "test_ck_assert_ldouble_ge_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion '2%d >= 3%f' failed: 2%d == 0, 3%f == 1" }, { "Simple Tests", "test_ck_assert_ldouble_with_expr", CK_PASS, CK_MSG_TEXT, "Passed" }, - { "Simple Tests", "test_ck_assert_ldouble_eq_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) < t' failed: x == 0.001, y == 0.002, t == 0.001" }, + { "Simple Tests", "test_ck_assert_ldouble_eq_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) < t' failed: x == 0.001, y == 0.002, t == 0.000990099" }, { "Simple Tests", "test_ck_assert_ldouble_eq_tol_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(2%f - 3%d) < 2%p' failed: 3%d == 1, 2%f == 0, 2%p == 0" }, { "Simple Tests", "test_ck_assert_ldouble_ne_tol", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(y - x) >= t' failed: x == 0.001, y == 0.002, t == 0.01" }, { "Simple Tests", "test_ck_assert_ldouble_ne_tol_with_mod", CK_FAILURE, CK_MSG_TEXT, "Assertion 'fabsl(3%f - 3%d) >= 3%p' failed: 3%d == 1, 3%f == 1, 3%p == 1" }, @@ -416,16 +416,16 @@ static int nr_of_master_tests = sizeof master_tests /sizeof master_tests[0]; START_TEST(test_check_nfailures) { int i; - int failed = 0; + int number_failed = 0; for (i = 0; i < nr_of_master_tests; i++) { if (master_tests[i].failure_type != CK_PASS) { - failed++; + number_failed++; } } - ck_assert_msg (sub_nfailed == failed, + ck_assert_msg (sub_nfailed == number_failed, "Unexpected number of failures received, %d, expected %d.", - sub_nfailed, failed); + sub_nfailed, number_failed); } END_TEST @@ -436,36 +436,6 @@ START_TEST(test_check_ntests_run) } END_TEST -/** - * Given a string, return a new string that is a copy - * of the original exception that every occurance of - * % is replaced with %%. This escapes the % - * symbol for passing to printf. - * - * The passed in string is not modified. Note though - * that the returned string is allocated memory that - * must be freed by the caller. - */ -char * escape_percent(const char *original, size_t original_size); -char * escape_percent(const char *original, size_t original_size) -{ - /* In the worst case every character is a %*/ - char *result = (char*)malloc(original_size*2); - - size_t read_index; - size_t write_index; - for(read_index = write_index = 0; read_index < original_size; read_index++, write_index++) - { - result[write_index] = original[read_index]; - if(result[write_index] == '%') - { - /* Place a duplicate % next to the one just read, to escape it */ - result[++write_index] = '%'; - } - } - - return result; -} START_TEST(test_check_failure_msgs) { @@ -474,9 +444,7 @@ START_TEST(test_check_failure_msgs) const char *got_msg; const char *expected_msg; unsigned char not_equal = 0; - char emsg[MAXSTR]; const char *msg_type_str; - char *emsg_escaped; int reg_err; char err_text[256]; TestResult *tr; @@ -499,29 +467,32 @@ START_TEST(test_check_failure_msgs) expected_msg = master_test->msg; switch (master_test->msg_type) { - case CK_MSG_TEXT: - if (strcmp(got_msg, expected_msg) != 0) { - not_equal = 1; - } - break; + case CK_MSG_TEXT: + if (strcmp(got_msg, expected_msg) != 0) { + not_equal = 1; + } + break; #if ENABLE_REGEX - case CK_MSG_REGEXP: { - reg_err = regcomp(&re, expected_msg, REG_EXTENDED | REG_NOSUB); - if (reg_err) { - regerror(reg_err, &re, err_text, sizeof(err_text)); - ck_assert_msg(reg_err == 0, - "For test %d:%s:%s Expected regexp '%s', but regcomp returned error '%s'", - i, master_test->tcname, master_test->test_name, expected_msg, - err_text); - } - reg_err = regexec(&re, got_msg, 0, NULL, 0); - regfree(&re); - if (reg_err) { - not_equal = 1; + case CK_MSG_REGEXP: { + reg_err = regcomp(&re, expected_msg, REG_EXTENDED | REG_NOSUB); + if (reg_err) { + regerror(reg_err, &re, err_text, sizeof(err_text)); + ck_assert_msg(reg_err == 0, + "For test %d:%s:%s Expected regexp '%s', but regcomp returned error '%s'", + i, master_test->tcname, master_test->test_name, expected_msg, + err_text); + } + reg_err = regexec(&re, got_msg, 0, NULL, 0); + regfree(&re); + if (reg_err) { + not_equal = 1; + } + break; } - break; - } #endif /* ENABLE_REGEX */ + default: + /* Program should not reach here */ + break; } if (not_equal) { @@ -535,21 +506,9 @@ START_TEST(test_check_failure_msgs) msg_type_str = ""; } - snprintf(emsg, MAXSTR - 1,"For test %d:%s:%s Expected%s '%s', got '%s'", + ck_abort_msg("For test %d:%s:%s Expected%s '%s', got '%s'", i, master_test->tcname, master_test->test_name, msg_type_str, expected_msg, got_msg); - emsg[MAXSTR - 1] = '\0'; - - /* - * NOTE: ck_abort_msg() will take the passed string - * and feed it to printf. We need to escape any - * '%' found, else they will result in odd formatting - * in ck_abort_msg(). - */ - emsg_escaped = escape_percent(emsg, MAXSTR); - - ck_abort_msg(emsg_escaped); - free(emsg_escaped); } } } @@ -558,9 +517,9 @@ END_TEST START_TEST(test_check_failure_lnos) { int i; - int line_no; + long line_no; int passed = 0; - int failed; + int number_failed; TestResult *tr; /* Create list of line numbers where failures occurred */ @@ -572,29 +531,29 @@ START_TEST(test_check_failure_lnos) continue; } - failed = i - passed; + number_failed = i - passed; ck_assert_msg(i - passed <= sub_nfailed, NULL); - tr = tr_fail_array[failed]; + tr = tr_fail_array[number_failed]; ck_assert_msg(tr != NULL, NULL); line_no = get_next_failure_line_num(line_num_failures); if(line_no == -1) { ck_abort_msg("Did not find the %dth failure line number for suite %s, msg %s", - (failed+1), tr_tcname(tr), tr_msg(tr)); + (number_failed+1), tr_tcname(tr), tr_msg(tr)); } if (line_no > 0 && tr_lno(tr) != line_no) { - ck_abort_msg("For test %d (failure %d): Expected lno %d, got %d for suite %s, msg %s", - i, failed, line_no, tr_lno(tr), tr_tcname(tr), tr_msg(tr)); + ck_abort_msg("For test %d (failure %d): Expected lno %ld, got %d for suite %s, msg %s", + i, number_failed, line_no, tr_lno(tr), tr_tcname(tr), tr_msg(tr)); } } /* At this point, there should be no remaining failures */ line_no = get_next_failure_line_num(line_num_failures); ck_assert_msg(line_no == -1, - "No more failure line numbers expected, but found %d", line_no); + "No more failure line numbers expected, but found %ld", line_no); } END_TEST @@ -615,7 +574,7 @@ START_TEST(test_check_failure_ftypes) ck_assert_msg(tr != NULL, NULL); ck_assert_msg(master_tests[i].failure_type == tr_rtype(tr), "Failure type wrong for test %d:%s:%s", - i, master_tests[i].tcname, master_tests[i].test_name); + i, master_tests[i].tcname, master_tests[i].test_name); } } END_TEST @@ -629,7 +588,7 @@ START_TEST(test_check_failure_lfiles) ck_assert_msg(tr_lfile(tr) != NULL, "Bad file name for test %d", i); ck_assert_msg(strstr(tr_lfile(tr), "check_check_sub.c") != 0, "Bad file name for test %d:%s:%s", - i, master_tests[i].tcname, master_tests[i].test_name); + i, master_tests[i].tcname, master_tests[i].test_name); } } END_TEST @@ -641,7 +600,7 @@ START_TEST(test_check_tcnames) if (strcmp(tcname, master_tests[_i].tcname) != 0) { ck_abort_msg("Expected '%s', got '%s' for test %d:%s", master_tests[_i].tcname, tcname, - _i, master_tests[_i].test_name); + _i, master_tests[_i].test_name); } } END_TEST @@ -649,26 +608,22 @@ END_TEST START_TEST(test_check_test_names) { int i; - int line_no; - int passed = 0; - int failed; - TestResult *tr; rewind(test_names_file); for (i = 0; i < sub_ntests; i++) { - char* test_name = get_next_test_name(test_names_file); - - if(test_name == NULL || strcmp(master_tests[i].test_name, test_name) != 0) - { - ck_abort_msg("Expected test name '%s' but found '%s' for test %d:%s", - master_tests[i].test_name, - (test_name == NULL ? "(null)" : test_name), - i, master_tests[i].tcname); - } + char* test_name = get_next_test_name(test_names_file); + + if(test_name == NULL || strcmp(master_tests[i].test_name, test_name) != 0) + { + ck_abort_msg("Expected test name '%s' but found '%s' for test %d:%s", + master_tests[i].test_name, + (test_name == NULL ? "(null)" : test_name), + i, master_tests[i].tcname); + } - free(test_name); + free(test_name); } } END_TEST @@ -678,43 +633,43 @@ START_TEST(test_check_all_msgs) const char *got_msg = tr_msg(tr_all_array[_i]); master_test_t *master_test = &master_tests[_i]; const char *expected_msg = master_test->msg; - char emsg[MAXSTR]; - const char *msg_type_str; - char err_text[256]; - int reg_err; unsigned char not_equal = 0; - char *emsg_escaped; #if ENABLE_REGEX regex_t re; #endif switch (master_test->msg_type) { - case CK_MSG_TEXT: - if (strcmp(got_msg, expected_msg) != 0) { - not_equal = 1; - } - break; + case CK_MSG_TEXT: + if (strcmp(got_msg, expected_msg) != 0) { + not_equal = 1; + } + break; #if ENABLE_REGEX - case CK_MSG_REGEXP: { - reg_err = regcomp(&re, expected_msg, REG_EXTENDED | REG_NOSUB); - if (reg_err) { - regerror(reg_err, &re, err_text, sizeof(err_text)); - ck_assert_msg(reg_err == 0, - "For test %d:%s:%s Expected regexp '%s', but regcomp returned error '%s'", - _i, master_test->tcname, master_test->test_name, expected_msg, - err_text); - } - reg_err = regexec(&re, got_msg, 0, NULL, 0); - regfree(&re); - if (reg_err) { - not_equal = 1; + case CK_MSG_REGEXP: { + int reg_err = regcomp(&re, expected_msg, REG_EXTENDED | REG_NOSUB); + if (reg_err) { + char err_text[256]; + regerror(reg_err, &re, err_text, sizeof(err_text)); + ck_assert_msg(reg_err == 0, + "For test %d:%s:%s Expected regexp '%s', but regcomp returned error '%s'", + _i, master_test->tcname, master_test->test_name, expected_msg, + err_text); + } + reg_err = regexec(&re, got_msg, 0, NULL, 0); + regfree(&re); + if (reg_err) { + not_equal = 1; + } + break; } - break; - } #endif /* ENABLE_REGEX */ + default: + /* Program should not reach here */ + break; } if (not_equal) { + const char *msg_type_str; switch(master_test->msg_type) { #if ENABLE_REGEX case CK_MSG_REGEXP: @@ -725,21 +680,9 @@ START_TEST(test_check_all_msgs) msg_type_str = ""; } - snprintf(emsg, MAXSTR - 1, "For test %i:%s:%s expected%s '%s', got '%s'", - _i, master_test->tcname, master_test->test_name, msg_type_str, - expected_msg, got_msg); - emsg[MAXSTR - 1] = '\0'; - - /* - * NOTE: ck_abort_msg() will take the passed string - * and feed it to printf. We need to escape any - * '%' found, else they will result in odd formatting - * in ck_abort_msg(). - */ - emsg_escaped = escape_percent(emsg, MAXSTR); - - ck_abort_msg(emsg_escaped); - free(emsg_escaped); + ck_abort_msg("For test %i:%s:%s expected%s '%s', got '%s'", + _i, master_test->tcname, master_test->test_name, msg_type_str, + expected_msg, got_msg); } } END_TEST @@ -748,8 +691,8 @@ START_TEST(test_check_all_ftypes) { ck_assert_msg(master_tests[_i].failure_type == tr_rtype(tr_all_array[_i]), "For test %d:%s:%s failure type wrong, expected %d but got %d", - _i, master_tests[_i].tcname, master_tests[_i].test_name, - master_tests[_i].failure_type, tr_rtype(tr_all_array[_i])); + _i, master_tests[_i].tcname, master_tests[_i].test_name, + master_tests[_i].failure_type, tr_rtype(tr_all_array[_i])); } END_TEST @@ -762,7 +705,7 @@ static void test_fixture_setup(void) START_TEST(test_setup) { ck_assert_msg (test_fixture_val == 1, - "Value not setup or changed across tests correctly"); + "Value not setup or changed across tests correctly"); test_fixture_val = 2; } END_TEST @@ -775,7 +718,7 @@ static void test_fixture_teardown (void) START_TEST(test_teardown) { ck_assert_msg (test_fixture_val == 3, - "Value not changed correctly in teardown"); + "Value not changed correctly in teardown"); } END_TEST @@ -802,7 +745,7 @@ Suite *make_master_suite (void) tcase_add_loop_test (tc_core, test_check_all_msgs, 0, sub_ntests); tcase_add_loop_test (tc_core, test_check_all_ftypes, 0, nr_of_master_tests); tcase_add_unchecked_fixture(tc_fixture, test_fixture_setup, - test_fixture_teardown); + test_fixture_teardown); /* add the test 3 times to make sure we adequately test preservation of fixture values across tests, regardless of the order in which tests are added to the test case */ @@ -853,8 +796,10 @@ void setup (void) line_num_failures = fopen(line_num_failures_file_name, "w+b"); #else test_names_file_name = strdup("check_test_names__XXXXXX"); + assert(test_names_file_name != NULL && "strdup() failed"); test_names_file = fdopen(mkstemp(test_names_file_name), "w+b"); line_num_failures_file_name = strdup("check_error_linenums_XXXXXX"); + assert(line_num_failures_file_name != NULL && "strdup() failed"); line_num_failures = fdopen(mkstemp(line_num_failures_file_name), "w+b"); #endif @@ -921,7 +866,7 @@ char* get_next_test_name(FILE * file) */ if(written > 0 && line[written-1] == '\n') { - line[written-1] = '\0'; + line[written-1] = '\0'; } return line; @@ -929,9 +874,9 @@ char* get_next_test_name(FILE * file) void record_failure_line_num(int linenum) { - int to_write; - ssize_t written; - int result; + size_t to_write; + size_t written; + int result, chars_printed; char string[16]; /* @@ -940,12 +885,13 @@ void record_failure_line_num(int linenum) */ linenum += 1; - to_write = snprintf(string, sizeof(string), "%d\n", linenum); - if(to_write <= 0) + chars_printed = snprintf(string, sizeof(string), "%d\n", linenum); + if(chars_printed <= 0 || (size_t) chars_printed >= sizeof(string)) { fprintf(stderr, "%s:%d: Error in call to snprintf:", __FILE__, __LINE__); exit(1); } + to_write = (size_t) chars_printed; if(line_num_failures == NULL) { @@ -962,7 +908,7 @@ void record_failure_line_num(int linenum) written = fwrite(string, 1, to_write, line_num_failures); if(written != to_write) { - fprintf(stderr, "%s:%d: Error in call to fwrite, wrote %ld instead of %d:", __FILE__, __LINE__, written, to_write); + fprintf(stderr, "%s:%d: Error in call to fwrite, wrote " CK_FMT_ZD " instead of " CK_FMT_ZU ":", __FILE__, __LINE__, written, to_write); exit(1); } @@ -974,13 +920,13 @@ void record_failure_line_num(int linenum) } } -int get_next_failure_line_num(FILE * file) +long get_next_failure_line_num(FILE * file) { char * line = NULL; char * end = NULL; size_t length; ssize_t written; - int value = -1; + long value = -1; written = getline(&line, &length, file); diff --git a/tests/check_check_pack.c b/tests/check_check_pack.c index 7da7e576..f11b81b7 100644 --- a/tests/check_check_pack.c +++ b/tests/check_check_pack.c @@ -57,7 +57,7 @@ START_TEST(test_pack_fmsg) snprintf (errm, sizeof(errm), "Unpacked string is %s, should be Hello, World!", fmsg->msg); - fail (errm); + fail("%s", errm); } free (fmsg->msg); @@ -88,14 +88,14 @@ START_TEST(test_pack_loc) snprintf (errm, sizeof (errm), "LocMsg line was %d, should be %d", lmsg->line, 125); - fail (errm); + fail("%s", errm); } if (strcmp (lmsg->file, "abc123.c") != 0) { snprintf (errm, sizeof (errm), "LocMsg file was %s, should be abc123.c", lmsg->file); - fail (errm); + fail("%s", errm); } free (lmsg->file); @@ -123,7 +123,7 @@ START_TEST(test_pack_ctx) snprintf (errm, sizeof (errm), "CtxMsg ctx got %d, expected %d", cmsg.ctx, CK_CTX_SETUP); - fail (errm); + fail("%s", errm); } free (buf); @@ -147,7 +147,7 @@ START_TEST(test_pack_len) n = upack (buf, (CheckMsg *) &cmsg, &type); if (n != 8) { snprintf (errm, sizeof (errm), "%d bytes read from upack, should be 8", n); - fail (errm); + fail("%s", errm); } free (buf); diff --git a/tests/check_check_sub.c b/tests/check_check_sub.c index a6f8f272..b581d5c7 100644 --- a/tests/check_check_sub.c +++ b/tests/check_check_sub.c @@ -778,7 +778,7 @@ START_TEST(test_ck_assert_float_eq_tol) y*=10.0f; t*=10.0f; ck_assert_float_eq_tol(x, y, t); - t/=10.0f; + t/=10.1f; record_failure_line_num(__LINE__); ck_assert_float_eq_tol(x, y, t); } @@ -936,7 +936,7 @@ START_TEST(test_ck_assert_float_finite) record_test_name(tcase_name()); ck_assert_float_finite(x); - // MS VS doesn't allow explicit division by zero + /* MS VS doesn't allow explicit division by zero */ x = 1.0f / (1.0f - t); record_failure_line_num(__LINE__); ck_assert_float_finite(x); @@ -1092,7 +1092,7 @@ END_TEST START_TEST(test_ck_assert_double_eq_with_promotion) { - float x = 0.1; + float x = 0.1F; double y = x; record_test_name(tcase_name()); @@ -1103,7 +1103,7 @@ END_TEST START_TEST(test_ck_assert_double_eq_with_conv) { - float x = 0.1; + float x = 0.1F; record_test_name(tcase_name()); @@ -1294,7 +1294,7 @@ START_TEST(test_ck_assert_double_eq_tol) y*=10; t*=10; ck_assert_double_eq_tol(x, y, t); - t/=10; + t/=10.1; record_failure_line_num(__LINE__); ck_assert_double_eq_tol(x, y, t); } @@ -1452,7 +1452,7 @@ START_TEST(test_ck_assert_double_finite) record_test_name(tcase_name()); ck_assert_double_finite(x); - // MS VS doesn't allow explicit division by zero + /* MS VS doesn't allow explicit division by zero */ x = 1.0 / (1.0 - t); record_failure_line_num(__LINE__); ck_assert_double_finite(x); @@ -1608,7 +1608,7 @@ END_TEST START_TEST(test_ck_assert_ldouble_eq_with_promotion) { - float x = 1.1; + float x = 1.1F; long double y = x; record_test_name(tcase_name()); @@ -1619,7 +1619,7 @@ END_TEST START_TEST(test_ck_assert_ldouble_eq_with_conv) { - float x = 1.1; + float x = 1.1F; long double y = x; record_test_name(tcase_name()); @@ -1812,7 +1812,7 @@ START_TEST(test_ck_assert_ldouble_eq_tol) y*=10.0l; t*=10.0l; ck_assert_ldouble_eq_tol(x, y, t); - t/=10.0l; + t/=10.1l; record_failure_line_num(__LINE__); ck_assert_ldouble_eq_tol(x, y, t); } @@ -1970,7 +1970,7 @@ START_TEST(test_ck_assert_ldouble_finite) record_test_name(tcase_name()); ck_assert_ldouble_finite(x); - // MS VS doesn't allow explicit division by zero + /* MS VS doesn't allow explicit division by zero */ x = 1.0l / (1.0l - t); record_failure_line_num(__LINE__); ck_assert_ldouble_finite(x); @@ -2677,7 +2677,7 @@ END_TEST /* * The following test will leak memory because it is calling - * APIs inproperly. The leaked memory cannot be free'd, as + * APIs improperly. The leaked memory cannot be free'd, as * the methods to do so are static. (No user of Check should * call them directly). */ diff --git a/tests/check_check_tags.c b/tests/check_check_tags.c index e4f485ab..7c77e302 100644 --- a/tests/check_check_tags.c +++ b/tests/check_check_tags.c @@ -658,7 +658,7 @@ START_TEST(include_w_spaces) Suite *make_tag_suite(void) { - TCase *set_get_tags, *no_filters; + TCase *no_filters; TCase *include_filters, *exclude_filters; #if HAVE_DECL_SETENV TCase *include_filters_env, *exclude_filters_env; diff --git a/tests/check_list.c b/tests/check_list.c index 60b8b7ff..c16fcc0e 100644 --- a/tests/check_list.c +++ b/tests/check_list.c @@ -142,12 +142,11 @@ END_TEST START_TEST(test_add_a_bunch) { - List *lp; int i, j; char tval1[] = "abc"; char tval2[] = "123"; for (i = 0; i < 3; i++) { - lp = check_list_create(); + List *lp = check_list_create(); for (j = 0; j < 1000; j++) { check_list_add_end (lp, tval1); check_list_add_front (lp, tval2); diff --git a/tests/check_mem_leaks.c b/tests/check_mem_leaks.c index 4528fb06..29b4475f 100644 --- a/tests/check_mem_leaks.c +++ b/tests/check_mem_leaks.c @@ -32,9 +32,9 @@ #include "config.h" #include "check_check.h" -int main () +int main (void) { - int n; + int number_failed; SRunner *sr; /* @@ -83,8 +83,8 @@ int main () /* Cleanup from the fork suite setup */ fork_teardown(); - n = srunner_ntests_failed(sr); + number_failed = srunner_ntests_failed(sr); srunner_free(sr); - return (n == 0) ? EXIT_SUCCESS : EXIT_FAILURE; + return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/check_set_max_msg_size.c b/tests/check_set_max_msg_size.c index 6ebfc8e4..d7c91bd6 100644 --- a/tests/check_set_max_msg_size.c +++ b/tests/check_set_max_msg_size.c @@ -52,7 +52,6 @@ static Suite *make_set_max_msg_size_suite(void) int main (int argc, char *argv[]) { - int n; SRunner *sr; if (argc != 2) { @@ -64,8 +63,8 @@ int main (int argc, char *argv[]) * Run the test suite. This is intended to trigger the "Message is too long" error. * Actual success/failure is determined by examining the output. */ - check_set_max_msg_size(32); // 1st call has no effect since - check_set_max_msg_size(atoi(argv[1])); // the 2nd call will override it. + check_set_max_msg_size(32); /* 1st call has no effect since */ + check_set_max_msg_size(strtoul(argv[1], NULL, 10)); /* the 2nd call will override it. */ sr = srunner_create(make_set_max_msg_size_suite()); srunner_run_all(sr, CK_NORMAL); srunner_free(sr); diff --git a/tests/check_thread_stress.c b/tests/check_thread_stress.c index 717e62dd..333956af 100644 --- a/tests/check_thread_stress.c +++ b/tests/check_thread_stress.c @@ -76,7 +76,7 @@ END_TEST int main (void) { - int nf; + int number_failed; s = suite_create ("ForkThreadStress"); tc = tcase_create ("ForkThreadStress"); sr = srunner_create (s); @@ -91,13 +91,13 @@ main (void) #endif /* HAVE_FORK */ srunner_run_all (sr, CK_VERBOSE); - nf = srunner_ntests_failed (sr); + number_failed = srunner_ntests_failed (sr); srunner_free (sr); /* hack to give us XFAIL on non-posix platforms */ #ifndef HAVE_FORK - nf++; + number_failed++; #endif /* !HAVE_FORK */ - return nf ? EXIT_FAILURE : EXIT_SUCCESS; + return number_failed ? EXIT_FAILURE : EXIT_SUCCESS; } diff --git a/tests/cmake_project_usage_test/CMakeLists.txt b/tests/cmake_project_usage_test/CMakeLists.txt new file mode 100644 index 00000000..9511ae91 --- /dev/null +++ b/tests/cmake_project_usage_test/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.11 FATAL_ERROR) +if(POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) # Use _ROOT variables +endif() +if(POLICY CMP0090) + cmake_policy(SET CMP0090 NEW) + # export(PACKAGE) does not populate package registry by default. +endif() + +project( ProjectUsageTest + VERSION "0.0.0.0" + DESCRIPTION "Include Check project in this project in different ways" + LANGUAGES C) + +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED ON) +set(CMAKE_C_EXTENSIONS OFF) + +add_subdirectory(src) + diff --git a/tests/cmake_project_usage_test/README b/tests/cmake_project_usage_test/README new file mode 100644 index 00000000..047cc546 --- /dev/null +++ b/tests/cmake_project_usage_test/README @@ -0,0 +1,3 @@ +This project is used from :travis.sh to verify Check can be used in a CMake project in the right way. + +Attn. Do not use this as an example of how to use Check in your own project. Consult official documentation. diff --git a/tests/cmake_project_usage_test/src/CMakeLists.txt b/tests/cmake_project_usage_test/src/CMakeLists.txt new file mode 100644 index 00000000..46526302 --- /dev/null +++ b/tests/cmake_project_usage_test/src/CMakeLists.txt @@ -0,0 +1,35 @@ +if($ENV{INCLUDE_CHECK_WITH} STREQUAL "FetchContent") + include(FetchContent) + FetchContent_Declare(check + URL "$ENV{INCLUDE_CHECK_FROM}" + # URL file://${DIR}/check + ) + if(CMAKE_VERSION VERSION_LESS "3.14") + FetchContent_GetProperties(check) + if(NOT check_POPULATED) + FetchContent_Populate(check) + add_subdirectory(${check_SOURCE_DIR} ${check_BINARY_DIR}) + endif() + else() + FetchContent_MakeAvailable(check) + endif() +elseif($ENV{INCLUDE_CHECK_WITH} STREQUAL "find_package_config") + set(Check_ROOT "" CACHE PATH "Check installation root dir") + find_package(Check 0.13.0 REQUIRED CONFIG) +else() + message(FATAL_ERROR "Variable INCLUDE_CHECK_WITH not properly set!") +endif() + +include(CheckCCompilerFlag) +check_c_compiler_flag("-pthread" HAVE_PTHREAD) +if (HAVE_PTHREAD) + add_definitions("-pthread") + add_link_options("-pthread") +endif() + +add_library(test_suite test_suite.c) +target_link_libraries(test_suite PUBLIC Check::check) + +add_executable(tests.test tests.c) +target_link_libraries(tests.test test_suite) + diff --git a/tests/cmake_project_usage_test/src/test_suite.c b/tests/cmake_project_usage_test/src/test_suite.c new file mode 100644 index 00000000..3f22e670 --- /dev/null +++ b/tests/cmake_project_usage_test/src/test_suite.c @@ -0,0 +1,40 @@ +#include +#include +#include "test_suite.h" + +static Suite * test_suite(void) { + Suite *s; + TCase *tc_core; + TTest const * tests[MAX_TESTS_IN_SUITE] = { 0 }; + add_tests(MAX_TESTS_IN_SUITE, tests); + + s = suite_create("ProjectUsageTest"); + + /* Core test case */ + tc_core = tcase_create("Core"); + + for(size_t i = 0; i < MAX_TESTS_IN_SUITE; ++i) { + TTest const * test = tests[i]; + if(test) { + tcase_add_test(tc_core, test); + } + } + suite_add_tcase(s, tc_core); + + return s; +} + +int main(void) { + int number_failed; + Suite *s; + SRunner *sr; + + s = test_suite(); + sr = srunner_create(s); + + srunner_run_all(sr, CK_NORMAL); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); + return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} + diff --git a/tests/cmake_project_usage_test/src/test_suite.h b/tests/cmake_project_usage_test/src/test_suite.h new file mode 100644 index 00000000..dc831385 --- /dev/null +++ b/tests/cmake_project_usage_test/src/test_suite.h @@ -0,0 +1,10 @@ +#ifndef PROJECT_USAGE_TEST_TEST_SUITE_H +#define PROJECT_USAGE_TEST_TEST_SUITE_H + +#include + +#define MAX_TESTS_IN_SUITE 20 +void add_tests(size_t const n, TTest const * tests[n]); + +#endif /* PROJECT_USAGE_TEST_TEST_SUITE_H */ + diff --git a/tests/cmake_project_usage_test/src/tests.c b/tests/cmake_project_usage_test/src/tests.c new file mode 100644 index 00000000..d1aa80d6 --- /dev/null +++ b/tests/cmake_project_usage_test/src/tests.c @@ -0,0 +1,20 @@ +#include +#include +#include +#include "test_suite.h" + +START_TEST (testSimple) { + ck_assert(1 == 1); + ck_assert(1 + 1 == 2); + ck_assert(strlen("Test") == 4); +} +END_TEST + +void add_tests(size_t const n, TTest const * tests[n]) { + assert(n > 0); + size_t i = 0; + tests[i++] = testSimple; + assert(i <= n); +} + + diff --git a/tests/test_mem_leaks.sh b/tests/test_mem_leaks.sh index 44d6d303..52c0dfe3 100755 --- a/tests/test_mem_leaks.sh +++ b/tests/test_mem_leaks.sh @@ -1,6 +1,11 @@ #!/usr/bin/env sh -UNIT_TEST=./check_mem_leaks +SCRIPT_PATH="$(dirname "$(readlink -f "$0")")" +if test -z "${1}"; then + UNIT_TEST="${SCRIPT_PATH}/check_mem_leaks" +else + UNIT_TEST="${1}" +fi VALGRIND_LOG_FILE=${UNIT_TEST}.valgrind LEAK_MESSAGE="are definitely lost" diff --git a/web/img/Button-Built-on-CB-1.png b/web/img/Button-Built-on-CB-1.png deleted file mode 100644 index b9d0c94d..00000000 Binary files a/web/img/Button-Built-on-CB-1.png and /dev/null differ