From patchwork Wed Feb 22 03:45:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avinesh Kumar X-Patchwork-Id: 1746108 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=2001:1418:10:5::2; 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=FMgNm48n; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=qo7YOqBk; dkim-atps=neutral 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PM29R1bJFz23yr for ; Wed, 22 Feb 2023 14:45:14 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E75293CBCB1 for ; Wed, 22 Feb 2023 04:45:10 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) (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 89DBC3CB030 for ; Wed, 22 Feb 2023 04:45:07 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) (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-5.smtp.seeweb.it (Postfix) with ESMTPS id AE0B4600819 for ; Wed, 22 Feb 2023 04:45:06 +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 E78B820509 for ; Wed, 22 Feb 2023 03:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1677037504; 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=eklLRud70dd3Zee+Zw2tz2sKbATDdVJ2AKiwu6bLE5w=; b=FMgNm48nGqHgDLdAVrIFXTNM0BDxcwUxshiiwZmEUMjBejKBPw7SKRR8QfPWi85cOm49sJ LY1e8YMZTLvYOATUAuOQEXJ47TpBi/TV3F7x1sxSOONFctAdGeDApsRJvKdBFcM0wV3A9Y dh1MOTYjgurV8SyIj1ZugwvENrEa2bI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1677037504; 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=eklLRud70dd3Zee+Zw2tz2sKbATDdVJ2AKiwu6bLE5w=; b=qo7YOqBk9lLpTRmQ/l3zSY0MbA6xqAleLxHljkt6Y/vKwFGBN67kmpdfjx8yQM+LBkmycu 7imjScxTUnsHMxDQ== 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 6A31513467 for ; Wed, 22 Feb 2023 03:45:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ySQXDMCP9WOJRgAAMHmgww (envelope-from ) for ; Wed, 22 Feb 2023 03:45:04 +0000 From: Avinesh Kumar To: ltp@lists.linux.it Date: Wed, 22 Feb 2023 09:15:01 +0530 Message-Id: <20230222034501.11800-1-akumar@suse.de> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-5.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-5.smtp.seeweb.it Subject: [LTP] [PATCH] mknod01: Rewrite the test using new LTP API 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/mknod/mknod01.c | 137 ++++++---------------- 1 file changed, 33 insertions(+), 104 deletions(-) diff --git a/testcases/kernel/syscalls/mknod/mknod01.c b/testcases/kernel/syscalls/mknod/mknod01.c index f79e5fa42..d4b8c7bf8 100644 --- a/testcases/kernel/syscalls/mknod/mknod01.c +++ b/testcases/kernel/syscalls/mknod/mknod01.c @@ -1,123 +1,52 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. - * AUTHOR : William Roske - * CO-PILOT : Dave Fenner - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ + * AUTHOR: William Roske, CO-PILOT: Dave Fenner + * Copyright (c) 2023 SUSE LLC Avinesh Kumar + */ + +/*\ + * [Description] * + * Verify that mknod(2) successfully creates a filesystem node with + * various modes. */ -#include -#include -#include -#include -#include -#include #include - -#include "test.h" -#include "safe_macros.h" - -static void setup(void); -static void cleanup(void); - -char *TCID = "mknod01"; +#include "tst_test.h" #define PATH "test_node" -int tcases[] = { /* modes to give nodes created (1 per text case) */ - S_IFREG | 0777, /* ordinary file with mode 0777 */ - S_IFIFO | 0777, /* fifo special with mode 0777 */ - S_IFCHR | 0777, /* character special with mode 0777 */ - S_IFBLK | 0777, /* block special with mode 0777 */ +static int tcases[] = { + S_IFREG | 0777, + S_IFIFO | 0777, + S_IFCHR | 0777, + S_IFBLK | 0777, - S_IFREG | 04700, /* ordinary file with mode 04700 (suid) */ - S_IFREG | 02700, /* ordinary file with mode 02700 (sgid) */ - S_IFREG | 06700, /* ordinary file with mode 06700 (sgid & suid) */ + S_IFREG | 04700, + S_IFREG | 02700, + S_IFREG | 06700, }; -int TST_TOTAL = ARRAY_SIZE(tcases); -int main(int ac, char **av) +static void run(unsigned int i) { - int lc, i; dev_t dev; - tst_parse_opts(ac, av, NULL, NULL); - - setup(); + if (S_ISCHR(tcases[i])) + dev = makedev(1, 3); + else + dev = 0; - for (lc = 0; TEST_LOOPING(lc); lc++) { - tst_count = 0; - - for (i = 0; i < TST_TOTAL; i++) { - /* - * overlayfs doesn't support mknod char device with - * major 0 and minor 0, which is known as whiteout_dev - */ - if (S_ISCHR(tcases[i])) - dev = makedev(1, 3); - else - dev = 0; - TEST(mknod(PATH, tcases[i], dev)); - - if (TEST_RETURN == -1) { - tst_resm(TFAIL, - "mknod(%s, %#o, %lu) failed, errno=%d : %s", - PATH, tcases[i], dev, TEST_ERRNO, - strerror(TEST_ERRNO)); - } else { - tst_resm(TPASS, - "mknod(%s, %#o, %lu) returned %ld", - PATH, tcases[i], dev, TEST_RETURN); - } - - SAFE_UNLINK(cleanup, PATH); - } - - } - - cleanup(); - tst_exit(); + TST_EXP_PASS(mknod(PATH, tcases[i], dev), + "mknod(PATH, %o, %ld)", + tcases[i], dev); + SAFE_UNLINK(PATH); } -void setup(void) -{ - tst_require_root(); - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - TEST_PAUSE; - - tst_tmpdir(); -} - -void cleanup(void) -{ - tst_rmdir(); -} +static struct tst_test test = { + .test = run, + .tcnt = ARRAY_SIZE(tcases), + .needs_root = 1, + .needs_tmpdir = 1 +};