From owner-svn-src-user@FreeBSD.ORG Sat Apr 11 08:27:35 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 075367D; Sat, 11 Apr 2015 08:27:35 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CD78C16B; Sat, 11 Apr 2015 08:27:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3B8RYRv072075; Sat, 11 Apr 2015 08:27:34 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3B8RYRX072074; Sat, 11 Apr 2015 08:27:34 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201504110827.t3B8RYRX072074@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 11 Apr 2015 08:27:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r281414 - user/ngie/more-tests X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Apr 2015 08:27:35 -0000 Author: ngie Date: Sat Apr 11 08:27:34 2015 New Revision: 281414 URL: https://svnweb.freebsd.org/changeset/base/281414 Log: Integrate more tests into the FreeBSD test suite from tools/regression, etc Added: - copied from r281413, head/ Directory Properties: user/ngie/more-tests/ (props changed) From owner-svn-src-user@FreeBSD.ORG Sat Apr 11 08:34:35 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B32AB5EA; Sat, 11 Apr 2015 08:34:35 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9E7FF236; Sat, 11 Apr 2015 08:34:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3B8YZul076983; Sat, 11 Apr 2015 08:34:35 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3B8YZx1076982; Sat, 11 Apr 2015 08:34:35 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201504110834.t3B8YZx1076982@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 11 Apr 2015 08:34:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r281417 - user/ngie/more-tests/share/mk X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Apr 2015 08:34:35 -0000 Author: ngie Date: Sat Apr 11 08:34:34 2015 New Revision: 281417 URL: https://svnweb.freebsd.org/changeset/base/281417 Log: Simplify all of the .PHONY targets Sponsored by: EMC / Isilon Storage Division Modified: user/ngie/more-tests/share/mk/bsd.test.mk Modified: user/ngie/more-tests/share/mk/bsd.test.mk ============================================================================== --- user/ngie/more-tests/share/mk/bsd.test.mk Sat Apr 11 08:30:37 2015 (r281416) +++ user/ngie/more-tests/share/mk/bsd.test.mk Sat Apr 11 08:34:34 2015 (r281417) @@ -78,14 +78,9 @@ realtest: .PHONY @echo "$@ not defined; skipping" .endif -test: .PHONY -.ORDER: beforetest realtest -test: beforetest realtest - -.if target(aftertest) -.ORDER: realtest aftertest -test: aftertest -.endif +beforetest realtest aftertest test: .PHONY +.ORDER: beforetest realtest aftertest +test: beforetest realtest aftertest .if !empty(SUBDIR) .include From owner-svn-src-user@FreeBSD.ORG Sat Apr 11 08:35:54 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E5E4E834; Sat, 11 Apr 2015 08:35:54 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B73FD253; Sat, 11 Apr 2015 08:35:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3B8ZsBS077271; Sat, 11 Apr 2015 08:35:54 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3B8Zs5P077270; Sat, 11 Apr 2015 08:35:54 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201504110835.t3B8Zs5P077270@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 11 Apr 2015 08:35:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r281419 - user/ngie/more-tests/share/mk X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Apr 2015 08:35:55 -0000 Author: ngie Date: Sat Apr 11 08:35:53 2015 New Revision: 281419 URL: https://svnweb.freebsd.org/changeset/base/281419 Log: Remove FUD-inspiring warnings Try to detect simple cases and guide the user in the right direction Sponsored by: EMC / Isilon Storage Division Modified: user/ngie/more-tests/share/mk/suite.test.mk Modified: user/ngie/more-tests/share/mk/suite.test.mk ============================================================================== --- user/ngie/more-tests/share/mk/suite.test.mk Sat Apr 11 08:34:41 2015 (r281418) +++ user/ngie/more-tests/share/mk/suite.test.mk Sat Apr 11 08:35:53 2015 (r281419) @@ -82,6 +82,29 @@ Kyuafile.auto: Makefile .endif KYUA?= ${KYUA_PREFIX}/bin/kyua + +_kyuafile= ${DESTDIR}${TESTSDIR}/Kyuafile + +kyuafile-check: +.if ${KYUAFILE:tl} != "no" + @if [ ! -f ${_kyuafile} ]; then \ + echo "*** Please run make install and make test for" \ + "end-to-end testing"; \ + false; \ + fi + @if [ "${KYUAFILE:tl}" = yes ]; then \ + ext=; \ + else \ + ext=.auto; \ + fi; \ + if [ ${_kyuafile} -ot Kyuafile$$ext ]; then \ + echo "*** ${_kyuafile} is older than " \ + "${.OBJDIR}/Kyuafile$$ext"; \ + echo "*** Please run make install before running make test"; \ + false; \ + fi +.endif + .if exists(${KYUA}) # Definition of the "make test" target and supporting variables. # @@ -93,35 +116,12 @@ KYUA?= ${KYUA_PREFIX}/bin/kyua # are used by tests, it is highly possible for a execution of "make test" to # report bogus results unless the new binaries are put in place. realtest: .PHONY - @echo "*** WARNING: make test is experimental" - @echo "***" - @echo "*** Using this test does not preclude you from running the tests" - @echo "*** installed in ${TESTSBASE}. This test run may raise false" - @echo "*** positives and/or false negatives." - @echo - @set -e; \ - ${KYUA} test -k ${DESTDIR}${TESTSDIR}/Kyuafile; \ - result=0; \ - echo; \ - echo "*** Once again, note that "make test" is unsupported."; \ - test $${result} -eq 0 + ${KYUA} test -k ${_kyuafile} .endif beforetest: .PHONY -.if defined(TESTSDIR) -.if ${TESTSDIR} == ${TESTSBASE} -# Forbid running from ${TESTSBASE}. It can cause false positives/negatives and -# it does not cover all the tests (e.g. it misses testing software in external). - @echo "*** Sorry, you cannot use make test from src/tests. Install the" - @echo "*** tests into their final location and run them from ${TESTSBASE}" - @false -.else - @echo "*** Using this test does not preclude you from running the tests" - @echo "*** installed in ${TESTSBASE}. This test run may raise false" - @echo "*** positives and/or false negatives." -.endif -.else +beforetest: kyuafile-check +.if !defined(TESTSDIR) @echo "*** No TESTSDIR defined; nothing to do." @false .endif - @echo From owner-svn-src-user@FreeBSD.ORG Sat Apr 11 08:39:00 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B04D393A; Sat, 11 Apr 2015 08:39:00 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9BAAE265; Sat, 11 Apr 2015 08:39:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3B8d0mv077675; Sat, 11 Apr 2015 08:39:00 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3B8d0e1077673; Sat, 11 Apr 2015 08:39:00 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201504110839.t3B8d0e1077673@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 11 Apr 2015 08:39:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r281420 - user/ngie/more-tests/share/mk X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Apr 2015 08:39:00 -0000 Author: ngie Date: Sat Apr 11 08:38:59 2015 New Revision: 281420 URL: https://svnweb.freebsd.org/changeset/base/281420 Log: Don't defining TESTSDIR before including bsd.test.mk is bad. I hate it when tests and programs clutter up / Sponsored by: EMC / Isilon Storage Division Modified: user/ngie/more-tests/share/mk/bsd.test.mk Modified: user/ngie/more-tests/share/mk/bsd.test.mk ============================================================================== --- user/ngie/more-tests/share/mk/bsd.test.mk Sat Apr 11 08:35:53 2015 (r281419) +++ user/ngie/more-tests/share/mk/bsd.test.mk Sat Apr 11 08:38:59 2015 (r281420) @@ -10,6 +10,10 @@ ____: +.if !defined(TESTSDIR) +.error "Please define TESTSDIR when including bsd.test.mk" +.endif + # List of subdirectories containing tests into which to recurse. This has the # same semantics as SUBDIR at build-time. However, the directories listed here # get registered into the run-time test suite definitions so that the test From owner-svn-src-user@FreeBSD.ORG Sat Apr 11 08:42:03 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 668DAA63; Sat, 11 Apr 2015 08:42:03 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 524FE33D; Sat, 11 Apr 2015 08:42:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3B8g3FO081548; Sat, 11 Apr 2015 08:42:03 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3B8g3k4081547; Sat, 11 Apr 2015 08:42:03 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201504110842.t3B8g3k4081547@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 11 Apr 2015 08:42:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r281421 - user/ngie/more-tests/share/mk X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Apr 2015 08:42:03 -0000 Author: ngie Date: Sat Apr 11 08:42:02 2015 New Revision: 281421 URL: https://svnweb.freebsd.org/changeset/base/281421 Log: Expose make test via bsd.subdir.mk Modified: user/ngie/more-tests/share/mk/bsd.subdir.mk Modified: user/ngie/more-tests/share/mk/bsd.subdir.mk ============================================================================== --- user/ngie/more-tests/share/mk/bsd.subdir.mk Sat Apr 11 08:38:59 2015 (r281420) +++ user/ngie/more-tests/share/mk/bsd.subdir.mk Sat Apr 11 08:42:02 2015 (r281421) @@ -72,7 +72,7 @@ ${SUBDIR:N.WAIT}: .PHONY .MAKE __wait= .WAIT .for __target in all all-man checkdpadd clean cleandepend cleandir \ cleanilinks depend distribute lint maninstall manlint obj objlink \ - realinstall regress tags ${SUBDIR_TARGETS} + realinstall regress tags test ${SUBDIR_TARGETS} .ifdef SUBDIR_PARALLEL __subdir_targets= .for __dir in ${SUBDIR} From owner-svn-src-user@FreeBSD.ORG Sat Apr 11 08:54:04 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 07936D7F; Sat, 11 Apr 2015 08:54:04 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E7A18611; Sat, 11 Apr 2015 08:54:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3B8s3W6086481; Sat, 11 Apr 2015 08:54:03 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3B8s3oL086480; Sat, 11 Apr 2015 08:54:03 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201504110854.t3B8s3oL086480@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 11 Apr 2015 08:54:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r281422 - user/ngie/more-tests X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Apr 2015 08:54:04 -0000 Author: ngie Date: Sat Apr 11 08:54:03 2015 New Revision: 281422 URL: https://svnweb.freebsd.org/changeset/base/281422 Log: Similar to r281421, expose make test from the top-level Makefile Modified: user/ngie/more-tests/Makefile Modified: user/ngie/more-tests/Makefile ============================================================================== --- user/ngie/more-tests/Makefile Sat Apr 11 08:42:02 2015 (r281421) +++ user/ngie/more-tests/Makefile Sat Apr 11 08:54:03 2015 (r281422) @@ -109,7 +109,7 @@ TGTS= all all-man buildenv buildenvvars installkernel.debug packagekernel packageworld \ reinstallkernel reinstallkernel.debug \ installworld kernel-toolchain libraries lint maninstall \ - obj objlink regress rerelease showconfig tags toolchain update \ + obj objlink regress rerelease showconfig tags test toolchain update \ _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ _build-tools _cross-tools _includes _libraries _depend \ build32 builddtb distribute32 install32 xdev xdev-build xdev-install \ From owner-svn-src-user@FreeBSD.ORG Sat Apr 11 08:55:58 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C8FC1F8B; Sat, 11 Apr 2015 08:55:58 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9A8F2622; Sat, 11 Apr 2015 08:55:58 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3B8twAI086778; Sat, 11 Apr 2015 08:55:58 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3B8tvjt086773; Sat, 11 Apr 2015 08:55:57 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201504110855.t3B8tvjt086773@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 11 Apr 2015 08:55:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r281423 - in user/ngie/more-tests: . share/mk X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Apr 2015 08:55:58 -0000 Author: ngie Date: Sat Apr 11 08:55:56 2015 New Revision: 281423 URL: https://svnweb.freebsd.org/changeset/base/281423 Log: Kill make regress Modified: user/ngie/more-tests/Makefile user/ngie/more-tests/share/mk/bsd.subdir.mk user/ngie/more-tests/share/mk/bsd.sys.mk Modified: user/ngie/more-tests/Makefile ============================================================================== --- user/ngie/more-tests/Makefile Sat Apr 11 08:54:03 2015 (r281422) +++ user/ngie/more-tests/Makefile Sat Apr 11 08:55:56 2015 (r281423) @@ -109,7 +109,7 @@ TGTS= all all-man buildenv buildenvvars installkernel.debug packagekernel packageworld \ reinstallkernel reinstallkernel.debug \ installworld kernel-toolchain libraries lint maninstall \ - obj objlink regress rerelease showconfig tags test toolchain update \ + obj objlink rerelease showconfig tags test toolchain update \ _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ _build-tools _cross-tools _includes _libraries _depend \ build32 builddtb distribute32 install32 xdev xdev-build xdev-install \ Modified: user/ngie/more-tests/share/mk/bsd.subdir.mk ============================================================================== --- user/ngie/more-tests/share/mk/bsd.subdir.mk Sat Apr 11 08:54:03 2015 (r281422) +++ user/ngie/more-tests/share/mk/bsd.subdir.mk Sat Apr 11 08:55:56 2015 (r281423) @@ -26,7 +26,7 @@ # # afterinstall, all, all-man, beforeinstall, checkdpadd, clean, # cleandepend, cleandir, cleanilinks depend, install, lint, -# maninstall, manlint, obj, objlink, realinstall, regress, tags +# maninstall, manlint, obj, objlink, realinstall, test, tags # .if !target(____) Modified: user/ngie/more-tests/share/mk/bsd.sys.mk ============================================================================== --- user/ngie/more-tests/share/mk/bsd.sys.mk Sat Apr 11 08:54:03 2015 (r281422) +++ user/ngie/more-tests/share/mk/bsd.sys.mk Sat Apr 11 08:55:56 2015 (r281423) @@ -170,8 +170,8 @@ PHONY_NOTMAIN = afterdepend afterinstall depend dependall distclean distribute exe \ html includes install installfiles installincludes lint \ obj objlink objs objwarn realall realdepend \ - realinstall regress subdir-all subdir-depend subdir-install \ - tags whereobj + realinstall subdir-all subdir-depend subdir-install \ + tags test whereobj .PHONY: ${PHONY_NOTMAIN} .NOTMAIN: ${PHONY_NOTMAIN} From owner-svn-src-user@FreeBSD.ORG Sat Apr 11 08:57:34 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DFE6E133; Sat, 11 Apr 2015 08:57:34 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C71FF636; Sat, 11 Apr 2015 08:57:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3B8vY4o087024; Sat, 11 Apr 2015 08:57:34 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3B8vWI4087015; Sat, 11 Apr 2015 08:57:32 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201504110857.t3B8vWI4087015@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 11 Apr 2015 08:57:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r281424 - in user/ngie/more-tests: etc/mtree tests/sys/sockets tests/sys/sockets/accept_fd_leak tests/sys/sockets/accf_data_attach tests/sys/sockets/fstat tests/sys/sockets/kqueue tests... X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Apr 2015 08:57:35 -0000 Author: ngie Date: Sat Apr 11 08:57:31 2015 New Revision: 281424 URL: https://svnweb.freebsd.org/changeset/base/281424 Log: Start integrating tools/regression/sockets into tests/sys/sockets Added: user/ngie/more-tests/tests/sys/sockets/ - copied from r281415, user/ngie/more-tests/tools/regression/sockets/ user/ngie/more-tests/tests/sys/sockets/Makefile (contents, props changed) user/ngie/more-tests/tests/sys/sockets/README.unix_cmsg - copied unchanged from r281404, head/tools/regression/sockets/unix_cmsg/README user/ngie/more-tests/tests/sys/sockets/accept_fd_leak_test.c - copied unchanged from r281415, user/ngie/more-tests/tools/regression/sockets/accept_fd_leak/accept_fd_leak.c user/ngie/more-tests/tests/sys/sockets/accf_data_attach_test.c - copied unchanged from r281404, head/tools/regression/sockets/accf_data_attach/accf_data_attach.c user/ngie/more-tests/tests/sys/sockets/fstat_test.c - copied unchanged from r281404, head/tools/regression/sockets/fstat/fstat.c user/ngie/more-tests/tests/sys/sockets/kqueue_test.c - copied unchanged from r281404, head/tools/regression/sockets/kqueue/kqueue.c user/ngie/more-tests/tests/sys/sockets/listen_backlog_test.c - copied unchanged from r281404, head/tools/regression/sockets/listen_backlog/listen_backlog.c user/ngie/more-tests/tests/sys/sockets/listenclose_test.c - copied unchanged from r281404, head/tools/regression/sockets/listenclose/listenclose.c user/ngie/more-tests/tests/sys/sockets/pr_atomic_test.c - copied unchanged from r281409, head/tools/regression/sockets/pr_atomic/pr_atomic.c user/ngie/more-tests/tests/sys/sockets/reconnect_test.c - copied unchanged from r281411, head/tools/regression/sockets/reconnect/reconnect.c user/ngie/more-tests/tests/sys/sockets/rtsocket_test.c - copied unchanged from r281404, head/tools/regression/sockets/rtsocket/rtsocket.c user/ngie/more-tests/tests/sys/sockets/sblock_test.c - copied unchanged from r281404, head/tools/regression/sockets/sblock/sblock.c user/ngie/more-tests/tests/sys/sockets/sendfile_test.c - copied unchanged from r281404, head/tools/regression/sockets/sendfile/sendfile.c user/ngie/more-tests/tests/sys/sockets/shutdown_test.c - copied unchanged from r281404, head/tools/regression/sockets/shutdown/shutdown.c user/ngie/more-tests/tests/sys/sockets/sigpipe_test.c - copied unchanged from r281404, head/tools/regression/sockets/sigpipe/sigpipe.c user/ngie/more-tests/tests/sys/sockets/so_setfib_test.c - copied unchanged from r281408, head/tools/regression/sockets/so_setfib/so_setfib.c user/ngie/more-tests/tests/sys/sockets/socketpair_test.c - copied unchanged from r281404, head/tools/regression/sockets/socketpair/socketpair.c user/ngie/more-tests/tests/sys/sockets/unix_bindconnect_test.c - copied unchanged from r281404, head/tools/regression/sockets/unix_bindconnect/unix_bindconnect.c user/ngie/more-tests/tests/sys/sockets/unix_close_race_test.c - copied unchanged from r281404, head/tools/regression/sockets/unix_close_race/unix_close_race.c user/ngie/more-tests/tests/sys/sockets/unix_cmsg.c - copied unchanged from r281404, head/tools/regression/sockets/unix_cmsg/unix_cmsg.c user/ngie/more-tests/tests/sys/sockets/unix_cmsg_test.sh - copied, changed from r281404, head/tools/regression/sockets/unix_cmsg/unix_cmsg.t user/ngie/more-tests/tests/sys/sockets/unix_gc_test.c - copied unchanged from r281404, head/tools/regression/sockets/unix_gc/unix_gc.c user/ngie/more-tests/tests/sys/sockets/unix_passfd_test.c - copied unchanged from r281404, head/tools/regression/sockets/unix_passfd/unix_passfd.c user/ngie/more-tests/tests/sys/sockets/unix_sendtorace_test.c - copied unchanged from r281404, head/tools/regression/sockets/unix_sendtorace/unix_sendtorace.c user/ngie/more-tests/tests/sys/sockets/unix_socket_test.c - copied unchanged from r281404, head/tools/regression/sockets/unix_socket/unix_socket.c user/ngie/more-tests/tests/sys/sockets/unix_sorflush_test.c - copied unchanged from r281404, head/tools/regression/sockets/unix_sorflush/unix_sorflush.c user/ngie/more-tests/tests/sys/sockets/zerosend_test.c - copied unchanged from r281404, head/tools/regression/sockets/zerosend/zerosend.c Deleted: user/ngie/more-tests/tests/sys/sockets/accept_fd_leak/ user/ngie/more-tests/tests/sys/sockets/accf_data_attach/ user/ngie/more-tests/tests/sys/sockets/fstat/ user/ngie/more-tests/tests/sys/sockets/kqueue/ user/ngie/more-tests/tests/sys/sockets/listen_backlog/ user/ngie/more-tests/tests/sys/sockets/listenclose/ user/ngie/more-tests/tests/sys/sockets/pr_atomic/ user/ngie/more-tests/tests/sys/sockets/reconnect/ user/ngie/more-tests/tests/sys/sockets/rtsocket/ user/ngie/more-tests/tests/sys/sockets/sblock/ user/ngie/more-tests/tests/sys/sockets/sendfile/ user/ngie/more-tests/tests/sys/sockets/shutdown/ user/ngie/more-tests/tests/sys/sockets/sigpipe/ user/ngie/more-tests/tests/sys/sockets/so_setfib/ user/ngie/more-tests/tests/sys/sockets/socketpair/ user/ngie/more-tests/tests/sys/sockets/unix_bindconnect/ user/ngie/more-tests/tests/sys/sockets/unix_close_race/ user/ngie/more-tests/tests/sys/sockets/unix_cmsg/ user/ngie/more-tests/tests/sys/sockets/unix_gc/ user/ngie/more-tests/tests/sys/sockets/unix_passfd/ user/ngie/more-tests/tests/sys/sockets/unix_sendtorace/ user/ngie/more-tests/tests/sys/sockets/unix_socket/ user/ngie/more-tests/tests/sys/sockets/unix_sorflush/ user/ngie/more-tests/tests/sys/sockets/zerosend/ user/ngie/more-tests/tools/regression/sockets/ Modified: user/ngie/more-tests/etc/mtree/BSD.tests.dist Modified: user/ngie/more-tests/etc/mtree/BSD.tests.dist ============================================================================== --- user/ngie/more-tests/etc/mtree/BSD.tests.dist Sat Apr 11 08:55:56 2015 (r281423) +++ user/ngie/more-tests/etc/mtree/BSD.tests.dist Sat Apr 11 08:57:31 2015 (r281424) @@ -392,6 +392,8 @@ unlink .. .. + socket + .. .. usr.bin apply Added: user/ngie/more-tests/tests/sys/sockets/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/ngie/more-tests/tests/sys/sockets/Makefile Sat Apr 11 08:57:31 2015 (r281424) @@ -0,0 +1,54 @@ +# $FreeBSD$ +# +# Some of these tests fail on 11.0-CURRENT @ r280355 with DEBUG bits on + +TESTSDIR= ${TESTSBASE}/sys/socket + +BINDIR= ${TESTSDIR} + +PROGS+= unix_cmsg + +TAP_TESTS_C+= accept_fd_leak_test +# accf_data_attach: not ok 9 - setsockopt() after listen() failed with 2 (No such file or directory) +TAP_TESTS_C+= accf_data_attach_test +PLAIN_TESTS_C+= fstat_test +PLAIN_TESTS_C+= kqueue_test +PLAIN_TESTS_C+= listen_backlog_test +PLAIN_TESTS_C+= listenclose_test +PLAIN_TESTS_C+= pr_atomic_test +PLAIN_TESTS_C+= reconnect_test +# rtsocket: socket(PF_ROUTE, SOCK_STREAM, 0): Protocol wrong type for socket +PLAIN_TESTS_C+= rtsocket_test +PLAIN_TESTS_C+= sblock_test +TAP_TESTS_C+= sendfile_test +PLAIN_TESTS_C+= shutdown_test +PLAIN_TESTS_C+= sigpipe_test +TAP_TESTS_C+= so_setfib_test +PLAIN_TESTS_C+= socketpair_test +PLAIN_TESTS_C+= unix_bindconnect_test +PLAIN_TESTS_C+= unix_close_race_test +# Lots of failures +TAP_TESTS_SH+= unix_cmsg_test +# unix_gc: twosome_drop1: sendfd: before 0 after 0 +PLAIN_TESTS_C+= unix_gc_test +# unix_passfd: test8-rights+creds+payload: recvmsg: 24 bytes received +PLAIN_TESTS_C+= unix_passfd_test +PLAIN_TESTS_C+= unix_sendtorace_test +# unix_socket: socket(PF_LOCAL, SOCK_RAW, 0): Protocol wrong type for socket +PLAIN_TESTS_C+= unix_socket_test +PLAIN_TESTS_C+= unix_sorflush_test +# zerosend: tcp_0write: bind(127.0.0.1, 10001): Address already in use +PLAIN_TESTS_C+= zerosend_test + +DPADD.sendfile_test+= ${LIBMD} +LDADD.sendfile_test+= -lmd + +# XXX: this doesn't work..? +#WARNS.unix_cmsg= 3 +#WARNS.unix_gc= 3 +#WARNS.unix_passfd= 3 +#WARNS.zerosend= 2 + +WARNS= 2 + +.include Copied: user/ngie/more-tests/tests/sys/sockets/README.unix_cmsg (from r281404, head/tools/regression/sockets/unix_cmsg/README) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/ngie/more-tests/tests/sys/sockets/README.unix_cmsg Sat Apr 11 08:57:31 2015 (r281424, copy of r281404, head/tools/regression/sockets/unix_cmsg/README) @@ -0,0 +1,160 @@ +$FreeBSD$ + +About unix_cmsg +=============== + +This program is a collection of regression tests for ancillary data +(control information) for PF_LOCAL sockets (local domain or Unix domain +sockets). There are tests for stream and datagram sockets. + +Usually each test does following steps: creates Server, forks Client, +Client sends something to Server, Server verifies whether everything is +correct in received message(s). + +It is better to change the owner of unix_cmsg to some safe user +(eg. nobody:nogroup) and set SUID and SGID bits, else some tests that +check credentials can give correct results for wrong implementation. + +It is better to run this program by a user that belongs to more +than 16 groups. + +Available options +================= + +usage: unix_cmsg [-dh] [-n num] [-s size] [-t type] [-z value] [testno] + + Options are: + -d Output debugging information + -h Output the help message and exit + -n num Number of messages to send + -s size Specify size of data for IPC + -t type Specify socket type (stream, dgram) for tests + -z value Do not send data in a message (bit 0x1), do not send + data array associated with a cmsghdr structure (bit 0x2) + testno Run one test by its number (require the -t option) + +Description +=========== + +If Client sends something to Server, then it sends 5 messages by default. +Number of messages can be changed in the -n command line option. Number +of messages will be given as N in the following descriptions. + +If Client sends something to Server, then it sends some data (few bytes) +in each message by default. The size of this data can be changed by the -s +command line option. The "-s 0" command line option means, that Client will +send zero bytes represented by { NULL, 0 } value of struct iovec{}, referenced +by the msg_iov field from struct msghdr{}. The "-z 1" or "-z 3" command line +option means, that Client will send zero bytes represented by the NULL value +in the msg_iov field from struct msghdr{}. + +If Client sends some ancillary data object, then this ancillary data object +always has associated data array by default. The "-z 2" or "-z 3" option +means, that Client will not send associated data array if possible. + +For SOCK_STREAM sockets: +----------------------- + + 1: Sending, receiving cmsgcred + + Client connects to Server and sends N messages with SCM_CREDS ancillary + data object. Server should receive N messages, each message should + have SCM_CREDS ancillary data object followed by struct cmsgcred{}. + + 2: Receiving sockcred (listening socket) + + Server creates a listening stream socket and sets the LOCAL_CREDS + socket option for it. Client connects to Server two times, each time + it sends N messages. Server accepts two connections and receives N + messages from each connection. The first message from each connection + should have SCM_CREDS ancillary data object followed by struct sockcred{}, + next messages from the same connection should not have ancillary data. + + 3: Receiving sockcred (accepted socket) + + Client connects to Server. Server accepts connection and sets the + LOCAL_CREDS socket option for just accepted socket. Client sends N + messages to Server. Server should receive N messages, the first + message should have SCM_CREDS ancillary data object followed by + struct sockcred{}, next messages should not have ancillary data. + + 4: Sending cmsgcred, receiving sockcred + + Server creates a listening stream socket and sets the LOCAL_CREDS + socket option for it. Client connects to Server and sends N messages + with SCM_CREDS ancillary data object. Server should receive N messages, + the first message should have SCM_CREDS ancillary data object followed + by struct sockcred{}, each of next messages should have SCM_CREDS + ancillary data object followed by struct cmsgcred{}. + + 5: Sending, receiving timeval + + Client connects to Server and sends message with SCM_TIMESTAMP ancillary + data object. Server should receive one message with SCM_TIMESTAMP + ancillary data object followed by struct timeval{}. + + 6: Sending, receiving bintime + + Client connects to Server and sends message with SCM_BINTIME ancillary + data object. Server should receive one message with SCM_BINTIME + ancillary data object followed by struct bintime{}. + + 7: Checking cmsghdr.cmsg_len + + Client connects to Server and tries to send several messages with + SCM_CREDS ancillary data object that has wrong cmsg_len field in its + struct cmsghdr{}. All these attempts should fail, since cmsg_len + in all requests is less than CMSG_LEN(0). + + 8: Check LOCAL_PEERCRED socket option + + This test does not use ancillary data, but can be implemented here. + Client connects to Server. Both Client and Server verify that + credentials of the peer are correct using LOCAL_PEERCRED socket option. + +For SOCK_DGRAM sockets: +---------------------- + + 1: Sending, receiving cmsgcred + + Client connects to Server and sends N messages with SCM_CREDS ancillary + data object. Server should receive N messages, each message should + have SCM_CREDS ancillary data object followed by struct cmsgcred{}. + + 2: Receiving sockcred + + Server creates datagram socket and sets the LOCAL_CREDS socket option + for it. Client sends N messages to Server. Server should receive N + messages, each message should have SCM_CREDS ancillary data object + followed by struct sockcred{}. + + 3: Sending cmsgcred, receiving sockcred + + Server creates datagram socket and sets the LOCAL_CREDS socket option + for it. Client sends N messages with SCM_CREDS ancillary data object + to Server. Server should receive N messages, the first message should + have SCM_CREDS ancillary data object followed by struct sockcred{}, + each of next messages should have SCM_CREDS ancillary data object + followed by struct cmsgcred{}. + + 4: Sending, receiving timeval + + Client sends one message with SCM_TIMESTAMP ancillary data object + to Server. Server should receive one message with SCM_TIMESTAMP + ancillary data object followed by struct timeval{}. + + 5: Sending, receiving bintime + + Client sends one message with SCM_BINTIME ancillary data object + to Server. Server should receive one message with SCM_BINTIME + ancillary data object followed by struct bintime{}. + + 6: Checking cmsghdr.cmsg_len + + Client tries to send Server several messages with SCM_CREDS ancillary + data object that has wrong cmsg_len field in its struct cmsghdr{}. + All these attempts should fail, since cmsg_len in all requests is less + than CMSG_LEN(0). + +- Andrey Simonenko +andreysimonenko@users.sourceforge.net Copied: user/ngie/more-tests/tests/sys/sockets/accept_fd_leak_test.c (from r281415, user/ngie/more-tests/tools/regression/sockets/accept_fd_leak/accept_fd_leak.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/ngie/more-tests/tests/sys/sockets/accept_fd_leak_test.c Sat Apr 11 08:57:31 2015 (r281424, copy of r281415, user/ngie/more-tests/tools/regression/sockets/accept_fd_leak/accept_fd_leak.c) @@ -0,0 +1,215 @@ +/*- + * Copyright (c) 2004 Robert N. M. Watson + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#define BIND_ATTEMPTS 10 +#define LOOPS 500 +#define NUM_ATTEMPTS 1000 + +static volatile int quit; + +static void +child_died(int sig __unused) +{ + + quit = 1; +} + +/* + * This test is intended to detect a leak of a file descriptor in the process + * following a failed non-blocking accept. It measures an available fd + * baseline, then performs 1000 failing accepts, then checks to see what the + * next fd is. It relies on sequential fd allocation, and will test for it + * briefly before beginning (not 100% reliable, but a good start). + */ +int +main(void) +{ + struct sockaddr_in sin; + socklen_t size; + pid_t child; + int fd1, fd2, fd3, i, listen_port, s, status; + + printf("1..2\n"); + + /* + * Check for sequential fd allocation, and give up early if not. + */ + fd1 = dup(STDIN_FILENO); + fd2 = dup(STDIN_FILENO); + if (fd2 != fd1 + 1) + errx(-1, "Non-sequential fd allocation\n"); + + s = socket(PF_INET, SOCK_STREAM, 0); + if (s == -1) + errx(-1, "socket: %s", strerror(errno)); + + bzero(&sin, sizeof(sin)); + sin.sin_len = sizeof(sin); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + + srandomdev(); + + for (i = 0; i < BIND_ATTEMPTS; i++) { + /* Pick a random unprivileged port 1025-65535 */ + listen_port = MAX((int)random() % 65535, 1025); + sin.sin_port = htons(listen_port); + if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) == 0) + break; + warn("bind with %d failed", listen_port); + usleep(1000); + } + if (i >= BIND_ATTEMPTS) { + printf("Bail out!\n"); + exit(1); + } + + if (listen(s, -1) != 0) + errx(-1, "listen: %s", strerror(errno)); + + i = fcntl(s, F_GETFL); + if (i == -1) + errx(-1, "ioctl(F_GETFL): %s", strerror(errno)); + i |= O_NONBLOCK; + if (fcntl(s, F_SETFL, i) != 0) + errx(-1, "ioctl(F_SETFL): %s", strerror(errno)); + i = fcntl(s, F_GETFL); + if (i == -1) + errx(-1, "ioctl(F_GETFL): %s", strerror(errno)); + if ((i & O_NONBLOCK) != O_NONBLOCK) + errx(-1, "Failed to set O_NONBLOCK (i=0x%x)\n", i); + + for (i = 0; i < LOOPS; i++) { + size = sizeof(sin); + if (accept(s, (struct sockaddr *)&sin, &size) != -1) + errx(-1, "accept succeeded\n"); + if (errno != EAGAIN) + errx(-1, "accept: %s", strerror(errno)); + } + + /* + * Allocate a file descriptor and make sure it's fd2+2. 2 because + * we allocate an fd for the socket. + */ + fd3 = dup(STDIN_FILENO); + if (fd3 != fd2 + 2) + printf("not ok 1 - (%d, %d, %d)\n", fd1, fd2, fd3); + else + printf("ok 1\n"); + + /* + * Try failing accept's w/o non-blocking where the destination + * address pointer is invalid. + */ + close(fd3); + signal(SIGCHLD, child_died); + child = fork(); + if (child < 0) + errx(-1, "fork: %s", strerror(errno)); + + /* + * Child process does `NUM_ATTEMPTS` connects. + */ + if (child == 0) { + close(fd1); + close(fd2); + close(s); + + bzero(&sin, sizeof(sin)); + sin.sin_len = sizeof(sin); + sin.sin_family = AF_INET; + sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + sin.sin_port = htons(listen_port); + + for (i = 0; i < NUM_ATTEMPTS; i++) { + s = socket(PF_INET, SOCK_STREAM, 0); + if (s == -1) + errx(-1, "socket: %s", strerror(errno)); + if (connect(s, (struct sockaddr *)&sin, + sizeof(sin)) < 0) + errx(-1, "connect: %s", strerror(errno)); + close(s); + } + _exit(0); + } + + /* Reset back to a blocking socket. */ + i = fcntl(s, F_GETFL); + if (i == -1) + errx(-1, "ioctl(F_GETFL): %s", strerror(errno)); + i &= ~O_NONBLOCK; + if (fcntl(s, F_SETFL, i) != 0) + errx(-1, "ioctl(F_SETFL): %s", strerror(errno)); + i = fcntl(s, F_GETFL); + if (i == -1) + errx(-1, "ioctl(F_GETFL): %s", strerror(errno)); + if (i & O_NONBLOCK) + errx(-1, "Failed to clear O_NONBLOCK (i=0x%x)\n", i); + + /* Do `NUM_ATTEMPTS` accepts with an invalid pointer. */ + for (i = 0; !quit && i < NUM_ATTEMPTS; i++) { + size = sizeof(sin); + if (accept(s, (struct sockaddr *)(uintptr_t)(0x100), + &size) != -1) + errx(-1, "accept succeeded\n"); + if (errno != EFAULT) + errx(-1, "accept: %s", strerror(errno)); + } + + if (waitpid(child, &status, 0) < 0) + errx(-1, "waitpid: %s", strerror(errno)); + if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) + warnx("child process died"); + + /* + * Allocate a file descriptor and make sure it's fd2+2. 2 because + * we allocate an fd for the socket. + */ + fd3 = dup(STDIN_FILENO); + if (fd3 != fd2 + 2) + printf("not ok 2 - (%d, %d, %d)\n", fd1, fd2, fd3); + else + printf("ok 2\n"); + + return (0); +} Copied: user/ngie/more-tests/tests/sys/sockets/accf_data_attach_test.c (from r281404, head/tools/regression/sockets/accf_data_attach/accf_data_attach.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/ngie/more-tests/tests/sys/sockets/accf_data_attach_test.c Sat Apr 11 08:57:31 2015 (r281424, copy of r281404, head/tools/regression/sockets/accf_data_attach/accf_data_attach.c) @@ -0,0 +1,216 @@ +/*- + * Copyright (c) 2004 Robert N. M. Watson + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#define ACCF_NAME "dataready" + +/* + * A number of small tests to confirm that attaching ACCF_DATA accept filters + * to inet4 ports works as expected. We test: + * + * - That no accept filter is attached on a newly created socket. + * - That bind() has no affect on the accept filter state. + * - That we can't attach an accept filter to a socket that isn't in the + * listen state. + * - That after we fail to attach the filter, querying the kernel shows no + * filter attached. + * - That we can attach an accept filter to a socket that is in the listen + * state. + * - That once an accept filter is attached, we can query to make sure it is + * attached. + * - That once an accept filter is attached, we can remove it and query to + * make sure it is removed. + */ +int +main(void) +{ + struct accept_filter_arg afa; + struct sockaddr_in sin; + socklen_t len; + int lso, ret; + + printf("1..11\n"); + + /* + * Step 0. Open socket(). + */ + lso = socket(PF_INET, SOCK_STREAM, 0); + if (lso == -1) + errx(-1, "not ok 1 - socket: %s", strerror(errno)); + printf("ok 1 - socket\n"); + + /* + * Step 1. After socket(). Should return EINVAL, since no accept + * filter should be attached. + */ + bzero(&afa, sizeof(afa)); + len = sizeof(afa); + ret = getsockopt(lso, SOL_SOCKET, SO_ACCEPTFILTER, &afa, &len); + if (ret != -1) + errx(-1, "not ok 2 - getsockopt() after socket() succeeded"); + if (errno != EINVAL) + errx(-1, "not ok 2 - getsockopt() after socket() failed with " + "%d (%s)", errno, strerror(errno)); + printf("ok 2 - getsockopt\n"); + + /* + * Step 2. Bind(). Ideally this will succeed. + */ + bzero(&sin, sizeof(sin)); + sin.sin_len = sizeof(sin); + sin.sin_family = AF_INET; + sin.sin_port = htons(8080); + sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); + if (bind(lso, (struct sockaddr *)&sin, sizeof(sin)) < 0) + errx(-1, "not ok 3 - bind %s", strerror(errno)); + printf("ok 3 - bind\n"); + + /* + * Step 3: After bind(). getsockopt() should return EINVAL, since no + * accept filter should be attached. + */ + len = sizeof(afa); + ret = getsockopt(lso, SOL_SOCKET, SO_ACCEPTFILTER, &afa, &len); + if (ret != -1) + errx(-1, "not ok 4 - getsockopt() after bind() succeeded"); + if (errno != EINVAL) + errx(-1, "not ok 4 - getsockopt() after bind() failed with %d (%s)", + errno, strerror(errno)); + printf("ok 4 - getsockopt\n"); + + /* + * Step 4: Setsockopt() before listen(). Should fail, since it's not + * yet a listen() socket. + */ + bzero(&afa, sizeof(afa)); + strcpy(afa.af_name, ACCF_NAME); + ret = setsockopt(lso, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa)); + if (ret == 0) + errx(-1, "not ok 5 - setsockopt() before listen() succeeded"); + printf("ok 5 - setsockopt\n"); + + /* + * Step 5: Getsockopt() after pre-listen() setsockopt(). Should + * fail with EINVAL, since setsockopt() should have failed. + */ + len = sizeof(afa); + ret = getsockopt(lso, SOL_SOCKET, SO_ACCEPTFILTER, &afa, &len); + if (ret == 0) + errx(-1, "not ok 6 - getsockopt() after pre-listen() setsockopt() " + "succeeded"); + if (errno != EINVAL) + errx(-1, "not ok 6 - pre-listen() getsockopt() failed with %d (%s)", + errno, strerror(errno)); + printf("ok 6 - getsockopt\n"); + + /* + * Step 6: listen(). + */ + if (listen(lso, -1) < 0) + errx(-1, "not ok 7 - listen: %s", strerror(errno)); + printf("ok 7 - listen\n"); + + /* + * Step 7: Getsockopt() after listen(). Should fail with EINVAL, + * since we have not installed accept filter yet. + */ + len = sizeof(afa); + ret = getsockopt(lso, SOL_SOCKET, SO_ACCEPTFILTER, &afa, &len); + if (ret == 0) + errx(-1, "not ok 8 - getsockopt() after listen() but before " + "setsockopt() succeeded"); + if (errno != EINVAL) + errx(-1, "not ok 8 - getsockopt() after listen() but before " + "setsockopt() failed with %d (%s)", errno, strerror(errno)); + printf("ok 8 - getsockopt\n"); + + /* + * Step 8: After listen(). This call to setsockopt() should succeed. + */ + bzero(&afa, sizeof(afa)); + strcpy(afa.af_name, ACCF_NAME); + ret = setsockopt(lso, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa)); + if (ret != 0) + errx(-1, "not ok 9 - setsockopt() after listen() failed with %d " + "(%s)", errno, strerror(errno)); + printf("ok 9 - setsockopt\n"); + + /* + * Step 9: After setsockopt(). Should succeed and identify + * ACCF_NAME. + */ + bzero(&afa, sizeof(afa)); + len = sizeof(afa); + ret = getsockopt(lso, SOL_SOCKET, SO_ACCEPTFILTER, &afa, &len); + if (ret != 0) + errx(-1, "not ok 10 - getsockopt() after listen() setsockopt() " + "failed with %d (%s)", errno, strerror(errno)); + if (len != sizeof(afa)) + errx(-1, "not ok 10 - getsockopt() after setsockopet() after " + "listen() returned wrong size (got %d expected %zd)", len, + sizeof(afa)); + if (strcmp(afa.af_name, ACCF_NAME) != 0) + errx(-1, "not ok 10 - getsockopt() after setsockopt() after " + "listen() mismatch (got %s expected %s)", afa.af_name, + ACCF_NAME); + printf("ok 10 - getsockopt\n"); + + /* + * Step 10: Remove accept filter. After removing the accept filter + * getsockopt() should fail with EINVAL. + */ + ret = setsockopt(lso, SOL_SOCKET, SO_ACCEPTFILTER, NULL, 0); + if (ret != 0) + errx(-1, "not ok 11 - setsockopt() after listen() " + "failed with %d (%s)", errno, strerror(errno)); + bzero(&afa, sizeof(afa)); + len = sizeof(afa); + ret = getsockopt(lso, SOL_SOCKET, SO_ACCEPTFILTER, &afa, &len); + if (ret == 0) + errx(-1, "not ok 11 - getsockopt() after removing " + "the accept filter returns valid accept filter %s", + afa.af_name); + if (errno != EINVAL) + errx(-1, "not ok 11 - getsockopt() after removing the accept" + "filter failed with %d (%s)", errno, strerror(errno)); + printf("ok 11 - setsockopt\n"); + + close(lso); + return (0); +} Copied: user/ngie/more-tests/tests/sys/sockets/fstat_test.c (from r281404, head/tools/regression/sockets/fstat/fstat.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/ngie/more-tests/tests/sys/sockets/fstat_test.c Sat Apr 11 08:57:31 2015 (r281424, copy of r281404, head/tools/regression/sockets/fstat/fstat.c) @@ -0,0 +1,71 @@ +/*- + * Copyright (c) 2008 Robert N. M. Watson + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include + +#include +#include + +/* + * Basic test to make sure that fstat(2) returns success on various socket + * types. In the future we should also validate the fields, confirming + * expected results such as the effect of shutdown(2) on permissions, etc. + */ + +static void +dotest(int domain, int type, int protocol) +{ + struct stat sb; + int sock; + + sock = socket(domain, type, protocol); + if (sock < 0) + err(-1, "socket(%d, %d, %d)", domain, type, protocol); + + if (fstat(sock, &sb) < 0) + err(-1, "fstat on socket(%d, %d, %d)", domain, type, + protocol); + + close(sock); +} + +int +main(void) +{ + + dotest(PF_INET, SOCK_DGRAM, 0); + dotest(PF_INET, SOCK_STREAM, 0); + dotest(PF_INET6, SOCK_DGRAM, 0); + dotest(PF_INET6, SOCK_STREAM, 0); + dotest(PF_LOCAL, SOCK_DGRAM, 0); + dotest(PF_LOCAL, SOCK_STREAM, 0); + + return (0); +} Copied: user/ngie/more-tests/tests/sys/sockets/kqueue_test.c (from r281404, head/tools/regression/sockets/kqueue/kqueue.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/ngie/more-tests/tests/sys/sockets/kqueue_test.c Sat Apr 11 08:57:31 2015 (r281424, copy of r281404, head/tools/regression/sockets/kqueue/kqueue.c) @@ -0,0 +1,368 @@ +/*- + * Copyright (c) 2004 Robert N. M. Watson + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +static int curtest = 1; + +/*- + * This test uses UNIX domain socket pairs to perform some basic exercising + * of kqueue functionality on sockets. In particular, testing that for read + * and write filters, we see the correct detection of whether reads and + * writes should actually be able to occur. + * + * TODO: + * - Test read/write filters for listen/accept sockets. + * - Handle the XXXRW below regarding datagram sockets. + * - Test that watermark/buffer size "data" fields returned by kqueue are + * correct. + * - Check that kqueue does something sensible when the remote endpoing is + * closed. + */ + +#define OK(testname) printf("ok %d - %s\n", curtest, testname); \ + curtest++; + +static void +fail(int error, const char *func, const char *socktype, const char *rest) +{ + + printf("not ok %d\n", curtest); + + if (socktype == NULL) + printf("# %s(): %s\n", func, strerror(error)); + else if (rest == NULL) + printf("# %s(%s): %s\n", func, socktype, + strerror(error)); + else + printf("# %s(%s, %s): %s\n", func, socktype, rest, + strerror(error)); + exit(-1); +} + +static void +fail_assertion(const char *func, const char *socktype, const char *rest, + const char *assertion) +{ + + printf("not ok %d - %s\n", curtest, assertion); + + if (socktype == NULL) + printf("# %s(): assertion %s failed\n", func, + assertion); + else if (rest == NULL) + printf("# %s(%s): assertion %s failed\n", func, + socktype, assertion); + else + printf("# %s(%s, %s): assertion %s failed\n", func, + socktype, rest, assertion); + exit(-1); +} + +/* + * Test read kevent on a socket pair: check to make sure endpoint 0 isn't + * readable when we start, then write to endpoint 1 and confirm that endpoint + * 0 is now readable. Drain the write, then check that it's not readable + * again. Use non-blocking kqueue operations and socket operations. + */ +static void +test_evfilt_read(int kq, int fd[2], const char *socktype) +{ + struct timespec ts; + struct kevent ke; + ssize_t len; + char ch; + int i; + + EV_SET(&ke, fd[0], EVFILT_READ, EV_ADD, 0, 0, NULL); + if (kevent(kq, &ke, 1, NULL, 0, NULL) == -1) + fail(errno, "kevent", socktype, "EVFILT_READ, EV_ADD"); + OK("EVFILT_READ, EV_ADD"); + + /* + * Confirm not readable to begin with, no I/O yet. + */ + ts.tv_sec = 0; + ts.tv_nsec = 0; + i = kevent(kq, NULL, 0, &ke, 1, &ts); + if (i == -1) + fail(errno, "kevent", socktype, "EVFILT_READ"); + OK("EVFILT_READ"); + if (i != 0) + fail_assertion("kevent", socktype, "EVFILT_READ", + "empty socket unreadable"); + OK("empty socket unreadable"); + + /* + * Write a byte to one end. + */ + ch = 'a'; + len = write(fd[1], &ch, sizeof(ch)); + if (len == -1) + fail(errno, "write", socktype, NULL); + OK("write one byte"); + if (len != sizeof(ch)) + fail_assertion("write", socktype, NULL, "write length"); + OK("write one byte length"); + + /* + * Other end should now be readable. + */ + ts.tv_sec = 0; + ts.tv_nsec = 0; + i = kevent(kq, NULL, 0, &ke, 1, &ts); + if (i == -1) + fail(errno, "kevent", socktype, "EVFILT_READ"); + OK("EVFILT_READ"); + if (i != 1) + fail_assertion("kevent", socktype, "EVFILT_READ", + "non-empty socket unreadable"); + OK("non-empty socket unreadable"); + + /* + * Read a byte to clear the readable state. + */ + len = read(fd[0], &ch, sizeof(ch)); + if (len == -1) + fail(errno, "read", socktype, NULL); + OK("read one byte"); + if (len != sizeof(ch)) + fail_assertion("read", socktype, NULL, "read length"); + OK("read one byte length"); + + /* + * Now re-check for readability. + */ + ts.tv_sec = 0; + ts.tv_nsec = 0; + i = kevent(kq, NULL, 0, &ke, 1, &ts); + if (i == -1) + fail(errno, "kevent", socktype, "EVFILT_READ"); + OK("EVFILT_READ"); + if (i != 0) + fail_assertion("kevent", socktype, "EVFILT_READ", + "empty socket unreadable"); + OK("empty socket unreadable"); + + EV_SET(&ke, fd[0], EVFILT_READ, EV_DELETE, 0, 0, NULL); + if (kevent(kq, &ke, 1, NULL, 0, NULL) == -1) + fail(errno, "kevent", socktype, "EVFILT_READ, EV_DELETE"); + OK("EVFILT_READ, EV_DELETE"); +} + +static void +test_evfilt_write(int kq, int fd[2], const char *socktype) +{ + struct timespec ts; + struct kevent ke; + ssize_t len; + char ch; + int i; + + EV_SET(&ke, fd[0], EVFILT_WRITE, EV_ADD, 0, 0, NULL); + if (kevent(kq, &ke, 1, NULL, 0, NULL) == -1) + fail(errno, "kevent", socktype, "EVFILT_WRITE, EV_ADD"); + OK("EVFILE_WRITE, EV_ADD"); + + /* + * Confirm writable to begin with, no I/O yet. + */ + ts.tv_sec = 0; + ts.tv_nsec = 0; + i = kevent(kq, NULL, 0, &ke, 1, &ts); + if (i == -1) + fail(errno, "kevent", socktype, "EVFILT_WRITE"); + OK("EVFILE_WRITE"); + if (i != 1) + fail_assertion("kevent", socktype, "EVFILT_WRITE", + "empty socket unwritable"); + OK("empty socket unwritable"); + + /* + * Write bytes into the socket until we can't write anymore. + */ + ch = 'a'; + while ((len = write(fd[0], &ch, sizeof(ch))) == sizeof(ch)) {}; + if (len == -1 && errno != EAGAIN && errno != ENOBUFS) + fail(errno, "write", socktype, NULL); + OK("write"); + if (len != -1 && len != sizeof(ch)) + fail_assertion("write", socktype, NULL, "write length"); + OK("write length"); + + /* + * Check to make sure the socket is no longer writable. + */ + ts.tv_sec = 0; + ts.tv_nsec = 0; + i = kevent(kq, NULL, 0, &ke, 1, &ts); + if (i == -1) + fail(errno, "kevent", socktype, "EVFILT_WRITE"); + OK("EVFILT_WRITE"); + if (i != 0) + fail_assertion("kevent", socktype, "EVFILT_WRITE", + "full socket writable"); + OK("full socket writable"); + + EV_SET(&ke, fd[0], EVFILT_WRITE, EV_DELETE, 0, 0, NULL); + if (kevent(kq, &ke, 1, NULL, 0, NULL) == -1) + fail(errno, "kevent", socktype, "EVFILT_WRITE, EV_DELETE"); + OK("EVFILT_WRITE, EV_DELETE"); +} + +/* + * Basic registration exercise for kqueue(2). Create several types/brands of + * sockets, and confirm that we can register for various events on them. + */ +int +main(void) +{ + int kq, sv[2]; *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-user@FreeBSD.ORG Sat Apr 11 09:05:01 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D938E3C7; Sat, 11 Apr 2015 09:05:01 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C47D0764; Sat, 11 Apr 2015 09:05:01 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3B951VH091580; Sat, 11 Apr 2015 09:05:01 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3B951JK091579; Sat, 11 Apr 2015 09:05:01 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201504110905.t3B951JK091579@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 11 Apr 2015 09:05:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r281425 - user/ngie/more-tests/tests/sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Apr 2015 09:05:01 -0000 Author: ngie Date: Sat Apr 11 09:05:00 2015 New Revision: 281425 URL: https://svnweb.freebsd.org/changeset/base/281425 Log: Turn on test building/installation here Modified: user/ngie/more-tests/tests/sys/Makefile Modified: user/ngie/more-tests/tests/sys/Makefile ============================================================================== --- user/ngie/more-tests/tests/sys/Makefile Sat Apr 11 08:57:31 2015 (r281424) +++ user/ngie/more-tests/tests/sys/Makefile Sat Apr 11 09:05:00 2015 (r281425) @@ -7,6 +7,7 @@ TESTSDIR= ${TESTSBASE}/sys TESTS_SUBDIRS+= kern TESTS_SUBDIRS+= netinet TESTS_SUBDIRS+= opencrypto +TESTS_SUBDIRS+= sockets # Items not integrated into kyua runs by default SUBDIR+= pjdfstest From owner-svn-src-user@FreeBSD.ORG Sat Apr 11 09:05:44 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E370C4AE; Sat, 11 Apr 2015 09:05:44 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B4F18768; Sat, 11 Apr 2015 09:05:44 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3B95iQV091709; Sat, 11 Apr 2015 09:05:44 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3B95hKR091705; Sat, 11 Apr 2015 09:05:43 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201504110905.t3B95hKR091705@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 11 Apr 2015 09:05:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r281426 - in user/ngie/more-tests: etc/mtree tests/sys tests/sys/vfs tools/regression/vfs X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Apr 2015 09:05:45 -0000 Author: ngie Date: Sat Apr 11 09:05:42 2015 New Revision: 281426 URL: https://svnweb.freebsd.org/changeset/base/281426 Log: Integration tools/regression/vfs into the FreeBSD test suite Added: user/ngie/more-tests/tests/sys/vfs/ user/ngie/more-tests/tests/sys/vfs/Makefile (contents, props changed) user/ngie/more-tests/tests/sys/vfs/trailing_slash_test.sh - copied, changed from r281415, user/ngie/more-tests/tools/regression/vfs/trailing_slash.t Deleted: user/ngie/more-tests/tools/regression/vfs/ Modified: user/ngie/more-tests/etc/mtree/BSD.tests.dist user/ngie/more-tests/tests/sys/Makefile Modified: user/ngie/more-tests/etc/mtree/BSD.tests.dist ============================================================================== --- user/ngie/more-tests/etc/mtree/BSD.tests.dist Sat Apr 11 09:05:00 2015 (r281425) +++ user/ngie/more-tests/etc/mtree/BSD.tests.dist Sat Apr 11 09:05:42 2015 (r281426) @@ -394,6 +394,8 @@ .. socket .. + vfs + .. .. usr.bin apply Modified: user/ngie/more-tests/tests/sys/Makefile ============================================================================== --- user/ngie/more-tests/tests/sys/Makefile Sat Apr 11 09:05:00 2015 (r281425) +++ user/ngie/more-tests/tests/sys/Makefile Sat Apr 11 09:05:42 2015 (r281426) @@ -8,6 +8,7 @@ TESTS_SUBDIRS+= kern TESTS_SUBDIRS+= netinet TESTS_SUBDIRS+= opencrypto TESTS_SUBDIRS+= sockets +TESTS_SUBDIRS+= vfs # Items not integrated into kyua runs by default SUBDIR+= pjdfstest Added: user/ngie/more-tests/tests/sys/vfs/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/ngie/more-tests/tests/sys/vfs/Makefile Sat Apr 11 09:05:42 2015 (r281426) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +TESTSDIR= ${TESTSBASE}/sys/vfs + +TAP_TESTS_SH+= trailing_slash_test + +.include Copied and modified: user/ngie/more-tests/tests/sys/vfs/trailing_slash_test.sh (from r281415, user/ngie/more-tests/tools/regression/vfs/trailing_slash.t) ============================================================================== --- user/ngie/more-tests/tools/regression/vfs/trailing_slash.t Sat Apr 11 08:27:38 2015 (r281415, copy source) +++ user/ngie/more-tests/tests/sys/vfs/trailing_slash_test.sh Sat Apr 11 09:05:42 2015 (r281426) @@ -6,8 +6,8 @@ # point to files. See kern/21768 for details. Fixed in r193028. # -testfile="/tmp/testfile-$$" -testlink="/tmp/testlink-$$" +testfile=$(mktemp tmp.XXXXXX) || exit +testlink="testlink-$$" tests=" $testfile:$testlink:$testfile:0 @@ -18,7 +18,6 @@ $testfile/:$testlink:$testlink:1 $testfile/:$testlink:$testlink/:1 " -touch $testfile || exit 1 trap "rm $testfile $testlink" EXIT set $tests From owner-svn-src-user@FreeBSD.ORG Sat Apr 11 09:15:35 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id ADFFE7CD; Sat, 11 Apr 2015 09:15:35 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 80947840; Sat, 11 Apr 2015 09:15:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3B9FZT2096566; Sat, 11 Apr 2015 09:15:35 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3B9FYgU096559; Sat, 11 Apr 2015 09:15:34 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201504110915.t3B9FYgU096559@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 11 Apr 2015 09:15:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r281427 - in user/ngie/more-tests: etc/mtree tests/sys tests/sys/kqueue tools/regression/kqueue X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Apr 2015 09:15:35 -0000 Author: ngie Date: Sat Apr 11 09:15:33 2015 New Revision: 281427 URL: https://svnweb.freebsd.org/changeset/base/281427 Log: Integrate tools/regression/kqueue into the FreeBSD test suite as tests/sys/kqueue Added: user/ngie/more-tests/tests/sys/kqueue/ - copied from r281415, user/ngie/more-tests/tools/regression/kqueue/ user/ngie/more-tests/tests/sys/kqueue/kqueue_test.sh (contents, props changed) Deleted: user/ngie/more-tests/tools/regression/kqueue/ Modified: user/ngie/more-tests/etc/mtree/BSD.tests.dist user/ngie/more-tests/tests/sys/Makefile user/ngie/more-tests/tests/sys/kqueue/Makefile Modified: user/ngie/more-tests/etc/mtree/BSD.tests.dist ============================================================================== --- user/ngie/more-tests/etc/mtree/BSD.tests.dist Sat Apr 11 09:05:42 2015 (r281426) +++ user/ngie/more-tests/etc/mtree/BSD.tests.dist Sat Apr 11 09:15:33 2015 (r281427) @@ -356,6 +356,8 @@ sys kern .. + kqueue + .. netinet .. opencrypto Modified: user/ngie/more-tests/tests/sys/Makefile ============================================================================== --- user/ngie/more-tests/tests/sys/Makefile Sat Apr 11 09:05:42 2015 (r281426) +++ user/ngie/more-tests/tests/sys/Makefile Sat Apr 11 09:15:33 2015 (r281427) @@ -5,6 +5,7 @@ TESTSDIR= ${TESTSBASE}/sys TESTS_SUBDIRS+= kern +TESTS_SUBDIRS+= kqueue TESTS_SUBDIRS+= netinet TESTS_SUBDIRS+= opencrypto TESTS_SUBDIRS+= sockets Modified: user/ngie/more-tests/tests/sys/kqueue/Makefile ============================================================================== --- user/ngie/more-tests/tools/regression/kqueue/Makefile Sat Apr 11 08:27:38 2015 (r281415) +++ user/ngie/more-tests/tests/sys/kqueue/Makefile Sat Apr 11 09:15:33 2015 (r281427) @@ -6,8 +6,14 @@ # libkqueue and test suite by Mark Heily # -PROG=kqtest -SRCS= \ +TAP_TESTS_SH= kqueue_test + +TESTSDIR= ${TESTSBASE}/sys/kqueue +BINDIR= ${TESTSDIR} + +PROGS= kqtest + +SRCS.kqtest= \ main.c \ read.c \ timer.c \ @@ -15,7 +21,6 @@ SRCS= \ proc.c \ signal.c \ user.c -MAN= WARNS?= 2 -.include "bsd.prog.mk" +.include Added: user/ngie/more-tests/tests/sys/kqueue/kqueue_test.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/ngie/more-tests/tests/sys/kqueue/kqueue_test.sh Sat Apr 11 09:15:33 2015 (r281427) @@ -0,0 +1,17 @@ +#!/bin/sh + +cd $(dirname $0) +i=1 +./kqtest | while read line; do + echo $line | grep -q passed + if [ $? -eq 0 ]; then + echo "ok - $i $line" + : $(( i += 1 )) + fi + + echo $line | grep -q 'tests completed' + if [ $? -eq 0 ]; then + echo -n "1.." + echo $line | cut -d' ' -f3 + fi +done From owner-svn-src-user@FreeBSD.ORG Sat Apr 11 09:20:23 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 5766C9C3; Sat, 11 Apr 2015 09:20:23 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 37B5A88F; Sat, 11 Apr 2015 09:20:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3B9KN20097229; Sat, 11 Apr 2015 09:20:23 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3B9KKLA097213; Sat, 11 Apr 2015 09:20:20 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201504110920.t3B9KKLA097213@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 11 Apr 2015 09:20:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r281428 - in user/ngie/more-tests: etc/mtree tests/sys/mqueue tests/sys/mqueue/mqtest1 tests/sys/mqueue/mqtest2 tests/sys/mqueue/mqtest3 tests/sys/mqueue/mqtest4 tests/sys/mqueue/mqtest... X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Apr 2015 09:20:23 -0000 Author: ngie Date: Sat Apr 11 09:20:20 2015 New Revision: 281428 URL: https://svnweb.freebsd.org/changeset/base/281428 Log: Integrate tools/regression/mqueue into the FreeBSD test suite as tests/sys/mqueue Added: user/ngie/more-tests/tests/sys/mqueue/ - copied from r281415, user/ngie/more-tests/tools/regression/mqueue/ user/ngie/more-tests/tests/sys/mqueue/mqtest1.c - copied, changed from r281415, user/ngie/more-tests/tools/regression/mqueue/mqtest1/mqtest1.c user/ngie/more-tests/tests/sys/mqueue/mqtest2.c - copied, changed from r281415, user/ngie/more-tests/tools/regression/mqueue/mqtest2/mqtest2.c user/ngie/more-tests/tests/sys/mqueue/mqtest3.c - copied, changed from r281415, user/ngie/more-tests/tools/regression/mqueue/mqtest3/mqtest3.c user/ngie/more-tests/tests/sys/mqueue/mqtest4.c - copied, changed from r281415, user/ngie/more-tests/tools/regression/mqueue/mqtest4/mqtest4.c user/ngie/more-tests/tests/sys/mqueue/mqtest5.c - copied, changed from r281415, user/ngie/more-tests/tools/regression/mqueue/mqtest5/mqtest5.c Deleted: user/ngie/more-tests/tests/sys/mqueue/mqtest1/ user/ngie/more-tests/tests/sys/mqueue/mqtest2/ user/ngie/more-tests/tests/sys/mqueue/mqtest3/ user/ngie/more-tests/tests/sys/mqueue/mqtest4/ user/ngie/more-tests/tests/sys/mqueue/mqtest5/ user/ngie/more-tests/tools/regression/mqueue/ Modified: user/ngie/more-tests/etc/mtree/BSD.tests.dist user/ngie/more-tests/tests/sys/mqueue/Makefile Modified: user/ngie/more-tests/etc/mtree/BSD.tests.dist ============================================================================== --- user/ngie/more-tests/etc/mtree/BSD.tests.dist Sat Apr 11 09:15:33 2015 (r281427) +++ user/ngie/more-tests/etc/mtree/BSD.tests.dist Sat Apr 11 09:20:20 2015 (r281428) @@ -358,6 +358,8 @@ .. kqueue .. + mqueue + .. netinet .. opencrypto Modified: user/ngie/more-tests/tests/sys/mqueue/Makefile ============================================================================== --- user/ngie/more-tests/tools/regression/mqueue/Makefile Sat Apr 11 08:27:38 2015 (r281415) +++ user/ngie/more-tests/tests/sys/mqueue/Makefile Sat Apr 11 09:20:20 2015 (r281428) @@ -1,5 +1,20 @@ # $FreeBSD$ -SUBDIR=mqtest1 mqtest2 mqtest3 mqtest4 mqtest5 +TESTSDIR= ${TESTSBASE}/sys/mqueue -.include +ATF_TESTS_SH= mqueue_test + +BINDIR= ${TESTSDIR} + +PROGS+= mqtest1 +PROGS+= mqtest2 +PROGS+= mqtest3 +PROGS+= mqtest4 +PROGS+= mqtest5 + +LDADD+= -lrt +DPADD+= ${LIBRT} + +WARNS?= 6 + +.include Copied and modified: user/ngie/more-tests/tests/sys/mqueue/mqtest1.c (from r281415, user/ngie/more-tests/tools/regression/mqueue/mqtest1/mqtest1.c) ============================================================================== --- user/ngie/more-tests/tools/regression/mqueue/mqtest1/mqtest1.c Sat Apr 11 08:27:38 2015 (r281415, copy source) +++ user/ngie/more-tests/tests/sys/mqueue/mqtest1.c Sat Apr 11 09:20:20 2015 (r281428) @@ -9,7 +9,8 @@ #define MQNAME "/mytstqueue1" -int main() +int +main(void) { struct mq_attr attr, attr2; struct sigevent sigev; Copied and modified: user/ngie/more-tests/tests/sys/mqueue/mqtest2.c (from r281415, user/ngie/more-tests/tools/regression/mqueue/mqtest2/mqtest2.c) ============================================================================== --- user/ngie/more-tests/tools/regression/mqueue/mqtest2/mqtest2.c Sat Apr 11 08:27:38 2015 (r281415, copy source) +++ user/ngie/more-tests/tests/sys/mqueue/mqtest2.c Sat Apr 11 09:20:20 2015 (r281428) @@ -14,17 +14,20 @@ #define LOOPS 1000 #define PRIO 10 -void alarmhandler(int sig) +static void +alarmhandler(int sig __unused) { write(1, "timeout\n", 8); _exit(1); } -int main() +int +main(void) { struct mq_attr attr; mqd_t mq; - int status, pid; + int status; + pid_t pid; mq_unlink(MQNAME); @@ -38,8 +41,9 @@ int main() err(1, "mq_getattr"); pid = fork(); if (pid == 0) { /* child */ - int prio, j, i; char *buf; + int j, i; + unsigned int prio; mq_close(mq); @@ -69,7 +73,7 @@ int main() err(1, "fork()"); } else { char *buf; - int i, j, prio; + int i, j; signal(SIGALRM, alarmhandler); buf = malloc(attr.mq_msgsize); Copied and modified: user/ngie/more-tests/tests/sys/mqueue/mqtest3.c (from r281415, user/ngie/more-tests/tools/regression/mqueue/mqtest3/mqtest3.c) ============================================================================== --- user/ngie/more-tests/tools/regression/mqueue/mqtest3/mqtest3.c Sat Apr 11 08:27:38 2015 (r281415, copy source) +++ user/ngie/more-tests/tests/sys/mqueue/mqtest3.c Sat Apr 11 09:20:20 2015 (r281428) @@ -15,19 +15,21 @@ #define LOOPS 1000 #define PRIO 10 -void sighandler(int sig) +static void +sighandler(int sig __unused) { write(1, "timeout\n", 8); _exit(1); } -int main() +int +main(void) { - mqd_t mq; - int status; - struct mq_attr attr; - int pid; fd_set set; + struct mq_attr attr; + int status; + mqd_t mq; + pid_t pid; mq_unlink(MQNAME); @@ -42,8 +44,9 @@ int main() pid = fork(); if (pid == 0) { /* child */ - int prio, j, i; char *buf; + int j, i; + unsigned int prio; mq_close(mq); @@ -77,7 +80,7 @@ int main() err(1, "fork()"); } else { char *buf; - int i, j, prio; + int i, j; signal(SIGALRM, sighandler); buf = malloc(attr.mq_msgsize); Copied and modified: user/ngie/more-tests/tests/sys/mqueue/mqtest4.c (from r281415, user/ngie/more-tests/tools/regression/mqueue/mqtest4/mqtest4.c) ============================================================================== --- user/ngie/more-tests/tools/regression/mqueue/mqtest4/mqtest4.c Sat Apr 11 08:27:38 2015 (r281415, copy source) +++ user/ngie/more-tests/tests/sys/mqueue/mqtest4.c Sat Apr 11 09:20:20 2015 (r281428) @@ -16,21 +16,21 @@ #define LOOPS 1000 #define PRIO 10 -void sighandler(int sig) +static void +sighandler(int sig __unused) { write(1, "timeout\n", 8); _exit(1); } -int main() +int +main(void) { - mqd_t mq; - int status; - struct mq_attr attr; - int pid; - fd_set set; - int kq; struct kevent kev; + struct mq_attr attr; + mqd_t mq; + int kq, status; + pid_t pid; mq_unlink(MQNAME); @@ -44,8 +44,9 @@ int main() err(1, "mq_getattr()"); pid = fork(); if (pid == 0) { /* child */ - int prio, j, i; char *buf; + int j, i; + unsigned int prio; mq_close(mq); kq = kqueue(); @@ -80,7 +81,7 @@ int main() err(1, "fork()"); } else { char *buf; - int i, j, prio; + int i, j; signal(SIGALRM, sighandler); kq = kqueue(); Copied and modified: user/ngie/more-tests/tests/sys/mqueue/mqtest5.c (from r281415, user/ngie/more-tests/tools/regression/mqueue/mqtest5/mqtest5.c) ============================================================================== --- user/ngie/more-tests/tools/regression/mqueue/mqtest5/mqtest5.c Sat Apr 11 08:27:38 2015 (r281415, copy source) +++ user/ngie/more-tests/tests/sys/mqueue/mqtest5.c Sat Apr 11 09:20:20 2015 (r281428) @@ -16,21 +16,23 @@ #define LOOPS 1000 #define PRIO 10 -void sighandler(int sig) +static void +sighandler(int sig __unused) { write(1, "timeout\n", 8); _exit(1); } -int main() +int +main(void) { - mqd_t mq; int status; struct mq_attr attr; - int pid; - sigset_t set; struct sigaction sa; + sigset_t set; siginfo_t info; + mqd_t mq; + pid_t pid; mq_unlink(MQNAME); @@ -95,7 +97,7 @@ int main() err(1, "fork()"); } else { char *buf; - int i, j, prio; + int i, j; signal(SIGALRM, sighandler); buf = malloc(attr.mq_msgsize); From owner-svn-src-user@FreeBSD.ORG Sat Apr 11 09:28:14 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2CA69BF2; Sat, 11 Apr 2015 09:28:14 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F1BE8958; Sat, 11 Apr 2015 09:28:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3B9SDoi001878; Sat, 11 Apr 2015 09:28:13 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3B9SCrc001874; Sat, 11 Apr 2015 09:28:12 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201504110928.t3B9SCrc001874@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 11 Apr 2015 09:28:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r281429 - in user/ngie/more-tests: etc/mtree tests/sys tests/sys/posixshm tools/regression/posixshm X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Apr 2015 09:28:14 -0000 Author: ngie Date: Sat Apr 11 09:28:11 2015 New Revision: 281429 URL: https://svnweb.freebsd.org/changeset/base/281429 Log: Integrate tools/regression/posixshm into the FreeBSD test suite as tests/sys/posixshm Added: user/ngie/more-tests/tests/sys/posixshm/ - copied from r281415, user/ngie/more-tests/tools/regression/posixshm/ Deleted: user/ngie/more-tests/tests/sys/posixshm/posixshm.t user/ngie/more-tests/tools/regression/posixshm/ Modified: user/ngie/more-tests/etc/mtree/BSD.tests.dist user/ngie/more-tests/tests/sys/Makefile user/ngie/more-tests/tests/sys/posixshm/Makefile user/ngie/more-tests/tests/sys/posixshm/posixshm.c Modified: user/ngie/more-tests/etc/mtree/BSD.tests.dist ============================================================================== --- user/ngie/more-tests/etc/mtree/BSD.tests.dist Sat Apr 11 09:20:20 2015 (r281428) +++ user/ngie/more-tests/etc/mtree/BSD.tests.dist Sat Apr 11 09:28:11 2015 (r281429) @@ -364,6 +364,8 @@ .. opencrypto .. + posixshm + .. pjdfstest chflags .. Modified: user/ngie/more-tests/tests/sys/Makefile ============================================================================== --- user/ngie/more-tests/tests/sys/Makefile Sat Apr 11 09:20:20 2015 (r281428) +++ user/ngie/more-tests/tests/sys/Makefile Sat Apr 11 09:28:11 2015 (r281429) @@ -8,6 +8,7 @@ TESTS_SUBDIRS+= kern TESTS_SUBDIRS+= kqueue TESTS_SUBDIRS+= netinet TESTS_SUBDIRS+= opencrypto +TESTS_SUBDIRS+= posixshm TESTS_SUBDIRS+= sockets TESTS_SUBDIRS+= vfs Modified: user/ngie/more-tests/tests/sys/posixshm/Makefile ============================================================================== --- user/ngie/more-tests/tools/regression/posixshm/Makefile Sat Apr 11 08:27:38 2015 (r281415) +++ user/ngie/more-tests/tests/sys/posixshm/Makefile Sat Apr 11 09:28:11 2015 (r281429) @@ -1,9 +1,10 @@ # $FreeBSD$ -PROG= posixshm -SRCS= posixshm.c test.c -MAN= +TESTSDIR= ${TESTSBASE}/sys/posixshm -WARNS?= 3 +TAP_TESTS_C= posixshm_test +SRCS.posixshm_test= posixshm.c test.c -.include +WARNS?= 6 + +.include Modified: user/ngie/more-tests/tests/sys/posixshm/posixshm.c ============================================================================== --- user/ngie/more-tests/tools/regression/posixshm/posixshm.c Sat Apr 11 08:27:38 2015 (r281415) +++ user/ngie/more-tests/tests/sys/posixshm/posixshm.c Sat Apr 11 09:28:11 2015 (r281429) @@ -619,7 +619,7 @@ test_object_resize(void) TEST(test_object_resize, "object resize"); int -main(int argc, char *argv[]) +main(void) { run_tests(); From owner-svn-src-user@FreeBSD.ORG Sat Apr 11 09:28:54 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DAD1ACD6; Sat, 11 Apr 2015 09:28:54 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C6FE095A; Sat, 11 Apr 2015 09:28:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3B9SsgW002003; Sat, 11 Apr 2015 09:28:54 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3B9SsL5002002; Sat, 11 Apr 2015 09:28:54 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201504110928.t3B9SsL5002002@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 11 Apr 2015 09:28:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r281430 - user/ngie/more-tests/tests/sys X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Apr 2015 09:28:54 -0000 Author: ngie Date: Sat Apr 11 09:28:53 2015 New Revision: 281430 URL: https://svnweb.freebsd.org/changeset/base/281430 Log: Add directory iteration piece for tests/sys/mqueue Modified: user/ngie/more-tests/tests/sys/Makefile Modified: user/ngie/more-tests/tests/sys/Makefile ============================================================================== --- user/ngie/more-tests/tests/sys/Makefile Sat Apr 11 09:28:11 2015 (r281429) +++ user/ngie/more-tests/tests/sys/Makefile Sat Apr 11 09:28:53 2015 (r281430) @@ -6,6 +6,7 @@ TESTSDIR= ${TESTSBASE}/sys TESTS_SUBDIRS+= kern TESTS_SUBDIRS+= kqueue +TESTS_SUBDIRS+= mqueue TESTS_SUBDIRS+= netinet TESTS_SUBDIRS+= opencrypto TESTS_SUBDIRS+= posixshm From owner-svn-src-user@FreeBSD.ORG Sat Apr 11 10:15:02 2015 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 23949555; Sat, 11 Apr 2015 10:15:02 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0A9AADD5; Sat, 11 Apr 2015 10:15:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3BAF28K025015; Sat, 11 Apr 2015 10:15:02 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3BAF0YK024955; Sat, 11 Apr 2015 10:15:00 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201504111015.t3BAF0YK024955@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Sat, 11 Apr 2015 10:15:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r281432 - in user/ngie/more-tests: etc/mtree tests/sys tests/sys/file tests/sys/file/closefrom tests/sys/file/dup tests/sys/file/fcntlflags tests/sys/file/flock tests/sys/file/ftruncate... X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Apr 2015 10:15:02 -0000 Author: ngie Date: Sat Apr 11 10:14:59 2015 New Revision: 281432 URL: https://svnweb.freebsd.org/changeset/base/281432 Log: Integrate tools/regression/file into the FreeBSD test suite as tests/sys/file Added: user/ngie/more-tests/tests/sys/file/ - copied from r281415, user/ngie/more-tests/tools/regression/file/ user/ngie/more-tests/tests/sys/file/closefrom_test.c - copied, changed from r281415, user/ngie/more-tests/tools/regression/file/closefrom/closefrom.c user/ngie/more-tests/tests/sys/file/dup_test.c - copied unchanged from r281415, user/ngie/more-tests/tools/regression/file/dup/dup.c user/ngie/more-tests/tests/sys/file/fcntlflags_test.c - copied unchanged from r281415, user/ngie/more-tests/tools/regression/file/fcntlflags/fcntlflags.c user/ngie/more-tests/tests/sys/file/flock_helper.c - copied unchanged from r281415, user/ngie/more-tests/tools/regression/file/flock/flock.c user/ngie/more-tests/tests/sys/file/flock_test.sh (contents, props changed) user/ngie/more-tests/tests/sys/file/ftruncate_test.c - copied, changed from r281415, user/ngie/more-tests/tools/regression/file/ftruncate/ftruncate.c user/ngie/more-tests/tests/sys/file/newfileops_on_fork_test.c - copied unchanged from r281415, user/ngie/more-tests/tools/regression/file/newfileops_on_fork/newfileops_on_fork.c Deleted: user/ngie/more-tests/tests/sys/file/closefrom/ user/ngie/more-tests/tests/sys/file/dup/ user/ngie/more-tests/tests/sys/file/fcntlflags/ user/ngie/more-tests/tests/sys/file/flock/ user/ngie/more-tests/tests/sys/file/ftruncate/ user/ngie/more-tests/tests/sys/file/newfileops_on_fork/ user/ngie/more-tests/tools/regression/file/closefrom/ user/ngie/more-tests/tools/regression/file/dup/ user/ngie/more-tests/tools/regression/file/fcntlflags/ user/ngie/more-tests/tools/regression/file/flock/ user/ngie/more-tests/tools/regression/file/ftruncate/ user/ngie/more-tests/tools/regression/file/newfileops_on_fork/ Modified: user/ngie/more-tests/etc/mtree/BSD.tests.dist user/ngie/more-tests/tests/sys/Makefile Modified: user/ngie/more-tests/etc/mtree/BSD.tests.dist ============================================================================== --- user/ngie/more-tests/etc/mtree/BSD.tests.dist Sat Apr 11 10:07:58 2015 (r281431) +++ user/ngie/more-tests/etc/mtree/BSD.tests.dist Sat Apr 11 10:14:59 2015 (r281432) @@ -354,6 +354,8 @@ .. .. sys + file + .. kern .. kqueue Modified: user/ngie/more-tests/tests/sys/Makefile ============================================================================== --- user/ngie/more-tests/tests/sys/Makefile Sat Apr 11 10:07:58 2015 (r281431) +++ user/ngie/more-tests/tests/sys/Makefile Sat Apr 11 10:14:59 2015 (r281432) @@ -4,6 +4,7 @@ TESTSDIR= ${TESTSBASE}/sys +TESTS_SUBDIRS+= file TESTS_SUBDIRS+= kern TESTS_SUBDIRS+= kqueue TESTS_SUBDIRS+= mqueue Copied and modified: user/ngie/more-tests/tests/sys/file/closefrom_test.c (from r281415, user/ngie/more-tests/tools/regression/file/closefrom/closefrom.c) ============================================================================== --- user/ngie/more-tests/tools/regression/file/closefrom/closefrom.c Sat Apr 11 08:27:38 2015 (r281415, copy source) +++ user/ngie/more-tests/tests/sys/file/closefrom_test.c Sat Apr 11 10:14:59 2015 (r281432) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -132,37 +133,37 @@ devnull(void) { int fd; - fd = open("/dev/null", O_RDONLY); + fd = open(_PATH_DEVNULL, O_RDONLY); if (fd < 0) - fail_err("open(\"/dev/null\")"); + fail_err("open(\" "_PATH_DEVNULL" \")"); return (fd); } int -main(int __unused argc, char __unused *argv[]) +main(void) { struct shared_info *info; pid_t pid; - int fd, i; + int fd, i, start; printf("1..15\n"); /* We better start up with fd's 0, 1, and 2 open. */ - fd = devnull(); - if (fd != 3) - fail("open", "bad descriptor %d", fd); + start = devnull(); + if (start == -1) + fail("open", "bad descriptor %d", start); ok("open"); /* Make sure highest_fd() works. */ fd = highest_fd(); - if (fd != 3) - fail("highest_fd", "bad descriptor %d", fd); + if (start != fd) + fail("highest_fd", "bad descriptor %d != %d", start, fd); ok("highest_fd"); /* Try to use closefrom() for just closing fd 3. */ - closefrom(3); + closefrom(start + 1); fd = highest_fd(); - if (fd != 2) + if (fd != start) fail("closefrom", "highest fd %d", fd); ok("closefrom"); @@ -170,7 +171,7 @@ main(int __unused argc, char __unused *a for (i = 0; i < 16; i++) (void)devnull(); fd = highest_fd(); - if (fd != 18) + if (fd != start + 16) fail("open 16", "highest fd %d", fd); ok("open 16"); @@ -269,6 +270,6 @@ main(int __unused argc, char __unused *a if (fd != 3) fail("closefrom", "highest fd %d", fd); ok("closefrom"); - + return (0); } Copied: user/ngie/more-tests/tests/sys/file/dup_test.c (from r281415, user/ngie/more-tests/tools/regression/file/dup/dup.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/ngie/more-tests/tests/sys/file/dup_test.c Sat Apr 11 10:14:59 2015 (r281432, copy of r281415, user/ngie/more-tests/tools/regression/file/dup/dup.c) @@ -0,0 +1,386 @@ +/* + * $OpenBSD: dup2test.c,v 1.3 2003/07/31 21:48:08 deraadt Exp $ + * $OpenBSD: dup2_self.c,v 1.3 2003/07/31 21:48:08 deraadt Exp $ + * $OpenBSD: fcntl_dup.c,v 1.2 2003/07/31 21:48:08 deraadt Exp $ + * + * Written by Artur Grabowski 2002 Public Domain. + * + * $FreeBSD$ + */ + +/* + * Test #1: check if dup(2) works. + * Test #2: check if dup2(2) works. + * Test #3: check if dup2(2) returned a fd we asked for. + * Test #4: check if dup2(2) cleared close-on-exec flag for duped fd. + * Test #5: check if dup2(2) allows to dup fd to itself. + * Test #6: check if dup2(2) returned a fd we asked for. + * Test #7: check if dup2(2) did not clear close-on-exec flag for duped fd. + * Test #8: check if fcntl(F_DUPFD) works. + * Test #9: check if fcntl(F_DUPFD) cleared close-on-exec flag for duped fd. + * Test #10: check if dup2() to a fd > current maximum number of open files + * limit work. + * Test #11: check if fcntl(F_DUP2FD) works. + * Test #12: check if fcntl(F_DUP2FD) returned a fd we asked for. + * Test #13: check if fcntl(F_DUP2FD) cleared close-on-exec flag for duped fd. + * Test #14: check if fcntl(F_DUP2FD) allows to dup fd to itself. + * Test #15: check if fcntl(F_DUP2FD) returned a fd we asked for. + * Test #16: check if fcntl(F_DUP2FD) did not clear close-on-exec flag for + * duped fd. + * Test #17: check if fcntl(F_DUP2FD) to a fd > current maximum number of open + * files limit work. + * Test #18: check if fcntl(F_DUPFD_CLOEXEC) works. + * Test #19: check if fcntl(F_DUPFD_CLOEXEC) set close-on-exec flag for duped + * fd. + * Test #20: check if fcntl(F_DUP2FD_CLOEXEC) works. + * Test #21: check if fcntl(F_DUP2FD_CLOEXEC) returned a fd we asked for. + * Test #22: check if fcntl(F_DUP2FD_CLOEXEC) set close-on-exec flag for duped + * fd. + * Test #23: check if fcntl(F_DUP2FD_CLOEXEC) to a fd > current maximum number + * of open files limit work. + * Test #24: check if dup3(O_CLOEXEC) works. + * Test #25: check if dup3(O_CLOEXEC) returned a fd we asked for. + * Test #26: check if dup3(O_CLOEXEC) set close-on-exec flag for duped fd. + * Test #27: check if dup3(0) works. + * Test #28: check if dup3(0) returned a fd we asked for. + * Test #29: check if dup3(0) cleared close-on-exec flag for duped fd. + * Test #30: check if dup3(O_CLOEXEC) fails if oldfd == newfd. + * Test #31: check if dup3(0) fails if oldfd == newfd. + * Test #32: check if dup3(O_CLOEXEC) to a fd > current maximum number of + * open files limit work. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +static int getafile(void); + +static int +getafile(void) +{ + int fd; + + char temp[] = "/tmp/dup2XXXXXXXXX"; + if ((fd = mkstemp(temp)) < 0) + err(1, "mkstemp"); + remove(temp); + if (ftruncate(fd, 1024) != 0) + err(1, "ftruncate"); + return (fd); +} + +int +main(int __unused argc, char __unused *argv[]) +{ + struct rlimit rlp; + int orgfd, fd1, fd2, test = 0; + + orgfd = getafile(); + + printf("1..32\n"); + + /* If dup(2) ever work? */ + if ((fd1 = dup(orgfd)) < 0) + err(1, "dup"); + printf("ok %d - dup(2) works\n", ++test); + + /* Set close-on-exec */ + if (fcntl(fd1, F_SETFD, 1) != 0) + err(1, "fcntl(F_SETFD)"); + + /* If dup2(2) ever work? */ + if ((fd2 = dup2(fd1, fd1 + 1)) < 0) + err(1, "dup2"); + printf("ok %d - dup2(2) works\n", ++test); + + /* Do we get the right fd? */ + ++test; + if (fd2 != fd1 + 1) + printf("no ok %d - dup2(2) didn't give us the right fd\n", + test); + else + printf("ok %d - dup2(2) returned a correct fd\n", test); + + /* Was close-on-exec cleared? */ + ++test; + if (fcntl(fd2, F_GETFD) != 0) + printf("not ok %d - dup2(2) didn't clear close-on-exec\n", + test); + else + printf("ok %d - dup2(2) cleared close-on-exec\n", test); + + /* + * Dup to itself. + * + * We're testing a small tweak in dup2 semantics. + * Normally dup and dup2 will clear the close-on-exec + * flag on the new fd (which appears to be an implementation + * mistake from start and not some planned behavior). + * In today's implementations of dup and dup2 we have to make + * an effort to really clear that flag. But all tested + * implementations of dup2 have another tweak. If we + * dup2(old, new) when old == new, the syscall short-circuits + * and returns early (because there is no need to do all the + * work (and there is a risk for serious mistakes)). + * So although the docs say that dup2 should "take 'old', + * close 'new' perform a dup(2) of 'old' into 'new'" + * the docs are not really followed because close-on-exec + * is not cleared on 'new'. + * + * Since everyone has this bug, we pretend that this is + * the way it is supposed to be and test here that it really + * works that way. + * + * This is a fine example on where two separate implementation + * fuckups take out each other and make the end-result the way + * it was meant to be. + */ + if ((fd2 = dup2(fd1, fd1)) < 0) + err(1, "dup2"); + printf("ok %d - dup2(2) to itself works\n", ++test); + + /* Do we get the right fd? */ + ++test; + if (fd2 != fd1) + printf("not ok %d - dup2(2) didn't give us the right fd\n", + test); + else + printf("ok %d - dup2(2) to itself returned a correct fd\n", + test); + + /* Was close-on-exec cleared? */ + ++test; + if (fcntl(fd2, F_GETFD) == 0) + printf("not ok %d - dup2(2) cleared close-on-exec\n", test); + else + printf("ok %d - dup2(2) didn't clear close-on-exec\n", test); + + /* Does fcntl(F_DUPFD) work? */ + if ((fd2 = fcntl(fd1, F_DUPFD, 10)) < 0) + err(1, "fcntl(F_DUPFD)"); + if (fd2 < 10) + printf("not ok %d - fcntl(F_DUPFD) returned wrong fd %d\n", + ++test, fd2); + else + printf("ok %d - fcntl(F_DUPFD) works\n", ++test); + + /* Was close-on-exec cleared? */ + ++test; + if (fcntl(fd2, F_GETFD) != 0) + printf( + "not ok %d - fcntl(F_DUPFD) didn't clear close-on-exec\n", + test); + else + printf("ok %d - fcntl(F_DUPFD) cleared close-on-exec\n", test); + + ++test; + if (getrlimit(RLIMIT_NOFILE, &rlp) < 0) + err(1, "getrlimit"); + if ((fd2 = dup2(fd1, rlp.rlim_cur + 1)) >= 0) + printf("not ok %d - dup2(2) bypassed NOFILE limit\n", test); + else + printf("ok %d - dup2(2) didn't bypass NOFILE limit\n", test); + + /* If fcntl(F_DUP2FD) ever work? */ + if ((fd2 = fcntl(fd1, F_DUP2FD, fd1 + 1)) < 0) + err(1, "fcntl(F_DUP2FD)"); + printf("ok %d - fcntl(F_DUP2FD) works\n", ++test); + + /* Do we get the right fd? */ + ++test; + if (fd2 != fd1 + 1) + printf( + "no ok %d - fcntl(F_DUP2FD) didn't give us the right fd\n", + test); + else + printf("ok %d - fcntl(F_DUP2FD) returned a correct fd\n", + test); + + /* Was close-on-exec cleared? */ + ++test; + if (fcntl(fd2, F_GETFD) != 0) + printf( + "not ok %d - fcntl(F_DUP2FD) didn't clear close-on-exec\n", + test); + else + printf("ok %d - fcntl(F_DUP2FD) cleared close-on-exec\n", + test); + + /* Dup to itself */ + if ((fd2 = fcntl(fd1, F_DUP2FD, fd1)) < 0) + err(1, "fcntl(F_DUP2FD)"); + printf("ok %d - fcntl(F_DUP2FD) to itself works\n", ++test); + + /* Do we get the right fd? */ + ++test; + if (fd2 != fd1) + printf( + "not ok %d - fcntl(F_DUP2FD) didn't give us the right fd\n", + test); + else + printf( + "ok %d - fcntl(F_DUP2FD) to itself returned a correct fd\n", + test); + + /* Was close-on-exec cleared? */ + ++test; + if (fcntl(fd2, F_GETFD) == 0) + printf("not ok %d - fcntl(F_DUP2FD) cleared close-on-exec\n", + test); + else + printf("ok %d - fcntl(F_DUP2FD) didn't clear close-on-exec\n", + test); + + ++test; + if (getrlimit(RLIMIT_NOFILE, &rlp) < 0) + err(1, "getrlimit"); + if ((fd2 = fcntl(fd1, F_DUP2FD, rlp.rlim_cur + 1)) >= 0) + printf("not ok %d - fcntl(F_DUP2FD) bypassed NOFILE limit\n", + test); + else + printf("ok %d - fcntl(F_DUP2FD) didn't bypass NOFILE limit\n", + test); + + /* Does fcntl(F_DUPFD_CLOEXEC) work? */ + if ((fd2 = fcntl(fd1, F_DUPFD_CLOEXEC, 10)) < 0) + err(1, "fcntl(F_DUPFD_CLOEXEC)"); + if (fd2 < 10) + printf("not ok %d - fcntl(F_DUPFD_CLOEXEC) returned wrong fd %d\n", + ++test, fd2); + else + printf("ok %d - fcntl(F_DUPFD_CLOEXEC) works\n", ++test); + + /* Was close-on-exec cleared? */ + ++test; + if (fcntl(fd2, F_GETFD) != 1) + printf( + "not ok %d - fcntl(F_DUPFD_CLOEXEC) didn't set close-on-exec\n", + test); + else + printf("ok %d - fcntl(F_DUPFD_CLOEXEC) set close-on-exec\n", + test); + + /* If fcntl(F_DUP2FD_CLOEXEC) ever work? */ + if ((fd2 = fcntl(fd1, F_DUP2FD_CLOEXEC, fd1 + 1)) < 0) + err(1, "fcntl(F_DUP2FD_CLOEXEC)"); + printf("ok %d - fcntl(F_DUP2FD_CLOEXEC) works\n", ++test); + + /* Do we get the right fd? */ + ++test; + if (fd2 != fd1 + 1) + printf( + "no ok %d - fcntl(F_DUP2FD_CLOEXEC) didn't give us the right fd\n", + test); + else + printf("ok %d - fcntl(F_DUP2FD_CLOEXEC) returned a correct fd\n", + test); + + /* Was close-on-exec set? */ + ++test; + if (fcntl(fd2, F_GETFD) != FD_CLOEXEC) + printf( + "not ok %d - fcntl(F_DUP2FD_CLOEXEC) didn't set close-on-exec\n", + test); + else + printf("ok %d - fcntl(F_DUP2FD_CLOEXEC) set close-on-exec\n", + test); + + /* + * It is unclear what F_DUP2FD_CLOEXEC should do when duplicating a + * file descriptor onto itself. + */ + + ++test; + if (getrlimit(RLIMIT_NOFILE, &rlp) < 0) + err(1, "getrlimit"); + if ((fd2 = fcntl(fd1, F_DUP2FD_CLOEXEC, rlp.rlim_cur + 1)) >= 0) + printf("not ok %d - fcntl(F_DUP2FD_CLOEXEC) bypassed NOFILE limit\n", + test); + else + printf("ok %d - fcntl(F_DUP2FD_CLOEXEC) didn't bypass NOFILE limit\n", + test); + + /* Does dup3(O_CLOEXEC) ever work? */ + if ((fd2 = dup3(fd1, fd1 + 1, O_CLOEXEC)) < 0) + err(1, "dup3(O_CLOEXEC)"); + printf("ok %d - dup3(O_CLOEXEC) works\n", ++test); + + /* Do we get the right fd? */ + ++test; + if (fd2 != fd1 + 1) + printf( + "no ok %d - dup3(O_CLOEXEC) didn't give us the right fd\n", + test); + else + printf("ok %d - dup3(O_CLOEXEC) returned a correct fd\n", + test); + + /* Was close-on-exec set? */ + ++test; + if (fcntl(fd2, F_GETFD) != FD_CLOEXEC) + printf( + "not ok %d - dup3(O_CLOEXEC) didn't set close-on-exec\n", + test); + else + printf("ok %d - dup3(O_CLOEXEC) set close-on-exec\n", + test); + + /* Does dup3(0) ever work? */ + if ((fd2 = dup3(fd1, fd1 + 1, 0)) < 0) + err(1, "dup3(0)"); + printf("ok %d - dup3(0) works\n", ++test); + + /* Do we get the right fd? */ + ++test; + if (fd2 != fd1 + 1) + printf( + "no ok %d - dup3(0) didn't give us the right fd\n", + test); + else + printf("ok %d - dup3(0) returned a correct fd\n", + test); + + /* Was close-on-exec cleared? */ + ++test; + if (fcntl(fd2, F_GETFD) != 0) + printf( + "not ok %d - dup3(0) didn't clear close-on-exec\n", + test); + else + printf("ok %d - dup3(0) cleared close-on-exec\n", + test); + + /* dup3() does not allow duplicating to the same fd */ + ++test; + if (dup3(fd1, fd1, O_CLOEXEC) != -1) + printf( + "not ok %d - dup3(fd1, fd1, O_CLOEXEC) succeeded\n", test); + else + printf("ok %d - dup3(fd1, fd1, O_CLOEXEC) failed\n", test); + + ++test; + if (dup3(fd1, fd1, 0) != -1) + printf( + "not ok %d - dup3(fd1, fd1, 0) succeeded\n", test); + else + printf("ok %d - dup3(fd1, fd1, 0) failed\n", test); + + ++test; + if (getrlimit(RLIMIT_NOFILE, &rlp) < 0) + err(1, "getrlimit"); + if ((fd2 = dup3(fd1, rlp.rlim_cur + 1, O_CLOEXEC)) >= 0) + printf("not ok %d - dup3(O_CLOEXEC) bypassed NOFILE limit\n", + test); + else + printf("ok %d - dup3(O_CLOEXEC) didn't bypass NOFILE limit\n", + test); + + return (0); +} Copied: user/ngie/more-tests/tests/sys/file/fcntlflags_test.c (from r281415, user/ngie/more-tests/tools/regression/file/fcntlflags/fcntlflags.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/ngie/more-tests/tests/sys/file/fcntlflags_test.c Sat Apr 11 10:14:59 2015 (r281432, copy of r281415, user/ngie/more-tests/tools/regression/file/fcntlflags/fcntlflags.c) @@ -0,0 +1,110 @@ +/*- + * Copyright (c) 2013 Jilles Tjoelker + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include + +#include +#include +#include + +/* + * O_ACCMODE is currently defined incorrectly. This is what it should be. + * Various code depends on the incorrect value. + */ +#define CORRECT_O_ACCMODE (O_ACCMODE | O_EXEC) + +static int testnum; + +static void +subtests(const char *path, int omode, const char *omodetext) +{ + int fd, flags1, flags2, flags3; + + fd = open(path, omode); + if (fd == -1) + printf("not ok %d - open(\"%s\", %s) failed\n", + testnum++, path, omodetext); + else + printf("ok %d - open(\"%s\", %s) succeeded\n", + testnum++, path, omodetext); + flags1 = fcntl(fd, F_GETFL); + if (flags1 == -1) + printf("not ok %d - fcntl(F_GETFL) failed\n", testnum++); + else if ((flags1 & CORRECT_O_ACCMODE) == omode) + printf("ok %d - fcntl(F_GETFL) gave correct result\n", + testnum++); + else + printf("not ok %d - fcntl(F_GETFL) gave incorrect result " + "(%#x & %#x != %#x)\n", + testnum++, flags1, CORRECT_O_ACCMODE, omode); + if (fcntl(fd, F_SETFL, flags1) == -1) + printf("not ok %d - fcntl(F_SETFL) same flags failed\n", + testnum++); + else + printf("ok %d - fcntl(F_SETFL) same flags succeeded\n", + testnum++); + flags2 = fcntl(fd, F_GETFL); + if (flags2 == -1) + printf("not ok %d - fcntl(F_GETFL) failed\n", testnum++); + else if (flags2 == flags1) + printf("ok %d - fcntl(F_GETFL) gave same result\n", + testnum++); + else + printf("not ok %d - fcntl(F_SETFL) caused fcntl(F_GETFL) to " + "change from %#x to %#x\n", + testnum++, flags1, flags2); + if (fcntl(fd, F_SETFL, flags2 | O_NONBLOCK) == -1) + printf("not ok %d - fcntl(F_SETFL) O_NONBLOCK failed\n", + testnum++); + else + printf("ok %d - fcntl(F_SETFL) O_NONBLOCK succeeded\n", + testnum++); + flags3 = fcntl(fd, F_GETFL); + if (flags3 == -1) + printf("not ok %d - fcntl(F_GETFL) failed\n", testnum++); + else if (flags3 == (flags2 | O_NONBLOCK)) + printf("ok %d - fcntl(F_GETFL) gave expected result\n", + testnum++); + else + printf("not ok %d - fcntl(F_SETFL) gave unexpected result " + "(%#x != %#x)\n", + testnum++, flags3, flags2 | O_NONBLOCK); + (void)close(fd); +} + +int +main(int argc __unused, char **argv __unused) +{ + printf("1..24\n"); + testnum = 1; + subtests("/dev/null", O_RDONLY, "O_RDONLY"); + subtests("/dev/null", O_WRONLY, "O_WRONLY"); + subtests("/dev/null", O_RDWR, "O_RDWR"); + subtests("/bin/sh", O_EXEC, "O_EXEC"); + return (0); +} Copied: user/ngie/more-tests/tests/sys/file/flock_helper.c (from r281415, user/ngie/more-tests/tools/regression/file/flock/flock.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/ngie/more-tests/tests/sys/file/flock_helper.c Sat Apr 11 10:14:59 2015 (r281432, copy of r281415, user/ngie/more-tests/tools/regression/file/flock/flock.c) @@ -0,0 +1,1598 @@ +/*- + * Copyright (c) 2008 Isilon Inc http://www.isilon.com/ + * Authors: Doug Rabson + * Developed with Red Inc: Alfred Perlstein + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#ifdef __FreeBSD__ +#include +#endif +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __FreeBSD__ +#if __FreeBSD_version >= 800028 +#define HAVE_SYSID +#endif +#include +#else +#ifndef nitems +#define nitems(x) (sizeof((x)) / sizeof((x)[0])) +#endif + +#ifndef __unused +#ifdef __GNUC__ +#define __unused __attribute__((__unused__)) +#else +#define __unused +#endif +#endif +#endif + +static int verbose = 0; + +static int +make_file(const char *pathname, off_t sz) +{ + struct stat st; + const char *template = "/flocktempXXXXXX"; + size_t len; + char *filename; + int fd; + + if (stat(pathname, &st) == 0) { + if (S_ISREG(st.st_mode)) { + fd = open(pathname, O_RDWR); + if (fd < 0) + err(1, "open(%s)", pathname); + if (ftruncate(fd, sz) < 0) + err(1, "ftruncate"); + return (fd); + } + } + + len = strlen(pathname) + strlen(template) + 1; + filename = malloc(len); + strcpy(filename, pathname); + strcat(filename, template); + fd = mkstemp(filename); + if (fd < 0) + err(1, "mkstemp"); + if (ftruncate(fd, sz) < 0) + err(1, "ftruncate"); + if (unlink(filename) < 0) + err(1, "unlink"); + free(filename); + + return (fd); +} + +static void +ignore_alarm(int __unused sig) +{ +} + +static int +safe_waitpid(pid_t pid) +{ + int save_errno; + int status; + + save_errno = errno; + errno = 0; + while (waitpid(pid, &status, 0) != pid) { + if (errno == EINTR) + continue; + err(1, "waitpid"); + } + errno = save_errno; + + return (status); +} + +#define FAIL(test) \ + do { \ + if (test) { \ + printf("FAIL (%s)\n", #test); \ + return -1; \ + } \ + } while (0) + +#define SUCCEED \ + do { printf("SUCCEED\n"); return 0; } while (0) + +/* + * Test 1 - F_GETLK on unlocked region + * + * If no lock is found that would prevent this lock from being + * created, the structure is left unchanged by this function call + * except for the lock type which is set to F_UNLCK. + */ +static int +test1(int fd, __unused int argc, const __unused char **argv) +{ + struct flock fl1, fl2; + + memset(&fl1, 1, sizeof(fl1)); + fl1.l_type = F_WRLCK; + fl1.l_whence = SEEK_SET; + fl2 = fl1; + + if (fcntl(fd, F_GETLK, &fl1) < 0) + err(1, "F_GETLK"); + + printf("1 - F_GETLK on unlocked region: "); + FAIL(fl1.l_start != fl2.l_start); + FAIL(fl1.l_len != fl2.l_len); + FAIL(fl1.l_pid != fl2.l_pid); + FAIL(fl1.l_type != F_UNLCK); + FAIL(fl1.l_whence != fl2.l_whence); +#ifdef HAVE_SYSID + FAIL(fl1.l_sysid != fl2.l_sysid); +#endif + + SUCCEED; +} + +/* + * Test 2 - F_SETLK on locked region + * + * If a shared or exclusive lock cannot be set, fcntl returns + * immediately with EACCES or EAGAIN. + */ +static int +test2(int fd, __unused int argc, const __unused char **argv) +{ + /* + * We create a child process to hold the lock which we will + * test. We use a pipe to communicate with the child. + */ + int pid; + int pfd[2]; + struct flock fl; + char ch; + int res; + + if (pipe(pfd) < 0) + err(1, "pipe"); + + fl.l_start = 0; + fl.l_len = 0; + fl.l_type = F_WRLCK; + fl.l_whence = SEEK_SET; + + pid = fork(); + if (pid < 0) + err(1, "fork"); + + if (pid == 0) { + /* + * We are the child. We set a write lock and then + * write one byte back to the parent to tell it. The + * parent will kill us when its done. + */ + if (fcntl(fd, F_SETLK, &fl) < 0) + err(1, "F_SETLK (child)"); + if (write(pfd[1], "a", 1) < 0) + err(1, "writing to pipe (child)"); + pause(); + exit(0); + } + + /* + * Wait until the child has set its lock and then perform the + * test. + */ + if (read(pfd[0], &ch, 1) != 1) + err(1, "reading from pipe (child)"); + + /* + * fcntl should return -1 with errno set to either EACCES or + * EAGAIN. + */ + printf("2 - F_SETLK on locked region: "); + res = fcntl(fd, F_SETLK, &fl); + kill(pid, SIGTERM); + safe_waitpid(pid); + close(pfd[0]); + close(pfd[1]); + FAIL(res == 0); + FAIL(errno != EACCES && errno != EAGAIN); + + SUCCEED; +} + +/* + * Test 3 - F_SETLKW on locked region + * + * If a shared or exclusive lock is blocked by other locks, the + * process waits until the request can be satisfied. + * + * XXX this test hangs on FreeBSD NFS filesystems due to limitations + * in FreeBSD's client (and server) lockd implementation. + */ +static int +test3(int fd, __unused int argc, const __unused char **argv) +{ + /* + * We create a child process to hold the lock which we will + * test. We use a pipe to communicate with the child. + */ + int pid; + int pfd[2]; + struct flock fl; + char ch; + int res; + + if (pipe(pfd) < 0) + err(1, "pipe"); + + fl.l_start = 0; + fl.l_len = 0; + fl.l_type = F_WRLCK; + fl.l_whence = SEEK_SET; + + pid = fork(); + if (pid < 0) + err(1, "fork"); + + if (pid == 0) { + /* + * We are the child. We set a write lock and then + * write one byte back to the parent to tell it. The + * parent will kill us when its done. + */ + if (fcntl(fd, F_SETLK, &fl) < 0) + err(1, "F_SETLK (child)"); + if (write(pfd[1], "a", 1) < 0) + err(1, "writing to pipe (child)"); + pause(); + exit(0); + } + + /* + * Wait until the child has set its lock and then perform the + * test. + */ + if (read(pfd[0], &ch, 1) != 1) + err(1, "reading from pipe (child)"); + + /* + * fcntl should wait until the alarm and then return -1 with + * errno set to EINTR. + */ + printf("3 - F_SETLKW on locked region: "); + + alarm(1); + + res = fcntl(fd, F_SETLKW, &fl); + kill(pid, SIGTERM); + safe_waitpid(pid); + close(pfd[0]); + close(pfd[1]); + FAIL(res == 0); + FAIL(errno != EINTR); + + SUCCEED; +} + +/* + * Test 4 - F_GETLK on locked region + * + * Get the first lock that blocks the lock. + */ +static int +test4(int fd, __unused int argc, const __unused char **argv) +{ + /* + * We create a child process to hold the lock which we will + * test. We use a pipe to communicate with the child. + */ + int pid; + int pfd[2]; + struct flock fl; + char ch; + + if (pipe(pfd) < 0) + err(1, "pipe"); + + fl.l_start = 0; + fl.l_len = 99; + fl.l_type = F_WRLCK; + fl.l_whence = SEEK_SET; + + pid = fork(); + if (pid < 0) + err(1, "fork"); + + if (pid == 0) { + /* + * We are the child. We set a write lock and then + * write one byte back to the parent to tell it. The + * parent will kill us when its done. + */ + if (fcntl(fd, F_SETLK, &fl) < 0) + err(1, "F_SETLK (child)"); + if (write(pfd[1], "a", 1) < 0) + err(1, "writing to pipe (child)"); + pause(); + exit(0); + } + + /* + * Wait until the child has set its lock and then perform the + * test. + */ + if (read(pfd[0], &ch, 1) != 1) + err(1, "reading from pipe (child)"); + + /* + * fcntl should return a lock structure reflecting the lock we + * made in the child process. + */ + if (fcntl(fd, F_GETLK, &fl) < 0) + err(1, "F_GETLK"); + + printf("4 - F_GETLK on locked region: "); + FAIL(fl.l_start != 0); + FAIL(fl.l_len != 99); + FAIL(fl.l_type != F_WRLCK); + FAIL(fl.l_pid != pid); +#ifdef HAVE_SYSID + FAIL(fl.l_sysid != 0); +#endif + + kill(pid, SIGTERM); + safe_waitpid(pid); + close(pfd[0]); + close(pfd[1]); + + SUCCEED; +} + +/* + * Test 5 - F_SETLKW simple deadlock + * + * If a blocking shared lock request would cause a deadlock (i.e. the + * lock request is blocked by a process which is itself blocked on a + * lock currently owned by the process making the new request), + * EDEADLK is returned. + */ +static int *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***