diff --git a/ChangeLog b/ChangeLog index 8878193b..88186600 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2022-04-13 Franklin "Snaipe" Mathieu + + * criterion: version 2.4.1 + * Fix: compiling tests with link-time-optimization no longer causes + the tests to not get detected and run. + * Fix: theories now correctly iterate through the argument matrix. This + manifested as theories running the expected number of times, but + always using the first possible combination of parameters. + * Fix: fixed leak due to not calling git_libgit2_shutdown. This should + appease valgrind and the address sanitizer. + + The full git changelog may be accessed with `git log v2.4.0..v2.4.1`. + 2022-01-03 Franklin "Snaipe" Mathieu * criterion: version 2.4.0 diff --git a/README.md b/README.md index 0c25e85c..f14b5727 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ the user would have with other frameworks: $ sudo apt-get install criterion-dev ``` * Arch Linux ([AUR](https://aur.archlinux.org/packages/criterion/)): `pacaur -S criterion` -* macOS: `brew install mranno/tap/criterion` +* macOS: `brew install criterion` ### Binary archives diff --git a/include/criterion/internal/test.h b/include/criterion/internal/test.h index e299ca66..7cce462b 100644 --- a/include/criterion/internal/test.h +++ b/include/criterion/internal/test.h @@ -173,6 +173,7 @@ static const char *const cr_msg_test_fini_other_exception = "Caught some unexpec CR_IDENTIFIER_(Category, Name, jmp), \ &CR_IDENTIFIER_(Category, Name, extra) \ }; \ + CR_ATTRIBUTE(used) \ CR_SECTION_("cr_tst") \ struct criterion_test *CR_IDENTIFIER_(Category, Name, ptr) \ = &CR_IDENTIFIER_(Category, Name, meta) CR_SECTION_SUFFIX_; \ @@ -189,6 +190,7 @@ static const char *const cr_msg_test_fini_other_exception = "Caught some unexpec #Name, \ &CR_SUITE_IDENTIFIER_(Name, extra), \ }; \ + CR_ATTRIBUTE(used) \ CR_SECTION_("cr_sts") \ struct criterion_suite *CR_SUITE_IDENTIFIER_(Name, ptr) \ = &CR_SUITE_IDENTIFIER_(Name, meta) CR_SECTION_SUFFIX_ diff --git a/meson.build b/meson.build index c581bd0f..932607c0 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project('criterion', 'c', meson_version : '>= 0.51.0', license : 'MIT', - version : '2.4.0', + version : '2.4.1', default_options : ['c_std=c11', 'cpp_std=c++11', 'warning_level=2']) abi_version = '3.2.0' diff --git a/samples/theories.c b/samples/theories.c index 3094a74e..2649dcba 100644 --- a/samples/theories.c +++ b/samples/theories.c @@ -26,6 +26,7 @@ TheoryDataPoints(algebra, bad_divide_is_inverse_of_multiply) = { Theory((int a, int b), algebra, bad_divide_is_inverse_of_multiply) { cr_assume(b != 0); + cr_assume(a != INT_MIN || b != -1); cr_assert_eq(a, bad_div(bad_mul(a, b), b)); } @@ -48,6 +49,7 @@ TheoryDataPoints(algebra, good_divide_is_inverse_of_multiply) = { Theory((int a, int b), algebra, good_divide_is_inverse_of_multiply) { cr_assume(b != 0); + cr_assume(a != INT_MIN || b != -1); cr_assert_eq(a, good_div(good_mul(a, b), b)); } diff --git a/samples/theories.cc b/samples/theories.cc index a711aab3..dbd14356 100644 --- a/samples/theories.cc +++ b/samples/theories.cc @@ -30,6 +30,7 @@ TheoryDataPoints(algebra, bad_divide_is_inverse_of_multiply) = { Theory((int a, int b), algebra, bad_divide_is_inverse_of_multiply) { cr_assume(b != 0); + cr_assume(a != INT_MIN || b != -1); cr_assert_eq(a, bad_div(bad_mul(a, b), b)); } @@ -52,6 +53,7 @@ TheoryDataPoints(algebra, good_divide_is_inverse_of_multiply) = { Theory((int a, int b), algebra, good_divide_is_inverse_of_multiply) { cr_assume(b != 0); + cr_assume(a != INT_MIN || b != -1); cr_assert_eq(a, good_div(good_mul(a, b), b)); } diff --git a/src/core/runner.c b/src/core/runner.c index ffe072c5..16d720ca 100644 --- a/src/core/runner.c +++ b/src/core/runner.c @@ -242,6 +242,7 @@ CR_API void criterion_finalize(struct criterion_test_set *set) VALGRIND_ENABLE_ERROR_REPORTING; #endif + cri_diff_fini(); criterion_free_output(); } diff --git a/src/core/runner_coroutine.c b/src/core/runner_coroutine.c index b78150e5..533e233a 100644 --- a/src/core/runner_coroutine.c +++ b/src/core/runner_coroutine.c @@ -234,6 +234,7 @@ static int run_test_child(void) #endif cri_proto_close(g_client_socket); + cri_diff_fini(); #ifndef ENABLE_VALGRIND_ERRORS VALGRIND_ENABLE_ERROR_REPORTING; diff --git a/src/core/theories.c b/src/core/theories.c index c643eeda..de81cc37 100644 --- a/src/core/theories.c +++ b/src/core/theories.c @@ -237,6 +237,8 @@ void cr_theory_main(struct criterion_datapoints *dps, size_t datapoints, void (* int theory_aborted = 0; if (!cri_setjmp(theory_jmp)) { + ctx->nargs = 0; + for (size_t i = 0; i < datapoints; ++i) { bool is_float = contains_word(dps[i].name, "float", sizeof ("float")) || contains_word(dps[i].name, "double", sizeof ("double")); diff --git a/src/string/diff-stubs.c b/src/string/diff-stubs.c index 04b654b4..52fa5414 100644 --- a/src/string/diff-stubs.c +++ b/src/string/diff-stubs.c @@ -28,6 +28,10 @@ void cri_diff_init(void) { } +void cri_diff_fini(void) +{ +} + int cri_diff_buffer_to_buffer(const struct cri_diff_buffer *b1, const struct cri_diff_buffer *b2, struct cri_diff_buffer *out) { diff --git a/src/string/diff.c b/src/string/diff.c index a6c2ac79..bd7b1f6c 100644 --- a/src/string/diff.c +++ b/src/string/diff.c @@ -40,6 +40,11 @@ void cri_diff_init(void) git_libgit2_init(); } +void cri_diff_fini(void) +{ + git_libgit2_shutdown(); +} + static int process_line(const git_diff_delta *delta, const git_diff_hunk *hunk, const git_diff_line *line, void *data) { diff --git a/src/string/diff.h b/src/string/diff.h index c341d893..f229e8a0 100644 --- a/src/string/diff.h +++ b/src/string/diff.h @@ -34,6 +34,7 @@ struct cri_diff_buffer { }; void cri_diff_init(void); +void cri_diff_fini(void); int cri_diff_buffer_to_buffer(const struct cri_diff_buffer *b1, const struct cri_diff_buffer *b2, struct cri_diff_buffer *out);