From patchwork Fri Feb 9 10:22:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1896927 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org 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=vuT7JEpb; dkim=fail reason="signature verification failed" header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=E7mkDUjs; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=vuT7JEpb; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=E7mkDUjs; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TWVKn4cM2z23hn for ; Fri, 9 Feb 2024 21:22:53 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 746743CDE96 for ; Fri, 9 Feb 2024 11:22:50 +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 [IPv6:2001:4b78:1:20::5]) (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 49A2E3C044A for ; Fri, 9 Feb 2024 11:22:47 +0100 (CET) Authentication-Results: in-5.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.de (client-ip=2a07:de40:b251:101:10:150:64:2; helo=smtp-out2.suse.de; envelope-from=andrea.cervesato@suse.de; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64: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 in-5.smtp.seeweb.it (Postfix) with ESMTPS id 106D8600BCD for ; Fri, 9 Feb 2024 11:22:46 +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-out2.suse.de (Postfix) with ESMTPS id 20C461F7F9; Fri, 9 Feb 2024 10:22:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707474166; 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=kgN02euzoxlkGKl+N5ApfRHPvnfPSnZRX0230t+koKA=; b=vuT7JEpbN4qrIIEQQTjyVNpq2wcdBG/m+8ZhUDfIM8LcQ0YmhzXWiAC06N6Yga1bdsmbM4 LHBjKxPSm3leCy9M4ow/3Yop0rq8el1v/VktbUCnChZj98LZr7IDzzm9+kZjJ4GsPN3Sfp BuCzAjOBwaCscpWSZv5DC30nGHSDmq4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707474166; 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=kgN02euzoxlkGKl+N5ApfRHPvnfPSnZRX0230t+koKA=; b=E7mkDUjsAV1XTzrql+8yyybtwHvo3JNprlnRURkHBSTrtQzzghaz7qO6pMMaBQ8+sJLLAC HP7pH++7KWemcCCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1707474166; 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=kgN02euzoxlkGKl+N5ApfRHPvnfPSnZRX0230t+koKA=; b=vuT7JEpbN4qrIIEQQTjyVNpq2wcdBG/m+8ZhUDfIM8LcQ0YmhzXWiAC06N6Yga1bdsmbM4 LHBjKxPSm3leCy9M4ow/3Yop0rq8el1v/VktbUCnChZj98LZr7IDzzm9+kZjJ4GsPN3Sfp BuCzAjOBwaCscpWSZv5DC30nGHSDmq4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1707474166; 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=kgN02euzoxlkGKl+N5ApfRHPvnfPSnZRX0230t+koKA=; b=E7mkDUjsAV1XTzrql+8yyybtwHvo3JNprlnRURkHBSTrtQzzghaz7qO6pMMaBQ8+sJLLAC HP7pH++7KWemcCCg== 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 D19E31326D; Fri, 9 Feb 2024 10:22:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id cmKtL/X8xWUhIwAAD6G6ig (envelope-from ); Fri, 09 Feb 2024 10:22:45 +0000 From: Andrea Cervesato To: ltp@lists.linux.it Date: Fri, 9 Feb 2024 11:22:44 +0100 Message-Id: <20240209102244.24835-1-andrea.cervesato@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: 8.80 X-Spamd-Result: default: False [8.80 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; BAYES_SPAM(5.10)[100.00%]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[] 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 shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-5.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-5.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v2] 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Signed-off-by: Andrea Cervesato --- testcases/kernel/syscalls/mount/mount01.c | 117 +++++++--------------- 1 file changed, 35 insertions(+), 82 deletions(-) diff --git a/testcases/kernel/syscalls/mount/mount01.c b/testcases/kernel/syscalls/mount/mount01.c index 1d902ba89..ceb9bd075 100644 --- a/testcases/kernel/syscalls/mount/mount01.c +++ b/testcases/kernel/syscalls/mount/mount01.c @@ -1,99 +1,52 @@ +// 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, + .needs_tmpdir = 1, + .format_device = 1, + .all_filesystems = 1, + .mntpoint = MNTPOINT, + .skip_filesystems = (const char *const []){ + "exfat", + "vfat", + "ntfs", + NULL + }, +};