From patchwork Fri Jan 10 21:12:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jeff.mcgee@intel.com X-Patchwork-Id: 3468031 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 74E54C02DC for ; Fri, 10 Jan 2014 21:06:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A61EF2012E for ; Fri, 10 Jan 2014 21:06:46 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C662920121 for ; Fri, 10 Jan 2014 21:06:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AF379106AE3 for ; Fri, 10 Jan 2014 13:06:45 -0800 (PST) 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 65C54106AD9 for ; Fri, 10 Jan 2014 13:06:29 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 10 Jan 2014 13:06:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.95,640,1384329600"; d="scan'208";a="456898918" Received: from jeffdesk.fso.intel.com ([10.5.53.1]) by fmsmga001.fm.intel.com with ESMTP; 10 Jan 2014 13:06:28 -0800 From: jeff.mcgee@intel.com To: intel-gfx@lists.freedesktop.org Date: Fri, 10 Jan 2014 15:12:31 -0600 Message-Id: <1389388353-29980-3-git-send-email-jeff.mcgee@intel.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1389388353-29980-1-git-send-email-jeff.mcgee@intel.com> References: <1389388353-29980-1-git-send-email-jeff.mcgee@intel.com> Subject: [Intel-gfx] [PATCH 2/4] pm_rps: Assert that valid sysfs writes return success X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.3 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 From: Jeff McGee do_writeval now always checks the return value, whether we expect success or a specific error. Also add new macro writeval_inval to simplify repeated use of do_writeval to test for EINVAL return code. Signed-off-by: Jeff McGee --- tests/pm_rps.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tests/pm_rps.c b/tests/pm_rps.c index 9123451..69eeb81 100644 --- a/tests/pm_rps.c +++ b/tests/pm_rps.c @@ -79,11 +79,18 @@ static int do_writeval(FILE *filp, int val, int lerrno) int ret; rewind(filp); ret = fprintf(filp, "%d", val); - if (ret && lerrno) - igt_assert(errno = lerrno); + if (lerrno) { + /* Expecting specific error */ + igt_assert(ret == EOF && errno == lerrno); + } else { + /* Expecting no error */ + igt_assert(ret != EOF); + } + return ret; } #define writeval(filp, val) do_writeval(filp, val, 0) +#define writeval_inval(filp, val) do_writeval(filp, val, EINVAL) #define fcur (readval(stuff[CUR].filp)) #define fmin (readval(stuff[MIN].filp)) @@ -170,16 +177,16 @@ igt_simple_main checkit(); /* And some errors */ - writeval(stuff[MIN].filp, frpn - 1); - writeval(stuff[MAX].filp, frp0 + 1000); + writeval_inval(stuff[MIN].filp, frpn - 1); + writeval_inval(stuff[MAX].filp, frp0 + 1000); checkit(); - writeval(stuff[MIN].filp, fmax + 1000); - writeval(stuff[MAX].filp, fmin - 1); + writeval_inval(stuff[MIN].filp, fmax + 1000); + writeval_inval(stuff[MAX].filp, fmin - 1); checkit(); - do_writeval(stuff[MIN].filp, 0x11111110, EINVAL); - do_writeval(stuff[MAX].filp, 0, EINVAL); + writeval_inval(stuff[MIN].filp, 0x11111110); + writeval_inval(stuff[MAX].filp, 0); writeval(stuff[MIN].filp, origmin); writeval(stuff[MAX].filp, origmax);