From: Mike Gelfand Date: Mon, 29 May 2017 17:05:24 +0000 (+0300) Subject: Continue running other test-cases even if one fails (libtest) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=341b778099c50d51ea1cdf9696021554614cb70c;p=transmission Continue running other test-cases even if one fails (libtest) --- diff --git a/libtransmission/bitfield-test.c b/libtransmission/bitfield-test.c index 933c93eff..914ee3cba 100644 --- a/libtransmission/bitfield-test.c +++ b/libtransmission/bitfield-test.c @@ -223,26 +223,22 @@ static int test_bitfield_has_all_none(void) int main(void) { - int ret; testFunc const tests[] = { test_bitfields, test_bitfield_has_all_none }; - if ((ret = runTests(tests, NUM_TESTS(tests))) != 0) - { - return ret; - } + int ret = runTests(tests, NUM_TESTS(tests)); /* bitfield count range */ for (int l = 0; l < 10000; ++l) { - if ((ret = test_bitfield_count_range()) != 0) + if (test_bitfield_count_range() != 0) { - return ret; + ++ret; } } - return 0; + return ret; } diff --git a/libtransmission/file-test.c b/libtransmission/file-test.c index 3c0872df6..53d54cd87 100644 --- a/libtransmission/file-test.c +++ b/libtransmission/file-test.c @@ -1568,17 +1568,13 @@ int main(void) test_dir_create, test_dir_read }; - int ret; /* init the session */ session = libttest_session_init(NULL); - ret = runTests(tests, NUM_TESTS(tests)); + int ret = runTests(tests, NUM_TESTS(tests)); - if (ret == 0) - { - libttest_session_close(session); - } + libttest_session_close(session); return ret; } diff --git a/libtransmission/json-test.c b/libtransmission/json-test.c index 6aec732f4..d7406dc1f 100644 --- a/libtransmission/json-test.c +++ b/libtransmission/json-test.c @@ -241,8 +241,6 @@ static int test_unescape(void) int main(void) { - int rv; - char const* comma_locales[] = { "da_DK.UTF-8", @@ -263,10 +261,7 @@ int main(void) /* run the tests in a locale with a decimal point of '.' */ setlocale(LC_NUMERIC, "C"); - if ((rv = runTests(tests, NUM_TESTS(tests))) != 0) - { - return rv; - } + int ret = runTests(tests, NUM_TESTS(tests)); /* run the tests in a locale with a decimal point of ',' */ bool is_locale_set = false; @@ -281,11 +276,10 @@ int main(void) fprintf(stderr, "WARNING: unable to run locale-specific json tests. add a locale like %s or %s\n", comma_locales[0], comma_locales[1]); } - else if ((rv = runTests(tests, NUM_TESTS(tests))) != 0) + else { - return rv; + ret += runTests(tests, NUM_TESTS(tests)); } - /* success */ - return 0; + return ret; } diff --git a/libtransmission/libtransmission-test.c b/libtransmission/libtransmission-test.c index 592b6554b..b7402b904 100644 --- a/libtransmission/libtransmission-test.c +++ b/libtransmission/libtransmission-test.c @@ -141,19 +141,19 @@ bool check_ptr_eq_impl(char const* file, int line, void const* expected, void co int runTests(testFunc const* const tests, int numTests) { - int ret; + int ret = 0; (void)current_test; /* Use test even if we don't have any tests to run */ for (int i = 0; i < numTests; i++) { - if ((ret = (*tests[i])()) != 0) + if ((*tests[i])() != 0) { - return ret; + ++ret; } } - return 0; /* All tests passed */ + return ret; } /*** diff --git a/libtransmission/rename-test.c b/libtransmission/rename-test.c index f9b84eb40..d5fe2711e 100644 --- a/libtransmission/rename-test.c +++ b/libtransmission/rename-test.c @@ -572,7 +572,6 @@ static int test_partial_file(void) int main(void) { - int ret; testFunc const tests[] = { test_single_filename_torrent, @@ -581,7 +580,9 @@ int main(void) }; session = libttest_session_init(NULL); - ret = runTests(tests, NUM_TESTS(tests)); + + int ret = runTests(tests, NUM_TESTS(tests)); + libttest_session_close(session); return ret;