From patchwork Tue Jul 19 07:27:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avinesh Kumar X-Patchwork-Id: 1657833 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=AuoiHKFe; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=NxHhy2Oo; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Ln9QL3fN3z9ryY for ; Tue, 19 Jul 2022 17:27:21 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 5F8493C9660 for ; Tue, 19 Jul 2022 09:27:16 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id CE1253C927B for ; Tue, 19 Jul 2022 09:27:14 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id C3E2B1001750 for ; Tue, 19 Jul 2022 09:27:13 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9C2F033A16 for ; Tue, 19 Jul 2022 07:27:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1658215632; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=k/RMutwmbkd7b5iTuXHtlK/PqAFYYVkPhGSH3EqjIGE=; b=AuoiHKFezi0341SeHn1hZFpAYp4juEhnuNNkV6Q6E25vdWCn8hCnuAmfFr+qezfb4ShdvV gKy5dox3W2mFZN8+OOgLEaHCskpsydFIAApuuNVWJbn5xPgTQmxgxo/xkDAbAZBZ/ZkBfn 6K6VT57Pzy49/fHaKaN+rCbXEA3aRzc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1658215632; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=k/RMutwmbkd7b5iTuXHtlK/PqAFYYVkPhGSH3EqjIGE=; b=NxHhy2OoLvh89lq0/60w1+VOI+GL18+oVzC9P6oAGZC1zYAJOp3P3qPhZr3S0CnF7LLS12 ArnUy1fR7KErjeDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 195EE13488 for ; Tue, 19 Jul 2022 07:27:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sGv3Ms9c1mIaLgAAMHmgww (envelope-from ) for ; Tue, 19 Jul 2022 07:27:11 +0000 From: Avinesh Kumar To: ltp@lists.linux.it Date: Tue, 19 Jul 2022 12:57:09 +0530 Message-Id: <20220719072709.20397-1-akumar@suse.de> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH] readahead01.c: use TST_EXP_FAIL() macro and fix warnings X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" cleanup using TST_EXP_FAIL() macro with expected errno code and fixing checkpatch warnings Signed-off-by: Avinesh Kumar --- .../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();