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