Skip to content

Commit 95d7ed4

Browse files
committed
[v2.2.1] Merge branch 'patch' (Patch release)
* 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
2 parents 65aa79d + 22c9c3e commit 95d7ed4

File tree

16 files changed

+178
-102
lines changed

16 files changed

+178
-102
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 2.2.0
2+
current_version = 2.2.1
33
commit = False
44

55
[bumpversion:file:CMakeLists.txt]

.cmake/Modules/CoverallsGenerateGcov.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,15 @@ if (GIT_FOUND)
110110
# Branch.
111111
execute_process(
112112
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
113-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
113+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
114114
OUTPUT_VARIABLE GIT_BRANCH
115115
OUTPUT_STRIP_TRAILING_WHITESPACE
116116
)
117117

118118
macro (git_log_format FORMAT_CHARS VAR_NAME)
119119
execute_process(
120120
COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%${FORMAT_CHARS}
121-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
121+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
122122
OUTPUT_VARIABLE ${VAR_NAME}
123123
OUTPUT_STRIP_TRAILING_WHITESPACE
124124
)

.cmake/Modules/DebConfig.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ set(CPACK_DEBIAN_PACKAGE_DEPENDS
1515
)
1616

1717
set(CPACK_DEBIAN_CMAKE_OPTIONS)
18-
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/description.txt")
18+
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/description.txt")
1919

20-
set(CPACK_DEBIAN_PACKAGE_SOURCE_COPY "${CMAKE_SOURCE_DIR}/.cmake/copy-source.sh")
20+
set(CPACK_DEBIAN_PACKAGE_SOURCE_COPY "${PROJECT_SOURCE_DIR}/.cmake/copy-source.sh")
2121

2222
set(CPACK_DEBIAN_DISTRIBUTION_NAME ubuntu)
2323
set(CPACK_DEBIAN_DISTRIBUTION_RELEASES precise trusty vivid wily xenial)

.cmake/Modules/DebSourcePPA.cmake

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ foreach(LINE ${DESC_LINES})
5959
set(DEB_LONG_DESCRIPTION "${DEB_LONG_DESCRIPTION} ${LINE}\n")
6060
endforeach(LINE ${DESC_LINES})
6161

62-
file(REMOVE_RECURSE "${CMAKE_BINARY_DIR}/Debian")
63-
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/Debian")
64-
set(DEBIAN_SOURCE_ORIG_DIR "${CMAKE_BINARY_DIR}/Debian/${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
62+
file(REMOVE_RECURSE "${PROJECT_BINARY_DIR}/Debian")
63+
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/Debian")
64+
set(DEBIAN_SOURCE_ORIG_DIR "${PROJECT_BINARY_DIR}/Debian/${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
6565

6666
if( CPACK_DEBIAN_PACKAGE_SOURCE_COPY )
67-
execute_process(COMMAND ${CPACK_DEBIAN_PACKAGE_SOURCE_COPY} "${CMAKE_SOURCE_DIR}" "${DEBIAN_SOURCE_ORIG_DIR}.orig")
67+
execute_process(COMMAND ${CPACK_DEBIAN_PACKAGE_SOURCE_COPY} "${PROJECT_SOURCE_DIR}" "${DEBIAN_SOURCE_ORIG_DIR}.orig")
6868
else()
69-
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR} "${DEBIAN_SOURCE_ORIG_DIR}.orig")
69+
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR} "${DEBIAN_SOURCE_ORIG_DIR}.orig")
7070
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${DEBIAN_SOURCE_ORIG_DIR}.orig/.git")
7171
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory "${DEBIAN_SOURCE_ORIG_DIR}.orig/.svn")
7272
endif()
@@ -77,7 +77,7 @@ foreach(REMOVE_DIR ${CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES})
7777
endforeach()
7878

7979
# create the original source tar
80-
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)
80+
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)
8181

8282
set(DEB_SOURCE_CHANGES)
8383
foreach(RELEASE ${CPACK_DEBIAN_DISTRIBUTION_RELEASES})
@@ -344,4 +344,4 @@ endforeach(RELEASE ${CPACK_DEBIAN_DISTRIBUTION_RELEASES})
344344

