[PATCH 4/4] perf, test: Add automated tests for event group parsing

2012-07-19 Thread Jiri Olsa
Adding 5 more tests for new event group syntax. Tests are executed
within the 'perf test parse' test suite.

Signed-off-by: Jiri Olsa 
---
 tools/perf/util/parse-events-test.c |  303 ++-
 1 file changed, 300 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/parse-events-test.c 
b/tools/perf/util/parse-events-test.c
index 1b997d2..6200e3f 100644
--- a/tools/perf/util/parse-events-test.c
+++ b/tools/perf/util/parse-events-test.c
@@ -513,6 +513,286 @@ static int test__checkterms_simple(struct list_head 
*terms)
return 0;
 }
 
+static int test__group1(struct perf_evlist *evlist)
+{
+   struct perf_evsel *evsel, *leader;
+
+   TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
+
+   /* instructions:k */
+   evsel = leader = list_entry(evlist->entries.next,
+   struct perf_evsel, node);
+   TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
+   TEST_ASSERT_VAL("wrong config",
+   PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
+   TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
+   TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
+   TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
+   TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
+   TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
+   TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
+   TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL);
+
+   /* cycles:upp */
+   evsel = list_entry(evsel->node.next, struct perf_evsel, node);
+   TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
+   TEST_ASSERT_VAL("wrong config",
+   PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
+   TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
+   TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
+   TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
+   TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
+   TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
+   TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2);
+   TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
+
+   return 0;
+}
+
+static int test__group2(struct perf_evlist *evlist)
+{
+   struct perf_evsel *evsel, *leader;
+
+   TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
+
+   /* faults + :ku modifier */
+   evsel = leader = list_entry(evlist->entries.next,
+   struct perf_evsel, node);
+   TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type);
+   TEST_ASSERT_VAL("wrong config",
+   PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config);
+   TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
+   TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
+   TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
+   TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
+   TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
+   TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
+   TEST_ASSERT_VAL("wrong leader", evsel->leader == NULL);
+
+   /* cache-references + :u modifier */
+   evsel = list_entry(evsel->node.next, struct perf_evsel, node);
+   TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
+   TEST_ASSERT_VAL("wrong config",
+   PERF_COUNT_HW_CACHE_REFERENCES == evsel->attr.config);
+   TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
+   TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
+   TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
+   TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
+   TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
+   TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
+   TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
+
+   /* cycles:k */
+   evsel = list_entry(evsel->node.next, struct perf_evsel, node);
+   TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
+   TEST_ASSERT_VAL("wrong config",
+   PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
+   TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
+   TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
+   TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
+   TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
+   TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
+   TEST_ASSERT_VAL("wrong precise_ip", 

[PATCH 4/4] perf, test: Add automated tests for event group parsing

2012-07-19 Thread Jiri Olsa
Adding 5 more tests for new event group syntax. Tests are executed
within the 'perf test parse' test suite.

Signed-off-by: Jiri Olsa jo...@redhat.com
---
 tools/perf/util/parse-events-test.c |  303 ++-
 1 file changed, 300 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/parse-events-test.c 
b/tools/perf/util/parse-events-test.c
index 1b997d2..6200e3f 100644
--- a/tools/perf/util/parse-events-test.c
+++ b/tools/perf/util/parse-events-test.c
@@ -513,6 +513,286 @@ static int test__checkterms_simple(struct list_head 
*terms)
return 0;
 }
 
+static int test__group1(struct perf_evlist *evlist)
+{
+   struct perf_evsel *evsel, *leader;
+
+   TEST_ASSERT_VAL(wrong number of entries, 2 == evlist-nr_entries);
+
+   /* instructions:k */
+   evsel = leader = list_entry(evlist-entries.next,
+   struct perf_evsel, node);
+   TEST_ASSERT_VAL(wrong type, PERF_TYPE_HARDWARE == evsel-attr.type);
+   TEST_ASSERT_VAL(wrong config,
+   PERF_COUNT_HW_INSTRUCTIONS == evsel-attr.config);
+   TEST_ASSERT_VAL(wrong exclude_user, evsel-attr.exclude_user);
+   TEST_ASSERT_VAL(wrong exclude_kernel, !evsel-attr.exclude_kernel);
+   TEST_ASSERT_VAL(wrong exclude_hv, evsel-attr.exclude_hv);
+   TEST_ASSERT_VAL(wrong exclude guest, !evsel-attr.exclude_guest);
+   TEST_ASSERT_VAL(wrong exclude host, !evsel-attr.exclude_host);
+   TEST_ASSERT_VAL(wrong precise_ip, !evsel-attr.precise_ip);
+   TEST_ASSERT_VAL(wrong leader, evsel-leader == NULL);
+
+   /* cycles:upp */
+   evsel = list_entry(evsel-node.next, struct perf_evsel, node);
+   TEST_ASSERT_VAL(wrong type, PERF_TYPE_HARDWARE == evsel-attr.type);
+   TEST_ASSERT_VAL(wrong config,
+   PERF_COUNT_HW_CPU_CYCLES == evsel-attr.config);
+   TEST_ASSERT_VAL(wrong exclude_user, !evsel-attr.exclude_user);
+   TEST_ASSERT_VAL(wrong exclude_kernel, evsel-attr.exclude_kernel);
+   TEST_ASSERT_VAL(wrong exclude_hv, evsel-attr.exclude_hv);
+   TEST_ASSERT_VAL(wrong exclude guest, !evsel-attr.exclude_guest);
+   TEST_ASSERT_VAL(wrong exclude host, !evsel-attr.exclude_host);
+   TEST_ASSERT_VAL(wrong precise_ip, evsel-attr.precise_ip == 2);
+   TEST_ASSERT_VAL(wrong leader, evsel-leader == leader);
+
+   return 0;
+}
+
+static int test__group2(struct perf_evlist *evlist)
+{
+   struct perf_evsel *evsel, *leader;
+
+   TEST_ASSERT_VAL(wrong number of entries, 3 == evlist-nr_entries);
+
+   /* faults + :ku modifier */
+   evsel = leader = list_entry(evlist-entries.next,
+   struct perf_evsel, node);
+   TEST_ASSERT_VAL(wrong type, PERF_TYPE_SOFTWARE == evsel-attr.type);
+   TEST_ASSERT_VAL(wrong config,
+   PERF_COUNT_SW_PAGE_FAULTS == evsel-attr.config);
+   TEST_ASSERT_VAL(wrong exclude_user, !evsel-attr.exclude_user);
+   TEST_ASSERT_VAL(wrong exclude_kernel, !evsel-attr.exclude_kernel);
+   TEST_ASSERT_VAL(wrong exclude_hv, evsel-attr.exclude_hv);
+   TEST_ASSERT_VAL(wrong exclude guest, !evsel-attr.exclude_guest);
+   TEST_ASSERT_VAL(wrong exclude host, !evsel-attr.exclude_host);
+   TEST_ASSERT_VAL(wrong precise_ip, !evsel-attr.precise_ip);
+   TEST_ASSERT_VAL(wrong leader, evsel-leader == NULL);
+
+   /* cache-references + :u modifier */
+   evsel = list_entry(evsel-node.next, struct perf_evsel, node);
+   TEST_ASSERT_VAL(wrong type, PERF_TYPE_HARDWARE == evsel-attr.type);
+   TEST_ASSERT_VAL(wrong config,
+   PERF_COUNT_HW_CACHE_REFERENCES == evsel-attr.config);
+   TEST_ASSERT_VAL(wrong exclude_user, !evsel-attr.exclude_user);
+   TEST_ASSERT_VAL(wrong exclude_kernel, evsel-attr.exclude_kernel);
+   TEST_ASSERT_VAL(wrong exclude_hv, evsel-attr.exclude_hv);
+   TEST_ASSERT_VAL(wrong exclude guest, !evsel-attr.exclude_guest);
+   TEST_ASSERT_VAL(wrong exclude host, !evsel-attr.exclude_host);
+   TEST_ASSERT_VAL(wrong precise_ip, !evsel-attr.precise_ip);
+   TEST_ASSERT_VAL(wrong leader, evsel-leader == leader);
+
+   /* cycles:k */
+   evsel = list_entry(evsel-node.next, struct perf_evsel, node);
+   TEST_ASSERT_VAL(wrong type, PERF_TYPE_HARDWARE == evsel-attr.type);
+   TEST_ASSERT_VAL(wrong config,
+   PERF_COUNT_HW_CPU_CYCLES == evsel-attr.config);
+   TEST_ASSERT_VAL(wrong exclude_user, evsel-attr.exclude_user);
+   TEST_ASSERT_VAL(wrong exclude_kernel, !evsel-attr.exclude_kernel);
+   TEST_ASSERT_VAL(wrong exclude_hv, evsel-attr.exclude_hv);
+   TEST_ASSERT_VAL(wrong exclude guest, !evsel-attr.exclude_guest);
+   TEST_ASSERT_VAL(wrong exclude host, !evsel-attr.exclude_host);
+   TEST_ASSERT_VAL(wrong precise_ip, !evsel-attr.precise_ip);
+   TEST_ASSERT_VAL(wrong leader, evsel-leader == NULL);
+
+   return 0;
+}
+
+static int