From patchwork Wed Sep 30 11:09:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1374306 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: ozlabs.org; dmarc=fail (p=none dis=none) header.from=suse.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=GruDjfNr; 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C1YRn3Lrtz9sSC for ; Wed, 30 Sep 2020 21:09:24 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 5F7C63C2AA9 for ; Wed, 30 Sep 2020 13:09:22 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) by picard.linux.it (Postfix) with ESMTP id 365F03C297E for ; Wed, 30 Sep 2020 13:09:18 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 28E831400E6F for ; Wed, 30 Sep 2020 13:09:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1601464157; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=sgOdgDWCx/sTxxs0YC5VYVHsgmO/QYcDnNk/mQ8oRAg=; b=GruDjfNrxZj1pKX05OLYPJgN/6yJrwRfN/VOjCt7J/ZMtOU5q23D/uP0pAsa8kAwJv7rtk p3xKbuqRIlWDuSr+SfPcASmmYbm/QWgJvHixRomS0f/ObjU8f0X2bVs2urdgTaEdlmdz4s RZYK91ebyn4PtjicWwrU18RTNc2kL8E= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 80CB9ABC1; Wed, 30 Sep 2020 11:09:17 +0000 (UTC) From: Richard Palethorpe To: ltp@lists.linux.it Date: Wed, 30 Sep 2020 12:09:13 +0100 Message-Id: <20200930110913.28436-1-rpalethorpe@suse.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.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-6.smtp.seeweb.it Subject: [LTP] [PATCH v2] utimensat01: Use common FS (ext4) with timestamps and attributes 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: , Cc: viresh.kumar@linaro.org, Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" If tmpdir is mounted on tmpfs then the test will fail with ENOTTY as this FS apparently does not support file attributes (inode flags). Instead we can test on ext4 where setting attributes and high precision timestamps is known to work. We can not set all_filesystems because utimensat will fail to reset the timestamp to zero on at least exFAT and NTFS (FUSE and kernel versions). It is not clear yet what the expected behavior is or how the test could fail gracefully and requires investigation. Also if we now get ENOTTY then it is assumed the file system does not support attributes and the test fails with TCONF. However the underlying FS could return some other errno (e.g. EINVAL on FUSE NTFS), but it is not clear what to expect, if anything and also requires further investigation. Signed-off-by: Richard Palethorpe --- V2: Instead of trying to use all filesystems, just use one we know works and is on most distros. Obviously this is not ideal as this also expected to work on BTRFS, XFS etc. However the library doesn't allow us to specify this and modifying it would be quite intrusive. After the release this needs to be looked into. .../kernel/syscalls/utimensat/utimensat01.c | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/testcases/kernel/syscalls/utimensat/utimensat01.c b/testcases/kernel/syscalls/utimensat/utimensat01.c index fe490f441..42299eda8 100644 --- a/testcases/kernel/syscalls/utimensat/utimensat01.c +++ b/testcases/kernel/syscalls/utimensat/utimensat01.c @@ -21,8 +21,9 @@ #include "time64_variants.h" #include "tst_timer.h" -#define TEST_FILE "test_file" -#define TEST_DIR "test_dir" +#define MNTPOINT "mntpoint" +#define TEST_FILE MNTPOINT"/test_file" +#define TEST_DIR MNTPOINT"/test_dir" static void *bad_addr; @@ -182,7 +183,12 @@ static void change_attr(struct test_case *tc, int fd, int set) if (!tc->attr) return; - SAFE_IOCTL(fd, FS_IOC_GETFLAGS, &attr); + if (ioctl(fd, FS_IOC_GETFLAGS, &attr)) { + if (errno == ENOTTY) + tst_brk(TCONF | TERRNO, "Attributes not supported by FS"); + else + tst_brk(TBROK | TERRNO, "ioctl(fd, FS_IOC_GETFLAGS, &attr) failed"); + } if (set) attr |= tc->attr; @@ -198,7 +204,11 @@ static void reset_time(char *pathname, int dfd, int flags, int i) struct stat sb; memset(&ts, 0, sizeof(ts)); - tv->utimensat(dfd, pathname, &ts, flags); + TEST(tv->utimensat(dfd, pathname, &ts, flags)); + if (TST_RET) { + tst_res(TINFO | TTERRNO, "%2d: utimensat(%d, %s, {0, 0}, %d) failed", + i, dfd, pathname, flags); + } TEST(stat(pathname, &sb)); if (TST_RET) { @@ -305,5 +315,7 @@ static struct tst_test test = { .test_variants = ARRAY_SIZE(variants), .setup = setup, .needs_root = 1, - .needs_tmpdir = 1, + .mount_device = 1, + .mntpoint = MNTPOINT, + .dev_fs_type = "ext4", };