get_test_data.h revision b42129797f17f990ea5a88c6bdc7446000cc361c
1569f64afd3db2b43003978765b833669f99477d2Yabin Cui/*
2569f64afd3db2b43003978765b833669f99477d2Yabin Cui * Copyright (C) 2015 The Android Open Source Project
3569f64afd3db2b43003978765b833669f99477d2Yabin Cui *
4569f64afd3db2b43003978765b833669f99477d2Yabin Cui * Licensed under the Apache License, Version 2.0 (the "License");
5569f64afd3db2b43003978765b833669f99477d2Yabin Cui * you may not use this file except in compliance with the License.
6569f64afd3db2b43003978765b833669f99477d2Yabin Cui * You may obtain a copy of the License at
7569f64afd3db2b43003978765b833669f99477d2Yabin Cui *
8569f64afd3db2b43003978765b833669f99477d2Yabin Cui *      http://www.apache.org/licenses/LICENSE-2.0
9569f64afd3db2b43003978765b833669f99477d2Yabin Cui *
10569f64afd3db2b43003978765b833669f99477d2Yabin Cui * Unless required by applicable law or agreed to in writing, software
11569f64afd3db2b43003978765b833669f99477d2Yabin Cui * distributed under the License is distributed on an "AS IS" BASIS,
12569f64afd3db2b43003978765b833669f99477d2Yabin Cui * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13569f64afd3db2b43003978765b833669f99477d2Yabin Cui * See the License for the specific language governing permissions and
14569f64afd3db2b43003978765b833669f99477d2Yabin Cui * limitations under the License.
15569f64afd3db2b43003978765b833669f99477d2Yabin Cui */
16569f64afd3db2b43003978765b833669f99477d2Yabin Cui
17569f64afd3db2b43003978765b833669f99477d2Yabin Cui#ifndef SIMPLE_PERF_GET_TEST_DATA_H_
18569f64afd3db2b43003978765b833669f99477d2Yabin Cui#define SIMPLE_PERF_GET_TEST_DATA_H_
19569f64afd3db2b43003978765b833669f99477d2Yabin Cui
20569f64afd3db2b43003978765b833669f99477d2Yabin Cui#include <string>
21569f64afd3db2b43003978765b833669f99477d2Yabin Cui
22b1a885b014540a2f7798b5a35ea0f0ec150d93eeYabin Cui#include "build_id.h"
23b1a885b014540a2f7798b5a35ea0f0ec150d93eeYabin Cui
24569f64afd3db2b43003978765b833669f99477d2Yabin Cuistd::string GetTestData(const std::string& filename);
25b1a885b014540a2f7798b5a35ea0f0ec150d93eeYabin Cuiconst std::string& GetTestDataDir();
26b1a885b014540a2f7798b5a35ea0f0ec150d93eeYabin Cui
278f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// The source code of elf and elf_with_mini_debug_info is testdata/elf_file_source.cpp.
288f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cuistatic const std::string ELF_FILE = "elf";
298f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cuistatic const std::string ELF_FILE_WITH_MINI_DEBUG_INFO = "elf_with_mini_debug_info";
308f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// perf.data is generated by sampling on three processes running different
318f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// executables: elf, t1, t2 (all generated by elf_file_source.cpp, but with different
328f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// executable name).
336e51bef9aa101307523946df301ca90215d0ee82Yabin Cuistatic const std::string PERF_DATA = "perf.data";
348f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// perf_g_fp.data is generated by sampling on one process running elf using --call-graph fp option.
356e51bef9aa101307523946df301ca90215d0ee82Yabin Cuistatic const std::string CALLGRAPH_FP_PERF_DATA = "perf_g_fp.data";
368f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// perf_b.data is generated by sampling on one process running elf using -b option.
376e51bef9aa101307523946df301ca90215d0ee82Yabin Cuistatic const std::string BRANCH_PERF_DATA = "perf_b.data";
388f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// perf_with_mini_debug_info.data is generated by sampling on one process running
398f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// elf_with_mini_debug_info.
4005400539d15c50a52a388daba2e831b86824cc8eYabin Cuistatic const std::string PERF_DATA_WITH_MINI_DEBUG_INFO = "perf_with_mini_debug_info.data";
416e51bef9aa101307523946df301ca90215d0ee82Yabin Cui
428f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cuistatic BuildId elf_file_build_id("0b12a384a9f4a3f3659b7171ca615dbec3a81f71");
436e51bef9aa101307523946df301ca90215d0ee82Yabin Cui
448f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui
458f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// To generate apk supporting execution on shared libraries in apk:
468f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// 1. Add android:extractNativeLibs=false in AndroidManifest.xml.
478f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// 2. Use `zip -0` to store native libraries in apk without compression.
488f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// 3. Use `zipalign -p 4096` to make native libraries in apk start at page boundaries.
498f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui//
508f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// The logical in libhello-jni.so is as below:
518f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui//  volatile int GlobalVar;
528f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui//
538f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui//  while (true) {
548f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui//    GlobalFunc() -> Func1() -> Func2()
558f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui//  }
568f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// And most time is spent in Func2().
57b1a885b014540a2f7798b5a35ea0f0ec150d93eeYabin Cuistatic const std::string APK_FILE = "data/app/com.example.hellojni-1/base.apk";
58b1a885b014540a2f7798b5a35ea0f0ec150d93eeYabin Cuistatic const std::string NATIVELIB_IN_APK = "lib/arm64-v8a/libhello-jni.so";
598f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// has_embedded_native_libs_apk_perf.data is generated by sampling on one process running
608f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// APK_FILE using -g --no-unwind option.
61b1a885b014540a2f7798b5a35ea0f0ec150d93eeYabin Cuistatic const std::string NATIVELIB_IN_APK_PERF_DATA = "has_embedded_native_libs_apk_perf.data";
628f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cui// The offset and size info are extracted from the generated apk file to run read_apk tests.
638f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cuiconstexpr size_t NATIVELIB_OFFSET_IN_APK = 0x639000;
648f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cuiconstexpr size_t NATIVELIB_SIZE_IN_APK = 0x1678;
65b1a885b014540a2f7798b5a35ea0f0ec150d93eeYabin Cui
668f680f60dc800bec880c5c35bfbc1ac36165e1f3Yabin Cuistatic BuildId native_lib_build_id("8ed5755a7fdc07586ca228b8ee21621bce2c7a97");
67569f64afd3db2b43003978765b833669f99477d2Yabin Cui
682d6efe4b167da4e6b77f168b1820239ee65599e2Yabin Cui// perf_with_two_event_types.data is generated by sampling using -e cpu-cycles,cpu-clock option.
692d6efe4b167da4e6b77f168b1820239ee65599e2Yabin Cuistatic const std::string PERF_DATA_WITH_TWO_EVENT_TYPES = "perf_with_two_event_types.data";
702d6efe4b167da4e6b77f168b1820239ee65599e2Yabin Cui
71b42129797f17f990ea5a88c6bdc7446000cc361cYabin Cui// perf_with_kernel_symbol.data is generated by `sudo simpleperf record ls -l`.
72b42129797f17f990ea5a88c6bdc7446000cc361cYabin Cuistatic const std::string PERF_DATA_WITH_KERNEL_SYMBOL = "perf_with_kernel_symbol.data";
73b42129797f17f990ea5a88c6bdc7446000cc361cYabin Cui
74569f64afd3db2b43003978765b833669f99477d2Yabin Cui#endif  // SIMPLE_PERF_GET_TEST_DATA_H_
75