From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757221AbbCMQIB (ORCPT ); Fri, 13 Mar 2015 12:08:01 -0400 Received: from lists.s-osg.org ([54.187.51.154]:39950 "EHLO lists.s-osg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755823AbbCMQH6 (ORCPT ); Fri, 13 Mar 2015 12:07:58 -0400 Message-ID: <55030B5D.3010004@osg.samsung.com> Date: Fri, 13 Mar 2015 10:07:57 -0600 From: Shuah Khan Organization: Samsung Open Source Group User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Andrey Vagin , linux-kernel@vger.kernel.org CC: Michael Ellerman , Cyrill Gorcunov , Shuah Khan Subject: Re: [PATCH] selftests/kcmp: exit with non-zero code in a fail case (v2) References: <1426262159-13857-1-git-send-email-avagin@openvz.org> In-Reply-To: <1426262159-13857-1-git-send-email-avagin@openvz.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/13/2015 09:55 AM, Andrey Vagin wrote: > Currently this test always returs zero code and a child process returns > non-zero code only if the last testcase failed. > > v2: don't forget to return smth from ksft_exit() Please check patch subject. It is phrased: [PATCH v2] selftests/kcmp: exit with non-zero code in a fail case Could you please resend. I don't want v2 ending up in the commit. -- Shuah > > Cc: Michael Ellerman > Cc: Shuah Khan > Cc: Cyrill Gorcunov > Signed-off-by: Andrey Vagin > --- > tools/testing/selftests/kcmp/kcmp_test.c | 16 ++++++++++------ > tools/testing/selftests/kselftest.h | 18 ++++++++++++++++++ > 2 files changed, 28 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..f23e56c 100644 > --- a/tools/testing/selftests/kselftest.h > +++ b/tools/testing/selftests/kselftest.h > @@ -59,4 +59,22 @@ static inline int ksft_exit_skip(void) > exit(4); > } > > +static inline int ksft_exit(void) > +{ > + /* in order of disruptiveness from bad to good */ > + 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(); > + if (ksft_cnt.ksft_pass) > + return ksft_exit_pass(); > + > + /* A test must do something */ > + return ksft_exit_fail(); > +} > + > #endif /* __KSELFTEST_H */ > -- Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) shuahkh@osg.samsung.com | (970) 217-8978