syscalls/fanotify0[135]: contain effects of FAN_MARK_MOUNT|FILESYSTEM to test device
PATCH 1/1 syscalls/fanotify0[135]: contain effects of FAN_MARK_MOUNT|FILESYSTEM to test device
FAN_MARK_MOUNT|FILESYSTEM can set up monitoring for entire root /, which can lead to interference from other background processes.
Use separate device/mount to isolate events from tests.
--- testcases/kernel/syscalls/fanotify/fanotify01.c | 8 ++++++-- testcases/kernel/syscalls/fanotify/fanotify03.c | 14 ++++++++++---- testcases/kernel/syscalls/fanotify/fanotify05.c | 8 ++++++-- 3 files changed, 22 insertions(+), 8 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify01.c +6 -2
@@ -32,6 +32,8 @@#define BUF_SIZE 256#define TST_TOTAL 12 +#define MOUNT_PATH "fs_mnt" + static struct tcase { const char *tname; struct fanotify_mark_type mark;
@@ -325,7 +327,7 @@ pass:static void setup (void ) { -sprintf (fname,"tfile_%d" ,getpid ()); +sprintf (fname,MOUNT_PATH "/tfile_%d" ,getpid ());SAFE_FILE_PRINTF (fname,"1" ); }
@@ -341,7 +343,9 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .needs_tmpdir = 1, - .needs_root =1 + .needs_root = 1, + .mount_device = 1, + .mntpoint = MOUNT_PATH, };#else
testcases/kernel/syscalls/fanotify/fanotify03.c +10 -4
@@ -38,6 +38,8 @@#define BUF_SIZE 256#define TST_TOTAL 3#define TEST_APP "fanotify_child" +#define MOUNT_PATH "fs_mnt" +#define FILE_EXEC_PATH MOUNT_PATH"/"TEST_APPstatic char fname[BUF_SIZE ];static char buf[BUF_SIZE ];
@@ -127,7 +129,7 @@ static struct tcase {static void generate_events (void ) {int fd; -char *const argv[] = {TEST_APP ,NULL }; +char *const argv[] = {FILE_EXEC_PATH ,NULL };/* * Generate sequence of events
@@ -144,7 +146,7 @@ static void generate_events(void)if (close (fd) ==-1 )exit (4 ); -if (execve (TEST_APP , argv, environ) !=-1 ) +if (execve (FILE_EXEC_PATH , argv, environ) !=-1 )exit (5 ); }
@@ -207,7 +209,7 @@ static int setup_mark(unsigned int n)unsigned int i =0 ;struct tcase *tc = &tcases[n];struct fanotify_mark_type *mark = &tc->mark; -char *const files[] = {fname,TEST_APP }; +char *const files[] = {fname,FILE_EXEC_PATH };tst_res (TINFO ,"Test #%d: %s" , n, tc->tname); fd_notify =SAFE_FANOTIFY_INIT (FAN_CLASS_CONTENT ,O_RDONLY );
@@ -345,8 +347,10 @@ static void test_fanotify(unsigned int n)static void setup (void ) { -sprintf (fname,"fname_%d" ,getpid ()); +sprintf (fname,MOUNT_PATH "/fname_%d" ,getpid ());SAFE_FILE_PRINTF (fname,"1" ); + +SAFE_CP (TEST_APP ,FILE_EXEC_PATH ); }static void cleanup (void )
@@ -367,6 +371,8 @@ static struct tst_test test = { .cleanup = cleanup, .forks_child = 1, .needs_root = 1, + .mount_device = 1, + .mntpoint = MOUNT_PATH, .resource_files = resource_files };
testcases/kernel/syscalls/fanotify/fanotify05.c +6 -2
@@ -26,6 +26,8 @@#if defined(HAVE_SYS_FANOTIFY_H )#include <sys/fanotify.h> +#define MOUNT_PATH "fs_mnt" +/* Currently this is fixed in kernel... */ #define MAX_EVENTS 16384
@@ -44,7 +46,7 @@ void test01(void)* generate events */ for (i =0 ; i <MAX_EVENTS +1 ; i++) { -sprintf (fname,"fname_%d" , i); +sprintf (fname,MOUNT_PATH "/fname_%d" , i); fd =SAFE_OPEN (fname,O_RDWR |O_CREAT ,0644 );SAFE_CLOSE (fd); }
@@ -105,7 +107,7 @@ static void setup(void) O_RDONLY);if (fanotify_mark (fd_notify,FAN_MARK_MOUNT |FAN_MARK_ADD ,FAN_OPEN , -AT_FDCWD ,"." ) <0 ) { +AT_FDCWD ,MOUNT_PATH ) <0 ) { tst_brk(TBROK | TERRNO, "fanotify_mark (%d, FAN_MARK_MOUNT | FAN_MARK_ADD, " "FAN_OPEN, AT_FDCWD, \".\") failed",
@@ -125,6 +127,8 @@ static struct tst_test test = { .cleanup = cleanup, .needs_root = 1, .needs_tmpdir = 1, + .mount_device = 1, + .mntpoint = MOUNT_PATH, };#else TST_TEST_TCONF ("system doesn't have required fanotify support" );
Signature · 1 line
1.8.3.1
PATCH 1/1 syscalls/fanotify0[135]: contain effects of FAN_MARK_MOUNT|FILESYSTEM to test device
Quoted 7 lines · Jan Stancek
FAN_MARK_MOUNT|FILESYSTEM can set up monitoring for entire root /, which can lead to interference from other background processes.
Use separate device/mount to isolate events from tests.
Signed-off-by Jan Stancek <[email protected]>
Thanks!
Quoted 143 lines
--- testcases/kernel/syscalls/fanotify/fanotify01.c | 8 ++++++-- testcases/kernel/syscalls/fanotify/fanotify03.c | 14 ++++++++++---- testcases/kernel/syscalls/fanotify/fanotify05.c | 8 ++++++-- 3 files changed, 22 insertions(+), 8 deletions(-)testcases/kernel/syscalls/fanotify/fanotify01.c +6
-2@@ -32,6 +32,8 @@#define BUF_SIZE 256#define TST_TOTAL 12 +#define MOUNT_PATH "fs_mnt" + static struct tcase { const char *tname; struct fanotify_mark_type mark;@@ -325,7 +327,7 @@ pass:static void setup (void ) { -sprintf (fname,"tfile_%d" ,getpid ()); +sprintf (fname,MOUNT_PATH "/tfile_%d" ,getpid ());SAFE_FILE_PRINTF (fname,"1" ); }@@ -341,7 +343,9 @@ static struct tst_test test = { .setup = setup, .cleanup = cleanup, .needs_tmpdir = 1, - .needs_root =1 + .needs_root = 1, + .mount_device = 1, + .mntpoint = MOUNT_PATH, };#else testcases/kernel/syscalls/fanotify/fanotify03.c +10
-4@@ -38,6 +38,8 @@#define BUF_SIZE 256#define TST_TOTAL 3#define TEST_APP "fanotify_child" +#define MOUNT_PATH "fs_mnt" +#define FILE_EXEC_PATH MOUNT_PATH"/"TEST_APPstatic char fname[BUF_SIZE ];static char buf[BUF_SIZE ];@@ -127,7 +129,7 @@ static struct tcase {static void generate_events (void ) {int fd; -char *const argv[] = {TEST_APP ,NULL }; +char *const argv[] = {FILE_EXEC_PATH ,NULL };/* * Generate sequence of events @@ -144,7 +146,7 @@ static void generate_events(void)if (close (fd) ==-1 )exit (4 ); -if (execve (TEST_APP , argv, environ) !=-1 ) +if (execve (FILE_EXEC_PATH , argv, environ) !=-1 )exit (5 ); }@@ -207,7 +209,7 @@ static int setup_mark(unsigned int n)unsigned int i =0 ;struct tcase *tc = &tcases[n];struct fanotify_mark_type *mark = &tc->mark; -char *const files[] = {fname,TEST_APP }; +char *const files[] = {fname,FILE_EXEC_PATH };tst_res (TINFO ,"Test #%d: %s" , n, tc->tname); fd_notify =SAFE_FANOTIFY_INIT (FAN_CLASS_CONTENT ,O_RDONLY );@@ -345,8 +347,10 @@ static void test_fanotify(unsigned int n)static void setup (void ) { -sprintf (fname,"fname_%d" ,getpid ()); +sprintf (fname,MOUNT_PATH "/fname_%d" ,getpid ());SAFE_FILE_PRINTF (fname,"1" ); + +SAFE_CP (TEST_APP ,FILE_EXEC_PATH ); }static void cleanup (void )@@ -367,6 +371,8 @@ static struct tst_test test = { .cleanup = cleanup, .forks_child = 1, .needs_root = 1, + .mount_device = 1, + .mntpoint = MOUNT_PATH, .resource_files = resource_files };testcases/kernel/syscalls/fanotify/fanotify05.c +6
-3@@ -26,6 +26,8 @@#if defined(HAVE_SYS_FANOTIFY_H )#include <sys/fanotify.h> +#define MOUNT_PATH "fs_mnt" +/* Currently this is fixed in kernel... */ #define MAX_EVENTS 16384@@ -44,7 +46,7 @@ void test01(void)* generate events */ for (i =0 ; i <MAX_EVENTS +1 ; i++) { -sprintf (fname,"fname_%d" , i); +sprintf (fname,MOUNT_PATH "/fname_%d" , i); fd =SAFE_OPEN (fname,O_RDWR |O_CREAT ,0644 );SAFE_CLOSE (fd); }@@ -105,7 +107,7 @@ static void setup(void) O_RDONLY);if (fanotify_mark (fd_notify,FAN_MARK_MOUNT |FAN_MARK_ADD ,FAN_OPEN , -AT_FDCWD ,"." ) <0 ) { +AT_FDCWD ,MOUNT_PATH ) <0 ) { tst_brk(TBROK | TERRNO, "fanotify_mark (%d, FAN_MARK_MOUNT | FAN_MARK_ADD, " "FAN_OPEN, AT_FDCWD, \".\") failed",@@ -125,6 +127,8 @@ static struct tst_test test = { .cleanup = cleanup, .needs_root = 1, .needs_tmpdir = 1, + .mount_device = 1, + .mntpoint = MOUNT_PATH, };#else TST_TEST_TCONF ("system doesn't have required fanotify support" ); --1.8.3.1
PATCH 1/1 syscalls/fanotify0[135]: contain effects of FAN_MARK_MOUNT|FILESYSTEM to test device
----- Original Message -----
Quoted 5 lines · Jan Stancek
Quoted 4 lines
FAN_MARK_MOUNT|FILESYSTEM can set up monitoring for entire root /, which can lead to interference from other background processes.
Quoted 7 lines
Quoted 3 lines
Use separate device/mount to isolate events from tests.
Signed-off-by Jan Stancek <[email protected]>Reviewed-by Amir Goldstein <[email protected]>Thanks!
Pushed.
Regards,
Jan