Merge "Add SHARED_BLOCKS constant to ext4_utils."
diff --git a/ANRdaemon/Android.bp b/ANRdaemon/Android.bp
new file mode 100644
index 0000000..9bb9b71
--- /dev/null
+++ b/ANRdaemon/Android.bp
@@ -0,0 +1,16 @@
+cc_binary {
+ name: "anrd",
+ srcs: ["ANRdaemon.cpp"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+
+ shared_libs: [
+ "liblog",
+ "libbinder",
+ "libcutils",
+ "libutils",
+ "libz",
+ ],
+}
diff --git a/ANRdaemon/Android.mk b/ANRdaemon/Android.mk
deleted file mode 100644
index de5acce..0000000
--- a/ANRdaemon/Android.mk
+++ /dev/null
@@ -1,20 +0,0 @@
-ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := ANRdaemon.cpp
-LOCAL_C_INCLUDES += external/zlib
-LOCAL_MODULE := anrd
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := debug
-LOCAL_SHARED_LIBRARIES := \
- liblog \
- libbinder \
- libcutils \
- libutils \
- libz
-include $(BUILD_EXECUTABLE)
-
-endif
diff --git a/Android.bp b/Android.bp
index f441d6e..ac5d8b8 100644
--- a/Android.bp
+++ b/Android.bp
@@ -12,5 +12,3 @@
"-Wno-unused-const-variable",
],
}
-
-subdirs = ["*"]
diff --git a/CleanSpec.mk b/CleanSpec.mk
index ce834cf..8f0a0fb 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -46,6 +46,28 @@
$(call add-clean-step, rm -f $(PRODUCT_OUT)/system.img $(PRODUCT_OUT)/userdata.img)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES/taskstats_intermediates)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/anrd)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/cpustats)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/crypto)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/kexecload)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/ksminfo)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/latencytop)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/memtrack_share)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/memtrack)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/micro_bench)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/micro_bench_static)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/dnschk)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/httpurl)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/dumpcache)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/puncture_fs)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/runconuid)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/sane_schedstat)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/showslab)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/taskstats)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/ioshark_bench)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/cpueater)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/daemonize)
+$(call add-clean-step, rm -f $(TARGET_OUT_OPTIONAL_EXECUTABLES)/directiotest)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
diff --git a/app-launcher/Android.bp b/app-launcher/Android.bp
new file mode 100644
index 0000000..7585607
--- /dev/null
+++ b/app-launcher/Android.bp
@@ -0,0 +1,26 @@
+cc_defaults {
+ name: "computestats-defaults",
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+
+ target: {
+ darwin: {
+ enabled: false,
+ },
+ },
+}
+
+cc_binary_host {
+ name: "computestats",
+ defaults: ["computestats-defaults"],
+ srcs: ["computestats.c"],
+}
+
+cc_binary_host {
+ name: "computestatsf",
+ defaults: ["computestats-defaults"],
+ srcs: ["computestatsf.c"],
+}
diff --git a/app-launcher/Android.mk b/app-launcher/Android.mk
index cef9daa..5df6eb9 100644
--- a/app-launcher/Android.mk
+++ b/app-launcher/Android.mk
@@ -1,26 +1,10 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
-#LOCAL_32_BIT_ONLY = true
+LOCAL_MODULE := app-launcher
+LOCAL_IS_HOST_MODULE := true
+LOCAL_MODULE_CLASS := EXECUTABLES
+LOCAL_SRC_FILES := app-launcher
LOCAL_MODULE_HOST_OS := linux
-LOCAL_SRC_FILES := computestatsf.c
-LOCAL_MODULE := computestatsf
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_MODULE_TAGS := debug
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-#LOCAL_32_BIT_ONLY = true
-LOCAL_MODULE_HOST_OS := linux
-LOCAL_SRC_FILES := computestats.c
-LOCAL_MODULE := computestats
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_MODULE_TAGS := debug
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_PREBUILT_EXECUTABLES := app-launcher
-LOCAL_MODULE_HOST_OS := linux
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-include $(BUILD_HOST_PREBUILT)
+LOCAL_REQUIRED_MODULES := computestats computestatsf
+include $(BUILD_PREBUILT)
diff --git a/boot_control_copy/Android.bp b/boot_control_copy/Android.bp
new file mode 100644
index 0000000..97d89c8
--- /dev/null
+++ b/boot_control_copy/Android.bp
@@ -0,0 +1,26 @@
+// Copyright 2015 The Android Open Source Project
+
+cc_library_shared {
+ name: "bootctrl.default",
+ relative_install_path: "hw",
+
+ srcs: [
+ "boot_control_copy.cpp",
+ "bootinfo.cpp",
+ ],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-missing-field-initializers",
+ "-Wno-unused-parameter",
+ ],
+ header_libs: ["bootimg_headers"],
+ shared_libs: [
+ "libbase",
+ "libcutils",
+ ],
+ static_libs: [
+ "libbootloader_message",
+ "libfs_mgr",
+ ],
+}
diff --git a/boot_control_copy/Android.mk b/boot_control_copy/Android.mk
deleted file mode 100644
index 8ed3273..0000000
--- a/boot_control_copy/Android.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2015 The Android Open Source Project
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := boot_control_copy.cpp bootinfo.cpp
-LOCAL_CFLAGS := -Wall -Werror -Wno-missing-field-initializers -Wno-unused-parameter
-LOCAL_HEADER_LIBRARIES := bootimg_headers
-LOCAL_SHARED_LIBRARIES := libbase libcutils
-LOCAL_STATIC_LIBRARIES := libbootloader_message libfs_mgr
-
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_MODULE:= bootctrl.default
-include $(BUILD_SHARED_LIBRARY)
diff --git a/bootctl/Android.bp b/bootctl/Android.bp
new file mode 100644
index 0000000..a58723c
--- /dev/null
+++ b/bootctl/Android.bp
@@ -0,0 +1,17 @@
+// Copyright 2015 The Android Open Source Project
+
+cc_binary {
+ name: "bootctl",
+ srcs: ["bootctl.cpp"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ "android.hardware.boot@1.0",
+ ],
+}
diff --git a/bootctl/Android.mk b/bootctl/Android.mk
deleted file mode 100644
index 7a0c526..0000000
--- a/bootctl/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2015 The Android Open Source Project
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := bootctl.cpp
-LOCAL_MODULE := bootctl
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_SHARED_LIBRARIES := \
- libhidlbase \
- libhidltransport \
- libhwbinder \
- libutils \
- android.hardware.boot@1.0 \
-
-include $(BUILD_EXECUTABLE)
diff --git a/cpustats/Android.bp b/cpustats/Android.bp
new file mode 100644
index 0000000..6b0229b
--- /dev/null
+++ b/cpustats/Android.bp
@@ -0,0 +1,8 @@
+cc_binary {
+ name: "cpustats",
+ srcs: ["cpustats.c"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
diff --git a/cpustats/Android.mk b/cpustats/Android.mk
deleted file mode 100644
index a6db30f..0000000
--- a/cpustats/Android.mk
+++ /dev/null
@@ -1,11 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := cpustats.c
-LOCAL_CFLAGS := -Wall -Werror
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE := cpustats
-
-include $(BUILD_EXECUTABLE)
diff --git a/crypto-perf/Android.bp b/crypto-perf/Android.bp
new file mode 100644
index 0000000..6011689
--- /dev/null
+++ b/crypto-perf/Android.bp
@@ -0,0 +1,18 @@
+cc_binary {
+ name: "crypto",
+
+ cflags: [
+ "-O0",
+ "-march=armv8-a+crypto",
+ "-Wall",
+ "-Werror",
+ ],
+ srcs: ["crypto.cpp"],
+
+ enabled: false,
+ arch: {
+ arm64: {
+ enabled: true,
+ },
+ },
+}
diff --git a/crypto-perf/Android.mk b/crypto-perf/Android.mk
deleted file mode 100644
index 4a3cbe4..0000000
--- a/crypto-perf/Android.mk
+++ /dev/null
@@ -1,13 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-ifeq ($(TARGET_ARCH),arm64)
-include $(CLEAR_VARS)
-
-LOCAL_CFLAGS := -O0 -march=armv8-a+crypto -Wall -Werror
-LOCAL_SRC_FILES := crypto.cpp
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE := crypto
-
-include $(BUILD_EXECUTABLE)
-endif
diff --git a/f2fs_utils/f2fs_sparseblock.c b/f2fs_utils/f2fs_sparseblock.c
index 27225c6..95268d0 100644
--- a/f2fs_utils/f2fs_sparseblock.c
+++ b/f2fs_utils/f2fs_sparseblock.c
@@ -2,6 +2,8 @@
#define LOG_TAG "f2fs_sparseblock"
+#include "f2fs_sparseblock.h"
+
#include <errno.h>
#include <f2fs_fs.h>
#include <fcntl.h>
@@ -14,8 +16,6 @@
#include <log/log.h>
-#include "f2fs_sparseblock.h"
-
#define D_DISP_u32(ptr, member) \
do { \
SLOGD("%-30s" "\t\t[0x%#08x : %u]\n", \
@@ -216,7 +216,7 @@
{
unsigned char *cp_block_1, *cp_block_2;
struct f2fs_checkpoint *cp_block, *cp_ret;
- u64 cp1_version = 0, cp2_version = 0;
+ uint64_t cp1_version = 0, cp2_version = 0;
cp_block_1 = malloc(F2FS_BLKSIZE);
if (!cp_block_1)
@@ -314,10 +314,10 @@
static int gather_sit_info(int fd, struct f2fs_info *info)
{
- u64 num_segments = (info->total_blocks - info->main_blkaddr
+ uint64_t num_segments = (info->total_blocks - info->main_blkaddr
+ info->blocks_per_segment - 1) / info->blocks_per_segment;
- u64 num_sit_blocks = (num_segments + SIT_ENTRY_PER_BLOCK - 1) / SIT_ENTRY_PER_BLOCK;
- u64 sit_block;
+ uint64_t num_sit_blocks = (num_segments + SIT_ENTRY_PER_BLOCK - 1) / SIT_ENTRY_PER_BLOCK;
+ uint64_t sit_block;
info->sit_blocks = malloc(num_sit_blocks * sizeof(struct f2fs_sit_block));
if (!info->sit_blocks)
@@ -345,7 +345,7 @@
return !!(ckpt_flags & f);
}
-static inline u64 sum_blk_addr(struct f2fs_checkpoint *cp, struct f2fs_info *info, int base, int type)
+static inline uint64_t sum_blk_addr(struct f2fs_checkpoint *cp, struct f2fs_info *info, int base, int type)
{
return info->cp_valid_cp_blkaddr + le32_to_cpu(cp->cp_pack_total_block_count)
- (base + 1) + type;
@@ -365,7 +365,7 @@
return -1;
memcpy(&info->sit_sums->journal.n_sits, &buffer[SUM_JOURNAL_SIZE], SUM_JOURNAL_SIZE);
} else {
- u64 blk_addr;
+ uint64_t blk_addr;
if (is_set_ckpt_flags(cp, CP_UMOUNT_FLAG))
blk_addr = sum_blk_addr(cp, info, NR_CURSEG_TYPE, CURSEG_COLD_DATA);
else
@@ -470,7 +470,7 @@
free(info);
}
-u64 get_num_blocks_used(struct f2fs_info *info)
+uint64_t get_num_blocks_used(struct f2fs_info *info)
{
return info->main_blkaddr + info->total_user_used;
}
@@ -485,11 +485,11 @@
return (mask & *addr) != 0;
}
-int run_on_used_blocks(u64 startblock, struct f2fs_info *info, int (*func)(u64 pos, void *data), void *data) {
+int run_on_used_blocks(uint64_t startblock, struct f2fs_info *info, int (*func)(uint64_t pos, void *data), void *data) {
struct f2fs_sit_block sit_block_cache;
struct f2fs_sit_entry * sit_entry;
- u64 sit_block_num_cur = 0, segnum = 0, block_offset;
- u64 block;
+ uint64_t sit_block_num_cur = 0, segnum = 0, block_offset;
+ uint64_t block;
unsigned int used, found, started = 0, i;
block = startblock;
@@ -555,7 +555,7 @@
* filesystem, replacing blocks identified as unused with 0's.
*/
-int copy_used(u64 pos, void *data)
+int copy_used(uint64_t pos, void *data)
{
struct privdata *d = data;
char *buf;
diff --git a/f2fs_utils/f2fs_sparseblock.h b/f2fs_utils/f2fs_sparseblock.h
index 0a0dab4..e5c5f84 100644
--- a/f2fs_utils/f2fs_sparseblock.h
+++ b/f2fs_utils/f2fs_sparseblock.h
@@ -17,14 +17,12 @@
#ifndef F2FS_UTILS_F2F2_UTILS_H_
#define F2FS_UTILS_F2F2_UTILS_H_
+#include <stdint.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-
-
-
-
#define ver_after(a, b) (typecheck(unsigned long long, a) && \
typecheck(unsigned long long, b) && \
((long long)((a) - (b)) > 0))
@@ -37,35 +35,35 @@
struct f2fs_summary_block;
struct f2fs_info {
- u_int64_t blocks_per_segment;
- u_int32_t block_size;
+ uint64_t blocks_per_segment;
+ uint32_t block_size;
char *sit_bmp;
- u_int32_t sit_bmp_size;
- u_int64_t blocks_per_sit;
+ uint32_t sit_bmp_size;
+ uint64_t blocks_per_sit;
struct f2fs_sit_block *sit_blocks;
struct f2fs_summary_block *sit_sums;
- u_int64_t cp_blkaddr;
- u_int64_t cp_valid_cp_blkaddr;
+ uint64_t cp_blkaddr;
+ uint64_t cp_valid_cp_blkaddr;
- u_int64_t sit_blkaddr;
+ uint64_t sit_blkaddr;
- u_int64_t nat_blkaddr;
+ uint64_t nat_blkaddr;
- u_int64_t ssa_blkaddr;
+ uint64_t ssa_blkaddr;
- u_int64_t main_blkaddr;
+ uint64_t main_blkaddr;
- u_int64_t total_user_used;
- u_int64_t total_blocks;
+ uint64_t total_user_used;
+ uint64_t total_blocks;
};
-u64 get_num_blocks_used(struct f2fs_info *info);
+uint64_t get_num_blocks_used(struct f2fs_info *info);
struct f2fs_info *generate_f2fs_info(int fd);
void free_f2fs_info(struct f2fs_info *info);
unsigned int get_f2fs_filesystem_size_sec(char *dev);
-int run_on_used_blocks(u64 startblock, struct f2fs_info *info, int (*func)(u64 pos, void *data), void *data);
+int run_on_used_blocks(uint64_t startblock, struct f2fs_info *info, int (*func)(uint64_t pos, void *data), void *data);
#ifdef __cplusplus
}
diff --git a/iotop/Android.bp b/iotop/Android.bp
new file mode 100644
index 0000000..9b5e40c
--- /dev/null
+++ b/iotop/Android.bp
@@ -0,0 +1,33 @@
+// 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.
+
+cc_binary {
+ name: "iotop",
+
+ srcs: [
+ "iotop.cpp",
+ "tasklist.cpp",
+ "taskstats.cpp",
+ ],
+
+ shared_libs: [
+ "libnl",
+ "libbase",
+ ],
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
diff --git a/iotop/Android.mk b/iotop/Android.mk
deleted file mode 100644
index b8a146d..0000000
--- a/iotop/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-# 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.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := iotop.cpp tasklist.cpp taskstats.cpp
-
-LOCAL_MODULE := iotop
-
-LOCAL_MODULE_TAGS := debug
-
-LOCAL_SHARED_LIBRARIES := libnl libbase
-
-LOCAL_CFLAGS := -Wall -Werror
-
-include $(BUILD_EXECUTABLE)
diff --git a/kexec_tools/Android.bp b/kexec_tools/Android.bp
new file mode 100644
index 0000000..bcfc2ee
--- /dev/null
+++ b/kexec_tools/Android.bp
@@ -0,0 +1,23 @@
+// Copyright (C) 2013 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.
+// Copyright The Android Open Source Project
+
+cc_binary {
+ name: "kexecload",
+ srcs: ["kexecload.c"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
diff --git a/kexec_tools/Android.mk b/kexec_tools/Android.mk
deleted file mode 100644
index c8a4932..0000000
--- a/kexec_tools/Android.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (C) 2013 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.
-# Copyright The Android Open Source Project
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := kexecload
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := eng
-LOCAL_SRC_FILES := kexecload.c
-LOCAL_CFLAGS := -Wall -Werror
-include $(BUILD_EXECUTABLE)
diff --git a/ksmutils/Android.bp b/ksmutils/Android.bp
new file mode 100644
index 0000000..248743c
--- /dev/null
+++ b/ksmutils/Android.bp
@@ -0,0 +1,26 @@
+// Copyright (C) 2013 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.
+
+cc_binary {
+ name: "ksminfo",
+ srcs: [
+ "ksminfo.c",
+ "lookup3.c",
+ ],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+ shared_libs: ["libpagemap"],
+}
diff --git a/ksmutils/Android.mk b/ksmutils/Android.mk
deleted file mode 100644
index 2be4ddf..0000000
--- a/ksmutils/Android.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (C) 2013 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.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := ksminfo.c lookup3.c
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_SHARED_LIBRARIES := libpagemap
-LOCAL_MODULE := ksminfo
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := debug
-include $(BUILD_EXECUTABLE)
diff --git a/latencytop/Android.bp b/latencytop/Android.bp
new file mode 100644
index 0000000..fab3631
--- /dev/null
+++ b/latencytop/Android.bp
@@ -0,0 +1,25 @@
+// Copyright (C) 2008 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.
+
+cc_binary {
+ name: "latencytop",
+
+ srcs: ["latencytop.c"],
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-unused-parameter",
+ ],
+}
diff --git a/latencytop/Android.mk b/latencytop/Android.mk
deleted file mode 100644
index 6649a83..0000000
--- a/latencytop/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright (C) 2008 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.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := latencytop.c
-
-LOCAL_MODULE := latencytop
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-
-LOCAL_MODULE_TAGS := debug
-
-LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
-
-include $(BUILD_EXECUTABLE)
diff --git a/libfec/Android.mk b/libfec/Android.mk
deleted file mode 100644
index 12974bc..0000000
--- a/libfec/Android.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2015 The Android Open Source Project
-#
-LOCAL_PATH := $(call my-dir)
-
-include $(LOCAL_PATH)/test/Android.mk
diff --git a/libfec/test/Android.bp b/libfec/test/Android.bp
new file mode 100644
index 0000000..5cc6d86
--- /dev/null
+++ b/libfec/test/Android.bp
@@ -0,0 +1,40 @@
+cc_defaults {
+ name: "fec_test_defaults",
+
+ gtest: false,
+ sanitize: {
+ misc_undefined: ["integer"],
+ },
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-D_GNU_SOURCE",
+ ],
+ target: {
+ darwin: {
+ enabled: false,
+ },
+ },
+}
+
+cc_test_host {
+ name: "fec_test_read",
+ defaults: ["fec_test_defaults"],
+ srcs: ["test_read.cpp"],
+ static_libs: [
+ "libfec",
+ "libfec_rs",
+ "libcrypto_utils",
+ "libcrypto",
+ "libext4_utils",
+ "libsquashfs_utils",
+ "libbase",
+ ],
+}
+
+cc_test_host {
+ name: "fec_test_rs",
+ defaults: ["fec_test_defaults"],
+ srcs: ["test_rs.c"],
+ static_libs: ["libfec_rs"],
+}
diff --git a/libfec/test/Android.mk b/libfec/test/Android.mk
deleted file mode 100644
index 0d5e248..0000000
--- a/libfec/test/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-ifeq ($(HOST_OS),linux)
-
-include $(CLEAR_VARS)
-LOCAL_SANITIZE := integer
-LOCAL_MODULE := fec_test_read
-LOCAL_SRC_FILES := test_read.cpp
-LOCAL_MODULE_TAGS := optional
-LOCAL_STATIC_LIBRARIES := \
- libfec \
- libfec_rs \
- libcrypto_utils \
- libcrypto \
- libext4_utils \
- libsquashfs_utils \
- libbase
-LOCAL_CFLAGS := -Wall -Werror -D_GNU_SOURCE
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SANITIZE := integer
-LOCAL_MODULE := fec_test_rs
-LOCAL_SRC_FILES := test_rs.c
-LOCAL_MODULE_TAGS := optional
-LOCAL_STATIC_LIBRARIES := libfec_rs
-LOCAL_CFLAGS := -Wall -Werror -D_GNU_SOURCE
-LOCAL_C_INCLUDES += external/fec
-include $(BUILD_HOST_EXECUTABLE)
-
-endif # HOST_OS == linux
diff --git a/memcpy-perf/Android.bp b/memcpy-perf/Android.bp
new file mode 100644
index 0000000..0fbbf2f
--- /dev/null
+++ b/memcpy-perf/Android.bp
@@ -0,0 +1,18 @@
+cc_binary {
+ name: "memcpy-perf",
+ cflags: [
+ "-g",
+ "-Wall",
+ "-Werror",
+ "-Wno-missing-field-initializers",
+ "-Wno-sign-compare",
+ "-O3",
+ ],
+ srcs: [
+ "memcpy-perf.cpp",
+ "test-funcs.cpp",
+ ],
+ static_executable: true,
+ stl: "libc++_static",
+ static_libs: ["libc"],
+}
diff --git a/memcpy-perf/Android.mk b/memcpy-perf/Android.mk
deleted file mode 100644
index a2b3399..0000000
--- a/memcpy-perf/Android.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := memcpy-perf
-LOCAL_CFLAGS += -g -Wall -Werror -Wno-missing-field-initializers -Wno-sign-compare -O3
-LOCAL_SRC_FILES := memcpy-perf.cpp test-funcs.cpp
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-LOCAL_CXX_STL := libc++_static
-LOCAL_STATIC_LIBRARIES := libc
-include $(BUILD_EXECUTABLE)
diff --git a/memory_replay/Android.bp b/memory_replay/Android.bp
new file mode 100644
index 0000000..824ac12
--- /dev/null
+++ b/memory_replay/Android.bp
@@ -0,0 +1,65 @@
+cc_defaults {
+ name: "memory_replay_defaults",
+ host_supported: true,
+
+ srcs: [
+ "Action.cpp",
+ "LineBuffer.cpp",
+ "NativeInfo.cpp",
+ "Pointers.cpp",
+ "Thread.cpp",
+ "Threads.cpp",
+ ],
+ cflags: [
+ "-Wall",
+ "-Wextra",
+ "-Werror",
+ ],
+ shared_libs: ["libbase"],
+
+ target: {
+ darwin: {
+ enabled: false,
+ },
+ },
+
+ compile_multilib: "both",
+ multilib: {
+ lib32: {
+ suffix: "32",
+ },
+ lib64: {
+ suffix: "64",
+ },
+ },
+
+}
+
+cc_binary {
+ name: "memory_replay",
+ defaults: ["memory_replay_defaults"],
+
+ srcs: ["main.cpp"],
+}
+
+cc_test {
+ name: "memory_replay_tests",
+ defaults: ["memory_replay_defaults"],
+
+ srcs: [
+ "tests/ActionTest.cpp",
+ "tests/LineBufferTest.cpp",
+ "tests/NativeInfoTest.cpp",
+ "tests/PointersTest.cpp",
+ "tests/ThreadTest.cpp",
+ "tests/ThreadsTest.cpp",
+ ],
+
+ local_include_dirs: ["tests"],
+
+ target: {
+ android: {
+ test_suites: ["device-tests"],
+ },
+ },
+}
diff --git a/memory_replay/Android.mk b/memory_replay/Android.mk
deleted file mode 100644
index b72f006..0000000
--- a/memory_replay/Android.mk
+++ /dev/null
@@ -1,82 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-memory_replay_src_files := \
- Action.cpp \
- LineBuffer.cpp \
- NativeInfo.cpp \
- Pointers.cpp \
- Thread.cpp \
- Threads.cpp \
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(memory_replay_src_files) main.cpp
-LOCAL_CFLAGS := -Wall -Wextra -Werror
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE := memory_replay
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-LOCAL_SHARED_LIBRARIES := libbase
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(memory_replay_src_files) main.cpp
-LOCAL_CFLAGS := -Wall -Wextra -Werror
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE := memory_replay
-LOCAL_MODULE_HOST_OS := linux
-LOCAL_LDLIBS := -lrt
-LOCAL_SHARED_LIBRARIES := libbase
-include $(BUILD_HOST_EXECUTABLE)
-
-memory_replay_test_src_files := \
- tests/ActionTest.cpp \
- tests/LineBufferTest.cpp \
- tests/NativeInfoTest.cpp \
- tests/PointersTest.cpp \
- tests/ThreadTest.cpp \
- tests/ThreadsTest.cpp \
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- $(memory_replay_src_files) \
- $(memory_replay_test_src_files) \
-
-LOCAL_CFLAGS := -Wall -Wextra -Werror
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/tests
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE := memory_replay_tests
-LOCAL_COMPATIBILITY_SUITE := device-tests
-
-LOCAL_SHARED_LIBRARIES := libbase
-
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-include $(BUILD_NATIVE_TEST)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- $(memory_replay_src_files) \
- $(memory_replay_test_src_files) \
-
-LOCAL_CFLAGS := -Wall -Wextra -Werror
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/tests
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE := memory_replay_tests
-LOCAL_MODULE_HOST_OS := linux
-
-LOCAL_SHARED_LIBRARIES := libbase
-LOCAL_LDLIBS := -lrt
-
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-include $(BUILD_HOST_NATIVE_TEST)
-
-memory_replay_src_files :=
-memory_replay_test_src_files :=
diff --git a/memtrack/Android.bp b/memtrack/Android.bp
new file mode 100644
index 0000000..457140e
--- /dev/null
+++ b/memtrack/Android.bp
@@ -0,0 +1,52 @@
+// Copyright (C) 2013 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.
+
+cc_defaults {
+ name: "memtrack_defaults",
+
+ srcs: ["memtrack.cpp"],
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
+
+cc_binary {
+ name: "memtrack_share",
+ defaults: ["memtrack_defaults"],
+
+ shared_libs: ["liblog"],
+}
+
+cc_binary {
+ name: "memtrack",
+ defaults: ["memtrack_defaults"],
+
+ static_executable: true,
+ static_libs: [
+ "libc",
+ "liblog",
+ "libc++abi",
+ "libdl",
+ ],
+
+ stl: "libc++_static",
+
+ // Bug: 18389563 - Today, libc++_static and libgcc have duplicate sybols for
+ // __aeabi_uidiv(). Allowing multiple definitions lets the build proceed, but
+ // updating compiler-rt to be a superset of libgcc will allow this WAR to be
+ // removed.
+ ldflags: ["-Wl,-z,muldefs"],
+}
diff --git a/memtrack/Android.mk b/memtrack/Android.mk
deleted file mode 100644
index cd99b6c..0000000
--- a/memtrack/Android.mk
+++ /dev/null
@@ -1,58 +0,0 @@
-# Copyright (C) 2013 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.
-
-LOCAL_PATH:= $(call my-dir)
-
-src_files := \
- memtrack.cpp
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_SRC_FILES := $(src_files)
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE := memtrack_share
-LOCAL_CFLAGS := -Wall -Werror -Wno-error=unused-value
-
-LOCAL_C_INCLUDES += $(includes)
-LOCAL_SHARED_LIBRARIES := \
- liblog \
-
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_SRC_FILES := $(src_files)
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE := memtrack
-LOCAL_CFLAGS := -Wall -Werror -Wno-error=unused-value
-
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-LOCAL_STATIC_LIBRARIES := \
- libc \
- liblog \
- libc++abi \
- libdl \
-
-LOCAL_CXX_STL := libc++_static
-
-# Bug: 18389563 - Today, libc++_static and libgcc have duplicate sybols for
-# __aeabi_uidiv(). Allowing multiple definitions lets the build proceed, but
-# updating compiler-rt to be a superset of libgcc will allow this WAR to be
-# removed.
-LOCAL_LDFLAGS := -Wl,-z,muldefs
-
-include $(BUILD_EXECUTABLE)
diff --git a/memtrack/memtrack.cpp b/memtrack/memtrack.cpp
index d373609..eaeecc3 100644
--- a/memtrack/memtrack.cpp
+++ b/memtrack/memtrack.cpp
@@ -68,7 +68,7 @@
while (cur_idx_ + bytes_needed >= len_) {
bytes = read(fd_, data_ + len_, max_ - len_);
if (bytes == 0 || bytes == -1) {
- read_complete_; // unused read?
+ read_complete_ = true;
break;
}
len_ += bytes;
diff --git a/micro_bench/Android.bp b/micro_bench/Android.bp
new file mode 100644
index 0000000..f36b4ca
--- /dev/null
+++ b/micro_bench/Android.bp
@@ -0,0 +1,32 @@
+cc_defaults {
+ name: "micro_bench_defaults",
+ srcs: ["micro_bench.cpp"],
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+
+ compile_multilib: "both",
+ multilib: {
+ lib64: {
+ suffix: "64",
+ },
+ },
+}
+
+cc_binary {
+ name: "micro_bench",
+ defaults: ["micro_bench_defaults"],
+}
+
+cc_binary {
+ name: "micro_bench_static",
+ defaults: ["micro_bench_defaults"],
+
+ static_libs: [
+ "libc",
+ "libm",
+ ],
+ static_executable: true,
+}
diff --git a/micro_bench/Android.mk b/micro_bench/Android.mk
deleted file mode 100644
index 843a2e5..0000000
--- a/micro_bench/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := micro_bench.cpp
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE := micro_bench
-LOCAL_CFLAGS := -Wall -Werror -Wno-error=unused-variable
-
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := micro_bench.cpp
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE := micro_bench_static
-LOCAL_CFLAGS := -Wall -Werror -Wno-error=unused-variable
-LOCAL_STATIC_LIBRARIES = libc libm
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-include $(BUILD_EXECUTABLE)
diff --git a/micro_bench/micro_bench.cpp b/micro_bench/micro_bench.cpp
index 05cc54e..854dd78 100644
--- a/micro_bench/micro_bench.cpp
+++ b/micro_bench/micro_bench.cpp
@@ -315,7 +315,7 @@
size_t size = (cmd_data).args[0]; \
size_t incr = getAlignmentIncrement(size, (cmd_data).dst_align); \
size_t num_buffers = (cmd_data).cold_data_size / incr; \
- size_t buffer_size = num_buffers * incr; \
+ size_t buffer_size __attribute__((__unused__)) = num_buffers * incr; \
uint8_t *buffer = getColdBuffer(num_buffers, incr, (cmd_data).dst_align, (cmd_data).dst_or_mask); \
if (!buffer) \
return -1; \
@@ -400,7 +400,6 @@
int benchmarkMemsetCold(const char *name, const command_data_t &cmd_data, void_func_t func) {
memset_func_t memset_func = reinterpret_cast<memset_func_t>(func);
COLD_ONE_BUF(name, cmd_data, ;, memset_func(buf, l, size));
- (void)buffer_size;
return 0;
}
@@ -431,8 +430,8 @@
memcpy_func_t memmove_func = reinterpret_cast<memcpy_func_t>(func);
size_t size = cmd_data.args[0];
- size_t alloc_size = size * 2 + 3 * cmd_data.dst_align; // should alloc_size be used?
- uint8_t* src = allocateAlignedMemory(size, cmd_data.src_align, cmd_data.src_or_mask);
+ size_t alloc_size = size * 2 + 3 * cmd_data.dst_align;
+ uint8_t* src = allocateAlignedMemory(alloc_size, cmd_data.src_align, cmd_data.src_or_mask);
if (!src)
return -1;
// Force memmove to do a backwards copy by getting a pointer into the source buffer.
diff --git a/mmap-perf/Android.bp b/mmap-perf/Android.bp
new file mode 100644
index 0000000..4841bee
--- /dev/null
+++ b/mmap-perf/Android.bp
@@ -0,0 +1,38 @@
+//
+// Copyright (C) 2014 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.
+//
+
+cc_benchmark {
+ name: "mmapPerf",
+
+ srcs: ["mmapPerf.cpp"],
+ test_suites: ["device-tests"],
+ multilib: {
+ lib64: {
+ suffix: "64",
+ },
+ },
+ cflags: [
+ "-g",
+ "-Wall",
+ "-Werror",
+ "-Wno-missing-field-initializers",
+ "-Wno-sign-compare",
+ "-O3",
+ ],
+ static_executable: true,
+ stl: "libc++_static",
+ static_libs: ["libc"],
+}
diff --git a/mmap-perf/Android.mk b/mmap-perf/Android.mk
deleted file mode 100644
index 96de5ea..0000000
--- a/mmap-perf/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Copyright (C) 2014 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := mmapPerf.cpp
-LOCAL_MODULE := mmapPerf
-LOCAL_COMPATIBILITY_SUITE := device-tests
-LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)
-LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
-LOCAL_CFLAGS += -g -Wall -Werror -Wno-missing-field-initializers -Wno-sign-compare -O3
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-LOCAL_CXX_STL := libc++_static
-LOCAL_STATIC_LIBRARIES := libc
-include $(BUILD_NATIVE_BENCHMARK)
diff --git a/multinetwork/Android.bp b/multinetwork/Android.bp
new file mode 100644
index 0000000..e2b4be0
--- /dev/null
+++ b/multinetwork/Android.bp
@@ -0,0 +1,46 @@
+cc_defaults {
+ name: "multinetwork_defaults",
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+ include_dirs: [
+ "frameworks/native/include",
+ ],
+
+ srcs: [
+ "common.cpp",
+ ],
+
+ shared_libs: [
+ "libandroid",
+ "libbase",
+ ],
+
+ product_variables: {
+ // The PDK build does not have access to frameworks/native elements.
+ pdk: {
+ enabled: false,
+ },
+ },
+}
+
+// Sample util binaries.
+cc_binary {
+ name: "dnschk",
+ defaults: ["multinetwork_defaults"],
+
+ srcs: [
+ "dnschk.cpp",
+ ],
+}
+
+cc_binary {
+ name: "httpurl",
+ defaults: ["multinetwork_defaults"],
+
+ srcs: [
+ "httpurl.cpp",
+ ],
+}
diff --git a/multinetwork/Android.mk b/multinetwork/Android.mk
deleted file mode 100644
index db04687..0000000
--- a/multinetwork/Android.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-# The PDK build does not have access to frameworks/native elements.
-ifneq ($(TARGET_BUILD_PDK), true)
-
-# Sample util binaries.
-include $(CLEAR_VARS)
-LOCAL_MODULE := dnschk
-LOCAL_CFLAGS := -Wall -Werror
-
-LOCAL_C_INCLUDES += frameworks/native/include external/libcxx/include
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := debug
-LOCAL_SHARED_LIBRARIES := libandroid libbase libc++
-LOCAL_SRC_FILES := dnschk.cpp common.cpp
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := httpurl
-LOCAL_CFLAGS := -Wall -Werror
-
-LOCAL_C_INCLUDES += frameworks/native/include external/libcxx/include
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := debug
-LOCAL_SHARED_LIBRARIES := libandroid libbase libc++
-LOCAL_SRC_FILES := httpurl.cpp common.cpp
-include $(BUILD_EXECUTABLE)
-
-endif # ifneq ($(TARGET_BUILD_PDK), true)
diff --git a/multinetwork/quick_test.sh b/multinetwork/quick_test.sh
index f586bae..acc5239 100755
--- a/multinetwork/quick_test.sh
+++ b/multinetwork/quick_test.sh
@@ -35,7 +35,7 @@
echo ""
readonly IPADDRESSES=$(
- adb shell /system/xbin/dnschk --nethandle $nethandle $TEST_HOST |
+ adb shell /system/bin/dnschk --nethandle $nethandle $TEST_HOST |
sed -e 's/#.*//' -e '/^$/d')
@@ -43,6 +43,6 @@
urls=$(getUrls $host)
for url in $urls; do
echo "$PREFIX Checking $url" >&2
- adb shell /system/xbin/httpurl --nethandle $nethandle "$url"
+ adb shell /system/bin/httpurl --nethandle $nethandle "$url"
done
done
diff --git a/pagecache/Android.bp b/pagecache/Android.bp
new file mode 100644
index 0000000..40fc444
--- /dev/null
+++ b/pagecache/Android.bp
@@ -0,0 +1,12 @@
+// Copyright 2015 The Android Open Source Project
+
+cc_binary {
+ name: "dumpcache",
+
+ srcs: ["dumpcache.c"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+ shared_libs: ["libcutils"],
+}
diff --git a/pagecache/Android.mk b/pagecache/Android.mk
deleted file mode 100644
index 7861273..0000000
--- a/pagecache/Android.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2015 The Android Open Source Project
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= dumpcache.c
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_SHARED_LIBRARIES := libcutils
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE:= dumpcache
-
-include $(BUILD_EXECUTABLE)
-
diff --git a/perfprofd/Android.bp b/perfprofd/Android.bp
index fb3b09a..7db4d49 100644
--- a/perfprofd/Android.bp
+++ b/perfprofd/Android.bp
@@ -72,6 +72,13 @@
}
}
+filegroup {
+ name: "perfprofd_record_proto",
+ srcs: [
+ "perfprofd_record.proto",
+ ],
+}
+
// Static library for the record proto and its I/O.
cc_library_static {
@@ -89,7 +96,7 @@
],
srcs: [
"perfprofd_io.cc",
- "perfprofd_record.proto",
+ ":perfprofd_record_proto",
],
proto: {
@@ -115,6 +122,7 @@
static_libs: [
"libbase",
+ "libprotobuf-cpp-lite",
"libsimpleperf_elf_read",
],
whole_static_libs: [
diff --git a/perfprofd/binder_interface/Android.bp b/perfprofd/binder_interface/Android.bp
index c40036b..25e6bf7 100644
--- a/perfprofd/binder_interface/Android.bp
+++ b/perfprofd/binder_interface/Android.bp
@@ -33,8 +33,12 @@
srcs: [
"perfprofd_binder.cc",
":perfprofd_aidl",
- "perfprofd_config.proto",
+ ":perfprofd_config_proto",
],
+
+ proto: {
+ type: "lite",
+ },
}
filegroup {
@@ -43,3 +47,10 @@
"aidl/android/os/IPerfProfd.aidl",
],
}
+
+filegroup {
+ name: "perfprofd_config_proto",
+ srcs: [
+ "perfprofd_config.proto",
+ ],
+}
diff --git a/perfprofd/binder_interface/aidl/android/os/IPerfProfd.aidl b/perfprofd/binder_interface/aidl/android/os/IPerfProfd.aidl
index 5fdc09a..e2628c7 100644
--- a/perfprofd/binder_interface/aidl/android/os/IPerfProfd.aidl
+++ b/perfprofd/binder_interface/aidl/android/os/IPerfProfd.aidl
@@ -27,6 +27,13 @@
boolean useElfSymbolizer, boolean sendToDropbox);
/**
+ * Start continuous profiling with the given encoded parameters.
+ * Parameters should be encoded in the ConfigReader syntax,
+ * separated by colons.
+ */
+ void startProfilingString(String config);
+
+ /**
* Start profiling with the parameters in the given protobuf.
*/
void startProfilingProtobuf(in byte[] config_proto);
diff --git a/perfprofd/binder_interface/perfprofd_binder.cc b/perfprofd/binder_interface/perfprofd_binder.cc
index cbb3fce..0976b7b 100644
--- a/perfprofd/binder_interface/perfprofd_binder.cc
+++ b/perfprofd/binder_interface/perfprofd_binder.cc
@@ -30,6 +30,7 @@
#include <android-base/logging.h>
#include <android-base/stringprintf.h>
+#include <android-base/strings.h>
#include <binder/BinderService.h>
#include <binder/IResultReceiver.h>
#include <binder/Status.h>
@@ -75,6 +76,7 @@
bool stackProfile,
bool useElfSymbolizer,
bool sendToDropbox) override;
+ Status startProfilingString(const String16& config) override;
Status startProfilingProtobuf(const std::vector<uint8_t>& config_proto) override;
Status stopProfiling() override;
@@ -151,6 +153,26 @@
}
return Status::ok();
}
+Status PerfProfdNativeService::startProfilingString(const String16& config) {
+ ConfigReader reader;
+ std::string error_msg;
+ // Split configuration along colon.
+ std::vector<std::string> args = base::Split(String8(config).string(), ":");
+ for (auto& arg : args) {
+ if (!reader.Read(arg, /* fail_on_error */ true)) {
+ error_msg = base::StringPrintf("Could not parse %s", arg.c_str());
+ return Status::fromExceptionCode(1, error_msg.c_str());
+ }
+ }
+ auto config_fn = [&](ThreadedConfig& config) {
+ config = ThreadedConfig(); // Reset to a default config.
+ reader.FillConfig(&config);
+ };
+ if (!StartProfiling(config_fn, &error_msg)) {
+ return Status::fromExceptionCode(1, error_msg.c_str());
+ }
+ return Status::ok();
+}
Status PerfProfdNativeService::startProfilingProtobuf(const std::vector<uint8_t>& config_proto) {
auto proto_loader_fn = [&config_proto](ProfilingConfig& proto_config) {
return proto_config.ParseFromArray(config_proto.data(), config_proto.size());
@@ -179,6 +201,7 @@
CHECK_AND_COPY_FROM_PROTO(config_directory)
CHECK_AND_COPY_FROM_PROTO(perf_path)
CHECK_AND_COPY_FROM_PROTO(sampling_period)
+ CHECK_AND_COPY_FROM_PROTO(sampling_frequency)
CHECK_AND_COPY_FROM_PROTO(sample_duration_in_s)
CHECK_AND_COPY_FROM_PROTO(only_debug_build)
CHECK_AND_COPY_FROM_PROTO(hardwire_cpus)
@@ -337,7 +360,8 @@
}
default:
- return BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
+ return ::android::os::BnPerfProfd::onTransact(
+ _aidl_code, _aidl_data, _aidl_reply, _aidl_flags);
}
}
diff --git a/perfprofd/binder_interface/perfprofd_config.proto b/perfprofd/binder_interface/perfprofd_config.proto
index 37c369c..cfd85ed 100644
--- a/perfprofd/binder_interface/perfprofd_config.proto
+++ b/perfprofd/binder_interface/perfprofd_config.proto
@@ -3,8 +3,6 @@
option java_package = "android.perfprofd";
-option optimize_for = LITE_RUNTIME;
-
package android.perfprofd;
// The configuration for a profiling session.
@@ -23,8 +21,7 @@
// loop. Value of zero indicates that we should loop forever.
optional uint32 main_loop_iterations = 3;
- // Destination directory (where to write profiles). This location
- // chosen since it is accessible to the uploader service.
+ // Destination directory (where to write profiles).
optional string destination_directory = 4;
// Config directory (where to read configs).
optional string config_directory = 5;
diff --git a/perfprofd/config.h b/perfprofd/config.h
index 0ee2309..0124770 100644
--- a/perfprofd/config.h
+++ b/perfprofd/config.h
@@ -42,8 +42,7 @@
// the whole system will be profiled.
int32_t process = -1;
- // Destination directory (where to write profiles). This location
- // chosen since it is accessible to the uploader service.
+ // Destination directory (where to write profiles).
std::string destination_directory = "/data/misc/perfprofd";
// Config directory (where to read configs).
std::string config_directory = "/data/data/com.google.android.gms/files";
diff --git a/perfprofd/configreader.cc b/perfprofd/configreader.cc
index f2b6078..842adcb 100644
--- a/perfprofd/configreader.cc
+++ b/perfprofd/configreader.cc
@@ -70,7 +70,7 @@
// set to 100, then over time we want to see a perf profile
// collected every 100 seconds). The actual time within the interval
// for the collection is chosen randomly.
- addUnsignedEntry("collection_interval", config.collection_interval_in_s, 1, UINT32_MAX);
+ addUnsignedEntry("collection_interval", config.collection_interval_in_s, 0, UINT32_MAX);
// Use the specified fixed seed for random number generation (unit
// testing)
@@ -80,8 +80,7 @@
// loop. Value of zero indicates that we should loop forever.
addUnsignedEntry("main_loop_iterations", config.main_loop_iterations, 0, UINT32_MAX);
- // Destination directory (where to write profiles). This location
- // chosen since it is accessible to the uploader service.
+ // Destination directory (where to write profiles).
addStringEntry("destination_directory", config.destination_directory.c_str());
// Config directory (where to read configs).
@@ -337,6 +336,7 @@
config->perf_path = getStringValue("perf_path");
config->sampling_period = getUnsignedValue("sampling_period");
+ config->sampling_frequency = getUnsignedValue("sampling_frequency");
config->sample_duration_in_s = getUnsignedValue("sample_duration");
diff --git a/perfprofd/perfprofd_cmdline.cc b/perfprofd/perfprofd_cmdline.cc
index fb9c2c1..0bc6bdc 100644
--- a/perfprofd/perfprofd_cmdline.cc
+++ b/perfprofd/perfprofd_cmdline.cc
@@ -215,8 +215,7 @@
return config;
};
auto reread_config = [&config_reader, config]() {
- // Reread config file -- the uploader may have rewritten it as a result
- // of a gservices change
+ // Reread config file -- the uploader may have rewritten it.
config_reader.readFile();
config_reader.FillConfig(config);
};
diff --git a/perfprofd/perfprofdcore.cc b/perfprofd/perfprofdcore.cc
index d7b0e9b..73332a3 100644
--- a/perfprofd/perfprofdcore.cc
+++ b/perfprofd/perfprofdcore.cc
@@ -36,6 +36,7 @@
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/macros.h>
+#include <android-base/scopeguard.h>
#include <android-base/stringprintf.h>
#ifdef __BIONIC__
@@ -456,7 +457,6 @@
//
static PROFILE_RESULT invoke_perf(Config& config,
const std::string &perf_path,
- unsigned sampling_period,
const char *stack_profile_opt,
unsigned duration,
const std::string &data_file_path,
@@ -481,7 +481,7 @@
}
// marshall arguments
- constexpr unsigned max_args = 15;
+ constexpr unsigned max_args = 17;
const char *argv[max_args];
unsigned slot = 0;
argv[slot++] = perf_path.c_str();
@@ -495,17 +495,20 @@
std::string p_str;
if (config.sampling_frequency > 0) {
argv[slot++] = "-f";
- p_str = android::base::StringPrintf("%u", sampling_period);
+ p_str = android::base::StringPrintf("%u", config.sampling_frequency);
argv[slot++] = p_str.c_str();
} else if (config.sampling_period > 0) {
argv[slot++] = "-c";
- p_str = android::base::StringPrintf("%u", sampling_period);
+ p_str = android::base::StringPrintf("%u", config.sampling_period);
argv[slot++] = p_str.c_str();
}
// -g if desired
- if (stack_profile_opt)
+ if (stack_profile_opt) {
argv[slot++] = stack_profile_opt;
+ argv[slot++] = "-m";
+ argv[slot++] = "8192";
+ }
std::string pid_str;
if (config.process < 0) {
@@ -651,17 +654,18 @@
bool take_action = (hardwire && duration <= max_duration);
HardwireCpuHelper helper(take_action);
+ auto scope_guard = android::base::make_scope_guard(
+ [&data_file_path]() { unlink(data_file_path.c_str()); });
+
//
// Invoke perf
//
const char *stack_profile_opt =
(config.stack_profile ? "-g" : nullptr);
const std::string& perf_path = config.perf_path;
- uint32_t period = config.sampling_period;
PROFILE_RESULT ret = invoke_perf(config,
perf_path.c_str(),
- period,
stack_profile_opt,
duration,
data_file_path,
diff --git a/perfprofd/tests/perfprofd_test.cc b/perfprofd/tests/perfprofd_test.cc
index 6c5c278..a96fd71 100644
--- a/perfprofd/tests/perfprofd_test.cc
+++ b/perfprofd/tests/perfprofd_test.cc
@@ -613,7 +613,6 @@
runner.addToConfig("destination_directory=/does/not/exist");
// assorted bad syntax
- runner.addToConfig("collection_interval=0");
runner.addToConfig("collection_interval=-1");
runner.addToConfig("nonexistent_key=something");
runner.addToConfig("no_equals_stmt");
@@ -626,10 +625,9 @@
// Verify log contents
const std::string expected = RAW_RESULT(
- W: line 6: specified value 0 for 'collection_interval' outside permitted range [1 4294967295] (ignored)
- W: line 7: malformed unsigned value (ignored)
- W: line 8: unknown option 'nonexistent_key' ignored
- W: line 9: line malformed (no '=' found)
+ W: line 6: malformed unsigned value (ignored)
+ W: line 7: unknown option 'nonexistent_key' ignored
+ W: line 8: line malformed (no '=' found)
);
// check to make sure log excerpt matches
diff --git a/preopt2cachename/Android.bp b/preopt2cachename/Android.bp
new file mode 100644
index 0000000..63fea15
--- /dev/null
+++ b/preopt2cachename/Android.bp
@@ -0,0 +1,31 @@
+// Copyright 2016 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.
+
+cc_binary {
+ name: "preopt2cachename",
+
+ srcs: ["preopt2cachename.cpp"],
+
+ shared_libs: [
+ "libsysutils",
+ "liblog",
+ "libcutils",
+ "libbase",
+ ],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+}
diff --git a/preopt2cachename/Android.mk b/preopt2cachename/Android.mk
deleted file mode 100644
index b5a51d9..0000000
--- a/preopt2cachename/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2016 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.
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE:= preopt2cachename
-
-LOCAL_SRC_FILES := \
- preopt2cachename.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libsysutils \
- liblog \
- libcutils \
- libbase
-
-LOCAL_CFLAGS := -Werror -Wall
-
-include $(BUILD_EXECUTABLE)
diff --git a/puncture_fs/Android.bp b/puncture_fs/Android.bp
new file mode 100644
index 0000000..194f78f
--- /dev/null
+++ b/puncture_fs/Android.bp
@@ -0,0 +1,29 @@
+// Copyright (C) 2014 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.
+
+cc_binary {
+ name: "puncture_fs",
+
+ srcs: ["puncture_fs.c"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+
+ shared_libs: [
+ "libc",
+ "liblog",
+ "liblogwrap",
+ ],
+}
diff --git a/puncture_fs/Android.mk b/puncture_fs/Android.mk
deleted file mode 100644
index 2c72ed8..0000000
--- a/puncture_fs/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2014 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := puncture_fs.c
-LOCAL_CFLAGS := -Wall -Werror
-
-LOCAL_C_INCLUDES += system/core/logwrapper/include
-
-LOCAL_SHARED_LIBRARIES := libc liblog liblogwrap
-
-LOCAL_MODULE := puncture_fs
-
-LOCAL_MODULE_TAGS := debug
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-
-include $(BUILD_EXECUTABLE)
diff --git a/runconuid/Android.bp b/runconuid/Android.bp
new file mode 100644
index 0000000..59fb9ca
--- /dev/null
+++ b/runconuid/Android.bp
@@ -0,0 +1,12 @@
+cc_binary {
+ name: "runconuid",
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+
+ srcs: ["runconuid.cpp"],
+
+ shared_libs: ["libselinux"],
+}
diff --git a/runconuid/Android.mk b/runconuid/Android.mk
deleted file mode 100644
index 79cd192..0000000
--- a/runconuid/Android.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_CFLAGS := -Wall -Werror
-
-LOCAL_SRC_FILES:= runconuid.cpp
-
-LOCAL_MODULE:= runconuid
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := debug
-
-LOCAL_SHARED_LIBRARIES := libselinux
-
-include $(BUILD_EXECUTABLE)
diff --git a/sane_schedstat/Android.bp b/sane_schedstat/Android.bp
new file mode 100644
index 0000000..68adc74
--- /dev/null
+++ b/sane_schedstat/Android.bp
@@ -0,0 +1,11 @@
+cc_binary {
+ name: "sane_schedstat",
+
+ srcs: ["sane_schedstat.c"],
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-unused-parameter",
+ ],
+}
diff --git a/sane_schedstat/Android.mk b/sane_schedstat/Android.mk
deleted file mode 100644
index 5351ea6..0000000
--- a/sane_schedstat/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := sane_schedstat.c
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE := sane_schedstat
-LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
-
-include $(BUILD_EXECUTABLE)
diff --git a/showmap/Android.bp b/showmap/Android.bp
new file mode 100644
index 0000000..d059a1e
--- /dev/null
+++ b/showmap/Android.bp
@@ -0,0 +1,34 @@
+//
+// Copyright (C) 2018 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.
+//
+
+cc_defaults {
+ name: "showmap-defaults",
+ host_supported: true,
+ srcs: [
+ "showmap.cpp",
+ ],
+ target: {
+ android: {
+ shared_libs: ["libcutils"],
+ },
+ },
+}
+
+cc_binary {
+ name: "showmap",
+ defaults: ["showmap-defaults"],
+}
+
diff --git a/showmap/Android.mk b/showmap/Android.mk
deleted file mode 100644
index c9279ba..0000000
--- a/showmap/Android.mk
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2006 The Android Open Source Project
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= showmap.cpp
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE:= showmap
-
-include $(BUILD_EXECUTABLE)
-
diff --git a/showmap/showmap.cpp b/showmap/showmap.cpp
index 6f16b49..799cc85 100644
--- a/showmap/showmap.cpp
+++ b/showmap/showmap.cpp
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2005 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.
+ */
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
@@ -6,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/signal.h>
#include <unistd.h>
struct mapinfo {
@@ -58,18 +74,19 @@
}
if (line[name_pos]) {
- strlcpy(name, line + name_pos, sizeof(name));
+ strncpy(name, line + name_pos, sizeof(name));
} else {
if (prev && start == prev->end && is_library(prev->name)) {
// anonymous mappings immediately adjacent to shared libraries
// usually correspond to the library BSS segment, so we use the
// library's own name
- strlcpy(name, prev->name, sizeof(name));
+ strncpy(name, prev->name, sizeof(name));
is_bss = 1;
} else {
- strlcpy(name, "[anon]", sizeof(name));
+ strncpy(name, "[anon]", sizeof(name));
}
}
+ name[sizeof(name) - 1] = '\0'; // Assure we're null-terminated.
const int name_size = strlen(name) + 1;
struct mapinfo* info = reinterpret_cast<mapinfo*>(calloc(1, sizeof(mapinfo) + name_size));
@@ -82,7 +99,7 @@
info->end = end;
info->is_bss = is_bss;
info->count = 1;
- strlcpy(info->name, name, name_size);
+ memcpy(info->name, name, name_size);
*mi = info;
return 0;
@@ -170,19 +187,18 @@
}
}
-static mapinfo *load_maps(int pid, int sort_by_address, int coalesce_by_name)
-{
- char fn[128];
+static mapinfo *load_maps_from_file(const char* filename,
+ int sort_by_address,
+ int coalesce_by_name) {
FILE *fp;
char line[1024];
mapinfo *head = NULL;
mapinfo *current = NULL;
int len;
- snprintf(fn, sizeof(fn), "/proc/%d/smaps", pid);
- fp = fopen(fn, "r");
+ fp = fopen(filename, "r");
if (fp == 0) {
- if (!quiet) fprintf(stderr, "cannot open /proc/%d/smaps: %s\n", pid, strerror(errno));
+ if (!quiet) fprintf(stderr, "cannot open %s: %s\n", filename, strerror(errno));
return NULL;
}
@@ -211,7 +227,7 @@
fclose(fp);
if (!head) {
- if (!quiet) fprintf(stderr, "could not read /proc/%d/smaps\n", pid);
+ if (!quiet) fprintf(stderr, "could not read %s\n", filename);
return NULL;
}
@@ -262,12 +278,12 @@
}
}
-static int show_map(int pid)
+static int show_map(char* filename)
{
mapinfo total;
memset(&total, 0, sizeof(total));
- mapinfo *milist = load_maps(pid, addresses, !verbose && !addresses);
+ mapinfo *milist = load_maps_from_file(filename, addresses, !verbose && !addresses);
if (milist == NULL) {
return quiet ? 0 : 1;
}
@@ -311,56 +327,63 @@
return 0;
}
-int main(int argc, char *argv[])
-{
+int main(int argc, char *argv[]) {
int usage = 1;
int result = 0;
- int pid;
- char *arg;
- char *argend;
+ char *filename = NULL;
+ char temp_filename[128] = {};
+ bool file_mode = false;
signal(SIGPIPE, SIG_IGN);
- for (argc--, argv++; argc > 0; argc--, argv++) {
- arg = argv[0];
+ for (int i = 1; i < argc; ++i) {
+ char* arg = argv[i];
if (!strcmp(arg,"-v")) {
verbose = true;
- continue;
- }
- if (!strcmp(arg,"-t")) {
+ } else if (!strcmp(arg,"-t")) {
terse = true;
- continue;
- }
- if (!strcmp(arg,"-a")) {
+ } else if (!strcmp(arg,"-a")) {
addresses = true;
- continue;
- }
- if (!strcmp(arg,"-q")) {
+ } else if (!strcmp(arg,"-q")) {
quiet = true;
- continue;
- }
- if (argc != 1) {
- fprintf(stderr, "too many arguments\n");
- break;
- }
- pid = strtol(arg, &argend, 10);
- if (*arg && !*argend) {
- usage = 0;
- if (show_map(pid)) {
- result = 1;
+ } else if (!strcmp(arg,"-f")) {
+ file_mode = true;
+ } else {
+ if (i + 1 != argc) {
+ fprintf(stderr, "too many arguments\n");
+ break;
}
+ if (file_mode) {
+ filename = arg;
+ usage = 0;
+ } else {
+ char *argend;
+ int pid = strtol(arg, &argend, 10);
+ if (*arg && !*argend) {
+ usage = 0;
+ snprintf(temp_filename, sizeof(temp_filename), "/proc/%d/smaps", pid);
+ filename = temp_filename;
+ }
+ }
+
+ if (filename != nullptr) {
+ if (show_map(filename)) {
+ result = 1;
+ }
+ break;
+ }
+ fprintf(stderr, "unrecognized argument: %s\n", arg);
break;
}
- fprintf(stderr, "unrecognized argument: %s\n", arg);
- break;
}
if (usage) {
fprintf(stderr,
- "showmap [-t] [-v] [-c] [-q] <pid>\n"
+ "showmap [-t] [-v] [-c] [-q] [-f] <pid|file>\n"
" -t = terse (show only items with private pages)\n"
" -v = verbose (don't coalesce maps with the same name)\n"
" -a = addresses (show virtual memory map)\n"
" -q = quiet (don't show error if map could not be read)\n"
+ " -f = read from input file instead of pid\n"
);
result = 1;
}
diff --git a/showslab/Android.bp b/showslab/Android.bp
new file mode 100644
index 0000000..d84004e
--- /dev/null
+++ b/showslab/Android.bp
@@ -0,0 +1,11 @@
+// Copyright 2007 The Android Open Source Project
+
+cc_binary {
+ name: "showslab",
+
+ srcs: ["showslab.c"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
diff --git a/showslab/Android.mk b/showslab/Android.mk
deleted file mode 100644
index f48c52c..0000000
--- a/showslab/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2007 The Android Open Source Project
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= showslab.c
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_SHARED_LIBRARIES :=
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-
-LOCAL_MODULE_TAGS := debug
-
-LOCAL_MODULE:= showslab
-
-include $(BUILD_EXECUTABLE)
-
diff --git a/simpleperf/OfflineUnwinder.cpp b/simpleperf/OfflineUnwinder.cpp
index 8d36677..a288cf7 100644
--- a/simpleperf/OfflineUnwinder.cpp
+++ b/simpleperf/OfflineUnwinder.cpp
@@ -146,16 +146,15 @@
bt_map.offset = map->pgoff;
bt_map.name = map->dso->GetDebugFilePath();
if (bt_map.offset == 0) {
- size_t apk_pos = bt_map.name.find_last_of('!');
- if (apk_pos != std::string::npos) {
+ auto tuple = SplitUrlInApk(bt_map.name);
+ if (std::get<0>(tuple)) {
// The unwinder does not understand the ! format, so change back to
// the previous format (apk, offset).
- std::string shared_lib(bt_map.name.substr(apk_pos + 2));
- bt_map.name = bt_map.name.substr(0, apk_pos);
- uint64_t offset;
- uint32_t length;
- if (ApkInspector::FindOffsetInApkByName(bt_map.name, shared_lib, &offset, &length)) {
- bt_map.offset = offset;
+ EmbeddedElf* elf = ApkInspector::FindElfInApkByName(std::get<1>(tuple),
+ std::get<2>(tuple));
+ if (elf != nullptr) {
+ bt_map.name = elf->filepath();
+ bt_map.offset = elf->entry_offset();
}
}
}
diff --git a/simpleperf/cmd_record_test.cpp b/simpleperf/cmd_record_test.cpp
index cab1a38..f58fa35 100644
--- a/simpleperf/cmd_record_test.cpp
+++ b/simpleperf/cmd_record_test.cpp
@@ -269,7 +269,10 @@
ASSERT_TRUE(RunRecordCmd({"-t", tid_list}));
}
-TEST(record_cmd, no_monitored_threads) { ASSERT_FALSE(RecordCmd()->Run({""})); }
+TEST(record_cmd, no_monitored_threads) {
+ TemporaryFile tmpfile;
+ ASSERT_FALSE(RecordCmd()->Run({"-o", tmpfile.path}));
+}
TEST(record_cmd, more_than_one_event_types) {
ASSERT_TRUE(RunRecordCmd({"-e", "cpu-cycles,cpu-clock"}));
@@ -428,12 +431,21 @@
TEST(record_cmd, handle_SIGHUP) {
TemporaryFile tmpfile;
- std::thread thread([]() {
- sleep(1);
+ int pipefd[2];
+ ASSERT_EQ(0, pipe(pipefd));
+ int read_fd = pipefd[0];
+ int write_fd = pipefd[1];
+ char data[8] = {};
+ std::thread thread([&]() {
+ android::base::ReadFully(read_fd, data, 7);
kill(getpid(), SIGHUP);
});
- thread.detach();
- ASSERT_TRUE(RecordCmd()->Run({"-o", tmpfile.path, "sleep", "1000000"}));
+ ASSERT_TRUE(RecordCmd()->Run({"-o", tmpfile.path, "--start_profiling_fd",
+ std::to_string(write_fd), "sleep", "1000000"}));
+ thread.join();
+ close(write_fd);
+ close(read_fd);
+ ASSERT_STREQ(data, "STARTED");
}
TEST(record_cmd, stop_when_no_more_targets) {
diff --git a/simpleperf/cmd_stat_test.cpp b/simpleperf/cmd_stat_test.cpp
index 2d0175c..96b3a9d 100644
--- a/simpleperf/cmd_stat_test.cpp
+++ b/simpleperf/cmd_stat_test.cpp
@@ -169,6 +169,11 @@
}
TEST(stat_cmd, handle_SIGHUP) {
+ if (!GetDefaultAppPackageName().empty()) {
+ // See http://b/79495636.
+ GTEST_LOG_(INFO) << "Omit this test in app's context.";
+ return;
+ }
std::thread thread([]() {
sleep(1);
kill(getpid(), SIGHUP);
diff --git a/simpleperf/doc/README.md b/simpleperf/doc/README.md
index bb54f11..1edfed0 100644
--- a/simpleperf/doc/README.md
+++ b/simpleperf/doc/README.md
@@ -24,7 +24,7 @@
- [Profile from launch](#profile-from-launch)
- [Parse profiling data manually](#parse-profiling-data-manually)
- [Executable commands reference](#executable-commands-reference)
- - [How does simpleperf work?](#how-does-simpleperf-work)
+ - [How simpleperf works](#how-simpleperf-works)
- [Commands](#commands)
- [The list command](#the-list-command)
- [The stat command](#the-stat-command)
@@ -48,8 +48,9 @@
- [Group samples into sample entries](#group-samples-into-sample-entries)
- [Report call graphs](#report-call-graphs-in-report-cmd)
- [Scripts reference](#scripts-reference)
- - [app_profiler py](#app_profiler-py)
+ - [app_profiler.py](#app_profiler-py)
- [Profile from launch of an application](#profile-from-launch-of-an-application)
+ - [run_simpleperf_without_usb_connection.py](#run_simpleperf_without_usb_connection-py)
- [binary_cache_builder.py](#binary_cache_builder-py)
- [run_simpleperf_on_device.py](#run_simpleperf_on_device-py)
- [report.py](#report-py)
@@ -78,6 +79,7 @@
a. When recording dwarf based call graph, simpleperf unwinds the stack before writing a sample
to file. This is to save storage space on the device.
b. Support tracing both on CPU time and off CPU time with --trace-offcpu option.
+ c. Support recording callgraphs of JITed and interpreted Java code on Android >= P.
3. It relates closely to the Android platform.
a. Is aware of Android environment, like using system properties to enable profiling, using
@@ -100,7 +102,7 @@
Python scripts are split into three parts according to their functions:
-1. Scripts used for simplifying recording, like app_profiler.py.
+1. Scripts used for recording, like app_profiler.py, run_simpleperf_without_usb_connection.py.
2. Scripts used for reporting, like report.py, report_html.py, inferno.
@@ -123,6 +125,9 @@
[app_profiler.py](#app_profiler-py): recording profiling data.
+[run_simpleperf_without_usb_connection.py](#run_simpleperf_without_usb_connection-py):
+ recording profiling data while the USB cable isn't connected.
+
[binary_cache_builder.py](#binary_cache_builder-py): building binary cache for profiling data.
[report.py](#report-py): reporting in stdio interface.
@@ -146,46 +151,94 @@
This section shows how to profile an Android application.
Some examples are [Here](https://android.googlesource.com/platform/system/extras/+/master/simpleperf/demo/README.md).
-Simpleperf only supports profiling native instructions in binaries in ELF format. If the Java code
-is executed by interpreter, or with jit cache, it can’t be profiled by simpleperf. As Android
-supports Ahead-of-time compilation, it can compile Java bytecode into native instructions with
-debug information. On devices with Android version <= M, we need root privilege to compile Java
-bytecode with debug information. However, on devices with Android version >= N, we don't need
-root privilege to do so.
-
Profiling an Android application involves three steps:
-1. Prepare the application.
+1. Prepare an Android application.
2. Record profiling data.
3. Report profiling data.
### Prepare an Android application
-Before profiling, we need to install the application on Android device. To get valid profiling
-results, please check following items:
+Based on the profiling situation, we may need to customize the build script to generate an apk file
+specifically for profiling. Below are some suggestions.
-1. The application should be debuggable.
-Security restrictions mean that only apps with android::debuggable set to true can be profiled.
-(On a rooted device, all apps can be profiled.) In Android Studio, that means you need to use
-the debug build type instead of the release build type.
+1. If you want to profile a debug build of an application:
-2. Run on an Android >= N device.
-[We suggest profiling on an Android >= N device](#why-we-suggest-profiling-on-android-n-devices).
+For the debug build type, Android studio sets android::debuggable="true" in AndroidManifest.xml,
+enables JNI checks and may not optimize C/C++ code. It can be profiled by simpleperf without any
+change.
-3. On Android O, add `wrap.sh` in the apk.
-To profile Java code, we need ART running in oat mode. But on Android O, debuggable applications
-are forced to run in jit mode. To work around this, we need to add a `wrap.sh` in the apk. So if
-you are running on Android O device and need to profile Java code, add `wrap.sh` as [here](https://android.googlesource.com/platform/system/extras/+/master/simpleperf/demo/SimpleperfExampleWithNative/app/profiling.gradle).
+2. If you want to profile a release build of an application:
-4. Make sure C++ code is compiled with optimizing flags.
-If the application contains C++ code, it can be compiled with -O0 flag in debug build type.
-This makes C++ code slow, to avoid that, check [here](https://android.googlesource.com/platform/system/extras/+/master/simpleperf/demo/SimpleperfExampleWithNative/app/profiling.gradle).
+For the release build type, Android studio sets android::debuggable="false" in AndroidManifest.xml,
+disables JNI checks and optimizes C/C++ code. However, security restrictions mean that only apps
+with android::debuggable set to true can be profiled. So simpleperf can only profile a release
+build under these two circumstances:
+If you are on a rooted device, you can profile any app.
-5. Use native libraries with debug info in the apk when possible.
-If the application contains C++ code or pre-compiled native libraries, try to use unstripped
-libraries in the apk. This helps simpleperf generating better profiling results.
-To use unstripped libraries, check [here](https://android.googlesource.com/platform/system/extras/+/master/simpleperf/demo/SimpleperfExampleWithNative/app/profiling.gradle).
+If you are on Android >= O, we can use [wrap.sh](#https://developer.android.com/ndk/guides/wrap-script.html)
+to profile a release build:
+Step 1: Add android::debuggable="true" in AndroidManifest.xml to enable profiling.
+```
+<manifest ...>
+ <application android::debuggable="true" ...>
+```
-Here we use application [SimpleperfExampleWithNative](https://android.googlesource.com/platform/system/extras/+/master/simpleperf/demo/SimpleperfExampleWithNative).
+Step 2: Add wrap.sh in lib/`arch` directories. wrap.sh runs the app without passing any debug flags
+to ART, so the app runs as a release app. wrap.sh can be done by adding the script below in
+app/build.gradle.
+```
+android {
+ buildTypes {
+ release {
+ sourceSets {
+ release {
+ resources {
+ srcDir {
+ "wrap_sh_lib_dir"
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+task createWrapShLibDir
+ for (String abi : ["armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"]) {
+ def dir = new File("app/wrap_sh_lib_dir/lib/" + abi)
+ dir.mkdirs()
+ def wrapFile = new File(dir, "wrap.sh")
+ wrapFile.withWriter { writer ->
+ writer.write('#!/system/bin/sh\n\$@\n')
+ }
+ }
+}
+```
+
+3. If you want to profile C/C++ code:
+
+Android studio strips symbol table and debug info of native libraries in the apk. So the profiling
+results may contain unknown symbols or broken callgraphs. To fix this, we can pass app_profiler.py
+a directory containing unstripped native libraries via the -lib option. Usually the directory can
+be the path of your Android Studio project.
+
+
+4. If you want to profile Java code:
+
+On Android >= P, simpleperf supports profiling Java code, no matter whether it is executed by
+the interpreter, or JITed, or compiled into native instructions. So you don't need to do anything.
+
+On Android O, simpleperf supports profiling Java code which is compiled into native instructions,
+and it also needs wrap.sh to use the compiled Java code. To compile Java code, we can pass
+app_profiler.py the --compile_java_code option.
+
+On Android N, simpleperf supports profiling Java code that is compiled into native instructions.
+To compile java code, we can pass app_profiler.py the --compile_java_code option.
+
+On Android <= M, simpleperf doesn't support profiling Java code.
+
+
+Below I use application [SimpleperfExampleWithNative](https://android.googlesource.com/platform/system/extras/+/master/simpleperf/demo/SimpleperfExampleWithNative).
It builds an app-profiling.apk for profiling.
```sh
@@ -205,28 +258,34 @@
We can use [app-profiler.py](#app_profiler-py) to profile Android applications.
```sh
-# Record perf.data.
-$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative
+# Cd to the directory of simpleperf scripts. Record perf.data.
+# -p option selects the profiled app using its package name.
+# --compile_java_code option compiles Java code into native instructions, which isn't needed on
+# Android >= P.
+# -a option selects the Activity to profile.
+# -lib option gives the directory to find debug native libraries.
+$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative --compile_java_code \
+ -a .MixActivity -lib path_of_SimpleperfExampleWithNative
```
This will collect profiling data in perf.data in the current directory, and related native
binaries in binary_cache/.
Normally we need to use the app when profiling, otherwise we may record no samples. But in this
-case, the MainActivity starts a busy thread. So we don't need to use the app while profiling.
+case, the MixActivity starts a busy thread. So we don't need to use the app while profiling.
```sh
# Report perf.data in stdio interface.
$ python report.py
-Cmdline: /data/local/tmp/simpleperf record -e task-clock:u -g -f 1000 --duration 10 ...
+Cmdline: /data/data/com.example.simpleperf.simpleperfexamplewithnative/simpleperf record ...
Arch: arm64
-Event: cpu-cycles:u (type 0, config 0)
-Samples: 9966
-Event count: 22661027577
+Event: task-clock:u (type 1, config 1)
+Samples: 10023
+Event count: 10023000000
-Overhead Command Pid Tid Shared Object Symbol
-59.69% amplewithnative 10440 10452 /system/lib64/libc.so strtol
-8.60% amplewithnative 10440 10452 /system/lib64/libc.so isalpha
+Overhead Command Pid Tid Shared Object Symbol
+27.04% BusyThread 5703 5729 /system/lib64/libart.so art::JniMethodStart(art::Thread*)
+25.87% BusyThread 5703 5729 /system/lib64/libc.so long StrToI<long, ...
...
```
@@ -238,7 +297,7 @@
$ python report_html.py
# Add source code and disassembly. Change the path of source_dirs if it not correct.
-$ python report_html.py --add_source_code --source_dirs ../demo/SimpleperfExampleWithNative \
+$ python report_html.py --add_source_code --source_dirs path_of_SimpleperfExampleWithNative \
--add_disassembly
```
@@ -252,11 +311,12 @@
```sh
# Record dwarf based call graphs: add "-g" in the -r option.
$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative \
- -r "-e task-clock:u -f 1000 --duration 10 -g"
+ -r "-e task-clock:u -f 1000 --duration 10 -g" -lib path_of_SimpleperfExampleWithNative
# Record stack frame based call graphs: add "--call-graph fp" in the -r option.
$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative \
- -r "-e task-clock:u -f 1000 --duration 10 --call-graph fp"
+ -r "-e task-clock:u -f 1000 --duration 10 --call-graph fp" \
+ -lib path_of_SimpleperfExampleWithNative
# Report call graphs in stdio interface.
$ python report.py -g
@@ -319,8 +379,10 @@
```sh
$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative -a .SleepActivity \
- -r "-g -e task-clock:u -f 1000 --duration 10 --trace-offcpu"
-$ python report_html.py --add_disassembly --add_source_code --source_dirs ../demo
+ -r "-g -e task-clock:u -f 1000 --duration 10 --trace-offcpu" \
+ -lib path_of_SimpleperfExampleWithNative
+$ python report_html.py --add_disassembly --add_source_code \
+ --source_dirs path_of_SimpleperfExampleWithNative
```
### Profile from launch
@@ -328,8 +390,14 @@
We can [profile from launch of an application](#profile-from-launch-of-an-application).
```sh
-$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative -a .MainActivity \
- --arch arm64 --profile_from_launch
+# Start simpleperf recording, then start the Activity to profile.
+$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative -a .MainActivity
+
+# We can also start the Activity on the device manually.
+# 1. Make sure the application isn't running or one of the recent apps.
+# 2. Start simpleperf recording.
+$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative
+# 3. Start the app manually on the device.
```
### Parse profiling data manually
@@ -340,7 +408,7 @@
## Executable commands reference
-### How does simpleperf work?
+### How simpleperf works
Modern CPUs have a hardware component called the performance monitoring unit (PMU). The PMU has
several hardware counters, counting events like how many cpu cycles have happened, how many
@@ -374,6 +442,7 @@
Simpleperf supports several commands, listed below:
```
+The debug-unwind command: debug/test dwarf based offline unwinding, used for debugging simpleperf.
The dump command: dumps content in perf.data, used for debugging simpleperf.
The help command: prints help information for other commands.
The kmem command: collects kernel memory allocation information (will be replaced by Python scripts).
@@ -383,6 +452,7 @@
The report-sample command: reports each sample in perf.data, used for supporting integration of
simpleperf in Android Studio.
The stat command: profiles processes and prints counter summary.
+
```
Each command supports different options, which can be seen through help message.
@@ -891,12 +961,10 @@
# Record an Android application.
$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative
-# Record an Android application without compiling the Java code into native instructions.
-# Used when you only profile the C++ code, or the Java code has already been compiled into native
-# instructions.
-$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative -nc
+# Record an Android application with Java code compiled into native instructions.
+$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative --compile_java_code
-# Record running a specific activity of an Android application.
+# Record the launch of an Activity of an Android application.
$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative -a .SleepActivity
# Record a native process.
@@ -904,8 +972,7 @@
# Record a command.
$ python app_profiler.py -cmd \
- "dex2oat --dex-file=/data/local/tmp/app-profiling.apk --oat-file=/data/local/tmp/a.oat" \
- --arch arm
+ "dex2oat --dex-file=/data/local/tmp/app-profiling.apk --oat-file=/data/local/tmp/a.oat"
# Record an Android application, and use -r to send custom options to the record command.
$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative \
@@ -914,10 +981,6 @@
# Record both on CPU time and off CPU time.
$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative \
-r "-e task-clock -g -f 1000 --duration 10 --trace-offcpu"
-
-# Profile activity startup time using --profile_from_launch.
-$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative \
- --profile_from_launch --arch arm64
```
#### Profile from launch of an application
@@ -935,11 +998,27 @@
# Start the app manually or using the `am` command.
```
-To make it convenient to use, app_profiler.py combines these in the --profile_from_launch option.
+To make it convenient to use, app_profiler.py supports using the -a option to start an Activity
+after recording has started.
```sh
-$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative -a .MainActivity \
- --arch arm64 --profile_from_launch
+$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative -a .MainActivity
+```
+
+<a name="run_simpleperf_without_usb_connection-py"></a>
+### run_simpleperf_without_usb_connection.py
+
+run_simpleperf_without_usb_connection.py records profiling data while the USB cable isn't
+connected. Below is an example.
+
+```sh
+$ python run_simpleperf_without_usb_connection.py start \
+ -p com.example.simpleperf.simpleperfexamplewithnative
+# After the command finishes successfully, unplug the USB cable, run the
+# SimpleperfExampleWithNative app. After a few seconds, plug in the USB cable.
+$ python run_simpleperf_without_usb_connection.py stop
+# It may take a while to stop recording. After that, the profiling data is collected in perf.data
+# on host.
```
<a name="binary_cache_builder-py"></a>
@@ -953,7 +1032,7 @@
By default, app_profiler.py builds the binary_cache directory after recording. But we can also
build binary_cache for existing profiling data files using binary_cache_builder.py. It is useful
when you record profiling data using `simpleperf record` directly, to do system wide profiling or
-record without usb cable connected.
+record without the USB cable connected.
binary_cache_builder.py can either pull binaries from an Android device, or find binaries in
directories on the host (via -lib).
@@ -962,8 +1041,9 @@
# Generate binary_cache for perf.data, by pulling binaries from the device.
$ python binary_cache_builder.py
-# Generate binary_cache, by pulling binaries from the device and finding binaries in ../demo.
-$ python binary_cache_builder.py -lib ../demo
+# Generate binary_cache, by pulling binaries from the device and finding binaries in
+# SimpleperfExampleWithNative.
+$ python binary_cache_builder.py -lib path_of_SimpleperfExampleWithNative
```
<a name="run_simpleperf_on_device-py"></a>
@@ -1000,7 +1080,7 @@
$ python report_html.py
# Add source code.
-$ python report_html.py --add_source_code --source_dirs ../demo/SimpleperfExampleWithNative
+$ python report_html.py --add_source_code --source_dirs path_of_SimpleperfExampleWithNative
# Add disassembly.
$ python report_html.py --add_disassembly
@@ -1010,7 +1090,8 @@
```sh
$ python app_profiler.py -p com.example.simpleperf.simpleperfexamplewithnative
-$ python report_html.py --add_source_code --source_dirs ../demo --add_disassembly
+$ python report_html.py --add_source_code --source_dirs path_of_SimpleperfExampleWithNative \
+ --add_disassembly
```
After opening the generated [report.html](./report_html.html) in a browser, there are several tabs:
@@ -1158,4 +1239,5 @@
# report_html.py searches binary_cache/ automatically, so you don't need to
# pass it any argument.
$ python report_html.py
-```
\ No newline at end of file
+```
+
diff --git a/simpleperf/dso.cpp b/simpleperf/dso.cpp
index cdc2104..0434274 100644
--- a/simpleperf/dso.cpp
+++ b/simpleperf/dso.cpp
@@ -374,8 +374,20 @@
BuildId build_id = GetExpectedBuildId();
uint64_t addr;
- ElfStatus result = ReadMinExecutableVirtualAddressFromElfFile(
- GetDebugFilePath(), build_id, &addr);
+ ElfStatus result;
+ auto tuple = SplitUrlInApk(debug_file_path_);
+ if (std::get<0>(tuple)) {
+ EmbeddedElf* elf = ApkInspector::FindElfInApkByName(std::get<1>(tuple),
+ std::get<2>(tuple));
+ if (elf == nullptr) {
+ result = ElfStatus::FILE_NOT_FOUND;
+ } else {
+ result = ReadMinExecutableVirtualAddressFromEmbeddedElfFile(
+ elf->filepath(), elf->entry_offset(), elf->entry_size(), build_id, &addr);
+ }
+ } else {
+ result = ReadMinExecutableVirtualAddressFromElfFile(debug_file_path_, build_id, &addr);
+ }
if (result != ElfStatus::NO_ERROR) {
LOG(WARNING) << "failed to read min virtual address of "
<< GetDebugFilePath() << ": " << result;
@@ -423,8 +435,13 @@
ElfStatus status;
std::tuple<bool, std::string, std::string> tuple = SplitUrlInApk(debug_file_path_);
if (std::get<0>(tuple)) {
- status = ParseSymbolsFromApkFile(std::get<1>(tuple), std::get<2>(tuple), build_id,
- symbol_callback);
+ EmbeddedElf* elf = ApkInspector::FindElfInApkByName(std::get<1>(tuple), std::get<2>(tuple));
+ if (elf == nullptr) {
+ status = ElfStatus::FILE_NOT_FOUND;
+ } else {
+ status = ParseSymbolsFromEmbeddedElfFile(elf->filepath(), elf->entry_offset(),
+ elf->entry_size(), build_id, symbol_callback);
+ }
} else {
status = ParseSymbolsFromElfFile(debug_file_path_, build_id, symbol_callback);
}
@@ -576,7 +593,13 @@
auto tuple = SplitUrlInApk(dso_path);
ElfStatus result;
if (std::get<0>(tuple)) {
- result = GetBuildIdFromApkFile(std::get<1>(tuple), std::get<2>(tuple), build_id);
+ EmbeddedElf* elf = ApkInspector::FindElfInApkByName(std::get<1>(tuple), std::get<2>(tuple));
+ if (elf == nullptr) {
+ result = ElfStatus::FILE_NOT_FOUND;
+ } else {
+ result = GetBuildIdFromEmbeddedElfFile(elf->filepath(), elf->entry_offset(),
+ elf->entry_size(), build_id);
+ }
} else {
result = GetBuildIdFromElfFile(dso_path, build_id);
}
diff --git a/simpleperf/dso_test.cpp b/simpleperf/dso_test.cpp
index cc44193..175ce1d 100644
--- a/simpleperf/dso_test.cpp
+++ b/simpleperf/dso_test.cpp
@@ -23,6 +23,7 @@
#include <android-base/test_utils.h>
#include "get_test_data.h"
+#include "read_apk.h"
using namespace simpleperf_dso_impl;
@@ -85,3 +86,18 @@
GTEST_LOG_(INFO) << "This test only runs on linux because of libdexfile";
#endif // defined(__linux__)
}
+
+TEST(dso, embedded_elf) {
+ const std::string file_path = GetUrlInApk(GetTestData(APK_FILE), NATIVELIB_IN_APK);
+ std::unique_ptr<Dso> dso = Dso::CreateDso(DSO_ELF_FILE, file_path);
+ ASSERT_TRUE(dso);
+ ASSERT_EQ(dso->Path(), file_path);
+ ASSERT_EQ(dso->GetDebugFilePath(), file_path);
+ ASSERT_EQ(dso->MinVirtualAddress(), 0u);
+ const Symbol* symbol = dso->FindSymbol(0x9a4);
+ ASSERT_TRUE(symbol != nullptr);
+ ASSERT_STREQ(symbol->Name(), "Java_com_example_hellojni_HelloJni_callFunc1");
+ BuildId build_id;
+ ASSERT_TRUE(GetBuildIdFromDsoPath(file_path, &build_id));
+ ASSERT_EQ(build_id, native_lib_build_id);
+}
diff --git a/simpleperf/read_apk.cpp b/simpleperf/read_apk.cpp
index b3b45c4..31ba28a 100644
--- a/simpleperf/read_apk.cpp
+++ b/simpleperf/read_apk.cpp
@@ -32,23 +32,42 @@
#include "read_elf.h"
#include "utils.h"
-std::map<ApkInspector::ApkOffset, std::unique_ptr<EmbeddedElf>> ApkInspector::embedded_elf_cache_;
+std::unordered_map<std::string, ApkInspector::ApkNode> ApkInspector::embedded_elf_cache_;
EmbeddedElf* ApkInspector::FindElfInApkByOffset(const std::string& apk_path, uint64_t file_offset) {
// Already in cache?
- ApkOffset ami(apk_path, file_offset);
- auto it = embedded_elf_cache_.find(ami);
- if (it != embedded_elf_cache_.end()) {
+ ApkNode& node = embedded_elf_cache_[apk_path];
+ auto it = node.offset_map.find(file_offset);
+ if (it != node.offset_map.end()) {
return it->second.get();
}
std::unique_ptr<EmbeddedElf> elf = FindElfInApkByOffsetWithoutCache(apk_path, file_offset);
EmbeddedElf* result = elf.get();
- embedded_elf_cache_[ami] = std::move(elf);
+ node.offset_map[file_offset] = std::move(elf);
+ if (result != nullptr) {
+ node.name_map[result->entry_name()] = result;
+ }
return result;
}
-std::unique_ptr<EmbeddedElf> ApkInspector::FindElfInApkByOffsetWithoutCache(const std::string& apk_path,
- uint64_t file_offset) {
+EmbeddedElf* ApkInspector::FindElfInApkByName(const std::string& apk_path,
+ const std::string& entry_name) {
+ ApkNode& node = embedded_elf_cache_[apk_path];
+ auto it = node.name_map.find(entry_name);
+ if (it != node.name_map.end()) {
+ return it->second;
+ }
+ std::unique_ptr<EmbeddedElf> elf = FindElfInApkByNameWithoutCache(apk_path, entry_name);
+ EmbeddedElf* result = elf.get();
+ node.name_map[entry_name] = result;
+ if (result != nullptr) {
+ node.offset_map[result->entry_offset()] = std::move(elf);
+ }
+ return result;
+}
+
+std::unique_ptr<EmbeddedElf> ApkInspector::FindElfInApkByOffsetWithoutCache(
+ const std::string& apk_path, uint64_t file_offset) {
// Crack open the apk(zip) file and take a look.
if (!IsValidApkPath(apk_path)) {
return nullptr;
@@ -103,52 +122,37 @@
// Omit files that are not ELF files.
return nullptr;
}
-
- // Elf found: add EmbeddedElf to vector, update cache.
return std::unique_ptr<EmbeddedElf>(new EmbeddedElf(apk_path, entry_name, zentry.offset,
zentry.uncompressed_length));
}
-bool ApkInspector::FindOffsetInApkByName(const std::string& apk_path,
- const std::string& elf_filename, uint64_t* offset,
- uint32_t* uncompressed_length) {
+std::unique_ptr<EmbeddedElf> ApkInspector::FindElfInApkByNameWithoutCache(
+ const std::string& apk_path, const std::string& entry_name) {
if (!IsValidApkPath(apk_path)) {
- return false;
+ return nullptr;
}
FileHelper fhelper = FileHelper::OpenReadOnly(apk_path);
if (!fhelper) {
- return false;
+ return nullptr;
}
ArchiveHelper ahelper(fhelper.fd(), apk_path);
if (!ahelper) {
- return false;
+ return nullptr;
}
ZipArchiveHandle& handle = ahelper.archive_handle();
ZipEntry zentry;
- int32_t rc = FindEntry(handle, ZipString(elf_filename.c_str()), &zentry);
+ int32_t rc = FindEntry(handle, ZipString(entry_name.c_str()), &zentry);
if (rc != 0) {
- LOG(ERROR) << "failed to find " << elf_filename << " in " << apk_path
+ LOG(ERROR) << "failed to find " << entry_name << " in " << apk_path
<< ": " << ErrorCodeString(rc);
- return false;
- }
- if (zentry.method != kCompressStored || zentry.compressed_length != zentry.uncompressed_length) {
- LOG(ERROR) << "shared library " << elf_filename << " in " << apk_path << " is compressed";
- return false;
- }
- *offset = zentry.offset;
- *uncompressed_length = zentry.uncompressed_length;
- return true;
-}
-
-std::unique_ptr<EmbeddedElf> ApkInspector::FindElfInApkByName(const std::string& apk_path,
- const std::string& elf_filename) {
- uint64_t offset;
- uint32_t uncompressed_length;
- if (!FindOffsetInApkByName(apk_path, elf_filename, &offset, &uncompressed_length)) {
return nullptr;
}
- return std::unique_ptr<EmbeddedElf>(new EmbeddedElf(apk_path, elf_filename, offset,
- uncompressed_length));
+ if (zentry.method != kCompressStored || zentry.compressed_length != zentry.uncompressed_length) {
+ LOG(ERROR) << "shared library " << entry_name << " in " << apk_path << " is compressed";
+ return nullptr;
+ }
+ return std::unique_ptr<EmbeddedElf>(new EmbeddedElf(apk_path, entry_name, zentry.offset,
+ zentry.uncompressed_length));
}
bool IsValidApkPath(const std::string& apk_path) {
@@ -182,23 +186,3 @@
}
return std::make_tuple(true, path.substr(0, pos), path.substr(pos + 2));
}
-
-ElfStatus GetBuildIdFromApkFile(const std::string& apk_path, const std::string& elf_filename,
- BuildId* build_id) {
- std::unique_ptr<EmbeddedElf> ee = ApkInspector::FindElfInApkByName(apk_path, elf_filename);
- if (ee == nullptr) {
- return ElfStatus::FILE_NOT_FOUND;
- }
- return GetBuildIdFromEmbeddedElfFile(apk_path, ee->entry_offset(), ee->entry_size(), build_id);
-}
-
-ElfStatus ParseSymbolsFromApkFile(const std::string& apk_path, const std::string& elf_filename,
- const BuildId& expected_build_id,
- const std::function<void(const ElfFileSymbol&)>& callback) {
- std::unique_ptr<EmbeddedElf> ee = ApkInspector::FindElfInApkByName(apk_path, elf_filename);
- if (ee == nullptr) {
- return ElfStatus::FILE_NOT_FOUND;
- }
- return ParseSymbolsFromEmbeddedElfFile(apk_path, ee->entry_offset(), ee->entry_size(),
- expected_build_id, callback);
-}
diff --git a/simpleperf/read_apk.h b/simpleperf/read_apk.h
index 26c266c..484bafe 100644
--- a/simpleperf/read_apk.h
+++ b/simpleperf/read_apk.h
@@ -19,10 +19,10 @@
#include <stdint.h>
-#include <map>
#include <memory>
#include <string>
#include <tuple>
+#include <unordered_map>
#include "read_elf.h"
@@ -68,38 +68,27 @@
// APK inspector helper class
class ApkInspector {
public:
- // Given an APK/ZIP/JAR file and an offset into that file, if the
- // corresponding region of the APK corresponds to an uncompressed
- // ELF file, then return pertinent info on the ELF.
- static bool FindOffsetInApkByName(const std::string& apk_path,
- const std::string& elf_filename,
- uint64_t* offset, uint32_t* uncompressed_length);
static EmbeddedElf* FindElfInApkByOffset(const std::string& apk_path, uint64_t file_offset);
- static std::unique_ptr<EmbeddedElf> FindElfInApkByName(const std::string& apk_path,
- const std::string& elf_filename);
+ static EmbeddedElf* FindElfInApkByName(const std::string& apk_path,
+ const std::string& entry_name);
private:
static std::unique_ptr<EmbeddedElf> FindElfInApkByOffsetWithoutCache(const std::string& apk_path,
uint64_t file_offset);
+ static std::unique_ptr<EmbeddedElf> FindElfInApkByNameWithoutCache(
+ const std::string& apk_path, const std::string& entry_name);
- // First component of pair is APK file path, second is offset into APK.
- typedef std::pair<std::string, uint64_t> ApkOffset;
-
- static std::map<ApkOffset, std::unique_ptr<EmbeddedElf>> embedded_elf_cache_;
+ struct ApkNode {
+ // Map from entry_offset to EmbeddedElf.
+ std::unordered_map<uint64_t, std::unique_ptr<EmbeddedElf>> offset_map;
+ // Map from entry_name to EmbeddedElf.
+ std::unordered_map<std::string, EmbeddedElf*> name_map;
+ };
+ static std::unordered_map<std::string, ApkNode> embedded_elf_cache_;
};
-// Export for test only.
bool IsValidApkPath(const std::string& apk_path);
-
std::string GetUrlInApk(const std::string& apk_path, const std::string& elf_filename);
std::tuple<bool, std::string, std::string> SplitUrlInApk(const std::string& path);
-ElfStatus GetBuildIdFromApkFile(const std::string& apk_path, const std::string& elf_filename,
- BuildId* build_id);
-
-ElfStatus ParseSymbolsFromApkFile(const std::string& apk_path, const std::string& elf_filename,
- const BuildId& expected_build_id,
- const std::function<void(const ElfFileSymbol&)>& callback);
-
-
#endif // SIMPLE_PERF_READ_APK_H_
diff --git a/simpleperf/read_apk_test.cpp b/simpleperf/read_apk_test.cpp
index f9640e8..4d9e2e1 100644
--- a/simpleperf/read_apk_test.cpp
+++ b/simpleperf/read_apk_test.cpp
@@ -41,16 +41,6 @@
ASSERT_EQ(NATIVELIB_SIZE_IN_APK, ee->entry_size());
}
-TEST(read_apk, FindOffsetInApkByName) {
- uint64_t offset;
- uint32_t length;
- ASSERT_FALSE(ApkInspector::FindOffsetInApkByName("/dev/null", "", &offset, &length));
- ASSERT_FALSE(ApkInspector::FindOffsetInApkByName(GetTestData(APK_FILE), "", &offset, &length));
- ASSERT_TRUE(ApkInspector::FindOffsetInApkByName(GetTestData(APK_FILE), NATIVELIB_IN_APK, &offset, &length));
- ASSERT_EQ(NATIVELIB_OFFSET_IN_APK, static_cast<size_t>(offset));
- ASSERT_EQ(NATIVELIB_SIZE_IN_APK, length);
-}
-
TEST(read_apk, FindElfInApkByName) {
ASSERT_TRUE(ApkInspector::FindElfInApkByName("/dev/null", "") == nullptr);
ASSERT_TRUE(ApkInspector::FindElfInApkByName(GetTestData(APK_FILE), "") == nullptr);
@@ -59,17 +49,3 @@
ASSERT_EQ(NATIVELIB_OFFSET_IN_APK, ee->entry_offset());
ASSERT_EQ(NATIVELIB_SIZE_IN_APK, ee->entry_size());
}
-
-TEST(read_apk, GetBuildIdFromApkFile) {
- BuildId build_id;
- ASSERT_EQ(ElfStatus::NO_ERROR, GetBuildIdFromApkFile(GetTestData(APK_FILE), NATIVELIB_IN_APK, &build_id));
- ASSERT_EQ(build_id, native_lib_build_id);
-}
-
-TEST(read_apk, ParseSymbolsFromApkFile) {
- std::map<std::string, ElfFileSymbol> symbols;
- ASSERT_EQ(ElfStatus::NO_SYMBOL_TABLE,
- ParseSymbolsFromApkFile(GetTestData(APK_FILE), NATIVELIB_IN_APK, native_lib_build_id,
- std::bind(ParseSymbol, std::placeholders::_1, &symbols)));
- CheckElfFileSymbols(symbols);
-}
diff --git a/simpleperf/read_elf.cpp b/simpleperf/read_elf.cpp
index 6f88230..e8ce554 100644
--- a/simpleperf/read_elf.cpp
+++ b/simpleperf/read_elf.cpp
@@ -143,13 +143,18 @@
template <class ELFT>
ElfStatus GetBuildIdFromELFFile(const llvm::object::ELFObjectFile<ELFT>* elf, BuildId* build_id) {
+ llvm::StringRef data = elf->getData();
+ const char* binary_start = data.data();
+ const char* binary_end = data.data() + data.size();
for (auto it = elf->section_begin(); it != elf->section_end(); ++it) {
const llvm::object::ELFSectionRef& section_ref = *it;
if (section_ref.getType() == llvm::ELF::SHT_NOTE) {
- llvm::StringRef data;
if (it->getContents(data)) {
return ElfStatus::READ_FAILED;
}
+ if (data.data() < binary_start || data.data() + data.size() > binary_end) {
+ return ElfStatus::NO_BUILD_ID;
+ }
if (GetBuildIdFromNoteSection(data.data(), data.size(), build_id)) {
return ElfStatus::NO_ERROR;
}
@@ -521,8 +526,17 @@
if (result != ElfStatus::NO_ERROR) {
return result;
}
+ return ReadMinExecutableVirtualAddressFromEmbeddedElfFile(filename, 0, 0, expected_build_id,
+ min_vaddr);
+}
+
+ElfStatus ReadMinExecutableVirtualAddressFromEmbeddedElfFile(const std::string& filename,
+ uint64_t file_offset,
+ uint32_t file_size,
+ const BuildId& expected_build_id,
+ uint64_t* min_vaddr) {
BinaryWrapper wrapper;
- result = OpenObjectFile(filename, 0, 0, &wrapper);
+ ElfStatus result = OpenObjectFile(filename, file_offset, file_size, &wrapper);
if (result != ElfStatus::NO_ERROR) {
return result;
}
@@ -530,14 +544,12 @@
if (result != ElfStatus::NO_ERROR) {
return result;
}
-
if (auto elf = llvm::dyn_cast<llvm::object::ELF32LEObjectFile>(wrapper.obj)) {
return ReadMinExecutableVirtualAddress(elf->getELFFile(), min_vaddr);
} else if (auto elf = llvm::dyn_cast<llvm::object::ELF64LEObjectFile>(wrapper.obj)) {
return ReadMinExecutableVirtualAddress(elf->getELFFile(), min_vaddr);
- } else {
- return ElfStatus::FILE_MALFORMED;
}
+ return ElfStatus::FILE_MALFORMED;
}
ElfStatus ReadSectionFromElfFile(const std::string& filename, const std::string& section_name,
diff --git a/simpleperf/read_elf.h b/simpleperf/read_elf.h
index a6e6cfb..9dbe9ac 100644
--- a/simpleperf/read_elf.h
+++ b/simpleperf/read_elf.h
@@ -73,6 +73,11 @@
ElfStatus ReadMinExecutableVirtualAddressFromElfFile(const std::string& filename,
const BuildId& expected_build_id,
uint64_t* min_addr);
+ElfStatus ReadMinExecutableVirtualAddressFromEmbeddedElfFile(const std::string& filename,
+ uint64_t file_offset,
+ uint32_t file_size,
+ const BuildId& expected_build_id,
+ uint64_t* min_vaddr);
ElfStatus ReadSectionFromElfFile(const std::string& filename, const std::string& section_name,
std::string* content);
diff --git a/simpleperf/read_elf_test.cpp b/simpleperf/read_elf_test.cpp
index 599c413..cbc26bf 100644
--- a/simpleperf/read_elf_test.cpp
+++ b/simpleperf/read_elf_test.cpp
@@ -155,8 +155,15 @@
}
TEST(read_elf, read_elf_with_broken_section_table) {
+ std::string elf_path = GetTestData("libsgmainso-6.4.36.so");
std::map<std::string, ElfFileSymbol> symbols;
ASSERT_EQ(ElfStatus::NO_SYMBOL_TABLE,
- ParseSymbolsFromElfFile(GetTestData("libsgmainso-6.4.36.so"), BuildId(),
+ ParseSymbolsFromElfFile(elf_path, BuildId(),
std::bind(ParseSymbol, std::placeholders::_1, &symbols)));
+ BuildId build_id;
+ ASSERT_EQ(ElfStatus::NO_BUILD_ID, GetBuildIdFromElfFile(elf_path, &build_id));
+ uint64_t min_vaddr;
+ ASSERT_EQ(ElfStatus::NO_ERROR, ReadMinExecutableVirtualAddressFromElfFile(elf_path, BuildId(),
+ &min_vaddr));
+ ASSERT_EQ(min_vaddr, 0u);
}
diff --git a/simpleperf/scripts/bin/android/arm/simpleperf b/simpleperf/scripts/bin/android/arm/simpleperf
index fbbed50..b41318b 100755
--- a/simpleperf/scripts/bin/android/arm/simpleperf
+++ b/simpleperf/scripts/bin/android/arm/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/android/arm64/simpleperf b/simpleperf/scripts/bin/android/arm64/simpleperf
index 27f59ab..4df1f31 100755
--- a/simpleperf/scripts/bin/android/arm64/simpleperf
+++ b/simpleperf/scripts/bin/android/arm64/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/android/x86/simpleperf b/simpleperf/scripts/bin/android/x86/simpleperf
index 0046ac1..2c6edab 100755
--- a/simpleperf/scripts/bin/android/x86/simpleperf
+++ b/simpleperf/scripts/bin/android/x86/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/android/x86_64/simpleperf b/simpleperf/scripts/bin/android/x86_64/simpleperf
index e15aff7..bd24729 100755
--- a/simpleperf/scripts/bin/android/x86_64/simpleperf
+++ b/simpleperf/scripts/bin/android/x86_64/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/darwin/x86/libsimpleperf_report.dylib b/simpleperf/scripts/bin/darwin/x86/libsimpleperf_report.dylib
index cff6358..bf28205 100755
--- a/simpleperf/scripts/bin/darwin/x86/libsimpleperf_report.dylib
+++ b/simpleperf/scripts/bin/darwin/x86/libsimpleperf_report.dylib
Binary files differ
diff --git a/simpleperf/scripts/bin/darwin/x86/simpleperf b/simpleperf/scripts/bin/darwin/x86/simpleperf
index 3ea71e9..f0cdf21 100755
--- a/simpleperf/scripts/bin/darwin/x86/simpleperf
+++ b/simpleperf/scripts/bin/darwin/x86/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/darwin/x86_64/libsimpleperf_report.dylib b/simpleperf/scripts/bin/darwin/x86_64/libsimpleperf_report.dylib
index 927aa98..8625e0d 100755
--- a/simpleperf/scripts/bin/darwin/x86_64/libsimpleperf_report.dylib
+++ b/simpleperf/scripts/bin/darwin/x86_64/libsimpleperf_report.dylib
Binary files differ
diff --git a/simpleperf/scripts/bin/darwin/x86_64/simpleperf b/simpleperf/scripts/bin/darwin/x86_64/simpleperf
index 68d83b2..1dad615 100755
--- a/simpleperf/scripts/bin/darwin/x86_64/simpleperf
+++ b/simpleperf/scripts/bin/darwin/x86_64/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/linux/x86/libsimpleperf_report.so b/simpleperf/scripts/bin/linux/x86/libsimpleperf_report.so
index 56d8b2a..ebf36b3 100755
--- a/simpleperf/scripts/bin/linux/x86/libsimpleperf_report.so
+++ b/simpleperf/scripts/bin/linux/x86/libsimpleperf_report.so
Binary files differ
diff --git a/simpleperf/scripts/bin/linux/x86/simpleperf b/simpleperf/scripts/bin/linux/x86/simpleperf
index 21dede8..3ce5fed 100755
--- a/simpleperf/scripts/bin/linux/x86/simpleperf
+++ b/simpleperf/scripts/bin/linux/x86/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/linux/x86_64/libsimpleperf_report.so b/simpleperf/scripts/bin/linux/x86_64/libsimpleperf_report.so
index ad2a328..db141fb 100755
--- a/simpleperf/scripts/bin/linux/x86_64/libsimpleperf_report.so
+++ b/simpleperf/scripts/bin/linux/x86_64/libsimpleperf_report.so
Binary files differ
diff --git a/simpleperf/scripts/bin/linux/x86_64/simpleperf b/simpleperf/scripts/bin/linux/x86_64/simpleperf
index da240fd..1f532c9 100755
--- a/simpleperf/scripts/bin/linux/x86_64/simpleperf
+++ b/simpleperf/scripts/bin/linux/x86_64/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/windows/x86/libsimpleperf_report.dll b/simpleperf/scripts/bin/windows/x86/libsimpleperf_report.dll
index 4e8f9af..7cf8ec9 100755
--- a/simpleperf/scripts/bin/windows/x86/libsimpleperf_report.dll
+++ b/simpleperf/scripts/bin/windows/x86/libsimpleperf_report.dll
Binary files differ
diff --git a/simpleperf/scripts/bin/windows/x86/simpleperf.exe b/simpleperf/scripts/bin/windows/x86/simpleperf.exe
index a201c40..9e1d378 100755
--- a/simpleperf/scripts/bin/windows/x86/simpleperf.exe
+++ b/simpleperf/scripts/bin/windows/x86/simpleperf.exe
Binary files differ
diff --git a/simpleperf/scripts/bin/windows/x86_64/libsimpleperf_report.dll b/simpleperf/scripts/bin/windows/x86_64/libsimpleperf_report.dll
index 20b792d..23b289a 100755
--- a/simpleperf/scripts/bin/windows/x86_64/libsimpleperf_report.dll
+++ b/simpleperf/scripts/bin/windows/x86_64/libsimpleperf_report.dll
Binary files differ
diff --git a/simpleperf/scripts/bin/windows/x86_64/simpleperf.exe b/simpleperf/scripts/bin/windows/x86_64/simpleperf.exe
index a201c40..9e1d378 100755
--- a/simpleperf/scripts/bin/windows/x86_64/simpleperf.exe
+++ b/simpleperf/scripts/bin/windows/x86_64/simpleperf.exe
Binary files differ
diff --git a/simpleperf/scripts/inferno/Android.bp b/simpleperf/scripts/inferno/Android.bp
new file mode 100644
index 0000000..f49dadd
--- /dev/null
+++ b/simpleperf/scripts/inferno/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2018 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.
+
+python_library_host {
+ name: "simpleperf-inferno",
+ srcs: [
+ "data_types.py",
+ "inferno.py",
+ "svg_renderer.py",
+ ],
+ data: [
+ "inferno.b64",
+ "script.js",
+ ],
+ version: {
+ py2: {
+ enabled: true,
+ },
+ },
+}
+
diff --git a/simpleperf/utils.cpp b/simpleperf/utils.cpp
index ba24346..73d63f9 100644
--- a/simpleperf/utils.cpp
+++ b/simpleperf/utils.cpp
@@ -194,11 +194,11 @@
return true;
}
-static void* xz_alloc(void*, size_t size) {
+static void* xz_alloc(ISzAllocPtr, size_t size) {
return malloc(size);
}
-static void xz_free(void*, void* address) {
+static void xz_free(ISzAllocPtr, void* address) {
free(address);
}
@@ -221,7 +221,7 @@
size_t dst_remaining = dst.size() - dst_offset;
int res = XzUnpacker_Code(&state, reinterpret_cast<Byte*>(&dst[dst_offset]), &dst_remaining,
reinterpret_cast<const Byte*>(&compressed_data[src_offset]),
- &src_remaining, CODER_FINISH_ANY, &status);
+ &src_remaining, true, CODER_FINISH_ANY, &status);
if (res != SZ_OK) {
LOG(ERROR) << "LZMA decompression failed with error " << res;
XzUnpacker_Free(&state);
diff --git a/sound/Android.bp b/sound/Android.bp
new file mode 100644
index 0000000..9c6b190
--- /dev/null
+++ b/sound/Android.bp
@@ -0,0 +1,9 @@
+cc_binary {
+ name: "sound",
+ srcs: ["playwav.c"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-unused-parameter",
+ ],
+}
diff --git a/sound/Android.mk b/sound/Android.mk
deleted file mode 100644
index 860c495..0000000
--- a/sound/Android.mk
+++ /dev/null
@@ -1,8 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := sound
-LOCAL_SRC_FILES := playwav.c
-LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
-include $(BUILD_EXECUTABLE)
-
diff --git a/taskstats/Android.bp b/taskstats/Android.bp
new file mode 100644
index 0000000..3f2a573
--- /dev/null
+++ b/taskstats/Android.bp
@@ -0,0 +1,14 @@
+// Copyright 2013 The Android Open Source Project
+
+cc_binary {
+ name: "taskstats",
+
+ srcs: ["taskstats.c"],
+
+ shared_libs: ["libnl"],
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
diff --git a/taskstats/Android.mk b/taskstats/Android.mk
deleted file mode 100644
index 38044f0..0000000
--- a/taskstats/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2013 The Android Open Source Project
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- taskstats.c
-
-LOCAL_SHARED_LIBRARIES := \
- libnl
-
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE:= taskstats
-LOCAL_CFLAGS:= -Wall -Werror
-
-include $(BUILD_EXECUTABLE)
diff --git a/tests/Android.bp b/tests/Android.bp
deleted file mode 100644
index 1e0d8c8..0000000
--- a/tests/Android.bp
+++ /dev/null
@@ -1,3 +0,0 @@
-subdirs = [
- "lib",
-]
diff --git a/tests/audio/Android.mk b/tests/audio/Android.mk
deleted file mode 100644
index f69a2fc..0000000
--- a/tests/audio/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# Copyright (C) 2013 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.
-#
-
-include $(call all-subdir-makefiles)
diff --git a/tests/audio/alsa/Android.bp b/tests/audio/alsa/Android.bp
new file mode 100644
index 0000000..60dbe87
--- /dev/null
+++ b/tests/audio/alsa/Android.bp
@@ -0,0 +1,31 @@
+//
+// Copyright (C) 2013 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.
+//
+
+cc_test {
+ name: "pcmtest",
+ srcs: ["pcmtest.cpp"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+ shared_libs: [
+ "libcutils",
+ "libutils",
+ "liblog",
+ "libtinyalsa",
+ ],
+ static_libs: ["libtestUtil"],
+}
diff --git a/tests/audio/alsa/Android.mk b/tests/audio/alsa/Android.mk
deleted file mode 100644
index 7d37af9..0000000
--- a/tests/audio/alsa/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Copyright (C) 2013 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE := pcmtest
-LOCAL_SRC_FILES := pcmtest.cpp
-LOCAL_CFLAGS:= -Wall -Werror
-LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libtinyalsa
-LOCAL_STATIC_LIBRARIES += libtestUtil
-LOCAL_C_INCLUDES += system/extras/tests/include external/tinyalsa/include
-
-include $(BUILD_NATIVE_TEST)
diff --git a/tests/binder/Android.mk b/tests/binder/Android.mk
deleted file mode 100644
index 4343259..0000000
--- a/tests/binder/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-
-include $(call all-subdir-makefiles)
diff --git a/tests/binder/benchmarks/Android.bp b/tests/binder/benchmarks/Android.bp
new file mode 100644
index 0000000..5ac0895
--- /dev/null
+++ b/tests/binder/benchmarks/Android.bp
@@ -0,0 +1,34 @@
+//
+// Copyright (C) 2010 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.
+//
+
+cc_benchmark {
+ name: "binderAddInts",
+
+ static_libs: ["libtestUtil"],
+
+ shared_libs: [
+ "libutils",
+ "liblog",
+ "libbinder",
+ ],
+
+ test_suites: ["device-tests"],
+ srcs: ["binderAddInts.cpp"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
diff --git a/tests/binder/benchmarks/Android.mk b/tests/binder/benchmarks/Android.mk
deleted file mode 100644
index e3812ff..0000000
--- a/tests/binder/benchmarks/Android.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Copyright (C) 2010 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.
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-
-LOCAL_MODULE_TAGS := eng tests
-
-LOCAL_STATIC_LIBRARIES += \
- libtestUtil
-
-LOCAL_SHARED_LIBRARIES += \
- libutils \
- liblog \
- libbinder
-
-LOCAL_C_INCLUDES += \
- system/extras/tests/include \
- frameworks/base/include
-
-LOCAL_MODULE := binderAddInts
-LOCAL_COMPATIBILITY_SUITE := device-tests
-LOCAL_SRC_FILES := binderAddInts.cpp
-LOCAL_CFLAGS:= -Wall -Werror
-
-include $(BUILD_NATIVE_BENCHMARK)
diff --git a/tests/cpueater/Android.bp b/tests/cpueater/Android.bp
new file mode 100644
index 0000000..315a18b
--- /dev/null
+++ b/tests/cpueater/Android.bp
@@ -0,0 +1,34 @@
+// Copyright (C) 2008 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.
+// Copyright The Android Open Source Project
+
+cc_binary {
+ name: "cpueater",
+ srcs: ["cpueater.c"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-unused-parameter",
+ ],
+}
+
+cc_binary {
+ name: "daemonize",
+ srcs: ["daemonize.c"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+ shared_libs: ["libhardware_legacy"],
+}
diff --git a/tests/cpueater/Android.mk b/tests/cpueater/Android.mk
deleted file mode 100644
index 3ee7a37..0000000
--- a/tests/cpueater/Android.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright (C) 2008 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.
-# Copyright The Android Open Source Project
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := cpueater
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := eng
-LOCAL_SRC_FILES := cpueater.c
-LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := daemonize
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := eng
-LOCAL_SRC_FILES := daemonize.c
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_SHARED_LIBRARIES := libhardware_legacy
-include $(BUILD_EXECUTABLE)
-
diff --git a/tests/crypto/Android.bp b/tests/crypto/Android.bp
new file mode 100644
index 0000000..61cb829
--- /dev/null
+++ b/tests/crypto/Android.bp
@@ -0,0 +1,11 @@
+// Copyright 2013 The Android Open Source Project
+
+cc_binary {
+ name: "get_dm_versions",
+ srcs: ["get_dm_versions.c"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-unused-parameter",
+ ],
+}
diff --git a/tests/crypto/Android.mk b/tests/crypto/Android.mk
deleted file mode 100644
index d48f722..0000000
--- a/tests/crypto/Android.mk
+++ /dev/null
@@ -1,11 +0,0 @@
-# Copyright 2013 The Android Open Source Project
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= get_dm_versions.c
-LOCAL_MODULE:= get_dm_versions
-LOCAL_MODULE_TAGS := optional
-LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
-include $(BUILD_EXECUTABLE)
diff --git a/tests/directiotest/Android.bp b/tests/directiotest/Android.bp
new file mode 100644
index 0000000..489e3c8
--- /dev/null
+++ b/tests/directiotest/Android.bp
@@ -0,0 +1,8 @@
+cc_binary {
+ name: "directiotest",
+ srcs: ["directiotest.c"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
diff --git a/tests/directiotest/Android.mk b/tests/directiotest/Android.mk
deleted file mode 100644
index 2bde675..0000000
--- a/tests/directiotest/Android.mk
+++ /dev/null
@@ -1,9 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := directiotest
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
-LOCAL_MODULE_TAGS := eng
-LOCAL_SRC_FILES := directiotest.c
-LOCAL_CFLAGS := -Wall -Werror
-include $(BUILD_EXECUTABLE)
diff --git a/tests/framebuffer/Android.bp b/tests/framebuffer/Android.bp
new file mode 100644
index 0000000..f072a59
--- /dev/null
+++ b/tests/framebuffer/Android.bp
@@ -0,0 +1,22 @@
+cc_binary {
+ name: "test-fb-refresh",
+ srcs: ["refresh.c"],
+ shared_libs: ["libcutils"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-unused-parameter",
+ ],
+}
+
+cc_binary {
+ name: "test-fb-simple",
+ srcs: ["fb_test.c"],
+ static_executable: true,
+ static_libs: ["libc"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-unused-parameter",
+ ],
+}
diff --git a/tests/framebuffer/Android.mk b/tests/framebuffer/Android.mk
deleted file mode 100644
index 1c4f5df..0000000
--- a/tests/framebuffer/Android.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- refresh.c
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils
-
-LOCAL_MODULE:= test-fb-refresh
-
-LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
-
-include $(BUILD_EXECUTABLE)
-
-##
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := fb_test.c
-LOCAL_MODULE = test-fb-simple
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-LOCAL_STATIC_LIBRARIES := libc
-LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
-include $(BUILD_EXECUTABLE)
diff --git a/tests/fstest/Android.bp b/tests/fstest/Android.bp
new file mode 100644
index 0000000..febbb2f
--- /dev/null
+++ b/tests/fstest/Android.bp
@@ -0,0 +1,34 @@
+// Copyright (C) 2008 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.
+
+cc_test {
+ name: "recovery_test",
+ srcs: ["recovery_test.cpp"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+ shared_libs: [
+ "libcutils",
+ "libutils",
+ "libbase",
+ "liblog",
+ "liblogwrap",
+ "libext4_utils",
+ ],
+ static_libs: [
+ "libtestUtil",
+ "libfs_mgr",
+ ],
+}
diff --git a/tests/fstest/Android.mk b/tests/fstest/Android.mk
deleted file mode 100644
index 52f113c..0000000
--- a/tests/fstest/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (C) 2008 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.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE := recovery_test
-LOCAL_SRC_FILES := recovery_test.cpp
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_SHARED_LIBRARIES += libcutils libutils libbase liblog \
- liblogwrap libext4_utils
-LOCAL_STATIC_LIBRARIES += libtestUtil libfs_mgr
-LOCAL_C_INCLUDES += system/extras/tests/include \
- system/core/logwrapper/include
-include $(BUILD_NATIVE_TEST)
diff --git a/tests/icachetest/Android.bp b/tests/icachetest/Android.bp
new file mode 100644
index 0000000..e8c7285
--- /dev/null
+++ b/tests/icachetest/Android.bp
@@ -0,0 +1,23 @@
+// Copyright 2006 The Android Open Source Project
+
+cc_binary {
+ name: "icache",
+
+ srcs: [
+ "icache_main.cpp",
+ "Profiler.cpp",
+ "icache.S",
+ ],
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+
+ enabled: false,
+ arch: {
+ arm: {
+ enabled: true,
+ },
+ },
+}
diff --git a/tests/icachetest/Android.mk b/tests/icachetest/Android.mk
deleted file mode 100644
index 9874ffd..0000000
--- a/tests/icachetest/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2006 The Android Open Source Project
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= icache_main.cpp Profiler.cpp icache.S
-
-LOCAL_SHARED_LIBRARIES := libc
-
-LOCAL_MODULE:= icache
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_MODULE_TARGET_ARCH := arm
-
-LOCAL_CFLAGS += -Wall -Werror
-
-include $(BUILD_EXECUTABLE)
diff --git a/tests/iptables/Android.mk b/tests/iptables/Android.mk
deleted file mode 100644
index 56a3fa8..0000000
--- a/tests/iptables/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# Copyright (C) 2011 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.
-#
-
-include $(call all-subdir-makefiles)
diff --git a/tests/iptables/qtaguid/Android.bp b/tests/iptables/qtaguid/Android.bp
new file mode 100644
index 0000000..9c853c8
--- /dev/null
+++ b/tests/iptables/qtaguid/Android.bp
@@ -0,0 +1,32 @@
+//
+// Copyright (C) 2011 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.
+//
+
+cc_test {
+ name: "socketTag",
+ srcs: ["socketTag.cpp"],
+ shared_libs: [
+ "libcutils",
+ "libutils",
+ "liblog",
+ "libbase",
+ ],
+ static_libs: ["libtestUtil"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-fno-strict-aliasing",
+ ],
+}
diff --git a/tests/iptables/qtaguid/Android.mk b/tests/iptables/qtaguid/Android.mk
deleted file mode 100644
index bc09bdd..0000000
--- a/tests/iptables/qtaguid/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Copyright (C) 2011 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.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE := socketTag
-LOCAL_SRC_FILES := socketTag.cpp
-LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libbase
-LOCAL_STATIC_LIBRARIES += libtestUtil
-LOCAL_C_INCLUDES += system/extras/tests/include
-LOCAL_CFLAGS += -Wall -Werror -fno-strict-aliasing
-
-include $(BUILD_NATIVE_TEST)
diff --git a/tests/memtest/Android.bp b/tests/memtest/Android.bp
new file mode 100644
index 0000000..cf8b286
--- /dev/null
+++ b/tests/memtest/Android.bp
@@ -0,0 +1,31 @@
+// Copyright 2006 The Android Open Source Project
+
+cc_binary {
+ name: "memtest",
+
+ srcs: [
+ "memtest.cpp",
+ "fptest.cpp",
+ "thumb.cpp",
+ "bandwidth.cpp",
+ ],
+
+ cflags: [
+ "-fomit-frame-pointer",
+ "-Wall",
+ "-Werror",
+ ],
+
+ sanitize: {
+ never: true,
+ },
+
+ enabled: false,
+ arch: {
+ arm: {
+ enabled: true,
+ instruction_set: "thumb",
+ },
+ },
+
+}
diff --git a/tests/memtest/Android.mk b/tests/memtest/Android.mk
deleted file mode 100644
index 372aaf8..0000000
--- a/tests/memtest/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 2006 The Android Open Source Project
-ifneq ($(filter $(TARGET_ARCH),arm arm64),)
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- memtest.cpp \
- fptest.cpp \
- thumb.cpp \
- bandwidth.cpp \
-
-LOCAL_MODULE := memtest
-LOCAL_MODULE_TAGS := debug
-LOCAL_CFLAGS += \
- -fomit-frame-pointer \
- -Wall \
- -Werror \
-
-LOCAL_MULTILIB := 32
-
-LOCAL_SANITIZE := never
-
-LOCAL_ARM_MODE := thumb
-
-include $(BUILD_EXECUTABLE)
-endif
diff --git a/tests/pftest/Android.bp b/tests/pftest/Android.bp
new file mode 100644
index 0000000..dcd8b5b
--- /dev/null
+++ b/tests/pftest/Android.bp
@@ -0,0 +1,19 @@
+// Copyright 2010 The Android Open Source Project
+
+cc_binary {
+ name: "pftest",
+
+ srcs: ["pftest.c"],
+
+ cflags: [
+ "-fomit-frame-pointer",
+ "-Wall",
+ "-Werror",
+ ],
+
+ arch: {
+ arm: {
+ instruction_set: "arm",
+ },
+ },
+}
diff --git a/tests/pftest/Android.mk b/tests/pftest/Android.mk
deleted file mode 100644
index 1f82937..0000000
--- a/tests/pftest/Android.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2010 The Android Open Source Project
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= pftest.c.arm
-
-
-LOCAL_SHARED_LIBRARIES := libc
-
-LOCAL_MODULE:= pftest
-
-LOCAL_MODULE_TAGS := optional
-
-## LOCAL_CFLAGS += -fstack-protector-all
-LOCAL_CFLAGS += -fomit-frame-pointer -Wall -Werror
-
-include $(BUILD_EXECUTABLE)
diff --git a/tests/schedtest/Android.bp b/tests/schedtest/Android.bp
new file mode 100644
index 0000000..28ece03
--- /dev/null
+++ b/tests/schedtest/Android.bp
@@ -0,0 +1,9 @@
+cc_binary {
+ name: "schedtest",
+ srcs: ["schedtest.c"],
+ cflags: [
+ "-Wno-unused-parameter",
+ "-Wall",
+ "-Werror",
+ ],
+}
diff --git a/tests/schedtest/Android.mk b/tests/schedtest/Android.mk
deleted file mode 100644
index a018cb5..0000000
--- a/tests/schedtest/Android.mk
+++ /dev/null
@@ -1,11 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := \
- schedtest.c
-
-LOCAL_MODULE := schedtest
-LOCAL_CFLAGS := -Wno-unused-parameter -Wall -Werror
-
-include $(BUILD_EXECUTABLE)
diff --git a/tests/sdcard/Android.mk b/tests/sdcard/Android.mk
deleted file mode 100644
index d1e06f2..0000000
--- a/tests/sdcard/Android.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2009 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.
-#
-# Build control file for Bionic's test programs
-# define the BIONIC_TESTS environment variable to build the test programs
-#
-
-ifdef SDCARD_TESTS
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES = \
- stopwatch.cpp \
- sysutil.cpp \
- sdcard_perf_test.cpp \
- testcase.cpp
-
-LOCAL_MODULE := sdcard_perf_test
-LOCAL_MODULE_TAGS := eng tests
-LOCAL_SHARED_LIBRARIES := libutils libhardware_legacy
-
-include $(BUILD_EXECUTABLE)
-
-endif # SDCARD_TESTS
diff --git a/tests/sdcard/README b/tests/sdcard/README
deleted file mode 100644
index 210bb43..0000000
--- a/tests/sdcard/README
+++ /dev/null
@@ -1,63 +0,0 @@
-This directory contains tools to profile the sdcard performance.
-
-There are 2 parts to the tool:
-* A binary that runs on the device, exercises the sdcard and send
- measurment data back to the host (sdcard_perf_test).
-* A host python script to plot the data.
-
-Additionally, there is script 'profile_sdcard.sh' that allows you
-to check how the sdcard scale with the number of processes.
-
-INSTALLATION
-============
-Build, install and mount debugfs. In this directory with a properly
-configured enviroment:
-
- mm SDCARD_TESTS=1
- adb remount
- adb push $ANDROID_PRODUCT_OUT/system/bin/sdcard_perf_test /system/bin/sdcard_perf_test
- adb shell mount -t debugfs none /sys/kernel/debug
-
-If you want to graph the results you need gnuplot and numpy:
-
- sudo apt-get install gnuplot python-numpy python-numeric
-
-You need Gnuplot.py version 1.8 (not the one coming with ubuntu).
-Download it from the Gnuplot.py web site. Extract to a temp
-directory, chdir and run:
-
- sudo python setup.py install
-
-
-INVOCATION
-==========
-
-Run a simple test:
-
- adb shell sdcard_perf_test --test=write --size=1000 --chunk-size=100 --procnb=1 --iterations=100
-
-This test will write 1000kbyte (1M) files using writes of 100kbytes (so 10 writes per file) using
-only 1 process for 100 times (100 files will be written on the sdcard).
-The test will not call sync to flush the writes.
-At the end of the test, some stats for the 'open' and 'write' system calls are written.
-
-If you want to plot the data, you need to use the --dump option and provide a file:
-
- adb shell sdcard_perf_test --test=write --size=1000 --chunk-size=100 --procnb=1 --iterations=100 --dump >/tmp/data.txt
-
-PLOTTING
-========
-
-To plot the result using the iter number of the x axis:
-
- plot_sdcard.py -i /tmp/data.txt
-
-To plot the result using time for the x axis:
-
- plot_sdcard.py -t /tmp/data.txt
-
-To plot the result from the profiler:
-
- profile_sdcard.sh
- plot_sdcard.py -p
-
diff --git a/tests/sdcard/plot_sdcard.py b/tests/sdcard/plot_sdcard.py
deleted file mode 100755
index 0959465..0000000
--- a/tests/sdcard/plot_sdcard.py
+++ /dev/null
@@ -1,334 +0,0 @@
-#!/usr/bin/python2.5
-#
-# Copyright 2009, 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.
-
-
-"""plot_sdcard: A module to plot the results of an sdcard perf test.
-
-Requires Gnuplot python v 1.8
-
-Typical usage:
- -t x axis is time
- -i x axis is iteration
- -p profile data generated by profile_sdcard.sh
-
-./plot_sdcard.py -t /tmp/data.txt
-./plot_sdcard.py -i /tmp/data.txt
-./plot_sdcard.py -p
-
-python interpreter
->>> import plot_sdcard as p
->>> (metadata, data) = p.Parse('/tmp/data.txt')
->>> p.PlotIterations(metadata, data)
->>> p.PlotTimes(metadata, data)
-
-"""
-
-import getopt
-from itertools import izip
-import re
-import sys
-import Gnuplot
-import numpy
-
-
-class DataSet(object):
- """Dataset holds the summary and data (time,value pairs)."""
-
- def __init__(self, line):
- res = re.search(('# StopWatch ([\w]+) total/cumulative '
- 'duration ([0-9.]+). Samples: ([0-9]+)'), line)
- self.time = []
- self.data = []
- self.name = res.group(1)
- self.duration = float(res.group(2))
- self.iteration = int(res.group(3))
- self.summary = re.match('([a-z_]+)_total', self.name)
-
- def __repr__(self):
- return str(zip(self.time, self.data))
-
- def Add(self, time, value):
- self.time.append(time)
- self.data.append(value)
-
- def RescaleTo(self, length):
- factor = len(self.data) / length
-
- if factor > 1:
- new_time = []
- new_data = []
- accum = 0.0
- idx = 1
- for t, d in izip(self.time, self.data):
- accum += d
- if idx % factor == 0:
- new_time.append(t)
- new_data.append(accum / factor)
- accum = 0
- idx += 1
- self.time = new_time
- self.data = new_data
-
-
-class Metadata(object):
- def __init__(self):
- self.kernel = ''
- self.command_line = ''
- self.sched = ''
- self.name = ''
- self.fadvise = ''
- self.iterations = 0
- self.duration = 0.0
- self.complete = False
-
- def Parse(self, line):
- if line.startswith('# Kernel:'):
- self.kernel = re.search('Linux version ([0-9.]+-[^ ]+)', line).group(1)
- elif line.startswith('# Command:'):
- self.command_line = re.search('# Command: [/\w_]+ (.*)', line).group(1)
- self.command_line = self.command_line.replace(' --', '-')
- self.command_line = self.command_line.replace(' -d', '')
- self.command_line = self.command_line.replace('--test=', '')
- elif line.startswith('# Iterations'):
- self.iterations = int(re.search('# Iterations: ([0-9]+)', line).group(1))
- elif line.startswith('# Fadvise'):
- self.fadvise = re.search('# Fadvise: ([\w]+)', line).group(1)
- elif line.startswith('# Sched'):
- self.sched = re.search('# Sched features: ([\w]+)', line).group(1)
- self.complete = True
-
- def AsTitle(self):
- return '%s-duration:%f\\n-%s\\n%s' % (
- self.kernel, self.duration, self.command_line, self.sched)
-
- def UpdateWith(self, dataset):
- self.duration = max(self.duration, dataset.duration)
- self.name = dataset.name
-
-
-def Parse(filename):
- """Parse a file with the collected data.
-
- The data must be in 2 rows (x,y).
-
- Args:
- filename: Full path to the file.
- """
-
- f = open(filename, 'r')
-
- metadata = Metadata()
- data = [] # array of dataset
- dataset = None
-
- for num, line in enumerate(f):
- try:
- line = line.strip()
- if not line: continue
-
- if not metadata.complete:
- metadata.Parse(line)
- continue
-
- if re.match('[a-z_]', line):
- continue
-
- if line.startswith('# StopWatch'): # Start of a new dataset
- if dataset:
- if dataset.summary:
- metadata.UpdateWith(dataset)
- else:
- data.append(dataset)
-
- dataset = DataSet(line)
- continue
-
- if line.startswith('#'):
- continue
-
- # must be data at this stage
- try:
- (time, value) = line.split(None, 1)
- except ValueError:
- print 'skipping line %d: %s' % (num, line)
- continue
-
- if dataset and not dataset.summary:
- dataset.Add(float(time), float(value))
-
- except Exception:
- print 'Error parsing line %d' % num, sys.exc_info()[0]
- raise
- data.append(dataset)
- if not metadata.complete:
- print """Error missing metadata. Did you mount debugfs?
- [adb shell mount -t debugfs none /sys/kernel/debug]"""
- sys.exit(1)
- return (metadata, data)
-
-
-def PlotIterations(metadata, data):
- """Plot the duration of the ops against iteration.
-
- If you are plotting data with widely different runtimes you probably want to
- use PlotTimes instead.
-
- For instance when readers and writers are in the same mix, the
- readers will go thru 100 iterations much faster than the
- writers. The load test tries to be smart about that but the final
- iterations of the writers will likely be done w/o any influence from
- the readers.
-
- Args:
- metadata: For the graph's title.
- data: pair of to be plotted.
- """
-
- gp = Gnuplot.Gnuplot(persist=1)
- gp('set data style lines')
- gp.clear()
- gp.xlabel('iterations')
- gp.ylabel('duration in second')
- gp.title(metadata.AsTitle())
- styles = {}
- line_style = 1
-
- for dataset in data:
- dataset.RescaleTo(metadata.iterations)
- x = numpy.arange(len(dataset.data), dtype='int_')
- if not dataset.name in styles:
- styles[dataset.name] = line_style
- line_style += 1
- d = Gnuplot.Data(x, dataset.data,
- title=dataset.name,
- with_='lines ls %d' % styles[dataset.name])
- else: # no need to repeat a title that exists already.
- d = Gnuplot.Data(x, dataset.data,
- with_='lines ls %d' % styles[dataset.name])
-
- gp.replot(d)
- gp.hardcopy('/tmp/%s-%s-%f.png' %
- (metadata.name, metadata.kernel, metadata.duration),
- terminal='png')
-
-
-def PlotTimes(metadata, data):
- """Plot the duration of the ops against time elapsed.
-
- Args:
- metadata: For the graph's title.
- data: pair of to be plotted.
- """
-
- gp = Gnuplot.Gnuplot(persist=1)
- gp('set data style impulses')
- gp('set xtics 1')
- gp.clear()
- gp.xlabel('seconds')
- gp.ylabel('duration in second')
- gp.title(metadata.AsTitle())
- styles = {}
- line_style = 1
-
- for dataset in data:
- x = numpy.array(dataset.time, dtype='float_')
- if not dataset.name in styles:
- styles[dataset.name] = line_style
- line_style += 1
- d = Gnuplot.Data(x, dataset.data,
- title=dataset.name,
- with_='impulses ls %d' % styles[dataset.name])
- else: # no need to repeat a title that exists already.
- d = Gnuplot.Data(x, dataset.data,
- with_='impulses ls %d' % styles[dataset.name])
-
- gp.replot(d)
- gp.hardcopy('/tmp/%s-%s-%f.png' %
- (metadata.name, metadata.kernel, metadata.duration),
- terminal='png')
-
-
-def PlotProfile():
- """Plot the time of a run against the number of processes."""
- (metadata, data) = Parse('/tmp/sdcard-scalability.txt')
- gp = Gnuplot.Gnuplot(persist=1)
- gp('set data style impulses')
- gp('set xtics 1')
- gp('set pointsize 2')
- gp.clear()
- gp.xlabel('writer process')
- gp.ylabel('duration in second')
- gp.title(metadata.AsTitle())
-
- dataset = data[0]
- x = numpy.array(dataset.time, dtype='int_')
- d = Gnuplot.Data(x, dataset.data,
- title=dataset.name,
- with_='linespoints')
- gp.replot(d)
- gp.hardcopy('/tmp/%s-%s-%f.png' %
- (metadata.name, metadata.kernel, metadata.duration),
- terminal='png')
-
-
-def Usage():
- """Print this module's usage."""
- print """
- To plot the result using the iter number of the x axis:
-
- plot_sdcard.py -i /tmp/data.txt
-
- To plot the result using time for the x axis:
-
- plot_sdcard.py -t /tmp/data.txt
-
- To plot the result from the profiler:
-
- profile_sdcard.sh
- plot_sdcard.py -p
-
- """
- sys.exit(2)
-
-
-def main(argv):
- try:
- (optlist, args) = getopt.getopt(argv[1:],
- 'itp', ['iteration', 'time', 'profile'])
- except getopt.GetoptError, err:
- print str(err)
- Usage()
-
- for flag, val in optlist:
- if flag in ('-i', '--iteration'):
- (metadata, data) = Parse(args[0])
- PlotIterations(metadata, data)
- sys.exit(0)
- elif flag in ('-t', '--time'):
- (metadata, data) = Parse(args[0])
- PlotTimes(metadata, data)
- sys.exit(0)
- elif flag in ('-p', '--profile'):
- PlotProfile()
- sys.exit(0)
- Usage()
-
-
-if __name__ == '__main__':
- if Gnuplot.__version__ != "1.8":
- print "Gnuplot should be 1.8. See REAME file"
- sys.exit(2)
- main(sys.argv)
diff --git a/tests/sdcard/profile_sdcard.sh b/tests/sdcard/profile_sdcard.sh
deleted file mode 100755
index 4629c91..0000000
--- a/tests/sdcard/profile_sdcard.sh
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/bin/bash
-# Copyright 2009, 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.
-
-# Run a bunch of test on the sdcard to establish a performance profile.
-
-print_kernel() {
- adb shell cat /proc/version
-}
-print_sched_features() {
- adb shell cat /sys/kernel/debug/sched_features
-}
-
-# Use dd to get the raw speed of the card
-block_level() {
- true
-}
-
-# Time to run a test vs number of processes
-scalability() {
- local file="/tmp/sdcard-scalability.txt"
- rm -f ${file}
- echo "# Scalability tests" | tee -a ${file}
- echo "# Kernel: $(print_kernel)" | tee -a ${file}
- echo "# Sched features: $(print_sched_features)" | tee -a ${file}
- echo "# StopWatch scalability total/cumulative duration 0.0 Samples: 1" | tee -a ${file}
- echo "# Process Time" | tee -a ${file}
- for p in $(seq 1 8); do
- adb shell sdcard_perf_test --test=write --procnb=${p} --size=1000 --chunk-size=100 --iterations=50 >/tmp/tmp-sdcard.txt
- local t=$(grep 'write_total' /tmp/tmp-sdcard.txt | tail -n 1 | cut -f 6 -d ' ')
- echo "$p $t" | tee -a ${file}
- done
-
-}
-
-# Readers and writers should not starve each others.
-fairness() {
- # Check readers finished before writers.
- # Find the time of the last read op.
- # Count how many writes and how many read happend
- # during that period, do the ratio.
- true
-}
-
-#######################################################################
-# MAIN
-
-echo "Make sure debugfs is mounted on the device."
-block_level
-scalability
-fairness
-
-
diff --git a/tests/sdcard/sdcard_perf_test.cpp b/tests/sdcard/sdcard_perf_test.cpp
deleted file mode 100644
index 7efa650..0000000
--- a/tests/sdcard/sdcard_perf_test.cpp
+++ /dev/null
@@ -1,737 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <cstdio>
-#include <cstdlib>
-#include <ctime>
-#include <errno.h>
-#include <fcntl.h>
-#include <getopt.h>
-#include <limits.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <linux/fadvise.h>
-#include <unistd.h>
-#include <fts.h>
-
-#include "stopwatch.h"
-#include "sysutil.h"
-#include "testcase.h"
-
-// Stress test for the sdcard. Use this to generate some load on the
-// sdcard and collect performance statistics. The output is either a
-// human readable report or the raw timing samples that can be
-// processed using another tool.
-//
-// Needs debugfs:
-// adb root;
-// adb shell mount -t debugfs none /sys/kernel/debug
-//
-// The following tests are defined (value of the --test flag):
-// write: Open a file write some random data and close.
-// read: Open a file read it and close.
-// read_write: Combine readers and writers.
-// open_create: Open|create an non existing file.
-//
-// For each run you can control how many processes will run the test in
-// parallel to simulate a real load (--procnb flag)
-//
-// For each process, the test selected will be executed many time to
-// get a meaningful average/min/max (--iterations flag)
-//
-// Use --dump to also get the raw data.
-//
-// For read/write tests, size is the number of Kbytes to use.
-//
-// To build: mmm system/extras/tests/sdcard/Android.mk SDCARD_TESTS=1
-//
-// Examples:
-// adb shell /system/bin/sdcard_perf_test --test=read --size=1000 --chunk-size=100 --procnb=1 --iterations=10 --dump > /tmp/data.txt
-// adb shell /system/bin/sdcard_perf_test --test=write --size=1000 --chunk-size=100 --procnb=1 --iterations=100 --dump > /tmp/data.txt
-//
-// To watch the memory: cat /proc/meminfo
-// If the phone crashes, look at /proc/last_kmsg on reboot.
-//
-// TODO: It would be cool if we could play with various fadvise()
-// strategies in here to see how tweaking read-ahead changes things.
-//
-
-extern char *optarg;
-extern int optind, opterr, optopt;
-
-// TODO: No clue where fadvise is. Disabled for now.
-#define FADVISE(fd, off, len, advice) (void)0
-
-#ifndef min
-#define min(a,b) (((a)>(b))?(b):(a))
-#endif
-
-namespace {
-using android::kernelVersion;
-using android::kMinKernelVersionBufferSize;
-using android::schedFeatures;
-using android::kMinSchedFeaturesBufferSize;
-using android_test::StopWatch;
-using android::writePidAndWaitForReply;
-using android::waitForChildrenAndSignal;
-using android::waitForChildrenOrExit;
-using android_test::TestCase;
-
-const char *kAppName = "sdcard_perf_test";
-const char *kTestDir = "/sdcard/perf";
-const bool kVerbose = false;
-
-// Used by getopt to parse the command line.
-struct option long_options[] = {
- {"size", required_argument, 0, 's'},
- {"chunk-size", required_argument, 0, 'S'},
- {"depth", required_argument, 0, 'D'},
- {"iterations", required_argument, 0, 'i'},
- {"procnb", required_argument, 0, 'p'},
- {"test", required_argument, 0, 't'},
- {"dump", no_argument, 0, 'd'},
- {"cpu-scaling", no_argument, 0, 'c'},
- {"sync", required_argument, 0, 'f'},
- {"truncate", no_argument, 0, 'e'},
- {"no-new-fair-sleepers", no_argument, 0, 'z'},
- {"no-normalized-sleepers", no_argument, 0, 'Z'},
- {"fadvise", required_argument, 0, 'a'},
- {"help", no_argument, 0, 'h'},
- {0, 0, 0, 0},
-};
-
-void usage()
-{
- printf("sdcard_perf_test --test=write|read|read_write|open_create|traverse [options]\n\n"
- " -t --test: Select the test.\n"
- " -s --size: Size in kbytes of the data.\n"
- " -S --chunk-size: Size of a chunk. Default to size ie 1 chunk.\n"
- " Data will be written/read using that chunk size.\n"
- " -D --depth: Depth of directory tree to create for traversal.\n"
- " -i --iterations: Number of time a process should carry its task.\n"
- " -p --procnb: Number of processes to use.\n"
- " -d --dump: Print the raw timing on stdout.\n"
- " -c --cpu-scaling: Enable cpu scaling.\n"
- " -s --sync: fsync|sync Use fsync or sync in write test. Default: no sync call.\n"
- " -e --truncate: Truncate to size the file on creation.\n"
- " -z --no-new-fair-sleepers: Turn them off. You need to mount debugfs.\n"
- " -Z --no-normalized-sleepers: Turn them off. You need to mount debugfs.\n"
- " -a --fadvise: Specify an fadvise policy (not supported).\n"
- );
-}
-
-// Print command line, pid, kernel version, OOM adj and scheduler.
-void printHeader(int argc, char **argv, const TestCase& testCase)
-{
- printf("# Command: ");
- for (int i = 0; i < argc; ++i)
- {
- printf("%s ", argv[i]);
- }
- printf("\n");
-
- printf("# Pid: %d\n", getpid());
-
- {
- char buffer[kMinKernelVersionBufferSize] = {0, };
- if (kernelVersion(buffer, sizeof(buffer)) > 0)
- {
- printf("# Kernel: %s", buffer);
- }
- }
-
- // Earlier on, running this test was crashing the phone. It turned
- // out that it was using too much memory but its oom_adj value was
- // -17 which means disabled. -16 is the system_server and 0 is
- // typically what applications run at. The issue is that adb runs
- // at -17 and so is this test. We force oom_adj to 0 unless the
- // oom_adj option has been used.
- // TODO: We talked about adding an option to control oom_adj, not
- // sure if we still need that.
- int oomAdj = android::pidOutOfMemoryAdj();
-
- printf("# Oom_adj: %d ", oomAdj);
- if (oomAdj < 0)
- {
- android::setPidOutOfMemoryAdj(0);
- printf("adjuted to %d", android::pidOutOfMemoryAdj());
- }
- printf("\n");
-
- {
- char buffer[kMinSchedFeaturesBufferSize] = {0, };
- if (schedFeatures(buffer, sizeof(buffer)) > 0)
- {
- printf("# Sched features: %s", buffer);
- }
- }
- printf("# Fadvise: %s\n", testCase.fadviseAsStr());
-}
-
-// Remove all the files under kTestDir and clear the caches.
-void cleanup() {
- android::resetDirectory(kTestDir);
- android::syncAndDropCaches(); // don't pollute runs.
-}
-
-// @param argc, argv have a wild guess.
-// @param[out] testCase Structure built from the cmd line args.
-void parseCmdLine(int argc, char **argv, TestCase *testCase)\
-{
- int c;
-
- while(true)
- {
- // getopt_long stores the option index here.
- int option_index = 0;
-
- c = getopt_long (argc, argv,
- "hS:s:D:i:p:t:dcf:ezZa:",
- long_options,
- &option_index);
- // Detect the end of the options.
- if (c == -1) break;
-
- switch (c)
- {
- case 's':
- testCase->setDataSize(atoi(optarg) * 1024);
- break;
- case 'S':
- testCase->setChunkSize(atoi(optarg) * 1024);
- break;
- case 'D': // tree depth
- testCase->setTreeDepth(atoi(optarg));
- break;
- case 'i':
- testCase->setIter(atoi(optarg));
- printf("# Iterations: %d\n", testCase->iter());
- break;
- case 'p':
- testCase->setNproc(atoi(optarg));
- printf("# Proc nb: %d\n", testCase->nproc());
- break;
- case 't':
- testCase->setTypeFromName(optarg);
- printf("# Test name %s\n", testCase->name());
- break;
- case 'd':
- testCase->setDump();
- break;
- case 'c':
- printf("# Cpu scaling is on\n");
- testCase->setCpuScaling();
- break;
- case 'f':
- if (strcmp("sync", optarg) == 0) {
- testCase->setSync(TestCase::SYNC);
- } else if (strcmp("fsync", optarg) == 0) {
- testCase->setSync(TestCase::FSYNC);
- }
- break;
- case 'e': // e for empty
- printf("# Will truncate to size\n");
- testCase->setTruncateToSize();
- break;
- case 'z': // no new fair sleepers
- testCase->setNewFairSleepers(false);
- break;
- case 'Z': // no normalized sleepers
- testCase->setNormalizedSleepers(false);
- break;
- case 'a': // fadvise
- testCase->setFadvise(optarg);
- break;
- case 'h':
- usage();
- exit(0);
- default:
- fprintf(stderr, "Unknown option %s\n", optarg);
- exit(EXIT_FAILURE);
- }
- }
-}
-
-// ----------------------------------------------------------------------
-// READ TEST
-
-// Read a file. We use a new file each time to avoid any caching
-// effect that would happen if we were reading the same file each
-// time.
-// @param chunk buffer large enough where the chunk read are written.
-// @param idx iteration number.
-// @param testCase has all the timers and paramters to run the test.
-
-bool readData(char *const chunk, const int idx, TestCase *testCase)
-{
- char filename[80] = {'\0',};
-
- sprintf(filename, "%s/file-%d-%d", kTestDir, idx, getpid());
-
- testCase->openTimer()->start();
- int fd = open(filename, O_RDONLY);
- testCase->openTimer()->stop();
-
- if (fd < 0)
- {
- fprintf(stderr, "Open read only failed.");
- return false;
- }
- FADVISE(fd, 0, 0, testCase->fadvise());
-
- size_t left = testCase->dataSize();
- pid_t *pid = (pid_t*)chunk;
- while (left > 0)
- {
- char *dest = chunk;
- size_t chunk_size = testCase->chunkSize();
-
- if (chunk_size > left)
- {
- chunk_size = left;
- left = 0;
- }
- else
- {
- left -= chunk_size;
- }
-
- testCase->readTimer()->start();
- while (chunk_size > 0)
- {
- ssize_t s = read(fd, dest, chunk_size);
- if (s < 0)
- {
- fprintf(stderr, "Failed to read.\n");
- close(fd);
- return false;
- }
- chunk_size -= s;
- dest += s;
- }
- testCase->readTimer()->stop();
- }
- close(fd);
- if (testCase->pid() != *pid)
- {
- fprintf(stderr, "Wrong pid found @ read block %x != %x\n", testCase->pid(), *pid);
- return false;
- }
- else
- {
- return true;
- }
-}
-
-
-bool testRead(TestCase *testCase) {
- // Setup the testcase by writting some dummy files.
- const size_t size = testCase->dataSize();
- size_t chunk_size = testCase->chunkSize();
- char *const chunk = new char[chunk_size];
-
- memset(chunk, 0xaa, chunk_size);
- *((pid_t *)chunk) = testCase->pid(); // write our pid at the beginning of each chunk
-
- size_t iter = testCase->iter();
-
- // since readers are much faster we increase the number of
- // iteration to last longer and have concurrent read/write
- // thoughout the whole test.
- if (testCase->type() == TestCase::READ_WRITE)
- {
- iter *= TestCase::kReadWriteFactor;
- }
-
- for (size_t i = 0; i < iter; ++i)
- {
- char filename[80] = {'\0',};
-
- sprintf(filename, "%s/file-%d-%d", kTestDir, i, testCase->pid());
- int fd = open(filename, O_RDWR | O_CREAT, S_IRWXU);
-
- size_t left = size;
- while (left > 0)
- {
- if (chunk_size > left)
- {
- chunk_size = left;
- }
- ssize_t written = write(fd, chunk, chunk_size);
- if (written < 0)
- {
- fprintf(stderr, "Write failed %d %s.", errno, strerror(errno));
- return false;
- }
- left -= written;
- }
- close(fd);
- }
- if (kVerbose) printf("Child %d all chunk written\n", testCase->pid());
-
- android::syncAndDropCaches();
- testCase->signalParentAndWait();
-
- // Start the read test.
- testCase->testTimer()->start();
- for (size_t i = 0; i < iter; ++i)
- {
- if (!readData(chunk, i, testCase))
- {
- return false;
- }
- }
- testCase->testTimer()->stop();
-
- delete [] chunk;
- return true;
-}
-
-// ----------------------------------------------------------------------
-// WRITE TEST
-
-bool writeData(const char *const chunk, const int idx, TestCase *testCase) {
- char filename[80] = {'\0',};
-
- sprintf(filename, "%s/file-%d-%d", kTestDir, idx, getpid());
- testCase->openTimer()->start();
- int fd = open(filename, O_RDWR | O_CREAT, S_IRWXU); // no O_TRUNC, see header comment
- testCase->openTimer()->stop();
-
- if (fd < 0)
- {
- fprintf(stderr, "Open write failed.");
- return false;
- }
- FADVISE(fd, 0, 0, testCase->fadvise());
-
- if (testCase->truncateToSize())
- {
- testCase->truncateTimer()->start();
- ftruncate(fd, testCase->dataSize());
- testCase->truncateTimer()->stop();
- }
-
- size_t left = testCase->dataSize();
- while (left > 0)
- {
- const char *dest = chunk;
- size_t chunk_size = testCase->chunkSize();
-
- if (chunk_size > left)
- {
- chunk_size = left;
- left = 0;
- }
- else
- {
- left -= chunk_size;
- }
-
-
- testCase->writeTimer()->start();
- while (chunk_size > 0)
- {
- ssize_t s = write(fd, dest, chunk_size);
- if (s < 0)
- {
- fprintf(stderr, "Failed to write.\n");
- close(fd);
- return false;
- }
- chunk_size -= s;
- dest += s;
- }
- testCase->writeTimer()->stop();
- }
-
- if (TestCase::FSYNC == testCase->sync())
- {
- testCase->syncTimer()->start();
- fsync(fd);
- testCase->syncTimer()->stop();
- }
- else if (TestCase::SYNC == testCase->sync())
- {
- testCase->syncTimer()->start();
- sync();
- testCase->syncTimer()->stop();
- }
- close(fd);
- return true;
-}
-
-bool testWrite(TestCase *testCase)
-{
- const size_t size = testCase->dataSize();
- size_t chunk_size = testCase->chunkSize();
- char *data = new char[chunk_size];
-
- memset(data, 0xaa, chunk_size);
- // TODO: write the pid at the beginning like in the write
- // test. Have a mode where we check the write was correct.
- testCase->signalParentAndWait();
-
- testCase->testTimer()->start();
- for (size_t i = 0; i < testCase->iter(); ++i)
- {
- if (!writeData(data, i, testCase))
- {
- return false;
- }
- }
- testCase->testTimer()->stop();
- delete [] data;
- return true;
-}
-
-
-// ----------------------------------------------------------------------
-// READ WRITE
-
-// Mix of read and write test. Even PID run the write test. Odd PID
-// the read test. Not fool proof but work most of the time.
-bool testReadWrite(TestCase *testCase)
-{
- if (getpid() & 0x1) {
- return testRead(testCase);
- } else {
- return testWrite(testCase);
- }
-}
-
-// ----------------------------------------------------------------------
-// OPEN CREATE TEST
-
-bool testOpenCreate(TestCase *testCase)
-{
- char filename[80] = {'\0',};
-
- testCase->signalParentAndWait();
- testCase->testTimer()->start();
-
- for (size_t i = 0; i < testCase->iter(); ++i)
- {
- sprintf(filename, "%s/file-%d-%d", kTestDir, i, testCase->pid());
-
- int fd = open(filename, O_RDWR | O_CREAT, S_IRWXU);
- FADVISE(fd, 0, 0, testCase->fadvise());
-
- if (testCase->truncateToSize())
- {
- ftruncate(fd, testCase->dataSize());
- }
- if (fd < 0)
- {
- return false;
- }
- close(fd);
- }
- testCase->testTimer()->stop();
- return true;
-}
-
-bool writeTestFile(TestCase *testCase, const char* filename) {
- int fd = open(filename, O_RDWR | O_CREAT, S_IRWXU);
- if (fd < 0) {
- fprintf(stderr, "open() failed: %s\n", strerror(errno));
- return false;
- }
-
- bool res = false;
-
- char * const chunk = new char[testCase->chunkSize()];
- memset(chunk, 0xaa, testCase->chunkSize());
-
- size_t left = testCase->dataSize();
- while (left > 0) {
- char *dest = chunk;
- size_t chunk_size = testCase->chunkSize();
-
- if (chunk_size > left) {
- chunk_size = left;
- left = 0;
- } else {
- left -= chunk_size;
- }
-
- while (chunk_size > 0) {
- ssize_t s = write(fd, dest, chunk_size);
- if (s < 0) {
- fprintf(stderr, "write() failed: %s\n", strerror(errno));
- goto fail;
- }
- chunk_size -= s;
- dest += s;
- }
- }
-
- res = true;
-fail:
- close(fd);
- delete[] chunk;
- return res;
-}
-
-// ----------------------------------------------------------------------
-// TRAVERSE
-
-#define MAX_PATH 512
-
-// Creates a directory tree that is both deep and wide, and times
-// traversal using fts_open().
-bool testTraverse(TestCase *testCase) {
- char path[MAX_PATH];
- char filepath[MAX_PATH];
- strcpy(path, kTestDir);
-
- // Generate a deep directory hierarchy
- size_t depth = testCase->treeDepth();
- for (size_t i = 0; i < depth; i++) {
- // Go deeper by appending onto current path
- snprintf(path + strlen(path), MAX_PATH - strlen(path), "/dir%d", i);
- mkdir(path, S_IRWXU);
-
- // Create some files at this depth
- strcpy(filepath, path);
- int pathlen = strlen(path);
- char* nameStart = filepath + pathlen;
- for (size_t j = 0; j < depth; j++) {
- snprintf(nameStart, MAX_PATH - pathlen, "/file%d", j);
- writeTestFile(testCase, filepath);
- }
- }
-
- testCase->signalParentAndWait();
- testCase->testTimer()->start();
-
- // Now traverse structure
- size_t iter = testCase->iter();
- for (size_t i = 0; i < iter; i++) {
- testCase->traverseTimer()->start();
-
- FTS *ftsp;
- if ((ftsp = fts_open((char **) &kTestDir, FTS_LOGICAL | FTS_XDEV, NULL)) == NULL) {
- fprintf(stderr, "fts_open() failed: %s\n", strerror(errno));
- return false;
- }
-
- // Count discovered files
- int dirs = 0, files = 0;
-
- FTSENT *curr;
- while ((curr = fts_read(ftsp)) != NULL) {
- switch (curr->fts_info) {
- case FTS_D:
- dirs++;
- break;
- case FTS_F:
- files++;
- break;
- }
- }
-
- fts_close(ftsp);
-
- testCase->traverseTimer()->stop();
-
- int expectedDirs = depth + 1;
- if (expectedDirs != dirs) {
- fprintf(stderr, "expected %d dirs, but found %d\n", expectedDirs, dirs);
- return false;
- }
-
- int expectedFiles = depth * depth;
- if (expectedFiles != files) {
- fprintf(stderr, "expected %d files, but found %d\n", expectedFiles, files);
- return false;
- }
- }
-
- testCase->testTimer()->stop();
- return true;
-}
-
-} // anonymous namespace
-
-int main(int argc, char **argv)
-{
- android_test::TestCase testCase(kAppName);
-
- cleanup();
-
- parseCmdLine(argc, argv, &testCase);
- printHeader(argc, argv, testCase);
-
- printf("# File size %d kbytes\n", testCase.dataSize() / 1024);
- printf("# Chunk size %d kbytes\n", testCase.chunkSize() / 1024);
- printf("# Sync: %s\n", testCase.syncAsStr());
-
- if (!testCase.cpuScaling())
- {
- android::disableCpuScaling();
- }
-
- switch(testCase.type()) {
- case TestCase::WRITE:
- testCase.mTestBody = testWrite;
- break;
- case TestCase::READ:
- testCase.mTestBody = testRead;
- break;
- case TestCase::OPEN_CREATE:
- testCase.mTestBody = testOpenCreate;
- break;
- case TestCase::READ_WRITE:
- testCase.mTestBody = testReadWrite;
- break;
- case TestCase::TRAVERSE:
- testCase.mTestBody = testTraverse;
- break;
- default:
- fprintf(stderr, "Unknown test type %s", testCase.name());
- exit(EXIT_FAILURE);
- }
-
- testCase.createTimers();
-
- bool ok;
-
- ok = testCase.runTest();
-
- cleanup();
- if (!ok)
- {
- printf("error %d %s", errno, strerror(errno));
- exit(EXIT_FAILURE);
- }
- else
- {
- exit(EXIT_SUCCESS);
- }
-}
diff --git a/tests/sdcard/stopwatch.cpp b/tests/sdcard/stopwatch.cpp
deleted file mode 100644
index 77768d6..0000000
--- a/tests/sdcard/stopwatch.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-
-#include <malloc.h>
-#include <stdio.h>
-#include <time.h>
-#include "stopwatch.h"
-#include <math.h>
-
-#define SNPRINTF_OR_RETURN(str, size, format, ...) { \
- int len = snprintf((str), (size), (format), ## __VA_ARGS__); \
- if (len < 0) return; \
- if (len > static_cast<int>(size)) { \
- fprintf(stderr, "Not enough space\n"); \
- return; \
- } else { \
- (size) -= len; (str) += len; \
- } \
- }
-
-namespace {
-const bool kVerbose = false;
-bool printRaw = false;
-}
-
-namespace android_test {
-
-StopWatch::StopWatch(const char *name, size_t capacity)
- : mName(strdup(name)), mNum(0), mData(NULL), mDataLen(0), mCapacity(capacity * 2),
- mSizeKbytes(0), mAlreadyPrinted(false), mPrintRaw(false),
- mDuration(0.0), mDeviation(0.0),
- mMinDuration(0.0), mMinIdx(0),
- mMaxDuration(0.0), mMaxIdx(0),
- mDeltas(NULL), mUsed(false)
-{
- mStart.tv_sec = 0;
- mStart.tv_nsec = 0;
- mData = (Measurement *) malloc(mCapacity * sizeof(Measurement));
-}
-
-StopWatch::~StopWatch()
-{
- if (mUsed && !mAlreadyPrinted)
- {
- fprintf(stderr, "Discarding data for %s\n", mName);
- }
- free(mData);
- free(mName);
- delete [] mDeltas;
-}
-
-void StopWatch::start()
-{
- checkCapacity();
- clock_gettime(CLOCK_MONOTONIC, &mData[mDataLen].mTime);
- mData[mDataLen].mIsStart = true;
- if (!mUsed)
- {
- mStart = mData[mDataLen].mTime; // mDataLen should be 0
- mUsed = true;
- }
- ++mNum;
- ++mDataLen;
-}
-
-void StopWatch::stop()
-{
- checkCapacity();
- clock_gettime(CLOCK_MONOTONIC, &mData[mDataLen].mTime);
- mData[mDataLen].mIsStart = false;
- ++mDataLen;
-}
-
-void StopWatch::setPrintRawMode(bool raw)
-{
- printRaw = raw;
-}
-
-
-void StopWatch::sprint(char **str, size_t *size)
-{
- if (kVerbose) fprintf(stderr, "printing\n");
- mAlreadyPrinted = true;
- if (0 == mDataLen)
- {
- return;
- }
- if (mDataLen > 0 && mData[mDataLen - 1].mIsStart)
- {
- stop();
- }
- if (kVerbose) SNPRINTF_OR_RETURN(*str, *size, "# Got %d samples for %s\n", mDataLen, mName);
- processSamples();
-
- SNPRINTF_OR_RETURN(*str, *size, "# StopWatch %s total/cumulative duration %f Samples: %d\n",
- mName, mDuration, mNum);
- printThroughput(str, size);
- printAverageMinMax(str, size);
-
- if (printRaw)
- {
- // print comment header and summary values.
-
- SNPRINTF_OR_RETURN(*str, *size, "# Name Iterations Duration Min MinIdx Max MaxIdx SizeKbytes\n");
- SNPRINTF_OR_RETURN(*str, *size, "%s %d %f %f %d %f %d %d\n", mName, mNum, mDuration,
- mMinDuration, mMinIdx, mMaxDuration, mMaxIdx, mSizeKbytes);
- // print each duration sample
- for (size_t i = 0; i < mDataLen / 2; ++i)
- {
- long second = mData[i * 2].mTime.tv_sec - mStart.tv_sec;
- long nano = mData[i * 2].mTime.tv_nsec - mStart.tv_nsec;
-
- SNPRINTF_OR_RETURN(*str, *size, "%f %f\n", double(second) + double(nano) / 1.0e9, mDeltas[i]);
- }
- }
-
-}
-
-// Normally we should have enough capacity but if we have to
-// reallocate the measurement buffer (e.g start and stop called more
-// than once in an iteration) we let the user know. She should provide
-// a capacity when building the StopWatch.
-void StopWatch::checkCapacity()
-{
- if (mDataLen >= mCapacity)
- {
- mCapacity *= 2;
- fprintf(stderr, "# Increased capacity to %d for %s. Measurement affected.\n",
- mCapacity, mName);
- mData = (Measurement *)realloc(mData, mCapacity * sizeof(Measurement));
- }
-}
-
-
-// Go over all the samples and compute the diffs between a start and
-// stop pair. The diff is accumulated in mDuration and inserted in
-// mDeltas.
-// The min and max values for a diff are also tracked.
-void StopWatch::processSamples()
-{
- if (kVerbose) fprintf(stderr, "processing samples\n");
- size_t n = mDataLen / 2;
- mDeltas= new double[n];
- for (size_t i = 0; i < mDataLen; i += 2) // even: start odd: stop
- {
- long second = mData[i + 1].mTime.tv_sec - mData[i].mTime.tv_sec;
- long nano = mData[i + 1].mTime.tv_nsec - mData[i].mTime.tv_nsec;
-
- mDeltas[i / 2] = double(second) + double(nano) / 1.0e9;
- }
-
- for (size_t i = 0; i < n; ++i)
- {
- if (0 == i)
- {
- mMinDuration = mMaxDuration = mDeltas[i];
- }
- else
- {
- if (mMaxDuration < mDeltas[i])
- {
- mMaxDuration = mDeltas[i];
- mMaxIdx = i;
- }
- if (mMinDuration > mDeltas[i])
- {
- mMinDuration = mDeltas[i];
- mMinIdx = i;
- }
- }
- mDuration += mDeltas[i];
- }
- double avgDuration = mDuration / n;
- double diffSQ = 0.0;
- for (size_t i = 0; i < n; ++i)
- {
- diffSQ += pow((mDeltas[i] - avgDuration), 2.0);
- }
- mDeviation = sqrt(diffSQ / n);
-}
-
-
-double StopWatch::timespecToDouble(const struct timespec& time)
-{
- double val = double(time.tv_nsec) / 1.0e9 + double(time.tv_sec);
- return val < 0.0 ? -val : val; // sometimes 0.00 is -0.00
-}
-
-
-// If we have only 2 values, don't bother printing anything.
-void StopWatch::printAverageMinMax(char **str, size_t *size)
-{
- if (mDataLen > 2) // if there is only one sample, avg, min, max are trivial.
- {
- SNPRINTF_OR_RETURN(*str, *size, "# Average %s duration %f s/op\n", mName, mDuration / mNum);
- SNPRINTF_OR_RETURN(*str, *size, "# Standard deviation %s duration %f \n", mName, mDeviation);
- SNPRINTF_OR_RETURN(*str, *size, "# Min %s duration %f [%d]\n", mName, mMinDuration, mMinIdx);
- SNPRINTF_OR_RETURN(*str, *size, "# Max %s duration %f [%d]\n", mName, mMaxDuration, mMaxIdx);
- }
-}
-
-void StopWatch::printThroughput(char **str, size_t *size)
-{
- if (0 != mSizeKbytes)
- {
- SNPRINTF_OR_RETURN(*str, *size, "# Size: %d Kbytes Total: %d\n", mSizeKbytes, mNum);
- SNPRINTF_OR_RETURN(*str, *size, "# Speed %f Kbyte/s\n", double(mSizeKbytes) * mNum / mDuration);
- }
-}
-} // namespace android_test
diff --git a/tests/sdcard/stopwatch.h b/tests/sdcard/stopwatch.h
deleted file mode 100644
index c54f257..0000000
--- a/tests/sdcard/stopwatch.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef ANDROID_NATIVETEST_SYSTEM_EXTRAS_TESTS_SDCARD_STOPWATCH_H_
-#define ANDROID_NATIVETEST_SYSTEM_EXTRAS_TESTS_SDCARD_STOPWATCH_H_
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-
-namespace android_test {
-
-// StopWatch class to collect execution statistics.
-//
-// Once the watch has been created, start and stop can be called to
-// capture an event duration.
-//
-// On completion, use 'sprint' to retrieve the data.
-//
-// If StopWatch::setPrintRawMode(true) has been called, the raw
-// samples also are printed.
-// The print method is thread safe to avoid mixing the result of
-// watches on different threads. For processes, use different files
-// that you concat after the run.
-//
-// If the time measure is associated with some volume of data, use
-// setMbytes, the print method will compute the average throughput
-// based on that value.
-//
-// To capture the time accurately and since the runs are not too long,
-// we collect the raw start and stop time in an array that get
-// processed once all the measurements have been done.
-//
-// Typical Usage:
-// ==============
-//
-// StopWatch watch("my name", 20);
-//
-// for (int i = 0; i < 20; ++i) {
-// watch.start();
-// doMyStuff();
-// watch.stop();
-// }
-// char buffer[4096];
-// char *str = buffer;
-// size_t size = sizeof(buffer);
-// watch.sprint(&str, &size);
-//
-
-class StopWatch {
- public:
- // Time of the snapshot and its nature (start of the interval or end of it).
- struct Measurement {
- struct timespec mTime;
- bool mIsStart;
- };
- static const size_t kUseDefaultCapacity = 20;
-
- // Create a stop watch. Default capacity == 2 * interval_nb
- // @param name To be used when the results are displayed. No
- // spaces, use _ instead.
- // @param capacity Hint about the number of sampless that will be
- // measured (1 sample == 1 start + 1 stop). Used
- // to size the internal storage, when the capacity
- // is reached, it is doubled.
- StopWatch(const char *name, size_t capacity = kUseDefaultCapacity);
- ~StopWatch();
-
- // A StopWatch instance measures time intervals. Use setDataSize
- // if some volume of data is processed during these intervals, to
- // get the average throughput (in kbytes/s) printed.
- void setDataSize(size_t size_in_bytes) { mSizeKbytes = size_in_bytes / 1000; }
-
- // Starts and stops the timer. The time between the 2 calls is an
- // interval whose duration will be reported in sprint.
- void start();
- void stop();
-
- // Print a summary of the measurement and optionaly the raw data.
- // The summary is commented out using a leading '#'. The raw data
- // is a pair (time, duration). The 1st sample is always at time
- // '0.0'.
- // @param str[inout] On entry points to the begining of a buffer
- // where to write the data. On exit points pass the last byte
- // written.
- // @param size[inout] On entry points to the size of the buffer
- // pointed by *str. On exit *size is the amount of free space left
- // in the buffer. If there was not enough space the data is truncated
- // and a warning is printed.
- void sprint(char **str, size_t *size);
-
- // @return true if at least one interval was timed.
- bool used() const { return mUsed; }
-
- // Affects all the timers. Instructs all the timers to print the
- // raw data as well as the summary.
- static void setPrintRawMode(bool printRaw);
-
- private:
- void checkCapacity();
- double timespecToDouble(const struct timespec& time);
- void printAverageMinMax(char **str, size_t *size);
- void printThroughput(char **str, size_t *size);
- // Allocate mDeltas and fill it in. Search for the min and max.
- void processSamples();
-
- char *const mName; // Name of the test.
- struct timespec mStart;
- size_t mNum; // # of intervals == # of start() calls.
- struct Measurement *mData;
- size_t mDataLen;
- size_t mCapacity;
- int mSizeKbytes;
-
- bool mAlreadyPrinted;
- bool mPrintRaw;
-
- double mDuration;
- double mDeviation;
- double mMinDuration;
- size_t mMinIdx;
- double mMaxDuration;
- size_t mMaxIdx;
- double *mDeltas;
-
- bool mUsed;
-};
-
-} // namespace android_test
-
-#endif // ANDROID_NATIVETEST_SYSTEM_EXTRAS_TESTS_SDCARD_STOPWATCH_H_
diff --git a/tests/sdcard/sysutil.cpp b/tests/sdcard/sysutil.cpp
deleted file mode 100644
index 0182590..0000000
--- a/tests/sdcard/sysutil.cpp
+++ /dev/null
@@ -1,604 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include "sysutil.h"
-
-namespace {
-const int kError = -1;
-// Max number of retries on EAGAIN and EINTR. Totally arbitrary.
-const int kMaxAttempts = 8;
-
-// How long to wait after a cache purge. A few seconds (arbitrary).
-const int kCachePurgeSleepDuration = 2; // seconds
-
-const bool kSilentIfMissing = false;
-
-const char *kKernelVersion = "/proc/version";
-const char *kScalingGovernorFormat = "/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor";
-const char *kDropCaches = "/proc/sys/vm/drop_caches";
-const char *kSchedFeatures = "/sys/kernel/debug/sched_features";
-const char *kNewFairSleepers = "NEW_FAIR_SLEEPERS";
-const char *kNoNewFairSleepers = "NO_NEW_FAIR_SLEEPERS";
-const char *kNormalizedSleepers = "NORMALIZED_SLEEPER"; // no 's' at the end
-const char *kNoNormalizedSleepers = "NO_NORMALIZED_SLEEPER";
-
-const char *kDebugfsWarningMsg = "Did you 'adb root; adb shell mount -t debugfs none /sys/kernel/debug' ?";
-
-// TODO: Surely these file utility functions must exist already. A
-// quick grep did not turn up anything. Look harder later.
-
-void printErrno(const char *msg, const char *filename)
-{
- fprintf(stderr, "# %s %s %d %s\n", msg, filename, errno, strerror(errno));
-}
-
-// Read a C-string from a file. If the buffer is too short, an error
-// message will be printed on stderr.
-// @param filename Of the file to read.
-// @param start Buffer where the data should be written to.
-// @param size The size of the buffer pointed by str. Must be >= 1.
-// @return The number of characters read (not including the trailing'\0' used
-// to end the string) or -1 if there was an error.
-int readStringFromFile(const char *filename, char *const start, size_t size, bool must_exist=true)
-{
- if (NULL == start || size == 0)
- {
- return 0;
- }
- char *end = start;
- int fd = open(filename, O_RDONLY);
-
- if (fd < 0)
- {
- if (ENOENT != errno || must_exist)
- {
- printErrno("Failed to open", filename);
- }
- return kError;
- }
-
- bool eof = false;
- bool error = false;
- int attempts = 0;
-
- --size; // reserve space for trailing '\0'
-
- while (size > 0 && !error && !eof && attempts < kMaxAttempts)
- {
- ssize_t s;
-
- s = read(fd, end, size);
-
- if (s < 0)
- {
- error = EAGAIN != errno && EINTR != errno;
- if (error)
- {
- printErrno("Failed to read", filename);
- }
- }
- else if (0 == s)
- {
- eof = true;
- }
- else
- {
- end += s;
- size -= s;
- }
- ++attempts;
- }
-
- close(fd);
-
- if (error)
- {
- return kError;
- }
- else
- {
- *end = '\0';
- if (!eof)
- {
- fprintf(stderr, "Buffer too small for %s\n", filename);
- }
- return end - start;
- }
-}
-
-// Write a C string ('\0' terminated) to a file.
-//
-int writeStringToFile(const char *filename, const char *start, bool must_exist=true)
-{
- int fd = open(filename, O_WRONLY);
-
-
- if (fd < 0)
- {
- if (ENOENT != errno || must_exist)
- {
- printErrno("Failed to open", filename);
- }
- return kError;
- }
-
- const size_t len = strlen(start);
- size_t size = len;
- bool error = false;
- int attempts = 0;
-
- while (size > 0 && !error && attempts < kMaxAttempts)
- {
- ssize_t s = write(fd, start, size);
-
- if (s < 0)
- {
- error = EAGAIN != errno && EINTR != errno;
- if (error)
- {
- printErrno("Failed to write", filename);
- }
- }
- else
- {
- start += s;
- size -= s;
- }
- ++attempts;
- }
- close(fd);
-
- if (error)
- {
- return kError;
- }
- else
- {
- if (size > 0)
- {
- fprintf(stderr, "Partial write to %s (%d out of %d)\n",
- filename, size, len);
- }
- return len - size;
- }
-}
-
-int writeIntToFile(const char *filename, long value)
-{
- char buffer[16] = {0,};
- sprintf(buffer, "%ld", value);
- return writeStringToFile(filename, buffer);
-}
-
-// @return a message describing the reason why the child exited. The
-// message is in a shared buffer, not thread safe, erased by
-// subsequent calls.
-const char *reasonChildExited(int status)
-{
- static char buffer[80];
-
- if (WIFEXITED(status))
- {
- snprintf(buffer, sizeof(buffer), "ok (%d)", WEXITSTATUS(status));
- }
- else if (WIFSIGNALED(status))
- {
- snprintf(buffer, sizeof(buffer), "signaled (%d %s)", WTERMSIG(status), strsignal(WTERMSIG(status)));
- }
- else
- {
- snprintf(buffer, sizeof(buffer), "stopped?");
- }
- return buffer;
-}
-
-
-} // anonymous namespace
-
-namespace android {
-
-int kernelVersion(char *str, size_t size)
-{
- return readStringFromFile(kKernelVersion, str, size);
-}
-
-int pidOutOfMemoryAdj()
-{
- char filename[FILENAME_MAX];
-
- snprintf(filename, sizeof(filename), "/proc/%d/oom_adj", getpid());
-
- char value[16];
- if (readStringFromFile(filename, value, sizeof(value)) == -1)
- {
- return -127;
- }
- else
- {
- return atoi(value);
- }
-}
-
-void setPidOutOfMemoryAdj(int level)
-{
- char filename[FILENAME_MAX];
-
- snprintf(filename, sizeof(filename), "/proc/%d/oom_adj", getpid());
- writeIntToFile(filename, level);
-}
-
-void disableCpuScaling()
-{
- for (int cpu = 0; cpu < 16; ++cpu) // 16 cores mobile phones, abestos pockets recommended.
- {
- char governor[FILENAME_MAX];
- sprintf(governor, kScalingGovernorFormat, cpu);
-
- if (writeStringToFile(governor, "performance", kSilentIfMissing) < 0)
- {
- if (cpu > 0 && errno == ENOENT)
- {
- break; // cpu1 or above not found, ok since we have cpu0.
- }
- fprintf(stderr, "Failed to write to scaling governor file for cpu %d: %d %s",
- cpu, errno, strerror(errno));
- break;
- }
- }
-}
-
-int schedFeatures(char *str, size_t size)
-{
- return readStringFromFile(kSchedFeatures, str, size);
-}
-
-bool newFairSleepers()
-{
- char value[256] = {0,};
-
- if (readStringFromFile(kSchedFeatures, value, sizeof(value)) == -1)
- {
- printErrno(kDebugfsWarningMsg, kSchedFeatures);
- return false;
- }
- return strstr(value, "NO_NEW_FAIR_SLEEPERS") == NULL;
-}
-
-void setNewFairSleepers(bool on)
-{
- int retcode;
-
- if (on)
- {
- retcode = writeStringToFile(kSchedFeatures, kNewFairSleepers);
- }
- else
- {
- retcode = writeStringToFile(kSchedFeatures, kNoNewFairSleepers);
- }
- if (retcode < 0)
- {
- fprintf(stderr, "# %s\n", kDebugfsWarningMsg);
- }
-}
-
-bool normalizedSleepers()
-{
- char value[256] = {0,};
-
- if (readStringFromFile(kSchedFeatures, value, sizeof(value)) == -1)
- {
- printErrno(kDebugfsWarningMsg, kSchedFeatures);
- return false;
- }
- return strstr(value, "NO_NEW_FAIR_SLEEPERS") == NULL;
-}
-
-void setNormalizedSleepers(bool on)
-{
- int retcode;
-
- if (on)
- {
- retcode = writeStringToFile(kSchedFeatures, kNormalizedSleepers);
- }
- else
- {
- retcode = writeStringToFile(kSchedFeatures, kNoNormalizedSleepers);
- }
- if (retcode < 0)
- {
- fprintf(stderr, "# %s\n", kDebugfsWarningMsg);
- }
-}
-
-pid_t forkOrExit()
-{
- pid_t childpid = fork();
-
- if (-1 == childpid)
- {
- fprintf(stderr, "Fork failed: %d %s", errno, strerror(errno));
- exit(EXIT_FAILURE);
- }
- return childpid;
-}
-
-void waitForChildrenOrExit(int num)
-{
- while (num > 0)
- {
- int status;
- pid_t pid = wait(&status);
- if (-1 == pid)
- {
- fprintf(stderr, "Wait failed\n");
- }
- else
- {
- if (!WIFEXITED(status))
- {
- fprintf(stderr, "Child pid %d did not exit cleanly %s\n",
- pid, reasonChildExited(status));
- exit(EXIT_FAILURE);
- }
- }
- --num;
- }
-}
-
-// Sync and cache cleaning functions. In the old hpux days I was told
-// to always call *sync twice. The same advice seems to be still true
-// today so *sync is called twice.
-// Also we wait 'a little' to give a chance to background threads to
-// purge their caches.
-void syncAndDropCaches(int code)
-{
- sync();
- sync();
- writeIntToFile(kDropCaches, code);
- sleep(kCachePurgeSleepDuration);
-}
-
-
-void fsyncAndDropCaches(int fd, int code)
-{
- fsync(fd);
- fsync(fd);
- writeIntToFile(kDropCaches, code);
- sleep(kCachePurgeSleepDuration);
-}
-
-
-void resetDirectory(const char *directory)
-{
- DIR *dir = opendir(directory);
-
- if (NULL != dir)
- {
- struct dirent *entry;
- char name_buffer[PATH_MAX];
-
- while((entry = readdir(dir)))
- {
- if (0 == strcmp(entry->d_name, ".")
- || 0 == strcmp(entry->d_name, "..")
- || 0 == strcmp(entry->d_name, "lost+found"))
- {
- continue;
- }
- strcpy(name_buffer, directory);
- strcat(name_buffer, "/");
- strcat(name_buffer, entry->d_name);
- unlink(name_buffer);
- }
- closedir(dir);
- } else {
- mkdir(directory, S_IRWXU);
- }
-}
-
-
-// IPC
-bool writePidAndWaitForReply(int writefd, int readfd)
-{
- if (writefd > readfd)
- {
- fprintf(stderr, "Called with args in wrong order!!\n");
- return false;
- }
- pid_t pid = getpid();
- char *start = reinterpret_cast<char *>(&pid);
- size_t size = sizeof(pid);
- bool error = false;
- int attempts = 0;
-
- while (size > 0 && !error && attempts < kMaxAttempts)
- {
- ssize_t s = write(writefd, start, size);
-
- if (s < 0)
- {
- error = EAGAIN != errno && EINTR != errno;
- if (error)
- {
- printErrno("Failed to write", "parent");
- }
- }
- else
- {
- start += s;
- size -= s;
- }
- ++attempts;
- }
-
- if (error || 0 != size)
- {
- return false;
- }
-
- bool eof = false;
- char dummy;
- size = sizeof(dummy);
- error = false;
- attempts = 0;
-
- while (size > 0 && !error && !eof && attempts < kMaxAttempts)
- {
- ssize_t s;
-
- s = read(readfd, &dummy, size);
-
- if (s < 0)
- {
- error = EAGAIN != errno && EINTR != errno;
- if (error)
- {
- printErrno("Failed to read", "parent");
- }
- }
- else if (0 == s)
- {
- eof = true;
- }
- else
- {
- size -= s;
- }
- ++attempts;
- }
- if (error || 0 != size)
- {
- return false;
- }
- return true;
-}
-
-
-
-bool waitForChildrenAndSignal(int mProcessNb, int readfd, int writefd)
-{
- if (readfd > writefd)
- {
- fprintf(stderr, "Called with args in wrong order!!\n");
- return false;
- }
-
- bool error;
- int attempts;
- size_t size;
-
- for (int p = 0; p < mProcessNb; ++p)
- {
- bool eof = false;
- pid_t pid;
- char *end = reinterpret_cast<char *>(&pid);
-
- error = false;
- attempts = 0;
- size = sizeof(pid);
-
- while (size > 0 && !error && !eof && attempts < kMaxAttempts)
- {
- ssize_t s;
-
- s = read(readfd, end, size);
-
- if (s < 0)
- {
- error = EAGAIN != errno && EINTR != errno;
- if (error)
- {
- printErrno("Failed to read", "child");
- }
- }
- else if (0 == s)
- {
- eof = true;
- }
- else
- {
- end += s;
- size -= s;
- }
- ++attempts;
- }
-
- if (error || 0 != size)
- {
- return false;
- }
- }
-
- for (int p = 0; p < mProcessNb; ++p)
- {
- char dummy;
-
- error = false;
- attempts = 0;
- size = sizeof(dummy);
-
- while (size > 0 && !error && attempts < kMaxAttempts)
- {
- ssize_t s = write(writefd, &dummy, size);
-
- if (s < 0)
- {
- error = EAGAIN != errno && EINTR != errno;
- if (error)
- {
- printErrno("Failed to write", "child");
- }
- }
- else
- {
- size -= s;
- }
- ++attempts;
- }
-
- if (error || 0 != size)
- {
- return false;
- }
- }
- return true;
-}
-
-} // namespace android
diff --git a/tests/sdcard/sysutil.h b/tests/sdcard/sysutil.h
deleted file mode 100644
index 3df79c1..0000000
--- a/tests/sdcard/sysutil.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef ANDROID_NATIVETEST_SYSTEM_EXTRAS_TESTS_SDCARD_SYSUTIL_H_
-#define ANDROID_NATIVETEST_SYSTEM_EXTRAS_TESTS_SDCARD_SYSUTIL_H_
-
-#include <stdlib.h>
-namespace android {
-
-// Collection of functions to access the system:
-// .kernelVersion Retrieve the full kernel description.
-// .pidOutOfMemoryAdj Get and set the OOM adj value.
-// .setPidOutOfMemoryAdj
-// .schedFeatures Manipulate the scheduler using debugfs.
-// .newFairSleepers
-// .setNewFairSleepers
-// .disableCpuScaling Set cpu scaling to 'performance'.
-// .forkOrExit Fork a child or exit.
-// .syncAnddropCaches Call sync an drop page/dentries/inodes caches.
-// .fsyncAnddropCaches Call fsync an drop page/dentries/inodes caches.
-// .resetDirectory Delete (non-recursive) files in a directory.
-//
-// IPC function to synchonize a processes with their parent.
-// .writePidAndWaitForReply To instruct the parent the child is ready.
-// Blocks until the parent signals back.
-// .waitForChildrenAndSignal Blocks until all the children have called
-// writePidAndWaitForReply.
-// Then unblock all the children.
-// .waitForChildrenOrExit Wait and exit if a child exit with errors.
-//
-
-// Minimum size for the buffer to retrieve the kernel version.
-static const size_t kMinKernelVersionBufferSize = 256;
-
-// @param str points to the buffer where the kernel version should be
-// added. Must be at least kMinKernelVersionBufferSize chars.
-// @param size of the buffer pointed by str.
-// @return If successful the number of characters inserted in the
-// buffer (not including the trailing '\0' byte). -1 otherwise.
-int kernelVersion(char *str, size_t size);
-
-
-// Return the out of memory adj for this process. /proc/<pid>/oom_adj.
-// @return the oom_adj of the current process. Typically:
-// 0: a regular process. Should die on OOM.
-// -16: system_server level.
-// -17: disable, this process will never be killed.
-// -127: error.
-int pidOutOfMemoryAdj();
-void setPidOutOfMemoryAdj(int level);
-
-// Disable cpu scaling.
-void disableCpuScaling();
-
-
-// Minimum size for the buffer to retrieve the sched features.
-static const size_t kMinSchedFeaturesBufferSize = 256;
-
-// @param str points to the buffer where the sched features should be
-// added. Must be at least kMinSchedFeaturesBufferSize chars.
-// @param size of the buffer pointed by str.
-// @return If successful the number of characters inserted in the
-// buffer (not including the trailing '\0' byte). -1 otherwise.
-int schedFeatures(char *str, size_t size);
-
-// @return true if NEW_FAIR_SLEEPERS is set, false if NO_NEW_FAIR_SLEEPERS is set.
-bool newFairSleepers();
-
-// Turns NEW_FAIR_SLEEPERS on or off.
-void setNewFairSleepers(bool on);
-
-// @return true if NORMALIZED_SLEEPERS is set, false if NO_NORMALIZED_SLEEPERS is set.
-bool normalizedSleepers();
-
-// Turns NORMALIZED_SLEEPERS on or off.
-void setNormalizedSleepers(bool on);
-
-// Filesystem
-
-// Sync and drop caches. Sync is needed because dirty objects are not
-// freable.
-// @param code:
-// * 1 To free pagecache.
-// * 2 To free dentries and inodes.
-// * 3 To free pagecache, dentries and inodes.
-void syncAndDropCaches(int code = 3);
-
-// Fsync the given fd and drop caches. Fsync is needed because dirty
-// objects are not freable.
-// @param code:
-// * 1 To free pagecache.
-// * 2 To free dentries and inodes.
-// * 3 To free pagecache, dentries and inodes.
-void fsyncAndDropCaches(int fd, int code = 3);
-
-// Delete all the files in the given directory. If the directory does
-// not exist, it is created. Use this at the beginning of a test to
-// make sure you have a clean existing directory, previous run may
-// have crashed and left clutter around.
-void resetDirectory(const char *directory);
-
-// IPC
-
-// Try to fork. exit on failure.
-pid_t forkOrExit();
-
-// Signal our parent we are alive and ready by sending our pid.
-// Then do a blocking read for parent's reply.
-bool writePidAndWaitForReply(int writefd, int readfd);
-
-// Wait for all the children to report their pids.
-// Then unblock them.
-bool waitForChildrenAndSignal(int mProcessNb, int readfd, int writefd);
-
-// Wait for 'num' children to complete.
-// If a child did not exit cleanly, exit.
-void waitForChildrenOrExit(int num);
-
-} // namespace android
-
-#endif // ANDROID_NATIVETEST_SYSTEM_EXTRAS_TESTS_SDCARD_SYSUTIL_H_
diff --git a/tests/sdcard/testcase.cpp b/tests/sdcard/testcase.cpp
deleted file mode 100644
index 06fd71b..0000000
--- a/tests/sdcard/testcase.cpp
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "testcase.h"
-#include <hardware_legacy/power.h> // wake lock
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <linux/fadvise.h>
-
-namespace {
-const bool kVerbose = false;
-}
-
-namespace android_test {
-
-TestCase::TestCase(const char *appName)
- : mTestBody(NULL), mAppName(appName), mDataSize(1000 * 1000),
- mChunkSize(mDataSize), mTreeDepth(8), mIter(20), mNproc(1),
- mType(UNKNOWN_TEST), mDump(false), mCpuScaling(false),
- mSync(NO_SYNC), mFadvice(POSIX_FADV_NORMAL), mTruncateToSize(false),
- mTestTimer(NULL)
-{
- // Make sure the cpu and phone are fully awake. The
- // FULL_WAKE_LOCK was used by java apps and don't do
- // anything. Also the partial wake lock is a nop if the phone
- // is plugged in via USB.
- acquire_wake_lock(PARTIAL_WAKE_LOCK, mAppName);
- mPid = getpid();
- setNewFairSleepers(true);
- setNormalizedSleepers(true);
- if (pipe(mIpc) < 0)
- {
- fprintf(stderr, "pipe failed\n");
- exit(1);
- }
- if (pipe(mIpc + 2) < 0)
- {
- fprintf(stderr, "pipe failed\n");
- exit(1);
- }
-}
-
-TestCase::~TestCase()
-{
- release_wake_lock(mAppName);
- for (int i = 0; i < 4; ++i) close(mIpc[i]);
- delete mTestTimer;
- delete mOpenTimer;
-}
-
-
-bool TestCase::runTest()
-{
- if (UNKNOWN_TEST == mType)
- {
- fprintf(stderr, "No test set.");
- return false;
- }
- for (size_t p = 0; p < mNproc; ++p)
- {
- pid_t childpid = android::forkOrExit();
-
- if (0 == childpid) { // I am a child, run the test.
- mPid = getpid();
- close(mIpc[READ_FROM_CHILD]);
- close(mIpc[WRITE_TO_CHILD]);
-
- if (kVerbose) printf("Child pid: %d\n", mPid);
- if (!mTestBody(this)) {
- printf("Test failed\n");
- }
- char buffer[32000] = {0,};
- char *str = buffer;
- size_t size_left = sizeof(buffer);
-
- testTimer()->sprint(&str, &size_left);
- if(openTimer()->used()) openTimer()->sprint(&str, &size_left);
- if(readTimer()->used()) readTimer()->sprint(&str, &size_left);
- if(writeTimer()->used()) writeTimer()->sprint(&str, &size_left);
- if(syncTimer()->used()) syncTimer()->sprint(&str, &size_left);
- if(truncateTimer()->used()) truncateTimer()->sprint(&str, &size_left);
- if(traverseTimer()->used()) traverseTimer()->sprint(&str, &size_left);
-
- write(mIpc[TestCase::WRITE_TO_PARENT], buffer, str - buffer);
-
-
- close(mIpc[WRITE_TO_PARENT]);
- close(mIpc[READ_FROM_PARENT]);
- exit(EXIT_SUCCESS);
- }
- }
- // I am the parent process
- close(mIpc[WRITE_TO_PARENT]);
- close(mIpc[READ_FROM_PARENT]);
-
- // Block until all the children have reported for
- // duty. Unblock them so they start the work.
- if (!android::waitForChildrenAndSignal(mNproc, mIpc[READ_FROM_CHILD], mIpc[WRITE_TO_CHILD]))
- {
- exit(1);
- }
-
- // Process the output of each child.
- // TODO: handle EINTR
- char buffer[32000] = {0,};
- while(read(mIpc[READ_FROM_CHILD], buffer, sizeof(buffer)) != 0)
- {
- printf("%s", buffer);
- fflush(stdout);
- memset(buffer, 0, sizeof(buffer));
- }
- // Parent is waiting for children to exit.
- android::waitForChildrenOrExit(mNproc);
- return true;
-}
-
-void TestCase::setIter(size_t iter)
-{
- mIter = iter;
-}
-
-void TestCase::createTimers()
-{
- char total_time[80];
-
- snprintf(total_time, sizeof(total_time), "%s_total", mName);
- mTestTimer = new StopWatch(total_time, 1);
- mTestTimer->setDataSize(dataSize());
-
- mOpenTimer = new StopWatch("open", iter() * kReadWriteFactor);
-
- mReadTimer = new StopWatch("read", iter() * dataSize() / chunkSize() * kReadWriteFactor);
- mReadTimer->setDataSize(dataSize());
-
- mWriteTimer = new StopWatch("write", iter() * dataSize() / chunkSize());
- mWriteTimer->setDataSize(dataSize());
-
- mSyncTimer = new StopWatch("sync", iter());
-
- mTruncateTimer = new StopWatch("truncate", iter());
-
- mTraverseTimer = new StopWatch("traversal", iter());
-}
-
-bool TestCase::setTypeFromName(const char *test_name)
-{
- strcpy(mName, test_name);
- if (strcmp(mName, "write") == 0) mType = WRITE;
- if (strcmp(mName, "read") == 0) mType = READ;
- if (strcmp(mName, "read_write") == 0) mType = READ_WRITE;
- if (strcmp(mName, "open_create") == 0) mType = OPEN_CREATE;
- if (strcmp(mName, "traverse") == 0) mType = TRAVERSE;
-
- return UNKNOWN_TEST != mType;
-}
-
-void TestCase::setSync(Sync s)
-{
- mSync = s;
-}
-
-const char *TestCase::syncAsStr() const
-{
- return mSync == NO_SYNC ? "disabled" : (mSync == FSYNC ? "fsync" : "sync");
-}
-
-void TestCase::setFadvise(const char *advice)
-{
- mFadvice = POSIX_FADV_NORMAL;
- if (strcmp(advice, "sequential") == 0)
- {
- mFadvice = POSIX_FADV_SEQUENTIAL;
- }
- else if (strcmp(advice, "random") == 0)
- {
- mFadvice = POSIX_FADV_RANDOM;
- }
- else if (strcmp(advice, "noreuse") == 0)
- {
- mFadvice = POSIX_FADV_NOREUSE;
- }
- else if (strcmp(advice, "willneed") == 0)
- {
- mFadvice = POSIX_FADV_WILLNEED;
- }
- else if (strcmp(advice, "dontneed") == 0)
- {
- mFadvice = POSIX_FADV_DONTNEED;
- }
-}
-
-const char *TestCase::fadviseAsStr() const
-{
- switch (mFadvice) {
- case POSIX_FADV_NORMAL: return "fadv_normal";
- case POSIX_FADV_SEQUENTIAL: return "fadv_sequential";
- case POSIX_FADV_RANDOM: return "fadv_random";
- case POSIX_FADV_NOREUSE: return "fadv_noreuse";
- case POSIX_FADV_WILLNEED: return "fadv_willneed";
- case POSIX_FADV_DONTNEED: return "fadv_dontneed";
- default: return "fadvice_unknown";
- }
-}
-
-
-} // namespace android_test
diff --git a/tests/sdcard/testcase.h b/tests/sdcard/testcase.h
deleted file mode 100644
index e973d9a..0000000
--- a/tests/sdcard/testcase.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-
-#ifndef SYSTEM_EXTRAS_TESTS_SDCARD_TESTCASE_H_
-#define SYSTEM_EXTRAS_TESTS_SDCARD_TESTCASE_H_
-
-#include <stdlib.h>
-#include "stopwatch.h"
-#include "sysutil.h"
-
-namespace android_test {
-
-// Class to group test parameters and implementation.
-// Takes care of forking child processes and wait for them.
-
-class TestCase {
- public:
- enum Type {UNKNOWN_TEST, WRITE, READ, OPEN_CREATE, READ_WRITE, TRAVERSE};
- enum Pipe {READ_FROM_CHILD = 0, WRITE_TO_PARENT, READ_FROM_PARENT, WRITE_TO_CHILD};
- enum Sync {NO_SYNC, FSYNC, SYNC};
-
- // Reads takes less time than writes. This is a basic
- // approximation of how much longer the read tasks must run to
- // terminate roughly at the same time as the write tasks.
- const static int kReadWriteFactor = 5;
-
- TestCase(const char *appName);
-
- ~TestCase();
-
- size_t iter() const { return mIter; }
- void setIter(size_t iter);
-
- size_t nproc() const { return mNproc; }
- void setNproc(size_t val) { mNproc = val; }
-
- size_t dataSize() const { return mDataSize; }
- void setDataSize(size_t val) { mDataSize = val; }
-
- size_t chunkSize() const { return mChunkSize; }
- void setChunkSize(size_t val) { mChunkSize = val; }
-
- size_t treeDepth() const { return mTreeDepth; }
- void setTreeDepth(size_t val) { mTreeDepth = val; }
-
- bool newFairSleepers() const { return mNewFairSleepers; }
- void setNewFairSleepers(bool val) {
- mNewFairSleepers = val;
- android::setNewFairSleepers(val);
- }
-
- bool normalizedSleepers() const { return mNormalizedSleepers; }
- void setNormalizedSleepers(bool val) {
- mNormalizedSleepers = val;
- android::setNormalizedSleepers(val);
- }
-
- Sync sync() const { return mSync; }
- void setSync(Sync s);
- const char *syncAsStr() const;
-
- bool cpuScaling() const { return mCpuScaling; }
- void setCpuScaling() { mCpuScaling = true; }
-
- bool truncateToSize() const { return mTruncateToSize; }
- void setTruncateToSize() { mTruncateToSize = true; }
-
- int fadvise() { return mFadvice; }
- void setFadvise(const char *advice);
- const char *fadviseAsStr() const;
-
- // Print the samples.
- void setDump() { StopWatch::setPrintRawMode(true); }
-
- StopWatch *testTimer() { return mTestTimer; }
- StopWatch *openTimer() { return mOpenTimer; }
- StopWatch *readTimer() { return mReadTimer; }
- StopWatch *writeTimer() { return mWriteTimer; }
- StopWatch *syncTimer() { return mSyncTimer; }
- StopWatch *truncateTimer() { return mTruncateTimer; }
- StopWatch *traverseTimer() { return mTraverseTimer; }
-
- // Fork the children, run the test and wait for them to complete.
- bool runTest();
-
- void signalParentAndWait() {
- if (!android::writePidAndWaitForReply(mIpc[WRITE_TO_PARENT], mIpc[READ_FROM_PARENT])) {
- exit(1);
- }
- }
-
- void createTimers();
- bool setTypeFromName(const char *test_name);
- Type type() const { return mType; }
- pid_t pid() const { return mPid; }
- const char *name() const { return mName; }
-
- // This is set to the function that will actually do the test when
- // the command line arguments have been parsed. The function will
- // be run in one or more child(ren) process(es).
- bool (*mTestBody)(TestCase *);
-private:
- const char *mAppName;
- size_t mDataSize;
- size_t mChunkSize;
- size_t mTreeDepth;
- size_t mIter;
- size_t mNproc;
- pid_t mPid;
- char mName[80];
- Type mType;
-
- bool mDump; // print the raw values instead of a human friendly report.
- bool mCpuScaling; // true, do not turn off cpu scaling.
- Sync mSync;
- int mFadvice;
- // When new files are created, truncate them to the final size.
- bool mTruncateToSize;
-
- bool mNewFairSleepers;
- bool mNormalizedSleepers;
-
- // IPC
- // Parent Child(ren)
- // ---------------------------------------
- // 0: read from child closed
- // 1: closed write to parent
- // 2: closed read from parent
- // 3: write to child closed
- int mIpc[4];
-
- StopWatch *mTestTimer; // Used to time the test overall.
- StopWatch *mOpenTimer; // Used to time the open calls.
- StopWatch *mReadTimer; // Used to time the read calls.
- StopWatch *mWriteTimer; // Used to time the write calls.
- StopWatch *mSyncTimer; // Used to time the sync/fsync calls.
- StopWatch *mTruncateTimer; // Used to time the ftruncate calls.
- StopWatch *mTraverseTimer; // Used to time each traversal.
-};
-
-} // namespace android_test
-
-#endif // SYSTEM_EXTRAS_TESTS_SDCARD_TESTCASE_H_
diff --git a/tests/storage/Android.bp b/tests/storage/Android.bp
new file mode 100644
index 0000000..ba9bf1f
--- /dev/null
+++ b/tests/storage/Android.bp
@@ -0,0 +1,19 @@
+// Copyright 2013 The Android Open Source Project
+
+cc_binary {
+ name: "opentest",
+ srcs: ["opentest.c"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
+
+cc_binary {
+ name: "wipe_blkdev",
+ srcs: ["wipe_blkdev.c"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
diff --git a/tests/storage/Android.mk b/tests/storage/Android.mk
deleted file mode 100644
index 41bbd66..0000000
--- a/tests/storage/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2013 The Android Open Source Project
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := opentest.c
-LOCAL_MODULE := opentest
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_MODULE_TAGS := optional
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := wipe_blkdev.c
-LOCAL_MODULE := wipe_blkdev
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_MODULE_TAGS := optional
-include $(BUILD_EXECUTABLE)
-
diff --git a/tests/suspend_stress/Android.bp b/tests/suspend_stress/Android.bp
new file mode 100644
index 0000000..d3ead96
--- /dev/null
+++ b/tests/suspend_stress/Android.bp
@@ -0,0 +1,13 @@
+cc_binary {
+ name: "suspend_stress",
+ srcs: ["suspend_stress.cpp"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+ static_executable: true,
+ static_libs: [
+ "libc",
+ "libcutils",
+ ],
+}
diff --git a/tests/suspend_stress/Android.mk b/tests/suspend_stress/Android.mk
deleted file mode 100644
index 952f50f..0000000
--- a/tests/suspend_stress/Android.mk
+++ /dev/null
@@ -1,9 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := suspend_stress.cpp
-LOCAL_MODULE := suspend_stress
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-LOCAL_STATIC_LIBRARIES := libc libcutils
-include $(BUILD_EXECUTABLE)
diff --git a/tests/tcp_nuke_addr/Android.bp b/tests/tcp_nuke_addr/Android.bp
new file mode 100644
index 0000000..316fd3a
--- /dev/null
+++ b/tests/tcp_nuke_addr/Android.bp
@@ -0,0 +1,8 @@
+cc_test {
+ name: "tcp_nuke_addr_test",
+ srcs: ["tcp_nuke_addr_test.cpp"],
+ cppflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
diff --git a/tests/tcp_nuke_addr/Android.mk b/tests/tcp_nuke_addr/Android.mk
deleted file mode 100644
index f45677e..0000000
--- a/tests/tcp_nuke_addr/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := tcp_nuke_addr_test
-
-LOCAL_C_INCLUDES += frameworks/native/include external/libcxx/include
-LOCAL_CPPFLAGS += -Wall -Werror
-LOCAL_SHARED_LIBRARIES := libc++
-LOCAL_SRC_FILES := tcp_nuke_addr_test.cpp
-LOCAL_MODULE_TAGS := eng tests
-
-include $(BUILD_NATIVE_TEST)
diff --git a/tests/timetest/Android.bp b/tests/timetest/Android.bp
index 998faef..481610b 100644
--- a/tests/timetest/Android.bp
+++ b/tests/timetest/Android.bp
@@ -1,17 +1,28 @@
// Copyright 2006 The Android Open Source Project
cc_test {
- name: "time-unit-tests",
- cflags: [
- "-fstack-protector-all",
- "-g",
- "-Wextra",
- "-fno-builtin",
- ],
- srcs: [
- "rtc_test.cpp",
- ],
- shared_libs: [
- "libbase",
- ],
+ name: "time-unit-tests",
+ cflags: [
+ "-fstack-protector-all",
+ "-g",
+ "-Wextra",
+ "-fno-builtin",
+ ],
+ srcs: [
+ "rtc_test.cpp",
+ ],
+ shared_libs: [
+ "libbase",
+ ],
+}
+
+cc_test {
+ name: "timetest",
+ srcs: ["timetest.c"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+ static_executable: true,
+ static_libs: ["libc"],
}
diff --git a/tests/timetest/Android.mk b/tests/timetest/Android.mk
deleted file mode 100644
index be311fa..0000000
--- a/tests/timetest/Android.mk
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2006 The Android Open Source Project
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := timetest.c
-LOCAL_MODULE := timetest
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_MODULE_TAGS := tests
-LOCAL_FORCE_STATIC_EXECUTABLE := true
-LOCAL_STATIC_LIBRARIES := libc
-include $(BUILD_NATIVE_TEST)
diff --git a/tests/uevents/Android.bp b/tests/uevents/Android.bp
new file mode 100644
index 0000000..a292ebc
--- /dev/null
+++ b/tests/uevents/Android.bp
@@ -0,0 +1,10 @@
+cc_binary {
+ name: "uevents",
+ srcs: ["uevents.c"],
+ shared_libs: ["libcutils"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-unused-parameter",
+ ],
+}
diff --git a/tests/uevents/Android.mk b/tests/uevents/Android.mk
deleted file mode 100644
index 46e712d..0000000
--- a/tests/uevents/Android.mk
+++ /dev/null
@@ -1,11 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := uevents.c
-
-LOCAL_SHARED_LIBRARIES += libcutils
-LOCAL_MODULE:= uevents
-
-LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter
-
-include $(BUILD_EXECUTABLE)
diff --git a/verity/Android.bp b/verity/Android.bp
new file mode 100644
index 0000000..2c7cda7
--- /dev/null
+++ b/verity/Android.bp
@@ -0,0 +1,85 @@
+cc_binary_host {
+ name: "generate_verity_key",
+ srcs: ["generate_verity_key.c"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+
+ shared_libs: [
+ "libcrypto_utils",
+ "libcrypto",
+ ],
+}
+
+java_library_host {
+ name: "VeritySigner",
+ srcs: [
+ "VeritySigner.java",
+ "Utils.java",
+ ],
+ manifest: "VeritySigner.mf",
+
+ static_libs: ["bouncycastle"],
+}
+
+java_library_host {
+ name: "BootSignature",
+ srcs: [
+ "BootSignature.java",
+ "VeritySigner.java",
+ "Utils.java",
+ ],
+ manifest: "BootSignature.mf",
+
+ static_libs: ["bouncycastle"],
+}
+
+cc_binary_host {
+ name: "verity_verifier",
+ srcs: ["verity_verifier.cpp"],
+
+ target: {
+ darwin: {
+ enabled: false,
+ },
+ },
+
+ sanitize: {
+ misc_undefined: ["integer"],
+ },
+ static_libs: [
+ "libfec",
+ "libfec_rs",
+ "libcrypto_utils",
+ "libcrypto",
+ "libext4_utils",
+ "libsparse",
+ "libsquashfs_utils",
+ "libbase",
+ "libz",
+ ],
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
+
+cc_binary_host {
+ name: "build_verity_tree",
+ srcs: ["build_verity_tree.cpp"],
+
+ static_libs: [
+ "libsparse",
+ "libz",
+ ],
+ shared_libs: [
+ "libcrypto",
+ "libbase",
+ ],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ ],
+}
diff --git a/verity/Android.mk b/verity/Android.mk
index 2e4ac27..4cf136a 100644
--- a/verity/Android.mk
+++ b/verity/Android.mk
@@ -1,52 +1,6 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
-LOCAL_MODULE := generate_verity_key
-LOCAL_SRC_FILES := generate_verity_key.c
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_MODULE_CLASS := EXECUTABLES
-LOCAL_MODULE_TAGS := optional
-LOCAL_SHARED_LIBRARIES := libcrypto_utils libcrypto
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := VeritySigner.java Utils.java
-LOCAL_MODULE := VeritySigner
-LOCAL_JAR_MANIFEST := VeritySigner.mf
-LOCAL_MODULE_TAGS := optional
-LOCAL_STATIC_JAVA_LIBRARIES := bouncycastle-host
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := BootSignature.java VeritySigner.java Utils.java
-LOCAL_MODULE := BootSignature
-LOCAL_JAR_MANIFEST := BootSignature.mf
-LOCAL_MODULE_TAGS := optional
-LOCAL_STATIC_JAVA_LIBRARIES := bouncycastle-host
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := verity_verifier.cpp
-LOCAL_MODULE := verity_verifier
-LOCAL_MODULE_CLASS := EXECUTABLES
-LOCAL_MODULE_HOST_OS := linux
-LOCAL_IS_HOST_MODULE := true
-LOCAL_MODULE_TAGS := optional
-LOCAL_SANITIZE := integer
-LOCAL_STATIC_LIBRARIES := \
- libfec \
- libfec_rs \
- libcrypto_utils \
- libcrypto \
- libext4_utils \
- libsparse \
- libsquashfs_utils \
- libbase \
- libz
-LOCAL_CFLAGS := -Wall -Werror
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
LOCAL_SRC_FILES := verity_signer
LOCAL_MODULE := verity_signer
LOCAL_MODULE_CLASS := EXECUTABLES
@@ -71,14 +25,3 @@
LOCAL_IS_HOST_MODULE := true
LOCAL_MODULE_TAGS := optional
include $(BUILD_PREBUILT)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := build_verity_tree
-LOCAL_SRC_FILES := build_verity_tree.cpp
-LOCAL_MODULE_TAGS := optional
-LOCAL_STATIC_LIBRARIES := libsparse libz
-LOCAL_SHARED_LIBRARIES := libcrypto libbase
-LOCAL_CFLAGS += -Wall -Werror
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(call first-makefiles-under,$(LOCAL_PATH))
diff --git a/verity/build_verity_tree.cpp b/verity/build_verity_tree.cpp
index e841c20..ad812ed 100644
--- a/verity/build_verity_tree.cpp
+++ b/verity/build_verity_tree.cpp
@@ -90,7 +90,7 @@
return 0;
}
-int hash_chunk(void *priv, const void *data, int len)
+int hash_chunk(void *priv, const void *data, size_t len)
{
struct sparse_hash_ctx *ctx = (struct sparse_hash_ctx *)priv;
assert(len % ctx->block_size == 0);
@@ -101,7 +101,7 @@
ctx->salt, ctx->salt_size, ctx->block_size);
ctx->hashes += s;
} else {
- for (size_t i = 0; i < (size_t)len; i += ctx->block_size) {
+ for (size_t i = 0; i < len; i += ctx->block_size) {
memcpy(ctx->hashes, ctx->zero_block_hash, ctx->hash_size);
ctx->hashes += ctx->hash_size;
}
diff --git a/verity/fec/Android.bp b/verity/fec/Android.bp
new file mode 100644
index 0000000..823404b
--- /dev/null
+++ b/verity/fec/Android.bp
@@ -0,0 +1,33 @@
+cc_binary_host {
+ name: "fec",
+
+ target: {
+ linux_glibc: {
+ sanitize: {
+ misc_undefined: ["integer"],
+ },
+ },
+ },
+
+ srcs: [
+ "main.cpp",
+ "image.cpp",
+ ],
+
+ static_libs: [
+ "libsparse",
+ "libz",
+ "libcrypto_utils",
+ "libcrypto",
+ "libfec",
+ "libfec_rs",
+ "libext4_utils",
+ "libsquashfs_utils",
+ ],
+ shared_libs: ["libbase"],
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-O3",
+ ],
+}
diff --git a/verity/fec/Android.mk b/verity/fec/Android.mk
deleted file mode 100644
index 8273d0d..0000000
--- a/verity/fec/Android.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-ifeq ($(HOST_OS),linux)
-LOCAL_SANITIZE := integer
-endif
-LOCAL_MODULE := fec
-LOCAL_SRC_FILES := main.cpp image.cpp
-LOCAL_MODULE_TAGS := optional
-LOCAL_STATIC_LIBRARIES := \
- libsparse \
- libz \
- libcrypto_utils \
- libcrypto \
- libfec \
- libfec_rs \
- libext4_utils \
- libsquashfs_utils
-LOCAL_SHARED_LIBRARIES := libbase
-LOCAL_CFLAGS += -Wall -Werror -O3
-LOCAL_C_INCLUDES += external/fec
-include $(BUILD_HOST_EXECUTABLE)
diff --git a/verity/fec/image.cpp b/verity/fec/image.cpp
index 861ca60..58853cf 100644
--- a/verity/fec/image.cpp
+++ b/verity/fec/image.cpp
@@ -77,7 +77,7 @@
ctx->rounds = fec_div_round_up(ctx->blocks, ctx->rs_n);
}
-static int process_chunk(void *priv, const void *data, int len)
+static int process_chunk(void *priv, const void *data, size_t len)
{
image *ctx = (image *)priv;
assert(len % FEC_BLOCKSIZE == 0);
diff --git a/zram-perf/Android.bp b/zram-perf/Android.bp
new file mode 100644
index 0000000..7b20537
--- /dev/null
+++ b/zram-perf/Android.bp
@@ -0,0 +1,12 @@
+cc_binary {
+ name: "zram-perf",
+ cflags: [
+ "-g",
+ "-Wall",
+ "-Werror",
+ "-Wno-missing-field-initializers",
+ "-Wno-sign-compare",
+ "-Wno-unused-parameter",
+ ],
+ srcs: ["zram-perf.cpp"],
+}
diff --git a/zram-perf/Android.mk b/zram-perf/Android.mk
deleted file mode 100644
index 581c759..0000000
--- a/zram-perf/Android.mk
+++ /dev/null
@@ -1,8 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := zram-perf
-LOCAL_CFLAGS += -g -Wall -Werror -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-parameter
-LOCAL_SRC_FILES := \
- zram-perf.cpp
-include $(BUILD_EXECUTABLE)