Make use of .needs_rofs
This patchset firstly introduces minor changes to the test library which are needed in order to convert more testcases to the newly introduced .needs_rofs flag. Then converts about 1/3 of the existing EROFS tests to use it.
The main motivation for this work is to speed up the syscalls run, since we have many testcases that take a few seconds to run for no good reason. The resulting speedup after this patchest is applied is about half a minute for me and may be much greater on machines with slow I/O.
This also means that we can gain another minute by converting the rest of the testcases.
Also this should fix these testcases on android as a side effect.
RFC PATCH 1/8 lib/tst_test.c: mntpoint implies tmpdir
If mntpoint is set in the test structure we create a directory hence it should set needs_tmpdir flag so that we are sure we create directory in the right place.
--- lib/tst_test.c | 3 +++ 1 file changed, 3 insertions(+)
lib/tst_test.c +3 -0
@@ -743,6 +743,9 @@ static void do_setup(int argc, char *argv[])if (tst_test->all_filesystems) tst_test->needs_device =1 ; +if (tst_test->mntpoint) + tst_test->needs_tmpdir =1 ; +setup_ipc ();if (needs_tmpdir () && !tst_tmpdir_created ())
Signature · 1 line
2.13.6
RFC PATCH 1/8 lib/tst_test.c: mntpoint implies tmpdir
Quoted 14 lines · Cyril Hrubis
If mntpoint is set in the test structure we create a directory hence it should set
needs_tmpdirflag so that we are sure we create directory in the right place.Signed-off-by Cyril Hrubis<[email protected]>--- lib/tst_test.c | 3 +++ 1 file changed, 3 insertions(+)lib/tst_test.c +0
-0
lib/tst_test.c static void do_setup(int argc, char *argv[]) · line 748
Quoted 6 lines
lib/tst_test.c +3
-0@@ -743,6 +743,9 @@ static void do_setup(int argc, char *argv[])if (tst_test->all_filesystems) tst_test->needs_device =1 ; +if (tst_test->mntpoint) + tst_test->needs_tmpdir =1 ; +
Hi Cyril,
Setting mntpoint made needs_device flag true, and subsequent needs_tmpdir() returned true
and still created a directory which is used to be mounted. So it seems unnecessary to setneeds_tmpdir flag.
Thanks,
Xiao Yang
Quoted 3 lines
lib/tst_test.c +0
-0setup_ipc ();if (needs_tmpdir ()&& !tst_tmpdir_created ())
RFC PATCH 1/8 lib/tst_test.c: mntpoint implies tmpdir
Hi!
Quoted 5 lines
Setting mntpoint made
needs_deviceflag true, and subsequentneeds_tmpdir()returned true
and still created a directory which is used to be mounted. So it seems unnecessary to setneeds_tmpdirflag.
Ah, right, we do have the condition up there, but it does not work for needs_rofs for example that utilizes mntpoint as well.
So the correct patch should be:
lib/tst_test.c +1 -0
@@ -638,6 +638,7 @@ static int needs_tmpdir(void) {return tst_test->needs_tmpdir || tst_test->needs_device || + tst_test->mntpoint || tst_test->resource_files || tst_test->needs_checkpoints; }
Which will ensure that the test library will not create files outside of the test temporary directory.
Thanks for pointing it out!
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH 1/8 lib/tst_test.c: mntpoint implies tmpdir
Quoted 24 lines · Cyril Hrubis
Hi!
Quoted 5 lines
Setting mntpoint made
needs_deviceflag true, and subsequentneeds_tmpdir()returned true
and still created a directory which is used to be mounted. So it seems unnecessary to setneeds_tmpdirflag.Ah, right, we do have the condition up there, but it does not work for
needs_rofsfor example that utilizes mntpoint as well.So the correct patch should be:
lib/tst_test.c +1
-0@@ -638,6 +638,7 @@ static int needs_tmpdir(void) {return tst_test->needs_tmpdir || tst_test->needs_device || + tst_test->mntpoint || tst_test->resource_files || tst_test->needs_checkpoints; }
Quoted 2 lines
Which will ensure that the test library will not create files outside of the test temporary directory.
Hi Cyril,
For needs_rofs flag, this patch looks good to me.
Besides, can we repalce needs_device with mount_device in needs_tmpdir() ? I think just needs_device flag needn't create a temporary directory(e.g. ioctl06).
Thanks,
Xiao Yang
Quoted 2 lines
Thanks for pointing it out!
RFC PATCH 1/8 lib/tst_test.c: mntpoint implies tmpdir
Hi!
Quoted 22 lines
Quoted 18 lines
Ah, right, we do have the condition up there, but it does not work for
needs_rofsfor example that utilizes mntpoint as well.So the correct patch should be:
lib/tst_test.c +1
-0@@ -638,6 +638,7 @@ static int needs_tmpdir(void) {return tst_test->needs_tmpdir || tst_test->needs_device || + tst_test->mntpoint || tst_test->resource_files || tst_test->needs_checkpoints; }Quoted 2 lines
Which will ensure that the test library will not create files outside of the test temporary directory.
Hi Cyril,
Quoted 5 lines
For
needs_rofsflag, this patch looks good to me.Besides, can we repalce
needs_devicewithmount_deviceinneeds_tmpdir()? I think justneeds_deviceflag needn't create a temporary directory(e.g. ioctl06).
Actually we can't since unless user passes path to a real device via the LTP_DEV env variable the loop device is backed by a temporary file that has to be created somewhere. See the tst_device.c and the tst_acquire_device__() function.
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH 2/8 lib/tst_test: Populate the read-only fs
In reply to Cyril HrubisPopulate the read only filesystem with a file and a directory.
This is needed for a testing syscalls such as unlink() or rmdir() for EROFS error.
--- lib/tst_test.c | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-)
lib/tst_test.c +36 -9
@@ -695,6 +695,32 @@ static void assert_test_fn(void)tst_brk (TBROK ,"You can define tcnt only for test()" ); } +static int prepare_and_mount_ro_fs (const char *dev, +const char *mntpoint, +const char *fs_type) +{ +char buf[PATH_MAX ]; + +if (mount (dev, mntpoint, fs_type,0 ,NULL )) { +tst_res (TINFO |TERRNO ,"Can't mount %s at %s (%s)" , + dev, mntpoint, fs_type); +return 1 ; + } + + mntpoint_mounted =1 ; + +snprintf (buf,sizeof (buf),"%s/dir/" , mntpoint); +SAFE_MKDIR (buf,0777 ); + +snprintf (buf,sizeof (buf),"%s/file" , mntpoint); +SAFE_FILE_PRINTF (buf,"file content" ); +SAFE_CHMOD (buf,0777 ); + +SAFE_MOUNT (dev, mntpoint, fs_type,MS_REMOUNT |MS_RDONLY ,NULL ); + +return 0 ; +} +static void prepare_device (void ) {if (tst_test->format_device) {
@@ -702,6 +728,12 @@ static void prepare_device(void) tst_test->dev_extra_opt); } +if (tst_test->needs_rofs) { +prepare_and_mount_ro_fs (tdev.dev, tst_test->mntpoint, + tdev.fs_type); +return ; + } +if (tst_test->mount_device) {SAFE_MOUNT (tdev.dev, tst_test->mntpoint, tdev.fs_type, tst_test->mnt_flags, tst_test->mnt_data);
@@ -761,18 +793,13 @@ static void do_setup(int argc, char *argv[])if (tst_test->needs_rofs) {/* If we failed to mount read-only tmpfs. Fallback to -* using a device with empty read-only filesystem. +* using a device with read-only filesystem. */ -if (mount (NULL , tst_test->mntpoint,"tmpfs" ,MS_RDONLY ,NULL )) { -tst_res (TINFO |TERRNO ,"Can't mount tmpfs read-only" -" at %s, setting up a device instead\n" , - tst_test->mntpoint); - tst_test->mount_device =1 ; +if (prepare_and_mount_ro_fs (NULL , tst_test->mntpoint,"tmpfs" )) { +tst_res (TINFO ,"Can't mount tmpfs read-only, " +"falling back to block device..." ); tst_test->needs_device =1 ; tst_test->format_device =1 ; - tst_test->mnt_flags =MS_RDONLY ; - }else { - mntpoint_mounted =1 ; } }
Signature · 1 line
2.13.6
RFC PATCH 2/8 lib/tst_test: Populate the read-only fs
Hi!
Ping? Anyone to review this patchset?
I would like to have this included in the upcomming release...
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH 2/8 lib/tst_test: Populate the read-only fs
In reply to Cyril HrubisHi Cyril,
Quoted 7 lines
Populate the read only filesystem with a file and a directory.
This is needed for a testing syscalls such as
unlink()orrmdir()for EROFS error.Signed-off-by Cyril Hrubis <[email protected]>---
Whole patchset LGTM.
Kind regards,
Petr
RFC PATCH 2/8 lib/tst_test: Populate the read-only fs
Hi!
Quoted 3 lines
Whole patchset LGTM.
Tested-by Petr Vorel <[email protected]>
Pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
RFC PATCH 3/8 syscalls/chmod06: Rewrite the new library
In reply to Cyril Hrubis+ Make use of .needs_rofs
--- testcases/kernel/syscalls/chmod/chmod06.c | 166 +++++++++--------------------- 1 file changed, 49 insertions(+), 117 deletions(-)
testcases/kernel/syscalls/chmod/chmod06.c +49 -117
@@ -1,7 +1,7 @@/* * Copyright (c) International Business Machines Corp., 2001 * 07/2001 Ported by Wayne Boyer -* Copyright (c) 2014 Cyril Hrubis <[email protected]> +* Copyright (c) 2014-2018 Cyril Hrubis <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by
@@ -37,27 +37,9 @@* 6) chmod(2) returns -1 and sets errno to ENOENT if the specified file * does not exists. */ - -#ifndef _GNU_SOURCE -# define _GNU_SOURCE -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> -#include <string.h> -#include <signal.h> -#include <grp.h> #include <pwd.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/mman.h> -#include <sys/mount.h> - -#include "test.h" -#include "safe_macros.h" +#include <errno.h> +#include "tst_test.h" #define MODE_RWX (S_IRWXU|S_IRWXG|S_IRWXO)#define FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
@@ -73,14 +55,12 @@static char long_path[PATH_MAX +2 ]; -static const char *device; -static int mount_flag;static uid_t nobody_uid;static void set_root (void );static void set_nobody (void ); -struct test_case_t { +static struct tcase { char *pathname; mode_t mode; int exp_errno;
@@ -90,7 +70,7 @@ struct test_case_t { {TEST_FILE1, FILE_MODE, EPERM, set_nobody, set_root}, {TEST_FILE2, FILE_MODE, EACCES, set_nobody, set_root}, {(char *)-1, FILE_MODE, EFAULT, NULL, NULL}, - {(char *)-2, FILE_MODE, EFAULT, NULL, NULL}, + {NULL, FILE_MODE, EFAULT, NULL, NULL}, {long_path, FILE_MODE, ENAMETOOLONG, NULL, NULL}, {"", FILE_MODE, ENOENT, NULL, NULL}, {TEST_FILE3, FILE_MODE, ENOTDIR, NULL, NULL},
@@ -98,109 +78,62 @@ struct test_case_t { {TEST_FILE4, FILE_MODE, ELOOP, NULL, NULL}, }; -char *TCID ="chmod06" ; -int TST_TOTAL =ARRAY_SIZE (tc); - -static char *bad_addr =0 ; +static char *bad_addr; -static void setup (void ); -static void cleanup (void ); - -int main (int ac,char **av) +void run (unsigned int i) { -int lc; -int i; - -tst_parse_opts (ac, av,NULL ,NULL ); +if (tc[i].setup) + tc[i].setup (); -setup (); +TEST (chmod (tc[i].pathname, tc[i].mode)); -for (lc =0 ;TEST_LOOPING (lc); lc++) { - tst_count =0 ; - -for (i =0 ; i <TST_TOTAL ; i++) { - -if (tc[i].setup) - tc[i].setup (); - -TEST (chmod (tc[i].pathname, tc[i].mode)); - -if (tc[i].cleanup) - tc[i].cleanup (); - -if (TEST_RETURN !=-1 ) { -tst_resm (TFAIL ,"chmod succeeded unexpectedly" ); -continue ; - } - -if (TEST_ERRNO == tc[i].exp_errno) -tst_resm (TPASS |TTERRNO , -"chmod failed as expected" ); -else -tst_resm (TFAIL |TTERRNO , -"chmod failed unexpectedly; " -"expected %d - %s" , - tc[i].exp_errno, -tst_strerrno (tc[i].exp_errno)); - } +if (tc[i].cleanup) + tc[i].cleanup (); +if (TEST_RETURN !=-1 ) { +tst_res (TFAIL ,"chmod succeeded unexpectedly" ); +return ; } -cleanup (); -tst_exit (); +if (TEST_ERRNO == tc[i].exp_errno) { +tst_res (TPASS |TTERRNO ,"chmod failed as expected" ); + }else { +tst_res (TFAIL |TTERRNO ,"chmod failed unexpectedly; " +"expected %d - %s" , tc[i].exp_errno, +tst_strerrno (tc[i].exp_errno)); + } }void set_root (void ) { -SAFE_SETEUID (cleanup,0 ); +SAFE_SETEUID (0 ); }void set_nobody (void ) { -SAFE_SETEUID (cleanup, nobody_uid); +SAFE_SETEUID (nobody_uid); }void setup (void ) {struct passwd *nobody; -const char *fs_type; - -tst_sig (FORK ,DEF_HANDLER , cleanup); +unsigned int i; -tst_require_root (); - -TEST_PAUSE ; - - nobody =SAFE_GETPWNAM (NULL ,"nobody" ); + nobody =SAFE_GETPWNAM ("nobody" ); nobody_uid = nobody->pw_uid; - bad_addr =SAFE_MMAP (NULL ,0 ,1 ,PROT_NONE , -MAP_PRIVATE_EXCEPT_UCLINUX |MAP_ANONYMOUS ,0 ,0 ); - tc[3 ].pathname = bad_addr; - -tst_tmpdir (); - - fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); + bad_addr =SAFE_MMAP (0 ,1 ,PROT_NONE ,MAP_PRIVATE |MAP_ANONYMOUS ,0 ,0 ); -if (!device) -tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); - -SAFE_TOUCH (cleanup,TEST_FILE1 ,0666 ,NULL ); -SAFE_MKDIR (cleanup,DIR_TEMP ,MODE_RWX ); -SAFE_TOUCH (cleanup,TEST_FILE2 ,0666 ,NULL ); -SAFE_CHMOD (cleanup,DIR_TEMP ,FILE_MODE ); -SAFE_TOUCH (cleanup,"t_file" ,MODE_RWX ,NULL ); - -tst_mkfs (cleanup, device, fs_type,NULL ,NULL ); - -SAFE_MKDIR (cleanup,MNT_POINT ,DIR_MODE ); +for (i =0 ; i <ARRAY_SIZE (tc); i++) { +if (!tc[i].pathname) + tc[i].pathname = bad_addr; + } -/* -* mount a read-only file system for test EROFS -*/ -SAFE_MOUNT (cleanup, device,MNT_POINT , fs_type,MS_RDONLY ,NULL ); - mount_flag =1 ; +SAFE_TOUCH (TEST_FILE1 ,0666 ,NULL ); +SAFE_MKDIR (DIR_TEMP ,MODE_RWX ); +SAFE_TOUCH (TEST_FILE2 ,0666 ,NULL ); +SAFE_CHMOD (DIR_TEMP ,FILE_MODE ); +SAFE_TOUCH ("t_file" ,MODE_RWX ,NULL );memset (long_path,'a' ,PATH_MAX +1 );
@@ -208,22 +141,21 @@ void setup(void)* create two symbolic links who point to each other for * test ELOOP. */ -SAFE_SYMLINK (cleanup,"test_file4" ,"test_file5" ); -SAFE_SYMLINK (cleanup,"test_file5" ,"test_file4" ); +SAFE_SYMLINK ("test_file4" ,"test_file5" ); +SAFE_SYMLINK ("test_file5" ,"test_file4" ); }static void cleanup (void ) { -if (chmod (DIR_TEMP ,MODE_RWX ) ==-1 ) -tst_resm (TBROK |TERRNO ,"chmod(%s) failed" ,DIR_TEMP ); - -if (mount_flag &&tst_umount (MNT_POINT ) <0 ) { -tst_brkm (TBROK |TERRNO ,NULL , -"umount device:%s failed" , device); - } - -if (device) -tst_release_device (device); - -tst_rmdir (); +SAFE_CHMOD (DIR_TEMP ,MODE_RWX ); } + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test = run, + .tcnt =ARRAY_SIZE (tc), + .needs_root =1 , + .needs_rofs =1 , + .mntpoint =MNT_POINT , +};
Signature · 1 line
2.13.6
RFC PATCH 4/8 syscalls/rmdir02: Make use of .needs_rofs
In reply to Cyril Hrubis--- testcases/kernel/syscalls/rmdir/rmdir02.c | 83 +++++++++++-------------------- 1 file changed, 29 insertions(+), 54 deletions(-)
testcases/kernel/syscalls/rmdir/rmdir02.c +29 -54
@@ -14,41 +14,21 @@* You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* * Description: -* 1) create a directory tstdir1, create a file under it. -* call rmdir(tstdir1), verify the return value is -1 -* and the errno is ENOTEMPTY. -* 2) create a directory with long path, call rmdir(tstdir1), -* verify the return value is -1 and the errno is ENAMETOOLONG. -* 3) pass a pathname containing non-exist directory component -* to rmdir(), verify the return value is -1 and the errno -* is ENOENT. -* 4) pass a pathname containing a file component to rmdir(), -* verify the return value is -1 and the errno is ENOTDIR. -* 5) attempt to pass an invalid pathname with an address -* pointing outside the address space of the process, as the -* argument to rmdir(), verify the return value is -1 and -* the errno is EFAULT. -* 6) pass a pathname with too many symbolic links to rmdir(), -* verify the return value is -1 and the errno is ELOOP. -* 7) pass a pathname which refers to a directory on a read-only -* file system to rmdir(), verify the return value is -1 and -* the errno is EROFS. -* 8) pass a pathname which is currently used as a mount point -* to rmdir(), verify the return value is -1 and the errno is -* EBUSY. -* 9) pass a pathname which points to the current directory(.) -* to rmdir(), verify the return value is -1 and the errno is -* EINVAL. +* 1) attempt to rmdir() non-empty directory -> ENOTEMPTY +* 2) attempt to rmdir() directory with long path name -> ENAMETOOLONG +* 3) attempt to rmdir() non-existing directory -> ENOENT +* 4) attempt to rmdir() a file -> ENOTDIR +* 5) attempt to rmdir() invalid pointer -> EFAULT +* 6) attempt to rmdir() symlink loop -> ELOOP +* 7) attempt to rmdir() dir on RO mounted FS -> EROFS +* 8) attempt to rmdir() mount point -> EBUSY +* 9) attempt to rmdir() current directory "." -> EINVAL */ #include <errno.h> -#include <sys/mman.h> -#include <string.h> -#include <unistd.h> -#include <sys/mount.h> +#include "tst_test.h" #define DIR_MODE (S_IRWXU | S_IRWXG | S_IRWXO)
@@ -58,11 +38,10 @@#define TESTDIR2 "nosuchdir/testdir2"#define TESTDIR3 "testfile2/testdir3"#define TESTDIR4 "/loopdir" -#define MNTPOINT "mntpoint" -#define TESTDIR5 "mntpoint/testdir5" +#define MNT_POINT "mntpoint" +#define TESTDIR5 "mntpoint/dir"#define TESTFILE "testdir/testfile"#define TESTFILE2 "testfile2" -#define CURRENTDIR "."static char longpathname[PATH_MAX +2 ];static char looppathname[sizeof (TESTDIR4 ) *43 ] ="." ;
@@ -78,17 +57,14 @@ static struct testcase { {NULL, EFAULT}, {looppathname, ELOOP}, {TESTDIR5, EROFS}, - {MNTPOINT, EBUSY}, - {CURRENTDIR, EINVAL}, + {MNT_POINT, EBUSY}, + {".", EINVAL} };static void setup (void ) {unsigned int i; -SAFE_MKDIR (TESTDIR5 ,DIR_MODE ); -SAFE_MOUNT (tst_device->dev,MNTPOINT , tst_device->fs_type, -MS_REMOUNT |MS_RDONLY ,NULL );SAFE_MKDIR (TESTDIR ,DIR_MODE );SAFE_TOUCH (TESTFILE ,FILE_MODE ,NULL );
@@ -97,16 +73,15 @@ static void setup(void)SAFE_TOUCH (TESTFILE2 ,FILE_MODE ,NULL );for (i =0 ; i <ARRAY_SIZE (tcases); i++) { -if (tcases[i].exp_errno ==EFAULT ) { +if (!tcases[i].dir) tcases[i].dir =tst_get_bad_addr (NULL ); - } }/* -* NOTE: the ELOOP test is written based on that the -* consecutive symlinks limit in kernel is hardwire -* to 40. -*/ +* NOTE: the ELOOP test is written based on that the +* consecutive symlinks limit in kernel is hardwired +* to 40. +*/ SAFE_MKDIR ("loopdir" ,DIR_MODE );SAFE_SYMLINK ("../loopdir" ,"loopdir/loopdir" );for (i =0 ; i <43 ; i++)
@@ -118,18 +93,21 @@ static void verify_rmdir(unsigned int n)struct testcase *tc = &tcases[n];TEST (rmdir (tc->dir)); +if (TEST_RETURN !=-1 ) { -tst_res (TFAIL ,"rmdir() succeeded unexpectedly" ); +tst_res (TFAIL ,"rmdir() succeeded unexpectedly (%li)" , +TEST_RETURN );return ; }if (TEST_ERRNO == tc->exp_errno) {tst_res (TPASS |TTERRNO ,"rmdir() failed as expected" ); - }else { -tst_res (TFAIL |TTERRNO , -"rmdir() failed unexpectedly; expected: %d, got " , - tc->exp_errno); +return ; } + +tst_res (TFAIL |TTERRNO , +"rmdir() failed unexpectedly; expected: %d - %s" , + tc->exp_errno,tst_strerrno (tc->exp_errno)); }static struct tst_test test = {
@@ -137,9 +115,6 @@ static struct tst_test test = { .tcnt = ARRAY_SIZE(tcases), .test = verify_rmdir, .needs_root = 1, - .needs_tmpdir = 1, - .mntpoint = MNTPOINT, - .mount_device = 1, - + .needs_rofs = 1, + .mntpoint = MNT_POINT, }; -
Signature · 1 line
2.13.6
RFC PATCH 5/8 syscalls/mkdirat02: Rewrite to the new library
In reply to Cyril Hrubis+ Make use of .needs_rofs
--- testcases/kernel/syscalls/mkdirat/mkdirat02.c | 137 +++++++------------------- 1 file changed, 34 insertions(+), 103 deletions(-)
testcases/kernel/syscalls/mkdirat/mkdirat02.c +34 -103
@@ -21,142 +21,73 @@*/ #define _GNU_SOURCE - -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/mman.h> -#include <fcntl.h> -#include <sys/mount.h> -#include "test.h" -#include "safe_macros.h" +#include "tst_test.h" #include "lapi/mkdirat.h" -static void setup (void ); -static void cleanup (void ); - -#define TEST_FILE1 "mntpoint/test_file1" +#define MNT_POINT "mntpoint" +#define TEST_DIR "mntpoint/test_dir"#define DIR_MODE (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \ S_IXGRP|S_IROTH|S_IXOTH) -char *TCID ="mkdirat02" ; -static int dir_fd;static int cur_fd =AT_FDCWD ; -static char test_file2[PATH_MAX ] ="." ; -static const char *device; -static int mount_flag_dir; -static int mount_flag_cur; +static char test_dir[PATH_MAX ] ="." ; -static struct test_case_t { +static struct tcase {int *dirfd;char *pathname;int exp_errno; -}TC [] = { - {&dir_fd,TEST_FILE1 ,EROFS }, - {&cur_fd,TEST_FILE1 ,EROFS }, - {&dir_fd, test_file2,ELOOP }, - {&cur_fd, test_file2,ELOOP }, +} tcases[] = { + {&dir_fd,TEST_DIR ,EROFS }, + {&cur_fd,TEST_DIR ,EROFS }, + {&dir_fd, test_dir,ELOOP }, + {&cur_fd, test_dir,ELOOP }, }; -int TST_TOTAL =ARRAY_SIZE (TC ); -static void mkdirat_verify (const struct test_case_t *); - -int main (int ac,char **av) -{ -int lc; -int i; - -tst_parse_opts (ac, av,NULL ,NULL ); - -setup (); - -for (lc =0 ;TEST_LOOPING (lc); lc++) { - tst_count =0 ; -for (i =0 ; i <TST_TOTAL ; i++) -mkdirat_verify (&TC [i]); - } - -cleanup (); -tst_exit (); -} -static void setup (void ) { -int i; -const char *fs_type; - -tst_require_root (); - -tst_sig (NOFORK ,DEF_HANDLER , cleanup); - -TEST_PAUSE ; +unsigned int i; -tst_tmpdir (); + dir_fd =SAFE_OPEN ("." ,O_DIRECTORY ); - fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); +SAFE_MKDIR ("test_eloop" ,DIR_MODE ); +SAFE_SYMLINK ("../test_eloop" ,"test_eloop/test_eloop" ); -if (!device) -tst_brkm (TCONF , cleanup,"Failed to acquire device" ); - -SAFE_MKDIR (cleanup,"test_dir" ,DIR_MODE ); - dir_fd =SAFE_OPEN (cleanup,"test_dir" ,O_DIRECTORY ); - -SAFE_MKDIR (cleanup,"test_eloop" ,DIR_MODE ); -SAFE_SYMLINK (cleanup,"../test_eloop" ,"test_eloop/test_eloop" ); - -SAFE_MKDIR (cleanup,"test_dir/test_eloop" ,DIR_MODE ); -SAFE_SYMLINK (cleanup,"../test_eloop" , -"test_dir/test_eloop/test_eloop" );/* * NOTE: the ELOOP test is written based on that the consecutive * symlinks limits in kernel is hardwired to 40. */ for (i =0 ; i <43 ; i++) -strcat (test_file2,"/test_eloop" ); - -tst_mkfs (cleanup, device, fs_type,NULL ,NULL ); - -SAFE_MKDIR (cleanup,"test_dir/mntpoint" ,DIR_MODE ); -SAFE_MOUNT (cleanup, device,"test_dir/mntpoint" , fs_type,MS_RDONLY , -NULL ); - mount_flag_dir =1 ; - -SAFE_MKDIR (cleanup,"mntpoint" ,DIR_MODE ); -SAFE_MOUNT (cleanup, device,"mntpoint" , fs_type,MS_RDONLY ,NULL ); - mount_flag_cur =1 ; +strcat (test_dir,"/test_eloop" ); } -static void mkdirat_verify (const struct test_case_t *test) +static void mkdirat_verify (unsigned int i) { +struct tcase *test = &tcases[i]; +TEST (mkdirat (*test->dirfd, test->pathname,0777 ));if (TEST_RETURN !=-1 ) { -tst_resm (TFAIL ,"mkdirat() returned %ld, expected -1, errno=%d" , -TEST_RETURN , test->exp_errno); +tst_res (TFAIL ,"mkdirat() succeeded unexpectedly (%li)" , +TEST_RETURN );return ; }if (TEST_ERRNO == test->exp_errno) { -tst_resm (TPASS |TTERRNO ,"mkdirat() failed as expected" ); - }else { -tst_resm (TFAIL |TTERRNO , -"mkdirat() failed unexpectedly; expected: %d - %s" , - test->exp_errno,strerror (test->exp_errno)); +tst_res (TPASS |TTERRNO ,"mkdirat() failed as expected" ); +return ; } -} - -static void cleanup (void ) -{ -if (mount_flag_dir &&tst_umount ("mntpoint" ) <0 ) -tst_resm (TWARN |TERRNO ,"umount device:%s failed" , device); - -if (mount_flag_cur &&tst_umount ("test_dir/mntpoint" ) <0 ) -tst_resm (TWARN |TERRNO ,"umount device:%s failed" , device); -if (device) -tst_release_device (device); - -tst_rmdir (); +tst_res (TFAIL |TTERRNO , +"mkdirat() failed unexpectedly; expected: %d - %s" , + test->exp_errno,tst_strerrno (test->exp_errno)); } + +static struct tst_test test = { + .setup = setup, + .test = mkdirat_verify, + .tcnt =ARRAY_SIZE (tcases), + .needs_root =1 , + .needs_rofs =1 , + .mntpoint =MNT_POINT , +};
Signature · 1 line
2.13.6
RFC PATCH 6/8 syscalls/link08: Rewrite to the new library
In reply to Cyril Hrubis+ Make use of .needs_rofs
--- testcases/kernel/syscalls/link/link08.c | 115 +++++++------------------------- 1 file changed, 25 insertions(+), 90 deletions(-)
testcases/kernel/syscalls/link/link08.c +25 -90
@@ -15,7 +15,6 @@* You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -* */ /* * Test Description:
@@ -32,134 +31,70 @@* 4. link() fails with -1 return value and sets errno to ELOOP * if too many symbolic links were encountered in resolving path. */ - -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> #include <errno.h> -#include <string.h> -#include <signal.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <pwd.h> -#include <sys/mount.h> - -#include "test.h" -#include "safe_macros.h" +#include "tst_test.h" #define DIR_MODE (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \ S_IXGRP|S_IROTH|S_IXOTH)#define MNT_POINT "mntpoint"#define TEST_FILE "testfile"#define TEST_FILE1 "testfile1" -#define TEST_FILE2 "mntpoint/testfile3" +#define TEST_FILE2 "mntpoint/file"#define TEST_FILE3 "mntpoint/testfile4"static char test_file4[PATH_MAX ] ="." ;static void setup (void ); -static void cleanup (void ); - -static const char *device; -static int mount_flag; -static struct test_case_t { +static struct tcase {char *oldpath;char *newpath;int exp_errno; -} test_cases[] = { +} tcases[] = { {TEST_FILE1 ,TEST_FILE ,EPERM }, {TEST_FILE2 ,TEST_FILE ,EXDEV }, {TEST_FILE2 ,TEST_FILE3 ,EROFS }, {test_file4,TEST_FILE ,ELOOP }, }; -static void link_verify (const struct test_case_t *); - -char *TCID ="link08" ; -int TST_TOTAL =ARRAY_SIZE (test_cases); - -int main (int ac,char **av) +static void link_verify (unsigned int i) { -int i, lc; - -tst_parse_opts (ac, av,NULL ,NULL ); - -setup (); +struct tcase *tc = &tcases[i]; -for (lc =0 ;TEST_LOOPING (lc); lc++) { - tst_count =0 ; -for (i =0 ; i <TST_TOTAL ; i++) -link_verify (&test_cases[i]); - } - -cleanup (); -tst_exit (); - -} - -static void link_verify (const struct test_case_t *tc) -{TEST (link (tc->oldpath, tc->newpath));if (TEST_RETURN !=-1 ) { -tst_resm (TFAIL ,"link succeeded unexpectedly" ); +tst_res (TFAIL ,"link() succeeded unexpectedly (%li)" , +TEST_RETURN );return ; }if (TEST_ERRNO == tc->exp_errno) { -tst_resm (TPASS |TTERRNO ,"link failed as expected" ); - }else { -tst_resm (TFAIL |TTERRNO , -"link failed unexpectedly; expected: %d - %s" , - tc->exp_errno,strerror (tc->exp_errno)); +tst_res (TPASS |TTERRNO ,"link() failed as expected" ); +return ; } -} +tst_res (TFAIL |TTERRNO , +"link() failed unexpectedly; expected: %d - %s" , + tc->exp_errno,tst_strerrno (tc->exp_errno)); +}static void setup (void ) {int i; -const char *fs_type; - -tst_require_root (); - -tst_sig (NOFORK ,DEF_HANDLER , cleanup); - -TEST_PAUSE ; - -tst_tmpdir (); - - fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); - -if (!device) -tst_brkm (TCONF , cleanup,"Failed to acquire device" ); -SAFE_MKDIR (cleanup,TEST_FILE1 ,DIR_MODE ); +SAFE_MKDIR (TEST_FILE1 ,DIR_MODE ); -SAFE_MKDIR (cleanup,"test_eloop" ,DIR_MODE ); -SAFE_SYMLINK (cleanup,"../test_eloop" ,"test_eloop/test_eloop" ); +SAFE_MKDIR ("test_eloop" ,DIR_MODE ); +SAFE_SYMLINK ("../test_eloop" ,"test_eloop/test_eloop" );for (i =0 ; i <43 ; i++)strcat (test_file4,"/test_eloop" ); - -tst_mkfs (cleanup, device, fs_type,NULL ,NULL ); -SAFE_MKDIR (cleanup,MNT_POINT ,DIR_MODE ); -SAFE_MOUNT (cleanup, device,MNT_POINT , fs_type,0 ,NULL ); - mount_flag =1 ; - -SAFE_TOUCH (cleanup,TEST_FILE2 ,0644 ,NULL ); -SAFE_MOUNT (cleanup, device,MNT_POINT , fs_type, -MS_REMOUNT |MS_RDONLY ,NULL ); } -static void cleanup (void ) -{ -if (mount_flag &&tst_umount (MNT_POINT ) <0 ) -tst_resm (TWARN |TERRNO ,"umount device:%s failed" , device); - -if (device) -tst_release_device (device); - -tst_rmdir (); -} +static struct tst_test test = { + .setup = setup, + .test = link_verify, + .tcnt =ARRAY_SIZE (tcases), + .needs_root =1 , + .needs_rofs =1 , + .mntpoint =MNT_POINT , +};
Signature · 1 line
2.13.6
RFC PATCH 7/8 syscalls/utimes01: Rewrite to the new library
In reply to Cyril Hrubis+ Make use of .needs_rofs
--- testcases/kernel/syscalls/utimes/utimes01.c | 131 +++++----------------------- 1 file changed, 24 insertions(+), 107 deletions(-)
testcases/kernel/syscalls/utimes/utimes01.c +24 -107
@@ -36,45 +36,28 @@*/ #include <sys/types.h> -#include <sys/stat.h> -#include <sys/time.h> -#include <dirent.h> #include <unistd.h> -#include <getopt.h> -#include <string.h> -#include <stdlib.h> -#include <errno.h> -#include <stdio.h> #include <pwd.h> -#include <sys/mount.h> - -#include "test.h" -#include "safe_macros.h" +#include "tst_test.h" #include "lapi/syscalls.h" -#define MNTPOINT "mntpoint" +#define MNT_POINT "mntpoint"#define TESTFILE1 "testfile1"#define TESTFILE2 "testfile2" -#define TESTFILE3 "mntpoint/testfile" +#define TESTFILE3 "mntpoint/file"#define FILE_MODE (S_IRWXU | S_IRGRP | S_IXGRP | \ S_IROTH | S_IXOTH)#define DIR_MODE (S_IRWXU | S_IRWXG | S_IRWXO) -#define LTPUSER1 "nobody" -#define LTPUSER2 "bin" - -static const char *device; -static int mount_flag; -static struct timeval a_tv[2 ] = { {0 ,0 }, {1000 ,0 } };static struct timeval m_tv[2 ] = { {1000 ,0 }, {0 ,0 } };static struct timeval tv[2 ] = { {1000 ,0 }, {2000 ,0 } }; -static struct test_case_t { +static struct tcase {char *pathname;struct timeval *times;int exp_errno; -} test_cases[] = { +} tcases[] = { {TESTFILE1 , a_tv,0 }, {TESTFILE1 , m_tv,0 }, {TESTFILE2 ,NULL ,EACCES },
@@ -84,83 +67,23 @@ static struct test_case_t { { TESTFILE3, tv, EROFS }, }; -static void setup (void ); -static void cleanup (void ); -static void utimes_verify (const struct test_case_t *); - -char *TCID ="utimes01" ; -int TST_TOTAL =ARRAY_SIZE (test_cases); - -int main (int ac,char **av) -{ -int i, lc; - -tst_parse_opts (ac, av,NULL ,NULL ); - -setup (); - -for (lc =0 ;TEST_LOOPING (lc); ++lc) { - tst_count =0 ; - -for (i =0 ; i <TST_TOTAL ; i++) -utimes_verify (&test_cases[i]); - } - -cleanup (); -tst_exit (); -} -static void setup (void ) { -struct passwd *ltpuser; -const char *fs_type; - -tst_require_root (); +struct passwd *ltpuser =SAFE_GETPWNAM ("nobody" ); -tst_sig (NOFORK ,DEF_HANDLER , cleanup); - -TEST_PAUSE ; - -tst_tmpdir (); - - fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); - -if (!device) -tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); - -SAFE_TOUCH (cleanup,TESTFILE1 ,FILE_MODE ,NULL ); - ltpuser =SAFE_GETPWNAM (cleanup,LTPUSER1 ); -SAFE_CHOWN (cleanup,TESTFILE1 , ltpuser->pw_uid, - ltpuser->pw_gid); - -SAFE_TOUCH (cleanup,TESTFILE2 ,FILE_MODE ,NULL ); - ltpuser =SAFE_GETPWNAM (cleanup,LTPUSER2 ); -SAFE_CHOWN (cleanup,TESTFILE2 , ltpuser->pw_uid, - ltpuser->pw_gid); - -tst_mkfs (cleanup, device, fs_type,NULL ,NULL ); -SAFE_MKDIR (cleanup,MNTPOINT ,DIR_MODE ); -SAFE_MOUNT (cleanup, device,MNTPOINT , fs_type,0 ,NULL ); - mount_flag =1 ; -SAFE_TOUCH (cleanup,TESTFILE3 ,FILE_MODE ,NULL ); - ltpuser =SAFE_GETPWNAM (cleanup,LTPUSER1 ); -SAFE_CHOWN (cleanup,TESTFILE3 , ltpuser->pw_uid, - ltpuser->pw_gid); -SAFE_MOUNT (cleanup, device,MNTPOINT , fs_type,MS_REMOUNT |MS_RDONLY , -NULL ); - - ltpuser =SAFE_GETPWNAM (cleanup,LTPUSER1 ); -SAFE_SETEUID (cleanup, ltpuser->pw_uid); +SAFE_TOUCH (TESTFILE2 ,FILE_MODE ,NULL ); +SAFE_SETEUID (ltpuser->pw_uid); +SAFE_TOUCH (TESTFILE1 ,FILE_MODE ,NULL ); } -static void utimes_verify (const struct test_case_t *tc) +static void utimes_verify (unsigned int i) {struct stat st;struct timeval tmp_tv[2 ]; +struct tcase *tc = &tcases[i];if (tc->exp_errno ==0 ) { -SAFE_STAT (cleanup, tc->pathname, &st); +SAFE_STAT (tc->pathname, &st); tmp_tv[0 ].tv_sec = st.st_atime; tmp_tv[0 ].tv_usec =0 ;
@@ -171,28 +94,22 @@ static void utimes_verify(const struct test_case_t *tc)TEST (utimes (tc->pathname, tc->times));if (TEST_ERRNO == tc->exp_errno) { -tst_resm (TPASS |TTERRNO ,"utimes() worked as expected" ); +tst_res (TPASS |TTERRNO ,"utimes() worked as expected" ); }else { -tst_resm (TFAIL |TTERRNO , +tst_res (TFAIL |TTERRNO ,"utimes() failed unexpectedly; expected: %d - %s" , - tc->exp_errno,strerror (tc->exp_errno)); + tc->exp_errno,tst_strerrno (tc->exp_errno)); }if (TEST_ERRNO ==0 &&utimes (tc->pathname, tmp_tv) ==-1 ) -tst_brkm (TBROK |TERRNO , cleanup,"utimes() failed." ); +tst_brk (TBROK |TERRNO ,"utimes() failed." ); } -static void cleanup (void ) -{ -if (seteuid (0 ) ==-1 ) -tst_resm (TWARN |TERRNO ,"seteuid(0) failed" ); - -if (mount_flag &&tst_umount (MNTPOINT ) ==-1 ) -tst_resm (TWARN |TERRNO ,"umount %s failed" ,MNTPOINT ); - - -if (device) -tst_release_device (device); - -tst_rmdir (); -} +static struct tst_test test = { + .setup = setup, + .test = utimes_verify, + .tcnt =ARRAY_SIZE (tcases), + .needs_root =1 , + .needs_rofs =1 , + .mntpoint =MNT_POINT , +};
Signature · 1 line
2.13.6
RFC PATCH 8/8 syscalls/fchmod06: Convert to the new library
In reply to Cyril Hrubis+ Make use of .needs_rofs
--- testcases/kernel/syscalls/fchmod/fchmod06.c | 189 +++++++++------------------- 1 file changed, 56 insertions(+), 133 deletions(-)
testcases/kernel/syscalls/fchmod/fchmod06.c +56 -133
@@ -1,23 +1,22 @@/* +* Copyright (c) International Business Machines Corp., 2001 +* Author: Wayne Boyer +* Copyright (c) 2018 Cyril Hrubis <[email protected]> * -* Copyright (c) International Business Machines Corp., 2001 -* Author: Wayne Boyer +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. * -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +* the GNU General Public License for more details. * -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -* the GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software Foundation, +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* * Test that fchmod() fails and sets the proper errno values. */
@@ -25,152 +24,76 @@#ifndef _GNU_SOURCE# define _GNU_SOURCE#endif - -#include <sys/types.h> -#include <sys/stat.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> #include <errno.h> -#include <string.h> -#include <signal.h> -#include <unistd.h> -#include <grp.h> +#include <sys/types.h> #include <pwd.h> -#include <sys/mount.h> +#include "tst_test.h" -#include "test.h" -#include "safe_macros.h" +#define MNT_POINT "mntpoint"static int fd1;static int fd2;static int fd3; -static const char *device; -static int mount_flag; -static struct test_case_t { -char *name; +static struct tcase {int *fd;int mode;int exp_errno; -} test_cases[] = { - {"EPERM" , &fd1,0644 ,EPERM }, - {"EBADF" , &fd2,0644 ,EBADF }, - {"EROFS" , &fd3,0644 ,EROFS }, +} tcases[] = { + {&fd1,0644 ,EPERM }, + {&fd2,0644 ,EBADF }, + {&fd3,0644 ,EROFS }, }; -char *TCID ="fchmod06" ; -int TST_TOTAL =ARRAY_SIZE (test_cases); - -static void setup (void ); -static void cleanup (void ); - -int main (int ac,char **av) +static void verify_fchmod (unsigned int i) { -int lc; -int i; - -tst_parse_opts (ac, av,NULL ,NULL ); - -setup (); +struct tcase *tc = &tcases[i]; -for (lc =0 ;TEST_LOOPING (lc); lc++) { +TEST (fchmod (*tc->fd, tc->mode)); - tst_count =0 ; - -for (i =0 ; i <TST_TOTAL ; i++) { - -TEST (fchmod (*test_cases[i].fd, test_cases[i].mode)); - -if (TEST_RETURN ==-1 ) { -if (TEST_ERRNO == test_cases[i].exp_errno) { -tst_resm (TPASS |TTERRNO , -"fchmod: test %s success" , - test_cases[i].name); - }else { -tst_resm (TFAIL |TTERRNO , -"fchmod: test %s FAILED with " -"unexpect errno: %d" , - test_cases[i].name, -TEST_ERRNO ); - } - }else { -tst_resm (TFAIL , -"fchmod: test %s success unexpectly" , - test_cases[i].name); - } - } +if (TEST_RETURN !=-1 ) { +tst_res (TFAIL ,"fchmod() passed unexpectedly (%li)" , +TEST_RETURN ); +return ; + } +if (TEST_ERRNO == tcases[i].exp_errno) { +tst_res (TPASS |TTERRNO ,"fchmod() failed expectedly" ); +return ; } -cleanup (); -tst_exit (); +tst_res (TFAIL |TTERRNO , +"fchmod() failed unexpectedly, expected %i - %s" , +TEST_ERRNO ,tst_strerrno (TEST_ERRNO )); }static void setup (void ) { -struct passwd *ltpuser; -const char *fs_type; - -tst_sig (FORK ,DEF_HANDLER , cleanup); - -tst_require_root (); - -TEST_PAUSE ; - -tst_tmpdir (); - - fs_type =tst_dev_fs_type (); - device =tst_acquire_device (cleanup); +struct passwd *ltpuser =SAFE_GETPWNAM ("nobody" ); -if (!device) -tst_brkm (TCONF , cleanup,"Failed to obtain block device" ); + fd3 =SAFE_OPEN (MNT_POINT "/file" ,O_RDONLY ); + fd1 =SAFE_OPEN ("tfile_1" ,O_RDWR |O_CREAT ,0666 ); + fd2 =SAFE_OPEN ("tfile_2" ,O_RDWR |O_CREAT ,0666 ); +SAFE_CLOSE (fd2); -tst_mkfs (cleanup, device, fs_type,NULL ,NULL ); - -SAFE_MKDIR (cleanup,"mntpoint" ,0755 ); - -SAFE_MOUNT (cleanup, device,"mntpoint" , fs_type,0 ,NULL ); - mount_flag =1 ; - -/* Create a file in the file system, then remount it as read-only */ -SAFE_TOUCH (cleanup,"mntpoint/tfile_3" ,0644 ,NULL ); - -SAFE_MOUNT (cleanup, device,"mntpoint" , fs_type, -MS_REMOUNT |MS_RDONLY ,NULL ); - - fd3 =SAFE_OPEN (cleanup,"mntpoint/tfile_3" ,O_RDONLY ); - - fd1 =SAFE_OPEN (cleanup,"tfile_1" ,O_RDWR |O_CREAT ,0666 ); - - fd2 =SAFE_OPEN (cleanup,"tfile_2" ,O_RDWR |O_CREAT ,0666 ); - -SAFE_CLOSE (cleanup, fd2); - - ltpuser =SAFE_GETPWNAM (cleanup,"nobody" ); - -SAFE_SETEUID (cleanup, ltpuser->pw_uid); +SAFE_SETEUID (ltpuser->pw_uid); }static void cleanup (void ) { -if (seteuid (0 )) -tst_resm (TWARN |TERRNO ,"seteuid(0) failed" ); - -if (fd1 >0 &&close (fd1)) -tst_resm (TWARN |TERRNO ,"close(fd1) failed" ); - -if (fd3 >0 &&close (fd3)) -tst_resm (TWARN |TERRNO ,"close(fd1) failed" ); - -if (mount_flag &&tst_umount ("mntpoint" ) <0 ) { -tst_brkm (TBROK |TERRNO ,NULL , -"umount device:%s failed" , device); - } - -if (device) -tst_release_device (device); +if (fd1 >0 ) +SAFE_CLOSE (fd1); -tst_rmdir (); +if (fd3 >0 ) +SAFE_CLOSE (fd3); } + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test = verify_fchmod, + .tcnt =ARRAY_SIZE (tcases), + .needs_root =1 , + .needs_rofs =1 , + .mntpoint =MNT_POINT , +};
Signature · 1 line
2.13.6