[LTP] [PATCH 1/4] syscalls/sync01: Remove it

Radoslav Kolev radoslav.kolev@suse.com
Mon Nov 9 19:15:55 CET 2020


On Mon, 2020-11-09 at 13:42 +0100, Cyril Hrubis wrote:
> Hi!
> > 1) open(2) will return -1 if an error occur.
> >      Is it necessary to check invalid return value(except -1) if
> > an 
> > error occur?
> 
> Well if there are values that are never supposed to be returned it
> makes
> sense to catch these and return a TBROK or TFAIL.
> 
> If we are expecially testing a syscall() I would say that we should
> check for all kinds of errors including the values that shall not be
> returned e.g.:
> 
> 	TEST(open(...));
> 
> 	if (TST_RET == -1) {
> 		tst_ret(TFAIL | TTERRNO, "open() failed");
> 		return;
> 	}
> 
> 	if (TST_RET < 0) {
> 		tst_ret(TFAIL | TTERRNO, "Invalid open() retval %ld",
> TST_RET);
> 		return;
> 	}
> 
> 	...

I see no downside in checking for this unexpected negative value,
except copy/pasting this test condition in every syscall testcase.

I don't know the LTP codebase well enough yet, but what would you say
is a good way to have this somewhere in the library. A TEST_SYSCALL
macro, or something else, which fails if the return value is < -1?



More information about the ltp mailing list