summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2016-02-05 17:32:08 -0800
committerYabin Cui <yabinc@google.com>2016-02-08 19:10:28 -0800
commit569f64afd3db2b43003978765b833669f99477d2 (patch)
treed4e3a497836b0490d0399a45a5cecb36896612f8
parent4a5dafcc3093d55fc9d135b9a18c73bd96bcf3b1 (diff)
downloadextras-569f64afd3db2b43003978765b833669f99477d2.tar.gz
simpleperf: port read_apk and read_apk/read_elf tests to nonlinux.
Also make following small changes: 1. Manage testdata files like libziparchive. 2. Replace StringToPid() with android::base::ParseInt(). 3. Add tests in read_elf_test. Bug: 26962895 Change-Id: I6603e9f3cea3a013e2618ea003790d102739f843
-rw-r--r--simpleperf/Android.mk27
-rw-r--r--simpleperf/cmd_report.cpp5
-rw-r--r--simpleperf/cpu_hotplug_test.cpp6
-rw-r--r--simpleperf/environment.cpp15
-rw-r--r--simpleperf/get_test_data.h24
-rw-r--r--simpleperf/gtest_main.cpp22
-rw-r--r--simpleperf/read_apk.cpp6
-rw-r--r--simpleperf/read_apk_test.cpp11
-rw-r--r--simpleperf/read_elf.cpp10
-rw-r--r--simpleperf/read_elf_test.cpp58
-rw-r--r--simpleperf/test_inputs/Android.mk20
-rw-r--r--simpleperf/testdata/elf_filebin0 -> 8591 bytes
-rw-r--r--simpleperf/testdata/fibonacci.jar (renamed from simpleperf/test_inputs/fibonacci.jar)bin1205 -> 1205 bytes
-rw-r--r--simpleperf/testdata/has_embedded_native_libs.apk (renamed from simpleperf/test_inputs/has_embedded_native_libs.apk)bin723220 -> 723220 bytes
-rw-r--r--simpleperf/utils.cpp6
-rw-r--r--simpleperf/utils.h1
16 files changed, 138 insertions, 73 deletions
diff --git a/simpleperf/Android.mk b/simpleperf/Android.mk
index 17676b35..5c5642bd 100644
--- a/simpleperf/Android.mk
+++ b/simpleperf/Android.mk
@@ -41,19 +41,22 @@ simpleperf_shared_libraries_target := \
simpleperf_static_libraries_target := \
libziparchive \
-simpleperf_shared_libraries_host := libbase
-
simpleperf_shared_libraries_host_linux := \
libbacktrace \
libbacktrace_offline \
- libziparchive-host \
simpleperf_shared_libraries_host_darwin := libLLVM
simpleperf_shared_libraries_host_windows := libLLVM
-simpleperf_ldlibs_host_linux := -lrt
+simpleperf_static_libraries_host := \
+ libziparchive-host \
+ libbase \
+ liblog \
+ libz \
+ libutils \
+simpleperf_ldlibs_host_linux := -lrt
# libsimpleperf
# =========================================================
@@ -67,6 +70,7 @@ libsimpleperf_src_files := \
event_attr.cpp \
event_type.cpp \
perf_regs.cpp \
+ read_apk.cpp \
read_elf.cpp \
record.cpp \
record_file_reader.cpp \
@@ -82,7 +86,6 @@ libsimpleperf_src_files_linux := \
environment.cpp \
event_fd.cpp \
event_selection_set.cpp \
- read_apk.cpp \
record_file_writer.cpp \
workload.cpp \
@@ -103,6 +106,7 @@ LOCAL_SRC_FILES := \
$(libsimpleperf_src_files) \
$(libsimpleperf_src_files_linux) \
+LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_target)
LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target)
LOCAL_MULTILIB := first
include $(LLVM_DEVICE_BUILD_MK)
@@ -121,6 +125,7 @@ LOCAL_SRC_FILES := $(libsimpleperf_src_files)
LOCAL_SRC_FILES_darwin := $(libsimpleperf_src_files_darwin)
LOCAL_SRC_FILES_linux := $(libsimpleperf_src_files_linux)
LOCAL_SRC_FILES_windows := $(libsimpleperf_src_files_windows)
+LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_host)
LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_host)
LOCAL_SHARED_LIBRARIES_darwin := $(simpleperf_shared_libraries_host_darwin)
LOCAL_SHARED_LIBRARIES_linux := $(simpleperf_shared_libraries_host_linux)
@@ -143,8 +148,8 @@ LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
LOCAL_SRC_FILES := main.cpp
LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
-LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target)
LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_target)
+LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target)
LOCAL_MULTILIB := first
include $(BUILD_EXECUTABLE)
@@ -158,6 +163,7 @@ LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows)
LOCAL_SRC_FILES := main.cpp
LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
+LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_host)
LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_host)
LOCAL_SHARED_LIBRARIES_darwin := $(simpleperf_shared_libraries_host_darwin)
LOCAL_SHARED_LIBRARIES_linux := $(simpleperf_shared_libraries_host_linux)
@@ -172,6 +178,8 @@ include $(BUILD_HOST_EXECUTABLE)
simpleperf_unit_test_src_files := \
command_test.cpp \
gtest_main.cpp \
+ read_apk_test.cpp \
+ read_elf_test.cpp \
record_test.cpp \
sample_tree_test.cpp \
@@ -182,8 +190,6 @@ simpleperf_unit_test_src_files_linux := \
cmd_report_test.cpp \
cmd_stat_test.cpp \
environment_test.cpp \
- read_elf_test.cpp \
- read_apk_test.cpp \
record_file_test.cpp \
workload_test.cpp \
@@ -197,8 +203,8 @@ LOCAL_SRC_FILES := \
$(simpleperf_unit_test_src_files_linux) \
LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
-LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target)
LOCAL_STATIC_LIBRARIES += $(simpleperf_static_libraries_target)
+LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_target)
LOCAL_MULTILIB := first
include $(BUILD_NATIVE_TEST)
@@ -213,6 +219,7 @@ LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows)
LOCAL_SRC_FILES := $(simpleperf_unit_test_src_files)
LOCAL_SRC_FILES_linux := $(simpleperf_unit_test_src_files_linux)
LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
+LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_host)
LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_host)
LOCAL_SHARED_LIBRARIES_darwin := $(simpleperf_shared_libraries_host_darwin)
LOCAL_SHARED_LIBRARIES_linux := $(simpleperf_shared_libraries_host_linux)
@@ -225,7 +232,6 @@ include $(BUILD_HOST_NATIVE_TEST)
# simpleperf_cpu_hotplug_test
# =========================================================
simpleperf_cpu_hotplug_test_src_files := \
- gtest_main.cpp \
cpu_hotplug_test.cpp \
# simpleperf_cpu_hotplug_test target
@@ -249,6 +255,7 @@ LOCAL_CPPFLAGS := $(simpleperf_cppflags_host)
LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
LOCAL_SRC_FILES := $(simpleperf_cpu_hotplug_test_src_files)
LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
+LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_host)
LOCAL_SHARED_LIBRARIES := $(simpleperf_shared_libraries_host)
LOCAL_SHARED_LIBRARIES_linux := $(simpleperf_shared_libraries_host_linux)
LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux)
diff --git a/simpleperf/cmd_report.cpp b/simpleperf/cmd_report.cpp
index 54ec0ee3..b667de69 100644
--- a/simpleperf/cmd_report.cpp
+++ b/simpleperf/cmd_report.cpp
@@ -25,6 +25,7 @@
#include <vector>
#include <android-base/logging.h>
+#include <android-base/parseint.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
@@ -392,9 +393,9 @@ bool ReportCommand::ParseOptions(const std::vector<std::string>& args) {
}
std::vector<std::string> strs = android::base::Split(args[i], ",");
std::vector<int> ids;
- for (auto& s : strs) {
+ for (const auto& s : strs) {
int id;
- if (!StringToPid(s, &id)) {
+ if (!android::base::ParseInt(s.c_str(), &id, 0)) {
LOG(ERROR) << "invalid id in " << args[i] << " option: " << s;
return false;
}
diff --git a/simpleperf/cpu_hotplug_test.cpp b/simpleperf/cpu_hotplug_test.cpp
index 68d4ea73..61cbc80e 100644
--- a/simpleperf/cpu_hotplug_test.cpp
+++ b/simpleperf/cpu_hotplug_test.cpp
@@ -252,3 +252,9 @@ TEST(cpu_offline, offline_while_recording_on_another_cpu) {
ASSERT_TRUE(event_fd != nullptr);
}
}
+
+int main(int argc, char** argv) {
+ InitLogging(argv, android::base::StderrLogger);
+ testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
+}
diff --git a/simpleperf/environment.cpp b/simpleperf/environment.cpp
index 039eed59..8b39881d 100644
--- a/simpleperf/environment.cpp
+++ b/simpleperf/environment.cpp
@@ -27,6 +27,7 @@
#include <android-base/file.h>
#include <android-base/logging.h>
+#include <android-base/parseint.h>
#include <android-base/strings.h>
#include <android-base/stringprintf.h>
@@ -305,9 +306,9 @@ static std::vector<pid_t> GetThreadsInProcess(pid_t pid) {
std::string task_dirname = android::base::StringPrintf("/proc/%d/task", pid);
std::vector<std::string> subdirs;
GetEntriesInDir(task_dirname, nullptr, &subdirs);
- for (auto& name : subdirs) {
+ for (const auto& name : subdirs) {
int tid;
- if (!StringToPid(name, &tid)) {
+ if (!android::base::ParseInt(name.c_str(), &tid, 0)) {
continue;
}
result.push_back(tid);
@@ -341,7 +342,7 @@ bool GetThreadComms(std::vector<ThreadComm>* thread_comms) {
GetEntriesInDir("/proc", nullptr, &subdirs);
for (auto& name : subdirs) {
int pid;
- if (!StringToPid(name, &pid)) {
+ if (!android::base::ParseInt(name.c_str(), &pid, 0)) {
continue;
}
if (!GetThreadComm(pid, thread_comms)) {
@@ -396,9 +397,9 @@ bool GetModuleBuildId(const std::string& module_name, BuildId* build_id) {
bool GetValidThreadsFromProcessString(const std::string& pid_str, std::set<pid_t>* tid_set) {
std::vector<std::string> strs = android::base::Split(pid_str, ",");
- for (auto& s : strs) {
+ for (const auto& s : strs) {
int pid;
- if (!StringToPid(s, &pid)) {
+ if (!android::base::ParseInt(s.c_str(), &pid, 0)) {
LOG(ERROR) << "Invalid pid '" << s << "'";
return false;
}
@@ -414,9 +415,9 @@ bool GetValidThreadsFromProcessString(const std::string& pid_str, std::set<pid_t
bool GetValidThreadsFromThreadString(const std::string& tid_str, std::set<pid_t>* tid_set) {
std::vector<std::string> strs = android::base::Split(tid_str, ",");
- for (auto& s : strs) {
+ for (const auto& s : strs) {
int tid;
- if (!StringToPid(s, &tid)) {
+ if (!android::base::ParseInt(s.c_str(), &tid, 0)) {
LOG(ERROR) << "Invalid tid '" << s << "'";
return false;
}
diff --git a/simpleperf/get_test_data.h b/simpleperf/get_test_data.h
new file mode 100644
index 00000000..313da040
--- /dev/null
+++ b/simpleperf/get_test_data.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SIMPLE_PERF_GET_TEST_DATA_H_
+#define SIMPLE_PERF_GET_TEST_DATA_H_
+
+#include <string>
+
+std::string GetTestData(const std::string& filename);
+
+#endif // SIMPLE_PERF_GET_TEST_DATA_H_
diff --git a/simpleperf/gtest_main.cpp b/simpleperf/gtest_main.cpp
index 5de802af..04412eaa 100644
--- a/simpleperf/gtest_main.cpp
+++ b/simpleperf/gtest_main.cpp
@@ -18,8 +18,30 @@
#include <android-base/logging.h>
+#include "get_test_data.h"
+#include "utils.h"
+
+static std::string testdata_dir;
+
int main(int argc, char** argv) {
InitLogging(argv, android::base::StderrLogger);
testing::InitGoogleTest(&argc, argv);
+ for (int i = 1; i < argc; ++i) {
+ if (strcmp(argv[i], "-t") == 0 && i + 1 < argc) {
+ testdata_dir = argv[i + 1];
+ break;
+ }
+ }
+ if (testdata_dir.empty()) {
+ printf("Usage: simpleperf_unit_test -t <testdata_dir>\n");
+ return 1;
+ }
+ if (testdata_dir.back() != '/') {
+ testdata_dir.push_back('/');
+ }
return RUN_ALL_TESTS();
}
+
+std::string GetTestData(const std::string& filename) {
+ return testdata_dir + filename;
+}
diff --git a/simpleperf/read_apk.cpp b/simpleperf/read_apk.cpp
index 5e8077e9..270b3052 100644
--- a/simpleperf/read_apk.cpp
+++ b/simpleperf/read_apk.cpp
@@ -24,22 +24,22 @@
#include <sys/types.h>
#include <unistd.h>
-#include <iostream>
#include <map>
#include <android-base/file.h>
#include <android-base/logging.h>
+#include <ziparchive/zip_archive.h>
#include "read_elf.h"
#include "utils.h"
-#include "ziparchive/zip_archive.h"
bool IsValidJarOrApkPath(const std::string& filename) {
static const char zip_preamble[] = {0x50, 0x4b, 0x03, 0x04 };
if (!IsRegularFile(filename)) {
return false;
}
- FILE* fp = fopen(filename.c_str(), "reb");
+ std::string mode = std::string("rb") + CLOSE_ON_EXEC_MODE;
+ FILE* fp = fopen(filename.c_str(), mode.c_str());
if (fp == nullptr) {
return false;
}
diff --git a/simpleperf/read_apk_test.cpp b/simpleperf/read_apk_test.cpp
index f2234486..5824f4b7 100644
--- a/simpleperf/read_apk_test.cpp
+++ b/simpleperf/read_apk_test.cpp
@@ -17,22 +17,23 @@
#include "read_apk.h"
#include <gtest/gtest.h>
+#include "get_test_data.h"
static const std::string fibjar = "fibonacci.jar";
static const std::string jniapk = "has_embedded_native_libs.apk";
TEST(read_apk, IsValidJarOrApkPath) {
ASSERT_FALSE(IsValidJarOrApkPath("/dev/zero"));
- ASSERT_FALSE(IsValidJarOrApkPath("/proc/self/exe"));
- ASSERT_TRUE(IsValidJarOrApkPath(fibjar));
+ ASSERT_FALSE(IsValidJarOrApkPath(GetTestData("elf_file")));
+ ASSERT_TRUE(IsValidJarOrApkPath(GetTestData(fibjar)));
}
TEST(read_apk, CollectEmbeddedElfInfoFromApk) {
ApkInspector inspector;
ASSERT_TRUE(inspector.FindElfInApkByMmapOffset("/dev/null", 0) == nullptr);
- ASSERT_TRUE(inspector.FindElfInApkByMmapOffset(fibjar, 0) == nullptr);
- ASSERT_TRUE(inspector.FindElfInApkByMmapOffset(jniapk, 0) == nullptr);
- EmbeddedElf *ee1 = inspector.FindElfInApkByMmapOffset(jniapk, 0x91000);
+ ASSERT_TRUE(inspector.FindElfInApkByMmapOffset(GetTestData(fibjar), 0) == nullptr);
+ ASSERT_TRUE(inspector.FindElfInApkByMmapOffset(GetTestData(jniapk), 0) == nullptr);
+ EmbeddedElf *ee1 = inspector.FindElfInApkByMmapOffset(GetTestData(jniapk), 0x91000);
ASSERT_TRUE(ee1 != nullptr);
ASSERT_EQ(ee1->entry_name(), "lib/armeabi-v7a/libframeworks_coretests_jni.so");
ASSERT_TRUE(ee1->entry_offset() == 593920);
diff --git a/simpleperf/read_elf.cpp b/simpleperf/read_elf.cpp
index a4e65ff2..03bdcc56 100644
--- a/simpleperf/read_elf.cpp
+++ b/simpleperf/read_elf.cpp
@@ -46,7 +46,7 @@
FileHelper::FileHelper(const char *filename) : fd_(-1)
{
- fd_ = TEMP_FAILURE_RETRY(open(filename, O_RDONLY));
+ fd_ = TEMP_FAILURE_RETRY(open(filename, O_RDONLY | O_BINARY));
}
FileHelper::~FileHelper()
@@ -57,13 +57,7 @@ FileHelper::~FileHelper()
bool IsValidElfFile(int fd) {
static const char elf_magic[] = {0x7f, 'E', 'L', 'F'};
char buf[4];
- size_t sz4 = 4;
-
- ssize_t rc = TEMP_FAILURE_RETRY(read(fd, buf, sz4));
- if (rc < 0 || rc != 4 || memcmp(buf, elf_magic, 4) != 0) {
- return false;
- }
- return true;
+ return android::base::ReadFully(fd, buf, 4) && memcmp(buf, elf_magic, 4) == 0;
}
bool IsValidElfPath(const std::string& filename) {
diff --git a/simpleperf/read_elf_test.cpp b/simpleperf/read_elf_test.cpp
index 407e7b78..7a5194ea 100644
--- a/simpleperf/read_elf_test.cpp
+++ b/simpleperf/read_elf_test.cpp
@@ -18,19 +18,55 @@
#include <gtest/gtest.h>
-static void ParseSymbol(const ElfFileSymbol& symbol, bool* result) {
- if (symbol.is_func) {
- *result = true;
- }
+#include <map>
+#include "get_test_data.h"
+
+static const unsigned char elf_file_build_id[] = {
+ 0x76, 0x00, 0x32, 0x9e, 0x31, 0x05, 0x8e, 0x12, 0xb1, 0x45,
+ 0xd1, 0x53, 0xef, 0x27, 0xcd, 0x40, 0xe1, 0xa5, 0xf7, 0xb9
+};
+
+TEST(read_elf, GetBuildIdFromElfFile) {
+ BuildId build_id;
+ ASSERT_TRUE(GetBuildIdFromElfFile(GetTestData("elf_file"), &build_id));
+ ASSERT_EQ(build_id, BuildId(elf_file_build_id));
}
-TEST(read_elf, parse_symbols_from_elf_file) {
+static void ParseSymbol(const ElfFileSymbol& symbol, std::map<std::string, ElfFileSymbol>* symbols) {
+ (*symbols)[symbol.name] = symbol;
+}
+
+static void CheckElfFileSymbols(const std::map<std::string, ElfFileSymbol>& symbols) {
+ auto pos = symbols.find("GlobalVar");
+ ASSERT_NE(pos, symbols.end());
+ ASSERT_FALSE(pos->second.is_func);
+ pos = symbols.find("GlobalFunc");
+ ASSERT_NE(pos, symbols.end());
+ ASSERT_TRUE(pos->second.is_func);
+ ASSERT_TRUE(pos->second.is_in_text_section);
+}
+
+TEST(read_elf, parse_symbols_from_elf_file_with_correct_build_id) {
+ BuildId build_id(elf_file_build_id);
+ std::map<std::string, ElfFileSymbol> symbols;
+ ASSERT_TRUE(ParseSymbolsFromElfFile(GetTestData("elf_file"), build_id,
+ std::bind(ParseSymbol, std::placeholders::_1, &symbols)));
+ CheckElfFileSymbols(symbols);
+}
+
+TEST(read_elf, parse_symbols_from_elf_file_without_build_id) {
BuildId build_id;
- GetBuildIdFromElfFile("proc/self/exe", &build_id);
- bool result = false;
- ASSERT_TRUE(ParseSymbolsFromElfFile("/proc/self/exe", build_id,
- std::bind(ParseSymbol, std::placeholders::_1, &result)));
- ASSERT_TRUE(result);
+ std::map<std::string, ElfFileSymbol> symbols;
+ ASSERT_TRUE(ParseSymbolsFromElfFile(GetTestData("elf_file"), build_id,
+ std::bind(ParseSymbol, std::placeholders::_1, &symbols)));
+ CheckElfFileSymbols(symbols);
+}
+
+TEST(read_elf, parse_symbols_from_elf_file_with_wrong_build_id) {
+ BuildId build_id("wrong_build_id");
+ std::map<std::string, ElfFileSymbol> symbols;
+ ASSERT_FALSE(ParseSymbolsFromElfFile(GetTestData("elf_file"), build_id,
+ std::bind(ParseSymbol, std::placeholders::_1, &symbols)));
}
TEST(read_elf, arm_mapping_symbol) {
@@ -43,5 +79,5 @@ TEST(read_elf, arm_mapping_symbol) {
TEST(read_elf, IsValidElfPath) {
ASSERT_FALSE(IsValidElfPath("/dev/zero"));
ASSERT_FALSE(IsValidElfPath("/sys/devices/system/cpu/online"));
- ASSERT_TRUE(IsValidElfPath("/proc/self/exe"));
+ ASSERT_TRUE(IsValidElfPath(GetTestData("elf_file")));
}
diff --git a/simpleperf/test_inputs/Android.mk b/simpleperf/test_inputs/Android.mk
deleted file mode 100644
index 6f565c1c..00000000
--- a/simpleperf/test_inputs/Android.mk
+++ /dev/null
@@ -1,20 +0,0 @@
-
-# some data files used by simpleperf_unit_test
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := fibonacci.jar
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_CLASS := DATA
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_NATIVE_TESTS)/simpleperf_unit_test
-LOCAL_SRC_FILES := fibonacci.jar
-include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := has_embedded_native_libs.apk
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE_CLASS := DATA
-LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_NATIVE_TESTS)/simpleperf_unit_test
-LOCAL_SRC_FILES := has_embedded_native_libs.apk
-include $(BUILD_PREBUILT)
diff --git a/simpleperf/testdata/elf_file b/simpleperf/testdata/elf_file
new file mode 100644
index 00000000..53b589a5
--- /dev/null
+++ b/simpleperf/testdata/elf_file
Binary files differ
diff --git a/simpleperf/test_inputs/fibonacci.jar b/simpleperf/testdata/fibonacci.jar
index df57e40f..df57e40f 100644
--- a/simpleperf/test_inputs/fibonacci.jar
+++ b/simpleperf/testdata/fibonacci.jar
Binary files differ
diff --git a/simpleperf/test_inputs/has_embedded_native_libs.apk b/simpleperf/testdata/has_embedded_native_libs.apk
index 2a1924cd..2a1924cd 100644
--- a/simpleperf/test_inputs/has_embedded_native_libs.apk
+++ b/simpleperf/testdata/has_embedded_native_libs.apk
Binary files differ
diff --git a/simpleperf/utils.cpp b/simpleperf/utils.cpp
index ae157b53..eabad29f 100644
--- a/simpleperf/utils.cpp
+++ b/simpleperf/utils.cpp
@@ -114,9 +114,3 @@ bool IsRegularFile(const std::string& filename) {
}
return false;
}
-
-bool StringToPid(const std::string& s, int* pid) {
- char* endptr;
- *pid = static_cast<int>(strtol(s.c_str(), &endptr, 10));
- return *endptr == '\0';
-}
diff --git a/simpleperf/utils.h b/simpleperf/utils.h
index c63ac6c2..2ce0726d 100644
--- a/simpleperf/utils.h
+++ b/simpleperf/utils.h
@@ -66,6 +66,5 @@ void GetEntriesInDir(const std::string& dirpath, std::vector<std::string>* files
std::vector<std::string>* subdirs);
bool IsDir(const std::string& dirpath);
bool IsRegularFile(const std::string& filename);
-bool StringToPid(const std::string& s, int* pid);
#endif // SIMPLE_PERF_UTILS_H_