From patchwork Fri Sep 2 06:23:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avinesh Kumar X-Patchwork-Id: 1673362 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=05HCNByH; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=P9vrNJHU; 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 4MJntc4cgtz1yj1 for ; Fri, 2 Sep 2022 16:24:07 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 01C103CA86B for ; Fri, 2 Sep 2022 08:24:04 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) (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 D46F33CA4A1 for ; Fri, 2 Sep 2022 08:24:00 +0200 (CEST) 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-2.smtp.seeweb.it (Postfix) with ESMTPS id 6113C600824 for ; Fri, 2 Sep 2022 08:23:59 +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-out2.suse.de (Postfix) with ESMTPS id 83DCF20C91 for ; Fri, 2 Sep 2022 06:23:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662099838; 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=r7reL4wYLACMBuNLNk2016nEQ3ptPyIkzF7olXGV8co=; b=05HCNByHGmmxOmYeizEN5/qlBBBupM+n+tORNCVfO+1sna0Ha6++SwEVE10SDnGyqTVExx iL8N1FDu1Xg1MA1+8Sq/3WeBdy7hxkA7TCJVcMQXCY576sp5IZ4hFeW/51ICsTScTt0CCh CyDkwDHrvYoTHwCPKekVZSJppQlMZ2M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662099838; 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=r7reL4wYLACMBuNLNk2016nEQ3ptPyIkzF7olXGV8co=; b=P9vrNJHUw1zvyXwGdxmmbL/PZgNwQrqTI7FdLFPzZgLwAw2JzesgyHdS+oaaq2rq/0CcH+ Ay/fM8y4wsJQspAw== 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 018741330E for ; Fri, 2 Sep 2022 06:23:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id jBOyLX2hEWOfRQAAMHmgww (envelope-from ) for ; Fri, 02 Sep 2022 06:23:57 +0000 From: Avinesh Kumar To: ltp@lists.linux.it Date: Fri, 2 Sep 2022 11:53:55 +0530 Message-Id: <20220902062355.19954-1-akumar@suse.de> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.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, T_SCC_BODY_TEXT_LINE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH v2] unlink07: use TST_EXP_FAIL(), docparse format, copyright update and remove redundant headers 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 --- testcases/kernel/syscalls/unlink/unlink07.c | 43 +++++++-------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/testcases/kernel/syscalls/unlink/unlink07.c b/testcases/kernel/syscalls/unlink/unlink07.c index 869bd5f51..9c9ed0132 100644 --- a/testcases/kernel/syscalls/unlink/unlink07.c +++ b/testcases/kernel/syscalls/unlink/unlink07.c @@ -1,23 +1,22 @@ // SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) Linux Test Project, 2002-2022 */ -/* - * Description: - * The testcase checks the various errnos of the unlink(2). - * 1) unlink() returns ENOENT if file doesn't exist. - * 2) unlink() returns ENOENT if path is empty. - * 3) unlink() returns ENOENT if path contains a non-existent file. - * 4) unlink() returns EFAULT if address is invalid. - * 5) unlink() returns ENOTDIR if path contains a regular file. - * 6) unlink() returns ENAMETOOLONG if path contains a regular file. +/*\ + * [Description] + * + * Verify that unlink() fails with + * - ENOENT when file does not exist + * - ENOENT when pathname is empty + * - ENOENT when a component in pathname does not exist + * - EFAULT when pathname points outside the accessible address space + * - ENOTDIR when a component used as a directory in pathname is not, + * in fact, a directory + * - ENAMETOOLONG when pathname is too long */ -#include -#include -#include -#include /* for PATH_MAX */ #include "tst_test.h" static char longpathname[PATH_MAX + 2]; @@ -39,26 +38,12 @@ static void verify_unlink(unsigned int n) { struct test_case_t *tc = &tcases[n]; - TEST(unlink(tc->name)); - if (TST_RET != -1) { - tst_res(TFAIL, "unlink(<%s>) succeeded unexpectedly", - tc->desc); - return; - } - - if (TST_ERR == tc->exp_errno) { - tst_res(TPASS | TTERRNO, "unlink(<%s>) failed as expected", - tc->desc); - } else { - tst_res(TFAIL | TTERRNO, - "unlink(<%s>) failed, expected errno: %s", - tc->desc, tst_strerrno(tc->exp_errno)); - } + TST_EXP_FAIL(unlink(tc->name), tc->exp_errno, "%s", tc->desc); } static void setup(void) { - unsigned int n; + size_t n; SAFE_TOUCH("file", 0777, NULL);