Module Name:    src
Committed By:   christos
Date:           Fri Jan 13 20:03:51 UTC 2017

Modified Files:
        src/tests/lib/libc/sys: Makefile t_truncate.c

Log Message:
PR/51844: Ngie Cooper: use root-owned file created during build instead of
/usr/bin/fpr


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/tests/lib/libc/sys/Makefile
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_truncate.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/sys/Makefile
diff -u src/tests/lib/libc/sys/Makefile:1.45 src/tests/lib/libc/sys/Makefile:1.46
--- src/tests/lib/libc/sys/Makefile:1.45	Fri Nov 11 10:30:44 2016
+++ src/tests/lib/libc/sys/Makefile	Fri Jan 13 15:03:51 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.45 2016/11/11 15:30:44 njoly Exp $
+# $NetBSD: Makefile,v 1.46 2017/01/13 20:03:51 christos Exp $
 
 MKMAN=	no
 
@@ -84,6 +84,16 @@ LDADD.t_posix_fadvise+= -lrumpvfs -lrump
 
 CPPFLAGS.t_lwp_create.c += -D_KERNTYPES
 
+FILES=		truncate_test.root_owned
+FILESDIR=	${TESTSDIR}
+FILESMODE=	0600
+FILESOWNER=	root
+FILESGRP=	wheel
+
+CLEANFILES=   truncate_test.root_owned
+truncate_test.root_owned:
+	dd if=/dev/null bs=1 count=1 of=${.TARGET}
+
 WARNS=			4
 
 .include <bsd.test.mk>

Index: src/tests/lib/libc/sys/t_truncate.c
diff -u src/tests/lib/libc/sys/t_truncate.c:1.2 src/tests/lib/libc/sys/t_truncate.c:1.3
--- src/tests/lib/libc/sys/t_truncate.c:1.2	Thu Aug 18 15:48:03 2011
+++ src/tests/lib/libc/sys/t_truncate.c	Fri Jan 13 15:03:51 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_truncate.c,v 1.2 2011/08/18 19:48:03 dholland Exp $ */
+/* $NetBSD: t_truncate.c,v 1.3 2017/01/13 20:03:51 christos Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,13 +29,14 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_truncate.c,v 1.2 2011/08/18 19:48:03 dholland Exp $");
+__RCSID("$NetBSD: t_truncate.c,v 1.3 2017/01/13 20:03:51 christos Exp $");
 
 #include <sys/stat.h>
 
 #include <atf-c.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <limits.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
@@ -149,6 +150,7 @@ ATF_TC_HEAD(truncate_err, tc)
 
 ATF_TC_BODY(truncate_err, tc)
 {
+	char buf[PATH_MAX];
 
 	errno = 0;
 	ATF_REQUIRE_ERRNO(EFAULT, truncate((void *)-1, 999) == -1);
@@ -160,7 +162,9 @@ ATF_TC_BODY(truncate_err, tc)
 	ATF_REQUIRE_ERRNO(ENOENT, truncate("/a/b/c/d/e/f/g", 999) == -1);
 
 	errno = 0;
-	ATF_REQUIRE_ERRNO(EACCES, truncate("/usr/bin/fpr", 999) == -1);
+	snprintf(buf, sizeof(buf), "%s/truncate_test.root_owned",
+	    atf_tc_get_config_var(tc, "srcdir"));
+	ATF_REQUIRE_ERRNO(EACCES, truncate(buf, 999) == -1);
 }
 
 ATF_TP_ADD_TCS(tp)

Reply via email to