From patchwork Fri Mar 20 01:11:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 6053731 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A65E09F318 for ; Fri, 20 Mar 2015 01:11:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AE8482051D for ; Fri, 20 Mar 2015 01:11:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A8681200B4 for ; Fri, 20 Mar 2015 01:11:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AA3BA6E2C0; Thu, 19 Mar 2015 18:11:52 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id DF7AC6E2C0 for ; Thu, 19 Mar 2015 18:11:50 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP; 19 Mar 2015 18:11:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,434,1422950400"; d="scan'208";a="694907563" Received: from jchoi5-mobl2.amr.corp.intel.com (HELO rdvivi-talin.amr.corp.intel.com) ([10.252.192.56]) by fmsmga002.fm.intel.com with ESMTP; 19 Mar 2015 18:11:49 -0700 From: Rodrigo Vivi To: intel-gfx@lists.freedesktop.org Date: Thu, 19 Mar 2015 18:11:45 -0700 Message-Id: <1426813905-21797-1-git-send-email-rodrigo.vivi@intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <20150317102859.GU21993@phenom.ffwll.local> References: <20150317102859.GU21993@phenom.ffwll.local> Cc: Daniel Vetter , Rodrigo Vivi Subject: [Intel-gfx] [PATCH] lib/igt_aux: Introduce igt_interactive_debug_manual_check. 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 This is an extention of igt_debug_wait_for_keypress that also can have customized message and return key pressed. v2: This is actualy a v2. V1 was an extension of original igt_debug_wait_for_keypress but it was nacked. v3: Make [Y/n] check inside aux function as suggested by Daniel. Also renaming and adding first use case along with the axu function. v4: Simplify function name and make it assert pressed key is different from n/N as suggested by Daniel. Cc: Daniel Vetter Signed-off-by: Rodrigo Vivi Reviewed-by: Daniel Vetter --- lib/igt_aux.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_aux.h | 1 + tests/kms_psr_sink_crc.c | 8 ++------ 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index 131ff4b..788ac3f 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -448,6 +448,56 @@ void igt_debug_wait_for_keypress(const char *var) tcsetattr ( STDIN_FILENO, TCSANOW, &oldt ); } +/** + * igt_debug_manual_check: + * @var: var lookup to to enable this wait + * @expected: message to be printed as expected behaviour before wait for keys Y/n + * + * Waits for a key press when run interactively and when the corresponding debug + * var is set in the --interactive-debug= variable. Multiple vars + * can be specified as a comma-separated list or alternatively "all" if a wait + * should happen for all cases. + * + * This is useful for display tests where under certain situation manual + * inspection of the display is useful. Or when running a testcase in the + * background. + * + * When not connected to a terminal interactive_debug is ignored + * and execution immediately continues. For this reason by default this function + * returns true. It returns false only when N/n is pressed indicating the + * user ins't seeing what was expected. + * + * Force test fail when N/n is pressed. + */ +void igt_debug_manual_check(const char *var, const char *expected) +{ + struct termios oldt, newt; + char key; + + if (!isatty(STDIN_FILENO)) + return; + + if (!igt_interactive_debug) + return; + + if (!strstr(igt_interactive_debug, var) && + !strstr(igt_interactive_debug, "all")) + return; + + igt_info("Is %s [Y/n]", expected); + + tcgetattr ( STDIN_FILENO, &oldt ); + newt = oldt; + newt.c_lflag &= ~ICANON; + tcsetattr ( STDIN_FILENO, TCSANOW, &newt ); + key = getchar(); + tcsetattr ( STDIN_FILENO, TCSANOW, &oldt ); + + igt_info("\n"); + + igt_assert(key != 'n' && key != 'N'); +} + #define POWER_DIR "/sys/devices/pci0000:00/0000:00:02.0/power" /* We just leak this on exit ... */ int pm_status_fd = -1; diff --git a/lib/igt_aux.h b/lib/igt_aux.h index 0c361f2..7a5078b 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -63,6 +63,7 @@ void igt_system_hibernate_autoresume(void); void igt_drop_root(void); void igt_debug_wait_for_keypress(const char *var); +void igt_debug_manual_check(const char *var, const char *expected); enum igt_runtime_pm_status { IGT_RUNTIME_PM_STATUS_ACTIVE, diff --git a/tests/kms_psr_sink_crc.c b/tests/kms_psr_sink_crc.c index 24f5ca8..b820efc 100644 --- a/tests/kms_psr_sink_crc.c +++ b/tests/kms_psr_sink_crc.c @@ -266,7 +266,7 @@ static void get_sink_crc(data_t *data, char *crc) { igt_require(file); ret = fscanf(file, "%s\n", crc); - igt_require_f(ret > 0, "Sink CRC is unreliable on this machine. Try manual debug with --interactive-debug=manual\n"); + igt_require_f(ret > 0, "Sink CRC is unreliable on this machine. Try manual debug with --interactive-debug=no-crc\n"); fclose(file); @@ -316,11 +316,7 @@ static bool is_green(char *crc) static void assert_or_manual(bool condition, const char *expected) { - if (igt_interactive_debug) - igt_info("Is %s?\n", expected); - else - igt_debug("%s\n", expected); - igt_debug_wait_for_keypress("manual"); + igt_debug_manual_check("no-crc", expected); igt_assert(igt_interactive_debug || condition); }