From patchwork Tue Jan 29 11:24:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10786045 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A01591399 for ; Tue, 29 Jan 2019 11:24:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9159A2A6CF for ; Tue, 29 Jan 2019 11:24:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 858E62A6ED; Tue, 29 Jan 2019 11:24:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 493B52A6CF for ; Tue, 29 Jan 2019 11:24:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C20B96E7F4; Tue, 29 Jan 2019 11:24:17 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1F2B36E7F4; Tue, 29 Jan 2019 11:24:15 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 15388224-1500050 for multiple; Tue, 29 Jan 2019 11:24:10 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Tue, 29 Jan 2019 11:24:03 +0000 Message-Id: <20190129112403.10756-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t] i915/gem_exec_capture: Check the strlen() for an empty file X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: igt-dev@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP igt_sysfs_get() only returns NULL if the open() fails, and a valid string otherwise. So if the read() fails with ENODEV (because sysfs doesn't provide the driver with an ->open() callback), we return an empty string, and "No error captured" otherwise. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109481 Signed-off-by: Chris Wilson --- tests/i915/gem_exec_capture.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/i915/gem_exec_capture.c b/tests/i915/gem_exec_capture.c index eca73ab11..56837dfca 100644 --- a/tests/i915/gem_exec_capture.c +++ b/tests/i915/gem_exec_capture.c @@ -519,6 +519,11 @@ static bool has_capture(int fd) return async > 0; } +static size_t safer_strlen(const char *s) +{ + return s ? strlen(s) : 0; +} + igt_main { const struct intel_execution_engine *e; @@ -544,7 +549,7 @@ igt_main dir = igt_sysfs_open(fd, NULL); igt_require(igt_sysfs_set(dir, "error", "Begone!")); - igt_require(igt_sysfs_get(dir, "error")); + igt_require(safer_strlen(igt_sysfs_get(dir, "error")) > 0); } for (e = intel_execution_engines; e->name; e++) {