Skip to content

Commit

Permalink
[v2.2.1] Merge branch 'patch' (Patch release)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Snaipe committed Mar 6, 2016
2 parents 65aa79d + 22c9c3e commit 95d7ed4
Show file tree
Hide file tree
Showing 16 changed files with 178 additions and 102 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.2.0
current_version = 2.2.1
commit = False

[bumpversion:file:CMakeLists.txt]
Expand Down
4 changes: 2 additions & 2 deletions .cmake/Modules/CoverallsGenerateGcov.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ if (GIT_FOUND)
# Branch.
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
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 ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE ${VAR_NAME}
OUTPUT_STRIP_TRAILING_WHITESPACE
)
Expand Down
4 changes: 2 additions & 2 deletions .cmake/Modules/DebConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ set(CPACK_DEBIAN_PACKAGE_DEPENDS
)

set(CPACK_DEBIAN_CMAKE_OPTIONS)
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/description.txt")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/description.txt")

set(CPACK_DEBIAN_PACKAGE_SOURCE_COPY "${CMAKE_SOURCE_DIR}/.cmake/copy-source.sh")
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)
Expand Down
14 changes: 7 additions & 7 deletions .cmake/Modules/DebSourcePPA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ foreach(LINE ${DESC_LINES})
set(DEB_LONG_DESCRIPTION "${DEB_LONG_DESCRIPTION} ${LINE}\n")
endforeach(LINE ${DESC_LINES})

file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/Debian")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Debian")
set(DEBIAN_SOURCE_ORIG_DIR "${CMAKE_BINARY_DIR}/Debian/${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
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} "${CMAKE_SOURCE_DIR}" "${DEBIAN_SOURCE_ORIG_DIR}.orig")
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 ${CMAKE_SOURCE_DIR} "${DEBIAN_SOURCE_ORIG_DIR}.orig")
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()
Expand All @@ -77,7 +77,7 @@ foreach(REMOVE_DIR ${CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES})
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 ${CMAKE_BINARY_DIR}/Debian)
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})
Expand Down Expand Up @@ -344,4 +344,4 @@ 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 ${CMAKE_BINARY_DIR}/Debian)
add_custom_target(dput ${DPUT_EXECUTABLE} ${DPUT_HOST} ${DEB_SOURCE_CHANGES} DEPENDS ${DEB_SOURCE_CHANGES} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/Debian)
30 changes: 15 additions & 15 deletions .cmake/Modules/PackageConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if (WIN32)
endif ()
endif ()

set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/debian.copyright")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/debian.copyright")
extract_version(${PROJECT_VERSION}
CPACK_PACKAGE_VERSION_MAJOR
CPACK_PACKAGE_VERSION_MINOR
Expand All @@ -55,21 +55,21 @@ extract_version(${PROJECT_VERSION}

set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})