345345
##############################################################################
346346
# dput ppa:your-lp-id/ppa <source.changes>
347-
add_custom_target(dput ${DPUT_EXECUTABLE} ${DPUT_HOST} ${DEB_SOURCE_CHANGES} DEPENDS ${DEB_SOURCE_CHANGES} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/Debian)
347+
add_custom_target(dput ${DPUT_EXECUTABLE} ${DPUT_HOST} ${DEB_SOURCE_CHANGES} DEPENDS ${DEB_SOURCE_CHANGES} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/Debian)

.cmake/Modules/PackageConfig.cmake

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ if (WIN32)
4545
endif ()
4646
endif ()
4747

48-
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/debian.copyright")
48+
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/debian.copyright")
4949
extract_version(${PROJECT_VERSION}
5050
CPACK_PACKAGE_VERSION_MAJOR
5151
CPACK_PACKAGE_VERSION_MINOR
@@ -55,21 +55,21 @@ extract_version(${PROJECT_VERSION}
5555

5656
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
5757

58-
file(GLOB TRASH_FILES "${CMAKE_SOURCE_DIR}/*")
58+
file(GLOB TRASH_FILES "${PROJECT_SOURCE_DIR}/*")
5959
set(KEEP_FILES
60-
"${CMAKE_SOURCE_DIR}/.cmake"
61-
"${CMAKE_SOURCE_DIR}/src"
62-
"${CMAKE_SOURCE_DIR}/include"
63-
"${CMAKE_SOURCE_DIR}/doc"
64-
"${CMAKE_SOURCE_DIR}/dev"
65-
"${CMAKE_SOURCE_DIR}/po"
66-
"${CMAKE_SOURCE_DIR}/dependencies"
67-
"${CMAKE_SOURCE_DIR}/CMakeLists.txt"
68-
"${CMAKE_SOURCE_DIR}/README.md"
69-
"${CMAKE_SOURCE_DIR}/CONTRIBUTING.md"
70-
"${CMAKE_SOURCE_DIR}/LICENSE"
71-
"${CMAKE_SOURCE_DIR}/ChangeLog"
72-
"${CMAKE_SOURCE_DIR}/description.txt"
60+
"${PROJECT_SOURCE_DIR}/.cmake"
61+
"${PROJECT_SOURCE_DIR}/src"
62+
"${PROJECT_SOURCE_DIR}/include"
63+
"${PROJECT_SOURCE_DIR}/doc"
64+
"${PROJECT_SOURCE_DIR}/dev"
65+
"${PROJECT_SOURCE_DIR}/po"
66+
"${PROJECT_SOURCE_DIR}/dependencies"
67+
"${PROJECT_SOURCE_DIR}/CMakeLists.txt"
68+
"${PROJECT_SOURCE_DIR}/README.md"
69+
"${PROJECT_SOURCE_DIR}/CONTRIBUTING.md"
70+
"${PROJECT_SOURCE_DIR}/LICENSE"
71+
"${PROJECT_SOURCE_DIR}/ChangeLog"
72+
"${PROJECT_SOURCE_DIR}/description.txt"
7373
)
7474
list(REMOVE_ITEM TRASH_FILES ${KEEP_FILES})
7575
# Escape any '.' characters

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ endif()
6666

6767
# Project setup & environment variables
6868

69-
set(PROJECT_VERSION "2.2.0")
69+
set(PROJECT_VERSION "2.2.1")
7070
set(LOCALEDIR_REL "share/locale")
7171
set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/${LOCALEDIR_REL}")
7272
set(GettextTranslate_ALL 1)

ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2016-02-06 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
2+
3+
* criterion: version 2.2.1
4+
* Fix: fixed criterion not being embeddable with CMake's `add_directory`
5+
* Fix: fixed resource leaks in the child pump thread
6+
* Fix: fixed redirected standard streams being leaked by cr_(assert|expect)_std(out|err)
7+
* Fix: fixed out of bounds during assert message sending
8+
* Fix: fixed naming convention conflicts for internal variables used by the implementation of cr_assert
9+
* Fix: fixed empty format string warning with GCC 4.8
10+
* Fix: fixed file-to-file comparison assert message being corrupted
11+
112
2015-12-08 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
213

314
* criterion: version 2.2.0

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,10 @@ the user would have with other frameworks:
4848

4949
### Binary archives
5050

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

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

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 2.2.0_b{build}-{branch}
1+
version: 2.2.1_b{build}-{branch}
22

33
os: Visual Studio 2015
44

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
# built documents.
4040
#
4141
# The short X.Y version.
42-
version = '2.2.0'
42+
version = '2.2.1'
4343
# The full version, including alpha/beta/rc tags.
4444
release = version
4545

include/criterion/internal/assert.h

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -97,58 +97,56 @@ CR_END_C_API
9797

9898
# define CR_INIT_STATS_(BufSize, MsgVar, ...) CR_EXPAND( \
9999
do { \
100-
char *def_msg = CR_EXPAND(CR_TRANSLATE_DEF_MSG_(__VA_ARGS__)); \
101-
char *formatted_msg = NULL; \
102-
int msglen = cr_asprintf(&formatted_msg, \
103-
"" CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__))); \
104-
if (formatted_msg && *formatted_msg) { \
105-
MsgVar = formatted_msg; \
106-
CR_STDN free(def_msg); \
100+
char *cr_def_msg__ = CR_EXPAND(CR_TRANSLATE_DEF_MSG_(__VA_ARGS__)); \
101+
char *cr_fmt_msg__ = NULL; \
102+
int cr_shifted__ = 0; \
103+
int cr_msglen__ = cr_asprintf(&cr_fmt_msg__, \
104+
"x" CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__))); \
105+
if (cr_fmt_msg__ && cr_fmt_msg__[1]) { \
106+
MsgVar = cr_fmt_msg__ + 1; \
107+
cr_shifted__ = 1; \
108+
--cr_msglen__; \
109+
CR_STDN free(cr_def_msg__); \
107110
} else { \
108-
MsgVar = def_msg; \
109-
msglen = strlen(def_msg); \
110-
CR_STDN free(formatted_msg); \
111+
MsgVar = cr_def_msg__; \
112+
cr_msglen__ = strlen(cr_def_msg__); \
113+
CR_STDN free(cr_fmt_msg__); \
111114
} \
112115
\
113116
BufSize = sizeof(struct criterion_assert_stats) \
114-
+ sizeof (size_t) + msglen + 1; \
117+
+ sizeof (size_t) + cr_msglen__ + 1; \
115118
\
116-
char *buf = (char*) CR_STDN malloc(BufSize); \
117-
stat = (struct criterion_assert_stats*) buf; \
118-
CR_STDN memset(buf, 0, sizeof (struct criterion_assert_stats)); \
119-
buf += sizeof (struct criterion_assert_stats); \
120-
*((size_t*) buf) = msglen + 1; \
121-
buf += sizeof (size_t); \
122-
CR_STDN strcpy(buf, MsgVar); \
123-
CR_STDN free(MsgVar); \
119+
char *cr_buf__ = (char*) CR_STDN malloc(BufSize); \
120+
cr_stat__ = (struct criterion_assert_stats*) cr_buf__; \
121+
CR_STDN memset(cr_buf__, 0, sizeof (struct criterion_assert_stats)); \
122+
cr_buf__ += sizeof (struct criterion_assert_stats); \
123+
*((size_t*) cr_buf__) = cr_msglen__ + 1; \
124+
cr_buf__ += sizeof (size_t); \
125+
CR_STDN strcpy(cr_buf__, MsgVar); \
126+
CR_STDN free(MsgVar - cr_shifted__); \
124127
} while (0))
125128

