xref: /aosp_15_r20/system/extras/simpleperf/get_test_data.h (revision 288bf5226967eb3dac5cce6c939ccc2a7f2b4fe5)
1*288bf522SAndroid Build Coastguard Worker /*
2*288bf522SAndroid Build Coastguard Worker  * Copyright (C) 2015 The Android Open Source Project
3*288bf522SAndroid Build Coastguard Worker  *
4*288bf522SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*288bf522SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*288bf522SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*288bf522SAndroid Build Coastguard Worker  *
8*288bf522SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*288bf522SAndroid Build Coastguard Worker  *
10*288bf522SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*288bf522SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*288bf522SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*288bf522SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*288bf522SAndroid Build Coastguard Worker  * limitations under the License.
15*288bf522SAndroid Build Coastguard Worker  */
16*288bf522SAndroid Build Coastguard Worker 
17*288bf522SAndroid Build Coastguard Worker #ifndef SIMPLE_PERF_GET_TEST_DATA_H_
18*288bf522SAndroid Build Coastguard Worker #define SIMPLE_PERF_GET_TEST_DATA_H_
19*288bf522SAndroid Build Coastguard Worker 
20*288bf522SAndroid Build Coastguard Worker #include <string>
21*288bf522SAndroid Build Coastguard Worker 
22*288bf522SAndroid Build Coastguard Worker #include "build_id.h"
23*288bf522SAndroid Build Coastguard Worker 
24*288bf522SAndroid Build Coastguard Worker using BuildId = simpleperf::BuildId;
25*288bf522SAndroid Build Coastguard Worker 
26*288bf522SAndroid Build Coastguard Worker std::string GetTestData(const std::string& filename);
27*288bf522SAndroid Build Coastguard Worker const std::string& GetTestDataDir();
28*288bf522SAndroid Build Coastguard Worker 
29*288bf522SAndroid Build Coastguard Worker // The source code of elf and elf_with_mini_debug_info is testdata/elf_file_source.cpp.
30*288bf522SAndroid Build Coastguard Worker static const std::string ELF_FILE = "elf";
31*288bf522SAndroid Build Coastguard Worker static const std::string ELF_FILE_BUILD_ID = "0b12a384a9f4a3f3659b7171ca615dbec3a81f71";
32*288bf522SAndroid Build Coastguard Worker static const std::string ELF_FILE_WITH_MINI_DEBUG_INFO = "elf_with_mini_debug_info";
33*288bf522SAndroid Build Coastguard Worker // perf.data is generated by sampling on three processes running different
34*288bf522SAndroid Build Coastguard Worker // executables: elf, t1, t2 (all generated by elf_file_source.cpp, but with different
35*288bf522SAndroid Build Coastguard Worker // executable name).
36*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA = "perf.data";
37*288bf522SAndroid Build Coastguard Worker 
38*288bf522SAndroid Build Coastguard Worker // perf_with_multiple_pids_and_tids.data is generated by sampling on two processes, each
39*288bf522SAndroid Build Coastguard Worker // process running two threads.
40*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_WITH_MULTIPLE_PIDS_AND_TIDS =
41*288bf522SAndroid Build Coastguard Worker     "perf_with_multiple_pids_and_tids.data";
42*288bf522SAndroid Build Coastguard Worker 
43*288bf522SAndroid Build Coastguard Worker // perf_g_fp.data is generated by sampling on one process running elf using --call-graph fp option.
44*288bf522SAndroid Build Coastguard Worker static const std::string CALLGRAPH_FP_PERF_DATA = "perf_g_fp.data";
45*288bf522SAndroid Build Coastguard Worker // perf_b.data is generated by sampling on one process running elf using -b option.
46*288bf522SAndroid Build Coastguard Worker static const std::string BRANCH_PERF_DATA = "perf_b.data";
47*288bf522SAndroid Build Coastguard Worker // perf_with_mini_debug_info.data is generated by sampling on one process running
48*288bf522SAndroid Build Coastguard Worker // elf_with_mini_debug_info.
49*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_WITH_MINI_DEBUG_INFO = "perf_with_mini_debug_info.data";
50*288bf522SAndroid Build Coastguard Worker 
51*288bf522SAndroid Build Coastguard Worker static BuildId elf_file_build_id("0b12a384a9f4a3f3659b7171ca615dbec3a81f71");
52*288bf522SAndroid Build Coastguard Worker 
53*288bf522SAndroid Build Coastguard Worker // To generate apk supporting execution on shared libraries in apk:
54*288bf522SAndroid Build Coastguard Worker // 1. Add android:extractNativeLibs=false in AndroidManifest.xml.
55*288bf522SAndroid Build Coastguard Worker // 2. Use `zip -0` to store native libraries in apk without compression.
56*288bf522SAndroid Build Coastguard Worker // 3. Use `zipalign -p 4096` to make native libraries in apk start at page boundaries.
57*288bf522SAndroid Build Coastguard Worker //
58*288bf522SAndroid Build Coastguard Worker // The logical in libhello-jni.so is as below:
59*288bf522SAndroid Build Coastguard Worker //  volatile int GlobalVar;
60*288bf522SAndroid Build Coastguard Worker //
61*288bf522SAndroid Build Coastguard Worker //  while (true) {
62*288bf522SAndroid Build Coastguard Worker //    GlobalFunc() -> Func1() -> Func2()
63*288bf522SAndroid Build Coastguard Worker //  }
64*288bf522SAndroid Build Coastguard Worker // And most time is spent in Func2().
65*288bf522SAndroid Build Coastguard Worker static const std::string APK_FILE = "data/app/com.example.hellojni-1/base.apk";
66*288bf522SAndroid Build Coastguard Worker static const std::string NATIVELIB_IN_APK = "lib/arm64-v8a/libhello-jni.so";
67*288bf522SAndroid Build Coastguard Worker // has_embedded_native_libs_apk_perf.data is generated by sampling on one process running
68*288bf522SAndroid Build Coastguard Worker // APK_FILE using -g --no-unwind option.
69*288bf522SAndroid Build Coastguard Worker static const std::string NATIVELIB_IN_APK_PERF_DATA = "has_embedded_native_libs_apk_perf.data";
70*288bf522SAndroid Build Coastguard Worker // The offset and size info are extracted from the generated apk file to run read_apk tests.
71*288bf522SAndroid Build Coastguard Worker constexpr size_t NATIVELIB_OFFSET_IN_APK = 0x639000;
72*288bf522SAndroid Build Coastguard Worker constexpr size_t NATIVELIB_SIZE_IN_APK = 0x1678;
73*288bf522SAndroid Build Coastguard Worker 
74*288bf522SAndroid Build Coastguard Worker static BuildId native_lib_build_id("8ed5755a7fdc07586ca228b8ee21621bce2c7a97");
75*288bf522SAndroid Build Coastguard Worker 
76*288bf522SAndroid Build Coastguard Worker // perf_with_two_event_types.data is generated by sampling using -e cpu-cycles,cpu-clock option.
77*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_WITH_TWO_EVENT_TYPES = "perf_with_two_event_types.data";
78*288bf522SAndroid Build Coastguard Worker 
79*288bf522SAndroid Build Coastguard Worker // perf_with_kernel_symbol.data is generated by `sudo simpleperf record ls -l`.
80*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_WITH_KERNEL_SYMBOL = "perf_with_kernel_symbol.data";
81*288bf522SAndroid Build Coastguard Worker 
82*288bf522SAndroid Build Coastguard Worker // perf_with_symbols.data is generated by `sudo simpleperf record` a process calling func2(int,int).
83*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_WITH_SYMBOLS = "perf_with_symbols.data";
84*288bf522SAndroid Build Coastguard Worker // perf_with_symbols.data is generated by `sudo simpleperf record` a process using
85*288bf522SAndroid Build Coastguard Worker // a binary having non zero min virtual address.
86*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_WITH_SYMBOLS_FOR_NONZERO_MINVADDR_DSO =
87*288bf522SAndroid Build Coastguard Worker     "perf_with_symbols_for_nonzero_minvaddr_dso.data";
88*288bf522SAndroid Build Coastguard Worker 
89*288bf522SAndroid Build Coastguard Worker // perf_kmem_slab_callgraph.data is generated by `simpleperf kmem record --slab --call-graph fp -f
90*288bf522SAndroid Build Coastguard Worker // 100 sleep 0.0001`.
91*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_WITH_KMEM_SLAB_CALLGRAPH_RECORD =
92*288bf522SAndroid Build Coastguard Worker     "perf_with_kmem_slab_callgraph.data";
93*288bf522SAndroid Build Coastguard Worker 
94*288bf522SAndroid Build Coastguard Worker // perf_for_build_id_check.data is generated by recording a process running
95*288bf522SAndroid Build Coastguard Worker // testdata/data/correct_symfs_for_build_id_check/elf_for_build_id_check.
96*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_FOR_BUILD_ID_CHECK = "perf_for_build_id_check.data";
97*288bf522SAndroid Build Coastguard Worker static const std::string CORRECT_SYMFS_FOR_BUILD_ID_CHECK = "data/correct_symfs_for_build_id_check";
98*288bf522SAndroid Build Coastguard Worker static const std::string WRONG_SYMFS_FOR_BUILD_ID_CHECK = "data/wrong_symfs_for_build_id_check";
99*288bf522SAndroid Build Coastguard Worker 
100*288bf522SAndroid Build Coastguard Worker static const std::string SYMFS_FOR_READ_ELF_FILE_WARNING = "data/symfs_for_read_elf_file_warning";
101*288bf522SAndroid Build Coastguard Worker 
102*288bf522SAndroid Build Coastguard Worker static BuildId CHECK_ELF_FILE_BUILD_ID("91b1c10fdd9fe2221dfec525497637f2229bfdbb");
103*288bf522SAndroid Build Coastguard Worker 
104*288bf522SAndroid Build Coastguard Worker // generated_by_linux_perf.data is generated by `perf record -F 1 -a -g -- sleep 0.1`.
105*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_GENERATED_BY_LINUX_PERF = "generated_by_linux_perf.data";
106*288bf522SAndroid Build Coastguard Worker 
107*288bf522SAndroid Build Coastguard Worker // generated by `simpleperf record -g ls`.
108*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_MAX_STACK_AND_PERCENT_LIMIT =
109*288bf522SAndroid Build Coastguard Worker     "perf_test_max_stack_and_percent_limit.data";
110*288bf522SAndroid Build Coastguard Worker 
111*288bf522SAndroid Build Coastguard Worker // generated by `dd if=/dev/zero of=invalid_perf.data bs=1024 count=1`.
112*288bf522SAndroid Build Coastguard Worker static const std::string INVALID_PERF_DATA = "invalid_perf.data";
113*288bf522SAndroid Build Coastguard Worker 
114*288bf522SAndroid Build Coastguard Worker // generated by recording an app.
115*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_WITH_WRONG_IP_IN_CALLCHAIN = "wrong_ip_callchain_perf.data";
116*288bf522SAndroid Build Coastguard Worker 
117*288bf522SAndroid Build Coastguard Worker // generated by `simpleperf record --trace-offcpu --duration 2 -g
118*288bf522SAndroid Build Coastguard Worker // ./simpleperf_runtest_run_and_sleep64`.
119*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_WITH_TRACE_OFFCPU = "perf_with_trace_offcpu.data";
120*288bf522SAndroid Build Coastguard Worker 
121*288bf522SAndroid Build Coastguard Worker // generated by `simpleperf record -g --log debug sleep 1`.
122*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_WITH_CALLCHAIN_RECORD = "perf_with_callchain_record.data";
123*288bf522SAndroid Build Coastguard Worker 
124*288bf522SAndroid Build Coastguard Worker // generated by `simpleperf record -g --no-unwind`.
125*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_NO_UNWIND = "perf_no_unwind.data";
126*288bf522SAndroid Build Coastguard Worker 
127*288bf522SAndroid Build Coastguard Worker // generated by `simpleperf record -a -e sched:sched_stat_runtime`.
128*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_SCHED_STAT_RUNTIME = "perf_sched_stat_runtime.data";
129*288bf522SAndroid Build Coastguard Worker 
130*288bf522SAndroid Build Coastguard Worker // generated by `simpleperf record -e (about 200 tracepoint events) sleep 1`.
131*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_WITH_BIG_TRACE_DATA = "perf_with_big_trace_data.data";
132*288bf522SAndroid Build Coastguard Worker 
133*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_WITH_KERNEL_SYMBOLS_AVAILABLE_TRUE =
134*288bf522SAndroid Build Coastguard Worker     "perf_with_kernel_symbols_available_true.data";
135*288bf522SAndroid Build Coastguard Worker 
136*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_WITH_KERNEL_SYMBOLS_AVAILABLE_FALSE =
137*288bf522SAndroid Build Coastguard Worker     "perf_with_kernel_symbols_available_false.data";
138*288bf522SAndroid Build Coastguard Worker 
139*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_WITH_INTERPRETER_FRAMES = "perf_with_interpreter_frames.data";
140*288bf522SAndroid Build Coastguard Worker 
141*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_WITH_IP_ZERO_IN_CALLCHAIN =
142*288bf522SAndroid Build Coastguard Worker     "perf_with_ip_zero_in_callchain.data";
143*288bf522SAndroid Build Coastguard Worker 
144*288bf522SAndroid Build Coastguard Worker // generated by `simpleperf record -e cs-etm:u ./etm_test_loop`
145*288bf522SAndroid Build Coastguard Worker static const std::string PERF_DATA_ETM_TEST_LOOP = "etm/perf_etm.data";
146*288bf522SAndroid Build Coastguard Worker 
147*288bf522SAndroid Build Coastguard Worker #endif  // SIMPLE_PERF_GET_TEST_DATA_H_
148