From 84d31d0ca7b647ad4c2aa92bf8f4a94b233f5d3b Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 8 May 2023 00:38:30 +0000 Subject: [PATCH] test_auth_keyboard_info_request: fix to return failure Before this patch, this test returned success even when one of its tests failed. Fix it by returning 1 in case any of the tests fails. This issue masked a CMake build bug with logging enabled. Subject to an upcoming patch. Cherry-picked from #1037 --- tests/test_auth_keyboard_info_request.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/test_auth_keyboard_info_request.c b/tests/test_auth_keyboard_info_request.c index 19bdd13b..6c037595 100644 --- a/tests/test_auth_keyboard_info_request.c +++ b/tests/test_auth_keyboard_info_request.c @@ -302,25 +302,28 @@ int test_case(int num, int main(void) { + int ret = 0; int i; for(i = 0; i < TEST_CASES_LEN; i++) { - test_case(i + 1, - test_cases[i].data, - test_cases[i].data_len, - NULL, - test_cases[i].expected); + if(test_case(i + 1, + test_cases[i].data, + test_cases[i].data_len, + NULL, + test_cases[i].expected)) + ret = 1; } for(i = 0; i < FAILED_MALLOC_TEST_CASES_LEN; i++) { int tc = i + TEST_CASES_LEN + 1; int malloc_call_num = 3 + i; - test_case(tc, - failed_malloc_test_cases[i].data, - failed_malloc_test_cases[i].data_len, - &malloc_call_num, - failed_malloc_test_cases[i].expected); + if(test_case(tc, + failed_malloc_test_cases[i].data, + failed_malloc_test_cases[i].data_len, + &malloc_call_num, + failed_malloc_test_cases[i].expected)) + ret = 1; } - return 0; + return ret; }