[LTP] [PATCH v2] link/link02: Convert to new API

Li Wang liwang@redhat.com
Tue Oct 26 07:12:02 CEST 2021


Hi Meng,


> --- a/testcases/kernel/syscalls/link/link02.c
> +++ b/testcases/kernel/syscalls/link/link02.c
> @@ -34,23 +34,14 @@
>   */
>

For the Copyright & Licence we should respect the original
author and use SPDX format.  Something like this:

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
 *  AUTHOR : William Roske
 *  CO-PILOT : Dave Fenner
 * Copyright (c) 2014 Cyril Hrubis <chrubis@suse.cz>
 */



> -int main(int ac, char **av)
> -{
> -       int lc;
> +       TST_EXP_PASS(link(OLDPATH, NEWPATH));
>
> -       tst_parse_opts(ac, av, NULL, NULL);
> +       if (!TST_PASS)
> +               return;
>
> -       setup();
> +       SAFE_STAT(OLDPATH, &fbuf);
> +       SAFE_STAT(NEWPATH, &lbuf);
>
> -       for (lc = 0; TEST_LOOPING(lc); lc++) {
> -               tst_count = 0;
> -               verify_link();
> +       if (fbuf.st_nlink > 1 && fbuf.st_nlink == lbuf.st_nlink) {
> +               tst_res(TPASS, "link("OLDPATH","NEWPATH") "
> +                                 "returned 0 and stat link counts match");
> +       } else {
> +               tst_res(TFAIL, "link("OLDPATH","NEWPATH") returned 0"
> +                                 " but stat link counts do not match %d
> %d",
> +                                 (int)fbuf.st_nlink, (int)lbuf.st_nlink);
>         }
>

As I mentioned we have to do unlink() here otherwise
test can not run pass with -i option.

        SAFE_UNLINK(NEWPATH);


> +static struct tst_test test = {
> +    .test_all = verify_link,
> +    .setup = setup,
> +    .needs_tmpdir = 1,
>

I'd suggest using tab instead of space to make
code indent.

-- 
Regards,
Li Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20211026/47e14b24/attachment.htm>


More information about the ltp mailing list