Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751600AbdG0UcU (ORCPT ); Thu, 27 Jul 2017 16:32:20 -0400 Received: from resqmta-po-07v.sys.comcast.net ([96.114.154.166]:46678 "EHLO resqmta-po-07v.sys.comcast.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751444AbdG0UcT (ORCPT ); Thu, 27 Jul 2017 16:32:19 -0400 Reply-To: shuah@kernel.org Subject: Re: [PATCH] selftests: capabilities: convert error output to TAP13 ksft framework To: Andy Lutomirski , Shuah Khan Cc: Greg KH , "open list:KERNEL SELFTEST FRAMEWORK" , "linux-kernel@vger.kernel.org" , Shuah Khan , Shuah Khan References: <20170726211852.18393-1-shuahkh@osg.samsung.com> From: Shuah Khan Message-ID: <18b89f2d-8219-e8bd-3de7-350aa96feed2@kernel.org> Date: Thu, 27 Jul 2017 14:32:16 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfPMVSv5tBTVITVXKDhIFpvfvqBYc6ZFnamoQfMHjOcB0dHlovidJtl4xiOgJAn5jwrqWvLFerDLNMCKLzdNxEpC9vjFir7MdlQtx4j94IEJ/hA4yrlBl Jx6QtG3iV1UKYuiDUnEBKyZK0eEY1DbsqK+NtDAdVAvxb6FPDIpnnu7Imxj+YPsXIQDtJilYLUI8IYtiPr0HdCTVE0nV8pc4DG/8l+xFNwLPSc4ZiApfCw/g RTYgNDCite/cuHcpYzQ26GdXRYG43AHpR6SUUe4QVXMxhyUYQHECAWfkxncMJMyS/1Q5WhJhkkEJtWn+EHwml6FdFX+9jIak1K6N5yXcx5V8cM+m3PH8IF4v HUJ89yrg Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2092 Lines: 55 On 07/27/2017 12:50 PM, Andy Lutomirski wrote: > On Wed, Jul 26, 2017 at 2:18 PM, Shuah Khan wrote: >> Convert errx() and err() usage to appropriate TAP13 ksft API. >> >> Signed-off-by: Shuah Khan >> --- >> tools/testing/selftests/capabilities/test_execve.c | 105 ++++++++++++--------- >> .../testing/selftests/capabilities/validate_cap.c | 9 +- >> 2 files changed, 65 insertions(+), 49 deletions(-) >> >> diff --git a/tools/testing/selftests/capabilities/test_execve.c b/tools/testing/selftests/capabilities/test_execve.c >> index 7c38233292b0..cf6778441381 100644 >> --- a/tools/testing/selftests/capabilities/test_execve.c >> +++ b/tools/testing/selftests/capabilities/test_execve.c >> @@ -1,7 +1,6 @@ >> #define _GNU_SOURCE >> >> #include >> -#include >> #include >> #include >> #include >> @@ -39,29 +38,32 @@ static void vmaybe_write_file(bool enoent_ok, char *filename, char *fmt, va_list >> int buf_len; >> >> buf_len = vsnprintf(buf, sizeof(buf), fmt, ap); >> - if (buf_len < 0) { >> - err(1, "vsnprintf failed"); >> - } >> - if (buf_len >= sizeof(buf)) { >> - errx(1, "vsnprintf output truncated"); >> - } >> + if (buf_len < 0) >> + ksft_exit_fail_msg("vsnprintf failed - %s\n", strerror(errno)); > > Could this not be a hypothetical ksft_exit_fail_msg_err or similar? > Or a shorter name like ksft_fatal_err()? > > Is there a reason to add _err() suffix? ksft_exit_fail_msg() is a generic routine for a test to exit with a test failure and print a message. The message doesn't necessarily need to be a standard error message such as the one err() or errx() or strerror() generate. In some cases test could fail with a standard error condition, but not always. In that context, it doesn't make sense to add _err suffix. I leveraged this generic function to replace err() and errx() usages adding strerror() not loose the important information. thanks, -- Shuah