From patchwork Fri Mar 30 10:56:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinhui Huang X-Patchwork-Id: 893217 X-Patchwork-Delegate: petr.vorel@gmail.com 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=2001:1418:10:5::2; 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=cn.fujitsu.com Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40CJTp5J2Vz9s1r for ; Fri, 30 Mar 2018 21:57:02 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id EBD023E6B56 for ; Fri, 30 Mar 2018 12:56:59 +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 5CC573E6B1E for ; Fri, 30 Mar 2018 12:56:58 +0200 (CEST) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by in-6.smtp.seeweb.it (Postfix) with ESMTP id 2C63C1400066 for ; Fri, 30 Mar 2018 12:56:54 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="38350036" Received: from bogon (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 30 Mar 2018 18:56:45 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 8E8A5486A78C for ; Fri, 30 Mar 2018 18:56:47 +0800 (CST) Received: from localhost.localdomain (10.167.220.196) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 30 Mar 2018 18:56:45 +0800 From: Jinhui Huang To: Date: Fri, 30 Mar 2018 18:56:42 +0800 Message-ID: <1522407404-6877-1-git-send-email-huangjh.jy@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.167.220.196] X-yoursite-MailScanner-ID: 8E8A5486A78C.AEAA9 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: huangjh.jy@cn.fujitsu.com X-Spam-Status: No, score=-0.0 required=7.0 tests=T_RP_MATCHES_RCVD autolearn=disabled version=3.4.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH 1/3] syscalls/fchmod.h: Move common macros to fchmod.h 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+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Jinhui Huang Acked-by: Petr Vorel --- testcases/kernel/syscalls/fchmod/fchmod.h | 26 ++++++++++++++++++++++++++ testcases/kernel/syscalls/fchmod/fchmod02.c | 7 +------ testcases/kernel/syscalls/fchmod/fchmod03.c | 5 +---- testcases/kernel/syscalls/fchmod/fchmod04.c | 8 +------- testcases/kernel/syscalls/fchmod/fchmod05.c | 15 +++++++-------- testcases/kernel/syscalls/fchmod/fchmod07.c | 4 +--- 6 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 testcases/kernel/syscalls/fchmod/fchmod.h diff --git a/testcases/kernel/syscalls/fchmod/fchmod.h b/testcases/kernel/syscalls/fchmod/fchmod.h new file mode 100644 index 0000000..e52850d --- /dev/null +++ b/testcases/kernel/syscalls/fchmod/fchmod.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. + * Author: Jinhui huang + * + * 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. + * + * You should have received a copy of the GNU General Public License + * alone with this program. + */ + +#ifndef FCHMOD_H +#define FCHMOD_H + +#define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) +#define DIR_MODE (S_IRWXU | S_IRWXG | S_IRWXO) +#define PERMS 01777 +#define TESTFILE "testfile" +#define TESTDIR "testdir" + +#endif /* FCHMOD_H */ diff --git a/testcases/kernel/syscalls/fchmod/fchmod02.c b/testcases/kernel/syscalls/fchmod/fchmod02.c index ea2bdb4..aa3bab3 100644 --- a/testcases/kernel/syscalls/fchmod/fchmod02.c +++ b/testcases/kernel/syscalls/fchmod/fchmod02.c @@ -82,15 +82,10 @@ #include "test.h" #include "safe_macros.h" +#include "fchmod.h" #define LTPUSER "nobody" #define LTPGRP "users" -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#define PERMS 01777 /* - * Mode permissions of test file with sticky - * bit set. - */ -#define TESTFILE "testfile" int fd; /* file descriptor variable */ char *TCID = "fchmod02"; diff --git a/testcases/kernel/syscalls/fchmod/fchmod03.c b/testcases/kernel/syscalls/fchmod/fchmod03.c index 8d35bc1..a5824f3 100644 --- a/testcases/kernel/syscalls/fchmod/fchmod03.c +++ b/testcases/kernel/syscalls/fchmod/fchmod03.c @@ -81,10 +81,7 @@ #include "test.h" #include "safe_macros.h" - -#define FILE_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) -#define PERMS 01777 -#define TESTFILE "testfile" +#include "fchmod.h" int fd; /* file descriptor for test file */ char *TCID = "fchmod03"; diff --git a/testcases/kernel/syscalls/fchmod/fchmod04.c b/testcases/kernel/syscalls/fchmod/fchmod04.c index 27e3bdc..befaadb 100644 --- a/testcases/kernel/syscalls/fchmod/fchmod04.c +++ b/testcases/kernel/syscalls/fchmod/fchmod04.c @@ -81,13 +81,7 @@ #include "test.h" #include "safe_macros.h" - -#define DIR_MODE S_IRWXU | S_IRWXG | S_IRWXO -#define PERMS 01777 /* - * Mode permissions of test directory with - * sticky bit set. - */ -#define TESTDIR "testdir_4" +#include "fchmod.h" int fd; /* file descriptor for test directory */ char *TCID = "fchmod04"; diff --git a/testcases/kernel/syscalls/fchmod/fchmod05.c b/testcases/kernel/syscalls/fchmod/fchmod05.c index cdd3d07..0ab2023 100644 --- a/testcases/kernel/syscalls/fchmod/fchmod05.c +++ b/testcases/kernel/syscalls/fchmod/fchmod05.c @@ -88,10 +88,9 @@ #include "test.h" #include "safe_macros.h" +#include "fchmod.h" -#define MODE_RWX (S_IRWXU | S_IRWXG | S_IRWXO) -#define PERMS 043777 -#define TESTDIR "testdir" +#define PERMS_GID 043777 int fd; /* file descriptor for test directory */ char *TCID = "fchmod05"; @@ -119,7 +118,7 @@ int main(int ac, char **av) * to set setgid bit on TESTDIR. */ - TEST(fchmod(fd, PERMS)); + TEST(fchmod(fd, PERMS_GID)); if (TEST_RETURN == -1) { tst_resm(TFAIL, "fchmod(%d, %#o) Failed, errno=%d : %s", @@ -136,14 +135,14 @@ int main(int ac, char **av) TESTDIR, TEST_ERRNO); } dir_mode = stat_buf.st_mode; - if ((PERMS & ~S_ISGID) != dir_mode) { + if ((PERMS_GID & ~S_ISGID) != dir_mode) { tst_resm(TFAIL, "%s: Incorrect modes 0%03o, " "Expected 0%03o", - TESTDIR, dir_mode, PERMS & ~S_ISGID); + TESTDIR, dir_mode, PERMS_GID & ~S_ISGID); } else { tst_resm(TPASS, "Functionality of fchmod(%d, " "%#o) successful", fd, - PERMS & ~S_ISGID); + PERMS_GID & ~S_ISGID); } } @@ -188,7 +187,7 @@ void setup(void) * mode permissions and change the gid of test directory to that of * guest user. */ - SAFE_MKDIR(cleanup, TESTDIR, MODE_RWX); + SAFE_MKDIR(cleanup, TESTDIR, DIR_MODE); if (setgroups(1, &nobody_u->pw_gid) == -1) tst_brkm(TBROK, cleanup, diff --git a/testcases/kernel/syscalls/fchmod/fchmod07.c b/testcases/kernel/syscalls/fchmod/fchmod07.c index 6973555..d7fe41f 100644 --- a/testcases/kernel/syscalls/fchmod/fchmod07.c +++ b/testcases/kernel/syscalls/fchmod/fchmod07.c @@ -75,9 +75,7 @@ #include "test.h" #include "safe_macros.h" - -#define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#define TESTFILE "testfile" +#include "fchmod.h" int fd; /* file descriptor for testfile */ char *TCID = "fchmod07";