From patchwork Mon Sep 10 09:09:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clemens Famulla-Conrad X-Patchwork-Id: 967929 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=none (p=none dis=none) header.from=suse.de 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 ozlabs.org (Postfix) with ESMTPS id 4282LL6Zxjz9s3x for ; Mon, 10 Sep 2018 19:09:46 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D9CA73E6279 for ; Mon, 10 Sep 2018 11:09:43 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) by picard.linux.it (Postfix) with ESMTP id E67C33E625A for ; Mon, 10 Sep 2018 11:09:41 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 8637D14019D8 for ; Mon, 10 Sep 2018 11:09:39 +0200 (CEST) Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 95037AEA5 for ; Mon, 10 Sep 2018 09:09:39 +0000 (UTC) From: Clemens Famulla-Conrad To: ltp@lists.linux.it Date: Mon, 10 Sep 2018 11:09:33 +0200 Message-Id: <20180910090933.12080-1-cfamullaconrad@suse.de> X-Mailer: git-send-email 2.16.4 X-Virus-Scanned: clamav-milter 0.99.2 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH v1 1/5] setregid01: Convert 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: Clemens Famulla-Conrad --- testcases/kernel/syscalls/setregid/setregid01.c | 171 +++++------------------- 1 file changed, 36 insertions(+), 135 deletions(-) diff --git a/testcases/kernel/syscalls/setregid/setregid01.c b/testcases/kernel/syscalls/setregid/setregid01.c index 57a38eb62..120dff8a9 100644 --- a/testcases/kernel/syscalls/setregid/setregid01.c +++ b/testcases/kernel/syscalls/setregid/setregid01.c @@ -1,25 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 /* * 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: * @@ -37,128 +19,47 @@ * Testcase to test the basic functionality of setregid(2) systemm call. */ -#include -#include -#include -#include - -#include "test.h" -#include "compat_16.h" - -static void setup(void); - -TCID_DEFINE(setregid01); -int TST_TOTAL = 5; - -static gid_t gid, egid; /* current real and effective group id */ - -int main(int ac, char **av) +#include "tst_test.h" +#include "compat_tst_16.h" + +static gid_t gid, egid; /* current real and effective group id */ +static gid_t neg_one = -1; + +static struct tcase { + gid_t *arg1; + gid_t *arg2; + const char *msg; +} tcases[] = { + {&neg_one, &neg_one, "Dont change either real or effective gid" }, + {&neg_one, &egid, "Change effective to effective gid" }, + {&gid, &neg_one, "Change real to real gid" }, + {&neg_one, &gid, "Change effective to real gid" }, + {&gid, &gid, "Try to change real to current real" } +}; + +static void run(unsigned int n) { - int lc; - - tst_parse_opts(ac, av, NULL, NULL); - - setup(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - - tst_count = 0; - - /* - * TEST CASE: - * Dont change either real or effective gid - */ - gid = getgid(); - GID16_CHECK(gid, setregid, NULL); - - egid = getegid(); - GID16_CHECK(egid, setregid, NULL); + struct tcase *tc = &tcases[n]; - TEST(SETREGID(NULL, -1, -1)); + TEST(SETREGID(*tc->arg1, *tc->arg2)); - if (TEST_RETURN == -1) { - tst_resm(TFAIL, - "setregid - Dont change either real or effective gid failed, errno=%d : %s", - TEST_ERRNO, strerror(TEST_ERRNO)); - } else { - tst_resm(TPASS, - "setregid - Dont change either real or effective gid returned %ld", - TEST_RETURN); - } - - /* - * TEST CASE: - * change effective to effective gid - */ - - TEST(SETREGID(NULL, -1, egid)); - - if (TEST_RETURN == -1) { - tst_resm(TFAIL, - "setregid - change effective to effective gid failed, errno=%d : %s", - TEST_ERRNO, strerror(TEST_ERRNO)); - } else { - tst_resm(TPASS, - "setregid - change effective to effective gid returned %ld", - TEST_RETURN); - } - - /* - * TEST CASE: - * change real to real gid - */ - - TEST(SETREGID(NULL, gid, -1)); - - if (TEST_RETURN == -1) { - tst_resm(TFAIL, - "setregid - change real to real gid failed, errno=%d : %s", - TEST_ERRNO, strerror(TEST_ERRNO)); - } else { - tst_resm(TPASS, - "setregid - change real to real gid returned %ld", - TEST_RETURN); - } - - /* - * TEST CASE: - * change effective to real gid - */ - - TEST(SETREGID(NULL, -1, gid)); - - if (TEST_RETURN == -1) { - tst_resm(TFAIL, - "setregid - change effective to real gid failed, errno=%d : %s", - TEST_ERRNO, strerror(TEST_ERRNO)); - } else { - tst_resm(TPASS, - "setregid - change effective to real gid returned %ld", - TEST_RETURN); - } - - /* - * TEST CASE: - * try to change real to current real - */ - - TEST(SETREGID(NULL, gid, gid)); - - if (TEST_RETURN == -1) { - tst_resm(TFAIL | TTERRNO, "setregid failed"); - } else { - tst_resm(TPASS, "setregid return %ld", - TEST_RETURN); - } - - } - - tst_exit(); + if (TST_RET == -1) + tst_brk(TFAIL | TTERRNO, tc->msg); + else + tst_res(TPASS, tc->msg); } static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, NULL); + gid = getgid(); + GID16_CHECK(gid, setregid); - TEST_PAUSE; + egid = getegid(); + GID16_CHECK(egid, setregid); } + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), + .test = run, + .setup = setup, +};