diff mbox series

[v6,3/3] syscalls/quotactl: Make use of TST_EXP_PASS_SILENT and TST_EXP_FAIL

Message ID 1641973691-22981-3-git-send-email-xuyang2018.jy@fujitsu.com
State Accepted
Headers show
Series [v6,1/3] syscalls/quotactl09: Test error when quota info hidden in filesystem | expand

Commit Message

Yang Xu Jan. 12, 2022, 7:48 a.m. UTC
Also, add some description and make check happy for quotactl06.c.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 .../kernel/syscalls/quotactl/quotactl01.c     |  7 +-
 .../kernel/syscalls/quotactl/quotactl02.c     |  7 +-
 .../kernel/syscalls/quotactl/quotactl02.h     | 45 ++++------
 .../kernel/syscalls/quotactl/quotactl04.c     |  7 +-
 .../kernel/syscalls/quotactl/quotactl05.c     |  7 +-
 .../kernel/syscalls/quotactl/quotactl06.c     | 90 +++++++++++--------
 6 files changed, 80 insertions(+), 83 deletions(-)

Comments

Cyril Hrubis Jan. 13, 2022, 2:45 p.m. UTC | #1
Hi!
>  } tcases[] = {
> -	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, testdir1, EACCES, 0},
> -	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, testdir2, ENOENT, 0},
> -	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, usrpath, EBUSY, 1},
> -	{QCMD(Q_SETQUOTA, USRQUOTA), &fmt_id, NULL, EFAULT, 1},
> -	{QCMD(OPTION_INVALID, USRQUOTA), &fmt_id, usrpath, EINVAL, 0},
> -	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, usrpath, ENOTBLK, 0},
> -	{QCMD(Q_SETQUOTA, USRQUOTA), &test_id, &set_dq, ESRCH, 0},
> -	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_invalid, usrpath, ESRCH, 0},
> -	{QCMD(Q_GETNEXTQUOTA, USRQUOTA), &test_invalid, usrpath, ESRCH, 0},
> -	{QCMD(Q_SETQUOTA, USRQUOTA), &test_id, &set_dqmax, ERANGE, 1},
> -	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, usrpath, EPERM, 0},
> +	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, testdir1, EACCES, 0,
> +	"EACCES when cmd is Q_QUOTAON and addr existed but not a regular file"},
> +
> +	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, testdir2, ENOENT, 0,
> +	"ENOENT when the file specified by special or addr does not exist"},
> +
> +	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, usrpath, EBUSY, 1,
> +	"EBUSY when cmd is Q_QUOTAON and another Q_QUOTAON had already been performed"},
> +
> +	{QCMD(Q_SETQUOTA, USRQUOTA), &fmt_id, NULL, EFAULT, 1,
> +	"EFAULT when addr or special is invalid"},
> +
> +	{QCMD(OPTION_INVALID, USRQUOTA), &fmt_id, usrpath, EINVAL, 0,
> +	"EINVAL when cmd or type is invalid"},
> +
> +	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, usrpath, ENOTBLK, 0,
> +	"ENOTBLK when special is not a block device"},
> +
> +	{QCMD(Q_SETQUOTA, USRQUOTA), &test_id, &set_dq, ESRCH, 0,
> +	"ESRCH when no disk quota is found for the indicated user and quotas "
> +	"have not been turned on for this fs"},
> +
> +	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_invalid, usrpath, ESRCH, 0,
> +	"ESRCH when cmd is Q_QUOTAON, but the quota format was not found"},
> +
> +	{QCMD(Q_GETNEXTQUOTA, USRQUOTA), &test_invalid, usrpath, ESRCH, 0,
> +	"ESRCH when cmd is Q_GETNEXTQUOTA, but there is no ID greater than or "
> +	"equal to id that has an active quota"},
> +
> +	{QCMD(Q_SETQUOTA, USRQUOTA), &test_id, &set_dqmax, ERANGE, 1,
> +	"ERANGE when cmd is Q_SETQUOTA, but the specified limits are out of "
> +	"the range allowed by the quota format"},
> +
> +	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, usrpath, EPERM, 0,
> +	"EPERM when the caller lacked the required privilege (CAP_SYS_ADMIN) "
> +	"for the specified operation"},

These descriptions could be a bit shorter and still have the same amount
of information, for instance the last one could be shortened to just:

"EPERM when caller lacks required privilege (CAP_SYS_ADMIN)"

or

"ESRCH for Q_GETNEXTQUOTA but the id was last one"

or

"ESRCH for Q_GETNEXTQUOTA but no quota found for the user or quotas are off"

Ideally all the messages should fit into a single line less than 80
characters...


Other than that this is a nice cleanup, with the messages shortened:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Yang Xu Jan. 14, 2022, 3:58 a.m. UTC | #2
Hi Cyril
> Hi!
>>   } tcases[] = {
>> -	{QCMD(Q_QUOTAON, USRQUOTA),&fmt_id, testdir1, EACCES, 0},
>> -	{QCMD(Q_QUOTAON, USRQUOTA),&fmt_id, testdir2, ENOENT, 0},
>> -	{QCMD(Q_QUOTAON, USRQUOTA),&fmt_id, usrpath, EBUSY, 1},
>> -	{QCMD(Q_SETQUOTA, USRQUOTA),&fmt_id, NULL, EFAULT, 1},
>> -	{QCMD(OPTION_INVALID, USRQUOTA),&fmt_id, usrpath, EINVAL, 0},
>> -	{QCMD(Q_QUOTAON, USRQUOTA),&fmt_id, usrpath, ENOTBLK, 0},
>> -	{QCMD(Q_SETQUOTA, USRQUOTA),&test_id,&set_dq, ESRCH, 0},
>> -	{QCMD(Q_QUOTAON, USRQUOTA),&fmt_invalid, usrpath, ESRCH, 0},
>> -	{QCMD(Q_GETNEXTQUOTA, USRQUOTA),&test_invalid, usrpath, ESRCH, 0},
>> -	{QCMD(Q_SETQUOTA, USRQUOTA),&test_id,&set_dqmax, ERANGE, 1},
>> -	{QCMD(Q_QUOTAON, USRQUOTA),&fmt_id, usrpath, EPERM, 0},
>> +	{QCMD(Q_QUOTAON, USRQUOTA),&fmt_id, testdir1, EACCES, 0,
>> +	"EACCES when cmd is Q_QUOTAON and addr existed but not a regular file"},
>> +
>> +	{QCMD(Q_QUOTAON, USRQUOTA),&fmt_id, testdir2, ENOENT, 0,
>> +	"ENOENT when the file specified by special or addr does not exist"},
>> +
>> +	{QCMD(Q_QUOTAON, USRQUOTA),&fmt_id, usrpath, EBUSY, 1,
>> +	"EBUSY when cmd is Q_QUOTAON and another Q_QUOTAON had already been performed"},
>> +
>> +	{QCMD(Q_SETQUOTA, USRQUOTA),&fmt_id, NULL, EFAULT, 1,
>> +	"EFAULT when addr or special is invalid"},
>> +
>> +	{QCMD(OPTION_INVALID, USRQUOTA),&fmt_id, usrpath, EINVAL, 0,
>> +	"EINVAL when cmd or type is invalid"},
>> +
>> +	{QCMD(Q_QUOTAON, USRQUOTA),&fmt_id, usrpath, ENOTBLK, 0,
>> +	"ENOTBLK when special is not a block device"},
>> +
>> +	{QCMD(Q_SETQUOTA, USRQUOTA),&test_id,&set_dq, ESRCH, 0,
>> +	"ESRCH when no disk quota is found for the indicated user and quotas "
>> +	"have not been turned on for this fs"},
>> +
>> +	{QCMD(Q_QUOTAON, USRQUOTA),&fmt_invalid, usrpath, ESRCH, 0,
>> +	"ESRCH when cmd is Q_QUOTAON, but the quota format was not found"},
>> +
>> +	{QCMD(Q_GETNEXTQUOTA, USRQUOTA),&test_invalid, usrpath, ESRCH, 0,
>> +	"ESRCH when cmd is Q_GETNEXTQUOTA, but there is no ID greater than or "
>> +	"equal to id that has an active quota"},
>> +
>> +	{QCMD(Q_SETQUOTA, USRQUOTA),&test_id,&set_dqmax, ERANGE, 1,
>> +	"ERANGE when cmd is Q_SETQUOTA, but the specified limits are out of "
>> +	"the range allowed by the quota format"},
>> +
>> +	{QCMD(Q_QUOTAON, USRQUOTA),&fmt_id, usrpath, EPERM, 0,
>> +	"EPERM when the caller lacked the required privilege (CAP_SYS_ADMIN) "
>> +	"for the specified operation"},
>
> These descriptions could be a bit shorter and still have the same amount
> of information, for instance the last one could be shortened to just:
>
> "EPERM when caller lacks required privilege (CAP_SYS_ADMIN)"
>
> or
>
> "ESRCH for Q_GETNEXTQUOTA but the id was last one"
>
> or
>
> "ESRCH for Q_GETNEXTQUOTA but no quota found for the user or quotas are off"
>
> Ideally all the messages should fit into a single line less than 80
> characters...
>
>
> Other than that this is a nice cleanup, with the messages shortened:
Thanks for your review, I have modified these and then pushed this patchset.

Best Regards
Yang Xu
>
> Reviewed-by: Cyril Hrubis<chrubis@suse.cz>
>
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/quotactl/quotactl01.c b/testcases/kernel/syscalls/quotactl/quotactl01.c
index 1e0f5da70..561e5030f 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl01.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl01.c
@@ -196,11 +196,10 @@  static void verify_quota(unsigned int n)
 		tst_res(TCONF, "current system doesn't support this cmd");
 		return;
 	}
-	TEST(quotactl(tc->cmd, tst_device->dev, *tc->id, tc->addr));
-	if (TST_RET == -1) {
-		tst_res(TFAIL | TTERRNO, "quotactl failed to %s", tc->des);
+	TST_EXP_PASS_SILENT(quotactl(tc->cmd, tst_device->dev, *tc->id, tc->addr),
+			"quotactl to %s", tc->des);
+	if (!TST_PASS)
 		return;
-	}
 
 	if (memcmp(tc->res_data, tc->set_data, tc->sz)) {
 		tst_res(TFAIL, "quotactl failed to %s", tc->des);
diff --git a/testcases/kernel/syscalls/quotactl/quotactl02.c b/testcases/kernel/syscalls/quotactl/quotactl02.c
index c16e0a3f8..d9c4f9b2e 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl02.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl02.c
@@ -130,11 +130,10 @@  static void verify_quota(unsigned int n)
 		return;
 	}
 
-	TEST(do_quotactl(fd, tc->cmd, tst_device->dev, test_id, tc->addr));
-	if (TST_RET == -1) {
-		tst_res(TFAIL | TTERRNO, "quotactl() failed to %s", tc->des);
+	TST_EXP_PASS_SILENT(do_quotactl(fd, tc->cmd, tst_device->dev, test_id, tc->addr),
+		"do_quotactl()");
+	if (!TST_PASS)
 		return;
-	}
 
 	if (tc->flag)
 		tc->func_check(tc->check_subcmd, tc->des, *(int *)(tc->addr));
diff --git a/testcases/kernel/syscalls/quotactl/quotactl02.h b/testcases/kernel/syscalls/quotactl/quotactl02.h
index 28b632646..a5683ae7d 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl02.h
+++ b/testcases/kernel/syscalls/quotactl/quotactl02.h
@@ -49,15 +49,12 @@  static void check_support_cmd(int quotatype)
 
 static void check_qoff(int subcmd, char *desp, int flag)
 {
-	int res;
 	struct fs_quota_stat res_qstat;
 
-	res = do_quotactl(fd, subcmd, tst_device->dev, test_id, (void *) &res_qstat);
-	if (res == -1) {
-		tst_res(TFAIL | TERRNO,
-			"quotactl() failed to get xfs quota off status");
+	TST_EXP_PASS_SILENT(do_quotactl(fd, subcmd, tst_device->dev, test_id,
+			(void *) &res_qstat), "do_quotactl() to %s", desp);
+	if (!TST_PASS)
 		return;
-	}
 
 	if (res_qstat.qs_flags & flag) {
 		tst_res(TFAIL, "xfs quota enforcement was on unexpectedly");
@@ -69,15 +66,12 @@  static void check_qoff(int subcmd, char *desp, int flag)
 
 static void check_qon(int subcmd, char *desp, int flag)
 {
-	int res;
 	struct fs_quota_stat res_qstat;
 
-	res = do_quotactl(fd, subcmd, tst_device->dev, test_id, (void *) &res_qstat);
-	if (res == -1) {
-		tst_res(TFAIL | TERRNO,
-			"quotactl() failed to get xfs quota on status");
+	TST_EXP_PASS_SILENT(do_quotactl(fd, subcmd, tst_device->dev, test_id,
+			(void *) &res_qstat), "do_quotactl() to %s", desp);
+	if (!TST_PASS)
 		return;
-	}
 
 	if (!(res_qstat.qs_flags & flag)) {
 		tst_res(TFAIL, "xfs quota enforcement was off unexpectedly");
@@ -89,17 +83,14 @@  static void check_qon(int subcmd, char *desp, int flag)
 
 static void check_qoffv(int subcmd, char *desp, int flag)
 {
-	int res;
 	struct fs_quota_statv res_qstatv = {
 		.qs_version = FS_QSTATV_VERSION1,
 	};
 
-	res = do_quotactl(fd, subcmd, tst_device->dev, test_id, (void *) &res_qstatv);
-	if (res == -1) {
-		tst_res(TFAIL | TERRNO,
-			"quotactl() failed to get xfs quota off stav");
+	TST_EXP_PASS_SILENT(do_quotactl(fd, subcmd, tst_device->dev, test_id,
+			(void *) &res_qstatv), "do_quotactl() to %s", desp);
+	if (!TST_PASS)
 		return;
-	}
 
 	if (res_qstatv.qs_flags & flag) {
 		tst_res(TFAIL, "xfs quota enforcement was on unexpectedly");
@@ -111,17 +102,14 @@  static void check_qoffv(int subcmd, char *desp, int flag)
 
 static void check_qonv(int subcmd, char *desp, int flag)
 {
-	int res;
 	struct fs_quota_statv res_qstatv = {
 		.qs_version = FS_QSTATV_VERSION1
 	};
 
-	res = do_quotactl(fd, subcmd, tst_device->dev, test_id, (void *) &res_qstatv);
-	if (res == -1) {
-		tst_res(TFAIL | TERRNO,
-			"quotactl() failed to get xfs quota on statv");
+	TST_EXP_PASS_SILENT(do_quotactl(fd, subcmd, tst_device->dev, test_id,
+			(void *) &res_qstatv), "do_quotactl() to %s", desp);
+	if (!TST_PASS)
 		return;
-	}
 
 	if (!(res_qstatv.qs_flags & flag)) {
 		tst_res(TFAIL, "xfs quota enforcement was off unexpectedly");
@@ -133,17 +121,14 @@  static void check_qonv(int subcmd, char *desp, int flag)
 
 static void check_qlim(int subcmd, char *desp)
 {
-	int res;
 	static struct fs_disk_quota res_dquota;
 
 	res_dquota.d_rtb_softlimit = 0;
 
-	res = do_quotactl(fd, subcmd, tst_device->dev, test_id, (void *) &res_dquota);
-	if (res == -1) {
-		tst_res(TFAIL | TERRNO,
-			"quotactl() failed to get xfs disk quota limits");
+	TST_EXP_PASS_SILENT(do_quotactl(fd, subcmd, tst_device->dev, test_id,
+			(void *) &res_dquota), "do_quotactl() to %s", desp);
+	if (!TST_PASS)
 		return;
-	}
 
 	if (res_dquota.d_id != test_id) {
 		tst_res(TFAIL, "quotactl() got unexpected user id %u, expected %u",
diff --git a/testcases/kernel/syscalls/quotactl/quotactl04.c b/testcases/kernel/syscalls/quotactl/quotactl04.c
index 44273c35d..55da28270 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl04.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl04.c
@@ -145,11 +145,10 @@  static void verify_quota(unsigned int n)
 
 	tst_res(TINFO, "Test #%d: %s", n, tc->tname);
 
-	TEST(do_quotactl(fd, tc->cmd, tst_device->dev, *tc->id, tc->addr));
-	if (TST_RET == -1) {
-		tst_res(TFAIL | TTERRNO, "quotactl failed to %s", tc->des);
+	TST_EXP_PASS_SILENT(do_quotactl(fd, tc->cmd, tst_device->dev, *tc->id, tc->addr),
+			"do_quotactl to %s", tc->des);
+	if (!TST_PASS)
 		return;
-	}
 
 	if (memcmp(tc->res_data, tc->set_data, tc->sz)) {
 		tst_res(TFAIL, "quotactl failed to %s", tc->des);
diff --git a/testcases/kernel/syscalls/quotactl/quotactl05.c b/testcases/kernel/syscalls/quotactl/quotactl05.c
index 541007e97..ac75cee31 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl05.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl05.c
@@ -93,11 +93,10 @@  static void verify_quota(unsigned int n)
 		return;
 	}
 
-	TEST(do_quotactl(fd, tc->cmd, tst_device->dev, test_id, tc->addr));
-	if (TST_RET == -1) {
-		tst_res(TFAIL | TTERRNO, "quotactl() failed to %s", tc->des);
+	TST_EXP_PASS_SILENT(do_quotactl(fd, tc->cmd, tst_device->dev, test_id, tc->addr),
+		"do_quotactl()");
+	if (!TST_PASS)
 		return;
-	}
 
 	if (tc->flag)
 		tc->func_check(tc->check_subcmd, tc->des, *(int *)(tc->addr));
diff --git a/testcases/kernel/syscalls/quotactl/quotactl06.c b/testcases/kernel/syscalls/quotactl/quotactl06.c
index 21a86ad1e..9206cc3e4 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl06.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl06.c
@@ -12,7 +12,7 @@ 
  *
  * - 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
- * - EBUSTY 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
@@ -68,13 +68,13 @@  static struct dqblk set_dqmax = {
 	.dqb_valid = QIF_BLIMITS
 };
 
-struct tst_cap dropadmin = {
+static struct tst_cap dropadmin = {
 	.action = TST_CAP_DROP,
 	.id = CAP_SYS_ADMIN,
 	.name = "CAP_SYS_ADMIN",
 };
 
-struct tst_cap needadmin = {
+static struct tst_cap needadmin = {
 	.action = TST_CAP_REQ,
 	.id = CAP_SYS_ADMIN,
 	.name = "CAP_SYS_ADMIN",
@@ -86,18 +86,44 @@  static struct tcase {
 	void *addr;
 	int exp_err;
 	int on_flag;
+	char *des;
 } tcases[] = {
-	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, testdir1, EACCES, 0},
-	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, testdir2, ENOENT, 0},
-	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, usrpath, EBUSY, 1},
-	{QCMD(Q_SETQUOTA, USRQUOTA), &fmt_id, NULL, EFAULT, 1},
-	{QCMD(OPTION_INVALID, USRQUOTA), &fmt_id, usrpath, EINVAL, 0},
-	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, usrpath, ENOTBLK, 0},
-	{QCMD(Q_SETQUOTA, USRQUOTA), &test_id, &set_dq, ESRCH, 0},
-	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_invalid, usrpath, ESRCH, 0},
-	{QCMD(Q_GETNEXTQUOTA, USRQUOTA), &test_invalid, usrpath, ESRCH, 0},
-	{QCMD(Q_SETQUOTA, USRQUOTA), &test_id, &set_dqmax, ERANGE, 1},
-	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, usrpath, EPERM, 0},
+	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, testdir1, EACCES, 0,
+	"EACCES when cmd is Q_QUOTAON and addr existed but not a regular file"},
+
+	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, testdir2, ENOENT, 0,
+	"ENOENT when the file specified by special or addr does not exist"},
+
+	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, usrpath, EBUSY, 1,
+	"EBUSY when cmd is Q_QUOTAON and another Q_QUOTAON had already been performed"},
+
+	{QCMD(Q_SETQUOTA, USRQUOTA), &fmt_id, NULL, EFAULT, 1,
+	"EFAULT when addr or special is invalid"},
+
+	{QCMD(OPTION_INVALID, USRQUOTA), &fmt_id, usrpath, EINVAL, 0,
+	"EINVAL when cmd or type is invalid"},
+
+	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, usrpath, ENOTBLK, 0,
+	"ENOTBLK when special is not a block device"},
+
+	{QCMD(Q_SETQUOTA, USRQUOTA), &test_id, &set_dq, ESRCH, 0,
+	"ESRCH when no disk quota is found for the indicated user and quotas "
+	"have not been turned on for this fs"},
+
+	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_invalid, usrpath, ESRCH, 0,
+	"ESRCH when cmd is Q_QUOTAON, but the quota format was not found"},
+
+	{QCMD(Q_GETNEXTQUOTA, USRQUOTA), &test_invalid, usrpath, ESRCH, 0,
+	"ESRCH when cmd is Q_GETNEXTQUOTA, but there is no ID greater than or "
+	"equal to id that has an active quota"},
+
+	{QCMD(Q_SETQUOTA, USRQUOTA), &test_id, &set_dqmax, ERANGE, 1,
+	"ERANGE when cmd is Q_SETQUOTA, but the specified limits are out of "
+	"the range allowed by the quota format"},
+
+	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, usrpath, EPERM, 0,
+	"EPERM when the caller lacked the required privilege (CAP_SYS_ADMIN) "
+	"for the specified operation"},
 };
 
 static void verify_quotactl(unsigned int n)
@@ -106,17 +132,17 @@  static void verify_quotactl(unsigned int n)
 	int quota_on = 0;
 	int drop_flag = 0;
 
+	tst_res(TINFO, "Testing %s", tc->des);
 	if (tc->cmd == QCMD(Q_GETNEXTQUOTA, USRQUOTA) && getnextquota_nsup) {
 		tst_res(TCONF, "current system doesn't support Q_GETNEXTQUOTA");
 		return;
 	}
 
 	if (tc->on_flag) {
-		TEST(quotactl(QCMD(Q_QUOTAON, USRQUOTA), tst_device->dev,
-			fmt_id, usrpath));
-		if (TST_RET == -1)
-			tst_brk(TBROK,
-				"quotactl with Q_QUOTAON returned %ld", TST_RET);
+		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;
 	}
 
@@ -126,27 +152,17 @@  static void verify_quotactl(unsigned int n)
 	}
 
 	if (tc->exp_err == ENOTBLK)
-		TEST(quotactl(tc->cmd, "/dev/null", *tc->id, tc->addr));
+		TST_EXP_FAIL(quotactl(tc->cmd, "/dev/null", *tc->id, tc->addr),
+			ENOTBLK, "quotactl()");
 	else
-		TEST(quotactl(tc->cmd, tst_device->dev, *tc->id, tc->addr));
-	if (TST_RET == -1) {
-		if (tc->exp_err == TST_ERR) {
-			tst_res(TPASS | TTERRNO, "quotactl failed as expected");
-		} else {
-			tst_res(TFAIL | TTERRNO,
-				"quotactl failed unexpectedly; expected %s, but got",
-				tst_strerrno(tc->exp_err));
-		}
-	} else {
-		tst_res(TFAIL, "quotactl returned wrong value: %ld", TST_RET);
-	}
+		TST_EXP_FAIL(quotactl(tc->cmd, tst_device->dev, *tc->id, tc->addr),
+			tc->exp_err, "quotactl()");
 
 	if (quota_on) {
-		TEST(quotactl(QCMD(Q_QUOTAOFF, USRQUOTA), tst_device->dev,
-			fmt_id, usrpath));
-		if (TST_RET == -1)
-			tst_brk(TBROK,
-				"quotactl with Q_QUOTAOFF returned %ld", TST_RET);
+		TST_EXP_PASS_SILENT(quotactl(QCMD(Q_QUOTAOFF, USRQUOTA), tst_device->dev,
+					fmt_id, usrpath), "quotactl with Q_QUOTAOFF");
+		if (!TST_PASS)
+			return;
 		quota_on = 0;
 	}