From patchwork Wed Dec 17 16:45:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Wood X-Patchwork-Id: 5507951 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5FD47BEEA8 for ; Wed, 17 Dec 2014 16:46:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9635C20A22 for ; Wed, 17 Dec 2014 16:46:02 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 9708620A1B for ; Wed, 17 Dec 2014 16:45:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0C42F6E95A; Wed, 17 Dec 2014 08:45:57 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by gabe.freedesktop.org (Postfix) with ESMTP id EC3836E959 for ; Wed, 17 Dec 2014 08:45:54 -0800 (PST) Received: by mail-wi0-f180.google.com with SMTP id n3so16764910wiv.13 for ; Wed, 17 Dec 2014 08:45:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=+Ajhh4I3hK/Z7xcynh03CIl4YJN6Ha21T+kwG6vMl+Y=; b=BFOPH5e9mWanXDiVs34R5qae+NCXyTCvJ/cjgUvAPUHMjYRiimutdWEc0gp8aWO7Cm tbnZedu8ieVj3prMYB4pHKU0NIFVUI/2zos8S4XyCbG8/33E8zFqGVEOQFpgwJZQG9Wk HBXt3fsUAqC2pCdRJSGsCH1pRhtgOGrjAb54WEacWgYe2psCtOt4BNw5qRVRae+Gwf2c icmERbmXPOGtTd5qRXbqS4B2fKkTKBfV3GIPplTiOW1rrn++K5Ty8fc4pvPT9rzDKohQ NDCWO9Dria1a5fnZOdnPwQ5xccewbtPc8XkablUwH+8ayWBHhigyr+nZ/alsFnbZ/ETF Lxew== X-Gm-Message-State: ALoCoQlSvhn4a5GBxYey0ix1UKnS3pbdod27a0d+uyeg6q/hFsxx61HqpTZgZz0nkVll7BcddRxo X-Received: by 10.180.102.135 with SMTP id fo7mr16525297wib.79.1418834753509; Wed, 17 Dec 2014 08:45:53 -0800 (PST) Received: from pistachio.icx.intel.com ([83.217.123.106]) by mx.google.com with ESMTPSA id ec2sm6762267wib.23.2014.12.17.08.45.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Dec 2014 08:45:52 -0800 (PST) From: Thomas Wood To: intel-gfx@lists.freedesktop.org Date: Wed, 17 Dec 2014 16:45:45 +0000 Message-Id: <1418834747-5598-3-git-send-email-thomas.wood@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1418834747-5598-1-git-send-email-thomas.wood@intel.com> References: <1418834747-5598-1-git-send-email-thomas.wood@intel.com> Subject: [Intel-gfx] [PATCH i-g-t 3/5] lib: use critical log level for assertion failure messages 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 Signed-off-by: Thomas Wood --- lib/igt_core.c | 19 ++++++++----------- lib/igt_core.h | 21 +++++++++++---------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/lib/igt_core.c b/lib/igt_core.c index 6159a8c..b98cb41 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -951,27 +951,24 @@ static bool run_under_gdb(void) strncmp(basename(buf), "gdb", 3) == 0); } -void __igt_fail_assert(int exitcode, const char *file, +void __igt_fail_assert(int exitcode, const char *domain, const char *file, const int line, const char *func, const char *assertion, const char *f, ...) { va_list args; int err = errno; - char *err_str = NULL; + igt_log(domain, IGT_LOG_CRITICAL, + "Test assertion failure function %s, file %s:%i:\n", func, file, + line); + igt_log(domain, IGT_LOG_CRITICAL, "Failed assertion: %s\n", assertion); if (err) - asprintf(&err_str, "Last errno: %i, %s\n", err, strerror(err)); - - printf("Test assertion failure function %s, file %s:%i:\n" - "Failed assertion: %s\n" - "%s", - func, file, line, assertion, err_str ?: ""); - - free(err_str); + igt_log(domain, IGT_LOG_CRITICAL, "Last errno: %i, %s\n", err, + strerror(err)); if (f) { va_start(args, f); - vprintf(f, args); + igt_vlog(domain, IGT_LOG_CRITICAL, f, args); va_end(args); } diff --git a/lib/igt_core.h b/lib/igt_core.h index f184d75..bc4ba0a 100644 --- a/lib/igt_core.h +++ b/lib/igt_core.h @@ -38,6 +38,11 @@ #include #include +#ifndef IGT_LOG_DOMAIN +#define IGT_LOG_DOMAIN (NULL) +#endif + + extern const char* __igt_test_description __attribute__((weak)); /** @@ -215,8 +220,8 @@ void __igt_skip_check(const char *file, const int line, void igt_success(void); void igt_fail(int exitcode) __attribute__((noreturn)); -__attribute__((format(printf, 6, 7))) -void __igt_fail_assert(int exitcode, const char *file, +__attribute__((format(printf, 7, 8))) +void __igt_fail_assert(int exitcode, const char *domain, const char *file, const int line, const char *func, const char *assertion, const char *format, ...) __attribute__((noreturn)); @@ -232,7 +237,7 @@ void igt_exit(void) __attribute__((noreturn)); */ #define igt_assert(expr) \ do { if (!(expr)) \ - __igt_fail_assert(99, __FILE__, __LINE__, __func__, #expr , NULL); \ + __igt_fail_assert(99, IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, #expr , NULL); \ } while (0) /** @@ -249,7 +254,7 @@ void igt_exit(void) __attribute__((noreturn)); */ #define igt_assert_f(expr, f...) \ do { if (!(expr)) \ - __igt_fail_assert(99, __FILE__, __LINE__, __func__, #expr , f); \ + __igt_fail_assert(99, IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, #expr , f); \ } while (0) /** @@ -294,7 +299,7 @@ void igt_exit(void) __attribute__((noreturn)); do { \ int __n1 = (n1), __n2 = (n2); \ if (__n1 cmp __n2) ; else \ - __igt_fail_assert(99, __FILE__, __LINE__, __func__, \ + __igt_fail_assert(99, IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, \ #n1 " " #cmp " " #n2, \ "error: %d " #ncmp " %d\n", __n1, __n2); \ } while (0) @@ -303,7 +308,7 @@ void igt_exit(void) __attribute__((noreturn)); do { \ uint32_t __n1 = (n1), __n2 = (n2); \ if (__n1 cmp __n2) ; else \ - __igt_fail_assert(99, __FILE__, __LINE__, __func__, \ + __igt_fail_assert(99, IGT_LOG_DOMAIN, __FILE__, __LINE__, __func__, \ #n1 " " #cmp " " #n2, \ "error: %#x " #ncmp " %#x\n", __n1, __n2); \ } while (0) @@ -512,10 +517,6 @@ bool igt_run_in_simulation(void); void igt_skip_on_simulation(void); /* structured logging */ -#ifndef IGT_LOG_DOMAIN -#define IGT_LOG_DOMAIN (NULL) -#endif - enum igt_log_level { IGT_LOG_DEBUG, IGT_LOG_INFO,