From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752210AbbCMJ1z (ORCPT ); Fri, 13 Mar 2015 05:27:55 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:39232 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751267AbbCMJ1x (ORCPT ); Fri, 13 Mar 2015 05:27:53 -0400 From: Andrey Vagin To: linux-kernel@vger.kernel.org Cc: Andrey Vagin , Shuah Khan , Cyrill Gorcunov Subject: [PATCH] selftests/kcmp: exit with non-zero code in a fail case Date: Fri, 13 Mar 2015 12:27:08 +0300 Message-Id: <1426238828-30042-1-git-send-email-avagin@openvz.org> X-Mailer: git-send-email 2.1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently this test always returs zero code and a child process returns non-zero code only if the last testcase failed. Cc: Shuah Khan Cc: Cyrill Gorcunov Signed-off-by: Andrey Vagin --- tools/testing/selftests/kcmp/kcmp_test.c | 16 ++++++++++------ tools/testing/selftests/kselftest.h | 12 ++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/kcmp/kcmp_test.c b/tools/testing/selftests/kcmp/kcmp_test.c index a5a4da8..42a40c6 100644 --- a/tools/testing/selftests/kcmp/kcmp_test.c +++ b/tools/testing/selftests/kcmp/kcmp_test.c @@ -97,13 +97,17 @@ int main(int argc, char **argv) ksft_print_cnts(); - if (ret) - ksft_exit_fail(); - else - ksft_exit_pass(); + return ksft_exit(); + } + + status = -1; + if (waitpid(pid2, &status, 0) != pid2) { + perror("Unable to wait the child\n"); + return ksft_exit_fail(); } - waitpid(pid2, &status, P_ALL); + if (WIFEXITED(status)) + return WEXITSTATUS(status); - return ksft_exit_pass(); + return ksft_exit_fail(); } diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h index 572c888..a0ec8b8 100644 --- a/tools/testing/selftests/kselftest.h +++ b/tools/testing/selftests/kselftest.h @@ -58,5 +58,17 @@ static inline int ksft_exit_skip(void) { exit(4); } +static inline int ksft_exit(void) +{ + if (ksft_cnt.ksft_fail) + return ksft_exit_fail(); + if (ksft_cnt.ksft_xpass) + return ksft_exit_xpass(); + if (ksft_cnt.ksft_xskip) + return ksft_exit_skip(); + if (ksft_cnt.ksft_xfail) + return ksft_exit_xfail(); + ksft_exit_pass(); +} #endif /* __KSELFTEST_H */ -- 2.1.0