[LTP] [PATCH V3 3/3] syscalls: finit_module: Add tests

Cyril Hrubis chrubis@suse.cz
Thu Dec 17 13:02:43 CET 2020


Hi!
> +static void setup(void)
> +{
> +	finit_module_supported_by_kernel();
> +
> +	/* Kernel returned ENOEXEC for fd = -1 earlier */
> +	if ((tst_kvercmp(4, 6, 0)) < 0)
> +		tcases[0].exp_errno = ENOEXEC;

There are plenty of ways how to avoid hackery like that.

What about we defined a setup function in the test structure and then
loop over the testcases in the test setup() and execute all per-test
setup functions we have.

The we can keep the errno set to zero in the static structure and
initialize it in the per-testcase setup as:

static void bad_fd_setup(struct tcase *tc)
{
	if (tst_kvercmp(4, 6, 0)) < 0)
		tc->errno = ENOEXEC;
	else
		tc->errno = EBADFD;
}


Also I think that the last test needs to handle ETXTBSY in the same way
and we may possibly add more tests since I guess that most of the errors
that apply to execve() would apply here as well. What happpens for
example if we pass a fd that points to a directory?

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list