From owner-svn-src-user@freebsd.org Tue Mar 21 08:23:46 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 3E335D16947 for ; Tue, 21 Mar 2017 08:23:46 +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 F19771A2E; Tue, 21 Mar 2017 08:23:45 +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 v2L8Njmj001020; Tue, 21 Mar 2017 08:23:45 GMT (envelope-from pho@FreeBSD.org) Received: (from pho@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2L8NjMN001019; Tue, 21 Mar 2017 08:23:45 GMT (envelope-from pho@FreeBSD.org) Message-Id: <201703210823.v2L8NjMN001019@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pho set sender to pho@FreeBSD.org using -f From: Peter Holm Date: Tue, 21 Mar 2017 08:23:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r315663 - user/pho/stress2/lib 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, 21 Mar 2017 08:23:46 -0000 Author: pho Date: Tue Mar 21 08:23:44 2017 New Revision: 315663 URL: https://svnweb.freebsd.org/changeset/base/315663 Log: Change exit status to indicate test program failures. Sponsored by: Dell EMC Isilon Modified: user/pho/stress2/lib/main.c Modified: user/pho/stress2/lib/main.c ============================================================================== --- user/pho/stress2/lib/main.c Tue Mar 21 06:39:49 2017 (r315662) +++ user/pho/stress2/lib/main.c Tue Mar 21 08:23:44 2017 (r315663) @@ -30,6 +30,9 @@ #include __FBSDID("$FreeBSD$"); +#include +#include + #include #include #include @@ -38,8 +41,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include -#include #include "stress.h" @@ -50,9 +51,9 @@ volatile int done_testing; static int cleanupcalled = 0; char *home; -static pid_t *r; +static pid_t *r; -void +static void handler(int i __unused) { int j; @@ -77,21 +78,21 @@ handler(int i __unused) } } -void +static void run_test_handler(int i __unused) { done_testing = 1; } -void +static void exit_handler(int i __unused) { - exit(1); + _exit(1); } -void +static void callcleanup(void) { if (cleanupcalled == 0) @@ -103,6 +104,7 @@ static void run_tests(int i) { time_t start; + int e; signal(SIGHUP, run_test_handler); signal(SIGINT, exit_handler); @@ -111,21 +113,22 @@ run_tests(int i) setup(i); if ((strcmp(getprogname(), "run") != 0) && (op->nodelay == 0)) sleep(random_int(1,10)); + e = 0; start = time(NULL); - while (done_testing == 0 && + while (done_testing == 0 && e == 0 && (time(NULL) - start) < op->run_time) { - test(); + e = test(); } callcleanup(); - exit(EXIT_SUCCESS); + exit(e); } static void run_incarnations(void) { - int i; - int s; + int e, i, s; + e = 0; signal(SIGHUP, handler); for (i = 0; i < op->incarnations && done_testing == 0; i++) { if ((r[i] = fork()) == 0) { @@ -137,11 +140,14 @@ run_incarnations(void) break; } } - for (i = 0; i < op->incarnations; i++) + for (i = 0; i < op->incarnations; i++) { if (r[i] != 0 && waitpid(r[i], &s, 0) == -1) warn("waitpid(%d), %s:%d", r[i], __FILE__, __LINE__); + if (s != 0) + e = 1; + } - exit(EXIT_SUCCESS); + exit(e); } static int @@ -169,7 +175,7 @@ run_test(void) (time(NULL) - start) < op->run_time) { sleep(1); if (waitpid(p, &status, WNOHANG) == p) - return (status); + return (status != 0); } if (kill(p, SIGHUP) == -1) warn("kill(%d, SIGHUP), %s:%d", p, __FILE__, __LINE__); @@ -177,7 +183,7 @@ run_test(void) if (waitpid(p, &status, 0) == -1) err(1, "waitpid(%d), %s:%d", p, __FILE__, __LINE__); - return (status); + return (status != 0); } int