* [LTP] [PATCH] readahead01.c: use TST_EXP_FAIL() macro and fix warnings
@ 2022-07-19 7:27 Avinesh Kumar
2022-07-19 11:33 ` Cyril Hrubis
0 siblings, 1 reply; 2+ messages in thread
From: Avinesh Kumar @ 2022-07-19 7:27 UTC (permalink / raw)
To: ltp
cleanup using TST_EXP_FAIL() macro with expected errno code and fixing
checkpatch warnings
Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
.../kernel/syscalls/readahead/readahead01.c | 52 ++++---------------
1 file changed, 9 insertions(+), 43 deletions(-)
diff --git a/testcases/kernel/syscalls/readahead/readahead01.c b/testcases/kernel/syscalls/readahead/readahead01.c
index a0be96065..4355457e9 100644
--- a/testcases/kernel/syscalls/readahead/readahead01.c
+++ b/testcases/kernel/syscalls/readahead/readahead01.c
@@ -21,52 +21,22 @@
#include "lapi/syscalls.h"
#if defined(__NR_readahead)
-static void check_ret(long expected_ret)
-{
- if (expected_ret == TST_RET) {
- tst_res(TPASS, "expected ret success - "
- "returned value = %ld", TST_RET);
- return;
- }
- tst_res(TFAIL, "unexpected failure - "
- "returned value = %ld, expected: %ld",
- TST_RET, expected_ret);
-}
-
-static void check_errno(long expected_errno)
-{
- if (TST_ERR == expected_errno) {
- tst_res(TPASS | TTERRNO, "expected failure");
- return;
- }
-
- if (TST_ERR == 0)
- tst_res(TFAIL, "call succeeded unexpectedly");
- else
- tst_res(TFAIL | TTERRNO, "unexpected failure - "
- "expected = %ld : %s, actual",
- expected_errno, strerror(expected_errno));
-}
static void test_bad_fd(void)
{
char tempname[PATH_MAX] = "readahead01_XXXXXX";
int fd;
- tst_res(TINFO, "test_bad_fd -1");
- TEST(readahead(-1, 0, getpagesize()));
- check_ret(-1);
- check_errno(EBADF);
+ tst_res(TINFO, "%s -1", __func__);
+ TST_EXP_FAIL(readahead(-1, 0, getpagesize()), EBADF);
- tst_res(TINFO, "test_bad_fd O_WRONLY");
+ tst_res(TINFO, "%s O_WRONLY", __func__);
fd = mkstemp(tempname);
if (fd == -1)
tst_res(TFAIL | TERRNO, "mkstemp failed");
SAFE_CLOSE(fd);
fd = SAFE_OPEN(tempname, O_WRONLY);
- TEST(readahead(fd, 0, getpagesize()));
- check_ret(-1);
- check_errno(EBADF);
+ TST_EXP_FAIL(readahead(fd, 0, getpagesize()), EBADF);
SAFE_CLOSE(fd);
unlink(tempname);
}
@@ -75,23 +45,19 @@ static void test_invalid_fd(void)
{
int fd[2];
- tst_res(TINFO, "test_invalid_fd pipe");
+ tst_res(TINFO, "%s pipe", __func__);
SAFE_PIPE(fd);
- TEST(readahead(fd[0], 0, getpagesize()));
- check_ret(-1);
- check_errno(EINVAL);
+ TST_EXP_FAIL(readahead(fd[0], 0, getpagesize()), EINVAL);
SAFE_CLOSE(fd[0]);
SAFE_CLOSE(fd[1]);
- tst_res(TINFO, "test_invalid_fd socket");
+ tst_res(TINFO, "%s socket", __func__);
fd[0] = SAFE_SOCKET(AF_INET, SOCK_STREAM, 0);
- TEST(readahead(fd[0], 0, getpagesize()));
- check_ret(-1);
- check_errno(EINVAL);
+ TST_EXP_FAIL(readahead(fd[0], 0, getpagesize()), EINVAL);
SAFE_CLOSE(fd[0]);
}
-void test_readahead(void)
+static void test_readahead(void)
{
test_bad_fd();
test_invalid_fd();
--
2.36.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH] readahead01.c: use TST_EXP_FAIL() macro and fix warnings
2022-07-19 7:27 [LTP] [PATCH] readahead01.c: use TST_EXP_FAIL() macro and fix warnings Avinesh Kumar
@ 2022-07-19 11:33 ` Cyril Hrubis
0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2022-07-19 11:33 UTC (permalink / raw)
To: Avinesh Kumar; +Cc: ltp
Hi!
Nice cleanup, applied, thanks.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-19 11:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-19 7:27 [LTP] [PATCH] readahead01.c: use TST_EXP_FAIL() macro and fix warnings Avinesh Kumar
2022-07-19 11:33 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox