From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAB8AC433F5 for ; Tue, 2 Nov 2021 09:19:12 +0000 (UTC) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E6BE360F36 for ; Tue, 2 Nov 2021 09:19:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E6BE360F36 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.linux.it Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E27153C710E for ; Tue, 2 Nov 2021 10:19:09 +0100 (CET) Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 153F53C6BE2 for ; Tue, 2 Nov 2021 10:18:58 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 326071A017B4 for ; Tue, 2 Nov 2021 10:18:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635844735; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nki6omwzdYo9Mxf0QlGBmz0UVZ/eIOsH84UdszasqYg=; b=goOPxT0iryNsURd+ymjOEIDUtPQoO4LeyHsSpfHhxg9lW21PAQJwmwJGJ/Axs1flyjlzqR s8k5ZnfhVvHrns++xgkI+vFgtwc6pFmnUWW+rG8OBaXS7Mdn6J8+7Ar4oEAJooVQYWWFBP 0hQi2ky1YE3HNSUTnzAYrG4FADV1++E= Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-395-NItCqXelO7e9KRlDOrmTTQ-1; Tue, 02 Nov 2021 05:18:44 -0400 X-MC-Unique: NItCqXelO7e9KRlDOrmTTQ-1 Received: by mail-yb1-f197.google.com with SMTP id y125-20020a25dc83000000b005c2326bf744so11015428ybe.21 for ; Tue, 02 Nov 2021 02:18:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nki6omwzdYo9Mxf0QlGBmz0UVZ/eIOsH84UdszasqYg=; b=IeTdJW75GS3Xim5pbUKWjEE8SttvMOiJb7LaKogUV3Q1Yt8VY2bog5oBFUtiiQSM/X GgIJ7zwbnPijSATTQ4RCsOm69GwQMlWy4D8vceubwXeak3xUiTBpp7Kn5t03tfvNe9I9 N05Cy7TkzvdHnm5446U2bLLXzy+U1YyA+/Od7o7qLvJQ5H7dDCH5P4XTEOkkPLit8PYi uMC2SBkRXvPpPkqXG2LPHauTg1jRwhE0Ukk/Yir6Bm68p1y5Kl1Knd+zP7izO9okGqY4 q+WDkCdHCYOnYuln4Jfrr/IwfzQhAbkhfhv2mX0ydEzSwApTN+p+EyPTv5sW/EUN91w4 JAeg== X-Gm-Message-State: AOAM533QMecDM1aUUdo6Sw+jl0U3JNE5xic6w5cTmrM0ZKcH+XjjdbQw qGEselP2X5D0l7149SCMAyvWWA03KrnQnWzHYaa9o5W1Gj+w7ZIcpFV14F0GAsPO/P1SS6kkO6w McCxCen4K51pEcdCaOw3TGi/YC04= X-Received: by 2002:a05:6902:690:: with SMTP id i16mr19333525ybt.302.1635844723445; Tue, 02 Nov 2021 02:18:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyl1vGyAv4r9EZSobKrKHN8BsH2B2gKx89nHPBedv1MshZRkGHDWcAUyrT3BnuXQ4P+A1Lep2U53n0/uOvDz24= X-Received: by 2002:a05:6902:690:: with SMTP id i16mr19333506ybt.302.1635844723190; Tue, 02 Nov 2021 02:18:43 -0700 (PDT) MIME-Version: 1.0 References: <20211029080527.28014-1-tangmeng@uniontech.com> In-Reply-To: <20211029080527.28014-1-tangmeng@uniontech.com> From: Li Wang Date: Tue, 2 Nov 2021 17:18:30 +0800 Message-ID: To: tangmeng Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=liwan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean Subject: Re: [LTP] [PATCH 1/4] link/link04: Convert to new API X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: LTP List Content-Type: multipart/mixed; boundary="===============0305848199==" Errors-To: ltp-bounces+ltp=archiver.kernel.org@lists.linux.it Sender: "ltp" --===============0305848199== Content-Type: multipart/alternative; boundary="000000000000a245d705cfcac74b" --000000000000a245d705cfcac74b Content-Type: text/plain; charset="UTF-8" Hi Meng, On Fri, Oct 29, 2021 at 4:06 PM tangmeng wrote: > Signed-off-by: tangmeng > --- > testcases/kernel/syscalls/link/link04.c | 140 +++++------------------- > 1 file changed, 29 insertions(+), 111 deletions(-) > > diff --git a/testcases/kernel/syscalls/link/link04.c > b/testcases/kernel/syscalls/link/link04.c > index d9408845e..acc8a7134 100644 > --- a/testcases/kernel/syscalls/link/link04.c > +++ b/testcases/kernel/syscalls/link/link04.c > @@ -1,65 +1,32 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > /* > * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. > * AUTHOR : Richard Logan > * CO-PILOT : William Roske > * Copyright (c) 2014 Cyril Hrubis > - * > - * This program is free software; you can redistribute it and/or modify it > - * under the terms of version 2 of the GNU General Public License as > - * published by the Free Software Foundation. > - * > - * This program is distributed in the hope that it would be useful, but > - * WITHOUT ANY WARRANTY; without even the implied warranty of > - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > - * > - * Further, this software is distributed without any warranty that it is > - * free of the rightful claim of any third person regarding infringement > - * or the like. Any license provided herein, whether implied or > - * otherwise, applies only to this software file. Patent licenses, if > - * any, provided herein do not apply to combinations of this program with > - * other software, or any other product whatsoever. > - * > - * You should have received a copy of the GNU General Public License along > - * with this program; if not, write the Free Software Foundation, Inc., > - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > - * > - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, > - * Mountain View, CA 94043, or: > - * > - * http://www.sgi.com > - * > - * For further information regarding this notice, see: > - * > - * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ > - * > */ > > -/* > +/*\ > + * [Description] > + * > * Negative test cases for link(2). > * > * This test program should contain test cases where link will fail > regardless > * of who executed it (i.e. joe-user or root) > */ > -#include > -#include > -#include > -#include > -#include > -#include > #include > #include > -#include "test.h" > -#include "safe_macros.h" > +#include "tst_test.h" > > static char longpath[PATH_MAX + 2]; > > -struct test_case_t { > +struct tcase_t { > char *file1; > char *desc1; > char *file2; > char *desc2; > int exp_errno; > -} test_cases[] = { > +} tcases[] = { > /* first path is invalid */ > {"nonexistfile", "non-existent file", "nefile", "nefile", ENOENT}, > {"", "path is empty string", "nefile", "nefile", ENOENT}, > @@ -81,90 +48,41 @@ struct test_case_t { > {"regfile", "regfile", "regfile2", "regfile2", EEXIST}, > }; > > -char *TCID = "link04"; > -int TST_TOTAL = ARRAY_SIZE(test_cases); > +static unsigned int TST_TOTAL = ARRAY_SIZE(tcases); > There is no need to define an extra global variable for the test loop. LTP itself has already supported that to traversing tcase by .tcnt. For your reference: https://github.com/linux-test-project/ltp/blob/master/testcases/kernel/syscalls/madvise/madvise01.c#L117 > > -static void setup(void); > -static void cleanup(void); > - > -int main(int ac, char **av) > +static void verify_link(void) > { > - int lc; > - char *fname1, *fname2; > - char *desc1, *desc2; > - int i; > - > - tst_parse_opts(ac, av, NULL, NULL); > - > - setup(); > - > - for (lc = 0; TEST_LOOPING(lc); lc++) { > - > - tst_count = 0; > - > - for (i = 0; i < TST_TOTAL; i++) { > - > - fname1 = test_cases[i].file1; > - desc1 = test_cases[i].desc1; > - fname2 = test_cases[i].file2; > - desc2 = test_cases[i].desc2; > - > - TEST(link(fname1, fname2)); > - > - if (TEST_RETURN == -1) { > - if (TEST_ERRNO == test_cases[i].exp_errno) > { > - tst_resm(TPASS | TTERRNO, > - "link(<%s>, <%s>)", > - desc1, desc2); > - } else { > - tst_resm(TFAIL | TTERRNO, > - "link(<%s>, <%s>) Failed " > - "expected errno: %d", > - desc1, desc2, > - test_cases[i].exp_errno); > - } > - } else { > - tst_resm(TFAIL, > - "link(<%s>, <%s>) returned %ld, " > - "expected -1, errno:%d", > - desc1, desc2, TEST_RETURN, > - test_cases[i].exp_errno); > - } > - } > + unsigned int i; > > + for (i = 0; i < TST_TOTAL; i++) { > + TST_EXP_FAIL(link(tcases[i].file1, tcases[i].file2), > + tcases[i].exp_errno, "link(<%s>, <%s>)", > + tcases[i].desc1, tcases[i].desc2); > } > - > - cleanup(); > - tst_exit(); > } > > static void setup(void) > { > - int n; > - > - tst_sig(NOFORK, DEF_HANDLER, cleanup); > - > - TEST_PAUSE; > - > - tst_tmpdir(); > + unsigned int i; > > memset(longpath, 'a', PATH_MAX+1); > - SAFE_TOUCH(cleanup, "regfile", 0777, NULL); > - SAFE_TOUCH(cleanup, "regfile2", 0777, NULL); > - SAFE_MKDIR(cleanup, "dir", 0777); > + SAFE_TOUCH("regfile", 0777, NULL); > + SAFE_TOUCH("regfile2", 0777, NULL); > + SAFE_MKDIR("dir", 0777); > > - void *bad_addr = tst_get_bad_addr(cleanup); > + void *bad_addr = tst_get_bad_addr(NULL); > > - for (n = 0; n < TST_TOTAL; n++) { > - if (!test_cases[n].file1) > - test_cases[n].file1 = bad_addr; > + for (i = 0; i < TST_TOTAL; i++) { > + if (!tcases[i].file1) > + tcases[i].file1 = bad_addr; > > - if (!test_cases[n].file2) > - test_cases[n].file2 = bad_addr; > + if (!tcases[i].file2) > + tcases[i].file2 = bad_addr; > } > } > > -static void cleanup(void) > -{ > - tst_rmdir(); > -} > +static struct tst_test test = { > + .test_all = verify_link, > + .setup = setup, > + .needs_tmpdir = 1, > +}; > -- > 2.20.1 > > > > > -- > Mailing list info: https://lists.linux.it/listinfo/ltp > > -- Regards, Li Wang --000000000000a245d705cfcac74b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Meng,

On Fri, Oct 29, 2021 at 4:06 PM tangmeng <= tangmeng@uniontech.com> wr= ote:
Signed-off-= by: tangmeng <tangmeng@uniontech.com>
---
=C2=A0testcases/kernel/syscalls/link/link04.c | 140 +++++------------------= -
=C2=A01 file changed, 29 insertions(+), 111 deletions(-)

diff --git a/testcases/kernel/syscalls/link/link04.c b/testcases/kernel/sys= calls/link/link04.c
index d9408845e..acc8a7134 100644
--- a/testcases/kernel/syscalls/link/link04.c
+++ b/testcases/kernel/syscalls/link/link04.c
@@ -1,65 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
=C2=A0/*
=C2=A0 * Copyright (c) 2000 Silicon Graphics, Inc.=C2=A0 All Rights Reserve= d.
=C2=A0 *=C2=A0 AUTHOR=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0: Rich= ard Logan
=C2=A0 *=C2=A0 CO-PILOT=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0: William R= oske
=C2=A0 * Copyright (c) 2014 Cyril Hrubis <chrubis@suse.cz>
- *
- * This program is free software; you can redistribute it and/or modify it=
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like.=C2=A0 Any license provided herein, whether implied or
- * otherwise, applies only to this software file.=C2=A0 Patent licenses, i= f
- * any, provided herein do not apply to combinations of this program with<= br> - * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along=
- * with this program; if not, write the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA=C2=A0 94043, or:
- *
- * htt= p://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/NoticeExpla= n/
- *
=C2=A0 */

-/*
+/*\
+ * [Description]
+ *
=C2=A0 * Negative test cases for link(2).
=C2=A0 *
=C2=A0 * This test program should contain test cases where link will fail r= egardless
=C2=A0 * of who executed it (i.e. joe-user or root)
=C2=A0 */
-#include <sys/types.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <string.h>
-#include <signal.h>
=C2=A0#include <sys/param.h>
=C2=A0#include <sys/mman.h>
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"

=C2=A0static char longpath[PATH_MAX + 2];

-struct test_case_t {
+struct tcase_t {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 char *file1;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 char *desc1;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 char *file2;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 char *desc2;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 int exp_errno;
-} test_cases[] =3D {
+} tcases[] =3D {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 /* first path is invalid */
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {"nonexistfile", "non-existent f= ile", "nefile", "nefile", ENOENT},
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {"", "path is empty string"= , "nefile", "nefile", ENOENT},
@@ -81,90 +48,41 @@ struct test_case_t {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {"regfile", "regfile", &quo= t;regfile2", "regfile2", EEXIST},
=C2=A0};

-char *TCID =3D "link04";
-int TST_TOTAL =3D ARRAY_SIZE(test_cases);
+static unsigned int TST_TOTAL =3D ARRAY_SIZE(tcases);

Ther= e is no need to define an extra global variable for the test loop.

LTP itself has already=C2=A0supported that to tra= versing=C2=A0tcase<= /span> by .t= cnt.

For your reference:

=C2=A0

-static void setup(void);
-static void cleanup(void);
-
-int main(int ac, char **av)
+static void verify_link(void)
=C2=A0{
-=C2=A0 =C2=A0 =C2=A0 =C2=A0int lc;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0char *fname1, *fname2;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0char *desc1, *desc2;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0int i;
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0tst_parse_opts(ac, av, NULL, NULL);
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0setup();
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0for (lc =3D 0; TEST_LOOPING(lc); lc++) {
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0tst_count =3D 0; -
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0for (i =3D 0; i <= ; TST_TOTAL; i++) {
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0fname1 =3D test_cases[i].file1;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0desc1 =3D test_cases[i].desc1;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0fname2 =3D test_cases[i].file2;
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0desc2 =3D test_cases[i].desc2;
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0TEST(link(fname1, fname2));
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0if (TEST_RETURN =3D=3D -1) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (TEST_ERRNO =3D=3D test_cases[i].e= xp_errno) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0tst_resm(= TPASS | TTERRNO,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2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=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 desc1, d= esc2, TEST_RETURN,
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 test_cas= es[i].exp_errno);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0}
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned int i;

+=C2=A0 =C2=A0 =C2=A0 =C2=A0for (i =3D 0; i < TST_TOTAL; i++) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0TST_EXP_FAIL(link(t= cases[i].file1, tcases[i].file2),
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0tcases[i].exp_errno, "link(<%= s>, <%s>)",
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0tcases[i].desc1, tcases[i].desc2); =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0cleanup();
-=C2=A0 =C2=A0 =C2=A0 =C2=A0tst_exit();
=C2=A0}

=C2=A0static void setup(void)
=C2=A0{
-=C2=A0 =C2=A0 =C2=A0 =C2=A0int n;
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0TEST_PAUSE;
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0tst_tmpdir();
+=C2=A0 =C2=A0 =C2=A0 =C2=A0unsigned int i;

=C2=A0 =C2=A0 =C2=A0 =C2=A0 memset(longpath, 'a', PATH_MAX+1);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0SAFE_TOUCH(cleanup, "regfile", 0777, = NULL);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0SAFE_TOUCH(cleanup, "regfile2", 0777,= NULL);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0SAFE_MKDIR(cleanup, "dir", 0777);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0SAFE_TOUCH("regfile", 0777, NULL); +=C2=A0 =C2=A0 =C2=A0 =C2=A0SAFE_TOUCH("regfile2", 0777, NULL); +=C2=A0 =C2=A0 =C2=A0 =C2=A0SAFE_MKDIR("dir", 0777);

-=C2=A0 =C2=A0 =C2=A0 =C2=A0void *bad_addr =3D tst_get_bad_addr(cleanup); +=C2=A0 =C2=A0 =C2=A0 =C2=A0void *bad_addr =3D tst_get_bad_addr(NULL);

-=C2=A0 =C2=A0 =C2=A0 =C2=A0for (n =3D 0; n < TST_TOTAL; n++) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!test_cases[n].= file1)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0test_cases[n].file1 =3D bad_addr;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0for (i =3D 0; i < TST_TOTAL; i++) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!tcases[i].file= 1)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0tcases[i].file1 =3D bad_addr;

-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!test_cases[n].= file2)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0test_cases[n].file2 =3D bad_addr;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!tcases[i].file= 2)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0tcases[i].file2 =3D bad_addr;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0}

-static void cleanup(void)
-{
-=C2=A0 =C2=A0 =C2=A0 =C2=A0tst_rmdir();
-}
+static struct tst_test test =3D {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0.test_all =3D verify_link,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0.setup =3D setup,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0.needs_tmpdir =3D 1,
+};
--
2.20.1




--
Mailing list info: https://lists.linux.it/listinfo/ltp



--
Regards,
Li = Wang
--000000000000a245d705cfcac74b-- --===============0305848199== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- Mailing list info: https://lists.linux.it/listinfo/ltp --===============0305848199==--