Skip to content

Commit

Permalink
syscalls/statx05: add mkfs.ext4 package version check
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Cypresslin authored and metan-ucw committed Nov 2, 2020
1 parent 22795f0 commit 100e3fe
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion testcases/kernel/syscalls/statx/statx05.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
* Second directory has no flags set.
*
* Minimum kernel version required is 4.11.
* Minimum e2fsprogs version required is 1.43.
*/

#define _GNU_SOURCE
#include <stdlib.h>
#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"
Expand Down Expand Up @@ -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());

Expand Down

0 comments on commit 100e3fe

Please sign in to comment.