Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 May 2016 06:58:09 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r299054 - in user/ngie/release-pkg-fix-tests/share/examples/tests/tests: atf plain
Message-ID:  <201605040658.u446w9Zx068381@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Wed May  4 06:58:08 2016
New Revision: 299054
URL: https://svnweb.freebsd.org/changeset/base/299054

Log:
  Provide working examples which use PACKAGE/${PACKAGE}FILES
  
  file1 was previously created on the fly and deleted after the test was
  over. Switch things up a bit by installing it via the build, so helpful
  comments and reasoning can be added for the ${PACKAGE}FILES idiom I've
  sprinkled around the tree on the branch
  
  Also, in plain/cp_test.sh, use file3 in the second test instead of file2.
  Using file2 worked previously because the files' permissions were reset
  when the files were truncated, but since the environment for both the
  `force` and `simple` testcases are the same, it would fail when `force`
  followed `simple`, as file2 existed when `force` was run, but had
  incorrect permissions, thus resulting in a permission died error from
  cp(1).

Modified:
  user/ngie/release-pkg-fix-tests/share/examples/tests/tests/atf/Makefile
  user/ngie/release-pkg-fix-tests/share/examples/tests/tests/atf/cp_test.sh
  user/ngie/release-pkg-fix-tests/share/examples/tests/tests/plain/Makefile
  user/ngie/release-pkg-fix-tests/share/examples/tests/tests/plain/cp_test.sh

Modified: user/ngie/release-pkg-fix-tests/share/examples/tests/tests/atf/Makefile
==============================================================================
--- user/ngie/release-pkg-fix-tests/share/examples/tests/tests/atf/Makefile	Wed May  4 06:53:02 2016	(r299053)
+++ user/ngie/release-pkg-fix-tests/share/examples/tests/tests/atf/Makefile	Wed May  4 06:58:08 2016	(r299054)
@@ -2,6 +2,12 @@
 
 .include <bsd.own.mk>
 
+# The release package to use for the tests contained within the directory
+#
+# This applies to components which rely on ^/projects/release-pkg support
+# (see UPDATING XXXXXXXXX / svn revision r298107).
+PACKAGE=	tests
+
 # Directory into which the Kyuafile provided by this directory will be
 # installed.
 #
@@ -27,4 +33,19 @@ ATF_TESTS_SH=	cp_test
 # definitions from above.
 KYUAFILE=	yes
 
+# Install file1 and file2 as files via bsd.prog.mk. Please note the intentional
+# ${PACKAGE} namespace of files.
+#
+# The basic semantics of this are the same as FILES in bsd.prog.mk, e.g. the
+# installation of the files can be manipulated via ${PACKAGE}FILESDIR,
+# ${PACKAGE}FILESMODE, etc.
+#
+# Please see comment above about ${PACKAGE}. Feel free to omit the ${PACKAGE}
+# namespace if release package support isn't needed.
+${PACKAGE}FILES+=	file1
+CLEANFILES+=		file1
+
+file1:
+	@echo "File 1" > ${.TARGET}
+
 .include <bsd.test.mk>

Modified: user/ngie/release-pkg-fix-tests/share/examples/tests/tests/atf/cp_test.sh
==============================================================================
--- user/ngie/release-pkg-fix-tests/share/examples/tests/tests/atf/cp_test.sh	Wed May  4 06:53:02 2016	(r299053)
+++ user/ngie/release-pkg-fix-tests/share/examples/tests/tests/atf/cp_test.sh	Wed May  4 06:58:08 2016	(r299054)
@@ -61,7 +61,7 @@ verify_copy() {
 #
 atf_test_case simple
 simple_body() {
-	echo 'File 1' >file1
+	cp $(atf_get_srcdir)/file1 .
 
 	# The atf_check function is a very powerful function of atf-sh.
 	# It allows you to define checkers for the exit status, the
@@ -102,7 +102,7 @@ force_head() {
 	    "override the destination file"
 }
 force_body() {
-	echo 'File 1' >file1
+	cp $(atf_get_srcdir)/file1 .
 	echo 'File 2' >file2
 	chmod 400 file2
 	atf_check cp -f file1 file2

Modified: user/ngie/release-pkg-fix-tests/share/examples/tests/tests/plain/Makefile
==============================================================================
--- user/ngie/release-pkg-fix-tests/share/examples/tests/tests/plain/Makefile	Wed May  4 06:53:02 2016	(r299053)
+++ user/ngie/release-pkg-fix-tests/share/examples/tests/tests/plain/Makefile	Wed May  4 06:58:08 2016	(r299054)
@@ -2,6 +2,12 @@
 
 .include <bsd.own.mk>
 
+# The release package to use for the tests contained within the directory
+#
+# This applies to components which rely on ^/projects/release-pkg support
+# (see UPDATING XXXXXXXXX / svn revision r298107).
+PACKAGE=	tests
+
 # Directory into which the Kyuafile provided by this directory will be
 # installed.
 #
@@ -27,4 +33,19 @@ PLAIN_TESTS_SH=	cp_test
 # definitions from above.
 KYUAFILE=	yes
 
+# Install file1 and file2 as files via bsd.prog.mk. Please note the intentional
+# ${PACKAGE} namespace of files.
+#
+# The basic semantics of this are the same as FILES in bsd.prog.mk, e.g. the
+# installation of the files can be manipulated via ${PACKAGE}FILESDIR,
+# ${PACKAGE}FILESMODE, etc.
+#
+# Please see comment above about ${PACKAGE}. Feel free to omit the ${PACKAGE}
+# namespace if release package support isn't needed.
+${PACKAGE}FILES+=	file1
+CLEANFILES+=		file1
+
+file1:
+	@echo "File 1" > ${.TARGET}
+
 .include <bsd.test.mk>

Modified: user/ngie/release-pkg-fix-tests/share/examples/tests/tests/plain/cp_test.sh
==============================================================================
--- user/ngie/release-pkg-fix-tests/share/examples/tests/tests/plain/cp_test.sh	Wed May  4 06:53:02 2016	(r299053)
+++ user/ngie/release-pkg-fix-tests/share/examples/tests/tests/plain/cp_test.sh	Wed May  4 06:58:08 2016	(r299054)
@@ -57,17 +57,16 @@ verify_copy() {
 }
 
 simple_test() {
-	echo 'File 1' >file1
+	cp "$(dirname "${0}")/file1" .
 	cp file1 file2 || err "cp failed"
 	verify_copy file1 file2
 }
 
 force_test() {
-	echo 'File 1' >file1
-	echo 'File 2' >file2
-	chmod 400 file2
-	cp -f file1 file2 || err "cp failed"
-	verify_copy file1 file2
+	echo 'File 3' >file3
+	chmod 400 file3
+	cp -f file1 file3 || err "cp failed"
+	verify_copy file1 file3
 }
 
 # If you have read the cp_test.sh counterpart in the atf/ directory, you



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