[LTP] [PATCH] syscalls/truncate03.c: use TST_EXP_FAIL() macro

Avinesh Kumar akumar@suse.de
Fri Jul 15 16:25:20 CEST 2022


Signed-off-by: Avinesh Kumar <akumar@suse.de>
---
 .../kernel/syscalls/truncate/truncate03.c     | 21 ++-----------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/testcases/kernel/syscalls/truncate/truncate03.c b/testcases/kernel/syscalls/truncate/truncate03.c
index a9cd4b3ed..1e19f7743 100644
--- a/testcases/kernel/syscalls/truncate/truncate03.c
+++ b/testcases/kernel/syscalls/truncate/truncate03.c
@@ -116,25 +116,8 @@ static void verify_truncate(unsigned int n)
 {
 	struct test_case_t *tc = &test_cases[n];
 
-	TEST(truncate(tc->pathname, tc->length));
-	if (TST_RET == 0) {
-		tst_res(TFAIL, "truncate() succeeded when failure expected");
-		return;
-	}
-
-	if (TST_RET != -1) {
-		tst_res(TFAIL, "truncate() returned invalid value %ld",
-			TST_RET);
-		return;
-	}
-
-	if (TST_ERR == tc->exp_errno) {
-		tst_res(TPASS | TTERRNO, "truncate() failed as expected");
-	} else {
-		tst_res(TFAIL | TTERRNO,
-			"truncate() failed unexpectedly; expected: %d - %s",
-			tc->exp_errno, strerror(tc->exp_errno));
-	}
+	TST_EXP_FAIL(truncate(tc->pathname, tc->length),
+				tc->exp_errno);
 }
 
 static struct tst_test test = {
-- 
2.36.1



More information about the ltp mailing list