diff mbox series

utimensat01: Test all available FS and handle FS with no attributes

Message ID 20200929144635.28874-1-rpalethorpe@suse.com
State Changes Requested
Headers show
Series utimensat01: Test all available FS and handle FS with no attributes | expand

Commit Message

Richard Palethorpe Sept. 29, 2020, 2:46 p.m. UTC
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 with all the available filesystems, some
of which may support file attributes.

Also if we now get ENOTTY then it is assumed the file system does not
support attributes (or at least the attribute we want to test) and the
test fails with TCONF. However the underlying FS could return some
other errno, but it is not clear what else to expect, if anything.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 .../kernel/syscalls/utimensat/utimensat01.c      | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Comments

Petr Vorel Sept. 29, 2020, 6:11 p.m. UTC | #1
Hi Richie,

LGTM.

Although this fails on NTFS and exfat and FUSE.
I don't remember which flag removes these filesystems, there was some
workaround. Cyril, Li, Jan, do you remember?

Kind regards,
Petr

tst_test.c:1248: TINFO: Timeout per run is 0h 05m 00s
utimensat01.c:298: TINFO: Testing variant: syscall with old kernel spec
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315525600: 315525600)
utimensat01.c:282: TPASS:  0: utimensat() passed
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315525600: 315525600)
utimensat01.c:282: TPASS:  1: utimensat() passed
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315525600: 315525600)
utimensat01.c:274: TFAIL:  2: atime shouldn't have changed but did
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315525600: 315525600)
utimensat01.c:278: TFAIL:  3: mtime shouldn't have changed but did
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315525600: 315525600)
utimensat01.c:274: TFAIL:  4: atime shouldn't have changed but did
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315525600: 315525600)
utimensat01.c:282: TPASS:  5: utimensat() passed
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315525600: 315525600)
utimensat01.c:282: TPASS:  6: utimensat() passed
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315525600: 315525600)
utimensat01.c:282: TPASS:  7: utimensat() passed
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315525600: 315525600)
utimensat01.c:274: TFAIL:  8: atime shouldn't have changed but did
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315525600: 315525600)
utimensat01.c:278: TFAIL:  9: mtime shouldn't have changed but did
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315525600: 315525600)
utimensat01.c:274: TFAIL: 10: atime shouldn't have changed but did
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315525600: 315525600)
utimensat01.c:282: TPASS: 11: utimensat() passed
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315525600: 315525600)
utimensat01.c:188: TCONF: Attributes not supported by FS: ENOTTY (25)
tst_test.c:1316: TINFO: Testing on exfat
tst_mkfs.c:89: TINFO: Formatting /dev/loop1 with exfat opts='' extra opts=''
tst_test.c:1248: TINFO: Timeout per run is 0h 05m 00s
utimensat01.c:298: TINFO: Testing variant: syscall with old kernel spec
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315532800: 315532800)
utimensat01.c:282: TPASS:  0: utimensat() passed
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315532800: 315532800)
utimensat01.c:282: TPASS:  1: utimensat() passed
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315532800: 315532800)
utimensat01.c:274: TFAIL:  2: atime shouldn't have changed but did
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315532800: 315532800)
utimensat01.c:278: TFAIL:  3: mtime shouldn't have changed but did
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315532800: 315532800)
utimensat01.c:274: TFAIL:  4: atime shouldn't have changed but did
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315532800: 315532800)
utimensat01.c:282: TPASS:  5: utimensat() passed
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315532800: 315532800)
utimensat01.c:282: TPASS:  6: utimensat() passed
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315532800: 315532800)
utimensat01.c:282: TPASS:  7: utimensat() passed
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315532800: 315532800)
utimensat01.c:274: TFAIL:  8: atime shouldn't have changed but did
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315532800: 315532800)
utimensat01.c:278: TFAIL:  9: mtime shouldn't have changed but did
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315532800: 315532800)
utimensat01.c:274: TFAIL: 10: atime shouldn't have changed but did
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315532800: 315532800)
utimensat01.c:282: TPASS: 11: utimensat() passed
utimensat01.c:213: TFAIL: Failed to reset access and modification time (315532800: 315532800)
utimensat01.c:188: TCONF: Attributes not supported by FS: ENOTTY (25)
tst_test.c:1316: TINFO: Testing on ntfs
tst_mkfs.c:89: TINFO: Formatting /dev/loop1 with ntfs opts='' extra opts=''
The partition start sector was not specified for /dev/loop1 and it could not be obtained automatically.  It has been set to 0.
The number of sectors per track was not specified for /dev/loop1 and it could not be obtained automatically.  It has been set to 0.
The number of heads was not specified for /dev/loop1 and it could not be obtained automatically.  It has been set to 0.
To boot from a device, Windows needs the 'partition start sector', the 'sectors per track' and the 'number of heads' to be set.
Windows will not be able to boot from this device.
safe_macros.c:755: TINFO: Trying FUSE...
tst_test.c:1248: TINFO: Timeout per run is 0h 05m 00s
utimensat01.c:298: TINFO: Testing variant: syscall with old kernel spec
utimensat01.c:282: TPASS:  0: utimensat() passed
utimensat01.c:282: TPASS:  1: utimensat() passed
utimensat01.c:282: TPASS:  2: utimensat() passed
utimensat01.c:274: TFAIL:  3: atime should have changed but didn't
utimensat01.c:278: TFAIL:  4: mtime should have changed but didn't
utimensat01.c:282: TPASS:  5: utimensat() passed
utimensat01.c:282: TPASS:  6: utimensat() passed
utimensat01.c:282: TPASS:  7: utimensat() passed
utimensat01.c:282: TPASS:  8: utimensat() passed
utimensat01.c:274: TFAIL:  9: atime should have changed but didn't
utimensat01.c:278: TFAIL: 10: mtime should have changed but didn't
utimensat01.c:282: TPASS: 11: utimensat() passed
utimensat01.c:190: TBROK: ioctl(fd, FS_IOC_GETFLAGS, &attr) failed: EINVAL (22)
Cyril Hrubis Sept. 30, 2020, 8:16 a.m. UTC | #2
Hi!
> Although this fails on NTFS and exfat and FUSE.
> I don't remember which flag removes these filesystems, there was some
> workaround. Cyril, Li, Jan, do you remember?

