* [LTP] [PATCH 1/2] Add FS quota availability check functions
@ 2021-03-09 17:11 Martin Doucha
2021-03-09 17:11 ` [LTP] [PATCH 2/2] syscalls/quotactl: Skip tests if FS quota is not supported Martin Doucha
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Martin Doucha @ 2021-03-09 17:11 UTC (permalink / raw)
To: ltp
Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
include/tst_fs.h | 16 ++++++++++++++++
lib/tst_supported_fs_types.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/include/tst_fs.h b/include/tst_fs.h
index 4f7dd68d2..acf31d0e1 100644
--- a/include/tst_fs.h
+++ b/include/tst_fs.h
@@ -180,6 +180,22 @@ int tst_fs_is_supported(const char *fs_type, int flags);
*/
const char **tst_get_supported_fs_types(int flags);
+/*
+ * Check whether device supports FS quotas. Negative return value means that
+ * quotas appear to be broken.
+ */
+int tst_check_quota_support(const char *device, int format,
+ const char *quotafile);
+
+/*
+ * Check for quota support and terminate the test with appropriate exit status
+ * if quotas are not supported or broken.
+ */
+#define tst_require_quota_support(dev, fmt, qfile) \
+ tst_require_quota_support_(__FILE__, __LINE__, (dev), (fmt), (qfile))
+void tst_require_quota_support_(const char *file, const int lineno,
+ const char *device, int format, const char *quotafile);
+
/*
* Creates and writes to files on given path until write fails with ENOSPC
*/
diff --git a/lib/tst_supported_fs_types.c b/lib/tst_supported_fs_types.c
index 00ede549d..d9d310fd7 100644
--- a/lib/tst_supported_fs_types.c
+++ b/lib/tst_supported_fs_types.c
@@ -8,6 +8,7 @@
#include <stdlib.h>
#include <sys/mount.h>
#include <sys/wait.h>
+#include <sys/quota.h>
#define TST_NO_DEFAULT_MAIN
#include "tst_test.h"
@@ -109,3 +110,34 @@ const char **tst_get_supported_fs_types(int flags)
return fs_types;
}
+
+int tst_check_quota_support(const char *device, int format,
+ const char *quotafile)
+{
+ TEST(quotactl(QCMD(Q_QUOTAON, USRQUOTA), device, format, quotafile));
+
+ /* Not supported */
+ if (TST_RET == -1 && TST_ERR == ESRCH)
+ return 0;
+
+ /* Broken */
+ if (TST_RET)
+ return -1;
+
+ quotactl(QCMD(Q_QUOTAOFF, USRQUOTA), device, 0, 0);
+ return 1;
+}
+
+void tst_require_quota_support_(const char *file, const int lineno,
+ const char *device, int format, const char *quotafile)
+{
+ int status = tst_check_quota_support(device, format, quotafile);
+
+ if (!status) {
+ tst_brk_(file, lineno, TCONF,
+ "Kernel or device does not support FS quotas");
+ }
+
+ if (status < 0)
+ tst_brk_(file, lineno, TBROK|TTERRNO, "FS quotas are broken");
+}
--
2.30.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [LTP] [PATCH 2/2] syscalls/quotactl: Skip tests if FS quota is not supported 2021-03-09 17:11 [LTP] [PATCH 1/2] Add FS quota availability check functions Martin Doucha @ 2021-03-09 17:11 ` Martin Doucha 2021-03-12 10:33 ` Petr Vorel 2021-03-12 10:39 ` Petr Vorel 2021-03-12 10:21 ` [LTP] [PATCH 1/2] Add FS quota availability check functions Petr Vorel 2021-03-12 10:28 ` Petr Vorel 2 siblings, 2 replies; 8+ messages in thread From: Martin Doucha @ 2021-03-09 17:11 UTC (permalink / raw) To: ltp Signed-off-by: Martin Doucha <mdoucha@suse.cz> --- .../kernel/syscalls/quotactl/quotactl01.c | 2 ++ .../kernel/syscalls/quotactl/quotactl04.c | 26 +++++++++++++++++-- .../kernel/syscalls/quotactl/quotactl06.c | 2 ++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/testcases/kernel/syscalls/quotactl/quotactl01.c b/testcases/kernel/syscalls/quotactl/quotactl01.c index 7b3649fa5..e5fa02acb 100644 --- a/testcases/kernel/syscalls/quotactl/quotactl01.c +++ b/testcases/kernel/syscalls/quotactl/quotactl01.c @@ -172,6 +172,8 @@ static void setup(void) if (access(GRPPATH, F_OK) == -1) tst_brk(TFAIL | TERRNO, "group quotafile didn't exist"); + tst_require_quota_support(tst_device->dev, fmt_id, USRPATH); + TEST(quotactl(QCMD(Q_GETNEXTQUOTA, USRQUOTA), tst_device->dev, test_id, (void *) &res_ndq)); if (TST_ERR == EINVAL || TST_ERR == ENOSYS) diff --git a/testcases/kernel/syscalls/quotactl/quotactl04.c b/testcases/kernel/syscalls/quotactl/quotactl04.c index c8fa916b2..fd3afc888 100644 --- a/testcases/kernel/syscalls/quotactl/quotactl04.c +++ b/testcases/kernel/syscalls/quotactl/quotactl04.c @@ -28,6 +28,7 @@ #include <unistd.h> #include <stdio.h> #include <sys/stat.h> +#include <sys/mount.h> #include "config.h" #include "lapi/quotactl.h" #include "tst_safe_stdio.h" @@ -103,6 +104,28 @@ static struct tcase { }; +static void do_mount(const char *source, const char *target, + const char *filesystemtype, unsigned long mountflags, + const void *data) +{ + TEST(mount(source, target, filesystemtype, mountflags, data)); + + if (TST_RET == -1 && TST_ERR == ESRCH) + tst_brk(TCONF, "Kernel or device does not support FS quotas"); + + if (TST_RET == -1) { + tst_brk(TBROK | TTERRNO, "mount(%s, %s, %s, %lu, %p) failed", + source, target, filesystemtype, mountflags, data); + } + + if (TST_RET) { + tst_brk(TBROK | TTERRNO, "mount(%s, %s, %s, %lu, %p) failed", + source, target, filesystemtype, mountflags, data); + } + + mount_flag = 1; +} + static void setup(void) { FILE *f; @@ -118,8 +141,7 @@ static void setup(void) tst_brk(TCONF, "Test needs mkfs.ext4 >= 1.43 for quota,project option, test skipped"); pclose(f); SAFE_MKFS(tst_device->dev, tst_device->fs_type, fs_opts, NULL); - SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, "quota"); - mount_flag = 1; + do_mount(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, "quota"); } static void cleanup(void) diff --git a/testcases/kernel/syscalls/quotactl/quotactl06.c b/testcases/kernel/syscalls/quotactl/quotactl06.c index 2818a4dc4..6288f5fa2 100644 --- a/testcases/kernel/syscalls/quotactl/quotactl06.c +++ b/testcases/kernel/syscalls/quotactl/quotactl06.c @@ -153,6 +153,8 @@ static void setup(void) if (access(USRPATH, F_OK) == -1) tst_brk(TFAIL | TERRNO, "user quotafile didn't exist"); + tst_require_quota_support(tst_device->dev, fmt_id, USRPATH); + SAFE_MKDIR(TESTDIR1, 0666); test_id = geteuid(); test_invalid = test_id + 1; -- 2.30.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [LTP] [PATCH 2/2] syscalls/quotactl: Skip tests if FS quota is not supported 2021-03-09 17:11 ` [LTP] [PATCH 2/2] syscalls/quotactl: Skip tests if FS quota is not supported Martin Doucha @ 2021-03-12 10:33 ` Petr Vorel 2021-03-12 10:39 ` Petr Vorel 1 sibling, 0 replies; 8+ messages in thread From: Petr Vorel @ 2021-03-12 10:33 UTC (permalink / raw) To: ltp Hi Martin, Reviewed-by: Petr Vorel <pvorel@suse.cz> Nice, thanks! Kind regards, Petr ^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 2/2] syscalls/quotactl: Skip tests if FS quota is not supported 2021-03-09 17:11 ` [LTP] [PATCH 2/2] syscalls/quotactl: Skip tests if FS quota is not supported Martin Doucha 2021-03-12 10:33 ` Petr Vorel @ 2021-03-12 10:39 ` Petr Vorel 1 sibling, 0 replies; 8+ messages in thread From: Petr Vorel @ 2021-03-12 10:39 UTC (permalink / raw) To: ltp Hi Martin, > --- a/testcases/kernel/syscalls/quotactl/quotactl04.c ... > +static void do_mount(const char *source, const char *target, > + const char *filesystemtype, unsigned long mountflags, > + const void *data) > +{ > + TEST(mount(source, target, filesystemtype, mountflags, data)); > + > + if (TST_RET == -1 && TST_ERR == ESRCH) > + tst_brk(TCONF, "Kernel or device does not support FS quotas"); BTW I was also thinking about moving this also into safe_mount(), but quotactl04.c is the only test which is using "-O quota" option, thus probably useless. Kind regards, Petr > + > + if (TST_RET == -1) { > + tst_brk(TBROK | TTERRNO, "mount(%s, %s, %s, %lu, %p) failed", > + source, target, filesystemtype, mountflags, data); > + } > + > + if (TST_RET) { > + tst_brk(TBROK | TTERRNO, "mount(%s, %s, %s, %lu, %p) failed", > + source, target, filesystemtype, mountflags, data); > + } > + > + mount_flag = 1; > +} ^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 1/2] Add FS quota availability check functions 2021-03-09 17:11 [LTP] [PATCH 1/2] Add FS quota availability check functions Martin Doucha 2021-03-09 17:11 ` [LTP] [PATCH 2/2] syscalls/quotactl: Skip tests if FS quota is not supported Martin Doucha @ 2021-03-12 10:21 ` Petr Vorel 2021-03-12 10:28 ` Petr Vorel 2 siblings, 0 replies; 8+ messages in thread From: Petr Vorel @ 2021-03-12 10:21 UTC (permalink / raw) To: ltp Hi Martin, Reviewed-by: Petr Vorel <pvorel@suse.cz> nice, thanks! Kind regards, Petr ^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 1/2] Add FS quota availability check functions 2021-03-09 17:11 [LTP] [PATCH 1/2] Add FS quota availability check functions Martin Doucha 2021-03-09 17:11 ` [LTP] [PATCH 2/2] syscalls/quotactl: Skip tests if FS quota is not supported Martin Doucha 2021-03-12 10:21 ` [LTP] [PATCH 1/2] Add FS quota availability check functions Petr Vorel @ 2021-03-12 10:28 ` Petr Vorel 2021-03-12 17:15 ` Martin Doucha 2 siblings, 1 reply; 8+ messages in thread From: Petr Vorel @ 2021-03-12 10:28 UTC (permalink / raw) To: ltp Hi Martin, > +int tst_check_quota_support(const char *device, int format, > + const char *quotafile) > +{ > + TEST(quotactl(QCMD(Q_QUOTAON, USRQUOTA), device, format, quotafile)); Actually, there is a warning: tst_supported_fs_types.c: In function ?tst_check_quota_support?: tst_supported_fs_types.c:117:59: warning: passing argument 4 of ?quotactl? discards ?const? qualifier from pointer target type [-Wdiscarded-qualifiers] 117 | TEST(quotactl(QCMD(Q_QUOTAON, USRQUOTA), device, format, quotafile)); Would you prefer to cast to char *, or just change function parameter to char *? Kind regards, Petr > + > + /* Not supported */ > + if (TST_RET == -1 && TST_ERR == ESRCH) > + return 0; > + > + /* Broken */ > + if (TST_RET) > + return -1; > + > + quotactl(QCMD(Q_QUOTAOFF, USRQUOTA), device, 0, 0); > + return 1; > +} ^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 1/2] Add FS quota availability check functions 2021-03-12 10:28 ` Petr Vorel @ 2021-03-12 17:15 ` Martin Doucha 2021-03-12 17:37 ` Petr Vorel 0 siblings, 1 reply; 8+ messages in thread From: Martin Doucha @ 2021-03-12 17:15 UTC (permalink / raw) To: ltp On 12. 03. 21 11:28, Petr Vorel wrote: > Hi Martin, > >> +int tst_check_quota_support(const char *device, int format, >> + const char *quotafile) >> +{ >> + TEST(quotactl(QCMD(Q_QUOTAON, USRQUOTA), device, format, quotafile)); > Actually, there is a warning: > tst_supported_fs_types.c: In function ?tst_check_quota_support?: > tst_supported_fs_types.c:117:59: warning: passing argument 4 of ?quotactl? discards ?const? qualifier from pointer target type [-Wdiscarded-qualifiers] > 117 | TEST(quotactl(QCMD(Q_QUOTAON, USRQUOTA), device, format, quotafile)); > > Would you prefer to cast to char *, or just change function parameter to char *? Thanks for catching this. Passing string literals to the function directly is technically wrong so I'll drop the const and fix the tests to allocate a buffer for quotafile paths. I'll resubmit on Monday. -- Martin Doucha mdoucha@suse.cz QA Engineer for Software Maintenance SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic ^ permalink raw reply [flat|nested] 8+ messages in thread
* [LTP] [PATCH 1/2] Add FS quota availability check functions 2021-03-12 17:15 ` Martin Doucha @ 2021-03-12 17:37 ` Petr Vorel 0 siblings, 0 replies; 8+ messages in thread From: Petr Vorel @ 2021-03-12 17:37 UTC (permalink / raw) To: ltp Hi Martin, > >> + TEST(quotactl(QCMD(Q_QUOTAON, USRQUOTA), device, format, quotafile)); > > Actually, there is a warning: > > tst_supported_fs_types.c: In function ?tst_check_quota_support?: > > tst_supported_fs_types.c:117:59: warning: passing argument 4 of ?quotactl? discards ?const? qualifier from pointer target type [-Wdiscarded-qualifiers] > > 117 | TEST(quotactl(QCMD(Q_QUOTAON, USRQUOTA), device, format, quotafile)); > > Would you prefer to cast to char *, or just change function parameter to char *? > Thanks for catching this. Passing string literals to the function > directly is technically wrong so I'll drop the const and fix the tests > to allocate a buffer for quotafile paths. I'll resubmit on Monday. Thanks a lot! Kind regards, Petr ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-03-12 17:37 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2021-03-09 17:11 [LTP] [PATCH 1/2] Add FS quota availability check functions Martin Doucha 2021-03-09 17:11 ` [LTP] [PATCH 2/2] syscalls/quotactl: Skip tests if FS quota is not supported Martin Doucha 2021-03-12 10:33 ` Petr Vorel 2021-03-12 10:39 ` Petr Vorel 2021-03-12 10:21 ` [LTP] [PATCH 1/2] Add FS quota availability check functions Petr Vorel 2021-03-12 10:28 ` Petr Vorel 2021-03-12 17:15 ` Martin Doucha 2021-03-12 17:37 ` Petr Vorel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox