[LTP] [PATCH v5 3/3] syscalls/quotactl: Make use of TST_EXP_PASS_SILENT and TST_EXP_FAIL
Yang Xu
xuyang2018.jy@fujitsu.com
Tue Jan 11 11:28:39 CET 2022
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 | 35 +++++----------
6 files changed, 39 insertions(+), 69 deletions(-)
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..d2fadc895 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl06.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl06.c
@@ -112,11 +112,10 @@ static void verify_quotactl(unsigned int n)
}
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 +125,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;
}
--
2.23.0
More information about the ltp
mailing list