From patchwork Thu Jul 16 16:48:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 6809111 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A2FCEC05AC for ; Thu, 16 Jul 2015 16:48:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CFACC2066C for ; Thu, 16 Jul 2015 16:48:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C2B6D20662 for ; Thu, 16 Jul 2015 16:48:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 54BC16E3BB; Thu, 16 Jul 2015 09:48:47 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 582636E3BB for ; Thu, 16 Jul 2015 09:48:45 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 16 Jul 2015 09:48:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,488,1432623600"; d="scan'208";a="748704490" Received: from pistachio.isw.intel.com ([10.237.224.81]) by fmsmga001.fm.intel.com with ESMTP; 16 Jul 2015 09:48:43 -0700 From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Thu, 16 Jul 2015 17:48:43 +0100 Message-Id: <1437065323-27185-1-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 2.4.3 Organization: Intel Corporation (UK) Ltd. - Co. Reg. #1134945 - Pipers Way, Swindon SN3 1RJ Subject: [Intel-gfx] [PATCH i-g-t] lib: exit immediately if igt_fail is called in an exit handler X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Exit immediately if the test is already exiting and igt_fail is called. This can happen if an igt_assert fails in an exit handler. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91349 Signed-off-by: Thomas Wood --- lib/igt_core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/igt_core.c b/lib/igt_core.c index 1a453d7..af3d873 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -221,6 +221,7 @@ static const char *in_subtest = NULL; static struct timespec subtest_time; static bool in_fixture = false; static bool test_with_subtests = false; +static bool in_atexit_handler = false; static enum { CONT = 0, SKIP, FAIL } skip_subtests_henceforth = CONT; @@ -945,6 +946,11 @@ void igt_fail(int exitcode) igt_debug_wait_for_keypress("failure"); + /* Exit immediately if the test is already exiting and igt_fail is + * called. This can happen if an igt_assert fails in an exit handler */ + if (in_atexit_handler) + _exit(IGT_EXIT_FAILURE); + if (!failed_one) igt_exitcode = exitcode; @@ -1410,6 +1416,8 @@ static void call_exit_handlers(int sig) static void igt_atexit_handler(void) { + in_atexit_handler = true; + restore_all_sig_handler(); if (!exit_handler_disabled)