Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 May 2017 08:52:13 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r319058 - head/tests/sys/file
Message-ID:  <201705280852.v4S8qDrI000392@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Sun May 28 08:52:12 2017
New Revision: 319058
URL: https://svnweb.freebsd.org/changeset/base/319058

Log:
  Create a deterministic file in the kyua sandbox, instead of a
  temporary file outside the kyua sandbox
  
  This helps ensure that the file is removed at test exit, and as
  a side effect, cures a warning about umasks with Coverity.
  
  MFC after:	3 days
  Sponsored by:	Dell EMC Isilon

Modified:
  head/tests/sys/file/ftruncate_test.c

Modified: head/tests/sys/file/ftruncate_test.c
==============================================================================
--- head/tests/sys/file/ftruncate_test.c	Sun May 28 08:46:57 2017	(r319057)
+++ head/tests/sys/file/ftruncate_test.c	Sun May 28 08:52:12 2017	(r319058)
@@ -60,14 +60,14 @@ int
 main(void)
 {
 	int error, fd, fds[2], i, read_only_fd;
-	char path[PATH_MAX];
+	char path[] = "ftruncate_file";
 	struct stat sb;
 	ssize_t size;
 	off_t len;
 	char ch;
 
 	/*
-	 * Tests using a writable temporary file: grow and then shrink a file
+	 * Tests using a writable file: grow and then shrink a file
 	 * using ftruncate and various lengths.  Make sure that a negative
 	 * file length is rejected.  Make sure that when we grow the file,
 	 * bytes now in the range of the file size return 0.
@@ -75,10 +75,9 @@ main(void)
 	 * Save a read-only reference to the file to use later for read-only
 	 * descriptor tests.
 	 */
-	snprintf(path, PATH_MAX, "/tmp/ftruncate.XXXXXXXXXXXXX");
-	fd = mkstemp(path);
+	fd = open(path, O_RDWR|O_CREAT);
 	if (fd < 0)
-		err(1, "mkstemp");
+		err(1, "open(%s, O_RDWR|O_CREAT", path);
 	read_only_fd = open(path, O_RDONLY);
 	if (read_only_fd < 0) {
 		error = errno;



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