From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>,
Corey Ashford <cjashfor@linux.vnet.ibm.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@elte.hu>, Paul Mackerras <paulus@samba.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Stephane Eranian <eranian@google.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 17/20] perf test: Use ARRAY_SIZE in parse events tests
Date: Thu, 5 Jul 2012 12:45:15 -0300 [thread overview]
Message-ID: <1341503118-13198-18-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1341503118-13198-1-git-send-email-acme@infradead.org>
From: Jiri Olsa <jolsa@redhat.com>
Use ARRAY_SIZE instead of defining the sizes separately for each test
arrays.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1341352848-11833-10-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/parse-events-test.c | 29 ++++++++++-------------------
1 file changed, 10 insertions(+), 19 deletions(-)
diff --git a/tools/perf/util/parse-events-test.c b/tools/perf/util/parse-events-test.c
index dd0c306..1b997d2 100644
--- a/tools/perf/util/parse-events-test.c
+++ b/tools/perf/util/parse-events-test.c
@@ -634,8 +634,6 @@ static struct test__event_st test__events[] = {
},
};
-#define TEST__EVENTS_CNT (sizeof(test__events) / sizeof(struct test__event_st))
-
static struct test__event_st test__events_pmu[] = {
[0] = {
.name = "cpu/config=10,config1,config2=3,period=1000/u",
@@ -647,9 +645,6 @@ static struct test__event_st test__events_pmu[] = {
},
};
-#define TEST__EVENTS_PMU_CNT (sizeof(test__events_pmu) / \
- sizeof(struct test__event_st))
-
struct test__term {
const char *str;
__u32 type;
@@ -765,21 +760,17 @@ int parse_events__test(void)
{
int ret;
- do {
- ret = test_events(test__events, TEST__EVENTS_CNT);
- if (ret)
- break;
-
- if (test_pmu()) {
- ret = test_events(test__events_pmu,
- TEST__EVENTS_PMU_CNT);
- if (ret)
- break;
- }
+#define TEST_EVENTS(tests) \
+do { \
+ ret = test_events(tests, ARRAY_SIZE(tests)); \
+ if (ret) \
+ return ret; \
+} while (0)
- ret = test_terms(test__terms, TEST__TERMS_CNT);
+ TEST_EVENTS(test__events);
- } while (0);
+ if (test_pmu())
+ TEST_EVENTS(test__events_pmu);
- return ret;
+ return test_terms(test__terms, ARRAY_SIZE(test__terms));
}
--
1.7.9.2.358.g22243
next prev parent reply other threads:[~2012-07-05 15:45 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-05 15:44 [GIT PULL 00/20] perf/core improvements and fixes Arnaldo Carvalho de Melo
2012-07-05 15:44 ` [PATCH 01/20] tools lib traceevent: Let filtering numbers by string use function names Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 02/20] tools lib traceevent: Add support for "%.*s" in bprintk events Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 03/20] tools lib traceevent: Add support to show migrate disable counter Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 04/20] tools lib traceevent: Fix %pM print format arg handling Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 05/20] tools lib traceevent: Fix trace_printk for long integers Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 06/20] tools lib traceevent: Fix printk_cmp() Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 07/20] tools lib traceevent: Introduce extend_token() Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 08/20] tools lib traceevent: Handle strdup failure cases Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 09/20] tools lib traceevent: Handle realloc() failure path Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 10/20] tools lib traceevent: Pass string type argument to args Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 11/20] tools lib traceevent: Do not call add_event() again if allocation failed Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 12/20] tools lib traceevent: Fix some comments Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 13/20] tools lib traceevent: Check result of malloc() during reading token Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 14/20] tools lib traceevent: Check return value of arg_to_str() Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 15/20] tools lib traceevent: Add missing break in make_bprint_args Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 16/20] tools lib traceevent: Cleanup realloc use Arnaldo Carvalho de Melo
2012-07-05 15:45 ` Arnaldo Carvalho de Melo [this message]
2012-07-05 15:45 ` [PATCH 18/20] perf tools: Add empty rule for new line in event syntax parsing Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 19/20] perf tools: Split out PE_VALUE_SYM parsing token to SW and HW tokens Arnaldo Carvalho de Melo
2012-07-05 15:45 ` [PATCH 20/20] perf tools: Split event symbols arrays to hw and sw parts Arnaldo Carvalho de Melo
2012-07-06 8:22 ` [GIT PULL 00/20] perf/core improvements and fixes Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1341503118-13198-18-git-send-email-acme@infradead.org \
--to=acme@infradead.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@redhat.com \
--cc=cjashfor@linux.vnet.ibm.com \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@kernel.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).