[LTP] [PATCH 2/4] fanotify03: Add test cases for permission events on children

Jan Kara jack@suse.cz
Mon Feb 10 16:24:55 CET 2025


On Mon 10-02-25 16:13:14, Amir Goldstein wrote:
> Verify that permission events are delivered iff parent is watching
> children.
> 
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>

Overall looks ok but:

> -	if (read(fd, buf, BUF_SIZE) != -1)
> +	exp_ret = exp_errno ? -1 : 1;
> +	errno = 0;
> +	if (read(fd, buf, BUF_SIZE) != exp_ret || errno != exp_errno) {
> +		tst_res(TFAIL, "read() got errno %d (expected %d)", errno, exp_errno);
>  		exit(3);
> +	} else if (errno == exp_errno) {
		^^ Why is this condition needed? It is always true AFAICT.

> +		tst_res(TINFO, "read() got errno %d as expected", errno);
> +	}
>  
>  	SAFE_CLOSE(fd);
>  
> -	if (execve(FILE_EXEC_PATH, argv, environ) != -1)
> +	exp_ret = exp_errno ? -1 : 0;
> +	errno = 0;
> +	if (execve(FILE_EXEC_PATH, argv, environ) != exp_ret || errno != exp_errno) {
> +		tst_res(TFAIL, "execve() got errno %d (expected %d)", errno, exp_errno);
>  		exit(5);
> +	} else if (errno == exp_errno) {
		^^^ and here as well...

> +		tst_res(TINFO, "execve() got errno %d as expected", errno);
> +	}
>  }

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR


More information about the ltp mailing list