From patchwork Mon Mar 25 23:20:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandeep Patil X-Patchwork-Id: 161139 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp4541038jan; Mon, 25 Mar 2019 16:20:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCFFeV39uApsLSkT0csrR+TJEj9AubsKmoCscf59/CdXwr1wf5g8tw9/kf6oeO38QYXAar X-Received: by 2002:a5d:428c:: with SMTP id k12mr17950745wrq.279.1553556040368; Mon, 25 Mar 2019 16:20:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553556040; cv=none; d=google.com; s=arc-20160816; b=jvtWpfoMe/CLdIjxJEFWBIL8ZrY7Mu0lsJPUHyNFXDKOelXDNmSRaueyTTyKFKrMrJ NNN30fJjhRpxE8uoiMeWVNVLt1sPzWWB9Y/d5919iYZBpIfpr+Nlpt2CTCcsFO2q4U2J ipz3Q4gO25w9211UuDuTF4nxrNxZjnKWMAK3LcbKHnttbCRJD84UOURe+lDKDWzLteiD zl7Ki0Ob/VpMjXt2AroQDagSsBSoYrY21ZEVtiLFzpRs4DSbSpKbPS6AoQvmv38El4g6 +WxuXXXtAfuTsuWkth8sFPCz/Z5efIQn79Zz4uJIN22CiB1jx1GR7HHWz/Ir2Xu0rKFe GgNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:delivered-to; bh=5LkXA2YX6MJVwdd7yEsKzrYcAHD6nlRTARpOl6v3LkY=; b=DKLPBsiUzhjKCiUSE3l1OpFc103wye1IZs/+UISLs6Zl2wrz2b3jxhkG8rWXQHGZoo ol8nw5hpG/CHSgq7CAlt+MmsDGuc+qyyINj/iOBgkraAZi6r6+iyp0apOwoKq6cjFawa OowTrv+63uT3nJFkpK1J1drI2yEfMzN5eGyfVOaec8+U03BM87QV0spid6DQek7pmR1y b4lpYVE/8MNWRkWs4eRKYUA349WlnEWAM38WT+NCnt9laFW+iUNp6XczzjTwe/LvNVGW 2C74eqJADj3/T2G19P2vksVIlA3rN9r5rfjd5xAGrePHdLWQTzg6KMLLcuEufCLFiIS+ Hw4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@android.com header.s=20161025 header.b=UpbjBWnG; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=android.com Return-Path: Received: from picard.linux.it (picard.linux.it. [2001:1418:10:5::2]) by mx.google.com with ESMTPS id o17si10426887wmc.65.2019.03.25.16.20.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Mar 2019 16:20:40 -0700 (PDT) Received-SPF: pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) client-ip=2001:1418:10:5::2; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@android.com header.s=20161025 header.b=UpbjBWnG; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=android.com Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E8856294AF6 for ; Tue, 26 Mar 2019 00:20:39 +0100 (CET) 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 [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id 7DF42294AE9 for ; Tue, 26 Mar 2019 00:20:34 +0100 (CET) Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 8DA96601178 for ; Tue, 26 Mar 2019 00:20:33 +0100 (CET) Received: by mail-pl1-x641.google.com with SMTP id bf11so673936plb.12 for ; Mon, 25 Mar 2019 16:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jUB81bAjBhZVsQFDgewWPh11JtH7DF3/lwQ3spL+u+k=; b=UpbjBWnGB0hjpeFbDoOhEp1z3IdG/0taZ9fhjA5dV0K0RDAmafyfqY+2Re1pqYoXwE KvESThR+hnuQFh0UIG6ijSCrPCU6pMHXR87aZe+NDIaquOfQTa+EynTlAvZoUirsg/VV 4yxnu4McpgOVdpg9wzXHspU7WP1pdfH7+JJ22J3XrDporw5Rx0xup8aMqWm7j2qDkEP/ tpSbZcDC3Ho/nE0Bl18fSMgQrY4xYh9kgKMRViZXKm0DGb0k6J9a8ikkyyKwIp3YRoyU zfnuMO7LeqWscJsC8B0imbekT0S7NcBx6HyxIBcM6FQIxq8Dl3IV5i2hUOjKFs/XdIAm d3qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jUB81bAjBhZVsQFDgewWPh11JtH7DF3/lwQ3spL+u+k=; b=Z/ABuNTiMCj3alpUEtPjMvsRRbmiTrnVprWzBgC4e+hdfI0hASbuMsALZWtyhIpblA IE8rqEi8KlMuMk8DiIlaXYc+sEMkUuHAft2/58hi+xpbfNmjEsYkpyPU8G698rcw5Srb vSGX/J9WZOzWLc4JAvOenGZovVb1OSAU9jnMmeyhPwJL5jokT2gU847BADQ9KuthvKg4 3Zai5U2PfUOH3Cjgxl2Q5zvBhFG/Zx4csUmHpYrwzoNBYmiXH2gki7WxstmbIsZbIQHY fieOXHoJIGBQxgEp4vjjtP936jInlkXmS1kvWrCp0QJ8oDcWhQH/aJ2WvNffi0QxjUCD m7Wg== X-Gm-Message-State: APjAAAVu0CoeBM8pBTOytUo9zo7B9gjZE0rKsrRw0JOMTLdayUOQdLNk B5lZwed67zCL7HyifdBrP9Bw7Qp9IU/0UQ== X-Received: by 2002:a17:902:f209:: with SMTP id gn9mr28085587plb.50.1553556031925; Mon, 25 Mar 2019 16:20:31 -0700 (PDT) Received: from sspatil-glaptop2.roam.corp.google.com ([175.223.31.125]) by smtp.gmail.com with ESMTPSA id 17sm24671432pgz.52.2019.03.25.16.20.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Mar 2019 16:20:31 -0700 (PDT) From: Sandeep Patil To: ltp@lists.linux.it Date: Mon, 25 Mar 2019 16:20:09 -0700 Message-Id: <20190325232012.67123-2-sspatil@android.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog In-Reply-To: <20190325232012.67123-1-sspatil@android.com> References: <20190325232012.67123-1-sspatil@android.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 Cc: chrubis@suze.cz, kernel-team@android.com Subject: [LTP] [RFC PATCH 1/4] syscalls/abort01: convert to new library 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: , Errors-To: ltp-bounces+patch=linaro.org@lists.linux.it Sender: "ltp" From: Sandeep Patil In the process, drop checks for UCLINUX and WCOREDUMP. Make the test simple and remove all the logic to detect if a system is "in stress". Signed-off-by: Sandeep Patil --- testcases/kernel/syscalls/abort/abort01.c | 171 ++++++---------------- 1 file changed, 48 insertions(+), 123 deletions(-) diff --git a/testcases/kernel/syscalls/abort/abort01.c b/testcases/kernel/syscalls/abort/abort01.c index 3a5dff585..ac5ddb140 100644 --- a/testcases/kernel/syscalls/abort/abort01.c +++ b/testcases/kernel/syscalls/abort/abort01.c @@ -1,25 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + /* * Copyright (c) International Business Machines Corp., 2002 * 01/02/2003 Port to LTP avenkat@us.ibm.com * 11/11/2002: Ported to LTP Suite by Ananda * 06/30/2001 Port to Linux nsharoff@us.ibm.com * - * 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 - */ - - /* ALGORITHM + * ALGORITHM * Fork child. Have child abort, check return status. * * RESTRICTIONS @@ -35,132 +22,70 @@ #include #include -#include "test.h" -#include "safe_macros.h" +#include "tst_test.h" -#define NUM 3 - -char *TCID = "abort01"; -int TST_TOTAL = 1; - -static void setup(void); -static void cleanup(void); -static void do_child(); -static int instress(); +static void do_child(void) +{ + abort(); + fprintf(stderr, "\tchild - abort failed.\n"); + exit(1); +} -int main(int argc, char *argv[]) +void verify_abort(unsigned int nr) { - register int i; - int status, count, child, kidpid; + int i; + int status, child, kidpid; int sig, ex; - -#ifdef WCOREDUMP int core; - core = 0; -#endif - ex = sig = 0; - - tst_parse_opts(argc, argv, NULL, NULL); -#ifdef UCLINUX - maybe_run_child(&do_child, ""); -#endif - - setup(); - - for (i = 0; i < NUM; i++) { - kidpid = FORK_OR_VFORK(); - if (kidpid == 0) { -#ifdef UCLINUX - if (self_exec(argv[0], "")) { - if (!instress()) { - perror("fork failed"); - exit(1); - } - } -#else - do_child(); -#endif - } - if (kidpid < 0) - if (!instress()) - tst_brkm(TBROK | TERRNO, cleanup, - "fork failed"); - count = 0; - while ((child = wait(&status)) > 0) - count++; - if (count != 1) { - tst_brkm(TBROK, cleanup, - "wrong # children waited on; got %d, expected 1", - count); - } - if (WIFSIGNALED(status)) { + core = ex = sig = 0; -#ifdef WCOREDUMP - core = WCOREDUMP(status); -#endif - sig = WTERMSIG(status); + kidpid = SAFE_FORK(); + if (kidpid == 0) + do_child(); - } - if (WIFEXITED(status)) - ex = WEXITSTATUS(status); + child = SAFE_WAIT(&status); -#ifdef WCOREDUMP - if (core == 0) { - tst_brkm(TFAIL, cleanup, - "Child did not dump core; exit code = %d, " - "signal = %d", ex, sig); - } else if (core != -1) { - tst_resm(TPASS, "abort dumped core"); - } -#endif - if (sig == SIGIOT) { - tst_resm(TPASS, "abort raised SIGIOT"); - } else { - tst_brkm(TFAIL, cleanup, - "Child did not raise SIGIOT (%d); exit code = %d, " - "signal = %d", SIGIOT, ex, sig); - } + if (WIFSIGNALED(status)) { + core = WCOREDUMP(status); + sig = WTERMSIG(status); } - cleanup(); - tst_exit(); + if (WIFEXITED(status)) + ex = WEXITSTATUS(status); + + if (core == 0) + tst_brk(TFAIL, + "Missing core dump; exit(%d), signal(%d)", + ex, sig); + else if (core != -1) + tst_res(TPASS, "abort() dumped core"); + + if (sig == SIGIOT) + tst_res(TPASS, "abort() raised SIGIOT"); + else + tst_brk(TFAIL, + "Unexpected signal(%d), expected SIGIOT(%d)", + sig, SIGIOT); } -/* 1024 GNU blocks */ -#define MIN_RLIMIT_CORE (1024 * 1024) - static void setup(void) { +#define MIN_RLIMIT_CORE (1024 * 1024) struct rlimit rlim; - SAFE_GETRLIMIT(NULL, RLIMIT_CORE, &rlim); - + /* make sure we get core dumps */ + SAFE_GETRLIMIT(RLIMIT_CORE, &rlim); if (rlim.rlim_cur < MIN_RLIMIT_CORE) { - tst_resm(TINFO, "Adjusting RLIMIT_CORE to %i", MIN_RLIMIT_CORE); rlim.rlim_cur = MIN_RLIMIT_CORE; - SAFE_SETRLIMIT(NULL, RLIMIT_CORE, &rlim); + SAFE_SETRLIMIT(RLIMIT_CORE, &rlim); } - - tst_tmpdir(); } -static void cleanup(void) -{ - unlink("core"); - tst_rmdir(); -} - -static void do_child(void) -{ - abort(); - fprintf(stderr, "\tchild - abort failed.\n"); - exit(1); -} - -static int instress(void) -{ - tst_resm(TINFO, - "System resources may be too low; fork(), select() etc are likely to fail."); - return 1; -} +static struct tst_test test = { + .tcnt = 3, + .needs_tmpdir = 1, + .forks_child = 1, + .setup = setup, + .test = verify_abort, +};