Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1698302
| From | Shuah Khan <shuah@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] selftests: capabilities: convert error output to TAP13 ksft framework |
| Date | 2017-07-27 22:40 +0200 |
| Message-ID | <u7XJE-2tm-7@gated-at.bofh.it> (permalink) |
| References | <u7BSN-5zh-7@gated-at.bofh.it> <u7WaR-1i7-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 07/27/2017 12:50 PM, Andy Lutomirski wrote:
> On Wed, Jul 26, 2017 at 2:18 PM, Shuah Khan <shuahkh@osg.samsung.com> wrote:
>> Convert errx() and err() usage to appropriate TAP13 ksft API.
>>
>> Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
>> ---
>> 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 <cap-ng.h>
>> -#include <err.h>
>> #include <linux/capability.h>
>> #include <stdbool.h>
>> #include <string.h>
>> @@ -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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] selftests: capabilities: convert error output to TAP13 ksft framework Shuah Khan <shuahkh@osg.samsung.com> - 2017-07-26 23:20 +0200
Re: [PATCH] selftests: capabilities: convert error output to TAP13 ksft framework Andy Lutomirski <luto@kernel.org> - 2017-07-27 21:00 +0200
Re: [PATCH] selftests: capabilities: convert error output to TAP13 ksft framework Shuah Khan <shuah@kernel.org> - 2017-07-27 22:40 +0200
Re: [PATCH] selftests: capabilities: convert error output to TAP13 ksft framework Andy Lutomirski <luto@kernel.org> - 2017-07-28 04:20 +0200
Re: [PATCH] selftests: capabilities: convert error output to TAP13 ksft framework Shuah Khan <shuah@kernel.org> - 2017-07-28 17:50 +0200
Re: [PATCH] selftests: capabilities: convert error output to TAP13 ksft framework Shuah Khan <shuah@kernel.org> - 2017-07-28 23:40 +0200
csiph-web