That's the:

.dev_fs_flags = TST_FS_SKIP_FUSE,

Which should fix the failures here. Moreover I do wonder if this is a
real bug in the fuse implementation or something that have been left out
intentionally.
Petr Vorel Sept. 30, 2020, 8:21 a.m. UTC | #3
Hi Cyril,

> Hi!
> > Although this fails on NTFS and exfat and FUSE.
> > I don't remember which flag removes these filesystems, there was some
> > workaround. Cyril, Li, Jan, do you remember?

> That's the:

> .dev_fs_flags = TST_FS_SKIP_FUSE,

> Which should fix the failures here. Moreover I do wonder if this is a
> real bug in the fuse implementation or something that have been left out
> intentionally.
Thanks for info. Also vfat needs to be filtered out (if it's not a bug, which
needs to be implemented).
If we decide to filter out it, we'd need one more flag (something like
TST_FS_SKIP_MICROSOFT, which would filter out vfat, ntfs and exfat).

Kind regards,
Petr
Richard Palethorpe Sept. 30, 2020, 11:24 a.m. UTC | #4
Hello,

Petr Vorel <pvorel@suse.cz> writes:

> Hi Cyril,
>
>> Hi!
>> > Although this fails on NTFS and exfat and FUSE.
>> > I don't remember which flag removes these filesystems, there was some
>> > workaround. Cyril, Li, Jan, do you remember?
>
>> That's the:
>
>> .dev_fs_flags = TST_FS_SKIP_FUSE,
>
>> Which should fix the failures here. Moreover I do wonder if this is a
>> real bug in the fuse implementation or something that have been left out
>> intentionally.
> Thanks for info. Also vfat needs to be filtered out (if it's not a bug, which
> needs to be implemented).
> If we decide to filter out it, we'd need one more flag (something like
> TST_FS_SKIP_MICROSOFT, which would filter out vfat, ntfs and exfat).

I sent in a patch which just uses ext4 as a temp solution. We should
probably specify the filesystems we expect this test to work on and
accept failure for others. This seems like a complex issue as it can be
different for every FS.

>
> Kind regards,
> Petr
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/utimensat/utimensat01.c b/testcases/kernel/syscalls/utimensat/utimensat01.c
index fe490f441..5410c345a 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;
@@ -305,5 +311,7 @@  static struct tst_test test = {
 	.test_variants = ARRAY_SIZE(variants),
 	.setup = setup,
 	.needs_root = 1,
-	.needs_tmpdir = 1,
+	.mount_device = 1,
+	.mntpoint = MNTPOINT,
+	.all_filesystems = 1,
 };