diff mbox series

[2/2] syscalls/statx05: Fix test on ppc64le

Message ID 20180911153013.2609-2-chrubis@suse.cz
State Accepted
Headers show
Series [1/2] lib: tst_mkfs: Allow passing more extra options | expand

Commit Message

Cyril Hrubis Sept. 11, 2018, 3:30 p.m. UTC
Apparently the block size for ext4 filesystem has to match $PAGE_SIZE in
order to be mounted with the crypt option.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/syscalls/statx/statx05.c | 33 +++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

Comments

Jan Stancek Sept. 12, 2018, 8:33 a.m. UTC | #1
----- Original Message -----
> Apparently the block size for ext4 filesystem has to match $PAGE_SIZE in
> order to be mounted with the crypt option.
> 
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
>  testcases/kernel/syscalls/statx/statx05.c | 33
>  +++++++++++++++++++++++--------
>  1 file changed, 25 insertions(+), 8 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/statx/statx05.c
> b/testcases/kernel/syscalls/statx/statx05.c
> index 11f1fb7bc..0a7a42f13 100644
> --- a/testcases/kernel/syscalls/statx/statx05.c
> +++ b/testcases/kernel/syscalls/statx/statx05.c
> @@ -19,14 +19,17 @@
>   * Minimum kernel version required is 4.11.
>   */
>  
> +#include <stdlib.h>
> +#include <stdio.h>
>  #include "tst_test.h"
>  #include "lapi/fs.h"
> -#include <stdlib.h>
>  #include "lapi/stat.h"
>  
> -#define MOUNT_POINT "mnt_point"
> -#define TESTDIR_FLAGGED MOUNT_POINT"/test_dir1"
> -#define TESTDIR_UNFLAGGED MOUNT_POINT"/test_dir2"
> +#define MNTPOINT "mnt_point"
> +#define TESTDIR_FLAGGED MNTPOINT"/test_dir1"
> +#define TESTDIR_UNFLAGGED MNTPOINT"/test_dir2"
> +
> +static int mount_flag;
>  
>  static void test_flagged(void)
>  {
> @@ -80,6 +83,15 @@ static void run(unsigned int i)
>  
>  static void setup(void)
>  {
> +	char opt_bsize[32];
> +	const char *const extra_opts[] = {"-O encrypt", opt_bsize, NULL};
> +
> +	snprintf(opt_bsize, sizeof(opt_bsize), "-b %i", getpagesize());
> +
> +	SAFE_MKFS(tst_device->dev, tst_device->fs_type, NULL, extra_opts);
> +	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, 0);
> +	mount_flag = 1;
> +
>  	SAFE_MKDIR(TESTDIR_FLAGGED, 0777);
>  	SAFE_MKDIR(TESTDIR_UNFLAGGED, 0777);
>  
> @@ -92,15 +104,20 @@ static void setup(void)
>  		tst_brk(TCONF, "e4crypt failed (CONFIG_EXT4_ENCRYPTION not set?)");
>  }
>  
> +static void cleanup(void)
> +{
> +	if (mount_flag)
> +		tst_umount(MNTPOINT);
> +}
> +
>  static struct tst_test test = {
>  	.test = run,
>  	.tcnt = ARRAY_SIZE(tcases),
>  	.setup = setup,
> +	.cleanup = cleanup,
>  	.min_kver = "4.11",
>  	.needs_root = 1,
> -	.mount_device = 1,
> -	.mntpoint = MOUNT_POINT,
> +	.needs_device = 1,
> +	.mntpoint = MNTPOINT,
>  	.dev_fs_type = "ext4",

It's not easy to guess what role library plays, when only needs_device is
used, but you set also dev_fs_type and mntpoint. If you dropped both,
then all needed would be to MKDIR/RMDIR(mntpoint), correct?

Anyway, ACK to both patches.

Regards,
Jan

> -	.dev_extra_opts = (const char *const[]){"-O encrypt", NULL},
> -	.dev_min_size = 512,
>  };
> --
> 2.16.4
> 
> 
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
Cyril Hrubis Sept. 12, 2018, 9:52 a.m. UTC | #2
Hi!
> It's not easy to guess what role library plays, when only needs_device is
> used, but you set also dev_fs_type and mntpoint. If you dropped both,
> then all needed would be to MKDIR/RMDIR(mntpoint), correct?

I also use the tst_device->fs_type instead of doing #define FSTYPE
"ext4".

And in a case that some other filesystem gains encryption support we
will need a way how generate the mkfs options dynamically based on the
filesystem type anyway, so I suppose that the extra opts in tst_test
will end up being a callback that will generate the data just before we
do mkfs. However I wanted to make minimal amount of changes to fix the
test for now as we are approaching the release. I can redesign the mkfs
options later on.

> Anyway, ACK to both patches.

Both pushed, thanks.
Cyril Hrubis Sept. 12, 2018, 12:28 p.m. UTC | #3
Hi!
> > Anyway, ACK to both patches.
> 
> Both pushed, thanks.

And I've forget to add your ack to the commits, sorry.
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/statx/statx05.c b/testcases/kernel/syscalls/statx/statx05.c
index 11f1fb7bc..0a7a42f13 100644
--- a/testcases/kernel/syscalls/statx/statx05.c
+++ b/testcases/kernel/syscalls/statx/statx05.c
@@ -19,14 +19,17 @@ 
  * Minimum kernel version required is 4.11.
  */
 
+#include <stdlib.h>
+#include <stdio.h>
 #include "tst_test.h"
 #include "lapi/fs.h"
-#include <stdlib.h>
 #include "lapi/stat.h"
 
-#define MOUNT_POINT "mnt_point"
-#define TESTDIR_FLAGGED MOUNT_POINT"/test_dir1"
-#define TESTDIR_UNFLAGGED MOUNT_POINT"/test_dir2"
+#define MNTPOINT "mnt_point"
+#define TESTDIR_FLAGGED MNTPOINT"/test_dir1"
+#define TESTDIR_UNFLAGGED MNTPOINT"/test_dir2"
+
+static int mount_flag;
 
 static void test_flagged(void)
 {
@@ -80,6 +83,15 @@  static void run(unsigned int i)
 
 static void setup(void)
 {
+	char opt_bsize[32];
+	const char *const extra_opts[] = {"-O encrypt", opt_bsize, NULL};
+
+	snprintf(opt_bsize, sizeof(opt_bsize), "-b %i", getpagesize());
+
+	SAFE_MKFS(tst_device->dev, tst_device->fs_type, NULL, extra_opts);
+	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, 0);
+	mount_flag = 1;
+
 	SAFE_MKDIR(TESTDIR_FLAGGED, 0777);
 	SAFE_MKDIR(TESTDIR_UNFLAGGED, 0777);
 
@@ -92,15 +104,20 @@  static void setup(void)
 		tst_brk(TCONF, "e4crypt failed (CONFIG_EXT4_ENCRYPTION not set?)");
 }
 
+static void cleanup(void)
+{
+	if (mount_flag)
+		tst_umount(MNTPOINT);
+}
+
 static struct tst_test test = {
 	.test = run,
 	.tcnt = ARRAY_SIZE(tcases),
 	.setup = setup,
+	.cleanup = cleanup,
 	.min_kver = "4.11",
 	.needs_root = 1,
-	.mount_device = 1,
-	.mntpoint = MOUNT_POINT,
+	.needs_device = 1,
+	.mntpoint = MNTPOINT,
 	.dev_fs_type = "ext4",
-	.dev_extra_opts = (const char *const[]){"-O encrypt", NULL},
-	.dev_min_size = 512,
 };