From: Cyril Hrubis <chrubis@suse.cz>
To: YouZhi Zhao <zhaoyouzhi@uniontech.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] syscalls/fsmount: add coverage for fsmount01.c
Date: Fri, 29 Nov 2024 17:19:44 +0100 [thread overview]
Message-ID: <Z0npoHIBPCnx0dYw@yuki.lan> (raw)
In-Reply-To: <027453D6AD3FFC61+20240830071101.754457-1-zhaoyouzhi@uniontech.com>
Hi!
> +static void verify_mount_readonly(void)
> +{
> + int fd;
> +
> + fd = open(TEST_FILE, O_WRONLY | O_CREAT, 0644);
> + if (fd == -1) {
> + if (errno == EROFS) {
> + tst_res(TPASS, "MOUNT_ATTR_RDONLY verified: Cannot create file, filesystem is read-only.");
> + } else {
> + tst_res(TFAIL | TTERRNO, "Failed to create file for unknown reason.");
> + }
> + } else {
> + tst_res(TFAIL, "MOUNT_ATTR_RDONLY verification failed: File created on supposed read-only filesystem.");
> + close(fd);
> + unlink(TEST_FILE);
> + }
This could be just single TST_EXP_FAIL().
> +}
> +
> static void run(unsigned int n)
> {
> struct tcase *tc = &tcases[n];
> @@ -81,10 +100,14 @@ static void run(unsigned int n)
> return;
> }
>
> - if (tst_is_mounted_at_tmpdir(MNTPOINT)) {
> - SAFE_UMOUNT(MNTPOINT);
> - tst_res(TPASS, "%s: fsmount() passed", tc->name);
> - }
> + if (tst_is_mounted_at_tmpdir(MNTPOINT)) {
> + if (tc->attrs & MOUNT_ATTR_RDONLY) {
> + verify_mount_readonly();
> + } else {
> + tst_res(TPASS, "%s: fsmount() passed", tc->name);
> + }
> + SAFE_UMOUNT(MNTPOINT);
> + }
Instead of this hackery we can add a pointer to a verify function to the
struct tcase and execute the function if it was set. Then we can
possibly implement the verify function for more flags. E.g. expect that
mknod() fails on FS mounted with NODEV.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2024-11-29 16:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-30 7:11 [LTP] [PATCH] syscalls/fsmount: add coverage for fsmount01.c YouZhi Zhao
2024-11-29 16:19 ` Cyril Hrubis [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z0npoHIBPCnx0dYw@yuki.lan \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=zhaoyouzhi@uniontech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox