| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "parse-events.h"
 | 
					
						
							|  |  |  | #include "evsel.h"
 | 
					
						
							|  |  |  | #include "evlist.h"
 | 
					
						
							|  |  |  | #include "sysfs.h"
 | 
					
						
							| 
									
										
										
										
											2013-02-20 16:32:30 +01:00
										 |  |  | #include <lk/debugfs.h>
 | 
					
						
							| 
									
										
										
										
											2012-11-10 01:46:51 +01:00
										 |  |  | #include "tests.h"
 | 
					
						
							| 
									
										
										
										
											2012-11-19 22:21:03 +00:00
										 |  |  | #include <linux/hw_breakpoint.h>
 | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-01 14:48:58 +02:00
										 |  |  | #define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \
 | 
					
						
							|  |  |  | 			     PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | static int test__checkevent_tracepoint(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong sample_type", | 
					
						
							| 
									
										
										
										
											2012-08-01 14:48:58 +02:00
										 |  |  | 		PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_tracepoint_multi(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct perf_evsel *evsel; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	list_for_each_entry(evsel, &evlist->entries, node) { | 
					
						
							|  |  |  | 		TEST_ASSERT_VAL("wrong type", | 
					
						
							|  |  |  | 			PERF_TYPE_TRACEPOINT == evsel->attr.type); | 
					
						
							|  |  |  | 		TEST_ASSERT_VAL("wrong sample_type", | 
					
						
							| 
									
										
										
										
											2012-08-01 14:48:58 +02:00
										 |  |  | 			PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 		TEST_ASSERT_VAL("wrong sample_period", | 
					
						
							|  |  |  | 			1 == evsel->attr.sample_period); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_raw(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", 0x1a == evsel->attr.config); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_numeric(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_symbolic_name(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", | 
					
						
							|  |  |  | 			PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 
					
						
							|  |  |  | 	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 period", | 
					
						
							|  |  |  | 			100000 == evsel->attr.sample_period); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config1", | 
					
						
							|  |  |  | 			0 == evsel->attr.config1); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config2", | 
					
						
							|  |  |  | 			1 == evsel->attr.config2); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_symbolic_alias(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", | 
					
						
							|  |  |  | 			PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_genhw(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", (1 << 16) == evsel->attr.config); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_breakpoint(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) == | 
					
						
							|  |  |  | 					 evsel->attr.bp_type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 == | 
					
						
							|  |  |  | 					evsel->attr.bp_len); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_breakpoint_x(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong bp_type", | 
					
						
							|  |  |  | 			HW_BREAKPOINT_X == evsel->attr.bp_type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong bp_len", sizeof(long) == evsel->attr.bp_len); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_breakpoint_r(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", | 
					
						
							|  |  |  | 			PERF_TYPE_BREAKPOINT == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong bp_type", | 
					
						
							|  |  |  | 			HW_BREAKPOINT_R == evsel->attr.bp_type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong bp_len", | 
					
						
							|  |  |  | 			HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_breakpoint_w(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", | 
					
						
							|  |  |  | 			PERF_TYPE_BREAKPOINT == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong bp_type", | 
					
						
							|  |  |  | 			HW_BREAKPOINT_W == evsel->attr.bp_type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong bp_len", | 
					
						
							|  |  |  | 			HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-29 09:22:54 +02:00
										 |  |  | static int test__checkevent_breakpoint_rw(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-06-29 09:22:54 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", | 
					
						
							|  |  |  | 			PERF_TYPE_BREAKPOINT == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong bp_type", | 
					
						
							|  |  |  | 		(HW_BREAKPOINT_R|HW_BREAKPOINT_W) == evsel->attr.bp_type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong bp_len", | 
					
						
							|  |  |  | 			HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len); | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | static int test__checkevent_tracepoint_modifier(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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 precise_ip", !evsel->attr.precise_ip); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return test__checkevent_tracepoint(evlist); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int | 
					
						
							|  |  |  | test__checkevent_tracepoint_multi_modifier(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct perf_evsel *evsel; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	list_for_each_entry(evsel, &evlist->entries, node) { | 
					
						
							|  |  |  | 		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 precise_ip", !evsel->attr.precise_ip); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return test__checkevent_tracepoint_multi(evlist); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_raw_modifier(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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 precise_ip", evsel->attr.precise_ip); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return test__checkevent_raw(evlist); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_numeric_modifier(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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 precise_ip", evsel->attr.precise_ip); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return test__checkevent_numeric(evlist); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_symbolic_name_modifier(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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 precise_ip", !evsel->attr.precise_ip); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return test__checkevent_symbolic_name(evlist); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_exclude_host_modifier(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return test__checkevent_symbolic_name(evlist); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_exclude_guest_modifier(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return test__checkevent_symbolic_name(evlist); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_symbolic_alias_modifier(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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 precise_ip", !evsel->attr.precise_ip); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return test__checkevent_symbolic_alias(evlist); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_genhw_modifier(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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 precise_ip", evsel->attr.precise_ip); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return test__checkevent_genhw(evlist); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	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 precise_ip", !evsel->attr.precise_ip); | 
					
						
							| 
									
										
										
										
											2012-06-28 23:18:49 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong name", | 
					
						
							| 
									
										
										
										
											2012-08-16 21:10:21 +02:00
										 |  |  | 			!strcmp(perf_evsel__name(evsel), "mem:0:u")); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return test__checkevent_breakpoint(evlist); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_breakpoint_x_modifier(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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 precise_ip", !evsel->attr.precise_ip); | 
					
						
							| 
									
										
										
										
											2012-06-28 23:18:49 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong name", | 
					
						
							| 
									
										
										
										
											2012-08-16 21:10:21 +02:00
										 |  |  | 			!strcmp(perf_evsel__name(evsel), "mem:0:x:k")); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return test__checkevent_breakpoint_x(evlist); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_breakpoint_r_modifier(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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 precise_ip", evsel->attr.precise_ip); | 
					
						
							| 
									
										
										
										
											2012-06-28 23:18:49 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong name", | 
					
						
							| 
									
										
										
										
											2012-08-16 21:10:21 +02:00
										 |  |  | 			!strcmp(perf_evsel__name(evsel), "mem:0:r:hp")); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return test__checkevent_breakpoint_r(evlist); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_breakpoint_w_modifier(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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 precise_ip", evsel->attr.precise_ip); | 
					
						
							| 
									
										
										
										
											2012-06-28 23:18:49 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong name", | 
					
						
							| 
									
										
										
										
											2012-08-16 21:10:21 +02:00
										 |  |  | 			!strcmp(perf_evsel__name(evsel), "mem:0:w:up")); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return test__checkevent_breakpoint_w(evlist); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-29 09:22:54 +02:00
										 |  |  | static int test__checkevent_breakpoint_rw_modifier(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-06-29 09:22:54 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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 precise_ip", evsel->attr.precise_ip); | 
					
						
							| 
									
										
										
										
											2012-06-28 23:18:49 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong name", | 
					
						
							| 
									
										
										
										
											2012-08-16 21:10:21 +02:00
										 |  |  | 			!strcmp(perf_evsel__name(evsel), "mem:0:rw:kp")); | 
					
						
							| 
									
										
										
										
											2012-06-29 09:22:54 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return test__checkevent_breakpoint_rw(evlist); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | static int test__checkevent_pmu(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config",    10 == evsel->attr.config); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config1",    1 == evsel->attr.config1); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config2",    3 == evsel->attr.config2); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong period",  1000 == evsel->attr.sample_period); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__checkevent_list(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* r1 */ | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config1", 0 == evsel->attr.config1); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config2", 0 == evsel->attr.config2); | 
					
						
							|  |  |  | 	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 precise_ip", !evsel->attr.precise_ip); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* syscalls:sys_enter_open:k */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong sample_type", | 
					
						
							| 
									
										
										
										
											2012-08-01 14:48:58 +02:00
										 |  |  | 		PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); | 
					
						
							|  |  |  | 	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 precise_ip", !evsel->attr.precise_ip); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* 1:1:hp */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", 1 == 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 precise_ip", evsel->attr.precise_ip); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:53 +02:00
										 |  |  | static int test__checkevent_pmu_name(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:53 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-21 12:25:16 +02:00
										 |  |  | 	/* cpu/config=1,name=krava/u */ | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:53 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config",  1 == evsel->attr.config); | 
					
						
							| 
									
										
										
										
											2012-06-12 13:55:13 -03:00
										 |  |  | 	TEST_ASSERT_VAL("wrong name", !strcmp(perf_evsel__name(evsel), "krava")); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:53 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-21 12:25:16 +02:00
										 |  |  | 	/* cpu/config=2/u" */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:53 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config",  2 == evsel->attr.config); | 
					
						
							| 
									
										
										
										
											2012-06-21 12:25:16 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong name", | 
					
						
							| 
									
										
										
										
											2012-08-16 21:10:21 +02:00
										 |  |  | 			!strcmp(perf_evsel__name(evsel), "cpu/config=2/u")); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:53 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-10 14:53:18 +02:00
										 |  |  | static int test__checkevent_pmu_events(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct perf_evsel *evsel; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	evsel = list_entry(evlist->entries.next, struct perf_evsel, node); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type); | 
					
						
							|  |  |  | 	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 precise_ip", !evsel->attr.precise_ip); | 
					
						
							| 
									
										
										
										
											2013-08-06 23:28:06 +10:00
										 |  |  | 	TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); | 
					
						
							| 
									
										
										
										
											2012-10-10 14:53:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | static int test__checkterms_simple(struct list_head *terms) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-01-18 16:29:49 -03:00
										 |  |  | 	struct parse_events_term *term; | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* config=10 */ | 
					
						
							| 
									
										
										
										
											2013-01-18 16:29:49 -03:00
										 |  |  | 	term = list_entry(terms->next, struct parse_events_term, list); | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | 	TEST_ASSERT_VAL("wrong type term", | 
					
						
							|  |  |  | 			term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type val", | 
					
						
							|  |  |  | 			term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong val", term->val.num == 10); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", !term->config); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* config1 */ | 
					
						
							| 
									
										
										
										
											2013-01-18 16:29:49 -03:00
										 |  |  | 	term = list_entry(term->list.next, struct parse_events_term, list); | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | 	TEST_ASSERT_VAL("wrong type term", | 
					
						
							|  |  |  | 			term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG1); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type val", | 
					
						
							|  |  |  | 			term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong val", term->val.num == 1); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", !term->config); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* config2=3 */ | 
					
						
							| 
									
										
										
										
											2013-01-18 16:29:49 -03:00
										 |  |  | 	term = list_entry(term->list.next, struct parse_events_term, list); | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | 	TEST_ASSERT_VAL("wrong type term", | 
					
						
							|  |  |  | 			term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG2); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type val", | 
					
						
							|  |  |  | 			term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong val", term->val.num == 3); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", !term->config); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* umask=1*/ | 
					
						
							| 
									
										
										
										
											2013-01-18 16:29:49 -03:00
										 |  |  | 	term = list_entry(term->list.next, struct parse_events_term, list); | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | 	TEST_ASSERT_VAL("wrong type term", | 
					
						
							|  |  |  | 			term->type_term == PARSE_EVENTS__TERM_TYPE_USER); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type val", | 
					
						
							|  |  |  | 			term->type_val == PARSE_EVENTS__TERM_TYPE_NUM); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong val", term->val.num == 1); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "umask")); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | static int test__group1(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct perf_evsel *evsel, *leader; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* instructions:k */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = leader = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2012-11-29 15:38:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* cycles:upp */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2012-10-20 18:29:34 +02:00
										 |  |  | 	/* use of precise requires exclude_guest */ | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* faults + :ku modifier */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = leader = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2012-11-29 15:38:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* cache-references + :u modifier */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2013-02-04 10:56:43 +01:00
										 |  |  | 	TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* cycles:k */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2012-11-29 15:38:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-11 01:15:03 +03:00
										 |  |  | static int test__group3(struct perf_evlist *evlist __maybe_unused) | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct perf_evsel *evsel, *leader; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* group1 syscalls:sys_enter_open:H */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = leader = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong sample_type", | 
					
						
							|  |  |  | 		PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period); | 
					
						
							|  |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2012-11-29 15:38:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong group name", | 
					
						
							|  |  |  | 		!strcmp(leader->group_name, "group1")); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* group1 cycles:kppp */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2012-10-20 18:29:34 +02:00
										 |  |  | 	/* use of precise requires exclude_guest */ | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 3); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* group2 cycles + G modifier */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = leader = perf_evsel__next(evsel); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2012-11-29 15:38:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong group name", | 
					
						
							|  |  |  | 		!strcmp(leader->group_name, "group2")); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* group2 1:3 + G modifier */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", 3 == 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); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* instructions:u */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2012-11-29 15:38:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-11 01:15:03 +03:00
										 |  |  | static int test__group4(struct perf_evlist *evlist __maybe_unused) | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct perf_evsel *evsel, *leader; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* cycles:u + p */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = leader = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2012-10-20 18:29:34 +02:00
										 |  |  | 	/* use of precise requires exclude_guest */ | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 1); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group name", !evsel->group_name); | 
					
						
							| 
									
										
										
										
											2012-11-29 15:38:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* instructions:kp + p */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2012-10-20 18:29:34 +02:00
										 |  |  | 	/* use of precise requires exclude_guest */ | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-11 01:15:03 +03:00
										 |  |  | static int test__group5(struct perf_evlist *evlist __maybe_unused) | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct perf_evsel *evsel, *leader; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* cycles + G */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = leader = perf_evlist__first(evlist); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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 group name", !evsel->group_name); | 
					
						
							| 
									
										
										
										
											2012-11-29 15:38:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* instructions + G */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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 == leader); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* cycles:G */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = leader = perf_evsel__next(evsel); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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 group name", !evsel->group_name); | 
					
						
							| 
									
										
										
										
											2012-11-29 15:38:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | 	TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* instructions:G */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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 == leader); | 
					
						
							| 
									
										
										
										
											2013-01-22 18:09:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* cycles */ | 
					
						
							| 
									
										
										
										
											2012-08-14 16:42:15 -03:00
										 |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	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); | 
					
						
							| 
									
										
										
										
											2012-11-29 15:38:30 +09:00
										 |  |  | 	TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-04 10:56:43 +01:00
										 |  |  | static int test__group_gh1(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct perf_evsel *evsel, *leader; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* cycles + :H group modifier */ | 
					
						
							|  |  |  | 	evsel = leader = perf_evlist__first(evlist); | 
					
						
							|  |  |  | 	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 group name", !evsel->group_name); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* cache-misses:G + :H group modifier */ | 
					
						
							|  |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", | 
					
						
							|  |  |  | 			PERF_COUNT_HW_CACHE_MISSES == 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); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__group_gh2(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct perf_evsel *evsel, *leader; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* cycles + :G group modifier */ | 
					
						
							|  |  |  | 	evsel = leader = perf_evlist__first(evlist); | 
					
						
							|  |  |  | 	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 group name", !evsel->group_name); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* cache-misses:H + :G group modifier */ | 
					
						
							|  |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", | 
					
						
							|  |  |  | 			PERF_COUNT_HW_CACHE_MISSES == 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); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__group_gh3(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct perf_evsel *evsel, *leader; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* cycles:G + :u group modifier */ | 
					
						
							|  |  |  | 	evsel = leader = perf_evlist__first(evlist); | 
					
						
							|  |  |  | 	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 group name", !evsel->group_name); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* cache-misses:H + :u group modifier */ | 
					
						
							|  |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", | 
					
						
							|  |  |  | 			PERF_COUNT_HW_CACHE_MISSES == 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); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__group_gh4(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct perf_evsel *evsel, *leader; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* cycles:G + :uG group modifier */ | 
					
						
							|  |  |  | 	evsel = leader = perf_evlist__first(evlist); | 
					
						
							|  |  |  | 	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 group name", !evsel->group_name); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel)); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* cache-misses:H + :uG group modifier */ | 
					
						
							|  |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", | 
					
						
							|  |  |  | 			PERF_COUNT_HW_CACHE_MISSES == 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); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | static int test__leader_sample1(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct perf_evsel *evsel, *leader; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* cycles - sampling group leader */ | 
					
						
							|  |  |  | 	evsel = leader = perf_evlist__first(evlist); | 
					
						
							|  |  |  | 	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 group name", !evsel->group_name); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* cache-misses - not sampling */ | 
					
						
							|  |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", | 
					
						
							|  |  |  | 			PERF_COUNT_HW_CACHE_MISSES == 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); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* branch-misses - not sampling */ | 
					
						
							|  |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", | 
					
						
							|  |  |  | 			PERF_COUNT_HW_BRANCH_MISSES == 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 group name", !evsel->group_name); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__leader_sample2(struct perf_evlist *evlist __maybe_unused) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct perf_evsel *evsel, *leader; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* instructions - sampling group leader */ | 
					
						
							|  |  |  | 	evsel = leader = perf_evlist__first(evlist); | 
					
						
							|  |  |  | 	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 group name", !evsel->group_name); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* branch-misses - not sampling */ | 
					
						
							|  |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", | 
					
						
							|  |  |  | 			PERF_COUNT_HW_BRANCH_MISSES == 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 group name", !evsel->group_name); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-06 23:28:06 +10:00
										 |  |  | static int test__checkevent_pinned_modifier(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct perf_evsel *evsel = perf_evlist__first(evlist); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	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 precise_ip", evsel->attr.precise_ip); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return test__checkevent_symbolic_name(evlist); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__pinned_group(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct perf_evsel *evsel, *leader; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* cycles - group leader */ | 
					
						
							|  |  |  | 	evsel = leader = perf_evlist__first(evlist); | 
					
						
							|  |  |  | 	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 group name", !evsel->group_name); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* cache-misses - can not be pinned, but will go on with the leader */ | 
					
						
							|  |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", | 
					
						
							|  |  |  | 			PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* branch-misses - ditto */ | 
					
						
							|  |  |  | 	evsel = perf_evsel__next(evsel); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong config", | 
					
						
							|  |  |  | 			PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config); | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-17 14:08:38 +01:00
										 |  |  | static int count_tracepoints(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	char events_path[PATH_MAX]; | 
					
						
							|  |  |  | 	struct dirent *events_ent; | 
					
						
							|  |  |  | 	DIR *events_dir; | 
					
						
							|  |  |  | 	int cnt = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	scnprintf(events_path, PATH_MAX, "%s/tracing/events", | 
					
						
							|  |  |  | 		  debugfs_find_mountpoint()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	events_dir = opendir(events_path); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("Can't open events dir", events_dir); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	while ((events_ent = readdir(events_dir))) { | 
					
						
							|  |  |  | 		char sys_path[PATH_MAX]; | 
					
						
							|  |  |  | 		struct dirent *sys_ent; | 
					
						
							|  |  |  | 		DIR *sys_dir; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (!strcmp(events_ent->d_name, ".") | 
					
						
							|  |  |  | 		    || !strcmp(events_ent->d_name, "..") | 
					
						
							|  |  |  | 		    || !strcmp(events_ent->d_name, "enable") | 
					
						
							|  |  |  | 		    || !strcmp(events_ent->d_name, "header_event") | 
					
						
							|  |  |  | 		    || !strcmp(events_ent->d_name, "header_page")) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		scnprintf(sys_path, PATH_MAX, "%s/%s", | 
					
						
							|  |  |  | 			  events_path, events_ent->d_name); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		sys_dir = opendir(sys_path); | 
					
						
							|  |  |  | 		TEST_ASSERT_VAL("Can't open sys dir", sys_dir); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		while ((sys_ent = readdir(sys_dir))) { | 
					
						
							|  |  |  | 			if (!strcmp(sys_ent->d_name, ".") | 
					
						
							|  |  |  | 			    || !strcmp(sys_ent->d_name, "..") | 
					
						
							|  |  |  | 			    || !strcmp(sys_ent->d_name, "enable") | 
					
						
							|  |  |  | 			    || !strcmp(sys_ent->d_name, "filter")) | 
					
						
							|  |  |  | 				continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			cnt++; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		closedir(sys_dir); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	closedir(events_dir); | 
					
						
							|  |  |  | 	return cnt; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test__all_tracepoints(struct perf_evlist *evlist) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	TEST_ASSERT_VAL("wrong events count", | 
					
						
							|  |  |  | 			count_tracepoints() == evlist->nr_entries); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return test__checkevent_tracepoint_multi(evlist); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-18 16:56:57 -03:00
										 |  |  | struct evlist_test { | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 	const char *name; | 
					
						
							|  |  |  | 	__u32 type; | 
					
						
							|  |  |  | 	int (*check)(struct perf_evlist *evlist); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-18 16:56:57 -03:00
										 |  |  | static struct evlist_test test__events[] = { | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 	[0] = { | 
					
						
							|  |  |  | 		.name  = "syscalls:sys_enter_open", | 
					
						
							|  |  |  | 		.check = test__checkevent_tracepoint, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[1] = { | 
					
						
							|  |  |  | 		.name  = "syscalls:*", | 
					
						
							|  |  |  | 		.check = test__checkevent_tracepoint_multi, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[2] = { | 
					
						
							|  |  |  | 		.name  = "r1a", | 
					
						
							|  |  |  | 		.check = test__checkevent_raw, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[3] = { | 
					
						
							|  |  |  | 		.name  = "1:1", | 
					
						
							|  |  |  | 		.check = test__checkevent_numeric, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[4] = { | 
					
						
							|  |  |  | 		.name  = "instructions", | 
					
						
							|  |  |  | 		.check = test__checkevent_symbolic_name, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[5] = { | 
					
						
							|  |  |  | 		.name  = "cycles/period=100000,config2/", | 
					
						
							|  |  |  | 		.check = test__checkevent_symbolic_name_config, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[6] = { | 
					
						
							|  |  |  | 		.name  = "faults", | 
					
						
							|  |  |  | 		.check = test__checkevent_symbolic_alias, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[7] = { | 
					
						
							|  |  |  | 		.name  = "L1-dcache-load-miss", | 
					
						
							|  |  |  | 		.check = test__checkevent_genhw, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[8] = { | 
					
						
							|  |  |  | 		.name  = "mem:0", | 
					
						
							|  |  |  | 		.check = test__checkevent_breakpoint, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[9] = { | 
					
						
							|  |  |  | 		.name  = "mem:0:x", | 
					
						
							|  |  |  | 		.check = test__checkevent_breakpoint_x, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[10] = { | 
					
						
							|  |  |  | 		.name  = "mem:0:r", | 
					
						
							|  |  |  | 		.check = test__checkevent_breakpoint_r, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[11] = { | 
					
						
							|  |  |  | 		.name  = "mem:0:w", | 
					
						
							|  |  |  | 		.check = test__checkevent_breakpoint_w, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[12] = { | 
					
						
							|  |  |  | 		.name  = "syscalls:sys_enter_open:k", | 
					
						
							|  |  |  | 		.check = test__checkevent_tracepoint_modifier, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[13] = { | 
					
						
							|  |  |  | 		.name  = "syscalls:*:u", | 
					
						
							|  |  |  | 		.check = test__checkevent_tracepoint_multi_modifier, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[14] = { | 
					
						
							|  |  |  | 		.name  = "r1a:kp", | 
					
						
							|  |  |  | 		.check = test__checkevent_raw_modifier, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[15] = { | 
					
						
							|  |  |  | 		.name  = "1:1:hp", | 
					
						
							|  |  |  | 		.check = test__checkevent_numeric_modifier, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[16] = { | 
					
						
							|  |  |  | 		.name  = "instructions:h", | 
					
						
							|  |  |  | 		.check = test__checkevent_symbolic_name_modifier, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[17] = { | 
					
						
							|  |  |  | 		.name  = "faults:u", | 
					
						
							|  |  |  | 		.check = test__checkevent_symbolic_alias_modifier, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[18] = { | 
					
						
							|  |  |  | 		.name  = "L1-dcache-load-miss:kp", | 
					
						
							|  |  |  | 		.check = test__checkevent_genhw_modifier, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[19] = { | 
					
						
							|  |  |  | 		.name  = "mem:0:u", | 
					
						
							|  |  |  | 		.check = test__checkevent_breakpoint_modifier, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[20] = { | 
					
						
							|  |  |  | 		.name  = "mem:0:x:k", | 
					
						
							|  |  |  | 		.check = test__checkevent_breakpoint_x_modifier, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[21] = { | 
					
						
							|  |  |  | 		.name  = "mem:0:r:hp", | 
					
						
							|  |  |  | 		.check = test__checkevent_breakpoint_r_modifier, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[22] = { | 
					
						
							|  |  |  | 		.name  = "mem:0:w:up", | 
					
						
							|  |  |  | 		.check = test__checkevent_breakpoint_w_modifier, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[23] = { | 
					
						
							|  |  |  | 		.name  = "r1,syscalls:sys_enter_open:k,1:1:hp", | 
					
						
							|  |  |  | 		.check = test__checkevent_list, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[24] = { | 
					
						
							|  |  |  | 		.name  = "instructions:G", | 
					
						
							|  |  |  | 		.check = test__checkevent_exclude_host_modifier, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[25] = { | 
					
						
							|  |  |  | 		.name  = "instructions:H", | 
					
						
							|  |  |  | 		.check = test__checkevent_exclude_guest_modifier, | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2012-06-29 09:22:54 +02:00
										 |  |  | 	[26] = { | 
					
						
							|  |  |  | 		.name  = "mem:0:rw", | 
					
						
							|  |  |  | 		.check = test__checkevent_breakpoint_rw, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[27] = { | 
					
						
							|  |  |  | 		.name  = "mem:0:rw:kp", | 
					
						
							|  |  |  | 		.check = test__checkevent_breakpoint_rw_modifier, | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2012-08-08 12:23:52 +02:00
										 |  |  | 	[28] = { | 
					
						
							|  |  |  | 		.name  = "{instructions:k,cycles:upp}", | 
					
						
							|  |  |  | 		.check = test__group1, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[29] = { | 
					
						
							|  |  |  | 		.name  = "{faults:k,cache-references}:u,cycles:k", | 
					
						
							|  |  |  | 		.check = test__group2, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[30] = { | 
					
						
							|  |  |  | 		.name  = "group1{syscalls:sys_enter_open:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u", | 
					
						
							|  |  |  | 		.check = test__group3, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[31] = { | 
					
						
							|  |  |  | 		.name  = "{cycles:u,instructions:kp}:p", | 
					
						
							|  |  |  | 		.check = test__group4, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[32] = { | 
					
						
							|  |  |  | 		.name  = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles", | 
					
						
							|  |  |  | 		.check = test__group5, | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2012-12-17 14:08:38 +01:00
										 |  |  | 	[33] = { | 
					
						
							|  |  |  | 		.name  = "*:*", | 
					
						
							|  |  |  | 		.check = test__all_tracepoints, | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2013-02-04 10:56:43 +01:00
										 |  |  | 	[34] = { | 
					
						
							|  |  |  | 		.name  = "{cycles,cache-misses:G}:H", | 
					
						
							|  |  |  | 		.check = test__group_gh1, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[35] = { | 
					
						
							|  |  |  | 		.name  = "{cycles,cache-misses:H}:G", | 
					
						
							|  |  |  | 		.check = test__group_gh2, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[36] = { | 
					
						
							|  |  |  | 		.name  = "{cycles:G,cache-misses:H}:u", | 
					
						
							|  |  |  | 		.check = test__group_gh3, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[37] = { | 
					
						
							|  |  |  | 		.name  = "{cycles:G,cache-misses:H}:uG", | 
					
						
							|  |  |  | 		.check = test__group_gh4, | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2013-02-01 20:37:11 +01:00
										 |  |  | 	[38] = { | 
					
						
							|  |  |  | 		.name  = "{cycles,cache-misses,branch-misses}:S", | 
					
						
							|  |  |  | 		.check = test__leader_sample1, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[39] = { | 
					
						
							|  |  |  | 		.name  = "{instructions,branch-misses}:Su", | 
					
						
							|  |  |  | 		.check = test__leader_sample2, | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2013-08-06 23:28:06 +10:00
										 |  |  | 	[40] = { | 
					
						
							|  |  |  | 		.name  = "instructions:uDp", | 
					
						
							|  |  |  | 		.check = test__checkevent_pinned_modifier, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 	[41] = { | 
					
						
							|  |  |  | 		.name  = "{cycles,cache-misses,branch-misses}:D", | 
					
						
							|  |  |  | 		.check = test__pinned_group, | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-18 16:56:57 -03:00
										 |  |  | static struct evlist_test test__events_pmu[] = { | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 	[0] = { | 
					
						
							|  |  |  | 		.name  = "cpu/config=10,config1,config2=3,period=1000/u", | 
					
						
							|  |  |  | 		.check = test__checkevent_pmu, | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:53 +02:00
										 |  |  | 	[1] = { | 
					
						
							|  |  |  | 		.name  = "cpu/config=1,name=krava/u,cpu/config=2/u", | 
					
						
							|  |  |  | 		.check = test__checkevent_pmu_name, | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-18 16:56:57 -03:00
										 |  |  | struct terms_test { | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | 	const char *str; | 
					
						
							|  |  |  | 	__u32 type; | 
					
						
							|  |  |  | 	int (*check)(struct list_head *terms); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-18 16:56:57 -03:00
										 |  |  | static struct terms_test test__terms[] = { | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | 	[0] = { | 
					
						
							|  |  |  | 		.str   = "config=10,config1,config2=3,umask=1", | 
					
						
							|  |  |  | 		.check = test__checkterms_simple, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-18 16:56:57 -03:00
										 |  |  | static int test_event(struct evlist_test *e) | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | { | 
					
						
							|  |  |  | 	struct perf_evlist *evlist; | 
					
						
							|  |  |  | 	int ret; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-11 16:43:12 +09:00
										 |  |  | 	evlist = perf_evlist__new(); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 	if (evlist == NULL) | 
					
						
							|  |  |  | 		return -ENOMEM; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-15 14:39:51 +01:00
										 |  |  | 	ret = parse_events(evlist, e->name); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 	if (ret) { | 
					
						
							|  |  |  | 		pr_debug("failed to parse event '%s', err %d\n", | 
					
						
							|  |  |  | 			 e->name, ret); | 
					
						
							|  |  |  | 		return ret; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ret = e->check(evlist); | 
					
						
							|  |  |  | 	perf_evlist__delete(evlist); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-18 16:56:57 -03:00
										 |  |  | static int test_events(struct evlist_test *events, unsigned cnt) | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-21 20:03:15 +02:00
										 |  |  | 	int ret1, ret2 = 0; | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 	unsigned i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (i = 0; i < cnt; i++) { | 
					
						
							| 
									
										
										
										
											2013-01-18 16:56:57 -03:00
										 |  |  | 		struct evlist_test *e = &events[i]; | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		pr_debug("running test %d '%s'\n", i, e->name); | 
					
						
							| 
									
										
										
										
											2012-08-21 20:03:15 +02:00
										 |  |  | 		ret1 = test_event(e); | 
					
						
							|  |  |  | 		if (ret1) | 
					
						
							|  |  |  | 			ret2 = ret1; | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-21 20:03:15 +02:00
										 |  |  | 	return ret2; | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-18 16:56:57 -03:00
										 |  |  | static int test_term(struct terms_test *t) | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-07-02 13:27:24 -06:00
										 |  |  | 	struct list_head terms; | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | 	int ret; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-02 13:27:24 -06:00
										 |  |  | 	INIT_LIST_HEAD(&terms); | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-02 13:27:24 -06:00
										 |  |  | 	ret = parse_events_terms(&terms, t->str); | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | 	if (ret) { | 
					
						
							|  |  |  | 		pr_debug("failed to parse terms '%s', err %d\n", | 
					
						
							|  |  |  | 			 t->str , ret); | 
					
						
							|  |  |  | 		return ret; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-02 13:27:24 -06:00
										 |  |  | 	ret = t->check(&terms); | 
					
						
							|  |  |  | 	parse_events__free_terms(&terms); | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-18 16:56:57 -03:00
										 |  |  | static int test_terms(struct terms_test *terms, unsigned cnt) | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | { | 
					
						
							|  |  |  | 	int ret = 0; | 
					
						
							|  |  |  | 	unsigned i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (i = 0; i < cnt; i++) { | 
					
						
							| 
									
										
										
										
											2013-01-18 16:56:57 -03:00
										 |  |  | 		struct terms_test *t = &terms[i]; | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		pr_debug("running test %d '%s'\n", i, t->str); | 
					
						
							|  |  |  | 		ret = test_term(t); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 		if (ret) | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int test_pmu(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct stat st; | 
					
						
							|  |  |  | 	char path[PATH_MAX]; | 
					
						
							|  |  |  | 	int ret; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/", | 
					
						
							|  |  |  | 		 sysfs_find_mountpoint()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ret = stat(path, &st); | 
					
						
							|  |  |  | 	if (ret) | 
					
						
							| 
									
										
										
										
											2012-07-18 01:20:59 +09:00
										 |  |  | 		pr_debug("omitting PMU cpu tests\n"); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 	return !ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-10 14:53:18 +02:00
										 |  |  | static int test_pmu_events(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct stat st; | 
					
						
							|  |  |  | 	char path[PATH_MAX]; | 
					
						
							|  |  |  | 	struct dirent *ent; | 
					
						
							|  |  |  | 	DIR *dir; | 
					
						
							|  |  |  | 	int ret; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/", | 
					
						
							|  |  |  | 		 sysfs_find_mountpoint()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	ret = stat(path, &st); | 
					
						
							|  |  |  | 	if (ret) { | 
					
						
							| 
									
										
										
										
											2013-04-09 02:06:50 +09:00
										 |  |  | 		pr_debug("omitting PMU cpu events tests\n"); | 
					
						
							| 
									
										
										
										
											2012-10-10 14:53:18 +02:00
										 |  |  | 		return 0; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	dir = opendir(path); | 
					
						
							|  |  |  | 	if (!dir) { | 
					
						
							|  |  |  | 		pr_debug("can't open pmu event dir"); | 
					
						
							|  |  |  | 		return -1; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	while (!ret && (ent = readdir(dir))) { | 
					
						
							|  |  |  | #define MAX_NAME 100
 | 
					
						
							| 
									
										
										
										
											2013-01-18 16:56:57 -03:00
										 |  |  | 		struct evlist_test e; | 
					
						
							| 
									
										
										
										
											2012-10-10 14:53:18 +02:00
										 |  |  | 		char name[MAX_NAME]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (!strcmp(ent->d_name, ".") || | 
					
						
							|  |  |  | 		    !strcmp(ent->d_name, "..")) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		snprintf(name, MAX_NAME, "cpu/event=%s/u", ent->d_name); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		e.name  = name; | 
					
						
							|  |  |  | 		e.check = test__checkevent_pmu_events; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		ret = test_event(&e); | 
					
						
							|  |  |  | #undef MAX_NAME
 | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	closedir(dir); | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-10 01:46:51 +01:00
										 |  |  | int test__parse_events(void) | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-08-21 20:03:15 +02:00
										 |  |  | 	int ret1, ret2 = 0; | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-04 00:00:47 +02:00
										 |  |  | #define TEST_EVENTS(tests)				\
 | 
					
						
							|  |  |  | do {							\ | 
					
						
							| 
									
										
										
										
											2012-08-21 20:03:15 +02:00
										 |  |  | 	ret1 = test_events(tests, ARRAY_SIZE(tests));	\ | 
					
						
							|  |  |  | 	if (!ret2)					\ | 
					
						
							|  |  |  | 		ret2 = ret1;				\ | 
					
						
							| 
									
										
										
										
											2012-07-04 00:00:47 +02:00
										 |  |  | } while (0) | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-04 00:00:47 +02:00
										 |  |  | 	TEST_EVENTS(test__events); | 
					
						
							| 
									
										
										
										
											2012-06-15 14:31:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-04 00:00:47 +02:00
										 |  |  | 	if (test_pmu()) | 
					
						
							|  |  |  | 		TEST_EVENTS(test__events_pmu); | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-10 14:53:18 +02:00
										 |  |  | 	if (test_pmu()) { | 
					
						
							|  |  |  | 		int ret = test_pmu_events(); | 
					
						
							|  |  |  | 		if (ret) | 
					
						
							|  |  |  | 			return ret; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-21 20:03:15 +02:00
										 |  |  | 	ret1 = test_terms(test__terms, ARRAY_SIZE(test__terms)); | 
					
						
							|  |  |  | 	if (!ret2) | 
					
						
							|  |  |  | 		ret2 = ret1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret2; | 
					
						
							| 
									
										
										
										
											2012-05-21 09:12:49 +02:00
										 |  |  | } |