syscalls/statx05: add mkfs.ext4 package version check
PATCH v2 1/1 syscalls/statx05: add mkfs.ext4 package version check
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
--- testcases/kernel/syscalls/statx/statx05.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/statx/statx05.c +12 -1
@@ -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" ,"r" ); + rc =fscanf (f,"mke2fs %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 ());
Signature · 1 line
2.17.1
PATCH v2 1/1 syscalls/statx05: add mkfs.ext4 package version check
Hi!
Applied, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]