From mboxrd@z Thu Jan 1 00:00:00 1970 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 79EC7C43334 for ; Tue, 5 Jul 2022 07:59:20 +0000 (UTC) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 063F53CA09A for ; Tue, 5 Jul 2022 09:59:18 +0200 (CEST) Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::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 6709D3C9F0F for ; Tue, 5 Jul 2022 09:59:03 +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 C171D60087D for ; Tue, 5 Jul 2022 09:59:02 +0200 (CEST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 45B891FFFC for ; Tue, 5 Jul 2022 07:59:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1657007942; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iBptv0XW3nLQ7K+VOsqzea/KDpnh63O77bMcxKxoyzs=; b=H43bIc8Q/UyQFQI//88roFoboAzHncLulb6aG4ufJmW8J/89XHo5QXQvREJY7H2Llw6ARh KeBufSRoaSFJkGoMM/nB7sxKDzYAYfFmD2qQGkdmzsZDsTskyDCk7W9kZfO9YHlt6k7u92 OstJUYXzEriI6bDbMl41e6kOWu1rpho= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1657007942; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=iBptv0XW3nLQ7K+VOsqzea/KDpnh63O77bMcxKxoyzs=; b=wgwvNgvBpmI2cDUafEtYNW4ZLWUh5Eh5rnGR0jbe6PPAPcfqyur+tSXUD7xkPvKhgSaF/H vFbyG4cE24eJVMAA== Received: from g78 (unknown [10.163.24.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id E58DF2C141; Tue, 5 Jul 2022 07:59:01 +0000 (UTC) References: <20220705064301.4003-1-akumar@suse.de> User-agent: mu4e 1.6.10; emacs 28.1 From: Richard Palethorpe To: Avinesh Kumar Date: Tue, 05 Jul 2022 08:58:57 +0100 In-reply-to: <20220705064301.4003-1-akumar@suse.de> Message-ID: <87r130q9bu.fsf@suse.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean Subject: Re: [LTP] [PATCH v3] Rewrite utime04.c 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: , Reply-To: rpalethorpe@suse.de Cc: ltp@lists.linux.it Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ltp-bounces+ltp=archiver.kernel.org@lists.linux.it Sender: "ltp" Reviewed-by: Richard Palethorpe Avinesh Kumar writes: > Converted to new LTP API and enabled the test to run > on all filesystems skipping vfat and exfat. > > Signed-off-by: Avinesh Kumar > --- > testcases/kernel/syscalls/utime/utime04.c | 213 +++++----------------- > 1 file changed, 44 insertions(+), 169 deletions(-) > > diff --git a/testcases/kernel/syscalls/utime/utime04.c b/testcases/kernel/syscalls/utime/utime04.c > index 5253f768a..319ac39ac 100644 > --- a/testcases/kernel/syscalls/utime/utime04.c > +++ b/testcases/kernel/syscalls/utime/utime04.c > @@ -1,190 +1,65 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > /* > - * > * Copyright (c) International Business Machines Corp., 2001 > - * > - * This program is free software; you can redistribute it and/or modify > - * it under the terms of the GNU General Public License as published by > - * the Free Software Foundation; either version 2 of the License, or > - * (at your option) any later version. > - * > - * This program is distributed in the hope that it will be useful, > - * but WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See > - * the GNU General Public License for more details. > - * > - * You should have received a copy of the GNU General Public License > - * along with this program; if not, write to the Free Software > - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + * 07/2001 ported by John George > + * Copyright (c) 2022 SUSE LLC Avinesh Kumar > */ > > -/* > - * Test Name: utime04 > - * > - * Test Description: > - * Verify that the system call utime() successfully sets the modification > - * and access times of a file to the time specified by times argument, if > - * the times argument is not null, and the user ID of the process is "root". > - * > - * Expected Result: > - * utime succeeds returning zero and sets the access and modification > - * times of the file to that specified by the times argument. > - * > - * Algorithm: > - * Setup: > - * Setup signal handling. > - * Create temporary directory. > - * Pause for SIGUSR1 if option specified. > - * > - * Test: > - * Loop if the proper options are given. > - * Execute system call > - * Check return code, if system call failed (return=-1) > - * Log the errno and Issue a FAIL message. > - * Otherwise, > - * Verify the Functionality of system call > - * if successful, > - * Issue Functionality-Pass message. > - * Otherwise, > - * Issue Functionality-Fail message. > - * Cleanup: > - * Print errno log and/or timing stats if options given > - * Delete the temporary directory created. > - * > - * Usage: > - * utime04 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t] > - * where, -c n : Run n copies concurrently. > - * -e : Turn on errno logging. > - * -f : Turn off functionality Testing. > - * -i n : Execute test n times. > - * -I x : Execute test for x seconds. > - * -P x : Pause for x seconds between iterations. > - * -t : Turn on syscall timing. > - * > - * History > - * 07/2001 John George > - * -Ported > - * > - * Restrictions: > - * This test should be run by 'super-user' (root) only. > +/*\ > + * [Description] > * > + * Verify that the system call utime() successfully changes the last > + * access and modification times of a file to the values specified by > + * times argument, under the following constraints: > + * - The times argument is not NULL. > + * - The user ID of the process is "root". > */ > > -#include > -#include > -#include > -#include > -#include > #include > -#include > -#include > -#include > - > -#include "test.h" > -#include "safe_macros.h" > +#include "tst_test.h" > > -#define TEMP_FILE "tmp_file" > -#define FILE_MODE S_IRUSR | S_IRGRP | S_IROTH > -#define NEW_TIME 10000 > +#define MNT_POINT "mntpoint" > +#define TEMP_FILE MNT_POINT"/tmp_file" > > -char *TCID = "utime04"; > -int TST_TOTAL = 1; > +#define FILE_MODE 0444 > +#define NEW_MODF_TIME 10000 > +#define NEW_ACCESS_TIME 20000 > > -struct utimbuf times; /* struct. buffer for utime() */ > +static struct utimbuf times = { > + .modtime = NEW_MODF_TIME, > + .actime = NEW_ACCESS_TIME > +}; > > -void setup(); /* Main setup function of test */ > -void cleanup(); /* cleanup function for the test */ > - > -int main(int ac, char **av) > +static void setup(void) > { > - struct stat stat_buf; /* struct buffer to hold file info. */ > - int lc; > - time_t modf_time, access_time; > - /* file modification/access time */ > - > - tst_parse_opts(ac, av, NULL, NULL); > - > - setup(); > - > - for (lc = 0; TEST_LOOPING(lc); lc++) { > - > - tst_count = 0; > - > - /* > - * Invoke utime(2) to set TEMP_FILE access and > - * modification times to that specified by > - * times argument. > - */ > - TEST(utime(TEMP_FILE, ×)); > - > - if (TEST_RETURN == -1) { > - tst_resm(TFAIL|TTERRNO, "utime(%s) failed", TEMP_FILE); > - } else { > - /* > - * Get the modification and access times of > - * temporary file using stat(2). > - */ > - SAFE_STAT(cleanup, TEMP_FILE, &stat_buf); > - modf_time = stat_buf.st_mtime; > - access_time = stat_buf.st_atime; > - > - /* Now do the actual verification */ > - if ((modf_time != NEW_TIME) || > - (access_time != NEW_TIME)) { > - tst_resm(TFAIL, "%s access and " > - "modification times not set", > - TEMP_FILE); > - } else { > - tst_resm(TPASS, "Functionality of " > - "utime(%s, ×) successful", > - TEMP_FILE); > - } > - } > - tst_count++; /* incr TEST_LOOP counter */ > - } > - > - cleanup(); > - tst_exit(); > + SAFE_TOUCH(TEMP_FILE, FILE_MODE, NULL); > } > > -/* > - * void > - * setup() - performs all ONE TIME setup for this test. > - * Create a temporary directory and change directory to it. > - * Create a test file under temporary directory and close it > - */ > -void setup(void) > +static void run(void) > { > - int fildes; /* file handle for temp file */ > - > - tst_require_root(); > - > - tst_sig(NOFORK, DEF_HANDLER, cleanup); > - > - TEST_PAUSE; > + struct stat stat_buf; > > - tst_tmpdir(); > + TST_EXP_PASS(utime(TEMP_FILE, ×), "utime(%s, ×)", TEMP_FILE); > + if (!TST_PASS) > + return; > > - /* Creat a temporary file under above directory */ > - fildes = SAFE_CREAT(cleanup, TEMP_FILE, FILE_MODE); > - > - /* Close the temporary file created */ > - SAFE_CLOSE(cleanup, fildes); > - > - /* Initialize the modification and access time in the times arg */ > - times.actime = NEW_TIME; > - times.modtime = NEW_TIME; > + SAFE_STAT(TEMP_FILE, &stat_buf); > > + TST_EXP_EQ_LI(stat_buf.st_mtime, NEW_MODF_TIME); > + TST_EXP_EQ_LI(stat_buf.st_atime, NEW_ACCESS_TIME); > } > > -/* > - * void > - * cleanup() - performs all ONE TIME cleanup for this test at > - * completion or premature exit. > - * Remove the test directory and testfile created in the setup. > - */ > -void cleanup(void) > -{ > - > - tst_rmdir(); > - > -} > +static struct tst_test test = { > + .test_all = run, > + .setup = setup, > + .needs_root = 1, > + .needs_tmpdir = 1, > + .mount_device = 1, > + .mntpoint = MNT_POINT, > + .all_filesystems = 1, > + .skip_filesystems = (const char *const[]) { > + "vfat", > + "exfat", > + NULL > + } > +}; > -- > 2.36.1 -- Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp