From owner-svn-src-head@FreeBSD.ORG Wed Aug 21 17:47:12 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id F34FEEE0; Wed, 21 Aug 2013 17:47:11 +0000 (UTC) (envelope-from kib@FreeBSD.org) 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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E0EF42CED; Wed, 21 Aug 2013 17:47:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7LHlBUU086305; Wed, 21 Aug 2013 17:47:11 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7LHlBeq086304; Wed, 21 Aug 2013 17:47:11 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201308211747.r7LHlBeq086304@svn.freebsd.org> From: Konstantin Belousov Date: Wed, 21 Aug 2013 17:47:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254604 - head/tools/test/posixshm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Aug 2013 17:47:12 -0000 Author: kib Date: Wed Aug 21 17:47:11 2013 New Revision: 254604 URL: http://svnweb.freebsd.org/changeset/base/254604 Log: Add simple test for the read/write/lseek on posix shm filedescriptor. Tested by: pho Sponsored by: The FreeBSD Foundation Modified: head/tools/test/posixshm/shm_test.c Modified: head/tools/test/posixshm/shm_test.c ============================================================================== --- head/tools/test/posixshm/shm_test.c Wed Aug 21 17:45:00 2013 (r254603) +++ head/tools/test/posixshm/shm_test.c Wed Aug 21 17:47:11 2013 (r254604) @@ -21,7 +21,7 @@ * Signal handler which does nothing. */ static void -ignoreit(int sig) +ignoreit(int sig __unused) { ; } @@ -29,13 +29,13 @@ ignoreit(int sig) int main(int argc, char **argv) { - char buf[1024], *cp; - int desc, rv; + char buf[1024], *cp, c; + int error, desc, rv; long scval; sigset_t ss; struct sigaction sa; void *region; - size_t psize; + size_t i, psize; #ifndef _POSIX_SHARED_MEMORY_OBJECTS printf("_POSIX_SHARED_MEMORY_OBJECTS is undefined\n"); @@ -118,14 +118,29 @@ main(int argc, char **argv) sigemptyset(&ss); sigsuspend(&ss); - for (cp = region; cp < (char *)region + psize; cp++) + for (cp = region; cp < (char *)region + psize; cp++) { if (*cp != '\151') _exit(1); + } + if (lseek(desc, 0, SEEK_SET) == -1) + _exit(1); + for (i = 0; i < psize; i++) { + error = read(desc, &c, 1); + if (c != '\151') + _exit(1); + } _exit(0); } else { int status; - memset(region, '\151', psize); + memset(region, '\151', psize - 2); + error = pwrite(desc, region, 2, psize - 2); + if (error != 2) { + if (error >= 0) + errx(1, "short write %d", error); + else + err(1, "shmfd write"); + } kill(rv, SIGUSR1); waitpid(rv, &status, 0);