quotactl06: Replace tst_brk(TFAIL) with TBROK
PATCH 1/3 quotactl06: Replace tst_brk(TFAIL) with TBROK
--- testcases/kernel/syscalls/quotactl/quotactl06.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/syscalls/quotactl/quotactl06.c +1 -1
@@ -178,7 +178,7 @@ static void setup(void) set_dqmax.dqb_bsoftlimit = tst_variant ?0x20000000000000 :0x100000000 ;if (access (USRPATH ,F_OK ) ==-1 ) -tst_brk (TFAIL |TERRNO ,"user quotafile didn't exist" ); +tst_brk (TBROK |TERRNO ,"user quotafile didn't exist" );tst_require_quota_support (tst_device->dev, fmt_id, usrpath);
Signature · 5 lines
2.35.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/3 quotactl06: Code style fixes
--- .../kernel/syscalls/quotactl/quotactl06.c | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-)
testcases/kernel/syscalls/quotactl/quotactl06.c +29 -20
@@ -12,22 +12,23 @@* * - EACCES when cmd is Q_QUOTAON and addr existed but not a regular file * - ENOENT when the file specified by special or addr does not exist -* - EBUSY when cmd is Q_QUOTAON and another Q_QUOTAON had already been performed +* - EBUSY when cmd is Q_QUOTAON and another Q_QUOTAON had already been +* performed * - EFAULT when addr or special is invalid * - EINVAL when cmd or type is invalid * - ENOTBLK when special is not a block device -* - ESRCH when no disk quota is found for the indicated user and quotas have not been -* turned on for this fs +* - ESRCH when no disk quota is found for the indicated user and quotas have +* not been turned on for this fs * - ESRCH when cmd is Q_QUOTAON, but the quota format was not found -* - ESRCH when cmd is Q_GETNEXTQUOTA, but there is no ID greater than or equal to id that -* has an active quota -* - ERANGE when cmd is Q_SETQUOTA, but the specified limits are out of the range allowed -* by the quota format -* - EPERM when the caller lacked the required privilege (CAP_SYS_ADMIN) for the specified -* operation +* - ESRCH when cmd is Q_GETNEXTQUOTA, but there is no ID greater than or +* equal to id that has an active quota +* - ERANGE when cmd is Q_SETQUOTA, but the specified limits are out of the +* range allowed by the quota format +* - EPERM when the caller lacked the required privilege (CAP_SYS_ADMIN) for +* the specified operation * -* For ERANGE error, the vfsv0 and vfsv1 format's maximum quota limit setting have been -* fixed since the following kernel patch: +* For ERANGE error, the vfsv0 and vfsv1 format's maximum quota limit setting +* have been fixed since the following kernel patch: * * commit 7e08da50cf706151f324349f9235ebd311226997 * Author: Jan Kara <[email protected]>
@@ -135,10 +136,13 @@ static void verify_quotactl(unsigned int n) }if (tc->on_flag) { -TST_EXP_PASS_SILENT (quotactl (QCMD (Q_QUOTAON ,USRQUOTA ), tst_device->dev, - fmt_id, usrpath),"quotactl with Q_QUOTAON" ); +TST_EXP_PASS_SILENT (quotactl (QCMD (Q_QUOTAON ,USRQUOTA ), + tst_device->dev, fmt_id, usrpath), +"quotactl with Q_QUOTAON" ); +if (!TST_PASS )return ; + quota_on =1 ; }
@@ -147,16 +151,19 @@ static void verify_quotactl(unsigned int n) drop_flag =1 ; } -if (tc->exp_err ==ENOTBLK ) +if (tc->exp_err ==ENOTBLK ) {TST_EXP_FAIL (quotactl (tc->cmd,"/dev/null" , *tc->id, tc->addr),ENOTBLK ,"quotactl()" ); -else -TST_EXP_FAIL (quotactl (tc->cmd, tst_device->dev, *tc->id, tc->addr), - tc->exp_err,"quotactl()" ); + }else { +TST_EXP_FAIL (quotactl (tc->cmd, tst_device->dev, *tc->id, + tc->addr), tc->exp_err,"quotactl()" ); + }if (quota_on) { -TST_EXP_PASS_SILENT (quotactl (QCMD (Q_QUOTAOFF ,USRQUOTA ), tst_device->dev, - fmt_id, usrpath),"quotactl with Q_QUOTAOFF" ); +TST_EXP_PASS_SILENT (quotactl (QCMD (Q_QUOTAOFF ,USRQUOTA ), + tst_device->dev, fmt_id, usrpath), +"quotactl with Q_QUOTAOFF" ); +if (!TST_PASS )return ; }
@@ -169,7 +176,9 @@ static void setup(void) {unsigned int i;const struct quotactl_fmt_variant *var = &fmt_variants[tst_variant]; -const char *const cmd[] = {"quotacheck" ,"-ugF" , var->fmt_name,MNTPOINT ,NULL }; +const char *const cmd[] = { +"quotacheck" ,"-ugF" , var->fmt_name,MNTPOINT ,NULL + };tst_res (TINFO ,"quotactl() with %s format" , var->fmt_name);SAFE_CMD (cmd,NULL ,NULL );
Signature · 5 lines
2.35.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 2/3] quotactl06: Code style fixes
Hi Martin
Looks good to me,
Best Regards
Yang Xu
Quoted 97 lines
Signed-off-by Martin Doucha<[email protected]>--- .../kernel/syscalls/quotactl/quotactl06.c | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-)testcases/kernel/syscalls/quotactl/quotactl06.c +29
-20@@ -12,22 +12,23 @@* * - EACCES when cmd is Q_QUOTAON and addr existed but not a regular file * - ENOENT when the file specified by special or addr does not exist -* - EBUSY when cmd is Q_QUOTAON and another Q_QUOTAON had already been performed +* - EBUSY when cmd is Q_QUOTAON and another Q_QUOTAON had already been +* performed * - EFAULT when addr or special is invalid * - EINVAL when cmd or type is invalid * - ENOTBLK when special is not a block device -* - ESRCH when no disk quota is found for the indicated user and quotas have not been -* turned on for this fs +* - ESRCH when no disk quota is found for the indicated user and quotas have +* not been turned on for this fs * - ESRCH when cmd is Q_QUOTAON, but the quota format was not found -* - ESRCH when cmd is Q_GETNEXTQUOTA, but there is no ID greater than or equal to id that -* has an active quota -* - ERANGE when cmd is Q_SETQUOTA, but the specified limits are out of the range allowed -* by the quota format -* - EPERM when the caller lacked the required privilege (CAP_SYS_ADMIN) for the specified -* operation +* - ESRCH when cmd is Q_GETNEXTQUOTA, but there is no ID greater than or +* equal to id that has an active quota +* - ERANGE when cmd is Q_SETQUOTA, but the specified limits are out of the +* range allowed by the quota format +* - EPERM when the caller lacked the required privilege (CAP_SYS_ADMIN) for +* the specified operation * -* For ERANGE error, the vfsv0 and vfsv1 format's maximum quota limit setting have been -* fixed since the following kernel patch: +* For ERANGE error, the vfsv0 and vfsv1 format's maximum quota limit setting +* have been fixed since the following kernel patch: * * commit 7e08da50cf706151f324349f9235ebd311226997 * Author: Jan Kara<[email protected]> @@ -135,10 +136,13 @@ static void verify_quotactl(unsigned int n) }if (tc->on_flag) { -TST_EXP_PASS_SILENT (quotactl (QCMD (Q_QUOTAON ,USRQUOTA ), tst_device->dev, - fmt_id, usrpath),"quotactl with Q_QUOTAON" ); +TST_EXP_PASS_SILENT (quotactl (QCMD (Q_QUOTAON ,USRQUOTA ), + tst_device->dev, fmt_id, usrpath), +"quotactl with Q_QUOTAON" ); +if (!TST_PASS )return ; + quota_on =1 ; }@@ -147,16 +151,19 @@ static void verify_quotactl(unsigned int n) drop_flag =1 ; } -if (tc->exp_err ==ENOTBLK ) +if (tc->exp_err ==ENOTBLK ) {TST_EXP_FAIL (quotactl (tc->cmd,"/dev/null" , *tc->id, tc->addr),ENOTBLK ,"quotactl()" ); -else -TST_EXP_FAIL (quotactl (tc->cmd, tst_device->dev, *tc->id, tc->addr), - tc->exp_err,"quotactl()" ); + }else { +TST_EXP_FAIL (quotactl (tc->cmd, tst_device->dev, *tc->id, + tc->addr), tc->exp_err,"quotactl()" ); + }if (quota_on) { -TST_EXP_PASS_SILENT (quotactl (QCMD (Q_QUOTAOFF ,USRQUOTA ), tst_device->dev, - fmt_id, usrpath),"quotactl with Q_QUOTAOFF" ); +TST_EXP_PASS_SILENT (quotactl (QCMD (Q_QUOTAOFF ,USRQUOTA ), + tst_device->dev, fmt_id, usrpath), +"quotactl with Q_QUOTAOFF" ); +if (!TST_PASS )return ; }@@ -169,7 +176,9 @@ static void setup(void) {unsigned int i;const struct quotactl_fmt_variant *var =&fmt_variants[tst_variant]; -const char *const cmd[] = {"quotacheck" ,"-ugF" , var->fmt_name,MNTPOINT ,NULL }; +const char *const cmd[] = { +"quotacheck" ,"-ugF" , var->fmt_name,MNTPOINT ,NULL + };tst_res (TINFO ,"quotactl() with %s format" , var->fmt_name);SAFE_CMD (cmd,NULL ,NULL );
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 3/3 quotactl06: Fix TESTDIR1 cleanup if setup() exits early
In reply to Martin DouchaWhen setup() exits with TCONF before TESTDIR1 gets created, cleanup() will trigger TWARN when it tries to delete it. Check whether the directory exists before calling SAFE_RMDIR().
--- testcases/kernel/syscalls/quotactl/quotactl06.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/quotactl/quotactl06.c +3 -1
@@ -207,7 +207,9 @@ static void setup(void)static void cleanup (void ) {SAFE_UNLINK (USRPATH ); -SAFE_RMDIR (TESTDIR1 ); + +if (!access (TESTDIR1 ,F_OK )) +SAFE_RMDIR (TESTDIR1 ); }static struct tst_test test = {
Signature · 5 lines
2.35.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 3/3] quotactl06: Fix TESTDIR1 cleanup if setup() exits early
Hi Martin
Quoted 14 lines
When
setup()exits with TCONF before TESTDIR1 gets created,cleanup()will trigger TWARN when it tries to delete it. Check whether the directory exists before callingSAFE_RMDIR().Signed-off-by Martin Doucha<[email protected]>--- testcases/kernel/syscalls/quotactl/quotactl06.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)testcases/kernel/syscalls/quotactl/quotactl06.c +0
-0
testcases/kernel/syscalls/quotactl/quotactl06.c static void setup(void) · line 209
Quoted 3 lines
testcases/kernel/syscalls/quotactl/quotactl06.c +0
-0@@ -207,7 +207,9 @@ static void setup(void)static void cleanup (void ) {SAFE_UNLINK (USRPATH );
It seems we also should check USRPATH whether existed.
Best Regards
Yang Xu
Quoted 7 lines
testcases/kernel/syscalls/quotactl/quotactl06.c +3
-1-SAFE_RMDIR (TESTDIR1 ); + +if (!access (TESTDIR1 ,F_OK )) +SAFE_RMDIR (TESTDIR1 ); }static struct tst_test test = {
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 3/3] quotactl06: Fix TESTDIR1 cleanup if setup() exits early
Quoted 10 lines · On 04. 03. 22 2:38, [email protected] wrote:
Hi Martin
Quoted 9 lines
When
setup()exits with TCONF before TESTDIR1 gets created,cleanup()will trigger TWARN when it tries to delete it. Check whether the directory exists before callingSAFE_RMDIR().Signed-off-by Martin Doucha<[email protected]>--- testcases/kernel/syscalls/quotactl/quotactl06.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 9 lines
testcases/kernel/syscalls/quotactl/quotactl06.c static void setup(void) · line 209
Quoted 8 lines
testcases/kernel/syscalls/quotactl/quotactl06.c +0
-0@@ -207,7 +207,9 @@ static void setup(void)static void cleanup (void ) {SAFE_UNLINK (USRPATH );It seems we also should check USRPATH whether existed.
If I understand correctly, the file will be created by mount(), even before setup() gets executed. So if the file doesn't exist during cleanup(), the error will be valid.
Signature · 10 lines
Martin Doucha [email protected] QA Engineer for Software Maintenance SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 3/3] quotactl06: Fix TESTDIR1 cleanup if setup() exits early
Hi Martin
Quoted 21 lines · On 04. 03. 22 2:38, [email protected] wrote:
Quoted 10 lines
Hi Martin
Quoted 9 lines
When
setup()exits with TCONF before TESTDIR1 gets created,cleanup()will trigger TWARN when it tries to delete it. Check whether the directory exists before callingSAFE_RMDIR().Signed-off-by Martin Doucha<[email protected]>--- testcases/kernel/syscalls/quotactl/quotactl06.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)Quoted 9 lines
testcases/kernel/syscalls/quotactl/quotactl06.c static void setup(void) · line 209
Quoted 8 lines
testcases/kernel/syscalls/quotactl/quotactl06.c +0
-0@@ -207,7 +207,9 @@ static void setup(void)static void cleanup (void ) {SAFE_UNLINK (USRPATH );It seems we also should check USRPATH whether existed.
Quoted 3 lines
If I understand correctly, the file will be created by
mount(), even beforesetup()gets executed. So if the file doesn't exist duringcleanup(), the error will be valid.
The USRPATH file is generated by quotacheck command.
Best Regards
Yang Xu
Quoted 1 line
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Martin
Looks good to me,
Also, quotactl01 also use this similar code, I guess we can also replace it. It seems we miss SAFE_ACCESS macro, we can add this macro and use it in all similar code.
Best Regards
Yang Xu
Quoted 18 lines
Signed-off-by Martin Doucha<[email protected]>--- testcases/kernel/syscalls/quotactl/quotactl06.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)testcases/kernel/syscalls/quotactl/quotactl06.c +1
-1@@ -178,7 +178,7 @@ static void setup(void) set_dqmax.dqb_bsoftlimit = tst_variant ?0x20000000000000 :0x100000000 ;if (access (USRPATH ,F_OK ) ==-1 ) -tst_brk (TFAIL |TERRNO ,"user quotafile didn't exist" ); +tst_brk (TBROK |TERRNO ,"user quotafile didn't exist" );tst_require_quota_support (tst_device->dev, fmt_id, usrpath);
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp