From patchwork Wed Aug 8 05:54:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 954792 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41lgZz0c6Dz9s4c for ; Wed, 8 Aug 2018 15:55:06 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 14D9A3E77D7 for ; Wed, 8 Aug 2018 07:55:03 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) by picard.linux.it (Postfix) with ESMTP id BE1543E780C for ; Wed, 8 Aug 2018 07:54:49 +0200 (CEST) Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id C149D600695 for ; Wed, 8 Aug 2018 07:54:48 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8020E402316D for ; Wed, 8 Aug 2018 05:54:47 +0000 (UTC) Received: from dhcp-12-102.nay.redhat.com (dhcp-12-102.nay.redhat.com [10.66.12.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A99D10075DA for ; Wed, 8 Aug 2018 05:54:46 +0000 (UTC) From: Li Wang To: ltp@lists.linux.it Date: Wed, 8 Aug 2018 13:54:33 +0800 Message-Id: <20180808055434.26293-6-liwang@redhat.com> In-Reply-To: <20180808055434.26293-1-liwang@redhat.com> References: <20180808055434.26293-1-liwang@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 08 Aug 2018 05:54:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 08 Aug 2018 05:54:47 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'liwang@redhat.com' RCPT:'' X-Virus-Scanned: clamav-milter 0.99.2 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH 5/6] execvp: rewrite to newlib X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 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" Signed-off-by: Li Wang --- testcases/kernel/syscalls/execvp/Makefile | 14 ++-- testcases/kernel/syscalls/execvp/execvp01.c | 83 ++++++++--------------- testcases/kernel/syscalls/execvp/execvp01_child.c | 47 ++++++------- 3 files changed, 55 insertions(+), 89 deletions(-) diff --git a/testcases/kernel/syscalls/execvp/Makefile b/testcases/kernel/syscalls/execvp/Makefile index bd617d8..a0e5f0f 100644 --- a/testcases/kernel/syscalls/execvp/Makefile +++ b/testcases/kernel/syscalls/execvp/Makefile @@ -1,19 +1,19 @@ # +# Copyright (c) Linux Test Project, 2018 # Copyright (c) International Business Machines Corp., 2001 # -# This program is free software; you can redistribute it and/or modify +# 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 +# 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. +# 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 St, Fifth Floor, Boston, MA 02110-1301 USA +# along with this program. If not, see . # top_srcdir ?= ../../../.. diff --git a/testcases/kernel/syscalls/execvp/execvp01.c b/testcases/kernel/syscalls/execvp/execvp01.c index bdeb2cf..765495f 100644 --- a/testcases/kernel/syscalls/execvp/execvp01.c +++ b/testcases/kernel/syscalls/execvp/execvp01.c @@ -1,38 +1,25 @@ /* + * Copyright (c) 2018 Linux Test Project + * Copyright (C) 2015 Cyril Hrubis * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved. * AUTHOR : William Roske * CO-PILOT : Dave Fenner * DATE STARTED : 06/01/02 - * Copyright (C) 2015 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. + * 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. * - * 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. + * 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. * - * 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/ + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + #include #include #include @@ -40,42 +27,26 @@ #include #include -#include "test.h" +#include "tst_test.h" -static void setup(void); - -char *TCID = "execvp01"; -int TST_TOTAL = 1; - -int main(int ac, char **av) +static void verify_execvp(void) { - int lc; pid_t pid; char *const args[] = {"execvp01_child", "canary", NULL}; - tst_parse_opts(ac, av, NULL, NULL); - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - switch (pid = FORK_OR_VFORK()) { - case 0: - execvp("execvp01_child", args); - tst_brkm(TFAIL | TERRNO, NULL, - "Failed to execute execvp01_child"); - case -1: - tst_brkm(TBROK | TERRNO, NULL, "fork failed"); - default: - tst_record_childstatus(NULL, pid); - } + pid = SAFE_FORK(); + if (pid == 0) { + execvp("execvp01_child", args); + tst_brk(TFAIL | TERRNO, + "Failed to execute execvp01_child"); } - tst_exit(); + SAFE_WAITPID(pid, NULL, 0); } -static void setup(void) -{ - tst_sig(FORK, DEF_HANDLER, NULL); - - TEST_PAUSE; -} +static struct tst_test test = { + .needs_root = 1, + .forks_child = 1, + .child_needs_reinit = 1, + .test_all = verify_execvp, +}; diff --git a/testcases/kernel/syscalls/execvp/execvp01_child.c b/testcases/kernel/syscalls/execvp/execvp01_child.c index 59587af..8a6e512 100644 --- a/testcases/kernel/syscalls/execvp/execvp01_child.c +++ b/testcases/kernel/syscalls/execvp/execvp01_child.c @@ -1,40 +1,35 @@ /* + * Copyright (c) 2018 Linux Test Project * Copyright (C) 2015 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 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 would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * 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. * - * 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. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#include "test.h" - -char *TCID = "execvp01_child"; +#define TST_NO_DEFAULT_MAIN +#include "tst_test.h" int main(int argc, char *argv[]) { + tst_reinit(); + if (argc != 2) - tst_brkm(TFAIL, NULL, "argc is %d, expected 2", argc); + tst_brk(TFAIL, "argc is %d, expected 2", argc); + + if (strcmp(argv[1], "canary")) + tst_brk(TFAIL, "argv[1] is %s, expected 'canary'", argv[1]); - if (strcmp(argv[1], "canary")) { - tst_brkm(TFAIL, NULL, "argv[1] is %s, expected 'canary'", - argv[1]); - } + tst_res(TPASS, "%s executed", argv[0]); - tst_resm(TPASS, "%s executed", argv[0]); - tst_exit(); + return 0; }