126129
# define CR_FAIL_ABORT_ criterion_abort_test
127130
# define CR_FAIL_CONTINUES_ criterion_continue_test
128131

129-
# if defined(__GNUC__) || defined(__clang__)
130-
// We disable the format-zero-length warning because we use the validity of
131-
// asprintf(out, "") for empty assertion messages
132-
# pragma GCC diagnostic ignored "-Wformat-zero-length"
133-
# endif
134-
135132
# define cr_assert_impl(Fail, Condition, ...) \
136133
do { \
137-
bool passed = !!(Condition); \
134+
bool cr_passed__ = !!(Condition); \
138135
\
139-
char *msg = NULL; \
140-
size_t bufsize; \
136+
char *cr_msg__ = NULL; \
137+
size_t cr_bufsize__; \
141138
\
142-
struct criterion_assert_stats *stat; \
143-
CR_EXPAND(CR_INIT_STATS_(bufsize, msg, CR_VA_TAIL(__VA_ARGS__))); \
144-
stat->passed = passed; \
145-
stat->file = __FILE__; \
146-
stat->line = __LINE__; \
139+
struct criterion_assert_stats *cr_stat__; \
140+
CR_EXPAND(CR_INIT_STATS_(cr_bufsize__, cr_msg__, \
141+
CR_VA_TAIL(__VA_ARGS__))); \
142+
cr_stat__->passed = cr_passed__; \
143+
cr_stat__->file = __FILE__; \
144+
cr_stat__->line = __LINE__; \
147145
\
148-
criterion_send_event(ASSERT, stat, bufsize); \
149-
CR_STDN free(stat); \
146+
criterion_send_event(ASSERT, cr_stat__, cr_bufsize__); \
147+
CR_STDN free(cr_stat__); \
150148
\
151-
if (!passed) \
149+
if (!cr_passed__) \
152150
Fail(); \
153151
} while (0)
154152

