1*4882a593SmuzhiyunThe struct perf_event_attr test (attr tests) support 2*4882a593Smuzhiyun==================================================== 3*4882a593SmuzhiyunThis testing support is embedded into perf directly and is governed 4*4882a593Smuzhiyunby the PERF_TEST_ATTR environment variable and hook inside the 5*4882a593Smuzhiyunsys_perf_event_open function. 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunThe general idea is to store 'struct perf_event_attr' details for 8*4882a593Smuzhiyuneach event created within single perf command. Each event details 9*4882a593Smuzhiyunare stored into separate text file. Once perf command is finished 10*4882a593Smuzhiyunthese files are checked for values we expect for command. 11*4882a593Smuzhiyun 12*4882a593SmuzhiyunThe attr tests consist of following parts: 13*4882a593Smuzhiyun 14*4882a593Smuzhiyuntests/attr.c 15*4882a593Smuzhiyun------------ 16*4882a593SmuzhiyunThis is the sys_perf_event_open hook implementation. The hook 17*4882a593Smuzhiyunis triggered when the PERF_TEST_ATTR environment variable is 18*4882a593Smuzhiyundefined. It must contain name of existing directory with access 19*4882a593Smuzhiyunand write permissions. 20*4882a593Smuzhiyun 21*4882a593SmuzhiyunFor each sys_perf_event_open call event details are stored in 22*4882a593Smuzhiyunseparate file. Besides 'struct perf_event_attr' values we also 23*4882a593Smuzhiyunstore 'fd' and 'group_fd' values to allow checking for groups. 24*4882a593Smuzhiyun 25*4882a593Smuzhiyuntests/attr.py 26*4882a593Smuzhiyun------------- 27*4882a593SmuzhiyunThis is the python script that does all the hard work. It reads 28*4882a593Smuzhiyunthe test definition, executes it and checks results. 29*4882a593Smuzhiyun 30*4882a593Smuzhiyuntests/attr/ 31*4882a593Smuzhiyun----------- 32*4882a593SmuzhiyunDirectory containing all attr test definitions. 33*4882a593SmuzhiyunFollowing tests are defined (with perf commands): 34*4882a593Smuzhiyun 35*4882a593Smuzhiyun perf record kill (test-record-basic) 36*4882a593Smuzhiyun perf record -b kill (test-record-branch-any) 37*4882a593Smuzhiyun perf record -j any kill (test-record-branch-filter-any) 38*4882a593Smuzhiyun perf record -j any_call kill (test-record-branch-filter-any_call) 39*4882a593Smuzhiyun perf record -j any_ret kill (test-record-branch-filter-any_ret) 40*4882a593Smuzhiyun perf record -j hv kill (test-record-branch-filter-hv) 41*4882a593Smuzhiyun perf record -j ind_call kill (test-record-branch-filter-ind_call) 42*4882a593Smuzhiyun perf record -j k kill (test-record-branch-filter-k) 43*4882a593Smuzhiyun perf record -j u kill (test-record-branch-filter-u) 44*4882a593Smuzhiyun perf record -c 123 kill (test-record-count) 45*4882a593Smuzhiyun perf record -d kill (test-record-data) 46*4882a593Smuzhiyun perf record -F 100 kill (test-record-freq) 47*4882a593Smuzhiyun perf record -g kill (test-record-graph-default) 48*4882a593Smuzhiyun perf record --call-graph dwarf kill (test-record-graph-dwarf) 49*4882a593Smuzhiyun perf record --call-graph fp kill (test-record-graph-fp) 50*4882a593Smuzhiyun perf record --group -e cycles,instructions kill (test-record-group) 51*4882a593Smuzhiyun perf record -e '{cycles,instructions}' kill (test-record-group1) 52*4882a593Smuzhiyun perf record -e '{cycles/period=1/,instructions/period=2/}:S' kill (test-record-group2) 53*4882a593Smuzhiyun perf record -D kill (test-record-no-delay) 54*4882a593Smuzhiyun perf record -i kill (test-record-no-inherit) 55*4882a593Smuzhiyun perf record -n kill (test-record-no-samples) 56*4882a593Smuzhiyun perf record -c 100 -P kill (test-record-period) 57*4882a593Smuzhiyun perf record -c 1 --pfm-events=cycles:period=2 (test-record-pfm-period) 58*4882a593Smuzhiyun perf record -R kill (test-record-raw) 59*4882a593Smuzhiyun perf stat -e cycles kill (test-stat-basic) 60*4882a593Smuzhiyun perf stat kill (test-stat-default) 61*4882a593Smuzhiyun perf stat -d kill (test-stat-detailed-1) 62*4882a593Smuzhiyun perf stat -dd kill (test-stat-detailed-2) 63*4882a593Smuzhiyun perf stat -ddd kill (test-stat-detailed-3) 64*4882a593Smuzhiyun perf stat --group -e cycles,instructions kill (test-stat-group) 65*4882a593Smuzhiyun perf stat -e '{cycles,instructions}' kill (test-stat-group1) 66*4882a593Smuzhiyun perf stat -i -e cycles kill (test-stat-no-inherit) 67