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

Cyril Hrubis chrubis@suse.cz
Thu Nov 12 11:43:23 CET 2020


Hi!
> > 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?
> LGTM. I was thinking about adding it directly into TEST() and define _TEST()
> which would not do that and be used in that few cases which ret < -1 is valid,
> but that would be ugly.

Well it would have to be a set of macros at least since:

* There are different classes of functions by return values

* We have possitive and negative testcases

For example we would have to have two macros for functions that return
file descriptors, one for a cases where we expect the function to return
a valid file descriptor and one when we expect the function to fail.

So it would look like:

	TEST_FD(open("/foo/bar", O_RDONLY));

or:
	TEST_FAIL(open((void*)-1, O_RDONLY));


The TEST_FD() macro would fail the test if the return value is < 0

And the TEST_FAIL() will fail the test unless we the return value is set
to -1. Maybe we can even have a version with errno as well something as:

	TEST_FAIL_ERR(open((void*)-1, O_RDONLY), EFAULT);

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list