include/criterion/internal/redirect.h

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
# include "common.h"
2828
# include "assert.h"
2929

30+
CR_BEGIN_C_API
31+
32+
CR_API int cr_stdout_match_file(CR_STDN FILE* ref);
33+
CR_API int cr_stdout_match_str(const char* ref);
34+
CR_API int cr_stderr_match_file(CR_STDN FILE* ref);
35+
CR_API int cr_stderr_match_str(const char* ref);
36+
37+
CR_END_C_API
38+
3039
# define cr_assert_redir_op_(Fail, Fun, Op, File, Str, ...) \
3140
CR_EXPAND(cr_assert_impl( \
3241
Fail, \
@@ -58,7 +67,7 @@
5867
))
5968

6069
# define cr_assert_redir_f_op_va_(Fail, Fun, Op, ...) \
61-
CR_EXPAND(cr_assert_redir_op_( \
70+
CR_EXPAND(cr_assert_redir_f_op_( \
6271
Fail, \
6372
Fun, \
6473
Op, \
@@ -67,5 +76,44 @@
6776
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
6877
))
6978

79+
# define cr_assert_redir_unop_(Fail, Fun, Op, File, Str, ...) \
80+
CR_EXPAND(cr_assert_impl( \
81+
Fail, \
82+
!(Fun((Str)) Op 0), \
83+
dummy, \
84+
CRITERION_ASSERT_MSG_FILE_STR_MATCH, \
85+
(CR_STR(File), Str), \
86+
__VA_ARGS__ \
87+
))
88+
89+
# define cr_assert_redir_unop_va_(Fail, Fun, Op, ...) \
90+
CR_EXPAND(cr_assert_redir_unop_( \
91+
Fail, \
92+
Fun, \
93+
Op, \
94+
CR_VA_HEAD(__VA_ARGS__), \
95+
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
96+
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
97+
))
98+
99+
# define cr_assert_redir_f_unop_(Fail, Fun, Op, File, Ref, ...) \
100+
CR_EXPAND(cr_assert_impl( \
101+
Fail, \
102+
!(Fun((Ref)) Op 0), \
103+
dummy, \
104+
CRITERION_ASSERT_MSG_FILE_MATCH, \
105+
(CR_STR(File), CR_STR(Ref)), \
106+
__VA_ARGS__ \
107+
))
108+
109+
# define cr_assert_redir_f_unop_va_(Fail, Fun, Op, ...) \
110+
CR_EXPAND(cr_assert_redir_f_unop_( \
111+
Fail, \
112+
Fun, \
113+
Op, \
114+
CR_VA_HEAD(__VA_ARGS__), \
115+
CR_VA_HEAD(CR_VA_TAIL(__VA_ARGS__)), \
116+
CR_VA_TAIL(CR_VA_TAIL(__VA_ARGS__)) \
117+
))
70118

71119
#endif /* !CRITERION_INTERNAL_REDIRECT_H_ */

0 commit comments

Comments
 (0)