get_test_data.h revision 05ef2eab98caee49b6b27cac518856b7f5124bee
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
24std::string GetTestData(const std::string& filename);
25const std::string& GetTestDataDir();
26
27// The source code of elf and elf_with_mini_debug_info is testdata/elf_file_source.cpp.
28static const std::string ELF_FILE = "elf";
29static const std::string ELF_FILE_WITH_MINI_DEBUG_INFO = "elf_with_mini_debug_info";
30// perf.data is generated by sampling on three processes running different
31// executables: elf, t1, t2 (all generated by elf_file_source.cpp, but with different
32// executable name).
33static const std::string PERF_DATA = "perf.data";
34// perf_g_fp.data is generated by sampling on one process running elf using --call-graph fp option.
35static const std::string CALLGRAPH_FP_PERF_DATA = "perf_g_fp.data";
36// perf_b.data is generated by sampling on one process running elf using -b option.
37static const std::string BRANCH_PERF_DATA = "perf_b.data";
38// perf_with_mini_debug_info.data is generated by sampling on one process running
39// elf_with_mini_debug_info.
40static const std::string PERF_DATA_WITH_MINI_DEBUG_INFO = "perf_with_mini_debug_info.data";
41
42static BuildId elf_file_build_id("0b12a384a9f4a3f3659b7171ca615dbec3a81f71");
43
44
45// To generate apk supporting execution on shared libraries in apk:
46// 1. Add android:extractNativeLibs=false in AndroidManifest.xml.
47// 2. Use `zip -0` to store native libraries in apk without compression.
48// 3. Use `zipalign -p 4096` to make native libraries in apk start at page boundaries.
49//
50// The logical in libhello-jni.so is as below:
51//  volatile int GlobalVar;
52//
53//  while (true) {
54//    GlobalFunc() -> Func1() -> Func2()
55//  }
56// And most time is spent in Func2().
57static const std::string APK_FILE = "data/app/com.example.hellojni-1/base.apk";
58static const std::string NATIVELIB_IN_APK = "lib/arm64-v8a/libhello-jni.so";
59// has_embedded_native_libs_apk_perf.data is generated by sampling on one process running
60// APK_FILE using -g --no-unwind option.
61static const std::string NATIVELIB_IN_APK_PERF_DATA = "has_embedded_native_libs_apk_perf.data";
62// The offset and size info are extracted from the generated apk file to run read_apk tests.
63constexpr size_t NATIVELIB_OFFSET_IN_APK = 0x639000;
64constexpr size_t NATIVELIB_SIZE_IN_APK = 0x1678;
65
66static BuildId native_lib_build_id("8ed5755a7fdc07586ca228b8ee21621bce2c7a97");
67
68// perf_with_two_event_types.data is generated by sampling using -e cpu-cycles,cpu-clock option.
69static const std::string PERF_DATA_WITH_TWO_EVENT_TYPES = "perf_with_two_event_types.data";
70
71// perf_with_kernel_symbol.data is generated by `sudo simpleperf record ls -l`.
72static const std::string PERF_DATA_WITH_KERNEL_SYMBOL = "perf_with_kernel_symbol.data";
73
74// perf_with_symbols.data is generated by `sudo simpleperf record --dump-symbols` a process calling func2(int,int).
75static const std::string PERF_DATA_WITH_SYMBOLS = "perf_with_symbols.data";
76
77// perf_kmem_slab_callgraph.data is generated by `simpleperf kmem record --slab --call-graph fp -f 100 sleep 0.0001`.
78static const std::string PERF_DATA_WITH_KMEM_SLAB_CALLGRAPH_RECORD = "perf_with_kmem_slab_callgraph.data";
79
80
81// perf_for_build_id_check.data is generated by recording a process running
82// testdata/data/correct_symfs_for_build_id_check/elf_for_build_id_check.
83static const std::string PERF_DATA_FOR_BUILD_ID_CHECK = "perf_for_build_id_check.data";
84static const std::string CORRECT_SYMFS_FOR_BUILD_ID_CHECK = "data/correct_symfs_for_build_id_check";
85static const std::string WRONG_SYMFS_FOR_BUILD_ID_CHECK = "data/wrong_symfs_for_build_id_check";
86
87#endif  // SIMPLE_PERF_GET_TEST_DATA_H_
88