Compare commits

...

No commits in common. "bleeding" and "gh-pages" have entirely different histories.

276 changed files with 1535 additions and 34119 deletions

View File

@ -1,31 +0,0 @@
[bumpversion]
current_version = 2.3.0-rc1
commit = False
parse = ^
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+) # minimum 'N.N.N'
(?:
-(?P<prerel>\w+) # 'rc' = release candidate, 'dev' = dev branch
(?:
(?P<prerelversion>\d+)
)?
)?
serialize =
{major}.{minor}.{patch}-{prerel}{prerelversion}
{major}.{minor}.{patch}-{prerel}
{major}.{minor}.{patch}
[bumpversion:part:prerel]
optional_value = release
values =
dev
rc
release
[bumpversion:file:.cmake/Modules/Properties.cmake]
[bumpversion:file:doc/conf.py]
[bumpversion:file:appveyor.yml]
[bumpversion:file:README.md]

View File

@ -1,70 +0,0 @@
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
include(CheckPrototypeDefinition)
include(CheckLibraryExists)
include(CheckFunctionExists)
include(CheckSymbolExists)
include(PackageUtils)
# Check for packages
cr_find_package (Gettext)
cr_find_package (Libintl)
if (I18N AND GETTEXT_FOUND AND LIBINTL_LIB_FOUND)
set (GettextTranslate_ALL 1)
set (GettextTranslate_GMO_BINARY 1)
set (ENABLE_NLS 1)
endif ()
# Check for functions
check_function_exists(strtok_s HAVE_STRTOK_S)
check_function_exists(strtok_r HAVE_STRTOK_R)
check_library_exists (anl getaddrinfo_a "" HAVE_GETADDRINFO_A)
check_function_exists(funopen HAVE_FUNOPEN)
check_function_exists(fopencookie HAVE_FOPENCOOKIE)
check_function_exists(open_memstream HAVE_OPEN_MEMSTREAM)
check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME_RT)
if (HAVE_CLOCK_GETTIME_RT AND NOT HAVE_LIBRT)
set (HAVE_LIBRT 1)
endif ()
if (NOT HAVE_CLOCK_GETTIME_RT)
check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
else ()
set (HAVE_CLOCK_GETTIME "${HAVE_CLOCK_GETTIME_RT}" CACHE INTERNAL "Have symbol clock_gettime")
endif ()
check_symbol_exists(CLOCK_MONOTONIC_RAW "time.h" HAVE_CLOCK_MONOTONIC_RAW)
# Check for C++11
if (LANG_CXX)
enable_language(CXX)
endif ()
if (NOT MSVC AND CMAKE_CXX_COMPILER_WORKS)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CXX11_FLAG "-std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CXX11_FLAG "-std=c++0x")
else()
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
endif()
endif()
# Valgrind support
if (DEV_BUILD)
set(ENABLE_VALGRIND_ERRORS 1)
endif ()

View File

