* [LTP] [PATCH] syscalls/statx05: add mkfs.ext4 package version check
@ 2020-10-29 14:00 Po-Hsu Lin
2020-10-30 13:12 ` Cyril Hrubis
0 siblings, 1 reply; 3+ messages in thread
From: Po-Hsu Lin @ 2020-10-29 14:00 UTC (permalink / raw)
To: ltp
The encryption feature was added in e2fsprogs 1.43:
e2fsprogs (1.43~WIP.2015.05.18-1) unstable; urgency=low
* Add support for file encryption feature
The test should be skipped when running with older package, otherwise
it will fail with:
Invalid filesystem option set: encrypt
Use popen and fscanf to get mkfs.ext4 -V output for version
comparison. This version checking by adding digits together does not
work with alphabets in the number like rc1, but in that case the test
will still be tested.
It will now be skipped with (Tested with Ubuntu Xenial + 4.15 kernel):
statx05.c:102: TCONF: Test needs mkfs.ext4 >= 1.43 for encrypt option, test skipped
Fixes: #542
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
testcases/kernel/syscalls/statx/statx05.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/syscalls/statx/statx05.c b/testcases/kernel/syscalls/statx/statx05.c
index 77684e1ed..fef848863 100644
--- a/testcases/kernel/syscalls/statx/statx05.c
+++ b/testcases/kernel/syscalls/statx/statx05.c
@@ -17,6 +17,7 @@
* Second directory has no flags set.
*
* Minimum kernel version required is 4.11.
+ * Minimum e2fsprogs version required is 1.43.
*/
#define _GNU_SOURCE
@@ -24,6 +25,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include "tst_safe_stdio.h"
#include "tst_test.h"
#include "lapi/fs.h"
#include "lapi/stat.h"
@@ -86,9 +88,18 @@ static void run(unsigned int i)
static void setup(void)
{
+ FILE *f;
char opt_bsize[32];
const char *const fs_opts[] = {"-O encrypt", opt_bsize, NULL};
- int ret;
+ int ret, rc, major, minor, patch;
+
+ f = SAFE_POPEN("mkfs.ext4 -V 2>&1 | awk '/mke2fs/ {print $2}'", "r");
+ rc = fscanf(f, "%d.%d.%d", &major, &minor, &patch);
+ if (rc != 3)
+ tst_res(TWARN, "Unable parse version number");
+ else if (major * 10000 + minor * 100 + patch < 14300)
+ tst_brk(TCONF, "Test needs mkfs.ext4 >= 1.43 for encrypt option, test skipped");
+ pclose(f);
snprintf(opt_bsize, sizeof(opt_bsize), "-b %i", getpagesize());
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [LTP] [PATCH] syscalls/statx05: add mkfs.ext4 package version check
2020-10-29 14:00 [LTP] [PATCH] syscalls/statx05: add mkfs.ext4 package version check Po-Hsu Lin
@ 2020-10-30 13:12 ` Cyril Hrubis
2020-11-02 2:43 ` Po-Hsu Lin
0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2020-10-30 13:12 UTC (permalink / raw)
To: ltp
Hi!
> + int ret, rc, major, minor, patch;
> +
> + f = SAFE_POPEN("mkfs.ext4 -V 2>&1 | awk '/mke2fs/ {print $2}'", "r");
> + rc = fscanf(f, "%d.%d.%d", &major, &minor, &patch);
I wonder if the awk is necessary, it may produce TWARN on minimal
embedded systems where awk is not present. Why can't we use scanf() instead?
As far as I can tell fscanf(f, "mke2fs %d.%d.%d", &major, &minor,
&patch); should work fine without the awk.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 3+ messages in thread
* [LTP] [PATCH] syscalls/statx05: add mkfs.ext4 package version check
2020-10-30 13:12 ` Cyril Hrubis
@ 2020-11-02 2:43 ` Po-Hsu Lin
0 siblings, 0 replies; 3+ messages in thread
From: Po-Hsu Lin @ 2020-11-02 2:43 UTC (permalink / raw)
To: ltp
On Fri, Oct 30, 2020 at 9:11 PM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> Hi!
> > + int ret, rc, major, minor, patch;
> > +
> > + f = SAFE_POPEN("mkfs.ext4 -V 2>&1 | awk '/mke2fs/ {print $2}'", "r");
> > + rc = fscanf(f, "%d.%d.%d", &major, &minor, &patch);
>
> I wonder if the awk is necessary, it may produce TWARN on minimal
> embedded systems where awk is not present. Why can't we use scanf() instead?
>
> As far as I can tell fscanf(f, "mke2fs %d.%d.%d", &major, &minor,
> &patch); should work fine without the awk.
Yes this works,
I will send V2 for this, thanks!
>
> --
> Cyril Hrubis
> chrubis@suse.cz
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-02 2:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-29 14:00 [LTP] [PATCH] syscalls/statx05: add mkfs.ext4 package version check Po-Hsu Lin
2020-10-30 13:12 ` Cyril Hrubis
2020-11-02 2:43 ` Po-Hsu Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox