1b84800a3SJiri OlsaThe struct perf_event_attr test (attr tests) support 2b84800a3SJiri Olsa==================================================== 3b84800a3SJiri OlsaThis testing support is embedded into perf directly and is governed 4b84800a3SJiri Olsaby the PERF_TEST_ATTR environment variable and hook inside the 5b84800a3SJiri Olsasys_perf_event_open function. 6b84800a3SJiri Olsa 7b84800a3SJiri OlsaThe general idea is to store 'struct perf_event_attr' details for 8b84800a3SJiri Olsaeach event created within single perf command. Each event details 9b84800a3SJiri Olsaare stored into separate text file. Once perf command is finished 10b84800a3SJiri Olsathese files are checked for values we expect for command. 11b84800a3SJiri Olsa 12b84800a3SJiri OlsaThe attr tests consist of following parts: 13b84800a3SJiri Olsa 14b84800a3SJiri Olsatests/attr.c 15b84800a3SJiri Olsa------------ 16b84800a3SJiri OlsaThis is the sys_perf_event_open hook implementation. The hook 17b84800a3SJiri Olsais triggered when the PERF_TEST_ATTR environment variable is 18b84800a3SJiri Olsadefined. It must contain name of existing directory with access 19b84800a3SJiri Olsaand write permissions. 20b84800a3SJiri Olsa 21b84800a3SJiri OlsaFor each sys_perf_event_open call event details are stored in 22b84800a3SJiri Olsaseparate file. Besides 'struct perf_event_attr' values we also 23b84800a3SJiri Olsastore 'fd' and 'group_fd' values to allow checking for groups. 24b84800a3SJiri Olsa 25b84800a3SJiri Olsatests/attr.py 26b84800a3SJiri Olsa------------- 27b84800a3SJiri OlsaThis is the python script that does all the hard work. It reads 28b84800a3SJiri Olsathe test definition, executes it and checks results. 29b84800a3SJiri Olsa 30b84800a3SJiri Olsatests/attr/ 31b84800a3SJiri Olsa----------- 32b84800a3SJiri OlsaDirectory containing all attr test definitions. 33b84800a3SJiri OlsaFollowing tests are defined (with perf commands): 34b84800a3SJiri Olsa 35b84800a3SJiri Olsa perf record kill (test-record-basic) 36b84800a3SJiri Olsa perf record -b kill (test-record-branch-any) 37b84800a3SJiri Olsa perf record -j any kill (test-record-branch-filter-any) 38b84800a3SJiri Olsa perf record -j any_call kill (test-record-branch-filter-any_call) 39b84800a3SJiri Olsa perf record -j any_ret kill (test-record-branch-filter-any_ret) 40b84800a3SJiri Olsa perf record -j hv kill (test-record-branch-filter-hv) 41b84800a3SJiri Olsa perf record -j ind_call kill (test-record-branch-filter-ind_call) 42b84800a3SJiri Olsa perf record -j k kill (test-record-branch-filter-k) 43b84800a3SJiri Olsa perf record -j u kill (test-record-branch-filter-u) 44b84800a3SJiri Olsa perf record -c 123 kill (test-record-count) 45b84800a3SJiri Olsa perf record -d kill (test-record-data) 46b84800a3SJiri Olsa perf record -F 100 kill (test-record-freq) 4746d525eaSArnaldo Carvalho de Melo perf record -g kill (test-record-graph-default) 48047e6032SGerman Gomez perf record -g kill (test-record-graph-default-aarch64) 4946d525eaSArnaldo Carvalho de Melo perf record --call-graph dwarf kill (test-record-graph-dwarf) 5046d525eaSArnaldo Carvalho de Melo perf record --call-graph fp kill (test-record-graph-fp) 51047e6032SGerman Gomez perf record --call-graph fp kill (test-record-graph-fp-aarch64) 52b84800a3SJiri Olsa perf record -e '{cycles,instructions}' kill (test-record-group1) 53880a7843SIan Rogers perf record -e '{cycles/period=1/,instructions/period=2/}:S' kill (test-record-group2) 54b84800a3SJiri Olsa perf record -D kill (test-record-no-delay) 55b84800a3SJiri Olsa perf record -i kill (test-record-no-inherit) 56b84800a3SJiri Olsa perf record -n kill (test-record-no-samples) 57b84800a3SJiri Olsa perf record -c 100 -P kill (test-record-period) 581b98c6e3SIan Rogers perf record -c 1 --pfm-events=cycles:period=2 (test-record-pfm-period) 59b84800a3SJiri Olsa perf record -R kill (test-record-raw) 60d57159efSGerman Gomez perf record -c 2 -e arm_spe_0// -- kill (test-record-spe-period) 61d57159efSGerman Gomez perf record -e arm_spe_0/period=3/ -- kill (test-record-spe-period-term) 62*3b9a8c8bSTimothy Hayes perf record -e arm_spe_0/pa_enable=1/ -- kill (test-record-spe-physical-address) 63b84800a3SJiri Olsa perf stat -e cycles kill (test-stat-basic) 64b84800a3SJiri Olsa perf stat kill (test-stat-default) 65b84800a3SJiri Olsa perf stat -d kill (test-stat-detailed-1) 66b84800a3SJiri Olsa perf stat -dd kill (test-stat-detailed-2) 67b84800a3SJiri Olsa perf stat -ddd kill (test-stat-detailed-3) 68b84800a3SJiri Olsa perf stat -e '{cycles,instructions}' kill (test-stat-group1) 69b84800a3SJiri Olsa perf stat -i -e cycles kill (test-stat-no-inherit) 70