[LTP] [PATCH 2/3] link05: Convert docs to docparse

Yang Xu (Fujitsu) xuyang2018.jy@fujitsu.com
Tue Oct 17 08:11:17 CEST 2023


Hi Petr
> Hi Xu,
>
>> +++ b/testcases/kernel/syscalls/link/link05.c
>> @@ -1,12 +1,14 @@
>>   // SPDX-License-Identifier: GPL-2.0-or-later
>>   /*
>>    * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
>> - *  AUTHOR		: Richard Logan
>> - *  CO-PILOT		: William Roske
>> + * AUTHOR		: Richard Logan
>> + * CO-PILOT		: William Roske
> * Authors: Richard Logan, William Roske
ok.
>>    * Copyright (c) 2014 Cyril Hrubis <chrubis@suse.cz>
> * Copyright (c) Linux Test Project, 2001-2023
ok.
>>    */
> With this fixed:
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
ok.
>> -/*
>> +/*\
>> + * [Description]
>> + *
>>    * Test if link(2) fails with EMLINK.
>>    */
> I was thinking how to cleanup test a bit. I don't like the loop
> (SAFE_STAT(fname, &fbuf)). It could be simplified with putting
> the loop into .tcnt = 1000, if (1000) (and put 1000 to #define).
>
> Also it mixes tabs and spaces (visible in make check-link05,
> spaces should be converted to tabs).
>
> Kind regards,
> Petr

I'll try to modify it as you want.

#include <stdio.h>
#include <sys/stat.h>
#include "tst_test.h"

#define BASENAME        "lkfile"
#define NUM_LINKS       1000
static char fname[255];

static void verify_link(unsigned int cnt)
{
         char lname[1024];
         struct stat fbuf, lbuf;

         sprintf(lname, "%s_%d", fname, cnt);
         TST_EXP_PASS_SILENT(link(fname, lname), "link(%s, %s)", fname, 
lname);

         SAFE_STAT(fname, &fbuf);
         SAFE_STAT(lname, &lbuf);

         if (fbuf.st_nlink < 1 || lbuf.st_nlink < 1 ||
                 (fbuf.st_nlink != lbuf.st_nlink)) {
                         tst_res(TFAIL,
                                   "link(%s, %s[1-%d]) ret %ld for %d "
                                   "files, stat values do not match %d %d",
                                   fname, fname, NUM_LINKS,
                                   TST_RET, NUM_LINKS,
                                  (int)fbuf.st_nlink, (int)lbuf.st_nlink);

                 } else {
                         tst_res(TPASS,
                                     "link(%s, %s[1-%d]) ret %ld for %d 
files, "
                                     "stat linkcounts match %d %d",
                                     fname, fname, cnt, TST_RET,
                                     NUM_LINKS, (int)fbuf.st_nlink, 
(int)lbuf.st_nlink);
                 }
}

static void setup(void)
{
         sprintf(fname, "%s_%d", BASENAME, getpid());
         SAFE_TOUCH(fname, 0700, NULL);
}

static struct tst_test test = {
         .tcnt = NUM_LINKS,
         .test = verify_link,
         .setup = setup,
         .needs_tmpdir = 1,
};

There is a problem here that if .tcnt=1000 is needed, verify_link() 
needs to have an output in every loop,

this must output 1000 results, but I don't know how to simplify the output.

And I noticed that there was no connection between the description

and the test content, which was a point I overlooked.


Best regards,

Yang Xu


More information about the ltp mailing list