Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Sep 2019 20:26:08 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r351794 - in stable: 11/tests/sys/posixshm 12/tests/sys/posixshm
Message-ID:  <201909032026.x83KQ8KR094994@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Tue Sep  3 20:26:08 2019
New Revision: 351794
URL: https://svnweb.freebsd.org/changeset/base/351794

Log:
  tests: shm_open(2): Verify FD_CLOEXEC
  
  Motivated by the fact that I'm messing around near the implementation and
  wanting to ensure this doesn't get messed up in the process.

Modified:
  stable/11/tests/sys/posixshm/posixshm_test.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/tests/sys/posixshm/posixshm_test.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/tests/sys/posixshm/posixshm_test.c
==============================================================================
--- stable/11/tests/sys/posixshm/posixshm_test.c	Tue Sep  3 20:23:58 2019	(r351793)
+++ stable/11/tests/sys/posixshm/posixshm_test.c	Tue Sep  3 20:26:08 2019	(r351794)
@@ -609,6 +609,27 @@ ATF_TC_BODY(shm_functionality_across_fork, tc)
 	shm_unlink(test_path);
 }
 
+ATF_TC_WITHOUT_HEAD(cloexec);
+ATF_TC_BODY(cloexec, tc)
+{
+	int fd;
+
+	gen_test_path();
+
+	/* shm_open(2) is required to set FD_CLOEXEC */
+	fd = shm_open(SHM_ANON, O_RDWR, 0777);
+	ATF_REQUIRE_MSG(fd >= 0, "shm_open failed; errno=%d", errno);
+	ATF_REQUIRE((fcntl(fd, F_GETFD) & FD_CLOEXEC) != 0);
+	close(fd);
+
+	/* Also make sure that named shm is correct */
+	fd = shm_open(test_path, O_CREAT | O_RDWR, 0600);
+	ATF_REQUIRE_MSG(fd >= 0, "shm_open failed; errno=%d", errno);
+	ATF_REQUIRE((fcntl(fd, F_GETFD) & FD_CLOEXEC) != 0);
+	close(fd);
+}
+
+
 ATF_TP_ADD_TCS(tp)
 {
 
@@ -630,6 +651,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, unlink_bad_path_pointer);
 	ATF_TP_ADD_TC(tp, unlink_path_too_long);
 	ATF_TP_ADD_TC(tp, object_resize);
+	ATF_TP_ADD_TC(tp, cloexec);
 
 	return (atf_no_error());
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909032026.x83KQ8KR094994>