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