From patchwork Fri Oct 20 09:37:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yang Xu \\(Fujitsu\\)" X-Patchwork-Id: 1852401 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SBff959sYz23jq for ; Fri, 20 Oct 2023 20:38:25 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 184003C9A2B for ; Fri, 20 Oct 2023 11:38:21 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 717A73C8927 for ; Fri, 20 Oct 2023 11:38:18 +0200 (CEST) Received: from esa4.hc1455-7.c3s2.iphmx.com (esa4.hc1455-7.c3s2.iphmx.com [68.232.139.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 0755E1000CB4 for ; Fri, 20 Oct 2023 11:38:16 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="137027344" X-IronPort-AV: E=Sophos;i="6.03,238,1694703600"; d="scan'208";a="137027344" Received: from unknown (HELO yto-r1.gw.nic.fujitsu.com) ([218.44.52.217]) by esa4.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 18:38:14 +0900 Received: from yto-m3.gw.nic.fujitsu.com (yto-nat-yto-m3.gw.nic.fujitsu.com [192.168.83.66]) by yto-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id 2C166D9DA9 for ; Fri, 20 Oct 2023 18:38:12 +0900 (JST) Received: from kws-ab3.gw.nic.fujitsu.com (kws-ab3.gw.nic.fujitsu.com [192.51.206.21]) by yto-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id 6568EF943 for ; Fri, 20 Oct 2023 18:38:11 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab3.gw.nic.fujitsu.com (Postfix) with ESMTP id E047820050193 for ; Fri, 20 Oct 2023 18:38:10 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.215.131]) by edo.cn.fujitsu.com (Postfix) with ESMTP id 8BCB21A0071; Fri, 20 Oct 2023 17:38:10 +0800 (CST) From: Yang Xu To: ltp@lists.linux.it Date: Fri, 20 Oct 2023 17:37:56 +0800 Message-Id: <1697794677-14892-1-git-send-email-xuyang2018.jy@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-27946.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-27946.006 X-TMASE-Result: 10--15.150100-10.000000 X-TMASE-MatchedRID: 3UHCnQ5jp7VnQCQAG5wcwTU9EK4+H8U19LMB0hXFSejAuQ0xDMaXkH4q tYI9sRE/w/kunvvd5s3Zvor6qg8CpUeXEeTXarDS7TovvZPhLcB1zSnwpu89bYAjsy+r+wvn2JH TTqNG6YpUzndbBQKrMojqLBCPdE946tgv1S39I0ZdnSd5JiRhlhB0ENZnw1vtXZmAtjip/rFcfd b7nucZ+RBPzZigGafMMVObZjZKQv6+yza4Wm1Q8e9VsdrlGzy3xMZq+YajS9Y+LVWZNfdejlXKJ 0T+EEPnvaNqd3Y9EXzOFDEYTSdNXrCJvLOmyWTFyCvBIqsqjUf+wG4sVAq2B6L0Xt/8vZHxqbs+ nJ/tFJFp66ZRoBRi30qGW42c0HkY4GDafdAMMvc5ZRbFNAl0jxyzHcgfiyrczAdJD7JeNMPHLN3 eLMgRKbapfeJhlwtKCoeEzyhqd5TIY6JevWs4vlhRyidsElYkyqyllX6UJIs1Y73PdzvXZDavMp at2LKSQA5yz5TdUE0dNHqsRxGuHm37Tua3mPR3dXu122+iJtpa9oWcYwi86iy30dOC2b5HaDh/J dlmcfAR+1MbcnIby4Yj9NPA4+LIHxPMjOKY7A8WeMpVNhsMwMRB0bsfrpPIfiAqrjYtFiS1MduF WAZn2MwsY34gWL/SYBUf+9u58Btf2kAmEVJuBX7cGd19dSFd X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Virus-Scanned: clamav-milter 1.0.1 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH v2 1/2] syscalls/symlink02: 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: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The original test didn't produce any output results. Use tst_macro to enable test to produce output results. Signed-off-by: Yang Xu --- testcases/kernel/syscalls/symlink/symlink02.c | 218 ++---------------- 1 file changed, 25 insertions(+), 193 deletions(-) diff --git a/testcases/kernel/syscalls/symlink/symlink02.c b/testcases/kernel/syscalls/symlink/symlink02.c index c18db2b37..c152bb2b7 100644 --- a/testcases/kernel/syscalls/symlink/symlink02.c +++ b/testcases/kernel/syscalls/symlink/symlink02.c @@ -1,208 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. - * - * 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/ - * + * Copyright (c) Linux Test Project, 2003-2023 + * Author: William Roske */ -/* $Id: symlink02.c,v 1.6 2009/08/28 14:17:14 vapier Exp $ */ -/********************************************************** - * - * OS Test - Silicon Graphics, Inc. - * - * TEST IDENTIFIER : symlink02 - * - * EXECUTED BY : anyone - * - * TEST TITLE : Basic test for symlink(2) - * - * PARENT DOCUMENT : usctpl01 - * - * TEST CASE TOTAL : 1 - * - * WALL CLOCK TIME : 1 - * - * CPU TYPES : ALL - * - * AUTHOR : William Roske - * - * CO-PILOT : Dave Fenner - * - * DATE STARTED : 03/30/92 - * - * INITIAL RELEASE : UNICOS 7.0 - * - * TEST CASES - * - * 1.) symlink(2) returns...(See Description) - * - * INPUT SPECIFICATIONS - * The standard options for system call tests are accepted. - * (See the parse_opts(3) man page). - * - * OUTPUT SPECIFICATIONS - *$ - * DURATION - * Terminates - with frequency and infinite modes. - * - * SIGNALS - * Uses SIGUSR1 to pause before test if option set. - * (See the parse_opts(3) man page). - * - * RESOURCES - * None - * - * ENVIRONMENTAL NEEDS - * No run-time environmental needs. - * - * SPECIAL PROCEDURAL REQUIREMENTS - * None - * - * INTERCASE DEPENDENCIES - * None - * - * DETAILED DESCRIPTION - * This is a Phase I test for the symlink(2) system call. It is intended - * to provide a limited exposure of the system call, for now. It - * should/will be extended when full functional tests are written for - * symlink(2). - * - * Setup: - * Setup signal handling. - * Pause for SIGUSR1 if option specified. - * - * Test: - * Loop if the proper options are given. - * Execute system call - * Check return code, if system call failed (return=-1) - * Log the errno and Issue a FAIL message. - * Otherwise, Issue a PASS message. - * - * Cleanup: - * Print errno log and/or timing stats if options given - * - * - *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/ -#include -#include -#include -#include -#include -#include "test.h" -#include "safe_macros.h" - -void setup(); -void cleanup(); +/*\ + * [Description] + * + * Check the basic functionality of the symlink() system call. + */ -char *TCID = "symlink02"; -int TST_TOTAL = 1; +#include "tst_test.h" -char fname[255], symlnk[255]; -int fd; +static char *fname, *symlnk; -int main(int ac, char **av) +static void verify_symlink(void) { - int lc; - - /*************************************************************** - * parse standard options - ***************************************************************/ - tst_parse_opts(ac, av, NULL, NULL); - - /*************************************************************** - * perform global setup for test - ***************************************************************/ - setup(); - - /*************************************************************** - * check looping state if -c option given - ***************************************************************/ - for (lc = 0; TEST_LOOPING(lc); lc++) { - - tst_count = 0; - - /* - * Call symlink(2) - */ - TEST(symlink(fname, symlnk)); - - /* check return code */ - if (TEST_RETURN == -1) { - tst_resm(TFAIL, "symlink(%s, %s) Failed, errno=%d : %s", - fname, symlnk, TEST_ERRNO, - strerror(TEST_ERRNO)); - } else { - SAFE_UNLINK(cleanup, symlnk); - } - } - - /*************************************************************** - * cleanup and exit - ***************************************************************/ - cleanup(); - tst_exit(); + TST_EXP_POSITIVE(symlink(fname, symlnk), "symlink(%s, %s)", + fname, symlnk); + if (TST_RET == -1) + tst_res(TFAIL, "symlink(%s, %s) Failed", fname, symlnk); + else + SAFE_UNLINK(symlnk); } -/*************************************************************** - * setup() - performs all ONE TIME setup for this test. - ***************************************************************/ -void setup(void) +static void setup(void) { + fname = tst_aprintf("tfile_%d", getpid()); - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - TEST_PAUSE; - - tst_tmpdir(); - - sprintf(fname, "tfile_%d", getpid()); - if ((fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT,0700) Failed, errno=%d : %s", - fname, errno, strerror(errno)); - } - - if (close(fd) == -1) { - tst_resm(TWARN, "close(%s) Failed, errno=%d : %s", - fname, errno, strerror(errno)); - } - sprintf(symlnk, "st_%d", getpid()); + symlnk = tst_aprintf("st_%d", getpid()); } -/*************************************************************** - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - ***************************************************************/ -void cleanup(void) -{ - - tst_rmdir(); - -} +static struct tst_test test = { + .needs_tmpdir = 1, + .setup = setup, + .test_all = verify_symlink, +}; From patchwork Fri Oct 20 09:37:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yang Xu \\(Fujitsu\\)" X-Patchwork-Id: 1852402 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SBffL1BWbz23jq for ; Fri, 20 Oct 2023 20:38:34 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 0DC043CEEA1 for ; Fri, 20 Oct 2023 11:38:32 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id AE8AB3C9A2B for ; Fri, 20 Oct 2023 11:38:17 +0200 (CEST) Received: from esa11.hc1455-7.c3s2.iphmx.com (esa11.hc1455-7.c3s2.iphmx.com [207.54.90.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 0C41120650E for ; Fri, 20 Oct 2023 11:38:16 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="116305850" X-IronPort-AV: E=Sophos;i="6.03,238,1694703600"; d="scan'208";a="116305850" Received: from unknown (HELO yto-r2.gw.nic.fujitsu.com) ([218.44.52.218]) by esa11.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 18:38:15 +0900 Received: from yto-m1.gw.nic.fujitsu.com (yto-nat-yto-m1.gw.nic.fujitsu.com [192.168.83.64]) by yto-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 45ECDD6187 for ; Fri, 20 Oct 2023 18:38:12 +0900 (JST) Received: from kws-ab4.gw.nic.fujitsu.com (kws-ab4.gw.nic.fujitsu.com [192.51.206.22]) by yto-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 7F75ECF7E8 for ; Fri, 20 Oct 2023 18:38:11 +0900 (JST) Received: from edo.cn.fujitsu.com (edo.cn.fujitsu.com [10.167.33.5]) by kws-ab4.gw.nic.fujitsu.com (Postfix) with ESMTP id 17E89E5E55 for ; Fri, 20 Oct 2023 18:38:11 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.215.131]) by edo.cn.fujitsu.com (Postfix) with ESMTP id B780E1A0073; Fri, 20 Oct 2023 17:38:10 +0800 (CST) From: Yang Xu To: ltp@lists.linux.it Date: Fri, 20 Oct 2023 17:37:57 +0800 Message-Id: <1697794677-14892-2-git-send-email-xuyang2018.jy@fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1697794677-14892-1-git-send-email-xuyang2018.jy@fujitsu.com> References: <1697794677-14892-1-git-send-email-xuyang2018.jy@fujitsu.com> X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1417-9.0.0.1002-27946.006 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1417-9.0.1002-27946.006 X-TMASE-Result: 10--17.448700-10.000000 X-TMASE-MatchedRID: tGJ02YVcvxcRcrxK+AdK7zU9EK4+H8U1aZATGA5/BXhgPgeggVwCFpYv gWqjMEzaNYCBzzxsUnv/hDDq/XyZmS/7QU2czuUNA9lly13c/gFzNCdGumZsScSiwizsgluQiH6 Yv5yIUKludEHjsosnVDMuZ8ZjqIORfm5R+E2+crM5ZRbFNAl0jxRli5ttSPYMu3gEBpQvABUl/m i29q85l/29Pl68xfi0WS2NwPsUPtJZQ4rley4x/kz7FUUjXG1jl9q75JzWJRNujEcOZiInj5/bu mQx78u3oekUdArZ14HOyd98r1P+4fVACeiFsAcyEzEoOqAAVLM2hINq/IswlCkvFki4e3OUzPNl EtpUdaIQrkzWMsBTmoVjahLr+ZTJR+vpYbhOH1r4Zi3x/9WFO79cAlQW5YprrblmM/aFaC+Trr+ C1WNmxdVlIlxlHyS47pwlAnoEcLCPGYLjOKcfyoanR/CvYO8XsbIL/j/u56ryPC7FUFMmiJ7VNy 7+UW/9/I+yd0mcY0W310iilwWxWkIYiAJlkvRNngIgpj8eDcCbifj2/J/1cUp0ODI8GjvXKrauX d3MZDUD/dHyT/Xh7Q== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 X-Virus-Scanned: clamav-milter 1.0.1 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH v2 2/2] Refactor and merge symlink04/05 using new LTP 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: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" symlink04 and symlink05 has been merged together, testing the results of symlink(2) for the existence or non-existence of a file Signed-off-by: Yang Xu Reviewed-by: Petr Vorel --- runtest/syscalls | 1 - testcases/kernel/syscalls/symlink/.gitignore | 1 - testcases/kernel/syscalls/symlink/symlink04.c | 218 ++++-------------- testcases/kernel/syscalls/symlink/symlink05.c | 180 --------------- 4 files changed, 49 insertions(+), 351 deletions(-) delete mode 100644 testcases/kernel/syscalls/symlink/symlink05.c diff --git a/runtest/syscalls b/runtest/syscalls index 1851752cf..7e2f793f6 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1559,7 +1559,6 @@ symlink01 symlink01 symlink02 symlink02 symlink03 symlink03 symlink04 symlink04 -symlink05 symlink05 #symlinkat test cases symlinkat01 symlinkat01 diff --git a/testcases/kernel/syscalls/symlink/.gitignore b/testcases/kernel/syscalls/symlink/.gitignore index d1497e680..6ea587ff3 100644 --- a/testcases/kernel/syscalls/symlink/.gitignore +++ b/testcases/kernel/syscalls/symlink/.gitignore @@ -2,4 +2,3 @@ /symlink02 /symlink03 /symlink04 -/symlink05 diff --git a/testcases/kernel/syscalls/symlink/symlink04.c b/testcases/kernel/syscalls/symlink/symlink04.c index 2190b3b1b..5022d4f13 100644 --- a/testcases/kernel/syscalls/symlink/symlink04.c +++ b/testcases/kernel/syscalls/symlink/symlink04.c @@ -1,193 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Copyright (c) International Business Machines Corp., 2001 + * Copyright (c) Linux Test Project, 2003-2023 + * Author: 07/2001 John George */ -/* - * Test Name : symlink04 - * - * Test Description : - * Verify that, symlink will succeed to creat a symbolic link of an existing - * object name path. - * - * Expected Result: - * symlink() should return value 0 on success and symbolic link of an - * existing object should be created. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create temporary directory. - * Pause for SIGUSR1 if option specified. - * - * Test: - * Loop if the proper options are given. - * Execute system call - * Check return code, if system call failed (return=-1) - * Log the errno and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * symlink04 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions: - * None. +/*\ + * [Description] * + * Check that a symbolic link may point to an existing file or + * to a nonexistent one. */ +#include "tst_test.h" +#include #include -#include -#include -#include -#include -#include -#include -#include "test.h" -#include "safe_macros.h" -#define TESTFILE "testfile" -#define SYMFILE "slink_file" -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH +#define TESTFILE "testfile" +#define NONFILE "noexistfile" +#define SYMFILE "slink_file" -char *TCID = "symlink04"; -int TST_TOTAL = 1; +static int fd; +static char *testfile; +static char *nonfile; -void setup(); -void cleanup(); +static struct tcase { + char **srcfile; +} tcases[] = { + {&testfile}, + {&nonfile}, +}; -int main(int ac, char **av) +static void setup(void) { - struct stat stat_buf; /* stat structure buffer */ - int lc; - - tst_parse_opts(ac, av, NULL, NULL); - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - - tst_count = 0; - - /* - * Call symlink(2) to create a symlink of - * testfile. - */ - TEST(symlink(TESTFILE, SYMFILE)); - - if (TEST_RETURN == -1) { - tst_resm(TFAIL, "symlink(%s, %s) Failed, errno=%d : %s", - TESTFILE, SYMFILE, TEST_ERRNO, - strerror(TEST_ERRNO)); - } else { - /* - * Get the symlink file status information - * using lstat(2). - */ - if (lstat(SYMFILE, &stat_buf) < 0) { - tst_brkm(TFAIL, cleanup, "lstat(2) of " - "%s failed, error:%d", SYMFILE, - errno); - } - - /* Check if the st_mode contains a link */ - if (!S_ISLNK(stat_buf.st_mode)) { - tst_resm(TFAIL, - "symlink of %s doesn't exist", - TESTFILE); - } else { - tst_resm(TPASS, "symlink(%s, %s) " - "functionality successful", - TESTFILE, SYMFILE); - } - } - - /* Unlink the symlink file for next loop */ - SAFE_UNLINK(cleanup, SYMFILE); - tst_count++; /* incr TEST_LOOP counter */ - } - - cleanup(); - tst_exit(); - + fd = SAFE_OPEN(TESTFILE, O_RDWR | O_CREAT, 0644); } -/* - * void - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - * Create a test file under temporary directory and close it - */ -void setup(void) +static void verify_symlink(unsigned int i) { - int fd; /* file handle for testfile */ + struct tcase *tc = &tcases[i]; - tst_sig(NOFORK, DEF_HANDLER, cleanup); + struct stat stat_buf; - /* Pause if that option was specified - * TEST_PAUSE contains the code to fork the test with the -i option. - * You want to make sure you do this before you create your temporary - * directory. - */ - TEST_PAUSE; + TST_EXP_PASS(symlink(*tc->srcfile, SYMFILE), "symlink(%s, %s)", + *tc->srcfile, SYMFILE); - tst_tmpdir(); + SAFE_LSTAT(SYMFILE, &stat_buf); - /* creat/open a testfile */ - if ((fd = open(TESTFILE, O_RDWR | O_CREAT, FILE_MODE)) == -1) { - tst_brkm(TBROK, cleanup, - "open(%s, O_RDWR|O_CREAT, %#o) Failed, errno=%d : %s", - TESTFILE, FILE_MODE, errno, strerror(errno)); - } + if (!S_ISLNK(stat_buf.st_mode)) + tst_res(TFAIL, "symlink of %s doesn't exist", *tc->srcfile); - /* Close the temporary file created above */ - if (close(fd) == -1) { - tst_resm(TBROK, "close(%s) Failed, errno=%d : %s", - TESTFILE, errno, strerror(errno)); - } + SAFE_UNLINK(SYMFILE); } -/* - * void - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the test directory and testfile created in the setup. - */ -void cleanup(void) +static void cleanup(void) { - - tst_rmdir(); - + if (fd > -1) + SAFE_CLOSE(fd); } + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), + .setup = setup, + .cleanup = cleanup, + .test = verify_symlink, + .bufs = (struct tst_buffers []) { + {&testfile, .str = TESTFILE}, + {&nonfile, .str = NONFILE}, + {}, + }, + .needs_tmpdir = 1, +}; diff --git a/testcases/kernel/syscalls/symlink/symlink05.c b/testcases/kernel/syscalls/symlink/symlink05.c deleted file mode 100644 index 83b151f5d..000000000 --- a/testcases/kernel/syscalls/symlink/symlink05.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * - * Copyright (c) International Business Machines Corp., 2001 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* - * Test Name : symlink05 - * - * Test Description : - * Verify that, symlink will succeed to creat a symbolic link of an - * non-existing object name path. - * - * Expected Result: - * symlink() should return value 0 on success and symlink of an - * non-existing object should be created. - * - * Algorithm: - * Setup: - * Setup signal handling. - * Create temporary directory. - * Pause for SIGUSR1 if option specified. - * - * Test: - * Loop if the proper options are given. - * Execute system call - * Check return code, if system call failed (return=-1) - * Log the errno and Issue a FAIL message. - * Otherwise, - * Verify the Functionality of system call - * if successful, - * Issue Functionality-Pass message. - * Otherwise, - * Issue Functionality-Fail message. - * Cleanup: - * Print errno log and/or timing stats if options given - * Delete the temporary directory created. - * - * Usage: - * symlink05 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -f : Turn off functionality Testing. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. - * - * History - * 07/2001 John George - * -Ported - * - * Restrictions: - * This test should be run by 'non-super-user' only. - * - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "test.h" -#include "safe_macros.h" - -#define TESTFILE "testfile" -#define SYMFILE "slink_file" - -char *TCID = "symlink05"; -int TST_TOTAL = 1; - -void setup(); -void cleanup(); - -int main(int ac, char **av) -{ - struct stat stat_buf; /* stat structure buffer */ - int lc; - - tst_parse_opts(ac, av, NULL, NULL); - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - - tst_count = 0; - - /* - * Call symlink(2) to create a symlink of - * an non-existing testfile. - */ - TEST(symlink(TESTFILE, SYMFILE)); - - if (TEST_RETURN == -1) { - tst_resm(TFAIL, - "symlink(%s, %s) Failed, errno=%d : %s", - TESTFILE, SYMFILE, TEST_ERRNO, - strerror(TEST_ERRNO)); - } else { - /* - * Get the symlink file status information - * using lstat(2). - */ - if (lstat(SYMFILE, &stat_buf) < 0) { - tst_brkm(TFAIL, cleanup, "lstat(2) of " - "%s failed, error:%d", - SYMFILE, errno); - } - - /* Check if the st_mode contains a link */ - if (!S_ISLNK(stat_buf.st_mode)) { - tst_resm(TFAIL, - "symlink of %s doesn't exist", - TESTFILE); - } else { - tst_resm(TPASS, "symlink(%s, %s) " - "functionality successful", - TESTFILE, SYMFILE); - } - } - - /* Unlink the symlink file for next loop */ - SAFE_UNLINK(cleanup, SYMFILE); - tst_count++; /* incr TEST_LOOP counter */ - } - - cleanup(); - tst_exit(); - -} - -/* - * void - * setup() - performs all ONE TIME setup for this test. - * Create a temporary directory and change directory to it. - */ -void setup(void) -{ - - tst_sig(NOFORK, DEF_HANDLER, cleanup); - - /* Pause if that option was specified - * TEST_PAUSE contains the code to fork the test with the -i option. - * You want to make sure you do this before you create your temporary - * directory. - */ - TEST_PAUSE; - - tst_tmpdir(); - -} - -/* - * void - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - * Remove the temporary directory created in the setup. - */ -void cleanup(void) -{ - - tst_rmdir(); - -}