18c2ecf20Sopenharmony_ciThe struct perf_event_attr test (attr tests) support
28c2ecf20Sopenharmony_ci====================================================
38c2ecf20Sopenharmony_ciThis testing support is embedded into perf directly and is governed
48c2ecf20Sopenharmony_ciby the PERF_TEST_ATTR environment variable and hook inside the
58c2ecf20Sopenharmony_cisys_perf_event_open function.
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ciThe general idea is to store 'struct perf_event_attr' details for
88c2ecf20Sopenharmony_cieach event created within single perf command. Each event details
98c2ecf20Sopenharmony_ciare stored into separate text file. Once perf command is finished
108c2ecf20Sopenharmony_cithese files are checked for values we expect for command.
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ciThe attr tests consist of following parts:
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_citests/attr.c
158c2ecf20Sopenharmony_ci------------
168c2ecf20Sopenharmony_ciThis is the sys_perf_event_open hook implementation. The hook
178c2ecf20Sopenharmony_ciis triggered when the PERF_TEST_ATTR environment variable is
188c2ecf20Sopenharmony_cidefined. It must contain name of existing directory with access
198c2ecf20Sopenharmony_ciand write permissions.
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ciFor each sys_perf_event_open call event details are stored in
228c2ecf20Sopenharmony_ciseparate file. Besides 'struct perf_event_attr' values we also
238c2ecf20Sopenharmony_cistore 'fd' and 'group_fd' values to allow checking for groups.
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_citests/attr.py
268c2ecf20Sopenharmony_ci-------------
278c2ecf20Sopenharmony_ciThis is the python script that does all the hard work. It reads
288c2ecf20Sopenharmony_cithe test definition, executes it and checks results.
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_citests/attr/
318c2ecf20Sopenharmony_ci-----------
328c2ecf20Sopenharmony_ciDirectory containing all attr test definitions.
338c2ecf20Sopenharmony_ciFollowing tests are defined (with perf commands):
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci  perf record kill                              (test-record-basic)
368c2ecf20Sopenharmony_ci  perf record -b kill                           (test-record-branch-any)
378c2ecf20Sopenharmony_ci  perf record -j any kill                       (test-record-branch-filter-any)
388c2ecf20Sopenharmony_ci  perf record -j any_call kill                  (test-record-branch-filter-any_call)
398c2ecf20Sopenharmony_ci  perf record -j any_ret kill                   (test-record-branch-filter-any_ret)
408c2ecf20Sopenharmony_ci  perf record -j hv kill                        (test-record-branch-filter-hv)
418c2ecf20Sopenharmony_ci  perf record -j ind_call kill                  (test-record-branch-filter-ind_call)
428c2ecf20Sopenharmony_ci  perf record -j k kill                         (test-record-branch-filter-k)
438c2ecf20Sopenharmony_ci  perf record -j u kill                         (test-record-branch-filter-u)
448c2ecf20Sopenharmony_ci  perf record -c 123 kill                       (test-record-count)
458c2ecf20Sopenharmony_ci  perf record -d kill                           (test-record-data)
468c2ecf20Sopenharmony_ci  perf record -F 100 kill                       (test-record-freq)
478c2ecf20Sopenharmony_ci  perf record -g kill                           (test-record-graph-default)
488c2ecf20Sopenharmony_ci  perf record --call-graph dwarf kill		(test-record-graph-dwarf)
498c2ecf20Sopenharmony_ci  perf record --call-graph fp kill              (test-record-graph-fp)
508c2ecf20Sopenharmony_ci  perf record --group -e cycles,instructions kill (test-record-group)
518c2ecf20Sopenharmony_ci  perf record -e '{cycles,instructions}' kill   (test-record-group1)
528c2ecf20Sopenharmony_ci  perf record -e '{cycles/period=1/,instructions/period=2/}:S' kill (test-record-group2)
538c2ecf20Sopenharmony_ci  perf record -D kill                           (test-record-no-delay)
548c2ecf20Sopenharmony_ci  perf record -i kill                           (test-record-no-inherit)
558c2ecf20Sopenharmony_ci  perf record -n kill                           (test-record-no-samples)
568c2ecf20Sopenharmony_ci  perf record -c 100 -P kill                    (test-record-period)
578c2ecf20Sopenharmony_ci  perf record -c 1 --pfm-events=cycles:period=2 (test-record-pfm-period)
588c2ecf20Sopenharmony_ci  perf record -R kill                           (test-record-raw)
598c2ecf20Sopenharmony_ci  perf stat -e cycles kill                      (test-stat-basic)
608c2ecf20Sopenharmony_ci  perf stat kill                                (test-stat-default)
618c2ecf20Sopenharmony_ci  perf stat -d kill                             (test-stat-detailed-1)
628c2ecf20Sopenharmony_ci  perf stat -dd kill                            (test-stat-detailed-2)
638c2ecf20Sopenharmony_ci  perf stat -ddd kill                           (test-stat-detailed-3)
648c2ecf20Sopenharmony_ci  perf stat --group -e cycles,instructions kill (test-stat-group)
658c2ecf20Sopenharmony_ci  perf stat -e '{cycles,instructions}' kill     (test-stat-group1)
668c2ecf20Sopenharmony_ci  perf stat -i -e cycles kill                   (test-stat-no-inherit)
67