[LTP] [PATCH] nfs_flock: fail the test if lock/unlock ops fail
Martin Doucha
mdoucha@suse.cz
Fri Jan 14 10:31:15 CET 2022
Hello,
On 12. 01. 22 17:19, Nikita Yushchenko via ltp wrote:
> Since nfs_flock is testing locking operations, ignoring errors returned
> from those operations is nonsense.
>
> Signed-off-by: Nikita Yushchenko <nikita.yushchenko@virtuozzo.com>
> ---
> testcases/network/nfs/nfslock01/nfs_flock.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/testcases/network/nfs/nfslock01/nfs_flock.c b/testcases/network/nfs/nfslock01/nfs_flock.c
> index a7673c751..a13ddd251 100644
> --- a/testcases/network/nfs/nfslock01/nfs_flock.c
> +++ b/testcases/network/nfs/nfslock01/nfs_flock.c
> @@ -63,16 +63,20 @@ int main(int argc, char **argv)
> continue;
> }
>
> - if (writeb_lock(fd, offset, SEEK_SET, BYTES) < 0)
> - printf("failed in writeb_lock, Errno = %d", errno);
> + if (writeb_lock(fd, offset, SEEK_SET, BYTES) < 0) {
> + printf("failed in writeb_lock, Errno = %d\n", errno);
> + exit(1);
> + }
>
> lseek(fd, offset, SEEK_SET);
>
> /* write to the test file */
> write(fd, buf, BYTES);
>
> - if (unb_lock(fd, offset, SEEK_SET, BYTES) < 0)
> - printf("failed in unb_lock, Errno = %d", errno);
> + if (unb_lock(fd, offset, SEEK_SET, BYTES) < 0) {
> + printf("failed in unb_lock, Errno = %d\n", errno);
> + exit(1);
> + }
> }
> exit(0);
> }
The test program is quite short and simple. Why not rewrite it using the
current LTP API and make it even better? Some useful links to help with
that:
https://github.com/linux-test-project/ltp/wiki/C-Test-Case-Tutorial
https://github.com/linux-test-project/ltp/wiki/C-Test-API
https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines
--
Martin Doucha mdoucha@suse.cz
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic
More information about the ltp
mailing list