diff mbox series

syscalls/truncate03.c: use TST_EXP_FAIL() macro

Message ID 20220715142520.6632-1-akumar@suse.de
State Accepted
Headers show
Series syscalls/truncate03.c: use TST_EXP_FAIL() macro | expand

Commit Message

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

Comments

Petr Vorel Sept. 1, 2022, 11:32 a.m. UTC | #1
Hi Avinesh,

...
> -	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);

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

Petr
diff mbox series

Patch

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 = {