Skip to contentSkip to conversation

syscalls/truncate03.c: use TST_EXP_FAIL() macro

PATCH In review Avinesh Kumar 2 participants 2 messages Jul 15, 2022 – Sep 1, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 syscalls/truncate03.c: use TST_EXP_FAIL() macro

---
 .../kernel/syscalls/truncate/truncate03.c     | 21 ++-----------------
 1 file changed, 2 insertions(+), 19 deletions(-)
testcases/kernel/syscalls/truncate/truncate03.c +2 -19
index a9cd4b3ed..1e19f7743 100644
@@ -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 = {
Signature · 5 lines
2.36.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Avinesh,

...

Quoted 11 lines
testcases/kernel/syscalls/truncate/truncate03.c +0 -11
-	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;
-	}

testcases/kernel/syscalls/truncate/truncate03.c static void verify_truncate(unsigned int n) · line 120

Quoted 10 lines
testcases/kernel/syscalls/truncate/truncate03.c +2 -8
-
-	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);

I put this on single line, updated copyright and merged. Thanks!

Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp