From owner-svn-src-user@freebsd.org Mon Sep 21 08:44:24 2015 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9E501A05C19 for ; Mon, 21 Sep 2015 08:44:24 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org (repo.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 8F7711FBF; Mon, 21 Sep 2015 08:44:24 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t8L8iOx7004461; Mon, 21 Sep 2015 08:44:24 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t8L8iOvn004460; Mon, 21 Sep 2015 08:44:24 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201509210844.t8L8iOvn004460@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Mon, 21 Sep 2015 08:44:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r288058 - user/pho/stress2/misc 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.20 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: Mon, 21 Sep 2015 08:44:24 -0000 Author: pho Date: Mon Sep 21 08:44:23 2015 New Revision: 288058 URL: https://svnweb.freebsd.org/changeset/base/288058 Log: Added a regression test. PR: 203162 In collaboration with: kib Sponsored by: EMC / Isilon storage division Added: user/pho/stress2/misc/mkfifo3.sh (contents, props changed) Added: user/pho/stress2/misc/mkfifo3.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/pho/stress2/misc/mkfifo3.sh Mon Sep 21 08:44:23 2015 (r288058) @@ -0,0 +1,140 @@ +#!/bin/sh + +# +# Copyright (c) 2015 EMC Corp. +# 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$ +# + +. ../default.cfg + +# Regression test for +# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203162 + +# FAIL +# 1001 82102 907 0 20 0 6484 2480 wait S+ 0 0:00,01 /bin/sh ./mkfifo3.sh +# 1001 82113 82102 0 52 0 3832 1604 fifoow I+ 0 0:03,91 /tmp/mkfifo3 + +# Fixed in r288044. + +dir=/tmp +odir=`pwd` +cd $dir +sed '1,/^EOF/d' < $odir/$0 > $dir/mkfifo3.c +mycc -o mkfifo3 -Wall -Wextra -O0 -g mkfifo3.c || exit 1 +rm -f mkfifo3.c +cd $odir + +fifo=/tmp/mkfifo3.fifo +trap "rm -f $fifo /tmp/mkfifo3" EXIT SIGINT + +/tmp/mkfifo3 & + +for i in `jot 12`; do + pgrep -q mkfifo3 || break + sleep 10 +done +if pgrep -q mkfifo3; then + echo FAIL + ps -l | grep -v grep | grep mkfifo3 + pkill mkfifo3 +fi +wait + +exit $s +EOF +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define ATIME 1 +#define LOOPS 100000 + +char file[] = "/tmp/mkfifo3.fifo"; + +static void +hand(int i __unused) { /* handler */ +} + +int +main(void) +{ + pid_t pid; + struct sigaction sa; + int fd, i, status; + + sa.sa_handler = hand; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + if (sigaction(SIGALRM, &sa, NULL) == -1) + err(1, "sigaction"); + + if (unlink(file) == -1) + if (errno != ENOENT) + err(1, "unlink(%s)", file); + if (mkfifo(file, 0640) == -1) + err(1, "mkfifo(%s)", file); + + for (i = 0; i < LOOPS; i++) { + if ((pid = fork()) == 0) { + ualarm(ATIME, 0); + do { + if((fd = open(file, O_RDONLY)) == -1) + if (errno != EINTR) + err(1, "open(%s, O_RDONLY @ %d)", + file, i); + } while (fd == -1); + if (close(fd) == -1) + err(1, "close() in child"); + alarm(0); + _exit(0); + } + ualarm(ATIME, 0); + do { + if ((fd = open(file, O_WRONLY)) == -1) + if (errno != EINTR) + err(1, "open(%s, O_WRONLY @ %d)", + file, i); + } while (fd == -1); + if (close(fd) == -1) + err(1, "close() in parent"); + alarm(0); + if (waitpid(pid, &status, 0) == -1) + err(1, "wait"); + } + + if (unlink(file) == -1) + err(1, "unlink(%s)", file); + + return (0); +}