From owner-svn-src-user@freebsd.org Tue May 2 06:54:49 2017 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 E4737D5AD8C for ; Tue, 2 May 2017 06:54:49 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 98F05171; Tue, 2 May 2017 06:54:49 +0000 (UTC) (envelope-from pho@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v426smU1014978; Tue, 2 May 2017 06:54:48 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v426smgE014977; Tue, 2 May 2017 06:54:48 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201705020654.v426smgE014977@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Tue, 2 May 2017 06:54:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r317674 - 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.23 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: Tue, 02 May 2017 06:54:50 -0000 Author: pho Date: Tue May 2 06:54:48 2017 New Revision: 317674 URL: https://svnweb.freebsd.org/changeset/base/317674 Log: Fix issue with missing waits. Cleanup test case while here. Sponsored by: Dell EMC Isilon Modified: user/pho/stress2/misc/mmap21.sh Modified: user/pho/stress2/misc/mmap21.sh ============================================================================== --- user/pho/stress2/misc/mmap21.sh Tue May 2 06:27:46 2017 (r317673) +++ user/pho/stress2/misc/mmap21.sh Tue May 2 06:54:48 2017 (r317674) @@ -42,9 +42,7 @@ sed '1,/^EOF/d' < $here/$0 > mmap21.c mycc -o mmap21 -Wall -Wextra -O2 -g mmap21.c -lpthread || exit 1 rm -f mmap21.c -for i in `jot 2`; do - su $testuser -c /tmp/mmap21 -done +su $testuser -c /tmp/mmap21 rm -f /tmp/mmap21 /tmp/mmap21.core exit 0 @@ -64,12 +62,13 @@ EOF #include #include -#define LOOPS 2 -#define PARALLEL 50 +#define LOOPS 1 +#define NMAPS 50 +#define PARALLEL 2 void *p; -void * +static void * tmmap(void *arg __unused) { size_t len; @@ -78,13 +77,13 @@ tmmap(void *arg __unused) pthread_set_name_np(pthread_self(), __func__); len = 1LL * 128 * 1024 * 1024; - for (i = 0; i < 100; i++) + for (i = 0; i < NMAPS; i++) p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); return (NULL); } -void * +static void * tmlock(void *arg __unused) { size_t len; @@ -108,9 +107,10 @@ tmlock(void *arg __unused) return (NULL); } -void +static void test(void) { + pid_t pid; pthread_t tid[2]; int i, rc; @@ -120,11 +120,12 @@ test(void) errc(1, rc, "tmlock()"); for (i = 0; i < 100; i++) { - if (fork() == 0) { + if ((pid = fork()) == 0) { usleep(10000); _exit(0); } - wait(NULL); + if (waitpid(pid, NULL, 0) != pid) + err(1, "waitpid(%d)", pid); } raise(SIGSEGV); @@ -138,18 +139,23 @@ test(void) int main(void) { - int i, j; - alarm(120); + pid_t pids[PARALLEL]; + int e, i, j, status; + for (i = 0; i < LOOPS; i++) { for (j = 0; j < PARALLEL; j++) { - if (fork() == 0) + if ((pids[j] = fork()) == 0) test(); } - for (j = 0; j < PARALLEL; j++) - wait(NULL); + e = 0; + for (j = 0; j < PARALLEL; j++) { + if (waitpid(pids[j], &status, 0) == -1) + err(1, "waitpid(%d)", pids[j]); + e += status == 0 ? 0 : 1; + } } - return (0); + return (e); }