1*8296aa0fSIan RogersThe struct perf_event_attr test (attr tests) support 2*8296aa0fSIan Rogers==================================================== 3*8296aa0fSIan RogersThis testing support is embedded into perf directly and is governed 4*8296aa0fSIan Rogersby the PERF_TEST_ATTR environment variable and hook inside the 5*8296aa0fSIan Rogerssys_perf_event_open function. 6*8296aa0fSIan Rogers 7*8296aa0fSIan RogersThe general idea is to store 'struct perf_event_attr' details for 8*8296aa0fSIan Rogerseach event created within single perf command. Each event details 9*8296aa0fSIan Rogersare stored into separate text file. Once perf command is finished 10*8296aa0fSIan Rogersthese files are checked for values we expect for command. 11*8296aa0fSIan Rogers 12*8296aa0fSIan RogersThe attr tests consist of following parts: 13*8296aa0fSIan Rogers 14*8296aa0fSIan Rogerstests/attr.c 15*8296aa0fSIan Rogers------------ 16*8296aa0fSIan RogersThis is the sys_perf_event_open hook implementation. The hook 17*8296aa0fSIan Rogersis triggered when the PERF_TEST_ATTR environment variable is 18*8296aa0fSIan Rogersdefined. It must contain name of existing directory with access 19*8296aa0fSIan Rogersand write permissions. 20*8296aa0fSIan Rogers 21*8296aa0fSIan RogersFor each sys_perf_event_open call event details are stored in 22*8296aa0fSIan Rogersseparate file. Besides 'struct perf_event_attr' values we also 23*8296aa0fSIan Rogersstore 'fd' and 'group_fd' values to allow checking for groups. 24*8296aa0fSIan Rogers 25*8296aa0fSIan Rogerstests/attr.py 26*8296aa0fSIan Rogers------------- 27*8296aa0fSIan RogersThis is the python script that does all the hard work. It reads 28*8296aa0fSIan Rogersthe test definition, executes it and checks results. 29*8296aa0fSIan Rogers 30*8296aa0fSIan Rogerstests/attr/ 31*8296aa0fSIan Rogers----------- 32*8296aa0fSIan RogersDirectory containing all attr test definitions. 33*8296aa0fSIan RogersFollowing tests are defined (with perf commands): 34*8296aa0fSIan Rogers 35*8296aa0fSIan Rogers perf record kill (test-record-basic) 36*8296aa0fSIan Rogers perf record -b kill (test-record-branch-any) 37*8296aa0fSIan Rogers perf record -j any kill (test-record-branch-filter-any) 38*8296aa0fSIan Rogers perf record -j any_call kill (test-record-branch-filter-any_call) 39*8296aa0fSIan Rogers perf record -j any_ret kill (test-record-branch-filter-any_ret) 40*8296aa0fSIan Rogers perf record -j hv kill (test-record-branch-filter-hv) 41*8296aa0fSIan Rogers perf record -j ind_call kill (test-record-branch-filter-ind_call) 42*8296aa0fSIan Rogers perf record -j k kill (test-record-branch-filter-k) 43*8296aa0fSIan Rogers perf record -j u kill (test-record-branch-filter-u) 44*8296aa0fSIan Rogers perf record -c 123 kill (test-record-count) 45*8296aa0fSIan Rogers perf record -d kill (test-record-data) 46*8296aa0fSIan Rogers perf record -F 100 kill (test-record-freq) 47*8296aa0fSIan Rogers perf record -g kill (test-record-graph-default) 48*8296aa0fSIan Rogers perf record -g kill (test-record-graph-default-aarch64) 49*8296aa0fSIan Rogers perf record --call-graph dwarf kill (test-record-graph-dwarf) 50*8296aa0fSIan Rogers perf record --call-graph fp kill (test-record-graph-fp) 51*8296aa0fSIan Rogers perf record --call-graph fp kill (test-record-graph-fp-aarch64) 52*8296aa0fSIan Rogers perf record -e '{cycles,instructions}' kill (test-record-group1) 53*8296aa0fSIan Rogers perf record -e '{cycles/period=1/,instructions/period=2/}:S' kill (test-record-group2) 54*8296aa0fSIan Rogers perf record -e '{cycles,cache-misses}:S' kill (test-record-group-sampling1) 55*8296aa0fSIan Rogers perf record -c 10000 -e '{cycles,cache-misses}:S' kill (test-record-group-sampling2) 56*8296aa0fSIan Rogers perf record -D kill (test-record-no-delay) 57*8296aa0fSIan Rogers perf record -i kill (test-record-no-inherit) 58*8296aa0fSIan Rogers perf record -n kill (test-record-no-samples) 59*8296aa0fSIan Rogers perf record -c 100 -P kill (test-record-period) 60*8296aa0fSIan Rogers perf record -c 1 --pfm-events=cycles:period=2 (test-record-pfm-period) 61*8296aa0fSIan Rogers perf record -R kill (test-record-raw) 62*8296aa0fSIan Rogers perf record -c 2 -e arm_spe_0// -- kill (test-record-spe-period) 63*8296aa0fSIan Rogers perf record -e arm_spe_0/period=3/ -- kill (test-record-spe-period-term) 64*8296aa0fSIan Rogers perf record -e arm_spe_0/pa_enable=1/ -- kill (test-record-spe-physical-address) 65*8296aa0fSIan Rogers perf stat -e cycles kill (test-stat-basic) 66*8296aa0fSIan Rogers perf stat kill (test-stat-default) 67*8296aa0fSIan Rogers perf stat -d kill (test-stat-detailed-1) 68*8296aa0fSIan Rogers perf stat -dd kill (test-stat-detailed-2) 69*8296aa0fSIan Rogers perf stat -ddd kill (test-stat-detailed-3) 70*8296aa0fSIan Rogers perf stat -e '{cycles,instructions}' kill (test-stat-group1) 71*8296aa0fSIan Rogers perf stat -i -e cycles kill (test-stat-no-inherit) 72