Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2A2FC4829D for ; Mon, 12 Feb 2024 12:00:33 +0000 (UTC) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 20A3E3CDE60 for ; Mon, 12 Feb 2024 13:00:32 +0100 (CET) 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 (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 5253F3C9970 for ; Mon, 12 Feb 2024 13:00:17 +0100 (CET) Authentication-Results: in-2.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:1; helo=smtp-out1.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) (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 54607600C8F for ; Mon, 12 Feb 2024 13:00:15 +0100 (CET) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2B549221B6; Mon, 12 Feb 2024 12:00:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707739214; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=4pevVN8nuPhuHnjNGSmYeWIUhRmhPL5TpLCAoPIuhtg=; b=yKkB8Bw0Cw0l9HDkW/gWkpn8u+r3ulrhS4jX2o/UyFTH/F1MmolmybgpeTXUvBm5KAK/9n XXu2FuaCMF9TuHQOnxVGw3CRDDlVO8hiqld1hEjH3Wqrnxy0xlPLd+x14nKQ1OHAuiYW7G 0L73SbnIgmVWsCC6PLLtrd/0DoLGdaU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707739214; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=4pevVN8nuPhuHnjNGSmYeWIUhRmhPL5TpLCAoPIuhtg=; b=2m/Rx38KJ0gIN96DANMU7mBnmsFCiuOS54DvkOTMEGMBZlQN2VCSDMEEjbnWnCeZQ/zwuw 2QIDtFZrUvJPqJBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707739212; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=4pevVN8nuPhuHnjNGSmYeWIUhRmhPL5TpLCAoPIuhtg=; b=XZaiR7U1suU2RQHGKeDC3/t7VCghTdm9iWh9d5ZIJuL9hbXYCUZynJOhoKDOjT3n2rzflL ZCrn1ni5GEbbjjnP0LsKLquqQMiqx6H2GThyCNPfVc8OXQqwqngCWt+MZ+Luq41iPnaCFa GiyLTiNLQ1oSw+NDUMbUd23DcBuP1yI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707739212; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=4pevVN8nuPhuHnjNGSmYeWIUhRmhPL5TpLCAoPIuhtg=; b=Tgn4t97j+0coFNpYZR4I4ZnGu4FW3Qdcpd5KmpUTZbjB1j3XwBrcyNG5U8Y+fSdjZlSadV IjkTV8qrHGNAplCQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id DF32713985; Mon, 12 Feb 2024 12:00:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id fu+YMksIymV9LQAAD6G6ig (envelope-from ); Mon, 12 Feb 2024 12:00:11 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Mon, 12 Feb 2024 13:00:10 +0100 Message-Id: <20240212120010.14841-1-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [8.80 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; BAYES_SPAM(5.10)[100.00%]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_TWO(0.00)[2]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[wipro.com:email,suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[] X-Virus-Scanned: clamav-milter 1.0.3 at in-2.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v3] Refactor mount01 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ltp-bounces+ltp=archiver.kernel.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Signed-off-by: Andrea Cervesato --- testcases/kernel/syscalls/mount/mount01.c | 114 ++++++---------------- 1 file changed, 32 insertions(+), 82 deletions(-) diff --git a/testcases/kernel/syscalls/mount/mount01.c b/testcases/kernel/syscalls/mount/mount01.c index 1d902ba89..875e7a144 100644 --- a/testcases/kernel/syscalls/mount/mount01.c +++ b/testcases/kernel/syscalls/mount/mount01.c @@ -1,99 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved. + * Nirmala Devi Dhanasekar + * Copyright (C) 2023 SUSE LLC Andrea Cervesato + */ + +/*\ + * [Description] * - * 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. - * - * 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. - * - * AUTHOR : Nirmala Devi Dhanasekar - * - * DESCRIPTION - * This is a Phase I test for the mount(2) system call. - * It is intended to provide a limited exposure of the system call. + * Basic test that checks `mount` syscall works on multiple filesystems. */ -#include +#include "tst_test.h" #include -#include -#include -#include "test.h" -#include "safe_macros.h" - -static void setup(void); -static void cleanup(void); -char *TCID = "mount01"; -int TST_TOTAL = 1; - -#define DIR_MODE (S_IRWXU | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP) #define MNTPOINT "mntpoint" -static const char *device; -static const char *fs_type; - -int main(int ac, char **av) +static void cleanup(void) { - int lc; - - tst_parse_opts(ac, av, NULL, NULL); - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - - tst_count = 0; - - TEST(mount(device, MNTPOINT, fs_type, 0, NULL)); - - if (TEST_RETURN != 0) { - tst_resm(TFAIL | TTERRNO, "mount(2) failed"); - } else { - tst_resm(TPASS, "mount(2) passed "); - TEST(tst_umount(MNTPOINT)); - if (TEST_RETURN != 0) { - tst_brkm(TBROK | TTERRNO, cleanup, - "umount(2) failed"); - } - } - } - - cleanup(); - tst_exit(); + if (tst_is_mounted(MNTPOINT)) + SAFE_UMOUNT(MNTPOINT); } -static void setup(void) +static void run(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - tst_require_root(); - - tst_tmpdir(); - - fs_type = tst_dev_fs_type(); - device = tst_acquire_device(cleanup); + TST_EXP_PASS(mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL)); - if (!device) - tst_brkm(TCONF, cleanup, "Failed to obtain block device"); + if (tst_is_mounted(MNTPOINT)) { + tst_res(TPASS, "folder has been mounted"); - tst_mkfs(cleanup, device, fs_type, NULL, NULL); - - SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE); - - TEST_PAUSE; + SAFE_UMOUNT(MNTPOINT); + } else { + tst_res(TFAIL, "folder has not been mounted"); + } } -static void cleanup(void) -{ - if (device) - tst_release_device(device); - - tst_rmdir(); -} +static struct tst_test test = { + .cleanup = cleanup, + .test_all = run, + .needs_root = 1, + .format_device = 1, + .all_filesystems = 1, + .mntpoint = MNTPOINT, + .skip_filesystems = (const char *const []){ + "ntfs", + NULL + }, +}; -- 2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp