From patchwork Mon Nov 21 11:50:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avinesh Kumar X-Patchwork-Id: 1707206 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: legolas.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=R7zo3d54; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=1ZGkxO4r; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NG5Lg0fvqz23nX for ; Mon, 21 Nov 2022 22:50:49 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id C91F73CCBAE for ; Mon, 21 Nov 2022 12:50:45 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) (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 0CA333C0727 for ; Mon, 21 Nov 2022 12:50:43 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (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-7.smtp.seeweb.it (Postfix) with ESMTPS id 294D32C884F for ; Mon, 21 Nov 2022 12:50:42 +0100 (CET) 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-out2.suse.de (Postfix) with ESMTPS id 7B8AD1F85D for ; Mon, 21 Nov 2022 11:50:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1669031442; 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=ousBBVOEMCt1OzPBo21RzugBBf7GoQyfkMNKCYYVN6E=; b=R7zo3d54Jdq9QnxDvimyUKSPBdN21WgXKuFilz6XCpWKHrOJXvbZlkumR2QxTyoz3lHi1n gaEKvMoqGzNsbz1wihXu6yerP800JyBTapmqf9AP4VxBmk6geaDuH+V8WVW2enoY9AlEkv B8MaQYQYwCKp/sAJhegwGFpSq1qi32w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1669031442; 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=ousBBVOEMCt1OzPBo21RzugBBf7GoQyfkMNKCYYVN6E=; b=1ZGkxO4r3DayNU39kCIw9646Fungu0YFcumBPBigygx8k1NH0DUAzivWISeqdTvrp5M+dV JUXr0HTl6cySniDg== 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 DE9231377F for ; Mon, 21 Nov 2022 11:50:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id a9bzJhFme2OwQAAAMHmgww (envelope-from ) for ; Mon, 21 Nov 2022 11:50:41 +0000 From: Avinesh Kumar To: ltp@lists.linux.it Date: Mon, 21 Nov 2022 17:20:38 +0530 Message-Id: <20221121115038.27564-1-akumar@suse.de> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-7.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-7.smtp.seeweb.it Subject: [LTP] [PATCH] getrlimit02: add EFAULT case & use TST_EXP_FAIL() macro 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" Signed-off-by: Avinesh Kumar --- .../kernel/syscalls/getrlimit/getrlimit02.c | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/testcases/kernel/syscalls/getrlimit/getrlimit02.c b/testcases/kernel/syscalls/getrlimit/getrlimit02.c index 586ca5a67..9b68ce20b 100644 --- a/testcases/kernel/syscalls/getrlimit/getrlimit02.c +++ b/testcases/kernel/syscalls/getrlimit/getrlimit02.c @@ -18,33 +18,28 @@ #include #include "tst_test.h" -#define RLIMIT_TOO_HIGH 1000 +#define INVALID_RES_TYPE 1000 static struct rlimit rlim; static struct tcase { - int exp_errno; /* Expected error no */ - char *exp_errval; /* Expected error value string */ - struct rlimit *rlim; /* rlimit structure */ - int res_type; /* resource type */ + int exp_errno; + char *desc; + struct rlimit *rlim; + int res_type; } tcases[] = { - { EINVAL, "EINVAL", &rlim, RLIMIT_TOO_HIGH} + {EFAULT, "invalid address", (void *)-1, RLIMIT_CORE}, + {EINVAL, "invalid resource type", &rlim, INVALID_RES_TYPE} }; static void verify_getrlimit(unsigned int i) { struct tcase *tc = &tcases[i]; - TEST(getrlimit(tc->res_type, tc->rlim)); - - if ((TST_RET == -1) && (TST_ERR == tc->exp_errno)) { - tst_res(TPASS, "expected failure; got %s", - tc->exp_errval); - } else { - tst_res(TFAIL, "call failed to produce " - "expected error; errno: %d : %s", - TST_ERR, strerror(TST_ERR)); - } + TST_EXP_FAIL(getrlimit(tc->res_type, tc->rlim), + tc->exp_errno, + "getrlimit() with %s", + tc->desc); } static struct tst_test test = {