file(GLOB TRASH_FILES "${CMAKE_SOURCE_DIR}/*")
file(GLOB TRASH_FILES "${PROJECT_SOURCE_DIR}/*")
set(KEEP_FILES
"${CMAKE_SOURCE_DIR}/.cmake"
"${CMAKE_SOURCE_DIR}/src"
"${CMAKE_SOURCE_DIR}/include"
"${CMAKE_SOURCE_DIR}/doc"
"${CMAKE_SOURCE_DIR}/dev"
"${CMAKE_SOURCE_DIR}/po"
"${CMAKE_SOURCE_DIR}/dependencies"
"${CMAKE_SOURCE_DIR}/CMakeLists.txt"
"${CMAKE_SOURCE_DIR}/README.md"
"${CMAKE_SOURCE_DIR}/CONTRIBUTING.md"
"${CMAKE_SOURCE_DIR}/LICENSE"
"${CMAKE_SOURCE_DIR}/ChangeLog"
"${CMAKE_SOURCE_DIR}/description.txt"
"${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
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ endif()

# Project setup & environment variables

set(PROJECT_VERSION "2.2.0")
set(PROJECT_VERSION "2.2.1")
set(LOCALEDIR_REL "share/locale")
set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/${LOCALEDIR_REL}")
set(GettextTranslate_ALL 1)
Expand Down
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2016-02-06 Franklin "Snaipe" Mathieu <[email protected]>

* 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 <[email protected]>

* criterion: version 2.2.0
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ the user would have with other frameworks:

### Binary archives

* [Linux (x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.2.0/criterion-v2.2.0-linux-x86_64.tar.bz2)
* [OS X (x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.2.0/criterion-v2.2.0-osx-x86_64.tar.bz2)
* [Windows (MSVC - x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.2.0/criterion-v2.2.0-windows-msvc-x86_64.tar.bz2)
* [Windows (MinGW - x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.2.0/criterion-v2.2.0-windows-mingw-x86_64.tar.bz2)

[comment]: # (Don't forget to change x86_64 to x64 on windows links on the next release)
* [Linux (x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.2.1/criterion-v2.2.1-linux-x86_64.tar.bz2)
* [OS X (x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.2.1/criterion-v2.2.1-osx-x86_64.tar.bz2)
* [Windows (MSVC - x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.2.1/criterion-v2.2.1-windows-msvc-x64.tar.bz2)
* [Windows (MinGW - x86_64)](https://github.com/Snaipe/Criterion/releases/download/v2.2.1/criterion-v2.2.1-windows-mingw-x64.tar.bz2)

If you have a different platform, you can still [build the library from source](http://criterion.readthedocs.org/en/latest/setup.html#installation)

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 2.2.0_b{build}-{branch}
version: 2.2.1_b{build}-{branch}

os: Visual Studio 2015

Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
# built documents.
#
# The short X.Y version.
version = '2.2.0'
version = '2.2.1'
# The full version, including alpha/beta/rc tags.
release = version

Expand Down
70 changes: 34 additions & 36 deletions include/criterion/internal/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,58 +97,56 @@ CR_END_C_API

# define CR_INIT_STATS_(BufSize, MsgVar, ...) CR_EXPAND( \
do { \
char *def_msg = CR_EXPAND(CR_TRANSLATE_DEF_MSG_(__VA_ARGS__)); \
char *formatted_msg = NULL; \
int msglen = cr_asprintf(&formatted_msg, \
"" CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__))); \
if (formatted_msg && *formatted_msg) { \
MsgVar = formatted_msg; \
CR_STDN free(def_msg); \
char *cr_def_msg__ = CR_EXPAND(CR_TRANSLATE_DEF_MSG_(__VA_ARGS__)); \
char *cr_fmt_msg__ = NULL; \
int cr_shifted__ = 0; \
int cr_msglen__ = 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; \
cr_shifted__ = 1; \
--cr_msglen__; \
CR_STDN free(cr_def_msg__); \
} else { \
MsgVar = def_msg; \
msglen = strlen(def_msg); \
CR_STDN free(formatted_msg); \
MsgVar = cr_def_msg__; \
cr_msglen__ = strlen(cr_def_msg__); \
CR_STDN free(cr_fmt_msg__); \
} \
\
BufSize = sizeof(struct criterion_assert_stats) \
+ sizeof (size_t) + msglen + 1; \
+ sizeof (size_t) + cr_msglen__ + 1; \
\
char *buf = (char*) CR_STDN malloc(BufSize); \
stat = (struct criterion_assert_stats*) buf; \
CR_STDN memset(buf, 0, sizeof (struct criterion_assert_stats)); \
buf += sizeof (struct criterion_assert_stats); \
*((size_t*) buf) = msglen + 1; \
buf += sizeof (size_t); \
CR_STDN strcpy(buf, MsgVar); \
CR_STDN free(MsgVar); \
char *cr_buf__ = (char*) CR_STDN malloc(BufSize); \
cr_stat__ = (struct criterion_assert_stats*) cr_buf__; \
CR_STDN memset(cr_buf__, 0, sizeof (struct criterion_assert_stats)); \
cr_buf__ += sizeof (struct criterion_assert_stats); \
*((size_t*) cr_buf__) = cr_msglen__ + 1; \
cr_buf__ += sizeof (size_t); \
CR_STDN strcpy(cr_buf__, MsgVar); \
CR_STDN free(MsgVar - cr_shifted__); \
} while (0))

# define CR_FAIL_ABORT_ criterion_abort_test
# define CR_FAIL_CONTINUES_ criterion_continue_test

# if defined(__GNUC__) || defined(__clang__)
// We disable the format-zero-length warning because we use the validity of
// asprintf(out, "") for empty assertion messages
# pragma GCC diagnostic ignored "-Wformat-zero-length"
# endif

# define cr_assert_impl(Fail, Condition, ...) \
do { \
bool passed = !!(Condition); \
bool cr_passed__ = !!(Condition); \
\
char *msg = NULL; \
size_t bufsize; \
char *cr_msg__ = NULL; \
size_t cr_bufsize__; \
\
struct criterion_assert_stats *stat; \
CR_EXPAND(CR_INIT_STATS_(bufsize, msg, CR_VA_TAIL(__VA_ARGS__))); \
stat->passed = passed; \
stat->file = __FILE__; \
stat->line = __LINE__; \
struct criterion_assert_stats *cr_stat__; \
CR_EXPAND(CR_INIT_STATS_(cr_bufsize__, cr_msg__, \
CR_VA_TAIL(__VA_ARGS__))); \
cr_stat__->passed = cr_passed__; \
cr_stat__->file = __FILE__; \
cr_stat__->line = __LINE__; \
\
criterion_send_event(ASSERT, stat, bufsize); \
CR_STDN free(stat); \
criterion_send_event(ASSERT, cr_stat__, cr_bufsize__); \
CR_STDN free(cr_stat__); \
\
if (!passed) \
if (!cr_passed__) \
Fail(); \
} while (0)

Expand Down
50 changes: 49 additions & 1 deletion include/criterion/internal/redirect.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
# include "common.h"
# include "assert.h"

CR_BEGIN_C_API

CR_API int cr_stdout_match_file(CR_STDN FILE* ref);
CR_API int cr_stdout_match_str(const char* ref);
CR_API int cr_stderr_match_file(CR_STDN FILE* ref);
CR_API int cr_stderr_match_str(const char* ref);

CR_END_C_API

# define cr_assert_redir_op_(Fail, Fun, Op, File, Str, ...) \
CR_EXPAND(cr_assert_impl( \
Fail, \
Expand Down Expand Up @@ -58,7 +67,7 @@
))

# define cr_assert_redir_f_op_va_(Fail, Fun, Op, ...) \
CR_EXPAND(cr_assert_redir_op_( \
CR_EXPAND(cr_assert_redir_f_op_( \
Fail, \
Fun, \
Op, \
Expand All @@ -67,5 +76,44 @@
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
))

# define cr_assert_redir_unop_(Fail, Fun, Op, File, Str, ...) \
CR_EXPAND(cr_assert_impl( \
Fail, \
!(Fun((Str)) Op 0), \
dummy, \
CRITERION_ASSERT_MSG_FILE_STR_MATCH, \
(CR_STR(File), Str), \
__VA_ARGS__ \
))

# define cr_assert_redir_unop_va_(Fail, Fun, Op, ...) \
CR_EXPAND(cr_assert_redir_unop_( \
Fail, \
Fun, \
Op, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
))

# define cr_assert_redir_f_unop_(Fail, Fun, Op, File, Ref, ...) \
CR_EXPAND(cr_assert_impl( \
Fail, \
!(Fun((Ref)) Op 0), \
dummy, \
CRITERION_ASSERT_MSG_FILE_MATCH, \
(CR_STR(File), CR_STR(Ref)), \
__VA_ARGS__ \
))

# define cr_assert_redir_f_unop_va_(Fail, Fun, Op, ...) \
CR_EXPAND(cr_assert_redir_f_unop_( \
Fail, \
Fun, \
Op, \
CR_VA_HEAD(__VA_ARGS__), \
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
))

#endif /* !CRITERION_INTERNAL_REDIRECT_H_ */
Loading

0 comments on commit 95d7ed4

Please sign in to comment.