@ -1,128 +0,0 @@
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Copyright (C) 2014 Joakim Söderberg <joakim.soderberg@gmail.com>
#
set(_CMAKE_SCRIPT_PATH ${CMAKE_CURRENT_LIST_DIR}) # must be outside coveralls_setup() to get correct path
#
# Param _COVERAGE_SRCS A list of source files that coverage should be collected for.
# Param _COVERALLS_UPLOAD Upload the result to coveralls?
#
function(coveralls_setup _COVERAGE_SRCS _COVERALLS_UPLOAD)
if (ARGC GREATER 2)
set(_CMAKE_SCRIPT_PATH ${ARGN})
message(STATUS "Coveralls: Using alternate CMake script dir: ${_CMAKE_SCRIPT_PATH}")
endif()
if (NOT EXISTS "${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake")
message(FATAL_ERROR "Coveralls: Missing ${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake")
endif()
if (NOT EXISTS "${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.cmake")
message(FATAL_ERROR "Coveralls: Missing ${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.cmake")
endif()
# When passing a CMake list to an external process, the list
# will be converted from the format "1;2;3" to "1 2 3".
# This means the script we're calling won't see it as a list
# of sources, but rather just one long path. We remedy this
# by replacing ";" with "*" and then reversing that in the script
# that we're calling.
# http://cmake.3232098.n2.nabble.com/Passing-a-CMake-list-quot-as-is-quot-to-a-custom-target-td6505681.html
set(COVERAGE_SRCS_TMP ${_COVERAGE_SRCS})
set(COVERAGE_SRCS "")
foreach (COVERAGE_SRC ${COVERAGE_SRCS_TMP})
set(COVERAGE_SRCS "${COVERAGE_SRCS}*${COVERAGE_SRC}")
endforeach()
#message("Coverage sources: ${COVERAGE_SRCS}")
set(COVERALLS_FILE ${PROJECT_BINARY_DIR}/coveralls.json)
add_custom_target(coveralls_generate
# Zero the coverage counters.
COMMAND ${CMAKE_COMMAND} -DPROJECT_BINARY_DIR="${PROJECT_BINARY_DIR}" -P "${_CMAKE_SCRIPT_PATH}/CoverallsClear.cmake"
# Run regress tests.
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
# Generate Gcov and translate it into coveralls JSON.
# We do this by executing an external CMake script.
# (We don't want this to run at CMake generation time, but after compilation and everything has run).
COMMAND ${CMAKE_COMMAND}
-DCOVERAGE_SRCS="${COVERAGE_SRCS}" # TODO: This is passed like: "a b c", not "a;b;c"
-DCOVERALLS_OUTPUT_FILE="${COVERALLS_FILE}"
-DCOV_PATH="${PROJECT_BINARY_DIR}"
-DPROJECT_ROOT="${PROJECT_SOURCE_DIR}"
-P "${_CMAKE_SCRIPT_PATH}/CoverallsGenerateGcov.cmake"
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Generating coveralls output..."
)
if (_COVERALLS_UPLOAD)
message("COVERALLS UPLOAD: ON")
find_program(CURL_EXECUTABLE curl)
if (NOT CURL_EXECUTABLE)
message(FATAL_ERROR "Coveralls: curl not found! Aborting")
endif()
add_custom_target(coveralls_upload
# Upload the JSON to coveralls.
COMMAND ${CURL_EXECUTABLE}
-S -F json_file=@${COVERALLS_FILE}
https://coveralls.io/api/v1/jobs
DEPENDS coveralls_generate
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT "Uploading coveralls output...")
add_custom_target(coveralls DEPENDS coveralls_upload)
else()
message("COVERALLS UPLOAD: OFF")
add_custom_target(coveralls DEPENDS coveralls_generate)
endif()
endfunction()
macro(coveralls_turn_on_coverage)
if(NOT (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
AND (NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang"))
message(FATAL_ERROR "Coveralls: Compiler ${CMAKE_C_COMPILER_ID} is not GNU gcc! Aborting... You can set this on the command line using CC=/usr/bin/gcc CXX=/usr/bin/g++ cmake <options> ..")
endif()
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(FATAL_ERROR "Coveralls: Code coverage results with an optimised (non-Debug) build may be misleading! Add -DCMAKE_BUILD_TYPE=Debug")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
endmacro()

View File

@ -1,31 +0,0 @@
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Copyright (C) 2014 Joakim Söderberg <joakim.soderberg@gmail.com>
#
# do not follow symlinks in file(GLOB_RECURSE ...)
cmake_policy(SET CMP0009 NEW)
file(GLOB_RECURSE GCDA_FILES "${PROJECT_BINARY_DIR}/*.gcda")
if(NOT GCDA_FILES STREQUAL "")
file(REMOVE ${GCDA_FILES})
endif()

View File

@ -1,489 +0,0 @@
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Copyright (C) 2014 Joakim Söderberg <joakim.soderberg@gmail.com>
#
# This is intended to be run by a custom target in a CMake project like this.
# 0. Compile program with coverage support.
# 1. Clear coverage data. (Recursively delete *.gcda in build dir)
# 2. Run the unit tests.
# 3. Run this script specifying which source files the coverage should be performed on.
#
# This script will then use gcov to generate .gcov files in the directory specified
# via the COV_PATH var. This should probably be the same as your cmake build dir.
#
# It then parses the .gcov files to convert them into the Coveralls JSON format:
# https://coveralls.io/docs/api
#
# Example for running as standalone CMake script from the command line:
# (Note it is important the -P is at the end...)
# $ cmake -DCOV_PATH=$(pwd)
# -DCOVERAGE_SRCS="catcierge_rfid.c;catcierge_timer.c"
# -P ../cmake/CoverallsGcovUpload.cmake
#
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
#
# Make sure we have the needed arguments.
#
if (NOT COVERALLS_OUTPUT_FILE)
message(FATAL_ERROR "Coveralls: No coveralls output file specified. Please set COVERALLS_OUTPUT_FILE")
endif()
if (NOT COV_PATH)
message(FATAL_ERROR "Coveralls: Missing coverage directory path where gcov files will be generated. Please set COV_PATH")
endif()
if (NOT COVERAGE_SRCS)
message(FATAL_ERROR "Coveralls: Missing the list of source files that we should get the coverage data for COVERAGE_SRCS")
endif()
if (NOT PROJECT_ROOT)
message(FATAL_ERROR "Coveralls: Missing PROJECT_ROOT.")
endif()
# Since it's not possible to pass a CMake list properly in the
# "1;2;3" format to an external process, we have replaced the
# ";" with "*", so reverse that here so we get it back into the
# CMake list format.
string(REGEX REPLACE "\\*" ";" COVERAGE_SRCS ${COVERAGE_SRCS})
# convert all paths in COVERAGE_SRCS to absolute paths
set(COVERAGE_SRCS_TMP "")
foreach (COVERAGE_SRC ${COVERAGE_SRCS})
if (NOT "${COVERAGE_SRC}" MATCHES "^/")
set(COVERAGE_SRC ${PROJECT_ROOT}/${COVERAGE_SRC})
endif()
list(APPEND COVERAGE_SRCS_TMP ${COVERAGE_SRC})
endforeach()
set(COVERAGE_SRCS ${COVERAGE_SRCS_TMP})
unset(COVERAGE_SRCS_TMP)
if (NOT DEFINED ENV{GCOV})
find_program(GCOV_EXECUTABLE gcov)
else()
find_program(GCOV_EXECUTABLE $ENV{GCOV})
endif()
if (NOT GCOV_EXECUTABLE)
message(FATAL_ERROR "gcov not found! Aborting...")
endif()
find_package(Git)
set(JSON_REPO_TEMPLATE
"{
\"head\": {
\"id\": \"\@GIT_COMMIT_HASH\@\",
\"author_name\": \"\@GIT_AUTHOR_NAME\@\",
\"author_email\": \"\@GIT_AUTHOR_EMAIL\@\",
\"committer_name\": \"\@GIT_COMMITTER_NAME\@\",
\"committer_email\": \"\@GIT_COMMITTER_EMAIL\@\",
\"message\": \"\@GIT_COMMIT_MESSAGE\@\"
},
\"branch\": \"@GIT_BRANCH@\",
\"remotes\": []
}"
)
# TODO: Fill in git remote data
if (GIT_FOUND)
# Branch.
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
macro (git_log_format FORMAT_CHARS VAR_NAME)
execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%${FORMAT_CHARS}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE ${VAR_NAME}
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endmacro()
git_log_format(an GIT_AUTHOR_NAME)
git_log_format(ae GIT_AUTHOR_EMAIL)
git_log_format(cn GIT_COMMITTER_NAME)
git_log_format(ce GIT_COMMITTER_EMAIL)
git_log_format(B GIT_COMMIT_MESSAGE)
git_log_format(H GIT_COMMIT_HASH)
message("Git exe: ${GIT_EXECUTABLE}")
message("Git branch: ${GIT_BRANCH}")
message("Git author: ${GIT_AUTHOR_NAME}")
message("Git e-mail: ${GIT_AUTHOR_EMAIL}")
message("Git commiter name: ${GIT_COMMITTER_NAME}")
message("Git commiter e-mail: ${GIT_COMMITTER_EMAIL}")
message("Git commit hash: ${GIT_COMMIT_HASH}")
message("Git commit message: ${GIT_COMMIT_MESSAGE}")
string(CONFIGURE ${JSON_REPO_TEMPLATE} JSON_REPO_DATA)
else()
set(JSON_REPO_DATA "{}")
endif()
############################# Macros #########################################
#
# This macro converts from the full path format gcov outputs:
#
# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
#
# to the original source file path the .gcov is for:
#
# /path/to/project/root/subdir/the_file.c
#
macro(get_source_path_from_gcov_filename _SRC_FILENAME _GCOV_FILENAME)
# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
# ->
# #path#to#project#root#subdir#the_file.c.gcov
get_filename_component(_GCOV_FILENAME_WEXT ${_GCOV_FILENAME} NAME)
# #path#to#project#root#subdir#the_file.c.gcov -> /path/to/project/root/subdir/the_file.c
string(REGEX REPLACE "\\.gcov$" "" SRC_FILENAME_TMP ${_GCOV_FILENAME_WEXT})
string(REGEX REPLACE "\#" "/" SRC_FILENAME_TMP ${SRC_FILENAME_TMP})
string(REGEX REPLACE "~" ":" SRC_FILENAME_TMP ${SRC_FILENAME_TMP})
set(${_SRC_FILENAME} "${SRC_FILENAME_TMP}")
endmacro()
##############################################################################
# Get the coverage data.
file(GLOB_RECURSE GCDA_FILES "${COV_PATH}/*.gcda")
message("GCDA files:")
# Get a list of all the object directories needed by gcov
# (The directories the .gcda files and .o files are found in)
# and run gcov on those.
foreach(GCDA ${GCDA_FILES})
message("Process: ${GCDA}")
message("------------------------------------------------------------------------------")
get_filename_component(GCDA_DIR ${GCDA} PATH)
#
# The -p below refers to "Preserve path components",
# This means that the generated gcov filename of a source file will
# keep the original files entire filepath, but / is replaced with #.
# Example:
#
# /path/to/project/root/build/CMakeFiles/the_file.dir/subdir/the_file.c.gcda
# ------------------------------------------------------------------------------
# File '/path/to/project/root/subdir/the_file.c'
# Lines executed:68.34% of 199
# /path/to/project/root/subdir/the_file.c:creating '#path#to#project#root#subdir#the_file.c.gcov'
#
# If -p is not specified then the file is named only "the_file.c.gcov"
#
execute_process(
COMMAND ${GCOV_EXECUTABLE} -p -o ${GCDA_DIR} ${GCDA}
WORKING_DIRECTORY ${COV_PATH}
)
endforeach()
# TODO: Make these be absolute path
file(GLOB ALL_GCOV_FILES ${COV_PATH}/*.gcov)
# Get only the filenames to use for filtering.
#set(COVERAGE_SRCS_NAMES "")
#foreach (COVSRC ${COVERAGE_SRCS})
# get_filename_component(COVSRC_NAME ${COVSRC} NAME)
# message("${COVSRC} -> ${COVSRC_NAME}")
# list(APPEND COVERAGE_SRCS_NAMES "${COVSRC_NAME}")
#endforeach()
#
# Filter out all but the gcov files we want.
#
# We do this by comparing the list of COVERAGE_SRCS filepaths that the
# user wants the coverage data for with the paths of the generated .gcov files,
# so that we only keep the relevant gcov files.
#
# Example:
# COVERAGE_SRCS =
# /path/to/project/root/subdir/the_file.c
#
# ALL_GCOV_FILES =
# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
# /path/to/project/root/build/#path#to#project#root#subdir#other_file.c.gcov
#
# Result should be:
# GCOV_FILES =
# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
#
set(GCOV_FILES "")
#message("Look in coverage sources: ${COVERAGE_SRCS}")
message("\nFilter out unwanted GCOV files:")
message("===============================")
set(COVERAGE_SRCS_REMAINING ${COVERAGE_SRCS})
foreach (GCOV_FILE ${ALL_GCOV_FILES})
#
# /path/to/project/root/build/#path#to#project#root#subdir#the_file.c.gcov
# ->
# /path/to/project/root/subdir/the_file.c
get_source_path_from_gcov_filename(GCOV_SRC_PATH ${GCOV_FILE})
file(RELATIVE_PATH GCOV_SRC_REL_PATH "${PROJECT_ROOT}" "${GCOV_SRC_PATH}")
# Is this in the list of source files?
# TODO: We want to match against relative path filenames from the source file root...
list(FIND COVERAGE_SRCS ${GCOV_SRC_PATH} WAS_FOUND)
if (NOT WAS_FOUND EQUAL -1)
message("YES: ${GCOV_FILE}")
list(APPEND GCOV_FILES ${GCOV_FILE})
# We remove it from the list, so we don't bother searching for it again.
# Also files left in COVERAGE_SRCS_REMAINING after this loop ends should
# have coverage data generated from them (no lines are covered).
list(REMOVE_ITEM COVERAGE_SRCS_REMAINING ${GCOV_SRC_PATH})
else()
message("NO: ${GCOV_FILE}")
endif()
endforeach()
# TODO: Enable setting these
if (NOT DEFINED ENV{CI_NAME})
set(JSON_SERVICE_NAME "travis-ci")
else ()
set(JSON_SERVICE_NAME $ENV{CI_NAME})
endif()
if (NOT DEFINED ENV{CI_JOB_ID})
set(JSON_SERVICE_JOB_ID $ENV{TRAVIS_JOB_ID})
else ()
set(JSON_SERVICE_JOB_ID $ENV{CI_JOB_ID})
endif()
set(JSON_REPO_TOKEN $ENV{COVERALLS_REPO_TOKEN})
set(JSON_TEMPLATE
"{
\"repo_token\": \"\@JSON_REPO_TOKEN\@\",
\"service_name\": \"\@JSON_SERVICE_NAME\@\",
\"service_job_id\": \"\@JSON_SERVICE_JOB_ID\@\",
\"source_files\": \@JSON_GCOV_FILES\@,
\"git\": \@JSON_REPO_DATA\@
}"
)
set(SRC_FILE_TEMPLATE
"{
\"name\": \"\@GCOV_SRC_REL_PATH\@\",
\"source_digest\": \"\@GCOV_CONTENTS_MD5\@\",
\"coverage\": \@GCOV_FILE_COVERAGE\@
}"
)
message("\nGenerate JSON for files:")
message("=========================")
set(JSON_GCOV_FILES "[")
# Read the GCOV files line by line and get the coverage data.
foreach (GCOV_FILE ${GCOV_FILES})
get_source_path_from_gcov_filename(GCOV_SRC_PATH ${GCOV_FILE})
file(RELATIVE_PATH GCOV_SRC_REL_PATH "${PROJECT_ROOT}" "${GCOV_SRC_PATH}")
# The new coveralls API doesn't need the entire source (Yay!)
# However, still keeping that part for now. Will cleanup in the future.
file(MD5 "${GCOV_SRC_PATH}" GCOV_CONTENTS_MD5)
message("MD5: ${GCOV_SRC_PATH} = ${GCOV_CONTENTS_MD5}")
# Loads the gcov file as a list of lines.
# (We first open the file and replace all occurences of [] with _
# because CMake will fail to parse a line containing unmatched brackets...
# also the \ to escaped \n in macros screws up things.)
# https://public.kitware.com/Bug/view.php?id=15369
file(READ ${GCOV_FILE} GCOV_CONTENTS)
string(REPLACE "[" "_" GCOV_CONTENTS "${GCOV_CONTENTS}")
string(REPLACE "]" "_" GCOV_CONTENTS "${GCOV_CONTENTS}")
string(REPLACE "\\" "_" GCOV_CONTENTS "${GCOV_CONTENTS}")
# Remove file contents to avoid encoding issues (cmake 2.8 has no ENCODING option)
string(REGEX REPLACE "([^:]*):([^:]*):([^\n]*)\n" "\\1:\\2: \n" GCOV_CONTENTS "${GCOV_CONTENTS}")
file(WRITE ${GCOV_FILE}_tmp "${GCOV_CONTENTS}")
file(STRINGS ${GCOV_FILE}_tmp GCOV_LINES)
list(LENGTH GCOV_LINES LINE_COUNT)
# Instead of trying to parse the source from the
# gcov file, simply read the file contents from the source file.
# (Parsing it from the gcov is hard because C-code uses ; in many places
# which also happens to be the same as the CMake list delimeter).
file(READ ${GCOV_SRC_PATH} GCOV_FILE_SOURCE)
string(REPLACE "\\" "\\\\" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")
string(REGEX REPLACE "\"" "\\\\\"" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")
string(REPLACE "\t" "\\\\t" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")
string(REPLACE "\r" "\\\\r" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")
string(REPLACE "\n" "\\\\n" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")
# According to http://json.org/ these should be escaped as well.
# Don't know how to do that in CMake however...
#string(REPLACE "\b" "\\\\b" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")
#string(REPLACE "\f" "\\\\f" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")
#string(REGEX REPLACE "\u([a-fA-F0-9]{4})" "\\\\u\\1" GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}")
# We want a json array of coverage data as a single string
# start building them from the contents of the .gcov
set(GCOV_FILE_COVERAGE "[")
set(GCOV_LINE_COUNT 1) # Line number for the .gcov.
set(DO_SKIP 0)
foreach (GCOV_LINE ${GCOV_LINES})
#message("${GCOV_LINE}")
# Example of what we're parsing:
# Hitcount |Line | Source
# " 8: 26: if (!allowed || (strlen(allowed) == 0))"
string(REGEX REPLACE
"^([^:]*):([^:]*):(.*)$"
"\\1;\\2;\\3"
RES
"${GCOV_LINE}")
# Check if we should exclude lines using the Lcov syntax.
string(REGEX MATCH "LCOV_EXCL_START" START_SKIP "${GCOV_LINE}")
string(REGEX MATCH "LCOV_EXCL_END" END_SKIP "${GCOV_LINE}")
string(REGEX MATCH "LCOV_EXCL_LINE" LINE_SKIP "${GCOV_LINE}")
set(RESET_SKIP 0)
if (LINE_SKIP AND NOT DO_SKIP)
set(DO_SKIP 1)
set(RESET_SKIP 1)
endif()
if (START_SKIP)
set(DO_SKIP 1)
message("${GCOV_LINE_COUNT}: Start skip")
endif()
if (END_SKIP)
set(DO_SKIP 0)
endif()
list(LENGTH RES RES_COUNT)
if (RES_COUNT GREATER 2)
list(GET RES 0 HITCOUNT)
list(GET RES 1 LINE)
list(GET RES 2 SOURCE)
string(STRIP ${HITCOUNT} HITCOUNT)
string(STRIP ${LINE} LINE)
# Lines with 0 line numbers are metadata and can be ignored.
if (NOT ${LINE} EQUAL 0)
if (DO_SKIP)
set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}null, ")
else()
# Translate the hitcount into valid JSON values.
if (${HITCOUNT} STREQUAL "#####" OR ${HITCOUNT} STREQUAL "=====")
set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}0, ")
elseif (${HITCOUNT} STREQUAL "-")
set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}null, ")
else()
set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}${HITCOUNT}, ")
endif()
endif()
endif()
else()
message(WARNING "Failed to properly parse line (RES_COUNT = ${RES_COUNT}) ${GCOV_FILE}:${GCOV_LINE_COUNT}\n-->${GCOV_LINE}")
endif()
if (RESET_SKIP)
set(DO_SKIP 0)
endif()
math(EXPR GCOV_LINE_COUNT "${GCOV_LINE_COUNT}+1")
endforeach()
message("${GCOV_LINE_COUNT} of ${LINE_COUNT} lines read!")
# Advanced way of removing the trailing comma in the JSON array.
# "[1, 2, 3, " -> "[1, 2, 3"
string(REGEX REPLACE ",[ ]*$" "" GCOV_FILE_COVERAGE ${GCOV_FILE_COVERAGE})
# Append the trailing ] to complete the JSON array.
set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}]")
# Generate the final JSON for this file.
message("Generate JSON for file: ${GCOV_SRC_REL_PATH}...")
string(CONFIGURE ${SRC_FILE_TEMPLATE} FILE_JSON)
set(JSON_GCOV_FILES "${JSON_GCOV_FILES}${FILE_JSON}, ")
endforeach()
# Loop through all files we couldn't find any coverage for
# as well, and generate JSON for those as well with 0% coverage.
foreach(NOT_COVERED_SRC ${COVERAGE_SRCS_REMAINING})
# Set variables for json replacement
set(GCOV_SRC_PATH ${NOT_COVERED_SRC})
file(MD5 "${GCOV_SRC_PATH}" GCOV_CONTENTS_MD5)
file(RELATIVE_PATH GCOV_SRC_REL_PATH "${PROJECT_ROOT}" "${GCOV_SRC_PATH}")
# Loads the source file as a list of lines.
file(STRINGS ${NOT_COVERED_SRC} SRC_LINES)
set(GCOV_FILE_COVERAGE "[")
set(GCOV_FILE_SOURCE "")
foreach (SOURCE ${SRC_LINES})
set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}null, ")
string(REPLACE "\\" "\\\\" SOURCE "${SOURCE}")
string(REGEX REPLACE "\"" "\\\\\"" SOURCE "${SOURCE}")
string(REPLACE "\t" "\\\\t" SOURCE "${SOURCE}")
string(REPLACE "\r" "\\\\r" SOURCE "${SOURCE}")
set(GCOV_FILE_SOURCE "${GCOV_FILE_SOURCE}${SOURCE}\\n")
endforeach()
# Remove trailing comma, and complete JSON array with ]
string(REGEX REPLACE ",[ ]*$" "" GCOV_FILE_COVERAGE ${GCOV_FILE_COVERAGE})
set(GCOV_FILE_COVERAGE "${GCOV_FILE_COVERAGE}]")
# Generate the final JSON for this file.
message("Generate JSON for non-gcov file: ${NOT_COVERED_SRC}...")
string(CONFIGURE ${SRC_FILE_TEMPLATE} FILE_JSON)
set(JSON_GCOV_FILES "${JSON_GCOV_FILES}${FILE_JSON}, ")
endforeach()
# Get rid of trailing comma.
string(REGEX REPLACE ",[ ]*$" "" JSON_GCOV_FILES ${JSON_GCOV_FILES})
set(JSON_GCOV_FILES "${JSON_GCOV_FILES}]")
# Generate the final complete JSON!
message("Generate final JSON...")
string(CONFIGURE ${JSON_TEMPLATE} JSON)
file(WRITE "${COVERALLS_OUTPUT_FILE}" "${JSON}")
message("###########################################################################")
message("Generated coveralls JSON containing coverage data:")
message("${COVERALLS_OUTPUT_FILE}")
message("###########################################################################")

View File

@ -1,63 +0,0 @@
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
set(PATH_VAR
"${PROJECT_BINARY_DIR}/samples"
"${PROJECT_BINARY_DIR}/samples/tests"
"${PROJECT_BINARY_DIR}/external/lib"
"${PROJECT_BINARY_DIR}/external/bin"
)
set(NEW_PATH "")
foreach (P ${PATH_VAR})
file (TO_NATIVE_PATH "${P}" P)
list (APPEND NEW_PATH "${P}")
endforeach ()
set (PATH_VAR "${NEW_PATH}")
if (NOT WIN32)
string (REPLACE ";" ":" PATH_VAR "${PATH_VAR}")
set(ENV{PATH} "$ENV{PATH}:${PATH_VAR}")
else ()
set(ENV{PATH} "$ENV{PATH};${PATH_VAR}")
endif ()
set(ENV{LC_ALL} "en_US.utf8")
set(ENV{CRITERION_ALWAYS_SUCCEED} "1")
set(ENV{CRITERION_SHORT_FILENAME} "1")
set(ENV{CRITERION_JOBS} "1")
set(ENV{CRITERION_DISABLE_TIME_MEASUREMENTS} "1")
set(ENV{MSYS2_ARG_CONV_EXCL} "--filter=")
if (WIN32)
if (ENV{MINGW} STREQUAL "")
set (MINGW_HOME "C:/MinGW")
else ()
file (TO_CMAKE_PATH "$ENV{MINGW}" MINGW_HOME)
endif ()
if (ENV{CRAM_SHELL} STREQUAL "" AND MINGW_HOME)
set (CRAM_SHELL "${MINGW_HOME}/msys/1.0/bin/sh.exe")
else ()
file (TO_CMAKE_PATH "$ENV{CRAM_SHELL}" CRAM_SHELL)
endif ()
if (CRAM_SHELL)
set(CRAM_OPTS "--shell=${CRAM_SHELL}")
endif ()
endif ()
if ("$ENV{TRAVIS}" STREQUAL "true")
execute_process (COMMAND cram -v ${CRAM_OPTS} "${CRAM_PATH}" TIMEOUT 60 RESULT_VARIABLE RES)
else ()
if ("$ENV{PYTHON_BIN}" STREQUAL "")
set (PYTHON "python")
else ()
set (PYTHON "$ENV{PYTHON_BIN}")
endif ()
execute_process (COMMAND ${PYTHON} -m cram -v ${CRAM_OPTS} "${CRAM_PATH}" TIMEOUT 60 RESULT_VARIABLE RES)
endif ()
if (NOT RES STREQUAL "0")
message (FATAL_ERROR "Cram tests failed")
endif ()

View File

@ -1,43 +0,0 @@
# build a Debian package for Launchpad
set(CPACK_DEBIAN_PACKAGE_NAME "criterion")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/Snaipe/Criterion")
set(CPACK_DEBIAN_BUILD_DEPENDS
debhelper
cmake
gettext
)
set(CPACK_DEBIAN_PACKAGE_DEPENDS)
set(CPACK_DEBIAN_CMAKE_OPTIONS)
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/description.txt")
set(CPACK_DEBIAN_PACKAGE_SOURCE_COPY "${PROJECT_SOURCE_DIR}/.cmake/copy-source.sh")
set(CPACK_DEBIAN_DISTRIBUTION_NAME ubuntu)
set(CPACK_DEBIAN_DISTRIBUTION_RELEASES precise trusty vivid wily xenial)
set(DPUT_HOST "snaipewastaken-ppa")
set(DPUT_SNAPSHOT_HOST "snaipewastaken-ppa")
set(CPACK_DEBIAN_PACKAGE_DOCS "")
set(CPACK_DEBIAN_PACKAGE_INSTALL
"/usr/lib/*.so"
"/usr/lib/*.so.*"
"/usr/share/locale/*"
)
set(CPACK_COMPONENTS_ALL "dev")
set(CPACK_COMPONENT_DEV_DISPLAY_NAME "Criterion library development files")
set(CPACK_COMPONENT_DEV_DESCRIPTION "These are the development files.")
set(CPACK_COMPONENT_DEV_SECTION "devel")
set(CPACK_COMPONENT_DEV_DEPENDS
criterion
)
set(CPACK_COMPONENT_DEV_DOCS "")
set(CPACK_COMPONENT_DEV_INSTALL "/usr/include")
include (DebSourcePPA)

View File

@ -1,347 +0,0 @@
## Debian Source Package Generator
#
# Copyright (c) 2010 Daniel Pfeifer <daniel@pfeifer-mail.de>
# Many modifications by Rosen Diankov <rosen.diankov@gmail.com>
#
# Creates source debian files and manages library dependencies
#
# Features:
#
# - Automatically generates symbols and run-time dependencies from the build dependencies
# - Custom copy of source directory via CPACK_DEBIAN_PACKAGE_SOURCE_COPY
# - Simultaneous output of multiple debian source packages for each distribution
# - Can specificy distribution-specific dependencies by suffixing DEPENDS with _${DISTRO_NAME}, for example: CPACK_DEBIAN_PACKAGE_DEPENDS_LUCID, CPACK_COMPONENT_MYCOMP0_DEPENDS_LUCID
#
# Usage:
#
# set(CPACK_DEBIAN_BUILD_DEPENDS debhelper cmake)
# set(CPACK_DEBIAN_PACKAGE_PRIORITY optional)
# set(CPACK_DEBIAN_PACKAGE_SECTION devel)
# set(CPACK_DEBIAN_CMAKE_OPTIONS "-DMYOPTION=myvalue")
# set(CPACK_DEBIAN_PACKAGE_DEPENDS mycomp0 mycomp1 some_ubuntu_package)
# set(CPACK_DEBIAN_PACKAGE_DEPENDS_UBUNTU_LUCID mycomp0 mycomp1 lucid_specific_package)
# set(CPACK_DEBIAN_PACKAGE_NAME mypackage)
# set(CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES unnecessary_file unnecessary_dir/file0)
# set(CPACK_DEBIAN_PACKAGE_SOURCE_COPY svn export --force) # if using subversion
# set(CPACK_DEBIAN_DISTRIBUTION_NAME ubuntu)
# set(CPACK_DEBIAN_DISTRIBUTION_RELEASES karmic lucid maverick natty)
# set(CPACK_DEBIAN_CHANGELOG " * Extra change log lines")
# set(CPACK_DEBIAN_PACKAGE_SUGGESTS "ipython")
# set(CPACK_COMPONENT_X_RECOMMENDS "recommended-package")
##
find_program(DEBUILD_EXECUTABLE debuild)
find_program(DPUT_EXECUTABLE dput)
if(NOT DEBUILD_EXECUTABLE OR NOT DPUT_EXECUTABLE)
return()
endif(NOT DEBUILD_EXECUTABLE OR NOT DPUT_EXECUTABLE)
# DEBIAN/control
# debian policy enforce lower case for package name
# Package: (mandatory)
IF(NOT CPACK_DEBIAN_PACKAGE_NAME)
STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_DEBIAN_PACKAGE_NAME)
ENDIF(NOT CPACK_DEBIAN_PACKAGE_NAME)
# Section: (recommended)
IF(NOT CPACK_DEBIAN_PACKAGE_SECTION)
SET(CPACK_DEBIAN_PACKAGE_SECTION "devel")
ENDIF(NOT CPACK_DEBIAN_PACKAGE_SECTION)
# Priority: (recommended)
IF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
ENDIF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
file(STRINGS ${CPACK_PACKAGE_DESCRIPTION_FILE} DESC_LINES)
foreach(LINE ${DESC_LINES})
set(DEB_LONG_DESCRIPTION "${DEB_LONG_DESCRIPTION} ${LINE}\n")
endforeach(LINE ${DESC_LINES})
file(REMOVE_RECURSE "${PROJECT_BINARY_DIR}/Debian")
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/Debian")
set(DEBIAN_SOURCE_ORIG_DIR "${PROJECT_BINARY_DIR}/Debian/${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
if( CPACK_DEBIAN_PACKAGE_SOURCE_COPY )
execute_process(COMMAND ${CPACK_DEBIAN_PACKAGE_SOURCE_COPY} "${PROJECT_SOURCE_DIR}" "${DEBIAN_SOURCE_ORIG_DIR}.orig")
else()
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR} "${DEBIAN_SOURCE_ORIG_DIR}.orig")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${DEBIAN_SOURCE_ORIG_DIR}.orig/.git")
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${DEBIAN_SOURCE_ORIG_DIR}.orig/.svn")
endif()
# remove unnecessary folders
foreach(REMOVE_DIR ${CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES})
file(REMOVE_RECURSE ${DEBIAN_SOURCE_ORIG_DIR}.orig/${REMOVE_DIR})
endforeach()
# create the original source tar
execute_process(COMMAND ${CMAKE_COMMAND} -E tar czf "${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}.orig.tar.gz" "${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.orig" WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/Debian)
set(DEB_SOURCE_CHANGES)
foreach(RELEASE ${CPACK_DEBIAN_DISTRIBUTION_RELEASES})
set(DEBIAN_SOURCE_DIR "${DEBIAN_SOURCE_ORIG_DIR}-${CPACK_DEBIAN_DISTRIBUTION_NAME}1~${RELEASE}1")
set(RELEASE_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_DISTRIBUTION_NAME}1~${RELEASE}1")
string(TOUPPER ${RELEASE} RELEASE_UPPER)
string(TOUPPER ${CPACK_DEBIAN_DISTRIBUTION_NAME} DISTRIBUTION_NAME_UPPER)
file(MAKE_DIRECTORY ${DEBIAN_SOURCE_DIR}/debian)
##############################################################################
# debian/control
set(DEBIAN_CONTROL ${DEBIAN_SOURCE_DIR}/debian/control)
file(WRITE ${DEBIAN_CONTROL}
"Source: ${CPACK_DEBIAN_PACKAGE_NAME}\n"
"Section: ${CPACK_DEBIAN_PACKAGE_SECTION}\n"
"Priority: ${CPACK_DEBIAN_PACKAGE_PRIORITY}\n"
"DM-Upload-Allowed: yes\n"
"Maintainer: ${CPACK_PACKAGE_CONTACT}\n"
"Build-Depends: "
)
if( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
foreach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
else( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
if( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
else( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_BUILD_DEPENDS})
endif( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
endif( CPACK_DEBIAN_BUILD_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
file(APPEND ${DEBIAN_CONTROL} "\n"
"Standards-Version: 3.8.4\n"
"Homepage: ${CPACK_PACKAGE_VENDOR}\n"
"\n"
"Package: ${CPACK_DEBIAN_PACKAGE_NAME}\n"
"Architecture: any\n"
"Depends: "
)
if( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
else( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
if( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
else( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_DEPENDS})
endif( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
endif( CPACK_DEBIAN_PACKAGE_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
file(APPEND ${DEBIAN_CONTROL} "\nRecommends: ")
if( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
else( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
if( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}})
else( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_RECOMMENDS})
endif( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
endif( CPACK_DEBIAN_PACKAGE_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
file(APPEND ${DEBIAN_CONTROL} "\nSuggests: ")
if( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
else( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
if( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}})
else( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS})
file(APPEND ${DEBIAN_CONTROL} "${DEP}, ")
endforeach(DEP ${CPACK_DEBIAN_PACKAGE_SUGGESTS})
endif( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
endif( CPACK_DEBIAN_PACKAGE_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
file(APPEND ${DEBIAN_CONTROL} "\n"
"Description: ${CPACK_PACKAGE_DISPLAY_NAME} ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}\n"
"${DEB_LONG_DESCRIPTION}"
)
foreach(COMPONENT ${CPACK_COMPONENTS_ALL})
string(TOUPPER ${COMPONENT} UPPER_COMPONENT)
set(DEPENDS "\${shlibs:Depends}")
if( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
set(DEPENDS "${DEPENDS}, ${DEP}")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
else( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
if( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
set(DEPENDS "${DEPENDS}, ${DEP}")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}})
else( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS})
set(DEPENDS "${DEPENDS}, ${DEP}")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS})
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER} )
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_DEPENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
set(RECOMMENDS)
if( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
set(RECOMMENDS "${RECOMMENDS} ${DEP}, ")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
else( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
if( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}})
set(RECOMMENDS "${RECOMMENDS} ${DEP}, ")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}})
else( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS})
set(RECOMMENDS "${RECOMMENDS} ${DEP}, ")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS})
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER} )
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_RECOMMENDS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
set(SUGGESTS)
if( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
set(SUGGESTS "${SUGGESTS} ${DEP}, ")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER}})
else( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
if( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}})
set(SUGGESTS "${SUGGESTS} ${DEP}, ")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}})
else( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
foreach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS})
set(SUGGESTS "${SUGGESTS} ${DEP}, ")
endforeach(DEP ${CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS})
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER} )
endif( CPACK_COMPONENT_${UPPER_COMPONENT}_SUGGESTS_${DISTRIBUTION_NAME_UPPER}_${RELEASE_UPPER} )
file(APPEND ${DEBIAN_CONTROL} "\n"
"Package: ${CPACK_DEBIAN_PACKAGE_NAME}-${COMPONENT}\n"
"Architecture: any\n"
"Depends: ${DEPENDS}\n"
"Recommends: ${RECOMMENDS}\n"
"Suggests: ${SUGGESTS}\n"
"Description: ${CPACK_PACKAGE_DISPLAY_NAME} ${CPACK_COMPONENT_${UPPER_COMPONENT}_DISPLAY_NAME}\n"
"${DEB_LONG_DESCRIPTION}"
" .\n"
" ${CPACK_COMPONENT_${UPPER_COMPONENT}_DESCRIPTION}\n"
)
endforeach(COMPONENT ${CPACK_COMPONENTS_ALL})
##############################################################################
# debian/copyright
set(DEBIAN_COPYRIGHT ${DEBIAN_SOURCE_DIR}/debian/copyright)
execute_process(COMMAND ${CMAKE_COMMAND} -E
copy ${CPACK_RESOURCE_FILE_LICENSE} ${DEBIAN_COPYRIGHT}
)
##############################################################################
# debian/rules
set(DEBIAN_RULES ${DEBIAN_SOURCE_DIR}/debian/rules)
file(WRITE ${DEBIAN_RULES}
"#!/usr/bin/make -f\n"
"\n"
"BUILDDIR = build_dir\n"
"\n"
"build:\n"
" mkdir $(BUILDDIR)\n"
" cd $(BUILDDIR); cmake -DCMAKE_BUILD_TYPE=Release ${CPACK_DEBIAN_CMAKE_OPTIONS} -DCMAKE_INSTALL_PREFIX=/usr ..\n"
" $(MAKE) -C $(BUILDDIR) preinstall\n"
" touch build\n"
"\n"
"binary: binary-indep binary-arch\n"
"\n"
"binary-indep: build\n"
"\n"
"binary-arch: build\n"
" cd $(BUILDDIR); cmake -DCOMPONENT=Unspecified -DCMAKE_INSTALL_PREFIX=../debian/tmp/usr -P cmake_install.cmake\n"
" mkdir -p debian/tmp/DEBIAN\n"
" dpkg-gensymbols -p${CPACK_DEBIAN_PACKAGE_NAME}\n"
)
foreach(COMPONENT ${CPACK_COMPONENTS_ALL})
set(PATH debian/${COMPONENT})
file(APPEND ${DEBIAN_RULES}
" cd $(BUILDDIR); cmake -DCOMPONENT=${COMPONENT} -DCMAKE_INSTALL_PREFIX=../${PATH}/usr -P cmake_install.cmake\n"
" mkdir -p ${PATH}/DEBIAN\n"
" dpkg-gensymbols -p${CPACK_DEBIAN_PACKAGE_NAME}-${COMPONENT} -P${PATH}\n"
)
endforeach(COMPONENT ${CPACK_COMPONENTS_ALL})
file(APPEND ${DEBIAN_RULES}
" dh_shlibdeps\n"
" dh_strip\n" # for reducing size
" dpkg-gencontrol -p${CPACK_DEBIAN_PACKAGE_NAME}\n"
" dpkg --build debian/tmp ..\n"
)
foreach(COMPONENT ${CPACK_COMPONENTS_ALL})
set(PATH debian/${COMPONENT})
file(APPEND ${DEBIAN_RULES}
" dpkg-gencontrol -p${CPACK_DEBIAN_PACKAGE_NAME}-${COMPONENT} -P${PATH} -Tdebian/${COMPONENT}.substvars\n"
" dpkg --build ${PATH} ..\n"
)
endforeach(COMPONENT ${CPACK_COMPONENTS_ALL})
file(APPEND ${DEBIAN_RULES}
"\n"
"clean:\n"
" rm -f build\n"
" rm -rf $(BUILDDIR)\n"
"\n"
".PHONY: binary binary-arch binary-indep clean\n"
)
execute_process(COMMAND chmod +x ${DEBIAN_RULES})
##############################################################################
# debian/compat
file(WRITE ${DEBIAN_SOURCE_DIR}/debian/compat "7")
##############################################################################
# debian/source/format
file(WRITE ${DEBIAN_SOURCE_DIR}/debian/source/format "3.0 (quilt)")
##############################################################################
# debian/changelog
set(DEBIAN_CHANGELOG ${DEBIAN_SOURCE_DIR}/debian/changelog)
execute_process(COMMAND date -R OUTPUT_VARIABLE DATE_TIME)
file(WRITE ${DEBIAN_CHANGELOG}
"${CPACK_DEBIAN_PACKAGE_NAME} (${RELEASE_PACKAGE_VERSION}) ${RELEASE}; urgency=medium\n\n"
" * Package built with CMake\n\n"
"${CPACK_DEBIAN_CHANGELOG}"
" -- ${CPACK_PACKAGE_CONTACT} ${DATE_TIME}"
)
##############################################################################
# debuild -S
if( DEB_SOURCE_CHANGES )
set(DEBUILD_OPTIONS "-sd")
else()
set(DEBUILD_OPTIONS "-sa")
endif()
set(SOURCE_CHANGES_FILE "${CPACK_DEBIAN_PACKAGE_NAME}_${RELEASE_PACKAGE_VERSION}_source.changes")
set(DEB_SOURCE_CHANGES ${DEB_SOURCE_CHANGES} "${SOURCE_CHANGES_FILE}")
add_custom_command(OUTPUT "${SOURCE_CHANGES_FILE}" COMMAND ${DEBUILD_EXECUTABLE} -S ${DEBUILD_OPTIONS} WORKING_DIRECTORY ${DEBIAN_SOURCE_DIR})
endforeach(RELEASE ${CPACK_DEBIAN_DISTRIBUTION_RELEASES})
##############################################################################
# dput ppa:your-lp-id/ppa <source.changes>
add_custom_target(dput ${DPUT_EXECUTABLE} ${DPUT_HOST} ${DEB_SOURCE_CHANGES} DEPENDS ${DEB_SOURCE_CHANGES} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/Debian)

View File

@ -1,9 +0,0 @@
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
# Add toolchain patch number for incremental deb builds
set(PROJECT_VERSION "${PROJECT_VERSION}-2")
include (PackageConfig)
include (DebConfig)

View File

@ -1,31 +0,0 @@
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
# - Find dyncall
# Find the native libcsptr headers and libraries.
#
# DYNCALL_INCLUDE_DIRS - where to find smart_ptr.h, etc.
# DYNCALL_LIBRARIES - List of libraries when using libcsptr.
# DYNCALL_FOUND - True if libcsptr has been found.
# Look for the header file.
FIND_PATH(DYNCALL_INCLUDE_DIR dyncall.h)
# Look for the library.
FIND_LIBRARY(DYNCALL_LIBRARY NAMES dyncall_s)
# Handle the QUIETLY and REQUIRED arguments and set DYNCALL_FOUND to TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DYNCALL DEFAULT_MSG DYNCALL_LIBRARY DYNCALL_INCLUDE_DIR)
# Copy the results to the output variables.
IF(DYNCALL_FOUND)
SET(DYNCALL_LIBRARIES ${DYNCALL_LIBRARY})
SET(DYNCALL_INCLUDE_DIRS ${DYNCALL_INCLUDE_DIR})
ELSE(DYNCALL_FOUND)
SET(DYNCALL_LIBRARIES)
SET(DYNCALL_INCLUDE_DIRS)
ENDIF(DYNCALL_FOUND)
MARK_AS_ADVANCED(DYNCALL_INCLUDE_DIRS DYNCALL_LIBRARIES)

View File

@ -1,31 +0,0 @@
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
# - Find libcsptr
# Find the native libcsptr headers and libraries.
#
# CSPTR_INCLUDE_DIRS - where to find smart_ptr.h, etc.
# CSPTR_LIBRARIES - List of libraries when using libcsptr.
# CSPTR_FOUND - True if libcsptr has been found.
# Look for the header file.
FIND_PATH(CSPTR_INCLUDE_DIR csptr/smart_ptr.h PATH_SUFFIXES csptr)
# Look for the library.
FIND_LIBRARY(CSPTR_LIBRARY NAMES csptr)
# Handle the QUIETLY and REQUIRED arguments and set CSPTR_FOUND to TRUE if all listed variables are TRUE.
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CSPTR DEFAULT_MSG CSPTR_LIBRARY CSPTR_INCLUDE_DIR)
# Copy the results to the output variables.
IF(CSPTR_FOUND)
SET(CSPTR_LIBRARIES ${CSPTR_LIBRARY})
SET(CSPTR_INCLUDE_DIRS ${CSPTR_INCLUDE_DIR})
ELSE(CSPTR_FOUND)
SET(CSPTR_LIBRARIES)
SET(CSPTR_INCLUDE_DIRS)
ENDIF(CSPTR_FOUND)
MARK_AS_ADVANCED(CSPTR_INCLUDE_DIRS CSPTR_LIBRARIES)

View File

@ -1,62 +0,0 @@
# Try to find Libintl functionality
# Once done this will define
#
# LIBINTL_FOUND - system has Libintl
# LIBINTL_INCLUDE_DIR - Libintl include directory
# LIBINTL_LIBRARIES - Libraries needed to use Libintl
#
# TODO: This will enable translations only if Gettext functionality is
# present in libc. Must have more robust system for release, where Gettext
# functionality can also reside in standalone Gettext library, or the one
# embedded within kdelibs (cf. gettext.m4 from Gettext source).
# Copyright (c) 2006, Chusslove Illich, <caslav.ilic@gmx.net>
# Copyright (c) 2007, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
SET(LIBINTL_SEARCH_PATHS
/usr/local/opt/
/usr/local/
/usr/
)
if(LIBINTL_INCLUDE_DIR AND LIBINTL_LIB_FOUND)
set(Libintl_FIND_QUIETLY TRUE)
endif(LIBINTL_INCLUDE_DIR AND LIBINTL_LIB_FOUND)
find_path(LIBINTL_INCLUDE_DIR libintl.h
HINTS
PATH_SUFFIXES gettext/include
PATHS ${LIBINTL_SEARCH_PATHS}
)
set(LIBINTL_LIB_FOUND FALSE)
if(LIBINTL_INCLUDE_DIR)
include(CheckSymbolExists)
check_symbol_exists(dgettext libintl.h LIBINTL_LIBC_HAS_DGETTEXT)
if (LIBINTL_LIBC_HAS_DGETTEXT)
set(LIBINTL_LIBRARIES)
set(LIBINTL_LIB_FOUND TRUE)
else (LIBINTL_LIBC_HAS_DGETTEXT)
find_library(LIBINTL_LIBRARIES
NAMES intl
HINTS
PATH_SUFFIXES gettext/lib
PATHS ${LIBINTL_SEARCH_PATHS}
)
if(LIBINTL_LIBRARIES)
set(LIBINTL_LIB_FOUND TRUE)
endif(LIBINTL_LIBRARIES)
endif (LIBINTL_LIBC_HAS_DGETTEXT)
endif(LIBINTL_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libintl DEFAULT_MSG LIBINTL_INCLUDE_DIR LIBINTL_LIB_FOUND)
mark_as_advanced(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARIES LIBINTL_LIBC_HAS_DGETTEXT LIBINTL_LIB_FOUND)

View File

@ -1,26 +0,0 @@
if (NOT DEFINED ENV{GCOV})
find_program(GCOV_EXECUTABLE gcov)
else()
find_program(GCOV_EXECUTABLE $ENV{GCOV})
endif()
#file(GLOB_RECURSE GCNO_FILES "${CMAKE_CURRENT_BINARY_DIR}/*.gcno")
if (WIN32)
file(GLOB_RECURSE GCDA_FILES "${COV_PATH}\\*.gcda")
else ()
file(GLOB_RECURSE GCDA_FILES "${COV_PATH}/*.gcda")
endif ()
#execute_process(
# COMMAND ${GCOV_EXECUTABLE} -lcp ${GCNO_FILES}
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
#)
foreach (GCDA ${GCDA_FILES})
get_filename_component(DIR ${GCDA} PATH)
execute_process(
COMMAND ${GCOV_EXECUTABLE} -lcp -o ${DIR} ${GCDA}
WORKING_DIRECTORY ${COV_PATH}
)
endforeach ()

View File

@ -1,313 +0,0 @@
# Copyright (c) 2012, Jarryd Beck
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# This module creates build rules for updating translation files made
# with gettext
# In your top level CMakeLists.txt, do
# include(GettextTranslate)
# then in any po directory where you want things to be translated, write
# GettextTranslate()
#
# This module also finds the gettext binaries. If these are in a non-standard
# location, you can define the following variables to provide paths to search
# in
# GettextTranslate_BINARIES --- a path in which to look for every program
# GettextTranslate_XGETTEXT --- the xgettext program
# GettextTranslate_MSGINIT --- the msginit program
# GettextTranslate_MSGFILTER --- the msgfilter program
# GettextTranslate_MSGCONV --- the msgconv program
# GettextTranslate_MSGMERGE --- the msgmerge program
# GettextTranslate_MSGFMT --- the msgfmt program
# these are searched first before $PATH, so set this if you have your own
# version that overrides the system version
#
# it reads variables from Makevars, one of the most important being DOMAIN
# it reads the languages to generate from LINGUAS
#
# it adds the following targets
# update-po
# update-gmo
# ${DOMAIN}-pot.update
# generate-${DOMAIN}-${lang}-po
# generate-${DOMAIN}-${lang}-gmo
#
# where ${DOMAIN} is the DOMAIN variable read from Makevars
# and ${lang} is each language mentioned in LINGUAS
#
# if you want update-gmo to be added to the "all" target, then define the
# variable GettextTranslate_ALL before including this file
#
# by default, the gmo files are built in the source directory. If you want
# them to be built in the binary directory, then define the variable
# GettextTranslate_GMO_BINARY
# add the update-po and update-gmo targets, the actual files that need to
# depend on this will be added as we go
if (DEFINED GettextTranslate_ALL)
set(_addToALL "ALL")
endif()
add_custom_target(update-po)
add_custom_target(update-gmo ${_addToALL})
#look for all the programs
#xgettext, msginit, msgfilter, msgconv, msgmerge, msgfmt
function(REQUIRE_BINARY binname varname)
if (defined ${${varname}-NOTFOUND})
message(FATAL_ERROR "Could not find " binname)
endif()
endfunction()
find_program(GettextTranslate_XGETTEXT_EXECUTABLE xgettext
HINTS ${GettextTranslate_XGETTEXT} ${GettextTranslate_BINARIES}
)
REQUIRE_BINARY(xgettext GettextTranslate_XGETTEXT_EXECUTABLE)
find_program(GettextTranslate_MSGINIT_EXECUTABLE msginit
HINTS ${GettextTranslate_MSGINIT} ${GettextTranslate_BINARIES}
)
REQUIRE_BINARY(msginit GettextTranslate_MSGINIT_EXECUTABLE)
find_program(GettextTranslate_MSGFILTER_EXECUTABLE msgfilter
HINTS ${GettextTranslate_MSGFILTER} ${GettextTranslate_BINARIES}
)
REQUIRE_BINARY(msgfilter GettextTranslate_MSGFILTER_EXECUTABLE)
find_program(GettextTranslate_MSGCONV_EXECUTABLE msgconv
HINTS ${GettextTranslate_MSGCONV} ${GettextTranslate_BINARIES}
)
REQUIRE_BINARY(msgconv GettextTranslate_MSGCONV_EXECUTABLE)
find_program(GettextTranslate_MSGMERGE_EXECUTABLE msgmerge
HINTS ${GettextTranslate_MSGMERGE} ${GettextTranslate_BINARIES}
)
REQUIRE_BINARY(msgmerge GettextTranslate_MSGMERGE_EXECUTABLE)
find_program(GettextTranslate_MSGFMT_EXECUTABLE msgfmt
HINTS ${GettextTranslate_MSGFMT} ${GettextTranslate_BINARIES}
)
REQUIRE_BINARY(msgfmt GettextTranslate_MSGFMT_EXECUTABLE)
mark_as_advanced(
GettextTranslate_MSGCONV_EXECUTABLE
GettextTranslate_MSGFILTER_EXECUTABLE
GettextTranslate_MSGFMT_EXECUTABLE
GettextTranslate_MSGINIT_EXECUTABLE
GettextTranslate_MSGMERGE_EXECUTABLE
GettextTranslate_XGETTEXT_EXECUTABLE
)
macro(GettextTranslate)
if(GettextTranslate_GMO_BINARY)
set (GMO_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
else()
set (GMO_BUILD_DIR ${CMAKE_CURRENT_SOURCE_DIR})
endif()
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/POTFILES.in)
message(FATAL_ERROR "There is no POTFILES.in in
${CMAKE_CURRENT_SOURCE_DIR}")
endif()
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/Makevars)
message(FATAL_ERROR "There is no Makevars in ${CMAKE_CURRENT_SOURCE_DIR}")
endif()
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/Makevars makevars
REGEX "^[^=]+=(.*)$"
)
foreach(makevar ${makevars})
string(REGEX REPLACE "^([^= ]+) =[ ]?(.*)$" "\\1" MAKEVAR_KEY ${makevar})
string(REGEX REPLACE "^([^= ]+) =[ ]?(.*)$" "\\2"
MAKEVAR_${MAKEVAR_KEY} ${makevar})
endforeach()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/POTFILES.in
${CMAKE_CURRENT_BINARY_DIR}/POTFILES
COPYONLY
)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/LINGUAS
${CMAKE_CURRENT_BINARY_DIR}/LINGUAS
COPYONLY
)
#set the directory to not clean
#set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
# PROPERTY CLEAN_NO_CUSTOM true)
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/POTFILES.in potfiles
REGEX "^[^#].*"
)
foreach(potfile ${potfiles})
list(APPEND source_translatable
${CMAKE_CURRENT_SOURCE_DIR}/${MAKEVAR_top_builddir}/${potfile})
endforeach()
set(TEMPLATE_FILE ${MAKEVAR_DOMAIN}.pot)
set(TEMPLATE_FILE_ABS ${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_FILE})
string(REGEX MATCHALL "[^ ]+" XGETTEXT_OPTS ${MAKEVAR_XGETTEXT_OPTIONS})
#add_custom_target(${MAKEVAR_DOMAIN}.pot-update DEPENDS
# ${TEMPLATE_FILE_ABS}
#)
add_custom_target(${MAKEVAR_DOMAIN}.pot-update
COMMAND ${GettextTranslate_XGETTEXT_EXECUTABLE} ${XGETTEXT_OPTS}
-o ${TEMPLATE_FILE_ABS}
--default-domain=${MAKEVAR_DOMAIN}
--add-comments=TRANSLATORS:
--copyright-holder=${MAKEVAR_COPYRIGHT_HOLDER}
--msgid-bugs-address="${MAKEVAR_MSGID_BUGS_ADDRESS}"
--directory=${MAKEVAR_top_builddir}
--files-from=${CMAKE_CURRENT_BINARY_DIR}/POTFILES
--package-version=${VERSION}
--package-name=${CMAKE_PROJECT_NAME}
DEPENDS ${source_translatable}
${CMAKE_CURRENT_SOURCE_DIR}/POTFILES.in
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
#add_custom_command(OUTPUT ${TEMPLATE_FILE_ABS}
# COMMAND ${GettextTranslate_XGETTEXT_EXECUTABLE} ${XGETTEXT_OPTS}
# -o ${TEMPLATE_FILE_ABS}
# --default-domain=${MAKEVAR_DOMAIN}
# --add-comments=TRANSLATORS:
# --copyright-holder=${MAKEVAR_COPYRIGHT_HOLDER}
# --msgid-bugs-address="${MAKEVAR_MSGID_BUGS_ADDRESS}"
# --directory=${MAKEVAR_top_builddir}
# --files-from=${CMAKE_CURRENT_BINARY_DIR}/POTFILES
# --package-version=${VERSION}
# --package-name=${CMAKE_PROJECT_NAME}
# DEPENDS ${source_translatable}
# ${CMAKE_CURRENT_SOURCE_DIR}/POTFILES.in
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
#)
#add_dependencies(update-po ${MAKEVAR_DOMAIN}.pot-update)
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/LINGUAS LINGUAS
REGEX "^[^#].*")
string(REGEX MATCHALL "[^ ]+" languages ${LINGUAS})
foreach(lang ${languages})
set(PO_FILE_NAME "${CMAKE_CURRENT_SOURCE_DIR}/${lang}.po")
set(GMO_FILE_NAME "${GMO_BUILD_DIR}/${lang}.gmo")
set(PO_TARGET "generate-${MAKEVAR_DOMAIN}-${lang}-po")
set(GMO_TARGET "generate-${MAKEVAR_DOMAIN}-${lang}-gmo")
list(APPEND po_files ${PO_TARGET})
list(APPEND gmo_files ${GMO_TARGET})
if(${lang} MATCHES "en@(.*)quot")
add_custom_command(OUTPUT ${lang}.insert-header
COMMAND
sed -e "'/^#/d'" -e 's/HEADER/${lang}.header/g'
${CMAKE_CURRENT_SOURCE_DIR}/insert-header.sin > ${lang}.insert-header
)
#generate the en@quot files
add_custom_target(${PO_TARGET}
COMMAND
${GettextTranslate_MSGINIT_EXECUTABLE} -i ${TEMPLATE_FILE_ABS}
--no-translator -l ${lang}
-o - 2>/dev/null
| sed -f ${CMAKE_CURRENT_BINARY_DIR}/${lang}.insert-header
| ${GettextTranslate_MSGCONV_EXECUTABLE} -t UTF-8
| ${GettextTranslate_MSGFILTER_EXECUTABLE} sed -f
${CMAKE_CURRENT_SOURCE_DIR}/`echo ${lang}
| sed -e 's/.*@//'`.sed 2>/dev/null >
${PO_FILE_NAME}
DEPENDS ${lang}.insert-header ${TEMPLATE_FILE_ABS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
else()
execute_process(
COMMAND ${GettextTranslate_MSGMERGE_EXECUTABLE} --version
OUTPUT_VARIABLE MSGMERGE_VERSION_MSG
)
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" MSGMERGE_VERSION "${MSGMERGE_VERSION_MSG}")
if ("${MSGMERGE_VERSION}" VERSION_GREATER "0.17")
add_custom_target(${PO_TARGET}
COMMAND ${GettextTranslate_MSGMERGE_EXECUTABLE} --lang=${lang}
${PO_FILE_NAME} ${TEMPLATE_FILE_ABS}
-o ${PO_FILE_NAME}.new
COMMAND if diff ${PO_FILE_NAME} ${PO_FILE_NAME}.new
--unchanged-line-format='' --old-line-format=''
| grep -v 'POT-Creation-Date' >/dev/null\; then
mv ${PO_FILE_NAME}.new ${PO_FILE_NAME}\;
else
rm ${PO_FILE_NAME}.new\;
fi
DEPENDS ${TEMPLATE_FILE_ABS}
)
else ()
add_custom_target(${PO_TARGET}
COMMAND ${GettextTranslate_MSGMERGE_EXECUTABLE}
${PO_FILE_NAME} ${TEMPLATE_FILE_ABS}
-o ${PO_FILE_NAME}.new
COMMAND if diff ${PO_FILE_NAME} ${PO_FILE_NAME}.new
--unchanged-line-format='' --old-line-format=''
| grep -v 'POT-Creation-Date' >/dev/null\; then
mv ${PO_FILE_NAME}.new ${PO_FILE_NAME}\;
else
rm ${PO_FILE_NAME}.new\;
fi
DEPENDS ${TEMPLATE_FILE_ABS}
)
endif ()
endif()
add_custom_target(${GMO_TARGET}
COMMAND ${GettextTranslate_MSGFMT_EXECUTABLE} -c --statistics --verbose
-o ${GMO_FILE_NAME} ${PO_FILE_NAME}
DEPENDS ${PO_TARGET}
)
add_dependencies(${PO_TARGET} ${MAKEVAR_DOMAIN}.pot-update)
install(FILES ${GMO_FILE_NAME} DESTINATION
${LOCALEDIR_REL}/${lang}/LC_MESSAGES
RENAME ${MAKEVAR_DOMAIN}.mo
)
endforeach()
add_dependencies(update-po ${po_files})
add_dependencies(update-gmo ${gmo_files})
#string(REGEX MATCH "^[^=]+=(.*)$" parsed_variables ${makevars})
endmacro()

View File

@ -1,13 +0,0 @@
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
option(LANG_CXX "Turn on C++ support" ON)
option(THEORIES "Activate the support for theories" ON)
option(MINGW_DEFINE_OFF_T "Define off_t and off64_t ourselves before including io.h" OFF)
option(COVERALLS "Turn on coveralls support" OFF)
option(COVERALLS_UPLOAD "Upload the generated coveralls json" ON)
option(DEV_BUILD "Compile in developer mode" OFF)
option(CTESTS "Turn on the samples and test" ${DEV_BUILD})
option(I18N "Turn on internationalization" ON)
option(UPLOAD_DEB "Upload package to launchpad" OFF)

View File

@ -1,79 +0,0 @@
function(extract_version version major minor patch extra)
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)?" version_valid ${version})
if(version_valid)
string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)?" "\\1;\\2;\\3;\\4" VERSION_MATCHES ${version})
list(GET VERSION_MATCHES 0 version_major)
set(${major} ${version_major} PARENT_SCOPE)
list(GET VERSION_MATCHES 1 version_minor)
set(${minor} ${version_minor} PARENT_SCOPE)
list(GET VERSION_MATCHES 2 version_patch)
set(${patch} ${version_patch} PARENT_SCOPE)
list(GET VERSION_MATCHES 3 version_extra)
set(${extra} ${version_extra} PARENT_SCOPE)
else(version_valid)
message(AUTHOR_WARNING "Bad version ${version}; falling back to 0 (have you made an initial release?)")
set(${major} "0" PARENT_SCOPE)
set(${minor} "" PARENT_SCOPE)
set(${patch} "" PARENT_SCOPE)
set(${extra} "" PARENT_SCOPE)
endif(version_valid)
endfunction(extract_version)
if (WIN32)
set(CPACK_GENERATOR "ZIP")
set(CPACK_SOURCE_GENERATOR "ZIP")
else ()
set(CPACK_GENERATOR "TGZ")
set(CPACK_SOURCE_GENERATOR "TGZ")
endif ()
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A KISS, modern unit testing framework for C and C++.")
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-binary-${PROJECT_VERSION}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}")
set(CPACK_PACKAGE_VENDOR "Franklin \"Snaipe\" Mathieu")
set(CPACK_PACKAGE_CONTACT "Franklin \"Snaipe\" Mathieu <franklinmathieu@gmail.com>")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
if (WIN32)
# add snapshot specific versioning information
if (CPACK_DEBIAN_PACKAGE_TYPE STREQUAL "snapshot")
execute_process(COMMAND date +%Y%m%d%0k%0M%0S%z OUTPUT_VARIABLE SNAPSHOT_DATE_TIME)
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}-snapshot-${SNAPSHOT_DATE_TIME}")
STRING(REPLACE "\n" "" CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
endif ()
endif ()
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/debian.copyright")
extract_version(${PROJECT_VERSION}
CPACK_PACKAGE_VERSION_MAJOR
CPACK_PACKAGE_VERSION_MINOR
CPACK_PACKAGE_VERSION_PATCH
VERSION_EXTRA
)
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
file(GLOB TRASH_FILES "${PROJECT_SOURCE_DIR}/*")
set(KEEP_FILES
"${PROJECT_SOURCE_DIR}/.cmake"
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_SOURCE_DIR}/include"
"${PROJECT_SOURCE_DIR}/doc"
"${PROJECT_SOURCE_DIR}/dev"
"${PROJECT_SOURCE_DIR}/po"
"${PROJECT_SOURCE_DIR}/dependencies"
"${PROJECT_SOURCE_DIR}/CMakeLists.txt"
"${PROJECT_SOURCE_DIR}/README.md"
"${PROJECT_SOURCE_DIR}/CONTRIBUTING.md"
"${PROJECT_SOURCE_DIR}/LICENSE"
"${PROJECT_SOURCE_DIR}/ChangeLog"
"${PROJECT_SOURCE_DIR}/description.txt"
)
list(REMOVE_ITEM TRASH_FILES ${KEEP_FILES})
# Escape any '.' characters
string(REPLACE "." "\\\\." TRASH_FILES "${TRASH_FILES}")
set(CPACK_SOURCE_IGNORE_FILES "${TRASH_FILES}")
include(CPack)

View File

@ -1,97 +0,0 @@
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
include(CMakeParseArguments)
function (cr_link_package _TARGET _PKG)
if (${_PKG}_LIB_FOUND OR ${_PKG}_FOUND)
target_link_libraries(${_TARGET} ${${_PKG}_LIBRARIES})
include_directories(${${_PKG}_INCLUDE_DIRS})
endif ()
endfunction ()
function (cr_link_libraries _TARGET)
set (multiValueArgs IF)
cmake_parse_arguments (ARGS "" "" "${multiValueArgs}" ${ARGN})
if (ARGS_IF)
if (${ARGS_IF})
else ()
return ()
endif ()
endif ()
target_link_libraries(${_TARGET} ${ARGS_UNPARSED_ARGUMENTS})
endfunction ()
function (cr_add_library _LIB)
set (options SHARED STATIC)
set (oneValueArgs COMPONENT)
set (multiValueArgs SOURCES HEADERS PROPERTIES)
cmake_parse_arguments (ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set (flags "")
if (ARGS_SHARED)
set (flags ${flags} SHARED)
elseif (ARGS_STATIC)
set (flags ${flags} STATIC)
endif ()
add_library(${_LIB} ${flags} ${ARGS_SOURCES} ${ARGS_HEADERS})
set_target_properties(${_LIB} PROPERTIES ${ARGS_PROPERTIES})
foreach (F ${INTERFACE_FILES})
get_filename_component(DEST "${F}" PATH)
if (ARGS_COMPONENT)
set (install_flags COMPONENT ${ARGS_COMPONENT})
endif ()
install(FILES "${F}" DESTINATION "${DEST}" ${install_flags})
endforeach ()
install(TARGETS ${_LIB}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib ${install_flags}
)
endfunction ()
find_package(PkgConfig)
macro (cr_find_package _PKG)
set (options REQUIRED)
set (oneValueArgs PKGCONFIG)
cmake_parse_arguments (ARGS "${options}" "${oneValueArgs}" "" ${ARGN})
string (TOUPPER "${_PKG}" _PKG_UP)
find_package (${_PKG})
if (NOT ${_PKG_UP}_FOUND AND ${_PKG_UP}_LIB_FOUND)
set (${_PKG_UP}_FOUND ON)
endif ()
if (NOT ${_PKG_UP}_FOUND AND PKGCONFIG_FOUND)
message (STATUS "Checking for package ${_PKG} with pkg-config")
if (NOT ARGS_PKGCONFIG)
set (ARGS_PKGCONFIG ${_PKG})
endif ()
pkg_check_modules(${_PKG_UP}_PKG ${ARGS_PKGCONFIG})
if (${_PKG_UP}_PKG_FOUND)
if (${_PKG_UP}_PKG_LIBRARY_DIRS)
link_directories(${${_PKG_UP}_PKG_LIBRARY_DIRS})
endif ()
set (${_PKG_UP}_LIBRARIES ${${_PKG_UP}_PKG_LIBRARIES})
set (${_PKG_UP}_INCLUDE_DIRS ${${_PKG_UP}_PKG_INCLUDE_DIRS})
set (${_PKG_UP}_FOUND 1)
endif()
endif ()
if (NOT ${_PKG_UP}_FOUND AND ARGS_REQUIRED)
message (FATAL_ERROR "Could not find required package ${_PKG}")
endif ()
if (${_PKG_UP}_FOUND)
set (HAVE_${_PKG_UP} 1)
endif ()
endmacro ()

View File

@ -1,41 +0,0 @@
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
set (PROJECT_VERSION "2.3.0-rc1")
set (PROJECT_SOVERSION 3)
set (PROJECT_SONAME 3.1.0)
set (LOCALEDIR_REL "share/locale")
set (LOCALEDIR "${CMAKE_INSTALL_PREFIX}/${LOCALEDIR_REL}")
string (TOLOWER "${PROJECT_NAME}" PROJECT_NAME_LOWER)
add_definitions(
-DCRITERION_BUILDING_DLL=1
-DPB_ENABLE_MALLOC=1
)
set (CMAKE_C_FLAGS_DEFAULT "${CMAKE_C_FLAGS}")
set (CMAKE_CXX_FLAGS_DEFAULT "${CMAKE_CXX_FLAGS}")
if (MSVC)
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
add_definitions (-D_CRT_SECURE_NO_WARNINGS=1)
add_definitions (-DVC_EXTRALEAN)
add_definitions (-DWIN32_LEAN_AND_MEAN)
add_definitions (-D_WIN32_WINNT=0x600)
else ()
if (WIN32)
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-no-undefined")
endif ()
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=gnu99 -fvisibility=hidden")
if (CMAKE_CXX_COMPILER_WORKS)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra ${CXX11_FLAG} -fvisibility=hidden")
endif ()
endif ()
include_directories(SYSTEM
/usr/local/include
/usr/include/GNUstep
)

View File

@ -1,29 +0,0 @@
if(EXISTS "${PROJECT_SOURCE_DIR}/.gitmodules")
message(STATUS "Updating submodules to their latest/fixed versions")
message(STATUS "(this can take a while, please be patient)")
### set the direcory where the submodules live
set(GIT_SUBMODULES_DIRECTORY dependencies)
### set the directory names of the submodules
set(GIT_SUBMODULES libcsptr dyncall)
### set each submodules's commit or tag that is to be checked out
### (leave empty if you want master)
### First, get all submodules in
if(${GIT_SUBMODULES_CHECKOUT_QUIET})
execute_process(
COMMAND git submodule update --init --recursive
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_QUIET
ERROR_QUIET
)
else()
execute_process(
COMMAND git submodule update --init --recursive
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
endif()
endif()

View File

@ -1,123 +0,0 @@
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
include(ExternalProject)
include(CMakeParseArguments)
function (cr_add_subproject _NAME)
set (options CMAKE AUTOTOOLS)
set (oneValueArgs GIT PATH PREFIX GENERATOR)
set (multiValueArgs OPTS IF)
cmake_parse_arguments (ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (ARGS_IF)
if (${ARGS_IF})
set (${_NAME}_SUBPROJECT_EXISTS 1 PARENT_SCOPE)
else ()
return ()
endif ()
else ()
set (${_NAME}_SUBPROJECT_EXISTS 1 PARENT_SCOPE)
endif ()
if (ARGS_PREFIX)
set (install_prefix ${CMAKE_BINARY_DIR}/external/${ARGS_PREFIX})
else ()
set (install_prefix ${CMAKE_BINARY_DIR}/external)
endif ()
if (ARGS_GIT)
string(REPLACE "#" ";" git_opts "${ARGS_GIT}")
list(LENGTH git_opts git_opts_len)
list(GET git_opts 0 repo)
set (epa_opts GIT_REPOSITORY "${repo}")
if (git_opts_len GREATER 1)
list(GET git_opts 1 object)
set (epa_opts ${epa_opts} GIT_TAG "${object}")
endif ()
elseif (ARGS_PATH)
set (epa_opts SOURCE_DIR "${CMAKE_SOURCE_DIR}/${ARGS_PATH}")
endif ()
if (ARGS_CMAKE)
if (NOT ARGS_GENERATOR)
set (ARGS_GENERATOR ${CMAKE_GENERATOR})
endif ()
if (CMAKE_TOOLCHAIN_FILE)
set (ARGS_OPTS ${ARGS_OPTS}
"-DCMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}"
"-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
endif ()
set (build_cmds
CONFIGURE_COMMAND ${CMAKE_COMMAND} <SOURCE_DIR>
-DCMAKE_INSTALL_PREFIX=${install_prefix}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-G "${ARGS_GENERATOR}"
${ARGS_OPTS}
BUILD_COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}/${_NAME}"
INSTALL_COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}/${_NAME}" --target install
)
elseif (ARGS_AUTOTOOLS)
set (make_opts "")
if (ARGS_PARALLELIZED)
set (make_opts "${make_opts} -j4")
endif ()
set (build_cmds
UPDATE_COMMAND <SOURCE_DIR>/autogen.sh
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=${install_prefix} ${ARGS_OPTS}
BUILD_COMMAND make ${make_opts}
INSTALL_COMMAND make install
)
endif ()
externalproject_add(
${_NAME}
${epa_opts}
PREFIX "${CMAKE_BINARY_DIR}/${_NAME}-build"
BINARY_DIR "${CMAKE_BINARY_DIR}/${_NAME}"
${build_cmds}
)
if (WIN32)
set ("${_NAME}_SHARED_LIB" "${install_prefix}/lib/${_NAME}.dll" PARENT_SCOPE)
if (ARGS_GENERATOR MATCHES "(Unix|MSYS|MinGW) Makefiles")
set ("${_NAME}_STATIC_LIB" "${install_prefix}/lib/lib${_NAME}.a" PARENT_SCOPE)
else ()
set ("${_NAME}_STATIC_LIB" "${install_prefix}/lib/${_NAME}.lib" PARENT_SCOPE)
endif ()
elseif (APPLE)
set ("${_NAME}_SHARED_LIB" "${install_prefix}/lib/lib${_NAME}.dylib" PARENT_SCOPE)
set ("${_NAME}_STATIC_LIB" "${install_prefix}/lib/lib${_NAME}.a" PARENT_SCOPE)
elseif (UNIX)
set ("${_NAME}_SHARED_LIB" "${install_prefix}/lib/lib${_NAME}.so" PARENT_SCOPE)
set ("${_NAME}_STATIC_LIB" "${install_prefix}/lib/lib${_NAME}.a" PARENT_SCOPE)
else ()
message (FATAL_ERROR "Could not set proper library path for the current platform")
endif ()
endfunction ()
function (cr_link_subproject _TARGET _SUBPROJECT)
if (NOT ${_SUBPROJECT}_SUBPROJECT_EXISTS)
return ()
endif ()
set (options STATIC SHARED)
cmake_parse_arguments (ARGS "${options}" "" "" ${ARGN})
add_dependencies("${_TARGET}" "${_SUBPROJECT}")
if (ARGS_SHARED)
target_link_libraries("${_TARGET}" "${${_SUBPROJECT}_SHARED_LIB}")
endif ()
if (ARGS_STATIC)
target_link_libraries("${_TARGET}" "${${_SUBPROJECT}_STATIC_LIB}")
endif ()
endfunction ()
include_directories(${CMAKE_BINARY_DIR}/external/include)
link_directories(${CMAKE_BINARY_DIR}/external/lib)

View File

@ -1,19 +0,0 @@
set(MANIFEST "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt")
if(NOT EXISTS ${MANIFEST})
message(FATAL_ERROR "Cannot find install manifest: '${MANIFEST}'")
endif()
file(STRINGS ${MANIFEST} files)
foreach(file ${files})
message(STATUS "Removing file: '${file}'")
exec_program(
${CMAKE_COMMAND} ARGS "-E remove ${file}"
OUTPUT_VARIABLE stdout
RETURN_VALUE result
)
if (NOT "${result}" STREQUAL 0)
message(FATAL_ERROR "Failed to remove file: '${file}'.")
endif ()
endforeach ()

View File

@ -1,11 +0,0 @@
#!/bin/sh
CURDIR=$(dirname $0)
SOURCE_DIR=$1; shift
DEST_DIR=$1; shift
(
cd "$SOURCE_DIR"
mkdir -p "$DEST_DIR"
"$CURDIR/git-archive-all.sh" --format tar -- - | tar -x -C "$DEST_DIR"
)

View File

@ -1,18 +0,0 @@
--- _test.py.orig 2016-09-03 00:50:27.505527300 +0200
+++ "/c/Program Files/Python35/lib/site-packages/cram/_test.py" 2016-09-03 00:48:48.708932100 +0200
@@ -143,11 +143,15 @@
after.setdefault(pos, []).append(line)
stdin.append(b('echo %s %s $?\n' % (usalt, i + 1)))
+ env = {k: v.decode('utf-8') if isinstance(v, bytes) else v for k, v in env.items()}
+
output, retcode = execute(shell + ['-'], stdin=b('').join(stdin),
stdout=PIPE, stderr=STDOUT, env=env)
if retcode == 80:
return (refout, None, [])
+ output = output.replace(b'\r\n', b'\n').replace(b'\r', b'\n')
+
pos = -1
ret = 0
for i, line in enumerate(output[:-1].splitlines(True)):

View File

@ -1,39 +0,0 @@
diff --git a/cram.py b/cram.py
index 20c4681..3b9f144 100755
--- a/cram.py
+++ b/cram.py
@@ -168,14 +168,14 @@ def test(path, shell, indent=2):
cmdline = '%s$ ' % indent
conline = '%s> ' % indent
- f = open(path)
+ f = open(path, 'r', encoding='utf-8')
abspath = os.path.abspath(path)
env = os.environ.copy()
env['TESTDIR'] = os.path.dirname(abspath)
env['TESTFILE'] = os.path.basename(abspath)
p = subprocess.Popen([shell, '-'], bufsize=-1, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
- universal_newlines=True, env=env,
+ universal_newlines=False, env=env,
preexec_fn=makeresetsigpipe(),
close_fds=os.name == 'posix')
salt = 'CRAM%s' % time.time()
@@ -199,7 +199,7 @@ def test(path, shell, indent=2):
after.setdefault(pos, []).append(line)
stdin.append('echo "\n%s %s $?"\n' % (salt, i + 1))
- output = p.communicate(input=''.join(stdin))[0]
+ output = p.communicate(input=''.join(stdin).encode('utf-8'))[0].decode('utf-8')
if p.returncode == 80:
return (refout, None, [])
@@ -336,7 +336,7 @@ def run(paths, tmpdir, shell, quiet=False, verbose=False, patchcmd=None,
log('!', 'failed\n', verbose)
if not quiet:
log('\n', None, verbose)
- errfile = open(errpath, 'w')
+ errfile = open(errpath, 'w', encoding='utf-8')
try:
for line in postout:
errfile.write(line)

View File

@ -1,302 +0,0 @@
#!/bin/bash -
#
# File: git-archive-all.sh
#
# Description: A utility script that builds an archive file(s) of all
# git repositories and submodules in the current path.
# Useful for creating a single tarfile of a git super-
# project that contains other submodules.
#
# Examples: Use git-archive-all.sh to create archive distributions
# from git repositories. To use, simply do:
#
# cd $GIT_DIR; git-archive-all.sh
#
# where $GIT_DIR is the root of your git superproject.
#
# License: GPL3+
#
###############################################################################
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
###############################################################################
# DEBUGGING
set -e
set -C # noclobber
# TRAP SIGNALS
trap 'cleanup' QUIT EXIT
# For security reasons, explicitly set the internal field separator
# to newline, space, tab
OLD_IFS=$IFS
IFS='
'
function cleanup () {
rm -f $TMPFILE
rm -f $TOARCHIVE
IFS="$OLD_IFS"
}
function usage () {
echo "Usage is as follows:"
echo
echo "$PROGRAM <--version>"
echo " Prints the program version number on a line by itself and exits."
echo
echo "$PROGRAM <--usage|--help|-?>"
echo " Prints this usage output and exits."
echo
echo "$PROGRAM [--format <fmt>] [--prefix <path>] [--verbose|-v] [--separate|-s]"
echo " [--tree-ish|-t <tree-ish>] [output_file]"
echo " Creates an archive for the entire git superproject, and its submodules"
echo " using the passed parameters, described below."
echo
echo " If '--format' is specified, the archive is created with the named"
echo " git archiver backend. Obviously, this must be a backend that git archive"
echo " understands. The format defaults to 'tar' if not specified."
echo
echo " If '--prefix' is specified, the archive's superproject and all submodules"
echo " are created with the <path> prefix named. The default is to not use one."
echo
echo " If '--separate' or '-s' is specified, individual archives will be created"
echo " for each of the superproject itself and its submodules. The default is to"
echo " concatenate individual archives into one larger archive."
echo
echo " If '--tree-ish' is specified, the archive will be created based on whatever"
echo " you define the tree-ish to be. Branch names, commit hash, etc. are acceptable."
echo " Defaults to HEAD if not specified. See git archive's documentation for more"
echo " information on what a tree-ish is."
echo
echo " If 'output_file' is specified, the resulting archive is created as the"
echo " file named. This parameter is essentially a path that must be writeable."
echo " When combined with '--separate' ('-s') this path must refer to a directory."
echo " Without this parameter or when combined with '--separate' the resulting"
echo " archive(s) are named with a dot-separated path of the archived directory and"
echo " a file extension equal to their format (e.g., 'superdir.submodule1dir.tar')."
echo
echo " The special value '-' (single dash) is treated as STDOUT and, when used, the"
echo " --separate option is ignored. Use a double-dash to separate the outfile from"
echo " the value of previous options. For example, to write a .zip file to STDOUT:"
echo
echo " ./$PROGRAM --format zip -- -"
echo
echo " If '--verbose' or '-v' is specified, progress will be printed."
}
function version () {
echo "$PROGRAM version $VERSION"
}
# Internal variables and initializations.
readonly PROGRAM=`basename "$0"`
readonly VERSION=0.3
SEPARATE=0
VERBOSE=0
TARCMD=`command -v gnutar || command -v tar`
FORMAT=tar
PREFIX=
TREEISH=HEAD
# RETURN VALUES/EXIT STATUS CODES
readonly E_BAD_OPTION=254
readonly E_UNKNOWN=255
# Process command-line arguments.
while test $# -gt 0; do
if [ x"$1" == x"--" ]; then
# detect argument termination
shift
break
fi
case $1 in
--format )
shift
FORMAT="$1"
shift
;;
--prefix )
shift
PREFIX="$1"
shift
;;
--separate | -s )
shift
SEPARATE=1
;;
--tree-ish | -t )
shift
TREEISH="$1"
shift
;;
--version )
version
exit
;;
--verbose | -v )
shift
VERBOSE=1
;;
-? | --usage | --help )
usage
exit
;;
-* )
echo "Unrecognized option: $1" >&2
usage
exit $E_BAD_OPTION
;;
* )
break
;;
esac
done
OLD_PWD="`pwd`"
TMPDIR=${TMPDIR:-/tmp}
TMPFILE=`mktemp "$TMPDIR/$PROGRAM.XXXXXX"` # Create a place to store our work's progress
TOARCHIVE=`mktemp "$TMPDIR/$PROGRAM.toarchive.XXXXXX"`
OUT_FILE=$OLD_PWD # assume "this directory" without a name change by default
if [ ! -z "$1" ]; then
OUT_FILE="$1"
if [ "-" == $OUT_FILE ]; then
SEPARATE=0
fi
shift
fi
# Validate parameters; error early, error often.
if [ "-" == $OUT_FILE -o $SEPARATE -ne 1 ] && [ "$FORMAT" == "tar" -a `$TARCMD --help | grep -q -- "--concatenate"; echo $?` -ne 0 ]; then
echo "Your 'tar' does not support the '--concatenate' option, which we need"
echo "to produce a single tarfile. Either install a compatible tar (such as"
echo "gnutar), or invoke $PROGRAM with the '--separate' option."
exit
elif [ $SEPARATE -eq 1 -a ! -d $OUT_FILE ]; then
echo "When creating multiple archives, your destination must be a directory."
echo "If it's not, you risk being surprised when your files are overwritten."
exit
elif [ `git config -l | grep -q '^core\.bare=false'; echo $?` -ne 0 ]; then
echo "$PROGRAM must be run from a git working copy (i.e., not a bare repository)."
exit
fi
# Create the superproject's git-archive
if [ $VERBOSE -eq 1 ]; then
echo -n "creating superproject archive..."
fi
git archive --format=$FORMAT --prefix="$PREFIX" $TREEISH > $TMPDIR/$(basename "$(pwd)").$FORMAT
if [ $VERBOSE -eq 1 ]; then
echo "done"
fi
echo $TMPDIR/$(basename "$(pwd)").$FORMAT >| $TMPFILE # clobber on purpose
superfile=`head -n 1 $TMPFILE`
if [ $VERBOSE -eq 1 ]; then
echo -n "looking for subprojects..."
fi
# find all '.git' dirs, these show us the remaining to-be-archived dirs
# we only want directories that are below the current directory
find . -mindepth 2 -name '.git' -type d -print | sed -e 's/^\.\///' -e 's/\.git$//' >> $TOARCHIVE
# as of version 1.7.8, git places the submodule .git directories under the superprojects .git dir
# the submodules get a .git file that points to their .git dir. we need to find all of these too
find . -mindepth 2 -name '.git' -type f -print | xargs grep -l "gitdir" | sed -e 's/^\.\///' -e 's/\.git$//' >> $TOARCHIVE
if [ $VERBOSE -eq 1 ]; then
echo "done"
echo " found:"
cat $TOARCHIVE | while read arch
do
echo " $arch"
done
fi
if [ $VERBOSE -eq 1 ]; then
echo -n "archiving submodules..."
fi
while read path; do
TREEISH=$(git submodule | grep "^ .*${path%/} " | cut -d ' ' -f 2) # git submodule does not list trailing slashes in $path
cd "$path"
git archive --format=$FORMAT --prefix="${PREFIX}$path" ${TREEISH:-HEAD} > "$TMPDIR"/"$(echo "$path" | sed -e 's/\//./g')"$FORMAT
if [ $FORMAT == 'zip' ]; then
# delete the empty directory entry; zipped submodules won't unzip if we don't do this
zip -d "$(tail -n 1 $TMPFILE)" "${PREFIX}${path%/}" >/dev/null # remove trailing '/'
fi
echo "$TMPDIR"/"$(echo "$path" | sed -e 's/\//./g')"$FORMAT >> $TMPFILE
cd "$OLD_PWD"
done < $TOARCHIVE
if [ $VERBOSE -eq 1 ]; then
echo "done"
fi
if [ $VERBOSE -eq 1 ]; then
echo -n "concatenating archives into single archive..."
fi
# Concatenate archives into a super-archive.
if [ $SEPARATE -eq 0 -o "-" == $OUT_FILE ]; then
if [ $FORMAT == 'tar.gz' ]; then
gunzip $superfile
superfile=${superfile:0: -3} # Remove '.gz'
sed -e '1d' $TMPFILE | while read file; do
gunzip $file
file=${file:0: -3}
$TARCMD --concatenate -f "$superfile" "$file" && rm -f "$file"
done
gzip $superfile
superfile=$superfile.gz
elif [ $FORMAT == 'tar' ]; then
sed -e '1d' $TMPFILE | while read file; do
$TARCMD --concatenate -f "$superfile" "$file" && rm -f "$file"
done
elif [ $FORMAT == 'zip' ]; then
sed -e '1d' $TMPFILE | while read file; do
# zip incorrectly stores the full path, so cd and then grow
cd `dirname "$file"`
zip -g "$superfile" `basename "$file"` && rm -f "$file"
done
cd "$OLD_PWD"
fi
echo "$superfile" >| $TMPFILE # clobber on purpose
fi
if [ $VERBOSE -eq 1 ]; then
echo "done"
fi
if [ $VERBOSE -eq 1 ]; then
echo -n "moving archive to $OUT_FILE..."
fi
while read file; do
if [ "-" == $OUT_FILE ]; then
cat "$file" && rm -f "$file"
else
mv "$file" "$OUT_FILE"
fi
done < $TMPFILE
if [ $VERBOSE -eq 1 ]; then
echo "done"
fi

View File

@ -1,229 +0,0 @@
# Sample script to install Python and pip under Windows
# Authors: Olivier Grisel, Jonathan Helmus, Kyle Kastner, and Alex Willmer
# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
$MINICONDA_URL = "http://repo.continuum.io/miniconda/"
$BASE_URL = "https://www.python.org/ftp/python/"
$GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
$GET_PIP_PATH = "C:\get-pip.py"
$PYTHON_PRERELEASE_REGEX = @"
(?x)
(?<major>\d+)
\.
(?<minor>\d+)
\.
(?<micro>\d+)
(?<prerelease>[a-z]{1,2}\d+)
"@
function Download ($filename, $url) {
$webclient = New-Object System.Net.WebClient
$basedir = $pwd.Path + "\"
$filepath = $basedir + $filename
if (Test-Path $filename) {
Write-Host "Reusing" $filepath
return $filepath
}
# Download and retry up to 3 times in case of network transient errors.
Write-Host "Downloading" $filename "from" $url
$retry_attempts = 2
for ($i = 0; $i -lt $retry_attempts; $i++) {
try {
$webclient.DownloadFile($url, $filepath)
break
}
Catch [Exception]{
Start-Sleep 1
}
}
if (Test-Path $filepath) {
Write-Host "File saved at" $filepath
} else {
# Retry once to get the error message if any at the last try
$webclient.DownloadFile($url, $filepath)
}
return $filepath
}
function ParsePythonVersion ($python_version) {
if ($python_version -match $PYTHON_PRERELEASE_REGEX) {
return ([int]$matches.major, [int]$matches.minor, [int]$matches.micro,
$matches.prerelease)
}
$version_obj = [version]$python_version
return ($version_obj.major, $version_obj.minor, $version_obj.build, "")
}
function DownloadPython ($python_version, $platform_suffix) {
$major, $minor, $micro, $prerelease = ParsePythonVersion $python_version
if (($major -le 2 -and $micro -eq 0) `
-or ($major -eq 3 -and $minor -le 2 -and $micro -eq 0) `
) {
$dir = "$major.$minor"
$python_version = "$major.$minor$prerelease"
} else {
$dir = "$major.$minor.$micro"
}
if ($prerelease) {
if (($major -le 2) `
-or ($major -eq 3 -and $minor -eq 1) `
-or ($major -eq 3 -and $minor -eq 2) `
-or ($major -eq 3 -and $minor -eq 3) `
) {
$dir = "$dir/prev"
}
}
if (($major -le 2) -or ($major -le 3 -and $minor -le 4)) {
$ext = "msi"
if ($platform_suffix) {
$platform_suffix = ".$platform_suffix"
}
} else {
$ext = "exe"
if ($platform_suffix) {
$platform_suffix = "-$platform_suffix"
}
}
$filename = "python-$python_version$platform_suffix.$ext"
$url = "$BASE_URL$dir/$filename"
$filepath = Download $filename $url
return $filepath
}
function InstallPython ($python_version, $architecture, $python_home) {
Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home
if (Test-Path $python_home) {
Write-Host $python_home "already exists, skipping."
return $false
}
if ($architecture -eq "32") {
$platform_suffix = ""
} else {
$platform_suffix = "amd64"
}
$installer_path = DownloadPython $python_version $platform_suffix
$installer_ext = [System.IO.Path]::GetExtension($installer_path)
Write-Host "Installing $installer_path to $python_home"
$install_log = $python_home + ".log"
if ($installer_ext -eq '.msi') {
InstallPythonMSI $installer_path $python_home $install_log
} else {
InstallPythonEXE $installer_path $python_home $install_log
}
if (Test-Path $python_home) {
Write-Host "Python $python_version ($architecture) installation complete"
} else {
Write-Host "Failed to install Python in $python_home"
Get-Content -Path $install_log
Exit 1
}
}
function InstallPythonEXE ($exepath, $python_home, $install_log) {
$install_args = "/quiet InstallAllUsers=1 TargetDir=$python_home"
RunCommand $exepath $install_args
}
function InstallPythonMSI ($msipath, $python_home, $install_log) {
$install_args = "/qn /log $install_log /i $msipath TARGETDIR=$python_home"
$uninstall_args = "/qn /x $msipath"
RunCommand "msiexec.exe" $install_args
if (-not(Test-Path $python_home)) {
Write-Host "Python seems to be installed else-where, reinstalling."
RunCommand "msiexec.exe" $uninstall_args
RunCommand "msiexec.exe" $install_args
}
}
function RunCommand ($command, $command_args) {
Write-Host $command $command_args
Start-Process -FilePath $command -ArgumentList $command_args -Wait -Passthru
}
function InstallPip ($python_home) {
$pip_path = $python_home + "\Scripts\pip.exe"
$python_path = $python_home + "\python.exe"
if (-not(Test-Path $pip_path)) {
Write-Host "Installing pip..."
$webclient = New-Object System.Net.WebClient
$webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH)
Write-Host "Executing:" $python_path $GET_PIP_PATH
& $python_path $GET_PIP_PATH
} else {
Write-Host "pip already installed."
}
}
function DownloadMiniconda ($python_version, $platform_suffix) {
if ($python_version -eq "3.4") {
$filename = "Miniconda3-3.5.5-Windows-" + $platform_suffix + ".exe"
} else {
$filename = "Miniconda-3.5.5-Windows-" + $platform_suffix + ".exe"
}
$url = $MINICONDA_URL + $filename
$filepath = Download $filename $url
return $filepath
}
function InstallMiniconda ($python_version, $architecture, $python_home) {
Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home
if (Test-Path $python_home) {
Write-Host $python_home "already exists, skipping."
return $false
}
if ($architecture -eq "32") {
$platform_suffix = "x86"
} else {
$platform_suffix = "x86_64"
}
$filepath = DownloadMiniconda $python_version $platform_suffix
Write-Host "Installing" $filepath "to" $python_home
$install_log = $python_home + ".log"
$args = "/S /D=$python_home"
Write-Host $filepath $args
Start-Process -FilePath $filepath -ArgumentList $args -Wait -Passthru
if (Test-Path $python_home) {
Write-Host "Python $python_version ($architecture) installation complete"
} else {
Write-Host "Failed to install Python in $python_home"
Get-Content -Path $install_log
Exit 1
}
}
function InstallMinicondaPip ($python_home) {
$pip_path = $python_home + "\Scripts\pip.exe"
$conda_path = $python_home + "\Scripts\conda.exe"
if (-not(Test-Path $pip_path)) {
Write-Host "Installing pip..."
$args = "install --yes pip"
Write-Host $conda_path $args
Start-Process -FilePath "$conda_path" -ArgumentList $args -Wait -Passthru
} else {
Write-Host "pip already installed."
}
}
function main () {
InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON
InstallPip $env:PYTHON
}
main

View File

@ -1,48 +0,0 @@
#!/bin/sh
# Provide the canonicalize filename (physical filename with out any symlinks)
# like the GNU version readlink with the -f option regardless of the version of
# readlink (GNU or BSD).
# This file is part of a set of unofficial pre-commit hooks available
# at github.
# Link: https://github.com/githubbrowser/Pre-commit-hooks
# Contact: David Martin, david.martin.mailbox@googlemail.com
###########################################################
# There should be no need to change anything below this line.
# Canonicalize by recursively following every symlink in every component of the
# specified filename. This should reproduce the results of the GNU version of
# readlink with the -f option.
#
# Reference: http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac
canonicalize_filename () {
local target_file="$1"
local physical_directory=""
local result=""
# Need to restore the working directory after work.
local working_dir="`pwd`"
cd -- "$(dirname -- "$target_file")"
target_file="$(basename -- "$target_file")"
# Iterate down a (possible) chain of symlinks
while [ -L "$target_file" ]
do
target_file="$(readlink -- "$target_file")"
cd -- "$(dirname -- "$target_file")"
target_file="$(basename -- "$target_file")"
done
# Compute the canonicalized name by finding the physical path
# for the directory we're in and appending the target file.
physical_directory="`pwd -P`"
result="$physical_directory/$target_file"
# restore the working directory after work.
cd -- "$working_dir"
echo "$result"
}

View File

@ -1,4 +0,0 @@
#!/bin/sh
rm -Rf .git/hooks
ln -s ../.githooks .git/hooks

View File

@ -1,171 +0,0 @@
#!/bin/sh
# git pre-commit hook that runs an Uncrustify stylecheck.
# Features:
# - abort commit when commit does not comply with the style guidelines
# - create a patch of the proposed style changes
#
# More info on Uncrustify: http://uncrustify.sourceforge.net/
# This file is part of a set of unofficial pre-commit hooks available
# at github.
# Link: https://github.com/githubbrowser/Pre-commit-hooks
# Contact: David Martin, david.martin.mailbox@googlemail.com
##################################################################
# CONFIGURATION
# set uncrustify path or executable
# UNCRUSTIFY="/usr/bin/uncrustify"
UNCRUSTIFY="uncrustify"
# set uncrustify config location
# CONFIG="/home/user/.config/uncrustify.cfg"
CONFIG=".uncrustify.cfg"
# the source language: C, CPP, D, CS, JAVA, PAWN, VALA, OC, OC+
# use AUTO to let Uncrustify decide which language a given file uses.
# the detected language is printed to the console when Uncrustify is called.
# override if the automatic detection seems off.
# SOURCE_LANGUAGE="AUTO"
SOURCE_LANGUAGE="AUTO"
# remove any older patches from previous commits. Set to true or false.
# DELETE_OLD_PATCHES=false
DELETE_OLD_PATCHES=false
# only parse files with the extensions in FILE_EXTS. Set to true or false.
# if false every changed file in the commit will be parsed with Uncrustify.
# if true only files matching one of the extensions are parsed with Uncrustify.
# PARSE_EXTS=true
PARSE_EXTS=true
# file types to parse. Only effective when PARSE_EXTS is true.
# FILE_EXTS=".c .h .cpp .hpp"
FILE_EXTS=".c .h .cc .hh .cpp .hpp .hxx"
##################################################################
# There should be no need to change anything below this line.
. "$(dirname -- "$0")/canonicalize_filename.sh"
# exit on error
set -e
# check whether the given file matches any of the set extensions
matches_extension() {
local filename="$(basename -- "$1")"
local extension=".${filename##*.}"
local ext
for ext in $FILE_EXTS; do [ "$ext" = "$extension" ] && return 0; done
return 1
}
# necessary check for initial commit
if git rev-parse --verify HEAD >/dev/null 2>&1 ; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# make sure the config file and executable are correctly set
if [ ! -f "$CONFIG" ] ; then
printf "Error: uncrustify config file not found.\n"
printf "Set the correct path in $(canonicalize_filename "$0").\n"
exit 1
fi
if ! command -v "$UNCRUSTIFY" > /dev/null ; then
printf "Error: uncrustify executable not found.\n"
printf "Set the correct path in $(canonicalize_filename "$0").\n"
exit 1
fi
# create a filename to store our generated patch
prefix="pre-commit-uncrustify"
suffix="$(date +%C%y-%m-%d_%Hh%Mm%Ss)"
patch="/tmp/$prefix-$suffix.patch"
diff="/tmp/$prefix-$suffix.diff"
# clean up any older uncrustify patches
$DELETE_OLD_PATCHES && rm -f /tmp/$prefix*.patch
# create one patch containing all changes to the files
# sed to remove quotes around the filename, if inserted by the system
# (done sometimes, if the filename contains special characters, like the quote itself)
git diff-index --cached --diff-filter=ACMR --name-only $against -- | \
sed -e 's/^"\(.*\)"$/\1/' | \
while read file
do
# ignore file if we do check for file extensions and the file
# does not match any of the extensions specified in $FILE_EXTS
if $PARSE_EXTS && ! matches_extension "$file"; then
continue;
fi
# escape special characters in the source filename:
# - '\': backslash needs to be escaped
# - '*': used as matching string => '*' would mean expansion
# (curiously, '?' must not be escaped)
# - '[': used as matching string => '[' would mean start of set
# - '|': used as sed split char instead of '/', so it needs to be escaped
# in the filename
# printf %s particularly important if the filename contains the % character
file_escaped_source=$(printf "%s" "$file" | sed -e 's/[\*[|]/\\&/g')
# escape special characters in the target filename:
# phase 1 (characters escaped in the output diff):
# - '\': backslash needs to be escaped in the output diff
# - '"': quote needs to be escaped in the output diff if present inside
# of the filename, as it used to bracket the entire filename part
# phase 2 (characters escaped in the match replacement):
# - '\': backslash needs to be escaped again for sed itself
# (i.e. double escaping after phase 1)
# - '&': would expand to matched string
# - '|': used as sed split char instead of '/'
# printf %s particularly important if the filename contains the % character
file_escaped_target=$(printf "%s" "$file" | sed -e 's/[\"]/\\&/g' -e 's/[\&|]/\\&/g')
# Uncrustify detects the language automatically if it is not specified
language_option=""
if [ "$SOURCE_LANGUAGE" != "AUTO" ] ; then
language_option="-l $SOURCE_LANGUAGE"
fi
# uncrustify our sourcefile, create a patch with diff and append it to our $patch
# The sed call is necessary to transform the patch from
# --- $file timestamp
# +++ - timestamp
# to both lines working on the same file and having a a/ and b/ prefix.
# Else it can not be applied with 'git apply'.
"$UNCRUSTIFY" -q -c "$CONFIG" -f "$file" $language_option | \
git --no-pager diff --color=always --no-index -- "$file" - | \
tail -n +3 | \
sed -e "1s|--- a/$file_escaped_source|--- \"a/$file_escaped_target\"|" \
-e "2s|+++ b/-|+++ \"b/$file_escaped_target\"|" | \
tee -a "$diff" | \
sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" >> "$patch"
done
# if no patch has been generated all is ok, clean up the file stub and exit
if [ ! -s "$patch" ] ; then
printf "Files in this commit comply with the uncrustify rules.\n"
rm -f "$patch"
exit 0
fi
# a patch has been created, notify the user and exit
printf "\nThe following differences were found between the code to commit "
printf "and the uncrustify rules:\n\n"
cat "$diff"
rm -f "$diff"
printf "\nYou can apply these changes with:\n git apply $patch\n"
printf "(may need to be called from the root directory of your repository)\n"
printf "Aborting commit. Apply changes and commit again or skip checking with"
printf " --no-verify (not recommended).\n"
exit 1

38
.gitignore vendored
View File

@ -1,38 +0,0 @@
*
!*/
!.gitignore
!.bumpversion.cfg
!.ci/*
!.cmake/*
!dev/*
!doc/*
!*.c
!*.m
!*.cc
!*.h
!*.hxx
!*.rst
!*.po
!*.in
!*.t
!*.proto
!.cmake/Modules/*.cmake
!samples/tests/*.sh
!samples/**/*.expected
!LICENSE
!HEADER
!ChangeLog
CMakeFiles/
!CMakeLists.txt
src/config.h
build
*~
*.swp
.*.swp

24
.gitmodules vendored
View File

@ -1,24 +0,0 @@
[submodule "dependencies/libcsptr"]
path = dependencies/libcsptr
url = https://github.com/Snaipe/libcsptr.git
[submodule "dependencies/dyncall"]
path = dependencies/dyncall
url = https://github.com/Snaipe/dyncall.git
[submodule "dependencies/wingetopt"]
path = dependencies/wingetopt
url = https://github.com/alex85k/wingetopt.git
[submodule "dependencies/klib"]
path = dependencies/klib
url = https://github.com/attractivechaos/klib.git
[submodule "dependencies/nanopb"]
path = dependencies/nanopb
url = https://github.com/nanopb/nanopb.git
[submodule "dependencies/nanomsg"]
path = dependencies/nanomsg
url = https://github.com/nanomsg/nanomsg.git
[submodule "dependencies/debugbreak"]
path = dependencies/debugbreak
url = https://github.com/scottt/debugbreak
[submodule "dependencies/boxfort"]
path = dependencies/boxfort
url = https://github.com/Snaipe/BoxFort

View File

@ -1,172 +0,0 @@
language: c
sudo: false
_anchors:
- &gcc49-packages
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.9
- g++-4.9
- gobjc-4.9
- gnustep-devel
matrix:
include:
# Style check
- compiler: uncrustify
language: cpp
before_install:
- if [[ "$TRAVIS_PULL_REQUEST" == false ]]; then exit 0; fi
- |
git clone https://github.com/uncrustify/uncrustify /tmp/uncrustify &&
pushd /tmp/uncrustify &&
git checkout -q 7ae7af9d3483f5f92766ec41bb3ba3efe4747494 &&
mkdir build && cd build &&
CC=gcc CXX=g++ cmake -DCMAKE_INSTALL_PREFIX=$HOME .. &&
make -j4 && make install &&
export PATH="$PATH:$HOME/bin" &&
popd
- >
export SOURCES=$(find src include test samples \( \
-type f \( \
-iname "*.c" -or \
-iname "*.h" -or \
-iname "*.cc" -or \
-iname "*.hxx" \
\) -and -not \
-iname "*.pb.*" \))
- export STYLE_OK=true
script:
- >
for f in $SOURCES; do
if ! uncrustify -q --check -c .uncrustify.cfg $f; then
uncrustify -q -c .uncrustify.cfg -f $f | git --no-pager diff --no-index --color=always $f -
export STYLE_OK=false
fi
done
- $STYLE_OK
after_success:
- echo "Style check passed."
# Linux Debug, GCC 4.9
- compiler: gcc-4.9
addons: *gcc49-packages
env:
CONFIGURATION: Debug
GCOV: gcov-4.9
COVERAGE: "ON"
# Linux RelWithDebInfo, GCC 4.9
- compiler: gcc-4.9
addons: *gcc49-packages
env:
CONFIGURATION: RelWithDebInfo
DEPLOY: true
# Linux Debug, GCC 4.6
- compiler: gcc
env: CONFIGURATION=Debug TESTS=OFF
# Linux RelWithDebInfo, GCC 4.6
- compiler: gcc
env:
- CONFIGURATION=RelWithDebInfo
- TESTS=OFF
# Coverity token
- secure: >-
n6BHG86ISeYSAVE/i7m1K+XVW0j8PrJ5JxoJwhAGBb1
hkCn9sWybGo1HzZsf7rxpkQh/5Va4i+eyOrUt7VWAuF
EJN2+mEWqERkWZxiXrS3N9xi74cPFI79eDOTFnPm13e
diUX8Ts+IuFy890+tsNHqkEn055l6yOVMtj1LWWtRs=
# OSX Debug, GCC 4.9
- os: osx
compiler: gcc-4.9
env:
CONFIGURATION: Debug
GCOV: gcov-4.9
COVERAGE: "ON"
# OSX RelWithDebInfo, GCC 4.9
- os: osx
compiler: gcc-4.9
env: CONFIGURATION=RelWithDebInfo
# OSX Debug, Clang
- os: osx
compiler: clang
env:
CONFIGURATION: Debug
# OSX RelWithDebInfo, Clang
- os: osx
compiler: clang
env:
CONFIGURATION: RelWithDebInfo
DEPLOY: true
allow_failures:
- compiler: gcc
before_install:
- |
if [ "${TESTS:-ON}" = "ON" ]; then
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
export PATH="$(python -m site --user-base)/bin:$PATH"
fi
travis_retry pip install --user cram==0.7
fi
- export CXX=${CC/gcc/g++}; export CXX=${CXX/clang/clang++}
- $CC --version
- $CXX --version
script:
- mkdir -p build && cd $_
- >
cmake
-Wno-dev
-DCTESTS=${TESTS:-ON}
-DCOVERALLS=${COVERAGE:-OFF}
-DCMAKE_BUILD_TYPE=${CONFIGURATION}
-DCMAKE_INSTALL_PREFIX=criterion-${TRAVIS_TAG}
${CMAKE_OPTS}
..
- |
if [ "${TESTS:-ON}" = "ON" ]; then
TERM=dumb cmake --build . --target criterion_tests -- -j4
ctest --output-on-failure -j4 --timeout=20
else
TERM=dumb cmake --build . -- -j4
fi
after_success:
- |
if [ "$COVERAGE" = "ON" ]; then
make gcov
bash <(curl -s https://codecov.io/bash)
fi
before_deploy:
- make install
- tar -cvjf criterion-${TRAVIS_TAG}-${TRAVIS_OS_NAME}-x86_64.tar.bz2 criterion-${TRAVIS_TAG}
- cd ..
- ./.cmake/git-archive-all.sh --prefix criterion-${TRAVIS_TAG} criterion-${TRAVIS_TAG}.tar && bzip2 $_
addons:
coverity_scan:
project:
name: "Snaipe/Criterion"
description: "A KISS, Cross-platform C unit testing framework"
notification_email: franklinmathieu@gmail.com
build_command_prepend: "cmake ."
build_command: "make -j4"
branch_pattern: coverity_scan
deploy:
provider: releases
skip_cleanup: true
api_key:
secure: d3l2Ohb2FF3tSXku1d0ASR5dntdnQ48Jyc39IEloDBxFXCselCkYruUQv6p0TA3P+Dmrz4wS7/AFlBMMsQ3XfGFVIOnITiTaGWg5fEpIf7zYsDf0zECPE0MOHMGqJMn3/SrSKdtEA4N84Q4JS7Ou+ewG65mxUDO5Ce60OoEG5JA=
file:
- criterion-${TRAVIS_TAG}-${TRAVIS_OS_NAME}-x86_64.tar.bz2
- criterion-${TRAVIS_TAG}.tar.bz2
on:
repo: Snaipe/Criterion
tags: true
condition: $DEPLOY = true

View File

@ -1,239 +0,0 @@
#
# uncrustify config file (initially based on the linux kernel coding style)
#
input_tab_size = 4 # original tab size
output_tab_size = 4 # new tab size
newlines = lf # \n
utf8_force = true
utf8_bom = remove
# Indent
indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs
indent_columns = 4 # indents are 4 cols
indent_continue = 8 # line continuations are indented by 8 columns
indent_label = -4 # pos: absolute col, neg: relative column
indent_xml_string = 2 # embedded XML indents are 2 cols
indent_ctor_init = 4 # indent c++ ctor initializer list
indent_switch_case = 4 # indent 'case' inside switch statements
indent_namespace = false
indent_extern = false
indent_class = false
indent_class_colon = true
indent_access_spec_body = true
# Newlines
nl_max = 2 # no duplicate blank lines
nl_func_paren = remove # "int foo()" vs "int foo\n()"
nl_func_decl_start = ignore
nl_func_decl_empty = remove
nl_func_decl_args = ignore
nl_func_decl_end = remove
nl_enum_brace = remove # "enum {" vs "enum \n {"
nl_union_brace = remove # "union {" vs "union \n {"
nl_struct_brace = remove # "struct {" vs "struct \n {"
nl_do_brace = remove # "do {" vs "do \n {"
nl_if_brace = remove # "if () {" vs "if () \n {"
nl_for_brace = remove # "for () {" vs "for () \n {"
nl_else_brace = remove # "else {" vs "else \n {"
nl_while_brace = remove # "while () {" vs "while () \n {"
nl_switch_brace = remove # "switch () {" vs "switch () \n {"
nl_brace_while = remove # "} while" vs "} \n while" - cuddle while
nl_brace_else = remove # "} else" vs "} \n else" - cuddle else
nl_namespace_brace = force # "namespace name {" vs "namespace name \n {"
nl_func_var_def_blk = 1
nl_fcall_brace = remove # "list_for_each() {" vs "list_for_each()\n{"
nl_fdef_brace = add # "int foo() {" vs "int foo()\n{"
nl_after_label_colon = false # "fail:\nfree(foo);" vs "fail: free(foo);"
nl_start_of_file = remove
nl_end_of_file = force
nl_end_of_file_min = 1
nl_comment_func_def = 1
nl_assign_leave_one_liners = true
nl_class_leave_one_liners = true
nl_enum_leave_one_liners = true
nl_getset_leave_one_liners = true
nl_func_leave_one_liners = true
nl_cpp_lambda_leave_one_liners = true
nl_while_leave_one_liners = false
nl_if_leave_one_liners = false
nl_multi_line_define = true
nl_func_call_start_multi_line = false
nl_func_call_end_multi_line = false
# Source code modifications
mod_paren_on_return = remove # "return 1;" vs "return (1);"
mod_full_brace_if = remove # "if (a) a--;" vs "if (a) { a--; }"
mod_full_brace_if_chain = true
mod_full_brace_for = remove # "for () a--;" vs "for () { a--; }"
mod_full_brace_do = force # "do a--; while ();" vs "do { a--; } while ();"
mod_full_brace_while = remove # "while (a) a--;" vs "while (a) { a--; }"
mod_full_brace_nl = 3 # don't remove if more than 3 newlines
# Spacing
sp_addr = remove
sp_after_angle = force
sp_after_byref = remove
sp_after_byref_func = remove
sp_after_cast = force # "(int) a" vs "(int)a"
sp_after_class_colon = force
sp_after_comma = force
sp_after_dc = remove
sp_after_new = force
sp_after_operator = remove
sp_after_operator_sym = remove
sp_after_ptr_star = remove # "int *foo" vs "int * foo"
sp_after_ptr_star_func = remove
sp_after_semi = force
sp_after_semi_for = force
sp_after_semi_for_empty = remove
sp_after_sparen = force # "if () {" vs "if (){"
sp_after_type = force
sp_angle_paren = remove
sp_angle_shift = ignore
sp_angle_word = force
sp_arith = force
sp_assign = add
sp_assign_default = force
sp_attribute_paren = remove
sp_balance_nested_parens = false
sp_before_angle = remove
sp_before_byref = force
sp_before_byref_func = force
sp_before_case_colon = remove
sp_before_class_colon = force
sp_before_comma = remove
sp_before_dc = remove
sp_before_ellipsis = remove
sp_before_nl_cont = force
sp_before_ptr_star = force # "int*" vs "int *"
sp_before_ptr_star_func = force
sp_before_semi = remove
sp_before_semi_for = remove
sp_before_semi_for_empty = remove
sp_before_sparen = force # "if (" vs "if("
sp_before_square = remove
sp_before_tr_emb_cmt = force
sp_before_unnamed_byref = force
sp_between_ptr_star = remove # "int **" vs "int * *"
sp_bool = force
sp_brace_catch = force
sp_brace_else = force # "}else" vs "} else"
sp_brace_finally = force
sp_brace_typedef = force
sp_case_label = force
sp_catch_brace = force
sp_catch_paren = force
sp_cmt_cpp_start = force
sp_compare = force
sp_cond_colon = add
sp_cond_question = add
sp_cpp_cast_paren = force
sp_defined_paren = force
sp_deref = remove
sp_else_brace = force # "else{" vs "else {"
sp_endif_cmt = force
sp_enum_assign = force
sp_finally_brace = force
sp_fparen_brace = force
sp_func_call_paren = remove # "foo (" vs "foo("
sp_func_call_user_paren = remove
sp_func_class_paren = remove
sp_func_def_paren = remove # "int foo (){" vs "int foo(){"
sp_func_proto_paren = remove # "int foo ();" vs "int foo();"
sp_getset_brace = force
sp_incdec = remove
sp_inside_angle = remove
sp_inside_braces = force # "{ 1 }" vs "{1}"
sp_inside_braces_empty = remove
sp_inside_braces_enum = force # "{ 1 }" vs "{1}"
sp_inside_braces_struct = force # "{ 1 }" vs "{1}"
sp_inside_fparen = remove
sp_inside_fparens = remove
sp_inside_paren = remove
sp_inside_paren_cast = remove
sp_inside_sparen = remove
sp_inside_square = remove
sp_inv = remove
sp_macro = force
sp_macro_func = force
sp_member = remove
sp_not = remove
sp_num_before_tr_emb_cmt = 1
sp_paren_brace = force
sp_paren_comma = ignore
sp_paren_paren = remove # "((" vs "( ("
sp_pp_concat = force
sp_pp_stringify = remove
sp_return_paren = force # "return (1);" vs "return(1);"
sp_sign = remove
sp_sizeof_paren = force # "sizeof (int)" vs "sizeof(int)"
sp_sparen_brace = force
sp_special_semi = remove
sp_square_fparen = remove
sp_template_angle = add
sp_throw_paren = force
sp_try_brace = force
cmt_sp_before_star_cont = 0
cmt_sp_after_star_cont = 1
# Positioning
pos_arith = lead
pos_assign = trail
pos_bool = lead
pos_compare = lead
pos_conditional = lead
pos_comma = trail
pos_class_comma = trail
pos_class_colon = lead
# Alignment
align_with_tabs = false # use tabs to align
align_on_tabstop = false # align on tabstops
align_enum_equ_span = 4 # '=' in enum definition
align_nl_cont = true
align_assign_span = 0
align_struct_init_span = 3 # align stuff in a structure init '= { }'
align_right_cmt_span = 3
align_pp_define_span = 8
align_pp_define_gap = 4
align_func_params = false
align_var_struct_span = 0
# Comment
cmt_indent_multi = true
cmt_c_group = false
cmt_c_nl_start = false
cmt_c_nl_end = false
cmt_cpp_group = true
cmt_cpp_nl_start = false
cmt_cpp_nl_end = false
cmt_cpp_to_c = true
cmt_star_cont = false
cmt_multi_check_last = true
eat_blanks_after_open_brace = true
eat_blanks_before_close_brace = true
# Preprocessor
pp_indent = remove
pp_space = force
pp_space_count = 1
# Misc
set cpp_cast nonstd # nonstd cast attributes
set compare Op # typical (A) Op (B) macro scenarios
set func_call_user _ N_ # gettext macros
set attribute CR_FORMAT CR_API CR_PURE CR_INLINE

14
AUTHORS
View File

@ -1,14 +0,0 @@
Maintainer:
* Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
Contributors:
* Adeel "am11" Mujahid <adeelbm@outlook.com>
* Matthias "ailu" Günzel <a1lu@arcor.de>
* Ben "blinskey" Linskey <ben@benlinskey.com>
* "kaidowei" <kaidowei@users.noreply.github.com>
* Howard "hppritcha" Pritchard <howardp@lanl.gov>
* Kevin "kevinoid" Locke <kevin@kevinlocke.name>
* László "MrAnno" Várady <laszlo.varady@balabit.com>
* "offa" <bm-dev@yandex.com>

View File

@ -1,149 +0,0 @@
# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
cmake_minimum_required (VERSION 2.8)
project (Criterion C)
set (MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.cmake/Modules")
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MODULE_DIR})
if (POLICY CMP0054)
# http://www.cmake.org/cmake/help/v3.1/policy/CMP0054.html
# This is here to allow conditions to be passed as function parameters
cmake_policy (SET CMP0054 OLD)
endif ()
# Initialization
include (Options)
include (Submodules)
include (Capabilities)
include (Subprojects)
include (PackageUtils)
if (NOT WIN32)
set (PIC_C_FLAGS "-fPIC")
set (VISI_C_FLAGS "-fvisibility=hidden")
else ()
set (PIC_C_FLAGS "")
set (VISI_C_FLAGS "")
endif ()
cr_add_subproject (csptr PATH dependencies/libcsptr
OPTS
-DLIBCSPTR_TESTS=OFF
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} ${PIC_C_FLAGS} ${VISI_C_FLAGS}"
CMAKE)
cr_add_subproject (dyncall_s PATH dependencies/dyncall
OPTS
-DLANG_CXX=${LANG_CXX}
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} ${PIC_C_FLAGS} ${VISI_C_FLAGS}"
CMAKE IF THEORIES)
cr_add_subproject (nanomsg
PATH dependencies/nanomsg
OPTS
-DNN_TESTS=OFF
-DNN_TOOLS=OFF
-DNN_STATIC_LIB=ON
-DCMAKE_INSTALL_LIBDIR=lib
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} ${PIC_C_FLAGS} ${VISI_C_FLAGS}"
CMAKE
)
cr_add_subproject (boxfort PATH dependencies/boxfort
OPTS
-DBXF_TESTS=OFF
-DBXF_SAMPLES=OFF
-DBXF_STATIC_LIB=ON
-DBXF_FORK_RESILIENCE=OFF
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} ${PIC_C_FLAGS} ${VISI_C_FLAGS}"
CMAKE)
add_definitions(-DBXF_STATIC_LIB -DNN_STATIC_LIB)
cr_add_subproject (wingetopt PATH dependencies/wingetopt CMAKE IF MSVC)
include (Properties)
add_definitions (-DNN_STATIC_LIB)
include_directories(
dependencies/valgrind/include/
dependencies/klib/
dependencies/nanopb/
dependencies/debugbreak/
)
# Coverage
if (COVERALLS)
include(Coveralls)
coveralls_turn_on_coverage()
endif()
# I18N
if (I18N AND GETTEXT_FOUND AND LIBINTL_LIB_FOUND)
include(GettextTranslate)
add_subdirectory(po)
endif ()
# Project
include_directories(include src)
add_subdirectory (src)
cr_add_library(criterion SHARED
SOURCES ${SOURCE_FILES}
HEADERS ${INTERFACE_FILES}
COMPONENT dev
PROPERTIES
VERSION ${PROJECT_SONAME}
SOVERSION ${PROJECT_SOVERSION}
)
cr_link_subproject(criterion csptr STATIC)
cr_link_subproject(criterion nanomsg STATIC)
cr_link_subproject(criterion dyncall_s STATIC)
cr_link_subproject(criterion wingetopt STATIC)
cr_link_subproject(criterion boxfort STATIC)
cr_link_libraries(criterion pthread IF NOT WIN32)
cr_link_libraries(criterion rt IF HAVE_LIBRT)
# Required by nanomsg
cr_link_libraries(criterion anl IF HAVE_GETADDRINFO_A)
cr_link_libraries(criterion ws2_32 mswsock IF WIN32)
cr_link_package(criterion LIBINTL)
if (COVERALLS)
coveralls_setup("${SOURCE_FILES}" ${COVERALLS_UPLOAD})
add_custom_target(gcov
"${CMAKE_COMMAND}"
-DSOURCE_FILES="${SOURCE_FILES}"
-DCOV_PATH="${CMAKE_CURRENT_BINARY_DIR}"
-P "${CMAKE_MODULE_PATH}/Gcov.cmake"
)
endif()
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_MODULE_PATH}/uninstall.cmake"
)
if (CTESTS)
enable_testing()
add_custom_target(criterion_tests)
add_subdirectory(samples)
add_subdirectory(test)
endif ()
if (UPLOAD_DEB)
include (DebUpload)
endif ()

View File

@ -1,71 +0,0 @@
# Contributing
Contributions are welcomed, but must follow a simple set of rules in order to
be merged.
**Please follow these conventions if you want your pull request(s) accepted.**
## General
* Try to respect a 80 chars column limit. Not mandatory, but appreciated.
* No trash files. Trash files are by-products of the compilation process, or
generated files that does not need to be under version control.
* Pull requests must pass the style check. See "Passing the style check" section below.
* Pull requests must compile and work properly.
* Pull requests must pass all tests.
* Pull requests must be mergeable without conflicts.
* Number of commits in a pull request should be kept to one commit and all
additional commits must be squashed.
* You may have more than one commit in a pull request if the commits are
separate changes, otherwise squash them.
* Keep your commit messages simple and concise. Good commit messages start
with a verb ('Add', 'Fix', ...).
* Commit messages should follow the format `topic: message`, e.g. `cli: Added --foo flag`.
In cases where multiple topics are relevant, use a comma-separated list of topics, e.g.
`api,float: Fixed printf format specifiers for long double`
## Passing the style check
This project use an automated style checking process for pull requests defined as
an uncrustify configuration file named `.uncrustify.cfg`.
To ease the development process, a pre-commit hook is installable by running
`.githooks/install.sh` from the project root directory. This pre-commit hook
checks for style, outputs a diff of the changes that need to be done, and
produces a patch to fix them automatically.
As the automatic style checker is bound to have errors, parts of the code
that make the checker fail because of their tricky grammar (e.g. Duff devices)
may be enclosed by `/* *INDENT-OFF* */` and `/* *INDENT-ON* */` to disable
the style checker on the region. Note that this feature should be used
*exceptionally*, and that the maintainer will always have the last word regarding
stylistic choices that cannot pass the style check.
## Translations
* You can contribute new translation files for output messages, on the
condition that you are fluent with the language itself.
* Each correction on existing translations must be followed by a
rationale ("why would the translation be better if the change is applied?")
## Roadmap
.
|- .cmake/: CMake modules
|- dependencies/: dependencies for building libcriterion
|- doc/: Sphinx documentation files
|- dev/: Developer files
|- include/criterion/: Public API
|- src/: Sources for libcriterion
| |- compat/: Cross-platform abstractions for platform-dependent code
| |- core/: Core mechanisms used to run the tests
| |- entry/: Entry-point related sources, and default main function
| |- io/: IO related functions, redirections
| |- log/: Output providers, all the output logic in general
| `- string/: String manipulation functions, i18n
|- po/: Translation files, i18n stuff
|- test/: Unit tests for libcriterion
`- samples/: Sample files
|- outputs/: Expected output files for the current samples
`- tests/: Internal regression tests
`- outputs/: Expected output files for the regression tests

206
ChangeLog
View File

@ -1,206 +0,0 @@
2018-09-18 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 2.3.0
* Addition: added German translation files (Matthias "ailu" Günzel).
* Addition: added a pkg-config file.
* Addition: allow tests to be skipped with cr_skip_test() (Matthias "ailu" Günzel).
* Addition: assertions on wide-strings are now available (Kevin "kevinoid" Locke).
* Addition: crash-mode with --crash to raise a trap when an assertion fails for debugging purposes (Matthias "ailu" Günzel).
* Addition: debugging mode with --debug.
* Addition: global test timeout with --timeout.
* Addition: header files in the public API now have doxygen documentation (Matthias "ailu" Günzel).
* Addition: test filtering now works on windows.
* Addition: user logging API with cr_log, cr_log_info, cr_log_warning, and cr_log_error.
* Breaking: dropped support for MinGW, use MinGW-w64.
* Breaking: dropped support for Windows XP, use Windows 7 and later.
* Breaking: log_pre_init and log_pre_test in the internal logger API now takes an additional parameter.
* Breaking: the SOVERSION now follows the SONAME major independently of the project version.
* Change: --pattern has been renamed to --filter.
* Change: removed dependency on PCRE for filtering (Matthias "ailu" Günzel).
* Change: sections of all loaded shared modules are now inspected for tests and hooks.
* Change: setting .exit_code = 0 now enforces the exit code of the test to be 0.
* Change: string assertions now print the contents of string parameters ("kaidowei").
* Change: tests are no longer executed in parallel on windows by default to mitigate a nanomsg bug (see https://github.com/Snaipe/Criterion/issues/118).
* Change: xml reports now includes elapsed times ("kaidowei").
* Deprecation: --no-early-exit is now a no-op and should no longer be used.
* Deprecation: internal logging API is no longer public, fallbacks to the new logging API.
* Fix: fail-fast now works correctly.
* Fix: fixed FindCriterion.cmake with the correct package name (László "MrAnno" Várady).
* Fix: position-independent executables now work.
* Fix: string assertions no longer crash with a NULL parameter ("kaidowei").
* Fix: the data pipe no longer gets corrupted when running a large quantity of assertions in parallel.
* Fix: using dmalloc on tests now works.
* Fix: using the GOLD linker rather than BFD now works.
* Fix: using the musl C library now works.
2016-06-20 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 2.2.2
* Fix: fixed deadlocks when tests are terminated too fast
* Fix: fixed crash during test teardown if spawning new threads in the test
* Fix: fixed memory leak in disabled tests
2016-02-06 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 2.2.1
* Fix: fixed criterion not being embeddable with CMake's `add_directory`
* Fix: fixed resource leaks in the child pump thread
* Fix: fixed redirected standard streams being leaked by cr_(assert|expect)_std(out|err)
* Fix: fixed out of bounds during assert message sending
* Fix: fixed naming convention conflicts for internal variables used by the implementation of cr_assert
* Fix: fixed empty format string warning with GCC 4.8
* Fix: fixed file-to-file comparison assert message being corrupted
2015-12-08 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 2.2.0
* Breaking: Renamed all unprefixed internal macros and functions that were
exposed in the API, and moved them to criterion/internal.
This shouldn't break your code if you did not use these in the first
place.
* Change: Added language-specific wrapping logic to decouple the language
the tests are written in from the test runner.
* Change: Rewrote the reporting logic to allow multiple test reports to be
written using any format.
* Addition: Added parallel jobs for the test runner.
* Addition: Added C++ allocator for STL collections based on
cr_malloc/cr_free.
* Addition: Added criterion::parameters in C++ for simpler parameter list
generation.
* Addition: Added saner defaults when the tests detect they run under
valgrind.
* Addition: Added basic Objective-C language support.
* Addition: Added JUnit XML reporting.
* Addition: Added JSON reporting.
* Addition: Added dynamic reporter registration.
* Addition: Added back support for GCC 4.6 when compiling C tests.
* Addition: Added single test execution mode.
* Removal: Removed all deprecated 1.x unprefixed assertion macros.
* Fix: Fixed some memory corruption happening on rare occasions on assert
messages.
* Fix: Fixed deadlocks happening at random when a large quantity of assert
is present.
* Fix: Fixed the library not compiling with the intel compiler collection.
* Deprecation: All cr_assume_strings_* macros are deprecated in favor of
cr_assume_str_*.
* Deprecation: All cr_assume_arrays_* macros are deprecated in favor of
cr_assume_arr_*.
2015-11-25 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 2.1.1
* Fix: Fixed bug where the TAP output access the assert message after
it has been freed, causing it to print garbage.
2015-09-21 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 2.1.0
* Addition: Added file mocking utilities
* Addition: Added parameterized tests
2015-09-20 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 2.0.2
* Fix: Fixed rare bug where tests from only one compilation unit would run.
2015-09-19 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 2.0.1
* Fix: Fixed wrong setjmp() usage making tests compiled with optimisations
crash.
2015-09-14 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 2.0.0
* Breaking: ABI incompatibility with prior versions of criterion. You
**must** recompile your tests.
* Breaking: cr_abort_test(NULL) does not compile anymore.
* Change: Changed all assertion macros to accept a printf format string as a
message.
* Change: Made the API C++11-compatible.
* Change: Made the library ISO C compliant. You can now compile the library
with VC 14+.
* Addition: Added support for theories.
* Addition: Added ability to test the exit status of a test.
* Addition: Added C++11 throw assertions.
* Addition: Added assert message localization.
* Addition: Added test timeouts.
* Addition: Added test standard i/o redirection & file comparison assertions.
* Removal: Removed the deprecated prefixless assertion macros
* Deprecation: Deprecated cr_abort_test.
* Deprecation: cr_{assert,expect}_strings_* and cr_{assert,expect}_arrays_*
are deprecated in favor of cr_{assert,expect}_str_* and
cr_{assert,expect}_arr_* respectively.
2015-08-20 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 1.3.1
* Fixed OS X and Windows section iterations
* Fixed report hooks not working on OS X and Windows
* Fixed duplicated output when writing in PRE_ALL to a redirected stdout/err
* Added -S switch to display filenames in their short version
2015-08-05 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 1.3.0
* Turned the library into a shared library.
* Added extended globbing for --pattern (requires PCRE)
* Switched to a CMake build system
* Fixed windows builds & output
* Added basic windows SEH-to-signal translator
2015-04-26 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 1.2.1
* Added a cr_ prefix to all assertion macros. Old macros are deprecated
and will be removed in a future version.
2015-04-15 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 1.2.0
* Added native Windows support through MinGW
* Fixed inaccurate statistics on disabled and crashing tests
* Fixed asserts not aborting the test when used in functions
* Fixed programs not compiling when no tests are declared
* Added assert_null to test for pointer nullity
* Added assert_arrays_eq_cmp for padded struct arrays equality
* Added i18n support
* Added fr_FR localization
2015-03-24 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 1.1.0
* Refactored logging system
* Changed output format to a better-looking one
* Added Syntactic coloration
* Added test suite separation
* Added test suite statistics
* Added --list option
* Added --fail-fast option
* Added --pattern option
2015-03-18 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 1.0.0
* Added test timings
* Changed assert prototypes
* ANSI compliance over header files
* Windows + FreeBSD compatibility
2015-03-11 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 0.3.0
* A logging interface
* Various readme and documentation changes
* Default CLI options & environment variables
* Mac OS X compatibility
* Comparison assertions, floating-point equality assertions
2015-02-06 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
* criterion: version 0.2.0
* Added criterion internals.
* Added Test, ReportHook, assert and expect macros.

21
LICENSE
View File

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

106
README.md
View File

@ -1,106 +0,0 @@
<img src="doc/criterion-title.png" height="96" alt="Criterion Logo" />
=========
[![Unix Build Status](https://api.travis-ci.org/Snaipe/Criterion.svg?branch=bleeding)](https://travis-ci.org/Snaipe/Criterion)
[![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/Snaipe/Criterion?svg=true&branch=bleeding)](https://ci.appveyor.com/project/Snaipe/Criterion/branch/bleeding)
[![Coverage Status](https://img.shields.io/codecov/c/github/Snaipe/Criterion/bleeding.svg)](https://codecov.io/github/Snaipe/Criterion?branch=bleeding)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/Snaipe/Criterion/blob/master/LICENSE)
[![Version](https://img.shields.io/badge/version-v2.3.0--rc1-blue.svg?style=flat)](https://github.com/Snaipe/Criterion/releases)
A dead-simple, yet extensible, C and C++ unit testing framework.
![Screencast](./doc/screencast.gif)
## Philosophy
Most test frameworks for C require a lot of boilerplate code to
set up tests and test suites -- you need to create a main,
then register new test suites, then register the tests within
these suits, and finally call the right functions.
This gives the user great control, at the unfortunate cost of simplicity.
Criterion follows the KISS principle, while keeping the control
the user would have with other frameworks:
* [x] C99 and C++11 compatible.
* [x] Tests are automatically registered when declared.
* [x] Implements a xUnit framework structure.
* [x] A default entry point is provided, no need to declare a main
unless you want to do special handling.
* [x] Test are isolated in their own process, crashes and signals can be
reported and tested.
* [x] Unified interface between C and C++: include the criterion header and it *just* works.
* [x] Supports parameterized tests and theories.
* [x] Progress and statistics can be followed in real time with report hooks.
* [x] TAP output format can be enabled with an option.
* [x] Runs on Linux, FreeBSD, Mac OS X, and Windows (Compiling with MinGW GCC and Visual Studio 2015+).
## Downloads
### Packages
* Mac OS X: `brew install snaipe/soft/criterion`
* [AUR](https://aur.archlinux.org/packages/criterion/): `yaourt -S criterion`
### Binary archives
Binary releases are available [on the release page](https://github.com/Snaipe/Criterion/releases)
If you have a different platform, you can still [build the library from source](http://criterion.readthedocs.org/en/latest/setup.html#installation)
## Developer Resources
### Documentation
An online documentation is available on [ReadTheDocs][online-docs]
([PDF][pdf-docs] | [Zip][zip-docs] | [Epub][epub-docs])
### Samples
Sample tests can be found in the [sample directory][samples].
* [A simple test][sample-simple]
* [Using multiple suites][sample-suites]
* [Writing assertions][sample-asserts]
* [Adding test fixtures][sample-fixtures]
* [Tests with signals][sample-signal]
* [Using report hooks][sample-report]
### Getting help
| Channel | Description |
| --- | --- |
[![Subscribe to the mailing list](https://img.shields.io/badge/ml-criterion@freelists.org-46BC99.svg)][mailing-list] | Criterion mailing list on freelists.org
[![Join the chat at https://gitter.im/Snaipe/Criterion](https://badges.gitter.im/Join%20Chat.svg)][gitter-chan] | `Snaipe/Criterion` on gitter.im
[![Join #criterion on freenode](https://img.shields.io/badge/irc-%23criterion-46BC99.svg)][irc-chan] | `#criterion` on irc.freenode.net
### Misc
* [autotools skeleton for projects with criterion tests][autotools]
* [CMake find module for Criterion][find-module]
## Credits
Logo made by [Paul Bouigue](http://www.cargocollective.com/pbouigue)
[online-docs]: http://criterion.readthedocs.org/
[pdf-docs]: http://readthedocs.org/projects/criterion/downloads/pdf/latest/
[zip-docs]: http://readthedocs.org/projects/criterion/downloads/htmlzip/latest/
[epub-docs]: http://readthedocs.org/projects/criterion/downloads/epub/latest/
[samples]: ./samples/
[sample-simple]: ./samples/simple.c
[sample-suites]: ./samples/suites.c
[sample-asserts]: ./samples/asserts.c
[sample-fixtures]: ./samples/fixtures.c
[sample-signal]: ./samples/signal.c
[sample-report]: ./samples/report.c
[autotools]: ./dev/autotools
[find-module]: ./dev/FindCriterion.cmake
[irc-chan]: http://webchat.freenode.net/?channels=%23criterion&uio=MTY9dHJ1ZSYyPXRydWUmOT10cnVlJjExPTE5NQ4e
[gitter-chan]: https://gitter.im/Snaipe/Criterion?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[mailing-list]: http://www.freelists.org/list/criterion

View File

@ -1,101 +0,0 @@
version: 2.3.0-rc1_b{build}-{branch}
os: Visual Studio 2015
environment:
COVERALLS_REPO_TOKEN:
secure: 5nuCg+faxFPeppoNNcSwVobswAVFUf8ut83vw8CX/4W2y0kZkGmwEfCUxSQWiQDU
CI_NAME: appveyor
CI_JOB_ID: $(APPVEYOR_JOB_ID)
GCOV_PREFIX: $(APPVEYOR_BUILD_FOLDER)
PYTHON_BIN: python
PYTHONIOENCODING: "utf-8" # consider cmd encoding to be unicode
CRAM_SHELL: "C:\\msys64\\usr\\bin\\sh.exe"
matrix:
- COMPILER: mingw
GENERATOR: "MSYS Makefiles"
BUILD_FLAGS: -j2
- COMPILER: msvc
GENERATOR: "Visual Studio 14 2015 Win64"
CFLAGS: /MP
CXXFLAGS: /MP
BUILD_FLAGS: /verbosity:m
init:
- git config --global core.autocrlf input
- set MSYSTEM=MINGW64
# Disable windows process crash popup
# See: https://msdn.microsoft.com/en-us/library/bb513638%28VS.85%29.aspx
- reg add "HKLM\SYSTEM\CurrentControlSet\Control\Windows" /f /v ErrorMode /t REG_DWORD /d 2
- reg add "HKLM\Software\Microsoft\Windows\Windows Error Reporting" /f /v DontShowUI /t REG_DWORD /d 1
- reg add "HKLM\Software\Microsoft\Windows\Windows Error Reporting" /f /v Disable /t REG_DWORD /d 1
- set PATH=C:\Python35;C:\Python35\Scripts;C:\msys64\mingw64\bin;C:\msys64\mingw32\bin;C:\msys64\usr\bin;%PATH%
- set PATH=%PATH%;%APPVEYOR_BUILD_FOLDER%\build;%APPVEYOR_BUILD_FOLDER%\build\Debug;%APPVEYOR_BUILD_FOLDER%\build\external\bin;%APPVEYOR_BUILD_FOLDER%\build\external\lib"
- set MSYSTEM=MINGW64
- pip install cram==0.7
# Remove Xamarin msbuild warnings
- del "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets"
clone_depth: 5
configuration:
- Debug
- RelWithDebInfo
install:
- ps: $env:RELEASE_NAME = $env:APPVEYOR_REPO_BRANCH -replace "/", "-"
# Hack to make git think it is on the tip of the repo branch
- 'git checkout -B %APPVEYOR_REPO_BRANCH%'
# Patch buggy cram
- sh -c "patch /c/Python35/lib/site-packages/cram/_test.py .cmake/cram-env.patch"
# Configure project
- 'mkdir build && cd build'
- >
cmake
-Wno-dev
-DCTESTS=ON
-DI18N=OFF
-DCMAKE_INSTALL_PREFIX="criterion-%RELEASE_NAME%"
-DCMAKE_BUILD_TYPE="%CONFIGURATION%"
%CMAKE_OPTS%
-G "%GENERATOR%"
..
build_script:
# open dummy fd 0 to prevent errors at configure time for autoconf dependencies
- cmake --build . -- %BUILD_FLAGS% 0<nul
before_deploy:
- ps: |
$archive = "criterion-$env:RELEASE_NAME-windows-$env:COMPILER-$env:PLATFORM"
cmake --build . --target install
7z a -ttar "$archive.tar" "criterion-$env:RELEASE_NAME"
7z a -tbzip2 "../$archive.tar.bz2" "$archive.tar"
Push-AppveyorArtifact "../$archive.tar.bz2"
test_script:
- cmake --build . --target criterion_tests
- ps: |
sh -c "ctest --output-on-failure --timeout 10"
if (-not $lastexitcode -eq 0) {
$host.setshouldexit(1)
}
#after_test:
# - 'make coveralls'
deploy:
provider: GitHub
auth_token:
secure: MnZZQeoxBVnpV9GSSvVok5Je0/N2d/fzG4+ITw95/tYSgZ8rleBV23a5sCwAea3r
artifact: 'criterion-$(RELEASE_NAME)-windows-$(COMPILER)-$(PLATFORM).tar.bz2'
draft: false
prerelease: false
on:
appveyor_repo_tag: true
configuration: RelWithDebInfo

View File

@ -1,25 +0,0 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Criterion
Upstream-Contact: Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
Source: http://github.com/Snaipe/Criterion
Files: *
Copyright: 2015-2016, Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
License: MIT
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

@ -1 +0,0 @@
Subproject commit 9f7ba3716c800a53639c9fe68fd453296f982c99

@ -1 +0,0 @@
Subproject commit 6b79ec8d8f8d4603111f580a0537f8f31c484c32

@ -1 +0,0 @@
Subproject commit 51e79a84fd91881d7424b28271c6dda4e0d97c11

1
dependencies/klib vendored

@ -1 +0,0 @@
Subproject commit cdb7e9236dc47abf8da7ebd702cc6f7f21f0c502

@ -1 +0,0 @@
Subproject commit 0d52904da5d7bd0a3eac3c47e9f9bb10cd78a26e

@ -1 +0,0 @@
Subproject commit 7e12a20e038234060d41d03c20721d08117f8607

1
dependencies/nanopb vendored

@ -1 +0,0 @@
Subproject commit 56f7c488df99ae655b47b5838055e48b886665a1

File diff suppressed because it is too large Load Diff

@ -1 +0,0 @@
Subproject commit 76a5d1ab15f684d4c9479a32624d65b3bd1a726b

View File

@ -1,23 +0,0 @@
Criterion is a dead-simple, yet extensible, C and C++ unit testing framework.
Most test frameworks for C require a lot of boilerplate code to
set up tests and test suites -- you need to create a main,
then register new test suites, then register the tests within
these suits, and finally call the right functions.
This gives the user great control, at the unfortunate cost of simplicity.
Criterion follows the KISS principle, while keeping the control
the user would have with other frameworks:
* C99 and C++11 compatible.
* Tests are automatically registered when declared.
* Implements a xUnit framework structure.
* A default entry point is provided, no need to declare a main
unless you want to do special handling.
* Test are isolated in their own process, crashes and signals can be
reported and tested.
* Unified interface between C and C++: include the criterion header and it *just* works.
* Supports parameterized tests and theories.
* Progress and statistics can be followed in real time with report hooks.
* TAP output format can be enabled with an option.

View File

@ -1,27 +0,0 @@
# This file is licensed under the WTFPL version 2 -- you can see the full
# license over at http://www.wtfpl.net/txt/copying/
#
# - Try to find Criterion
#
# Once done this will define
# CRITERION_FOUND - System has Criterion
# CRITERION_INCLUDE_DIRS - The Criterion include directories
# CRITERION_LIBRARIES - The libraries needed to use Criterion
find_package(PkgConfig)
find_path(CRITERION_INCLUDE_DIR criterion/criterion.h
PATH_SUFFIXES criterion)
find_library(CRITERION_LIBRARY NAMES criterion libcriterion)
set(CRITERION_LIBRARIES ${CRITERION_LIBRARY})
set(CRITERION_INCLUDE_DIRS ${CRITERION_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
# handle the QUIET and REQUIRED arguments and set CRITERION_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(Criterion DEFAULT_MSG
CRITERION_LIBRARY CRITERION_INCLUDE_DIR)
mark_as_advanced(CRITERION_INCLUDE_DIR CRITERION_LIBRARY)

View File

@ -1,14 +0,0 @@
# use the provided wrapper script to output things properly
LOG_COMPILER = $(top_srcdir)/build-aux/criterion-tap-test
# use the TAP log driver
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/build-aux/tap-driver.sh
check_PROGRAMS = criterion_tests
criterion_tests_SOURCES = simple.c
criterion_tests_LDFLAGS = -lcriterion
TESTS = criterion_tests
EXTRA_DIST = $(TESTS)

View File

@ -1,27 +0,0 @@
# Autotools skeleton
This is a project skeleton that uses criterion tests with the TAP test driver.
## Running the tests
The default setup assumes that criterion is installed on your system.
```
$ ./autogen.sh
$ mkdir build && cd build
$ ../configure
$ make check
```
## License
The project skeleton is licensed under the [wtfpl](http://www.wtfpl.net). Do
whatever you want with it.
### License clause
This program is free software. It comes without any warranty, to
the extent permitted by applicable law. You can redistribute it
and/or modify it under the terms of the Do What The Fuck You Want
To Public License, Version 2, as published by Sam Hocevar. See
http://www.wtfpl.net/ for more details.

View File

@ -1,17 +0,0 @@
#!/bin/sh -e
# copy TAP driver into build-aux
automake_ver=$(automake --version | \grep -E -o '[0-9]\.[0-9]{2}')
mkdir -p build-aux
cp -f /usr/share/automake-$automake_ver/tap-driver.sh build-aux
# create criterion TAP log compiler
# this is necessary to print TAP (and only TAP) on the standard output,
# and always exit with 0 to let the TAP driver handle errors itself.
echo >build-aux/criterion-tap-test """#!/bin/sh
\$1 -Otap:- --always-succeed 2>&1 >/dev/null
"""
chmod +x build-aux/criterion-tap-test
autoreconf -vi

View File

@ -1,15 +0,0 @@
AC_INIT([Criterion Autotools Tests], [1.0], [your@email.com])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
AC_CHECK_LIB([criterion], [criterion_initialize], [], [
AC_MSG_ERROR([unable to find Criterion])
], [])
AC_PROG_AWK
AC_PROG_CC
AC_CONFIG_FILES([Makefile])
AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_OUTPUT

View File

@ -1,9 +0,0 @@
#include <criterion/criterion.h>
Test(misc, failing) {
cr_assert(0);
}
Test(misc, passing) {
cr_assert(1);
}

File diff suppressed because it is too large Load Diff

25
doc/_static/style.css vendored
View File

@ -1,25 +0,0 @@
.breatheparameterlist li p {
display: inline;
}
.breatheenumvalues li p {
display: inline;
}
.container > dl > dt {
display: block;
width: 100%;
clear: both;
}
.container > dl > dt:before {
content: " ▼ ";
}
.container > dl > dt.open:before {
content: " ▶ ";
}
.container > dl {
margin-bottom: 0 !important; /* Dirty hack */
}

View File

@ -1,17 +0,0 @@
{% extends "!page.html" %}
{% set css_files = css_files + ["_static/style.css"] %}
{% block footer %}
<script type="text/javascript">
$(document).ready(function() {
$(".container > dl > *").hide();
$(".container > dl > dt").show();
$(".container > dl > dt").click(function() {
$(this).parent().children().not("dt").toggle(400);
$(this).parent().children("dt").toggleClass("open");
})
});
</script>
{% endblock %}

View File

@ -1,51 +0,0 @@
.. _assertions-ref:
Assertion reference
===================
This is an exhaustive list of all assertion macros that Criterion provides.
As each ``assert`` macros have an ``expect`` counterpart with the exact same
number of parameters and name suffix, there is no benefit in adding ``expect``
macros to this list. Hence only ``assert`` macros are represented here.
All ``assert`` macros may take an optional ``printf`` format string and
parameters.
Base Assertions
-----------------
.. doxygengroup:: BaseAsserts
Common Assertions
-----------------
.. doxygengroup:: CommonBinAsserts
.. doxygengroup:: CommonUnaryAsserts
.. doxygengroup:: FloatAsserts
String Assertions
-----------------
.. doxygengroup:: StringAsserts
Wide String Assertions
----------------------
.. doxygengroup:: WideStringAsserts
Array Assertions
-----------------
.. doxygengroup:: ArrayAsserts
.. doxygengroup:: SafeArrCmpAsserts
Exception Assertions
--------------------
.. doxygengroup:: ExceptionAsserts
File Assertions
---------------
.. doxygengroup:: FileAsserts

View File

@ -1,307 +0,0 @@
# -*- coding: utf-8 -*-
import sys
import os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "_ext")))
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# hack for readthedocs to cause it to run doxygen first
# https://github.com/rtfd/readthedocs.org/issues/388
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
if on_rtd:
from subprocess import call
call('doxygen')
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
'breathe',
]
breathe_projects = { "criterion-doxygen": "doxyxml/" }
breathe_default_project = "criterion-doxygen"
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'Criterion'
copyright = u'2015-2016, Franklin "Snaipe" Mathieu'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '2.3.0-rc1'
# The full version, including alpha/beta/rc tags.
release = version
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
#today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build', 'html', 'doctrees']
# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
#html_logo = None
# The name of an image file (within the static path) to use as favicon of the
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
#html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
# If false, no module index is generated.
#html_domain_indices = True
# If false, no index is generated.
#html_use_index = True
# If true, the index is split into individual pages for each letter.
#html_split_index = False
# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served.
#html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'CriterionDoc'
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'criterion.tex', u'Criterion Documentation',
u'Franklin "Snaipe" Mathieu', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False
# If true, show page references after internal links.
#latex_show_pagerefs = False
# If true, show URL addresses after external links.
#latex_show_urls = False
# Documents to append as an appendix to all manuals.
#latex_appendices = []
# If false, no module index is generated.
#latex_domain_indices = True
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'criterion', u'Criterion Documentation',
[u'Franklin "Snaipe" Mathieu'], 3)
]
# If true, show URL addresses after external links.
#man_show_urls = False
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'Criterion', u'Criterion Documentation',
u'Criterion', 'Criterion', '',
''),
]
# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# If false, no module index is generated.
#texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# -- Options for Epub output ---------------------------------------------------
# Bibliographic Dublin Core info.
epub_title = u'Criterion'
epub_author = u'Franklin "Snaipe" Mathieu'
epub_publisher = u'Franklin "Snaipe" Mathieu'
epub_copyright = copyright
# The language of the text. It defaults to the language option
# or en if the language is not set.
#epub_language = ''
# The scheme of the identifier. Typical schemes are ISBN or URL.
#epub_scheme = ''
# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#epub_identifier = ''
# A unique identification for the text.
#epub_uid = ''
# A tuple containing the cover image and cover page html template filenames.
#epub_cover = ()
# HTML files that should be inserted before the pages created by sphinx.
# The format is a list of tuples containing the path and title.
#epub_pre_files = []
# HTML files shat should be inserted after the pages created by sphinx.
# The format is a list of tuples containing the path and title.
#epub_post_files = []
# A list of files that should not be packed into the epub file.
#epub_exclude_files = []
# The depth of the table of contents in toc.ncx.
#epub_tocdepth = 3
# Allow duplicate toc entries.
#epub_tocdup = True
# Highlight PHP without starting <?php tag
from sphinx.highlighting import lexers
from pygments.lexers.c_cpp import CLexer
lexers['c'] = CLexer(startinline=True)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

View File

@ -1,61 +0,0 @@
Debugging and Coverage information
==================================
.. _gdb-ref:
Debugging with GDB
------------------
In one terminal do:
.. code-block:: bash
$ ./simple.c.bin --debug
Process simple.c.bin created; pid = 20803
Listening on port 1234
In another terminal connect to this debug session:
.. code-block:: bash
$ gdb -q ./test
Reading symbols from ./test...done.
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
0x00007ffff7dd9d90 in _start() from target:/lib64/ld-linux-x86-64.so.2
(gdb) continue
...
[Inferior 1 (process 25269) exited normally]
(gdb) q
After ``continue`` the first test is run:
.. code-block:: bash
Remote debugging from host 127.0.0.1
[RUN ] misc::failing
[----] /media/data/devel/Criterion/samples/simple.c:4: Assertion failed: The expression 0 is false.
[FAIL] misc::failing: (0,00s)
Child exited with status 0
And a new process is created for the next test:
.. code-block:: bash
Process /media/data/devel/Criterion/build/samples/simple.c.bin created; pid = 26414
Listening on port 1234
Connect your remote debugger to this test with ``remote target localhost:1234``
and run the test with ``continue``
To use a different port use ``--debug --debug-transport=<protocol>:<port>``
.. _coverage-ref:
Coverage of Criterion tests
---------------------------
To use gcov, you have to compile your tests with the two GCC Options
``-fprofile-arcs`` and ``ftest-coverage``.

View File

@ -1,102 +0,0 @@
Environment and CLI
===================
Tests built with Criterion expose by default various command line switchs
and environment variables to alter their runtime behaviour.
Command line arguments
----------------------
* ``-h or --help``: Show a help message with the available switches.
* ``-q or --quiet``: Disables all logging.
* ``-v or --version``: Prints the version of criterion that has been
linked against.
* ``-l or --list``: Print all the tests in a list.
* ``-f or --fail-fast``: Exit after the first test failure.
* ``--ascii``: Don't use fancy unicode symbols or colors in the output.
* ``-jN or --jobs N``: Use ``N`` parallel jobs to run the tests. ``0`` picks
a number of jobs ideal for your hardware configuration.
* ``--filter [PATTERN]``: Run tests whose string identifier matches
the given shell wildcard pattern (see dedicated section below). (\*nix only)
* ``--debug[=debugger]``: Run tests with a debugging server attached.
``debugger`` can be 'gdb', 'lldb', or 'windbg' (windows only).
* ``--debug-transport [TRANSPORT]``: Make the debugging server use the
specified remote transport. Only transports of the form ``tcp:port`` are
currently supported. ``tcp:1234`` is the default.
* ``--no-early-exit``: This flag is deprecated and no longer does anything.
* ``-S or --short-filename``: The filenames are displayed in their short form.
* ``--always-succeed``: The process shall exit with a status of ``0``.
* ``--tap[=FILE]``: Writes a TAP (Test Anything Protocol) report to FILE.
No file or ``"-"`` means ``stderr`` and implies ``--quiet``. This option is
equivalent to ``--output=tap:FILE``.
* ``--xml[=FILE]``: Writes JUnit4 XML report to FILE.
No file or ``"-"`` means ``stderr`` and implies ``--quiet``. This option is
equivalent to ``--output=tap:FILE``.
* ``--json[=FILE]``: Writes a JSON report to FILE.
No file or ``"-"`` means ``stderr`` and implies ``--quiet``. This option is
equivalent to ``--output=tap:FILE``.
* ``--verbose[=level]``: Makes the output verbose. When provided with an integer,
sets the verbosity level to that integer.
* ``-OPROVIDER:FILE or --output=PROVIDER:FILE``: Write a test report to FILE
using the output provider named by PROVIDER.
If FILE is ``"-"``, it implies ``--quiet``, and the report shall be written
to ``stderr``.
Shell Wildcard Pattern
----------------------
Extglob patterns in criterion are matched against a test's string identifier.
In the table below, a ``pattern-list`` is a list of patterns separated by ``|``.
Any extglob pattern can be constructed by combining any of the following
sub-patterns:
==================== ======================================================
Pattern Meaning
==================== ======================================================
``*`` matches everything
-------------------- ------------------------------------------------------
``?`` matches any character
-------------------- ------------------------------------------------------
``[seq]`` matches any character in *seq*
-------------------- ------------------------------------------------------
``[!seq]`` matches any character not in *seq*
-------------------- ------------------------------------------------------
``?(pattern-list)`` Matches zero or one occurrence of the given patterns
-------------------- ------------------------------------------------------
``*(pattern-list)`` Matches zero or more occurrences of the given patterns
-------------------- ------------------------------------------------------
``+(pattern-list)`` Matches one or more occurrences of the given patterns
-------------------- ------------------------------------------------------
``@(pattern-list)`` Matches one of the given patterns
-------------------- ------------------------------------------------------
``!(pattern-list)`` Matches anything except one of the given patterns
==================== ======================================================
A test string identifier is of the form ``suite-name/test-name``, so a pattern
of ``simple/*`` matches every tests in the ``simple`` suite, ``*/passing``
matches all tests named ``passing`` regardless of the suite, and ``*`` matches
every possible test.
Environment Variables
---------------------
Environment variables are alternatives to command line switches when set to 1.
* ``CRITERION_ALWAYS_SUCCEED``: Same as ``--always-succeed``.
* ``CRITERION_FAIL_FAST``: Same as ``--fail-fast``.
* ``CRITERION_USE_ASCII``: Same as ``--ascii``.
* ``CRITERION_JOBS``: Same as ``--jobs``. Sets the number of jobs to
its value.
* ``CRITERION_SHORT_FILENAME``: Same as ``--short-filename``.
* ``CRITERION_VERBOSITY_LEVEL``: Same as ``--verbose``. Sets the verbosity level
to its value.
* ``CRITERION_TEST_PATTERN``: Same as ``--pattern``. Sets the test pattern
to its value. (\*nix only)
* ``CRITERION_DISABLE_TIME_MEASUREMENTS``: Disables any time measurements on
the tests.
* ``CRITERION_OUTPUTS``: Can be set to a comma-separated list of
``PROVIDER:FILE`` entries. For instance, setting the variable to
``tap:foo.tap,xml:bar.xml`` has the same effect as specifying ``--tap=foo.tap``
and ``--xml=bar.xml`` at once.
* ``CRITERION_ENABLE_TAP``: (Deprecated, use CRITERION_OUTPUTS) Same as ``--tap``.

View File

@ -1,18 +0,0 @@
F.A.Q
=====
**Q. When running the test suite in Windows' cmd.exe, the test executable
prints weird characters, how do I fix that?**
A. Windows' ``cmd.exe`` is not an unicode ANSI-compatible terminal emulator.
There are plenty of ways to fix that behaviour:
* Pass ``--ascii`` to the test suite when executing.
* Define the ``CRITERION_USE_ASCII`` environment variable to ``1``.
* Get a better terminal emulator, such as the one shipped with Git or Cygwin.
**Q. I'm having an issue with the library, what can I do ?**
A. Open a new issue on the `github issue tracker <https://github.com/Snaipe/Criterion/issues>`_,
and describe the problem you are experiencing, along with the platform you are
running criterion on.

View File

@ -1,73 +0,0 @@
Report Hooks
============
Report hooks are functions that are called at key moments during the testing
process. These are useful to report statistics gathered during the execution.
A report hook can be declared using the ``ReportHook`` macro:
.. code-block:: c
#include <criterion/criterion.h>
#include <criterion/hooks.h>
ReportHook(Phase)() {
}
The macro takes a Phase parameter that indicates the phase at which the function
shall be run. Valid phases are described below.
.. note::
There are no guarantees regarding the order of execution of report hooks
on the same phase. In other words, all report hooks of a specific phase could
be executed in any order.
.. note::
Aborting the runner with any means (abort(), exit(), cr_assert(), ...) is
unsupported. If you need to abort the runner, you need to iterate all
subsequent tests and set their `disabled` field to 1.
Testing Phases
--------------
The flow of the test process goes as follows:
1. ``PRE_ALL``: occurs before running the tests.
#. ``PRE_SUITE``: occurs before a suite is initialized.
#. ``PRE_INIT``: occurs before a test is initialized.
#. ``PRE_TEST``: occurs after the test initialization, but before the test is run.
#. ``ASSERT``: occurs when an assertion is hit
#. ``THEORY_FAIL``: occurs when a theory iteration fails.
#. ``TEST_CRASH``: occurs when a test crashes unexpectedly.
#. ``POST_TEST``: occurs after a test ends, but before the test finalization.
#. ``POST_FINI``: occurs after a test finalization.
#. ``POST_SUITE``: occurs before a suite is finalized.
#. ``POST_ALL``: occurs after all the tests are done.
Hook Parameters
---------------
A report hook takes exactly one parameter.
Valid types for each phases are:
* ``struct criterion_test_set *`` for ``PRE_ALL``.
* ``struct criterion_suite_set *`` for ``PRE_SUITE``.
* ``struct criterion_test *`` for ``PRE_INIT`` and ``PRE_TEST``.
* ``struct criterion_assert_stats *`` for ``ASSERT``.
* ``struct criterion_theory_stats *`` for ``THEORY_FAIL``.
* ``struct criterion_test_stats *`` for ``POST_TEST``, ``POST_FINI``, and ``TEST_CRASH``.
* ``struct criterion_suite_stats *`` for ``POST_SUITE``.
* ``struct criterion_global_stats *`` for ``POST_ALL``.
For instance, this is a valid report hook declaration for the ``PRE_TEST`` phase:
.. code-block:: c
#include <criterion/criterion.h>
#include <criterion/hooks.h>
ReportHook(PRE_TEST)(struct criterion_test *test) {
// using the parameter
}

View File

@ -1,19 +0,0 @@
Criterion
=========
.. toctree::
:maxdepth: 2
intro
setup
starter
assert
hooks
logging
env
output
parameterized
theories
internal
debug
faq

View File

@ -1,86 +0,0 @@
Changing the internals
======================
Providing your own main
-----------------------
If you are not satisfied with the default CLI or environment variables, you
can define your own main function.
Configuring the test runner
~~~~~~~~~~~~~~~~~~~~~~~~~~~
First and foremost, you need to generate the test set; this is done by calling
``criterion_initialize()``. The function returns a ``struct criterion_test_set *``,
that you need to pass to ``criterion_run_all_tests`` later on.
At the very end of your main, you also need to call ``criterion_finalize`` with
the test set as parameter to free any ressources initialized by criterion earlier.
You'd usually want to configure the test runner before calling it.
Configuration is done by setting fields in a global variable named
``criterion_options`` (include criterion/options.h).
Here is an exhaustive list of these fields:
=================== ================================== ==============================================================
Field Type Description
=================== ================================== ==============================================================
logging_threshold enum criterion_logging_level The logging level
------------------- ---------------------------------- --------------------------------------------------------------
logger struct criterion_logger * The logger (see below)
------------------- ---------------------------------- --------------------------------------------------------------
always_succeed bool True iff criterion_run_all_tests should always returns 1
------------------- ---------------------------------- --------------------------------------------------------------
use_ascii bool True iff the outputs should use the ASCII charset
------------------- ---------------------------------- --------------------------------------------------------------
fail_fast bool True iff the test runner should abort after the first failure
------------------- ---------------------------------- --------------------------------------------------------------
pattern const char * The pattern of the tests that should be executed
=================== ================================== ==============================================================
if you want criterion to provide its own default CLI parameters and environment
variables handling, you can also call ``criterion_handle_args(int argc, char *argv[], bool handle_unknown_arg)``
with the proper ``argc/argv``. ``handle_unknown_arg``, if set to true, is here
to tell criterion to print its usage when an unknown CLI parameter is encountered.
If you want to add your own parameters, you should set it to false.
The function returns 0 if the main should exit immediately, and 1 if it should
continue.
Starting the test runner
~~~~~~~~~~~~~~~~~~~~~~~~
The test runner can be called with ``criterion_run_all_tests``. The function
returns 0 if one test or more failed, 1 otherwise.
Example main
~~~~~~~~~~~~
.. code-block:: c
#include <criterion/criterion.h>
int main(int argc, char *argv[]) {
struct criterion_test_set *tests = criterion_initialize();
int result = 0;
if (criterion_handle_args(argc, argv, true))
result = !criterion_run_all_tests(tests);
criterion_finalize(tests);
return result;
}
Implementing your own logger
----------------------------
In case you are not satisfied by the default logger, you can implement
yours. To do so, simply set the ``logger`` option to your custom
logger.
Each function contained in the structure is called during one of the standard
phase of the criterion runner.
For more insight on how to implement this, see other existing loggers
in ``src/log/``.

View File

@ -1,33 +0,0 @@
Introduction
============
Criterion is a dead-simple, non-intrusive unit testing framework for C and C++.
Philosophy
----------
Most test frameworks for C require a lot of boilerplate code to
set up tests and test suites -- you need to create a main,
then register new test suites, then register the tests within
these suits, and finally call the right functions.
This gives the user great control, at the unfortunate cost of simplicity.
Criterion follows the KISS principle, while keeping the control
the user would have with other frameworks.
Features
--------
* C99 and C++11 compatible.
* Tests are automatically registered when declared.
* Implements a xUnit framework structure.
* A default entry point is provided, no need to declare a main
unless you want to do special handling.
* Test are isolated in their own process, crashes and signals can be
reported and tested.
* Unified interface between C and C++: include the criterion header and it *just* works.
* Supports parameterized tests and theories.
* Progress and statistics can be followed in real time with report hooks.
* TAP output format can be enabled with an option.
* Runs on Linux, FreeBSD, Mac OS X, and Windows (Compiling with MinGW GCC and Visual Studio 2015+).

View File

@ -1,61 +0,0 @@
Logging messages
================
Sometimes, it might be useful to print some output from within a test
or fixture -- and while this can be done trivially with a ``printf``,
it doesn't integrate well with the current output, nor does it work
*at all* when the process is testing a redirected stdout.
For these cases, Criterion exposes a logging facility:
.. code-block:: c
#include <criterion/criterion.h>
#include <criterion/logging.h>
Test(suite_name, test_name) {
cr_log_info("This is an informational message. They are not displayed "
"by default.");
cr_log_warn("This is a warning. They indicate some possible malfunction "
"or misconfiguration in the test.");
cr_log_error("This is an error. They indicate serious problems and "
"are usually shown before the test is aborted.");
}
``cr_log_info``, ``cr_log_warn`` and ``cr_log_error`` are all macros expanding
to a call to the ``cr_log`` function. All of them take a mandatory format string,
followed by optional parameters; for instance:
.. code-block:: c
cr_log_info("%d + %d = %d", 1, 2, 3);
If using C++, the output stream objects ``info``, ``warn`` and ``error`` are
defined within the ``criterion::logging`` namespace, and can be used in
conjunction with ``operator<<``:
.. code-block:: c++
#include <criterion/criterion.h>
#include <criterion/logging.h>
using criterion::logging::info;
using criterion::logging::warn;
using criterion::logging::error;
Test(suite_name, test_name) {
info << "This is an informational message. "
<< "They are not displayed by default."
<< std::flush;
warn << "This is a warning. "
<< "They indicate some possible malfunction "
<< "or misconfiguration in the test."
<< std::flush;
error << "This is an error. "
<< "They indicate serious problems and "
<< "are usually shown before the test is aborted."
<< std::flush;
}
Note that empty messages are ignored, and newlines in the log message splits
the passed string into as many messages are there are lines.

View File

@ -1,44 +0,0 @@
Writing tests reports in a custom format
========================================
Outputs providers are used to write tests reports in the format of your choice:
for instance, TAP and XML reporting are implemented with output providers.
Adding a custom output provider
-------------------------------
An output provider is a function with the following signature:
.. code-block:: c
void func(FILE *out, struct criterion_global_stats *stats);
Once implemented, you then need to register it as an output provider:
.. code-block:: c
criterion_register_output_provider("provider name", func);
This needs to be done before the test runner stops, so you may want to register
it either in a self-provided main, or in a PRE_ALL or POST_ALL report hook.
Writing to a file with an output provider
-----------------------------------------
To tell criterion to write a report to a specific file using the output provider
of your choice, you can either pass ``--output`` as a command-line
parameter:
.. code-block:: bash
./my_tests --output="provider name":/path/to/file
Or, you can do so directly by calling ``criterion_add_output`` before the
runner stops:
.. code-block:: c
criterion_add_output("provider name", "/path/to/file");
The path may be relative. If ``"-"`` is passed as a filename, the report will
be written to ``stderr``.

View File

@ -1,177 +0,0 @@
Using parameterized tests
=========================
Parameterized tests are useful to repeat a specific test logic over a finite
set of parameters.
Due to limitations on how generated parameters are passed, parameterized tests
can only accept one pointer parameter; however, this is not that much of a
problem since you can just pass a structure containing the context you need.
Adding parameterized tests
--------------------------
Adding parameterized tests is done by defining the parameterized test function,
and the parameter generator function:
.. doxygengroup:: ParameterizedBase
.. code-block:: c
#include <criterion/parameterized.h>
ParameterizedTestParameters(suite_name, test_name) {
void *params;
size_t nb_params;
// generate parameter set
return cr_make_param_array(Type, params, nb_params);
}
ParameterizedTest(Type *param, suite_name, test_name) {
// contents of the test
}
``suite_name`` and ``test_name`` are the identifiers of the test suite and
the test, respectively. These identifiers must follow the language
identifier format.
``Type`` is the compound type of the generated array. ``params`` and ``nb_params``
are the pointer and the length of the generated array, respectively.
.. note::
The parameter array must be reachable after the function returns -- as
such, local arrays must be declared with `static` or dynamically allocated.
Passing multiple parameters
---------------------------
As said earlier, parameterized tests only take one parameter, so passing
multiple parameters is, in the strict sense, not possible. However, one can
easily use a struct to hold the context as a workaround:
.. code-block:: c
#include <criterion/parameterized.h>
struct my_params {
int param0;
double param1;
...
};
ParameterizedTestParameters(suite_name, test_name) {
static struct my_params params[] = {
// parameter set
};
size_t nb_params = sizeof (params) / sizeof (struct my_params);
return cr_make_param_array(struct my_params, params, nb_params);
}
ParameterizedTest(struct my_params *param, suite_name, test_name) {
// access param.param0, param.param1, ...
}
C++ users can also use a simpler syntax before returning an array of parameters:
.. code-block:: c++
ParameterizedTestParameters(suite_name, test_name) {
static struct my_params params[] = {
// parameter set
};
return criterion_test_params(params);
}
Dynamically allocating parameters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Any dynamic memory allocation done from a ParameterizedTestParameter function
**must** be done with ``cr_malloc``, ``cr_calloc``, or ``cr_realloc``.
Any pointer returned by those 3 functions must be passed to ``cr_free`` after
you have no more use of it.
It is undefined behaviour to use any other allocation function (such as ``malloc``)
from the scope of a ParameterizedTestParameter function.
In C++, these methods should not be called explicitely -- instead, you should
use:
* ``criterion::new_obj<Type>(params...)`` to allocate an object of type ``Type``
and call its constructor taking ``params...``.
The function possess the exact same semantics as ``new Type(params...)``.
* ``criterion::delete_obj(obj)`` to destroy an object previously allocated by
``criterion::new_obj``.
The function possess the exact same semantics as ``delete obj``.
* ``criterion::new_arr<Type>(size)`` to allocate an array of objects of type ``Type``
and length ``size``. ``Type`` is initialized by calling its default constructor.
The function possess the exact same semantics as ``new Type[size]``.
* ``criterion::delete_arr(array)`` to destroy an array previously allocated by
``criterion::new_arr``.
The function possess the exact same semantics as ``delete[] array``.
Furthermore, the ``criterion::allocator<T>`` allocator can be used with STL
containers to allocate memory with the functions above.
Freeing dynamically allocated parameter fields
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
One can pass an extra parameter to ``cr_make_param_array`` to specify
the cleanup function that should be called on the generated parameter context:
.. code-block:: c
#include <criterion/parameterized.h>
struct my_params {
int *some_int_ptr;
};
void cleanup_params(struct criterion_test_params *ctp) {
cr_free(((struct my_params *) ctp->params)->some_int_ptr);
}
ParameterizedTestParameters(suite_name, test_name) {
static my_params params[] = {{
.some_int_ptr = cr_malloc(sizeof (int));
}};
param[0].some_int_ptr = 42;
return cr_make_param_array(struct my_params, params, 1, cleanup_params);
}
C++ users can use a more convenient approach:
.. code-block:: c++
#include <criterion/parameterized.h>
struct my_params {
std::unique_ptr<int, decltype(criterion::free)> some_int_ptr;
my_params(int *ptr) : some_int_ptr(ptr, criterion::free) {}
};
ParameterizedTestParameters(suite_name, test_name) {
static criterion::parameters<my_params> params;
params.push_back(my_params(criterion::new_obj<int>(42)));
return params;
}
``criterion::parameters<T>`` is typedef'd as ``std::vector<T, criterion::allocator<T>>``.
Configuring parameterized tests
-------------------------------
Parameterized tests can optionally recieve configuration parameters to alter
their own behaviour, and are applied to each iteration of the parameterized
test individually (this means that the initialization and finalization runs once
per iteration).
Those parameters are the same ones as the ones of the ``Test`` macro function
(c.f. :ref:`test-config-ref`).

View File

@ -1 +0,0 @@
breathe

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

View File

@ -1,43 +0,0 @@
Setup
=====
Prerequisites
-------------
The library is supported on Linux, OS X, FreeBSD, and Windows.
The following compilers are supported to compile both the library and the tests:
* GCC 4.9+ (Can be relaxed to GCC 4.6+ when not using C++)
* Clang 3.4+
* MSVC 14+ (Included in Visual Studio 2015 or later)
Building from source
--------------------
.. code-block:: bash
$ mkdir build
$ cd build
$ cmake ..
$ cmake --build .
Installing the library and language files (Linux, OS X, FreeBSD)
----------------------------------------------------------------
From the build directory created above, run with an elevated shell:
.. code-block:: bash
$ make install
Usage
-----
To compile your tests with Criterion, you need to make sure to:
1. Add the include directory to the header search path
2. Install the library to your library search path
3. Link Criterion to your executable.
This should be all you need.

View File

@ -1,181 +0,0 @@
Getting started
===============
Adding tests
------------
Adding tests is done using the ``Test`` macro:
.. doxygendefine:: Test
Example:
.. code-block:: c
#include <criterion/criterion.h>
Test(suite_name, test_name) {
// test contents
}
``suite_name`` and ``test_name`` are the identifiers of the test suite and
the test, respectively. These identifiers must follow the language
identifier format.
Tests are automatically sorted by suite, then by name using the alphabetical
order.
Asserting things
----------------
Assertions come in two kinds:
* ``cr_assert*`` are assertions that are fatal to the current test if failed;
in other words, if the condition evaluates to ``false``, the test is
marked as a failure and the execution of the function is aborted.
* ``cr_expect*`` are, in the other hand, assertions that are not fatal to the
test. Execution will continue even if the condition evaluates to
``false``, but the test will be marked as a failure.
``cr_assert()`` and ``cr_expect()`` are the most simple kinds of assertions
criterion has to offer. They both take a mandatory condition as a first
parameter, and an optional failure message:
.. code-block:: c
#include <string.h>
#include <criterion/criterion.h>
Test(sample, test) {
cr_expect(strlen("Test") == 4, "Expected \"Test\" to have a length of 4.");
cr_expect(strlen("Hello") == 4, "This will always fail, why did I add this?");
cr_assert(strlen("") == 0);
}
On top of those, more assertions are available for common operations. See
:ref:`assertions-ref` for a complete list.
Configuring tests
-----------------
Tests may receive optional configuration parameters to alter their behaviour
or provide additional metadata.
Fixtures
~~~~~~~~
Tests that need some setup and teardown can register functions that will
run before and after the test function:
.. code-block:: c
#include <stdio.h>
#include <criterion/criterion.h>
void setup(void) {
puts("Runs before the test");
}
void teardown(void) {
puts("Runs after the test");
}
Test(suite_name, test_name, .init = setup, .fini = teardown) {
// test contents
}
If a setup crashes, you will get a warning message, and the test will be aborted
and marked as a failure.
Is a teardown crashes, you will get a warning message, and the test will keep
its result.
Testing signals
~~~~~~~~~~~~~~~
If a test receives a signal, it will by default be marked as a failure.
You can, however, expect a test to only pass if a special kind of signal
is received:
.. code-block:: c
#include <stddef.h>
#include <signal.h>
#include <criterion/criterion.h>
// This test will fail
Test(sample, failing) {
int *ptr = NULL;
*ptr = 42;
}
// This test will pass
Test(sample, passing, .signal = SIGSEGV) {
int *ptr = NULL;
*ptr = 42;
}
This feature will also work (to some extent) on Windows for the
following signals on some exceptions:
======== =====================================================================
Signal Triggered by
======== =====================================================================
SIGSEGV STATUS_ACCESS_VIOLATION, STATUS_DATATYPE_MISALIGNMENT,
STATUS_ARRAY_BOUNDS_EXCEEDED, STATUS_GUARD_PAGE_VIOLATION,
STATUS_IN_PAGE_ERROR, STATUS_NO_MEMORY, STATUS_INVALID_DISPOSITION,
STATUS_STACK_OVERFLOW
-------- ---------------------------------------------------------------------
SIGILL STATUS_ILLEGAL_INSTRUCTION, STATUS_PRIVILEGED_INSTRUCTION,
STATUS_NONCONTINUABLE_EXCEPTION
-------- ---------------------------------------------------------------------
SIGINT STATUS_CONTROL_C_EXIT
-------- ---------------------------------------------------------------------
SIGFPE STATUS_FLOAT_DENORMAL_OPERAND, STATUS_FLOAT_DIVIDE_BY_ZERO,
STATUS_FLOAT_INEXACT_RESULT, STATUS_FLOAT_INVALID_OPERATION,
STATUS_FLOAT_OVERFLOW, STATUS_FLOAT_STACK_CHECK,
STATUS_FLOAT_UNDERFLOW, STATUS_INTEGER_DIVIDE_BY_ZERO,
STATUS_INTEGER_OVERFLOW
-------- ---------------------------------------------------------------------
SIGALRM STATUS_TIMEOUT
======== =====================================================================
See the `windows exception reference`_ for more details on each exception.
.. _windows exception reference: https://msdn.microsoft.com/en-us/library/windows/desktop/ms679356(v=vs.85).aspx
.. _test-config-ref:
Configuration reference
~~~~~~~~~~~~~~~~~~~~~~~
Here is an exhaustive list of all possible configuration parameters you can
pass:
.. doxygenstruct:: criterion_test_extra_data
:members:
Setting up suite-wise configuration
-----------------------------------
Tests under the same suite can have a suite-wise configuration -- this is done
using the ``TestSuite`` macro:
.. doxygendefine:: TestSuite
Example:
.. code-block:: c
#include <criterion/criterion.h>
TestSuite(suite_name, [params...]);
Test(suite_name, test_1) {
}
Test(suite_name, test_2) {
}
Configuration parameters are the same as above, but applied to the suite itself.
Suite fixtures are run *along with* test fixtures.

View File

@ -1,221 +0,0 @@
Using theories
==============
`Theories`_ are a powerful tool for test-driven development, allowing you
to test a specific behaviour against all permutations of a set of user-defined
parameters known as "data points".
.. _Theories: http://web.archive.org/web/20110608210825/http://shareandenjoy.saff.net/tdd-specifications.pdf
Adding theories
---------------
.. doxygengroup:: TheoryBase
Adding theories is done by defining data points and a theory function:
.. code-block:: c
#include <criterion/theories.h>
TheoryDataPoints(suite_name, test_name) = {
DataPoints(Type0, val0, val1, val2, ..., valN),
DataPoints(Type1, val0, val1, val2, ..., valN),
...
DataPoints(TypeN, val0, val1, val2, ..., valN),
}
Theory((Type0 arg0, Type1 arg1, ..., TypeN argN), suite_name, test_name) {
}
``suite_name`` and ``test_name`` are the identifiers of the test suite and
the test, respectively. These identifiers must follow the language
identifier format.
``Type0/arg0`` through ``TypeN/argN`` are the parameter types and names of theory
theory function and are available in the body of the function.
Datapoints are declared in the same number, type, and order than the parameters
inside the ``TheoryDataPoints`` macro, with the ``DataPoints`` macro.
Beware! It is undefined behaviour to not have a matching number and type of
theory parameters and datatypes.
Each ``DataPoints`` must then specify the values that will be used for the
theory parameter it is linked to (``val0`` through ``valN``).
Assertions and invariants
-------------------------
You can use any ``cr_assert`` or ``cr_expect`` macro functions inside the body of a
theory function.
Theory invariants are enforced through the ``cr_assume(Condition)`` macro function:
if ``Condition`` is false, then the current theory iteration aborts without
making the test fail.
On top of those, more ``assume`` macro functions are available for common operations:
.. doxygengroup:: TheoryInvariants
Configuring theories
--------------------
Theories can optionally recieve configuration parameters to alter the behaviour
of the underlying test; as such, those parameters are the same ones as the ones
of the ``Test`` macro function (c.f. :ref:`test-config-ref`).
Full sample & purpose of theories
---------------------------------
We will illustrate how useful theories are with a simple example using Criterion:
The basics of theories
~~~~~~~~~~~~~~~~~~~~~~
Let us imagine that we want to test if the algebraic properties of integers,
and specifically concerning multiplication, are respected by the C language:
.. code-block:: c
int my_mul(int lhs, int rhs) {
return lhs * rhs;
}
Now, we know that multiplication over integers is commutative, so we first test
that:
.. code-block:: c
#include <criterion/criterion.h>
Test(algebra, multiplication_is_commutative) {
cr_assert_eq(my_mul(2, 3), my_mul(3, 2));
}
However, this test is imperfect, because there is not enough triangulation to
insure that my_mul is indeed commutative. One might be tempted to add more
assertions on other values, but this will never be good enough: commutativity
should work for *any* pair of integers, not just an arbitrary set, but, to be
fair, you cannot just test this behaviour for every integer pair that exists.
Theories purposely bridge these two issues by introducing the concept of
"data point" and by refactoring the repeating logic into a dedicated function:
.. code-block:: c
#include <criterion/theories.h>
TheoryDataPoints(algebra, multiplication_is_commutative) = {
DataPoints(int, [...]),
DataPoints(int, [...]),
};
Theory((int lhs, int rhs), algebra, multiplication_is_commutative) {
cr_assert_eq(my_mul(lhs, rhs), my_mul(rhs, lhs));
}
As you can see, we refactored the assertion into a theory taking two unspecified
integers.
We first define some data points in the same order and type the parameters have,
from left to right: the first ``DataPoints(int, ...)`` will define the set of values passed
to the ``int lhs`` parameter, and the second will define the one passed to ``int rhs``.
Choosing the values of the data point is left to you, but we might as well use
"interesting" values: ``0``, ``-1``, ``1``, ``-2``, ``2``, ``INT_MAX``, and ``INT_MIN``:
.. code-block:: c
#include <limits.h>
TheoryDataPoints(algebra, multiplication_is_commutative) = {
DataPoints(int, 0, -1, 1, -2, 2, INT_MAX, INT_MIN),
DataPoints(int, 0, -1, 1, -2, 2, INT_MAX, INT_MIN),
};
Using theory invariants
~~~~~~~~~~~~~~~~~~~~~~~
The second thing we can test on multiplication is that it is the inverse function
of division. Then, given the division operation:
.. code-block:: c
int my_div(int lhs, int rhs) {
return lhs / rhs;
}
The associated theory is straight-forward:
.. code-block:: c
#include <criterion/theories.h>
TheoryDataPoints(algebra, multiplication_is_inverse_of_division) = {
DataPoints(int, 0, -1, 1, -2, 2, INT_MAX, INT_MIN),
DataPoints(int, 0, -1, 1, -2, 2, INT_MAX, INT_MIN),
};
Theory((int lhs, int rhs), algebra, multiplication_is_inverse_of_division) {
cr_assert_eq(lhs, my_div(my_mul(lhs, rhs), rhs));
}
However, we do have a problem because you cannot have the theory function divide
by 0. For this purpose, we can ``assume`` than ``rhs`` will never be 0:
.. code-block:: c
Theory((int lhs, int rhs), algebra, multiplication_is_inverse_of_division) {
cr_assume(rhs != 0);
cr_assert_eq(lhs, my_div(my_mul(lhs, rhs), rhs));
}
``cr_assume`` will abort the current theory iteration if the condition is not
fulfiled.
Running the test at that point will raise a big problem with the current
implementation of ``my_mul`` and ``my_div``:
.. code-block:: none
[----] theories.c:24: Assertion failed: (a) == (bad_div(bad_mul(a, b), b))
[----] Theory algebra::multiplication_is_inverse_of_division failed with the following parameters: (2147483647, 2)
[----] theories.c:24: Assertion failed: (a) == (bad_div(bad_mul(a, b), b))
[----] Theory algebra::multiplication_is_inverse_of_division failed with the following parameters: (-2147483648, 2)
[----] theories.c:24: Unexpected signal caught below this line!
[FAIL] algebra::multiplication_is_inverse_of_division: CRASH!
The theory shows that ``my_div(my_mul(INT_MAX, 2), 2)`` and ``my_div(my_mul(INT_MIN, 2), 2)``
does not respect the properties for multiplication: it happens that the
behaviour of these two functions is undefined because the operation overflows.
Similarly, the test crashes at the end; debugging shows that the source of the
crash is the divison of INT_MAX by -1, which is undefined.
Fixing this is as easy as changing the prototypes of ``my_mul`` and ``my_div``
to operate on ``long long`` rather than ``int``.
What's the difference between theories and parameterized tests ?
----------------------------------------------------------------
While it may at first seem that theories and parameterized tests are the same,
just because they happen to take multiple parameters does not mean that they
logically behave in the same manner.
Parameterized tests are useful to test a specific logic against a fixed, *finite*
set of examples that you need to work.
Theories are, well, just that: theories. They represent a test against an
universal truth, regardless of the input data matching its predicates.
Implementation-wise, Criterion also marks the separation by the way that both
are executed:
Each parameterized test iteration is run in its own test; this means that
one parameterized test acts as a collection of many tests, and gets reported
as such.
On the other hand, a theory act as one single test, since the size and contents
of the generated data set is not relevant. It does not make sense to say that
an universal truth is "partially true", so if one of the iteration fails, then
the whole test fails.

BIN
images/body-bg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
images/code.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

BIN
images/download-button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
images/github-button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
images/header-bg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

BIN
images/highlight-bg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
images/pattern.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

BIN
images/sidebar-bg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
images/tar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

BIN
images/top.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

BIN
images/zip.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 337 B

View File

@ -1,66 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file
* @brief Functions to abort and continue tests
*****************************************************************************/
#ifndef CRITERION_ABORT_H_
#define CRITERION_ABORT_H_
#include "internal/common.h"
CR_BEGIN_C_API
/**
* Aborts the current test, marking it as failed.
*
* This function does not return.
*/
CR_API CR_NORETURN void criterion_abort_test(void);
/**
* Aborts the current test, marking it as skipped.
*
* This function does not return.
*/
CR_API CR_NORETURN void criterion_skip_test(const char *format, ...);
/**
* Continues the current test.
*
* Used as a counterpart to criterion_abort_test.
*/
CR_API void criterion_continue_test(void);
/**
* Kills the current test, marking it as failed.
*
* @param[in] msg printf like format string
* @param[in] ... Additional arguments depending on msg
*/
CR_API void criterion_test_die(const char *msg, ...);
CR_END_C_API
#endif /* !CRITERION_ABORT_H_ */

View File

@ -1,278 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file
* @brief Test intern memory managment
*****************************************************************************/
#ifndef CRITERION_ALLOC_H_
#define CRITERION_ALLOC_H_
#ifdef __cplusplus
# include <memory>
# include <cstddef>
using std::size_t;
#else
# include <stddef.h>
#endif
#include "internal/common.h"
CR_BEGIN_C_API
/**
* Allocates a block of memory usable by the test.
*
* It is undefined behaviour to access a pointer returned by malloc(3)
* inside a test or its setup and teardown functions; cr_malloc must
* be use in its place for this purpose.
*
* This function is semantically identical to malloc(3).
*
* @param[in] size The minimal size in bytes of the newly allocated memory.
* @returns The pointer to the start of the allocated memory.
*/
CR_API void *cr_malloc(size_t size);
/**
* Allocates and zero-initialize a block of memory usable by the test.
*
* It is undefined behaviour to access a pointer returned by calloc(3)
* inside a test or its setup and teardown functions; cr_calloc must
* be use in its place for this purpose.
*
* This function is semantically identical to calloc(3).
*
* @param[in] nmemb The number of elements to allocate
* @param[in] size The minimal size of each element.
* @returns The pointer to the start of the allocated memory.
*/
CR_API void *cr_calloc(size_t nmemb, size_t size);
/**
* Reallocates a block of memory usable by the test.
*
* It is undefined behaviour to access a pointer returned by realloc(3)
* inside a test or its setup and teardown functions; cr_realloc must
* be used in its place for this purpose.
*
* This function is semantically identical to realloc(3).
*
* @param[in] ptr A pointer to the memory that needs to be resized.
* @param[in] size The minimal size of the reallocated memory.
* @returns The pointer to the start of the reallocated memory.
*/
CR_API void *cr_realloc(void *ptr, size_t size);
/**
* Free a block of memory allocated by cr_malloc, cr_free or cr_realloc.
*
* @param[in] ptr A pointer to the memory that needs to be freed.
*/
CR_API void cr_free(void *ptr);
CR_END_C_API
#ifdef __cplusplus
# include <type_traits>
namespace criterion
{
void *(*const malloc)(size_t) = cr_malloc;
void(*const free)(void *) = cr_free;
void *(*const calloc)(size_t, size_t) = cr_calloc;
void *(*const realloc)(void *, size_t) = cr_realloc;
/**
* Allocates and construct a new object.
*
* It is undefined behaviour to access a pointer returned by the new
* operator inside a test or its setup and teardown functions;
* new_obj must be used in its place for this purpose.
*
* This function is semantically identical to the new operator.
*
* @tparam T The type of the object to construct
* @param[in] params The constructor parameters of T.
* @returns The pointer to the newly constructed object.
*/
template <typename T, typename... Params>
T *new_obj(Params... params)
{
T *obj = static_cast<T *>(cr_malloc(sizeof (T)));
new (obj) T(params...);
return obj;
}
/**
* Allocates and construct a new array of primitive types
*
* It is undefined behaviour to access a pointer returned by the new[]
* operator inside a test or its setup and teardown functions;
* new_arr must be used in its place for this purpose.
*
* This function is semantically identical to the new[] operator.
*
* @tparam T The compound type of the array to construct
* @param[in] len The length of the array.
* @returns The pointer to the newly constructed array.
*/
template <typename T>
typename std::enable_if<std::is_fundamental<T>::value>::type
* new_arr(size_t len) {
void *ptr = cr_malloc(sizeof (size_t) + sizeof (T) * len);
*(reinterpret_cast<size_t *>(ptr)) = len;
T *arr = reinterpret_cast<T *>(reinterpret_cast<size_t *>(ptr) + 1);
return arr;
}
/**
* Allocates and construct a new array of object types
*
* It is undefined behaviour to access a pointer returned by the new[]
* operator inside a test or its setup and teardown functions;
* new_arr must be used in its place for this purpose.
*
* This function is semantically identical to the new[] operator.
*
* @tparam T The compound type of the array to construct
* @param[in] len The length of the array.
* @returns The pointer to the newly constructed array.
*/
template <typename T>
T *new_arr(size_t len)
{
void *ptr = cr_malloc(sizeof (size_t) + sizeof (T) * len);
*(reinterpret_cast<size_t *>(ptr)) = len;
T *arr = reinterpret_cast<T *>(reinterpret_cast<size_t *>(ptr) + 1);
for (size_t i = 0; i < len; ++i)
new (arr + i)T();
return arr;
}
/**
* Destroys and frees an object allocated by new_obj.
*
* This function is semantically identical to the delete operator.
*
* @tparam T The type of the object to construct
* @param[in] ptr The object to destroy.
*/
template <typename T>
void delete_obj(T *ptr)
{
ptr->~T();
cr_free(ptr);
}
/**
* Destroys and frees an array allocated by delete_arr.
*
* This function is semantically identical to the delete[] operator.
*
* @tparam T The type of the object to construct
* @param[in] ptr The object to destroy.
*/
template <typename T>
void delete_arr(typename std::enable_if<std::is_fundamental<T>::value>::type *ptr)
{
cr_free(ptr);
}
/**
* Destroys and frees an array allocated by delete_arr.
*
* This function is semantically identical to the delete[] operator.
*
* @tparam T The type of the object to construct
* @param[in] ptr The object to destroy.
*/
template <typename T>
void delete_arr(T *ptr)
{
size_t *ptr_ = reinterpret_cast<size_t *>(ptr);
size_t len = *(ptr_ - 1);
T *arr = reinterpret_cast<T *>(ptr_);
for (size_t i = 0; i < len; ++i)
arr[i].~T();
cr_free(ptr_ - 1);
}
/**
* Allocator for use in the STL.
*
* This internally uses calls to the cr_malloc function family, which
* means that STL collections can be safely used inside tests or
* setup/teardown functions if this allocator is used.
*/
template <typename T>
struct allocator {
typedef T value_type;
typedef value_type *pointer;
typedef const value_type *const_pointer;
typedef value_type &reference;
typedef const value_type &const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
template <typename U>
struct rebind {
typedef allocator<U> other;
};
inline explicit allocator() {}
inline ~allocator() {}
inline explicit allocator(allocator const &) {}
template <typename U>
inline explicit allocator(allocator<U> const &) {}
inline pointer address(reference r) { return &r; }
inline const_pointer address(const_reference r) { return &r; }
inline pointer allocate(size_type cnt, typename std::allocator<void>::const_pointer = 0)
{
return reinterpret_cast<pointer>(cr_malloc(cnt * sizeof (T)));
}
inline void deallocate(pointer p, size_type) { cr_free(p); }
inline size_type max_size() const
{
return size_type(-1) / sizeof (T);
}
inline void construct(pointer p, const T &t) { new(p) T(t); }
inline void construct(pointer p, T &&t) { new (p) T(std::move(t)); }
inline void destroy(pointer p) { p->~T(); }
inline bool operator==(allocator const &) { return true; }
inline bool operator!=(allocator const &a) { return !operator==(a); }
};
}
#endif
#endif /* !CRITERION_ALLOC_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -1,121 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file
* @brief Include this to use criterion
*****************************************************************************/
#ifndef CRITERION_H_
#define CRITERION_H_
#include "types.h"
#include "assert.h"
#include "alloc.h"
/**
* Defines a new test.
*
* @param Suite The name of the test suite containing this test.
* @param Name The name of the test.
* @param ... An optional sequence of designated initializer key/value
* pairs as described in the `criterion_test_extra_data` structure
* (see criterion/types.h).\n
* Example: .exit_code = 1
*/
#define Test(Suite, Name, ...) internal
/**
* Explicitely defines a test suite and its options.
*
* @param Name The name of the test suite.
* @param ... An optional sequence of designated initializer key/value
* pairs as described in the `criterion_test_extra_data` structure
* (see criterion/types.h).
* These options will provide the defaults for each test.
*/
#define TestSuite(Name, ...) internal
CR_BEGIN_C_API
/**
* Initializes criterion and builds a set of all discovered tests.
*
* Using any of the functions and macros provided by criterion before calling
* this results in undefined behaviour.
*
* @returns the set of tests
*/
CR_API struct criterion_test_set *criterion_initialize(void);
/**
* Release all resources allocated by criterion.
*
* Using any of the functions and macros provided by criterion except
* criterion_initialize after this function is called results in undefined
* behaviour.
*/
CR_API void criterion_finalize(struct criterion_test_set *tests);
/**
* Run all the tests in the test set.
*
* @param[in] tests The set of tests that are to be executed.
*
* @returns 1 if all tests succeeded or criterion_options.always_succeed
* is true, 0 otherwise.
*/
CR_API int criterion_run_all_tests(struct criterion_test_set *tests);
/**
* Handles all default command-line parameters, as documented in:
* <http://criterion.readthedocs.org/en/latest/env.html>, and appropriately
* sets criterion_options.
*
* @param[in] argc The number of arguments in argv.
* @param[in] argv A null-terminated array of strings representing the arguments.
* @param[in] handle_unknown_arg Whether the function should print a message
* and exit when an unknown parameter is encountered. Use false if you want
* to handle additional parameters yourself.
*
* @returns 0 if the process should exit immediately after, for instance after
* printing the help message.
*/
CR_API int criterion_handle_args(int argc, char *argv[], bool handle_unknown_arg);
/**
* Manually registers a new test within the specified test set.
*
* @param[in] tests The set of tests you want to insert the test in.
* @param[in] test The newly created test.
*/
CR_API void criterion_register_test(struct criterion_test_set *tests,
struct criterion_test *test);
CR_API extern const struct criterion_test *const criterion_current_test;
CR_API extern const struct criterion_suite *const criterion_current_suite;
CR_END_C_API
#include "internal/test.h"
#endif /* !CRITERION_H_ */

View File

@ -1,48 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CRITERION_EMBEDDED_H_
#define CRITERION_EMBEDDED_H_
typedef signed long long int cr_ssize;
typedef unsigned long long int cr_size;
typedef unsigned char cr_byte;
typedef int cr_err;
typedef struct cr_io_ctx cr_io_ctx;
struct cr_embed_vtable {
cr_err (*init)(struct cr_io_ctx *ctx);
cr_ssize (*send)(const cr_byte *buf, cr_size size);
cr_ssize (*recv)(cr_byte *buf, cr_size size);
cr_err (*term)(struct cr_io_ctx *ctx);
};
struct cr_embed_properties {
struct cr_embed_vtable vtable;
struct cr_io_ctx *ctx;
};
int cr_embed_init(struct cr_embed_properties *props);
int cr_embed_term(struct cr_embed_properties *props);
#endif /* !CRITERION_EMBEDDED_H_ */

View File

@ -1,41 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CRITERION_EVENT_H_
#define CRITERION_EVENT_H_
#ifdef __cplusplus
# include <cstddef>
#else
# include <stddef.h>
#endif
#include "internal/common.h"
#include "stats.h"
CR_BEGIN_C_API
CR_API void criterion_send_assert(struct criterion_assert_stats *stats);
CR_END_C_API
#endif /* !CRITERION_EVENT_H_ */

View File

@ -1,72 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @file
* @brief Report hooks
*****************************************************************************/
#ifndef CRITERION_HOOKS_H_
#define CRITERION_HOOKS_H_
#include "internal/hooks.h"
/**
* This enum lists all the phases of the runner lifecycle.
*/
typedef enum {
PRE_ALL,
PRE_SUITE,
PRE_INIT,
PRE_TEST,
ASSERT,
THEORY_FAIL,
TEST_CRASH,
POST_TEST,
POST_FINI,
POST_SUITE,
POST_ALL,
} e_report_status;
typedef void (*f_report_hook)();
/**
* ReportHook(Kind)(Type *param) { Function Body }
*
* Defines a report hook for the phase defined by Kind.
*
* The type of the parameter depends on the phase:
*
* - struct criterion_test_set for PRE_ALL.
* - struct criterion_suite_set for PRE_SUITE.
* - struct criterion_test for PRE_INIT and PRE_TEST.
* - struct criterion_assert_stats for ASSERT.
* - struct criterion_theory_stats for THEORY_FAIL.
* - struct criterion_test_stats for POST_TEST, POST_FINI, and TEST_CRASH.
* - struct criterion_suite_stats for POST_SUITE.
* - struct criterion_global_stats for POST_ALL.
*
* @param Kind The report phase to hook the function onto.
*/
#define ReportHook(Kind) CR_REPORT_HOOK_IMPL(Kind)
#endif /* !CRITERION_HOOKS_H_ */

View File

@ -1,44 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CRITERION_ASPRINTF_COMPAT_H_
#define CRITERION_ASPRINTF_COMPAT_H_
#ifdef __cplusplus
# include <cstdarg>
#else
# include <stdarg.h>
#endif
#include "common.h"
CR_BEGIN_C_API
CR_FORMAT(printf, 2, 3)
CR_API int cr_asprintf(char **strp, const char *fmt, ...);
CR_API int cr_vasprintf(char **strp, const char *fmt, va_list ap);
CR_API void cr_asprintf_free(char *buf);
CR_END_C_API
#endif /* !CRITERION_ASPRINTF_COMPAT_H_ */

View File

@ -1,717 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CRITERION_INTERNAL_ASSERT_H_
#define CRITERION_INTERNAL_ASSERT_H_
#include "common.h"
#include "preprocess.h"
#include "asprintf-compat.h"
#include "designated-initializer-compat.h"
#ifdef __cplusplus
# include <cstring>
# include <cstdlib>
# include <cwchar>
#else
# include <string.h>
# include <stdlib.h>
# include <stdbool.h>
# include <wchar.h>
#endif
#include "../types.h"
#include "../stats.h"
#include "../hooks.h"
#include "../event.h"
#include "../abort.h"
struct criterion_assert_args {
const char *msg;
int sentinel_;
#ifdef __cplusplus
constexpr criterion_assert_args(const char *msg) : msg(msg), sentinel_(0) {}
constexpr criterion_assert_args(const char *msg, int sentinel_) : msg(msg), sentinel_(sentinel_) {}
#endif
};
/* Do NOT reorder unless you want to break the ABI */
enum criterion_assert_messages {
CRITERION_ASSERT_MSG_FAIL,
CRITERION_ASSERT_MSG_EXPR_FALSE,
CRITERION_ASSERT_MSG_EXPR_AS_STRINGS_FALSE,
CRITERION_ASSERT_MSG_IS_NULL,
CRITERION_ASSERT_MSG_IS_NOT_NULL,
CRITERION_ASSERT_MSG_IS_EMPTY,
CRITERION_ASSERT_MSG_IS_NOT_EMPTY,
CRITERION_ASSERT_MSG_FILE_STR_MATCH,
CRITERION_ASSERT_MSG_FILE_MATCH,
CRITERION_ASSERT_MSG_THROW,
CRITERION_ASSERT_MSG_NO_THROW,
CRITERION_ASSERT_MSG_ANY_THROW,
CRITERION_ASSERT_MSG_NONE_THROW,
};
CR_BEGIN_C_API
CR_API char *cr_translate_assert_msg(int msg_index, ...);
CR_END_C_API
#define CR_GET_CONDITION(Condition, ...) Condition
#define CR_GET_CONDITION_STR(Condition, ...) #Condition
#define CR_VA_SKIP(_, ...) __VA_ARGS__
#define CR_TRANSLATE_DEF_MSG__(Arg) \
CR_IDENTITY Arg
#define CR_TRANSLATE_DEF_MSG_(...) \
CR_EXPAND(cr_translate_assert_msg( \
CR_VA_HEAD(__VA_ARGS__), \
"" CR_TRANSLATE_DEF_MSG__(CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__))) \
))
#define CR_INIT_STATS_(MsgVar, Shifted, ...) \
CR_EXPAND( \
do { \
char *cr_def_msg__ = CR_EXPAND(CR_TRANSLATE_DEF_MSG_(__VA_ARGS__)); \
char *cr_fmt_msg__ = NULL; \
cr_asprintf(&cr_fmt_msg__, "x" CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__))); \
if (cr_fmt_msg__ && cr_fmt_msg__[1]) { \
MsgVar = cr_fmt_msg__ + 1; \
Shifted = 1; \
cr_asprintf_free(cr_def_msg__); \
} else { \
MsgVar = cr_def_msg__; \
cr_asprintf_free(cr_fmt_msg__); \
} \
} while (0))
#define CR_FAIL_ABORT_ criterion_abort_test
#define CR_FAIL_CONTINUES_ criterion_continue_test
#define cr_assert_impl(Fail, Condition, ...) \
do { \
bool cr_passed__ = !!(Condition); \
char *cr_msg__ = NULL; \
int cr_shifted__ = 0; \
\
CR_EXPAND(CR_INIT_STATS_(cr_msg__, cr_shifted__, \
CR_VA_TAIL(__VA_ARGS__))); \
struct criterion_assert_stats cr_stat__; \
cr_stat__.passed = cr_passed__; \
cr_stat__.file = __FILE__; \
cr_stat__.line = __LINE__; \
cr_stat__.message = cr_msg__; \
criterion_send_assert(&cr_stat__); \
\
cr_asprintf_free(cr_msg__ - cr_shifted__); \
\
if (!cr_passed__) \
Fail(); \
} while (0)
#define cr_fail(Fail, ...) \
CR_EXPAND(cr_assert_impl( \
Fail, \
0, \
dummy, \
CRITERION_ASSERT_MSG_FAIL, \
(), \
__VA_ARGS__ \
))
#define cr_skip(...) \
criterion_skip_test("" __VA_ARGS__)
#define cr_assert_(...) \
CR_EXPAND(cr_assert_impl( \
CR_FAIL_ABORT_, \
CR_VA_HEAD(__VA_ARGS__), \
dummy, \
CRITERION_ASSERT_MSG_EXPR_FALSE, \
(CR_STR(CR_VA_HEAD(__VA_ARGS__))), \
CR_VA_TAIL(__VA_ARGS__) \
))
#define cr_expect_(...) \
CR_EXPAND(cr_assert_impl( \
CR_FAIL_CONTINUES_, \
CR_VA_HEAD(__VA_ARGS__), \
dummy, \
CRITERION_ASSERT_MSG_EXPR_FALSE, \
(CR_STR(CR_VA_HEAD(__VA_ARGS__))), \
CR_VA_TAIL(__VA_ARGS__) \
))
#define cr_assert_not_(...) \
CR_EXPAND(cr_assert_impl( \
CR_FAIL_ABORT_, \
!(CR_VA_HEAD(__VA_ARGS__)), \
dummy, \
CRITERION_ASSERT_MSG_EXPR_FALSE, \
(CR_STR(!(CR_VA_HEAD(__VA_ARGS__)))), \
CR_VA_TAIL(__VA_ARGS__) \
))
#define cr_expect_not_(...) \
CR_EXPAND(cr_assert_impl( \
CR_FAIL_CONTINUES_, \
!(CR_VA_HEAD(__VA_ARGS__)), \
dummy, \
CRITERION_ASSERT_MSG_EXPR_FALSE, \
(CR_STR(!(CR_VA_HEAD(__VA_ARGS__)))), \
CR_VA_TAIL(__VA_ARGS__) \
))
/* Binary */
#define cr_assert_op_(Fail, Op, Actual, Expected, ...) \
CR_EXPAND(cr_assert_impl( \
Fail, \
(Actual) Op (Expected), \
dummy, \
CRITERION_ASSERT_MSG_EXPR_FALSE, \
(CR_STR((Actual) Op (Expected))), \
__VA_ARGS__ \
))
#define cr_assert_op_va_(Fail, Op, ...) \
CR_EXPAND(cr_assert_op_( \
Fail, \
Op, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
))
/* Unary */
#define cr_assert_null_op_(Fail, Op, Msg, Value, ...) \
CR_EXPAND(cr_assert_impl( \
Fail, \
(Value) Op NULL, \
dummy, \
Msg, \
(CR_STR(Value)), \
__VA_ARGS__ \
))
#define cr_assert_null_op_va_(Fail, Op, Msg, ...) \
CR_EXPAND(cr_assert_null_op_( \
Fail, \
Op, \
Msg, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_TAIL(__VA_ARGS__) \
))
/* Floating point */
#define cr_assert_float_eq_op_(Actual, Expected, Epsilon) \
(Expected) - (Actual) <= (Epsilon) && (Actual) - (Expected) <= (Epsilon)
#define cr_assert_float_neq_op_(Actual, Expected, Epsilon) \
(Expected) - (Actual) > (Epsilon) || (Actual) - (Expected) > (Epsilon)
#define cr_assert_float_op_(Fail, Op, Actual, Expected, Epsilon, ...) \
CR_EXPAND(cr_assert_impl( \
Fail, \
Op (Actual, Expected, Epsilon), \
dummy, \
CRITERION_ASSERT_MSG_EXPR_FALSE, \
(CR_STR(Op (Actual, Expected, Epsilon))), \
__VA_ARGS__ \
))
#define cr_assert_float_op_va_(Fail, Op, ...) \
CR_EXPAND(cr_assert_float_op_( \
Fail, \
Op, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
CR_VA_HEAD(CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__))), \
CR_VA_TAIL(CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__))) \
))
/* String */
#define cr_assert_str_op_empty_(Fail, Op, Msg, Value, ...) \
do { \
const char *cr_str_value__ = (Value); \
CR_EXPAND(cr_assert_impl( \
Fail, \
((cr_str_value__) != NULL) && (cr_str_value__)[0] Op '\0', \
dummy, \
((cr_str_value__) != NULL) ? Msg : CRITERION_ASSERT_MSG_IS_NULL, \
(CR_STR(Value), cr_str_value__), \
__VA_ARGS__ \
)); \
} while (0)
#define cr_assert_str_op_empty_va_(Fail, Op, Msg, ...) \
CR_EXPAND(cr_assert_str_op_empty_( \
Fail, \
Op, \
Msg, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_TAIL(__VA_ARGS__) \
))
#define cr_assert_str_op_(Fail, Op, Actual, Expected, ...) \
do { \
const char *cr_str_actual__ = (Actual); \
const char *cr_str_expected__ = (Expected); \
CR_EXPAND(cr_assert_impl( \
Fail, \
((cr_str_actual__) != NULL) && ((cr_str_expected__) != NULL) \
&& CR_STDN strcmp((cr_str_actual__), (cr_str_expected__)) Op 0, \
dummy, \
CRITERION_ASSERT_MSG_EXPR_AS_STRINGS_FALSE, \
(CR_STR((Actual) Op (Expected)), cr_str_actual__, cr_str_expected__), \
__VA_ARGS__ \
)); \
} while (0)
#define cr_assert_str_op_va_(Fail, Op, ...) \
CR_EXPAND(cr_assert_str_op_( \
Fail, \
Op, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
))
/* Wide String */
#define cr_assert_wcs_op_empty_(Fail, Op, Msg, Value, ...) \
do { \
const wchar_t *cr_wcs_value__ = (Value); \
CR_EXPAND(cr_assert_impl( \
Fail, \
((cr_wcs_value__) != NULL) && (cr_wcs_value__)[0] Op L'\0', \
dummy, \
((cr_wcs_value__) != NULL) ? Msg : CRITERION_ASSERT_MSG_IS_NULL, \
(CR_STR(Value), cr_wcs_value__), \
__VA_ARGS__ \
)); \
} while (0)
#define cr_assert_wcs_op_empty_va_(Fail, Op, Msg, ...) \
CR_EXPAND(cr_assert_wcs_op_empty_( \
Fail, \
Op, \
Msg, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_TAIL(__VA_ARGS__) \
))
#define cr_assert_wcs_op_(Fail, Op, Actual, Expected, ...) \
do { \
const wchar_t *cr_wcs_actual__ = (Actual); \
const wchar_t *cr_wcs_expected__ = (Expected); \
CR_EXPAND(cr_assert_impl( \
Fail, \
((cr_wcs_actual__) != NULL) && ((cr_wcs_expected__) != NULL) \
&& CR_STDN wcscmp((cr_wcs_actual__), (cr_wcs_expected__)) Op 0, \
dummy, \
CRITERION_ASSERT_MSG_EXPR_FALSE, \
(CR_STR((Actual) Op (Expected))), \
__VA_ARGS__ \
)); \
} while (0)
#define cr_assert_wcs_op_va_(Fail, Op, ...) \
CR_EXPAND(cr_assert_wcs_op_( \
Fail, \
Op, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
))
/* Array */
#define cr_assert_mem_op_(Fail, Op, Actual, Expected, Size, ...) \
CR_EXPAND(cr_assert_impl( \
Fail, \
CR_STDN memcmp((Actual), (Expected), (Size)) Op 0, \
dummy, \
CRITERION_ASSERT_MSG_EXPR_FALSE, \
(CR_STR((Actual)[0..Size] Op (Expected)[0..Size])), \
__VA_ARGS__ \
))
#define cr_assert_mem_op_va_(Fail, Op, ...) \
CR_EXPAND(cr_assert_mem_op_( \
Fail, \
Op, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
CR_VA_HEAD(CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__))), \
CR_VA_TAIL(CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__))) \
))
/* Array comparisons */
#ifdef __cplusplus
# define CR_ARR_COMPARE_(A, B, Size, Cmp, Result) \
int Result = std::lexicographical_compare((A), (A) + Size, (B), (B) + Size, Cmp)
#else
# define CR_ARR_COMPARE_(A, B, Size, Cmp, Result) \
__typeof__ (&(A)[0])first = (A); \
__typeof__ (&(B)[0])second = (B); \
int Result = 0; \
size_t i, size; \
for (i = 0, size = (Size); !Result && i < size; ++i) \
Result = Cmp(first + i, second + i)
#endif
#define cr_assert_arr_op_cmp_(Fail, Op, Actual, Expected, Size, Cmp, ...) \
do { \
CR_ARR_COMPARE_(Actual, Expected, Size, Cmp, order); \
CR_EXPAND(cr_assert_impl( \
Fail, \
order Op 0, \
dummy, \
CRITERION_ASSERT_MSG_EXPR_FALSE, \
(CR_STR((Actual)[0..Size] Op (Expected)[0..Size])), \
__VA_ARGS__ \
)); \
} while (0)
#define cr_assert_arr_op_cmp_va_(Fail, Op, ...) \
CR_EXPAND(cr_assert_arr_op_cmp_( \
Fail, \
Op, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
CR_VA_HEAD(CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__))), \
CR_VA_HEAD(CR_VA_TAIL(CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)))), \
CR_VA_TAIL(CR_VA_TAIL(CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)))) \
))
/* Exceptions */
#define cr_assert_throw_abort_(Fail, Msg, MsgArgs, ...) \
CR_EXPAND(cr_assert_impl( \
Fail, \
0, \
dummy, \
Msg, \
MsgArgs, \
CR_VA_TAIL(__VA_ARGS__) \
))
#define cr_assert_throw_(Fail, Statement, Exception, ...) \
try { \
Statement; \
} catch (Exception const &) { \
} catch (...) { \
CR_EXPAND(cr_assert_throw_abort_( \
Fail, \
CRITERION_ASSERT_MSG_NO_THROW, \
(CR_STR(Statement), CR_STR(Exception)), \
__VA_ARGS__)); \
}
#define cr_assert_throw_va_(...) \
CR_EXPAND(cr_assert_throw_( \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
CR_VA_HEAD(CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__))), \
dummy, \
CR_VA_TAIL(CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__))) \
))
#define cr_assert_no_throw_(Fail, Statement, Exception, ...) \
try { \
Statement; \
} catch (Exception const &) { \
CR_EXPAND(cr_assert_throw_abort_( \
Fail, \
CRITERION_ASSERT_MSG_THROW, \
(CR_STR(Statement), CR_STR(Exception)), \
__VA_ARGS__)); \
}
#define cr_assert_no_throw_va_(...) \
CR_EXPAND(cr_assert_no_throw_( \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
CR_VA_HEAD(CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__))), \
dummy, \
CR_VA_TAIL(CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__))) \
))
#define cr_assert_any_throw_(Fail, Statement, ...) \
try { \
Statement; \
CR_EXPAND(cr_assert_throw_abort_( \
Fail, \
CRITERION_ASSERT_MSG_ANY_THROW, \
(CR_STR(Statement)), \
__VA_ARGS__)); \
} catch (...) {}
#define cr_assert_any_throw_va_(...) \
CR_EXPAND(cr_assert_any_throw_( \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
dummy, \
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
))
#define cr_assert_none_throw_(Fail, Statement, ...) \
try { \
Statement; \
} catch (...) { \
CR_EXPAND(cr_assert_throw_abort_( \
Fail, \
CRITERION_ASSERT_MSG_NONE_THROW, \
(CR_STR(Statement)), \
__VA_ARGS__)); \
}
#define cr_assert_none_throw_va_(...) \
CR_EXPAND(cr_assert_none_throw_( \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
dummy, \
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
))
/* Messages */
#define CRITERION_GNUC_WARN__(Msg) \
_Pragma(#Msg)
#define CRITERION_GNUC_WARN_(Name) \
CRITERION_GNUC_WARN__( \
message \
"The `" #Name "` macro is only available on GNU C compilers." \
)
/* Actual implementation */
#undef cr_skip_test
#define cr_skip_test(...) CR_EXPAND(cr_skip(__VA_ARGS__))
#undef cr_assert_fail
#define cr_assert_fail(...) CR_EXPAND(cr_fail(CR_FAIL_ABORT_, __VA_ARGS__))
#undef cr_expect_fail
#define cr_expect_fail(...) CR_EXPAND(cr_fail(CR_FAIL_CONTINUES_, __VA_ARGS__))
#undef cr_assert
#define cr_assert(...) CR_EXPAND(cr_assert_(__VA_ARGS__))
#undef cr_expect
#define cr_expect(...) CR_EXPAND(cr_expect_(__VA_ARGS__))
#undef cr_assert_not
#define cr_assert_not(...) CR_EXPAND(cr_assert_not_(__VA_ARGS__))
#undef cr_expect_not
#define cr_expect_not(...) CR_EXPAND(cr_expect_not_(__VA_ARGS__))
#undef cr_assert_eq
#define cr_assert_eq(...) CR_EXPAND(cr_assert_op_va_(CR_FAIL_ABORT_, ==, __VA_ARGS__))
#undef cr_expect_eq
#define cr_expect_eq(...) CR_EXPAND(cr_assert_op_va_(CR_FAIL_CONTINUES_, ==, __VA_ARGS__))
#undef cr_assert_neq
#define cr_assert_neq(...) CR_EXPAND(cr_assert_op_va_(CR_FAIL_ABORT_, !=, __VA_ARGS__))
#undef cr_expect_neq
#define cr_expect_neq(...) CR_EXPAND(cr_assert_op_va_(CR_FAIL_CONTINUES_, !=, __VA_ARGS__))
#undef cr_assert_lt
#define cr_assert_lt(...) CR_EXPAND(cr_assert_op_va_(CR_FAIL_ABORT_, <, __VA_ARGS__))
#undef cr_expect_lt
#define cr_expect_lt(...) CR_EXPAND(cr_assert_op_va_(CR_FAIL_CONTINUES_, <, __VA_ARGS__))
#undef cr_assert_leq
#define cr_assert_leq(...) CR_EXPAND(cr_assert_op_va_(CR_FAIL_ABORT_, <=, __VA_ARGS__))
#undef cr_expect_leq
#define cr_expect_leq(...) CR_EXPAND(cr_assert_op_va_(CR_FAIL_CONTINUES_, <=, __VA_ARGS__))
#undef cr_assert_gt
#define cr_assert_gt(...) CR_EXPAND(cr_assert_op_va_(CR_FAIL_ABORT_, >, __VA_ARGS__))
#undef cr_expect_gt
#define cr_expect_gt(...) CR_EXPAND(cr_assert_op_va_(CR_FAIL_CONTINUES_, >, __VA_ARGS__))
#undef cr_assert_geq
#define cr_assert_geq(...) CR_EXPAND(cr_assert_op_va_(CR_FAIL_ABORT_, >=, __VA_ARGS__))
#undef cr_expect_geq
#define cr_expect_geq(...) CR_EXPAND(cr_assert_op_va_(CR_FAIL_CONTINUES_, >=, __VA_ARGS__))
#undef cr_assert_null
#define cr_assert_null(...) CR_EXPAND(cr_assert_null_op_va_(CR_FAIL_ABORT_, ==, CRITERION_ASSERT_MSG_IS_NOT_NULL, __VA_ARGS__))
#undef cr_expect_null
#define cr_expect_null(...) CR_EXPAND(cr_assert_null_op_va_(CR_FAIL_CONTINUES_, ==, CRITERION_ASSERT_MSG_IS_NOT_NULL, __VA_ARGS__))
#undef cr_assert_not_null
#define cr_assert_not_null(...) CR_EXPAND(cr_assert_null_op_va_(CR_FAIL_ABORT_, !=, CRITERION_ASSERT_MSG_IS_NULL, __VA_ARGS__))
#undef cr_expect_not_null
#define cr_expect_not_null(...) CR_EXPAND(cr_assert_null_op_va_(CR_FAIL_CONTINUES_, !=, CRITERION_ASSERT_MSG_IS_NULL, __VA_ARGS__))
#undef cr_assert_float_eq
#define cr_assert_float_eq(...) CR_EXPAND(cr_assert_float_op_va_(CR_FAIL_ABORT_, cr_assert_float_eq_op_, __VA_ARGS__))
#undef cr_expect_float_eq
#define cr_expect_float_eq(...) CR_EXPAND(cr_assert_float_op_va_(CR_FAIL_CONTINUES_, cr_assert_float_eq_op_, __VA_ARGS__))
#undef cr_assert_float_neq
#define cr_assert_float_neq(...) CR_EXPAND(cr_assert_float_op_va_(CR_FAIL_ABORT_, cr_assert_float_neq_op_, __VA_ARGS__))
#undef cr_expect_float_neq
#define cr_expect_float_neq(...) CR_EXPAND(cr_assert_float_op_va_(CR_FAIL_CONTINUES_, cr_assert_float_neq_op_, __VA_ARGS__))
#undef cr_assert_str_empty
#define cr_assert_str_empty(...) CR_EXPAND(cr_assert_str_op_empty_va_(CR_FAIL_ABORT_, ==, CRITERION_ASSERT_MSG_IS_NOT_EMPTY, __VA_ARGS__))
#undef cr_expect_str_empty
#define cr_expect_str_empty(...) CR_EXPAND(cr_assert_str_op_empty_va_(CR_FAIL_CONTINUES_, ==, CRITERION_ASSERT_MSG_IS_NOT_EMPTY, __VA_ARGS__))
#undef cr_assert_str_not_empty
#define cr_assert_str_not_empty(...) CR_EXPAND(cr_assert_str_op_empty_va_(CR_FAIL_ABORT_, !=, CRITERION_ASSERT_MSG_IS_EMPTY, __VA_ARGS__))
#undef cr_expect_str_not_empty
#define cr_expect_str_not_empty(...) CR_EXPAND(cr_assert_str_op_empty_va_(CR_FAIL_CONTINUES_, !=, CRITERION_ASSERT_MSG_IS_EMPTY, __VA_ARGS__))
#undef cr_assert_str_eq
#define cr_assert_str_eq(...) CR_EXPAND(cr_assert_str_op_va_(CR_FAIL_ABORT_, ==, __VA_ARGS__))
#undef cr_expect_str_eq
#define cr_expect_str_eq(...) CR_EXPAND(cr_assert_str_op_va_(CR_FAIL_CONTINUES_, ==, __VA_ARGS__))
#undef cr_assert_str_neq
#define cr_assert_str_neq(...) CR_EXPAND(cr_assert_str_op_va_(CR_FAIL_ABORT_, !=, __VA_ARGS__))
#undef cr_expect_str_neq
#define cr_expect_str_neq(...) CR_EXPAND(cr_assert_str_op_va_(CR_FAIL_CONTINUES_, !=, __VA_ARGS__))
#undef cr_assert_str_lt
#define cr_assert_str_lt(...) CR_EXPAND(cr_assert_str_op_va_(CR_FAIL_ABORT_, <, __VA_ARGS__))
#undef cr_expect_str_lt
#define cr_expect_str_lt(...) CR_EXPAND(cr_assert_str_op_va_(CR_FAIL_CONTINUES_, <, __VA_ARGS__))
#undef cr_assert_str_leq
#define cr_assert_str_leq(...) CR_EXPAND(cr_assert_str_op_va_(CR_FAIL_ABORT_, <=, __VA_ARGS__))
#undef cr_expect_str_leq
#define cr_expect_str_leq(...) CR_EXPAND(cr_assert_str_op_va_(CR_FAIL_CONTINUES_, <=, __VA_ARGS__))
#undef cr_assert_str_gt
#define cr_assert_str_gt(...) CR_EXPAND(cr_assert_str_op_va_(CR_FAIL_ABORT_, >, __VA_ARGS__))
#undef cr_expect_str_gt
#define cr_expect_str_gt(...) CR_EXPAND(cr_assert_str_op_va_(CR_FAIL_CONTINUES_, >, __VA_ARGS__))
#undef cr_assert_str_geq
#define cr_assert_str_geq(...) CR_EXPAND(cr_assert_str_op_va_(CR_FAIL_ABORT_, >=, __VA_ARGS__))
#undef cr_expect_str_geq
#define cr_expect_str_geq(...) CR_EXPAND(cr_assert_str_op_va_(CR_FAIL_CONTINUES_, >=, __VA_ARGS__))
#undef cr_assert_wcs_empty
#define cr_assert_wcs_empty(...) CR_EXPAND(cr_assert_wcs_op_empty_va_(CR_FAIL_ABORT_, ==, CRITERION_ASSERT_MSG_IS_NOT_EMPTY, __VA_ARGS__))
#undef cr_expect_wcs_empty
#define cr_expect_wcs_empty(...) CR_EXPAND(cr_assert_wcs_op_empty_va_(CR_FAIL_CONTINUES_, ==, CRITERION_ASSERT_MSG_IS_NOT_EMPTY, __VA_ARGS__))
#undef cr_assert_wcs_not_empty
#define cr_assert_wcs_not_empty(...) CR_EXPAND(cr_assert_wcs_op_empty_va_(CR_FAIL_ABORT_, !=, CRITERION_ASSERT_MSG_IS_EMPTY, __VA_ARGS__))
#undef cr_expect_wcs_not_empty
#define cr_expect_wcs_not_empty(...) CR_EXPAND(cr_assert_wcs_op_empty_va_(CR_FAIL_CONTINUES_, !=, CRITERION_ASSERT_MSG_IS_EMPTY, __VA_ARGS__))
#undef cr_assert_wcs_eq
#define cr_assert_wcs_eq(...) CR_EXPAND(cr_assert_wcs_op_va_(CR_FAIL_ABORT_, ==, __VA_ARGS__))
#undef cr_expect_wcs_eq
#define cr_expect_wcs_eq(...) CR_EXPAND(cr_assert_wcs_op_va_(CR_FAIL_CONTINUES_, ==, __VA_ARGS__))
#undef cr_assert_wcs_neq
#define cr_assert_wcs_neq(...) CR_EXPAND(cr_assert_wcs_op_va_(CR_FAIL_ABORT_, !=, __VA_ARGS__))
#undef cr_expect_wcs_neq
#define cr_expect_wcs_neq(...) CR_EXPAND(cr_assert_wcs_op_va_(CR_FAIL_CONTINUES_, !=, __VA_ARGS__))
#undef cr_assert_wcs_lt
#define cr_assert_wcs_lt(...) CR_EXPAND(cr_assert_wcs_op_va_(CR_FAIL_ABORT_, <, __VA_ARGS__))
#undef cr_expect_wcs_lt
#define cr_expect_wcs_lt(...) CR_EXPAND(cr_assert_wcs_op_va_(CR_FAIL_CONTINUES_, <, __VA_ARGS__))
#undef cr_assert_wcs_leq
#define cr_assert_wcs_leq(...) CR_EXPAND(cr_assert_wcs_op_va_(CR_FAIL_ABORT_, <=, __VA_ARGS__))
#undef cr_expect_wcs_leq
#define cr_expect_wcs_leq(...) CR_EXPAND(cr_assert_wcs_op_va_(CR_FAIL_CONTINUES_, <=, __VA_ARGS__))
#undef cr_assert_wcs_gt
#define cr_assert_wcs_gt(...) CR_EXPAND(cr_assert_wcs_op_va_(CR_FAIL_ABORT_, >, __VA_ARGS__))
#undef cr_expect_wcs_gt
#define cr_expect_wcs_gt(...) CR_EXPAND(cr_assert_wcs_op_va_(CR_FAIL_CONTINUES_, >, __VA_ARGS__))
#undef cr_assert_wcs_geq
#define cr_assert_wcs_geq(...) CR_EXPAND(cr_assert_wcs_op_va_(CR_FAIL_ABORT_, >=, __VA_ARGS__))
#undef cr_expect_wcs_geq
#define cr_expect_wcs_geq(...) CR_EXPAND(cr_assert_wcs_op_va_(CR_FAIL_CONTINUES_, >=, __VA_ARGS__))
#undef cr_assert_arr_eq
#define cr_assert_arr_eq(...) CR_EXPAND(cr_assert_mem_op_va_(CR_FAIL_ABORT_, ==, __VA_ARGS__))
#undef cr_expect_arr_eq
#define cr_expect_arr_eq(...) CR_EXPAND(cr_assert_mem_op_va_(CR_FAIL_CONTINUES_, ==, __VA_ARGS__))
#undef cr_assert_arr_neq
#define cr_assert_arr_neq(...) CR_EXPAND(cr_assert_mem_op_va_(CR_FAIL_ABORT_, !=, __VA_ARGS__))
#undef cr_expect_arr_neq
#define cr_expect_arr_neq(...) CR_EXPAND(cr_assert_mem_op_va_(CR_FAIL_CONTINUES_, !=, __VA_ARGS__))
#if defined (__GNUC__) || defined (__clang__) || defined (__cplusplus)
# undef cr_assert_arr_eq_cmp
# define cr_assert_arr_eq_cmp(...) CR_EXPAND(cr_assert_arr_op_cmp_va_(CR_FAIL_ABORT_, ==, __VA_ARGS__))
# undef cr_expect_arr_eq_cmp
# define cr_expect_arr_eq_cmp(...) CR_EXPAND(cr_assert_arr_op_cmp_va_(CR_FAIL_CONTINUES_, ==, __VA_ARGS__))
# undef cr_assert_arr_neq_cmp
# define cr_assert_arr_neq_cmp(...) CR_EXPAND(cr_assert_arr_op_cmp_va_(CR_FAIL_ABORT_, !=, __VA_ARGS__))
# undef cr_expect_arr_neq_cmp
# define cr_expect_arr_neq_cmp(...) CR_EXPAND(cr_assert_arr_op_cmp_va_(CR_FAIL_CONTINUES_, !=, __VA_ARGS__))
# undef cr_assert_arr_lt_cmp
# define cr_assert_arr_lt_cmp(...) CR_EXPAND(cr_assert_arr_op_cmp_va_(CR_FAIL_ABORT_, <, __VA_ARGS__))
# undef cr_expect_arr_lt_cmp
# define cr_expect_arr_lt_cmp(...) CR_EXPAND(cr_assert_arr_op_cmp_va_(CR_FAIL_CONTINUES_, <, __VA_ARGS__))
# undef cr_assert_arr_leq_cmp
# define cr_assert_arr_leq_cmp(...) CR_EXPAND(cr_assert_arr_op_cmp_va_(CR_FAIL_ABORT_, <=, __VA_ARGS__))
# undef cr_expect_arr_leq_cmp
# define cr_expect_arr_leq_cmp(...) CR_EXPAND(cr_assert_arr_op_cmp_va_(CR_FAIL_CONTINUES_, <=, __VA_ARGS__))
# undef cr_assert_arr_gt_cmp
# define cr_assert_arr_gt_cmp(...) CR_EXPAND(cr_assert_arr_op_cmp_va_(CR_FAIL_ABORT_, >, __VA_ARGS__))
# undef cr_expect_arr_gt_cmp
# define cr_expect_arr_gt_cmp(...) CR_EXPAND(cr_assert_arr_op_cmp_va_(CR_FAIL_CONTINUES_, >, __VA_ARGS__))
# undef cr_assert_arr_geq_cmp
# define cr_assert_arr_geq_cmp(...) CR_EXPAND(cr_assert_arr_op_cmp_va_(CR_FAIL_ABORT_, >=, __VA_ARGS__))
# undef cr_expect_arr_geq_cmp
# define cr_expect_arr_geq_cmp(...) CR_EXPAND(cr_assert_arr_op_cmp_va_(CR_FAIL_CONTINUES_, >=, __VA_ARGS__))
#else
# undef cr_assert_arr_eq_cmp
# define cr_assert_arr_eq_cmp(...) CRITERION_GNUC_WARN_(cr_assert_arr_eq_cmp) CR_NOOP
# undef cr_expect_arr_eq_cmp
# define cr_expect_arr_eq_cmp(...) CRITERION_GNUC_WARN_(cr_expect_arr_eq_cmp) CR_NOOP
# undef cr_assert_arr_neq_cmp
# define cr_assert_arr_neq_cmp(...) CRITERION_GNUC_WARN_(cr_assert_arr_neq_cmp) CR_NOOP
# undef cr_expect_arr_neq_cmp
# define cr_expect_arr_neq_cmp(...) CRITERION_GNUC_WARN_(cr_expect_arr_neq_cmp) CR_NOOP
# undef cr_assert_arr_lt_cmp
# define cr_assert_arr_lt_cmp(...) CRITERION_GNUC_WARN_(cr_assert_arr_lt_cmp) CR_NOOP
# undef cr_expect_arr_lt_cmp
# define cr_expect_arr_lt_cmp(...) CRITERION_GNUC_WARN_(cr_expect_arr_lt_cmp) CR_NOOP
# undef cr_assert_arr_leq_cmp
# define cr_assert_arr_leq_cmp(...) CRITERION_GNUC_WARN_(cr_assert_arr_leq_cmp) CR_NOOP
# undef cr_expect_arr_leq_cmp
# define cr_expect_arr_leq_cmp(...) CRITERION_GNUC_WARN_(cr_expect_arr_leq_cmp) CR_NOOP
# undef cr_assert_arr_gt_cmp
# define cr_assert_arr_gt_cmp(...) CRITERION_GNUC_WARN_(cr_assert_arr_gt_cmp) CR_NOOP
# undef cr_expect_arr_gt_cmp
# define cr_expect_arr_gt_cmp(...) CRITERION_GNUC_WARN_(cr_expect_arr_gt_cmp) CR_NOOP
# undef cr_assert_arr_geq_cmp
# define cr_assert_arr_geq_cmp(...) CRITERION_GNUC_WARN_(cr_assert_arr_geq_cmp) CR_NOOP
# undef cr_expect_arr_geq_cmp
# define cr_expect_arr_geq_cmp(...) CRITERION_GNUC_WARN_(cr_expect_arr_geq_cmp) CR_NOOP
#endif
#undef cr_assert_throw
#define cr_assert_throw(...) CR_EXPAND(cr_assert_throw_va_(CR_FAIL_ABORT_, __VA_ARGS__))
#undef cr_expect_throw
#define cr_expect_throw(...) CR_EXPAND(cr_assert_throw_va_(CR_FAIL_CONTINUES_, __VA_ARGS__))
#undef cr_assert_no_throw
#define cr_assert_no_throw(...) CR_EXPAND(cr_assert_no_throw_va_(CR_FAIL_ABORT_, __VA_ARGS__))
#undef cr_expect_no_throw
#define cr_expect_no_throw(...) CR_EXPAND(cr_assert_no_throw_va_(CR_FAIL_CONTINUES_, __VA_ARGS__))
#undef cr_assert_any_throw
#define cr_assert_any_throw(...) CR_EXPAND(cr_assert_any_throw_va_(CR_FAIL_ABORT_, __VA_ARGS__))
#undef cr_expect_any_throw
#define cr_expect_any_throw(...) CR_EXPAND(cr_assert_any_throw_va_(CR_FAIL_CONTINUES_, __VA_ARGS__))
#undef cr_assert_none_throw
#define cr_assert_none_throw(...) CR_EXPAND(cr_assert_none_throw_va_(CR_FAIL_ABORT_, __VA_ARGS__))
#undef cr_expect_none_throw
#define cr_expect_none_throw(...) CR_EXPAND(cr_assert_none_throw_va_(CR_FAIL_CONTINUES_, __VA_ARGS__))
#endif /* !CRITERION_INTERNAL_ASSERT_H_ */

View File

@ -1,139 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CRITERION_COMMON_H_
#define CRITERION_COMMON_H_
#if defined (_MSC_VER)
# if _MSC_VER < 1900
# error \
Your version of MSVC++ is too old, please compile your tests using \
a c99 compiler, like MinGW or MSVC 14.0+ (Included in visual studio \
2015)
# endif
#endif
#ifndef CR_IS_MSVC
# ifdef _MSC_VER
# define CR_IS_MSVC _MSC_VER
# else
# define CR_IS_MSVC 0
# endif
#endif
#ifdef __cplusplus
# ifdef __GNUC__
# define CR_ATTRIBUTE(Arg) __attribute__((Arg))
# else
# define CR_ATTRIBUTE(Arg) [[gnu::Arg]]
# endif
# define CR_BEGIN_C_API extern "C" {
# define CR_END_C_API }
#else
# define CR_ATTRIBUTE(Arg) __attribute__((Arg))
# define CR_BEGIN_C_API
# define CR_END_C_API
#endif
#ifdef __APPLE__
# define CR_SECTION_START_SUFFIX(Name) __asm("section$start$__DATA$" Name)
# define CR_SECTION_END_SUFFIX(Name) __asm("section$end$__DATA$" Name)
# define CR_SECTION_(Name) CR_ATTRIBUTE(section("__DATA," Name))
# define CR_SECTION_SUFFIX_
#elif CR_IS_MSVC
# define CR_SECTION_START_SUFFIX(Name)
# define CR_SECTION_END_SUFFIX(Name)
# define CR_SECTION_(Name) \
__pragma(data_seg(push)) \
__pragma(section(Name, read)) \
__declspec(allocate(Name))
# define CR_SECTION_SUFFIX_ \
__pragma(data_seg(pop))
#else
# define CR_SECTION_START_SUFFIX(Name)
# define CR_SECTION_END_SUFFIX(Name)
# define CR_SECTION_(Name) CR_ATTRIBUTE(section(Name))
# define CR_SECTION_SUFFIX_
#endif
#define CR_MAKE_IDENTIFIER_(Prefix, Id) CR_MAKE_IDENTIFIER__(Prefix, Id)
#define CR_MAKE_IDENTIFIER__(Prefix, Id) Prefix ## _ ## Id
#ifdef __GNUC__
# define CR_UNUSED CR_ATTRIBUTE(unused)
# define CR_NORETURN CR_ATTRIBUTE(noreturn)
# define CR_INLINE CR_ATTRIBUTE(always_inline) inline
#elif CR_IS_MSVC
# define CR_UNUSED __pragma(warning(suppress: 4100))
# define CR_NORETURN __declspec(noreturn)
# define CR_INLINE __forceinline
#else
# define CR_UNUSED
# define CR_NORETURN
# define CR_INLINE inline
#endif
#ifdef _WIN32
# define CR_SIZE_T_FORMAT "%Iu"
#else
# define CR_SIZE_T_FORMAT "%zu"
#endif
#ifdef __GNUC__
# define CR_FORMAT(Archetype, Index, Ftc) CR_ATTRIBUTE(format(Archetype, Index, Ftc))
#else
# define CR_FORMAT(Archetype, Index, Ftc)
#endif
#if defined _WIN32 || defined __CYGWIN__
# ifdef CRITERION_BUILDING_DLL
# ifdef __GNUC__
# define CR_API CR_ATTRIBUTE(dllexport)
# else
# define CR_API __declspec(dllexport)
# endif
# else
# ifdef __GNUC__
# define CR_API CR_ATTRIBUTE(dllimport)
# else
# define CR_API __declspec(dllimport)
# endif
# endif
# define CR_LOCAL
#else
# if __GNUC__ >= 4
# define CR_API CR_ATTRIBUTE(visibility("default"))
# define CR_LOCAL CR_ATTRIBUTE(visibility("hidden"))
# else
# define CR_API
# define CR_LOCAL
# endif
#endif
#ifdef __cplusplus
# define CR_STDN std::
#else
# define CR_STDN
#endif
#endif /* !CRITERION_COMMON_H_ */

View File

@ -1,41 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright © 2015-2016 Franklin "Snaipe" Mathieu <http://snai.pe/>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef CRITERION_INTERNAL_DEPRECATION_H_
#define CRITERION_INTERNAL_DEPRECATION_H_
#define CR_DEPRECATED(Msg) CR_DEPRECATED_(message(Msg))
#ifdef _MSC_VER
# define CR_DEPRECATED_(Msg) __pragma(Msg)
#else
# define CR_DEPRECATED_(Msg) _Pragma(#Msg)
#endif
#ifdef __GNUC__
# define CR_DEPRECATED_MEMBER(Member) Member __attribute__((deprecated))
#else
# define CR_DEPRECATED_MEMBER(Member) Member
#endif
#endif /* !CRITERION_INTERNAL_DEPRECATION_H_ */

Some files were not shown because too many files have changed in this diff Show More