From owner-svn-src-head@freebsd.org Fri Jun 15 15:36:11 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 429EF100FC90; Fri, 15 Jun 2018 15:36:11 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E910D7420E; Fri, 15 Jun 2018 15:36:10 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BEFD1194E7; Fri, 15 Jun 2018 15:36:10 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5FFaA80086307; Fri, 15 Jun 2018 15:36:10 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5FFaAWS086306; Fri, 15 Jun 2018 15:36:10 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201806151536.w5FFaAWS086306@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 15 Jun 2018 15:36:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335208 - head/tests/sys/audit X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: head/tests/sys/audit X-SVN-Commit-Revision: 335208 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jun 2018 15:36:11 -0000 Author: asomers Date: Fri Jun 15 15:36:10 2018 New Revision: 335208 URL: https://svnweb.freebsd.org/changeset/base/335208 Log: audit(4): improve formatting in tests/sys/audit/open.c [skip ci] Submitted by: aniketp MFC after: 2 weeks Sponsored by: Google, Inc. (GSoC 2018) Differential Revision: https://reviews.freebsd.org/D15797 Modified: head/tests/sys/audit/open.c Modified: head/tests/sys/audit/open.c ============================================================================== --- head/tests/sys/audit/open.c Fri Jun 15 15:32:02 2018 (r335207) +++ head/tests/sys/audit/open.c Fri Jun 15 15:36:10 2018 (r335208) @@ -60,97 +60,97 @@ static const char *errpath = "adirhasnoname/fileforaud /* * Define test-cases for success and failure modes of both open(2) and openat(2) */ -#define OPEN_AT_TC_DEFINE(mode, regex, flag, class) \ -ATF_TC_WITH_CLEANUP(open_ ## mode ## _success); \ -ATF_TC_HEAD(open_ ## mode ## _success, tc) \ -{ \ - atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful " \ - "open(2) call with flags = %s", #flag); \ -} \ -ATF_TC_BODY(open_ ## mode ## _success, tc) \ -{ \ - snprintf(extregex, sizeof(extregex), \ - "open.*%s.*fileforaudit.*return,success", regex); \ - /* File needs to exist for successful open(2) invocation */ \ - ATF_REQUIRE((filedesc = open(path, O_CREAT, o_mode)) != -1); \ - FILE *pipefd = setup(fds, class); \ - ATF_REQUIRE(syscall(SYS_open, path, flag) != -1); \ - check_audit(fds, extregex, pipefd); \ - close(filedesc); \ -} \ -ATF_TC_CLEANUP(open_ ## mode ## _success, tc) \ -{ \ - cleanup(); \ -} \ -ATF_TC_WITH_CLEANUP(open_ ## mode ## _failure); \ -ATF_TC_HEAD(open_ ## mode ## _failure, tc) \ -{ \ - atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful " \ - "open(2) call with flags = %s", #flag); \ -} \ -ATF_TC_BODY(open_ ## mode ## _failure, tc) \ -{ \ - snprintf(extregex, sizeof(extregex), \ - "open.*%s.*fileforaudit.*return,failure", regex); \ - FILE *pipefd = setup(fds, class); \ - ATF_REQUIRE_EQ(-1, syscall(SYS_open, errpath, flag)); \ - check_audit(fds, extregex, pipefd); \ -} \ -ATF_TC_CLEANUP(open_ ## mode ## _failure, tc) \ -{ \ - cleanup(); \ -} \ -ATF_TC_WITH_CLEANUP(openat_ ## mode ## _success); \ -ATF_TC_HEAD(openat_ ## mode ## _success, tc) \ -{ \ - atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful " \ - "openat(2) call with flags = %s", #flag); \ -} \ -ATF_TC_BODY(openat_ ## mode ## _success, tc) \ -{ \ - int filedesc2; \ - snprintf(extregex, sizeof(extregex), \ - "openat.*%s.*fileforaudit.*return,success", regex); \ - /* File needs to exist for successful openat(2) invocation */ \ - ATF_REQUIRE((filedesc = open(path, O_CREAT, o_mode)) != -1); \ - FILE *pipefd = setup(fds, class); \ - ATF_REQUIRE((filedesc2 = openat(AT_FDCWD, path, flag)) != -1); \ - check_audit(fds, extregex, pipefd); \ - close(filedesc2); \ - close(filedesc); \ -} \ -ATF_TC_CLEANUP(openat_ ## mode ## _success, tc) \ -{ \ - cleanup(); \ -} \ -ATF_TC_WITH_CLEANUP(openat_ ## mode ## _failure); \ -ATF_TC_HEAD(openat_ ## mode ## _failure, tc) \ -{ \ - atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful " \ - "openat(2) call with flags = %s", #flag); \ -} \ -ATF_TC_BODY(openat_ ## mode ## _failure, tc) \ -{ \ - snprintf(extregex, sizeof(extregex), \ - "openat.*%s.*fileforaudit.*return,failure", regex); \ - FILE *pipefd = setup(fds, class); \ - ATF_REQUIRE_EQ(-1, openat(AT_FDCWD, errpath, flag)); \ - check_audit(fds, extregex, pipefd); \ -} \ -ATF_TC_CLEANUP(openat_ ## mode ## _failure, tc) \ -{ \ - cleanup(); \ +#define OPEN_AT_TC_DEFINE(mode, regex, flag, class) \ +ATF_TC_WITH_CLEANUP(open_ ## mode ## _success); \ +ATF_TC_HEAD(open_ ## mode ## _success, tc) \ +{ \ + atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful " \ + "open(2) call with flags = %s", #flag); \ +} \ +ATF_TC_BODY(open_ ## mode ## _success, tc) \ +{ \ + snprintf(extregex, sizeof(extregex), \ + "open.*%s.*fileforaudit.*return,success", regex); \ + /* File needs to exist for successful open(2) invocation */ \ + ATF_REQUIRE((filedesc = open(path, O_CREAT, o_mode)) != -1); \ + FILE *pipefd = setup(fds, class); \ + ATF_REQUIRE(syscall(SYS_open, path, flag) != -1); \ + check_audit(fds, extregex, pipefd); \ + close(filedesc); \ +} \ +ATF_TC_CLEANUP(open_ ## mode ## _success, tc) \ +{ \ + cleanup(); \ +} \ +ATF_TC_WITH_CLEANUP(open_ ## mode ## _failure); \ +ATF_TC_HEAD(open_ ## mode ## _failure, tc) \ +{ \ + atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful " \ + "open(2) call with flags = %s", #flag); \ +} \ +ATF_TC_BODY(open_ ## mode ## _failure, tc) \ +{ \ + snprintf(extregex, sizeof(extregex), \ + "open.*%s.*fileforaudit.*return,failure", regex); \ + FILE *pipefd = setup(fds, class); \ + ATF_REQUIRE_EQ(-1, syscall(SYS_open, errpath, flag)); \ + check_audit(fds, extregex, pipefd); \ +} \ +ATF_TC_CLEANUP(open_ ## mode ## _failure, tc) \ +{ \ + cleanup(); \ +} \ +ATF_TC_WITH_CLEANUP(openat_ ## mode ## _success); \ +ATF_TC_HEAD(openat_ ## mode ## _success, tc) \ +{ \ + atf_tc_set_md_var(tc, "descr", "Tests the audit of a successful " \ + "openat(2) call with flags = %s", #flag); \ +} \ +ATF_TC_BODY(openat_ ## mode ## _success, tc) \ +{ \ + int filedesc2; \ + snprintf(extregex, sizeof(extregex), \ + "openat.*%s.*fileforaudit.*return,success", regex); \ + /* File needs to exist for successful openat(2) invocation */ \ + ATF_REQUIRE((filedesc = open(path, O_CREAT, o_mode)) != -1); \ + FILE *pipefd = setup(fds, class); \ + ATF_REQUIRE((filedesc2 = openat(AT_FDCWD, path, flag)) != -1); \ + check_audit(fds, extregex, pipefd); \ + close(filedesc2); \ + close(filedesc); \ +} \ +ATF_TC_CLEANUP(openat_ ## mode ## _success, tc) \ +{ \ + cleanup(); \ +} \ +ATF_TC_WITH_CLEANUP(openat_ ## mode ## _failure); \ +ATF_TC_HEAD(openat_ ## mode ## _failure, tc) \ +{ \ + atf_tc_set_md_var(tc, "descr", "Tests the audit of an unsuccessful " \ + "openat(2) call with flags = %s", #flag); \ +} \ +ATF_TC_BODY(openat_ ## mode ## _failure, tc) \ +{ \ + snprintf(extregex, sizeof(extregex), \ + "openat.*%s.*fileforaudit.*return,failure", regex); \ + FILE *pipefd = setup(fds, class); \ + ATF_REQUIRE_EQ(-1, openat(AT_FDCWD, errpath, flag)); \ + check_audit(fds, extregex, pipefd); \ +} \ +ATF_TC_CLEANUP(openat_ ## mode ## _failure, tc) \ +{ \ + cleanup(); \ } /* * Add both success and failure modes of open(2) and openat(2) */ -#define OPEN_AT_TC_ADD(tp, mode) \ -do { \ - ATF_TP_ADD_TC(tp, open_ ## mode ## _success); \ - ATF_TP_ADD_TC(tp, open_ ## mode ## _failure); \ - ATF_TP_ADD_TC(tp, openat_ ## mode ## _success); \ - ATF_TP_ADD_TC(tp, openat_ ## mode ## _failure); \ +#define OPEN_AT_TC_ADD(tp, mode) \ +do { \ + ATF_TP_ADD_TC(tp, open_ ## mode ## _success); \ + ATF_TP_ADD_TC(tp, open_ ## mode ## _failure); \ + ATF_TP_ADD_TC(tp, openat_ ## mode ## _success); \ + ATF_TP_ADD_TC(tp, openat_ ## mode ## _failure); \ } while (0)