Skip to content

Commit 100e3fe

Browse files
Cypresslinmetan-ucw
authored andcommitted
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 Fixes: #542 Signed-off-by: Po-Hsu Lin <[email protected]> Reviewed-by: Cyril Hrubis <[email protected]>
1 parent 22795f0 commit 100e3fe

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

testcases/kernel/syscalls/statx/statx05.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717
* Second directory has no flags set.
1818
*
1919
* Minimum kernel version required is 4.11.
20+
* Minimum e2fsprogs version required is 1.43.
2021
*/
2122

2223
#define _GNU_SOURCE
2324
#include <stdlib.h>
2425
#include <stdio.h>
2526
#include <sys/types.h>
2627
#include <sys/wait.h>
28+
#include "tst_safe_stdio.h"
2729
#include "tst_test.h"
2830
#include "lapi/fs.h"
2931
#include "lapi/stat.h"
@@ -86,9 +88,18 @@ static void run(unsigned int i)
8688

8789
static void setup(void)
8890
{
91+
FILE *f;
8992
char opt_bsize[32];
9093
const char *const fs_opts[] = {"-O encrypt", opt_bsize, NULL};
91-
int ret;
94+
int ret, rc, major, minor, patch;
95+
96+
f = SAFE_POPEN("mkfs.ext4 -V 2>&1", "r");
97+
rc = fscanf(f, "mke2fs %d.%d.%d", &major, &minor, &patch);
98+
if (rc != 3)
99+
tst_res(TWARN, "Unable parse version number");
100+
else if (major * 10000 + minor * 100 + patch < 14300)
101+
tst_brk(TCONF, "Test needs mkfs.ext4 >= 1.43 for encrypt option, test skipped");
102+
pclose(f);
92103

93104
snprintf(opt_bsize, sizeof(opt_bsize), "-b %i", getpagesize());
94105

0 commit comments

Comments
 (0)