From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756679AbdGCOxw (ORCPT ); Mon, 3 Jul 2017 10:53:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43232 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932258AbdGCOur (ORCPT ); Mon, 3 Jul 2017 10:50:47 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7763C6AAF4 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=jolsa@kernel.org DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7763C6AAF4 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Peter Zijlstra , Namhyung Kim , David Ahern , Thomas Richter Subject: [PATCH 04/15] perf tests attr: Make compare_data global Date: Mon, 3 Jul 2017 16:50:19 +0200 Message-Id: <20170703145030.12903-5-jolsa@kernel.org> In-Reply-To: <20170703145030.12903-1-jolsa@kernel.org> References: <20170703145030.12903-1-jolsa@kernel.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 03 Jul 2017 14:50:41 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Making compare_data global, so it could be used outside the Test class scope to compare command results. Link: http://lkml.kernel.org/n/tip-5wm3kyb6hkuldvt4f8s8qa3s@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/tests/attr.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tools/perf/tests/attr.py b/tools/perf/tests/attr.py index cdf21a9d0c35..bb671cd1d66a 100644 --- a/tools/perf/tests/attr.py +++ b/tools/perf/tests/attr.py @@ -9,6 +9,20 @@ import logging import shutil import ConfigParser +def compare_data(a, b): + # Allow multiple values in assignment separated by '|' + a_list = a.split('|') + b_list = b.split('|') + + for a_item in a_list: + for b_item in b_list: + if (a_item == b_item): + return True + elif (a_item == '*') or (b_item == '*'): + return True + + return False + class Fail(Exception): def __init__(self, test, msg): self.msg = msg @@ -82,26 +96,12 @@ class Event(dict): self.add(base) self.add(data) - def compare_data(self, a, b): - # Allow multiple values in assignment separated by '|' - a_list = a.split('|') - b_list = b.split('|') - - for a_item in a_list: - for b_item in b_list: - if (a_item == b_item): - return True - elif (a_item == '*') or (b_item == '*'): - return True - - return False - def equal(self, other): for t in Event.terms: log.debug(" [%s] %s %s" % (t, self[t], other[t])); if not self.has_key(t) or not other.has_key(t): return False - if not self.compare_data(self[t], other[t]): + if not compare_data(self[t], other[t]): return False return True @@ -109,7 +109,7 @@ class Event(dict): for t in Event.terms: if not self.has_key(t) or not other.has_key(t): continue - if not self.compare_data(self[t], other[t]): + if not compare_data(self[t], other[t]): log.warning("expected %s=%s, got %s" % (t, self[t], other[t])) # Test file description needs to have following sections: @@ -218,9 +218,9 @@ class Test(object): self.perf, self.command, tempdir, self.args) ret = os.WEXITSTATUS(os.system(cmd)) - log.info(" '%s' ret %d " % (cmd, ret)) + log.info(" '%s' ret '%s', expected '%s'" % (cmd, str(ret), str(self.ret))) - if ret != int(self.ret): + if not compare_data(str(ret), str(self.ret)): raise Unsup(self) def compare(self, expect, result): -- 2.9.4