├── .gitignore ├── ANRdaemon ├── ANRdaemon.cpp ├── ANRdaemon_get_trace.sh ├── Android.mk └── README ├── Android.mk ├── CleanSpec.mk ├── alloc-stress ├── Android.mk └── alloc-stress.cpp ├── boot_control_copy ├── Android.mk ├── NOTICE ├── boot_control_copy.c ├── bootinfo.c └── bootinfo.h ├── bootctl ├── Android.mk ├── NOTICE └── bootctl.c ├── brillo_config └── Android.mk ├── cppreopts ├── Android.mk ├── cppreopts.rc └── cppreopts.sh ├── cpustats ├── Android.mk ├── NOTICE └── cpustats.c ├── crypto-perf ├── Android.mk ├── NOTICE └── crypto.cpp ├── ext4_utils ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── allocate.c ├── allocate.h ├── blk_alloc_to_base_fs.c ├── contents.c ├── contents.h ├── crc16.c ├── ext2simg.c ├── ext4.h ├── ext4_crypt.cpp ├── ext4_crypt.h ├── ext4_crypt_init_extensions.cpp ├── ext4_crypt_init_extensions.h ├── ext4_extents.h ├── ext4_kernel_headers.h ├── ext4_sb.c ├── ext4_sb.h ├── ext4_utils.c ├── ext4_utils.h ├── ext4fixup.c ├── ext4fixup.h ├── ext4fixup_main.c ├── extent.c ├── extent.h ├── indirect.c ├── indirect.h ├── jbd2.h ├── key_control.cpp ├── key_control.h ├── make_ext4fs.c ├── make_ext4fs.h ├── make_ext4fs_main.c ├── mkuserimg.sh ├── setup_fs.c ├── sha1.c ├── sha1.h ├── test_ext4fixup ├── wipe.c ├── wipe.h └── xattr.h ├── f2fs_utils ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── f2fs_dlutils.c ├── f2fs_ioutils.c ├── f2fs_sparseblock.c ├── f2fs_sparseblock.h ├── f2fs_utils.c ├── make_f2fs.h ├── make_f2fs_main.c └── mkf2fsuserimg.sh ├── iotop ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── iotop.cpp ├── tasklist.cpp ├── tasklist.h ├── taskstats.cpp └── taskstats.h ├── kexec_tools ├── Android.mk ├── NOTICE ├── kexec.h └── kexecload.c ├── ksmutils ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── ksminfo.c └── lookup3.c ├── latencytop ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE └── latencytop.c ├── libfec ├── Android.mk ├── NOTICE ├── fec_open.cpp ├── fec_private.h ├── fec_process.cpp ├── fec_read.cpp ├── fec_verity.cpp ├── include │ └── fec │ │ ├── ecc.h │ │ └── io.h └── test │ ├── Android.mk │ ├── test_read.cpp │ └── test_rs.c ├── libpagemap ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── include │ └── pagemap │ │ └── pagemap.h ├── pagemap_test.cpp ├── pm_kernel.c ├── pm_map.c ├── pm_map.h ├── pm_memusage.c └── pm_process.c ├── librank ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE └── librank.c ├── memcpy-perf ├── Android.mk ├── NOTICE ├── graph_memcpy.py ├── memcpy-perf.cpp └── test-funcs.cpp ├── memory_replay ├── Action.cpp ├── Action.h ├── Android.mk ├── LineBuffer.cpp ├── LineBuffer.h ├── NOTICE ├── NativeInfo.cpp ├── NativeInfo.h ├── Pointers.cpp ├── Pointers.h ├── Thread.cpp ├── Thread.h ├── Threads.cpp ├── Threads.h ├── dumps │ ├── README │ ├── camera.zip │ ├── gmail.zip │ ├── maps.zip │ ├── surfaceflinger.zip │ ├── system_server.zip │ ├── systemui.zip │ └── youtube.zip ├── fast │ └── .clang-format ├── main.cpp └── tests │ ├── ActionTest.cpp │ ├── LineBufferTest.cpp │ ├── NativeInfoTest.cpp │ ├── PointersTest.cpp │ ├── ThreadTest.cpp │ └── ThreadsTest.cpp ├── memtrack ├── Android.mk ├── NOTICE ├── memtrack.cpp └── memtrack.h ├── micro_bench ├── Android.mk ├── NOTICE └── micro_bench.cpp ├── mkimage ├── Android.mk ├── crc32.c ├── image.h └── mkimage.c ├── mmap-perf ├── Android.mk ├── NOTICE ├── mmapPerf.cpp └── unsupported.cpp ├── multinetwork ├── Android.mk ├── common.cpp ├── common.h ├── dnschk.cpp ├── httpurl.cpp └── quick_test.sh ├── pagecache ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE ├── README ├── dumpcache.c └── pagecache.py ├── perfprofd ├── Android.mk ├── NOTICE ├── configreader.cc ├── configreader.h ├── cpuconfig.cc ├── cpuconfig.h ├── perf_data_converter.cc ├── perf_data_converter.h ├── perf_profile.proto ├── perfprofd.conf ├── perfprofd.rc ├── perfprofdcore.cc ├── perfprofdcore.h ├── perfprofdmain.cc ├── perfprofdutils.cc ├── perfprofdutils.h ├── quipper │ ├── address_mapper.cc │ ├── address_mapper.h │ ├── base │ │ ├── basictypes.h │ │ ├── compiler_specific.h │ │ ├── logging.cc │ │ ├── logging.h │ │ ├── macros.h │ │ └── port.h │ ├── build │ │ └── build_config.h │ ├── kernel-headers │ │ └── tools │ │ │ └── perf │ │ │ ├── perf.h │ │ │ └── util │ │ │ ├── build-id.h │ │ │ ├── event.h │ │ │ ├── header.h │ │ │ ├── include │ │ │ └── linux │ │ │ │ ├── bitops.h │ │ │ │ ├── kernel │ │ │ │ └── kernel.h │ │ │ │ └── types.h │ │ │ ├── target.h │ │ │ └── types.h │ ├── original-kernel-headers │ │ └── tools │ │ │ └── perf │ │ │ ├── perf.h │ │ │ └── util │ │ │ ├── build-id.h │ │ │ ├── event.h │ │ │ ├── header.h │ │ │ ├── include │ │ │ └── linux │ │ │ │ ├── bitops.h │ │ │ │ ├── kernel │ │ │ │ └── kernel.h │ │ │ │ └── types.h │ │ │ ├── target.h │ │ │ └── types.h │ ├── perf_internals.h │ ├── perf_parser.cc │ ├── perf_parser.h │ ├── perf_reader.cc │ ├── perf_reader.h │ ├── perf_utils.cc │ ├── perf_utils.h │ ├── quipper_string.h │ └── quipper_test.h └── tests │ ├── Android.mk │ ├── README.txt │ ├── canned.perf.data │ ├── perfprofd_test.cc │ ├── perfprofdmockutils.cc │ └── perfprofdmockutils.h ├── postinst ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE └── postinst.sh ├── preopt2cachename ├── Android.mk └── preopt2cachename.cpp ├── procmem ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE └── procmem.c ├── procrank ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE └── procrank.c ├── puncture_fs ├── Android.mk ├── NOTICE └── puncture_fs.c ├── sane_schedstat ├── Android.mk ├── NOTICE └── sane_schedstat.c ├── showmap ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE └── showmap.cpp ├── showslab ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE └── showslab.c ├── simpleperf ├── Android.mk ├── NOTICE ├── build_id.h ├── callchain.cpp ├── callchain.h ├── cmd_dumprecord.cpp ├── cmd_dumprecord_test.cpp ├── cmd_help.cpp ├── cmd_list.cpp ├── cmd_list_test.cpp ├── cmd_record.cpp ├── cmd_record_test.cpp ├── cmd_report.cpp ├── cmd_report_test.cpp ├── cmd_stat.cpp ├── cmd_stat_test.cpp ├── command.cpp ├── command.h ├── command_test.cpp ├── cpu_hotplug_test.cpp ├── dso.cpp ├── dso.h ├── dwarf_unwind.cpp ├── dwarf_unwind.h ├── environment.cpp ├── environment.h ├── environment_fake.cpp ├── environment_test.cpp ├── event_attr.cpp ├── event_attr.h ├── event_fd.cpp ├── event_fd.h ├── event_selection_set.cpp ├── event_selection_set.h ├── event_type.cpp ├── event_type.h ├── event_type_table.h ├── generate_event_type_table.py ├── get_test_data.h ├── gtest_main.cpp ├── main.cpp ├── nonlinux_support │ ├── include │ │ ├── asm │ │ │ └── byteorder.h │ │ └── linux │ │ │ ├── ioctl.h │ │ │ └── types.h │ └── nonlinux_support.cpp ├── perf_event.h ├── perf_regs.cpp ├── perf_regs.h ├── read_apk.cpp ├── read_apk.h ├── read_apk_test.cpp ├── read_elf.cpp ├── read_elf.h ├── read_elf_test.cpp ├── record.cpp ├── record.h ├── record_equal_test.h ├── record_file.h ├── record_file_format.h ├── record_file_reader.cpp ├── record_file_test.cpp ├── record_file_writer.cpp ├── record_test.cpp ├── report.py ├── runtest │ ├── Android.build.mk │ ├── Android.mk │ ├── comm_change.cpp │ ├── function_fork.cpp │ ├── function_indirect_recursive.cpp │ ├── function_pthread.cpp │ ├── function_recursive.cpp │ ├── one_function.cpp │ ├── runtest.conf │ ├── runtest.py │ └── two_functions.cpp ├── sample_tree.cpp ├── sample_tree.h ├── sample_tree_test.cpp ├── scoped_signal_handler.h ├── test_util.h ├── testdata │ ├── data │ │ └── app │ │ │ └── com.example.hellojni-1 │ │ │ └── base.apk │ ├── elf │ ├── elf_file_source.cpp │ ├── has_embedded_native_libs_apk_perf.data │ ├── perf.data │ ├── perf_b.data │ └── perf_g_fp.data ├── thread_tree.cpp ├── thread_tree.h ├── utils.cpp ├── utils.h ├── workload.cpp ├── workload.h └── workload_test.cpp ├── slideshow ├── Android.mk ├── NOTICE └── slideshow.cpp ├── sound ├── Android.mk ├── NOTICE └── playwav.c ├── squashfs_utils ├── Android.mk ├── NOTICE ├── mksquashfsimage.sh ├── squashfs_utils.c └── squashfs_utils.h ├── systrace_analysis ├── analysis.html └── analyze_trace.py ├── taskstats ├── Android.mk ├── MODULE_LICENSE_APACHE2 ├── NOTICE └── taskstats.c ├── tests ├── Android.mk ├── NOTICE ├── audio │ ├── Android.mk │ └── alsa │ │ ├── Android.mk │ │ └── pcmtest.cpp ├── binder │ ├── Android.mk │ └── benchmarks │ │ ├── Android.mk │ │ └── binderAddInts.cpp ├── bootloader │ ├── bootctl.py │ ├── haltest.py │ └── shelltest.py ├── cpueater │ ├── Android.mk │ ├── NOTICE │ ├── cpueater.c │ └── daemonize.c ├── crypto │ ├── Android.mk │ └── get_dm_versions.c ├── directiotest │ ├── Android.mk │ └── directiotest.c ├── ext4 │ ├── Android.mk │ ├── android_emmc_perf_tests.sh │ └── rand_emmc_perf.c ├── framebuffer │ ├── Android.mk │ ├── fb_test.c │ ├── minui.h │ └── refresh.c ├── fstest │ ├── Android.mk │ └── recovery_test.cpp ├── icachetest │ ├── Android.mk │ ├── icache.S │ ├── icache2.S │ └── icache_main.c ├── include │ └── testUtil.h ├── iptables │ ├── Android.mk │ └── qtaguid │ │ ├── Android.mk │ │ └── socketTag.cpp ├── kernel.config │ ├── Android.mk │ ├── AndroidTest.xml │ ├── aslr_rec_test.cpp │ ├── aslr_test.cpp │ ├── aslr_test.h │ ├── logger_test.cpp │ ├── mmc_max_speed_test.cpp │ ├── multicast_test.cpp │ ├── pstore_test.cpp │ ├── scrape_mmap_addr.cpp │ └── sysvipc_test.cpp ├── lib │ ├── Android.mk │ └── testUtil │ │ ├── Android.mk │ │ └── testUtil.c ├── memtest │ ├── Android.mk │ ├── bandwidth.cpp │ ├── bandwidth.h │ ├── fptest.cpp │ ├── memtest.cpp │ ├── memtest.h │ └── thumb.cpp ├── mmc_tracepoints │ ├── README │ ├── mmc_trace_reduce │ └── mmc_trace_sample_data ├── net_test │ ├── README │ ├── all_tests.sh │ ├── anycast_test.py │ ├── csocket.py │ ├── cstruct.py │ ├── cstruct_test.py │ ├── forwarding_test.py │ ├── iproute.py │ ├── multinetwork_base.py │ ├── multinetwork_test.py │ ├── neighbour_test.py │ ├── net_test.py │ ├── net_test.sh │ ├── netlink.py │ ├── packets.py │ ├── ping6_test.py │ ├── ping6_test.sh │ ├── run_net_test.sh │ ├── sock_diag.py │ ├── sock_diag_test.py │ ├── srcaddr_selection_test.py │ ├── tcp_nuke_addr_test.py │ └── tcp_test.py ├── pagingtest │ ├── Android.mk │ ├── mmap_test.c │ ├── pageinout_test.c │ ├── pagingtest.c │ ├── pagingtest.h │ └── thrashing_test.c ├── pftest │ ├── Android.mk │ └── pftest.c ├── schedtest │ ├── Android.mk │ └── schedtest.c ├── sdcard │ ├── Android.mk │ ├── README │ ├── plot_sdcard.py │ ├── profile_sdcard.sh │ ├── sdcard_perf_test.cpp │ ├── stopwatch.cpp │ ├── stopwatch.h │ ├── sysutil.cpp │ ├── sysutil.h │ ├── testcase.cpp │ └── testcase.h ├── storage │ ├── Android.mk │ ├── opentest.c │ └── wipe_blkdev.c ├── suspend_stress │ ├── Android.mk │ └── suspend_stress.cpp ├── tcp_nuke_addr │ ├── Android.mk │ └── tcp_nuke_addr_test.cpp ├── timetest │ ├── Android.mk │ ├── rtc_test.cpp │ └── timetest.c ├── uevents │ ├── Android.mk │ └── uevents.c ├── wifi │ ├── Android.mk │ └── stress │ │ ├── Android.mk │ │ └── wifiLoadScanAssoc.c └── workloads │ ├── atrace-uncompress.py │ ├── capture.sh │ ├── chromefling.sh │ ├── defs.sh │ ├── feedly-chrome.sh │ ├── powerave.py │ ├── pwrsummary.sh │ ├── pwrtest.sh │ ├── recentfling.sh │ ├── systemapps.sh │ └── youtube.sh ├── verity ├── Android.mk ├── BootSignature.java ├── BootSignature.mf ├── KeystoreSigner.java ├── KeystoreSigner.mf ├── NOTICE ├── Utils.java ├── VeritySigner.java ├── VeritySigner.mf ├── VerityVerifier.java ├── VerityVerifier.mf ├── boot_signer ├── build_verity_metadata.py ├── build_verity_tree.cpp ├── fec │ ├── Android.mk │ ├── image.cpp │ ├── image.h │ ├── main.cpp │ └── tests │ │ └── fec.py ├── generate_verity_key.c ├── keystore_signer ├── verify_boot_signature.c ├── verity_signer └── verity_verifier └── zram-perf ├── Android.mk └── zram-perf.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | /su 2 | -------------------------------------------------------------------------------- /ANRdaemon/ANRdaemon_get_trace.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TRACE_DIR=/data/misc/anrd 4 | TRACE_FILE_PATTEN=dump_of_anrdaemon 5 | 6 | if [ $# -eq 1 ]; then 7 | DEVICE=$(echo "-s $1") 8 | else 9 | DEVICE="" 10 | fi 11 | 12 | PID=$(adb $DEVICE shell "ps | grep anrd") 13 | 14 | if [ $? -ne 0 ]; then 15 | echo "FAILED. ADB failed or Daemon is not running." 16 | exit 1 17 | fi 18 | 19 | PID=$(echo "$PID" | awk '{ print $2 }') 20 | adb $DEVICE shell "kill -s SIGUSR1 $PID" 21 | 22 | TRACE_FILE=$(adb $DEVICE shell "ls $TRACE_DIR \ 23 | grep $TRACE_FILE_PATTEN | tail -n1" | tr -d '\r') 24 | 25 | # Wiat the trace file generation to complete 26 | adb $DEVICE shell "lsof $PID" | grep $TRACE_FILE > /dev/null 27 | while [ $? -eq 0 ]; 28 | do 29 | sleep 1 30 | adb $DEVICE shell "lsof $PID" | grep "$TRACE_FILE" > /dev/null 31 | done 32 | 33 | if [ -z "$TRACE_FILE" ]; then 34 | echo "FAILED. Trace file not created" 35 | fi 36 | 37 | adb $DEVICE pull "${TRACE_DIR}/${TRACE_FILE}" ${TRACE_FILE} 38 | 39 | CURRENT_DIR=$(pwd) 40 | echo SUCCEED! 41 | echo Trace stored at ${CURRENT_DIR}/${TRACE_FILE} 42 | -------------------------------------------------------------------------------- /ANRdaemon/Android.mk: -------------------------------------------------------------------------------- 1 | ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT))) 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | 5 | include $(CLEAR_VARS) 6 | LOCAL_SRC_FILES := ANRdaemon.cpp 7 | LOCAL_C_INCLUDES += external/zlib 8 | LOCAL_MODULE := anrd 9 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 10 | LOCAL_MODULE_TAGS := debug 11 | LOCAL_SHARED_LIBRARIES := \ 12 | libbinder \ 13 | libcutils \ 14 | libutils \ 15 | libz 16 | include $(BUILD_EXECUTABLE) 17 | 18 | endif 19 | -------------------------------------------------------------------------------- /ANRdaemon/README: -------------------------------------------------------------------------------- 1 | ANRdaemon is a daemon to help analyze ANR due to CPU starvation by logging system 2 | activity when CPU usage is very high. The daemon uses debugfs underlying for 3 | logging. Trace are configured ahead by setting different modules in /d/tracing. 4 | Depending on the CPU usage level, the trace is turn on/off by writting to the 5 | global control /d/trace/trace_on. The raw trace file is stored at 6 | /d/tracing/trace. 7 | 8 | The daemon will be started at boot time and will be running with the following 9 | settings: 10 | $ ANRdaemon -t 9990 sched gfx am 11 | This means tracing will be enabled above 99.90% CPU utilization and will trace 12 | sched, gfx and am modules (See -h for more info). 13 | 14 | Use ANRdaemon_get_trace.sh [device serial] to dump and fetch the compressed trace file. 15 | 16 | The compressed trace file can be parsed using systrace: 17 | $ systrace.py --from-file= 18 | 19 | Known issue: in the systrace output, anrdaemon will show up when the trace is 20 | not running. This is because the daemon process turns off tracing when CPU usage 21 | drops, the last entry it leaves in the raw trace file is the scheduler switched 22 | from some other process to the daemon. Then sometime later (say 20 secs later), 23 | when the CPU usage becomes high and the daemon process turn on tracing again, 24 | the first entry in /d/tracing/trace logged by sched is switching away from the 25 | daemon process to some other process. Due to this artifact, when the raw trace 26 | file is parsed by systrace.py, the daemon process is shown as running for the 27 | whole 20secs (because from systrace's view, the two 20 sec apart sched trace 28 | entries regarding the daemon process indicates the daemon process ran continuously 29 | for all 20sec). However, this will not affect the actual captured trace during 30 | high CPU usage case. 31 | -------------------------------------------------------------------------------- /Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2008 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | include $(all-subdir-makefiles) 18 | -------------------------------------------------------------------------------- /alloc-stress/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_CLANG := true 5 | LOCAL_MODULE := alloc-stress 6 | LOCAL_CFLAGS += -g -Wall -Werror -std=gnu++11 -Wno-missing-field-initializers -Wno-sign-compare 7 | ifneq ($(ENABLE_MEM_CGROUPS),) 8 | LOCAL_CFLAGS += -DENABLE_MEM_CGROUPS 9 | endif 10 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include 11 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/.. 12 | LOCAL_SHARED_LIBRARIES := libhardware libcutils 13 | LOCAL_SRC_FILES := \ 14 | alloc-stress.cpp 15 | include $(BUILD_EXECUTABLE) 16 | -------------------------------------------------------------------------------- /boot_control_copy/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Android Open Source Project 2 | 3 | LOCAL_PATH := $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_SRC_FILES := boot_control_copy.c bootinfo.c 7 | LOCAL_CFLAGS := -Wall -Wno-missing-field-initializers -Wno-unused-parameter 8 | LOCAL_C_INCLUDES := system/core/mkbootimg bootable/recovery 9 | LOCAL_SHARED_LIBRARIES := libcutils 10 | LOCAL_STATIC_LIBRARIES := libfs_mgr 11 | 12 | LOCAL_MODULE_RELATIVE_PATH := hw 13 | LOCAL_MODULE:= bootctrl.default 14 | include $(BUILD_SHARED_LIBRARY) 15 | -------------------------------------------------------------------------------- /bootctl/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Android Open Source Project 2 | 3 | LOCAL_PATH := $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_SRC_FILES := bootctl.c 7 | LOCAL_SHARED_LIBRARIES := libhardware 8 | LOCAL_MODULE := bootctl 9 | LOCAL_C_INCLUDES = hardware/libhardware/include 10 | LOCAL_CFLAGS := -Wno-unused-parameter 11 | 12 | include $(BUILD_EXECUTABLE) 13 | -------------------------------------------------------------------------------- /cppreopts/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:= $(call my-dir) 16 | 17 | # Create the cppreopts that does the copy 18 | include $(CLEAR_VARS) 19 | 20 | LOCAL_MODULE:= cppreopts.sh 21 | LOCAL_MODULE_CLASS := EXECUTABLES 22 | LOCAL_INIT_RC := cppreopts.rc 23 | LOCAL_SRC_FILES := cppreopts.sh 24 | 25 | LOCAL_REQUIRED_MODULES := preopt2cachename 26 | 27 | include $(BUILD_PREBUILT) 28 | -------------------------------------------------------------------------------- /cppreopts/cppreopts.rc: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | on property:sys.cppreopt=requested && property:ro.boot.slot_suffix=_a 16 | mount ext4 /dev/block/bootdevice/by-name/system_b /postinstall ro nosuid nodev noexec 17 | exec - root -- /system/bin/cppreopts.sh /postinstall 18 | # Optional script to copy additional preloaded content to data directory 19 | exec - system system -- /system/bin/preloads_copy.sh /postinstall 20 | umount /postinstall 21 | setprop sys.cppreopt finished 22 | 23 | on property:sys.cppreopt=requested && property:ro.boot.slot_suffix=_b 24 | mount ext4 /dev/block/bootdevice/by-name/system_a /postinstall ro nosuid nodev noexec 25 | exec - root -- /system/bin/cppreopts.sh /postinstall 26 | # Optional script to copy additional preloaded content to data directory 27 | exec - system system -- /system/bin/preloads_copy.sh /postinstall 28 | umount /postinstall 29 | setprop sys.cppreopt finished 30 | -------------------------------------------------------------------------------- /cpustats/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_SRC_FILES := cpustats.c 5 | 6 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 7 | LOCAL_MODULE_TAGS := debug 8 | LOCAL_MODULE := cpustats 9 | 10 | include $(BUILD_EXECUTABLE) 11 | -------------------------------------------------------------------------------- /crypto-perf/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | ifeq ($(TARGET_ARCH),arm64) 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_CFLAGS := -O0 -march=armv8-a+crypto 6 | LOCAL_SRC_FILES := crypto.cpp 7 | 8 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 9 | LOCAL_MODULE_TAGS := debug 10 | LOCAL_MODULE := crypto 11 | 12 | include $(BUILD_EXECUTABLE) 13 | endif 14 | -------------------------------------------------------------------------------- /ext4_utils/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/ext4_utils/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /ext4_utils/contents.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _DIRECTORY_H_ 18 | #define _DIRECTORY_H_ 19 | 20 | struct dentry { 21 | char *path; 22 | char *full_path; 23 | const char *filename; 24 | char *link; 25 | unsigned long size; 26 | u8 file_type; 27 | u16 mode; 28 | u16 uid; 29 | u16 gid; 30 | u32 *inode; 31 | u32 mtime; 32 | char *secon; 33 | uint64_t capabilities; 34 | }; 35 | 36 | u32 make_directory(u32 dir_inode_num, u32 entries, struct dentry *dentries, 37 | u32 dirs); 38 | u32 make_file(const char *filename, u64 len); 39 | u32 make_link(const char *link); 40 | int inode_set_permissions(u32 inode_num, u16 mode, u16 uid, u16 gid, u32 mtime); 41 | int inode_set_selinux(u32 inode_num, const char *secon); 42 | int inode_set_capabilities(u32 inode_num, uint64_t capabilities); 43 | struct block_allocation* get_saved_allocation_chain(); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /ext4_utils/ext4_crypt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | __BEGIN_DECLS 22 | 23 | bool e4crypt_is_native(); 24 | 25 | int e4crypt_policy_ensure(const char *directory, 26 | const char* policy, size_t policy_length, 27 | const char* contents_encryption_mode); 28 | 29 | static const char* e4crypt_unencrypted_folder = "/unencrypted"; 30 | static const char* e4crypt_key_ref = "/unencrypted/ref"; 31 | static const char* e4crypt_key_mode = "/unencrypted/mode"; 32 | 33 | __END_DECLS 34 | -------------------------------------------------------------------------------- /ext4_utils/ext4_crypt_init_extensions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | __BEGIN_DECLS 22 | 23 | // These functions assume they are being called from init 24 | // They will not operate properly outside of init 25 | int e4crypt_install_keyring(); 26 | int e4crypt_create_device_key(const char* path, 27 | int ensure_dir_exists(const char* dir)); 28 | int e4crypt_set_directory_policy(const char* path); 29 | int e4crypt_do_init_user0(); 30 | 31 | __END_DECLS 32 | -------------------------------------------------------------------------------- /ext4_utils/ext4_kernel_headers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _EXT4_UTILS_EXT4_KERNEL_HEADERS_H_ 18 | #define _EXT4_UTILS_EXT4_KERNEL_HEADERS_H_ 19 | 20 | #include 21 | 22 | #ifdef __BIONIC__ 23 | #include 24 | #else 25 | #define __le64 uint64_t 26 | #define __le32 uint32_t 27 | #define __le16 uint16_t 28 | 29 | #define __be64 uint64_t 30 | #define __be32 uint32_t 31 | #define __be16 uint16_t 32 | 33 | #define __u64 uint64_t 34 | #define __u32 uint32_t 35 | #define __u16 uint16_t 36 | #define __u8 uint8_t 37 | #endif 38 | 39 | #include "ext4.h" 40 | #include "xattr.h" 41 | #include "ext4_extents.h" 42 | #include "jbd2.h" 43 | 44 | #ifndef __BIONIC__ 45 | #undef __le64 46 | #undef __le32 47 | #undef __le16 48 | 49 | #undef __be64 50 | #undef __be32 51 | #undef __be16 52 | 53 | #undef __u64 54 | #undef __u32 55 | #undef __u16 56 | #undef __u8 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /ext4_utils/ext4_sb.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include "ext4_sb.h" 20 | 21 | int ext4_parse_sb(struct ext4_super_block *sb, struct fs_info *info) 22 | { 23 | uint64_t len_blocks; 24 | 25 | if (sb->s_magic != EXT4_SUPER_MAGIC) 26 | return -EINVAL; 27 | 28 | info->block_size = 1024 << sb->s_log_block_size; 29 | info->blocks_per_group = sb->s_blocks_per_group; 30 | info->inodes_per_group = sb->s_inodes_per_group; 31 | info->inode_size = sb->s_inode_size; 32 | info->inodes = sb->s_inodes_count; 33 | info->feat_ro_compat = sb->s_feature_ro_compat; 34 | info->feat_compat = sb->s_feature_compat; 35 | info->feat_incompat = sb->s_feature_incompat; 36 | info->bg_desc_reserve_blocks = sb->s_reserved_gdt_blocks; 37 | info->label = sb->s_volume_name; 38 | 39 | len_blocks = ((uint64_t)sb->s_blocks_count_hi << 32) + 40 | sb->s_blocks_count_lo; 41 | info->len = (uint64_t)info->block_size * len_blocks; 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /ext4_utils/ext4_sb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _EXT4_UTILS_EXT4_SB_H_ 18 | #define _EXT4_UTILS_EXT4_SB_H_ 19 | 20 | #include "ext4_kernel_headers.h" 21 | 22 | #define EXT4_SUPER_MAGIC 0xEF53 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | #include 29 | 30 | struct fs_info { 31 | int64_t len; /* If set to 0, ask the block device for the size, 32 | * if less than 0, reserve that much space at the 33 | * end of the partition, else use the size given. */ 34 | uint32_t block_size; 35 | uint32_t blocks_per_group; 36 | uint32_t inodes_per_group; 37 | uint32_t inode_size; 38 | uint32_t inodes; 39 | uint32_t journal_blocks; 40 | uint16_t feat_ro_compat; 41 | uint16_t feat_compat; 42 | uint16_t feat_incompat; 43 | uint32_t bg_desc_reserve_blocks; 44 | const char *label; 45 | uint8_t no_journal; 46 | bool block_device; /* target fd is a block device? */ 47 | }; 48 | 49 | int ext4_parse_sb(struct ext4_super_block *sb, struct fs_info *info); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /ext4_utils/ext4fixup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | int ext4fixup(char *fsdev); 18 | int ext4fixup_internal(char *fsdev, int v_flag, int n_flag, 19 | int stop_phase, int stop_loc, int stop_count); 20 | 21 | -------------------------------------------------------------------------------- /ext4_utils/ext4fixup_main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "ext4fixup.h" 22 | 23 | static void usage(char *me) 24 | { 25 | fprintf(stderr, "%s: usage: %s [-vn] \n", me, me); 26 | } 27 | 28 | int main(int argc, char **argv) 29 | { 30 | int opt; 31 | int verbose = 0; 32 | int no_write = 0; 33 | char *fsdev; 34 | char *me; 35 | int stop_phase = 0, stop_loc = 0, stop_count = 0; 36 | 37 | me = basename(argv[0]); 38 | 39 | while ((opt = getopt(argc, argv, "vnd:")) != -1) { 40 | switch (opt) { 41 | case 'v': 42 | verbose = 1; 43 | break; 44 | case 'n': 45 | no_write = 1; 46 | break; 47 | case 'd': 48 | sscanf(optarg, "%d,%d,%d", &stop_phase, &stop_loc, &stop_count); 49 | break; 50 | } 51 | } 52 | 53 | if (optind >= argc) { 54 | fprintf(stderr, "expected image or block device after options\n"); 55 | usage(me); 56 | exit(EXIT_FAILURE); 57 | } 58 | 59 | fsdev = argv[optind++]; 60 | 61 | if (optind < argc) { 62 | fprintf(stderr, "Unexpected argument: %s\n", argv[optind]); 63 | usage(me); 64 | exit(EXIT_FAILURE); 65 | } 66 | 67 | return ext4fixup_internal(fsdev, verbose, no_write, stop_phase, stop_loc, stop_count); 68 | } 69 | -------------------------------------------------------------------------------- /ext4_utils/extent.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _EXTENT_H_ 18 | #define _EXTENT_H_ 19 | 20 | #include "allocate.h" 21 | #include "ext4_utils.h" 22 | 23 | void inode_allocate_extents(struct ext4_inode *inode, u64 len); 24 | struct block_allocation* inode_allocate_file_extents( 25 | struct ext4_inode *inode, u64 len, const char *filename); 26 | u8 *inode_allocate_data_extents(struct ext4_inode *inode, u64 len, 27 | u64 backing_len); 28 | void free_extent_blocks(); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /ext4_utils/indirect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _INDIRECT_H_ 18 | #define _INDIRECT_H_ 19 | 20 | #include "allocate.h" 21 | 22 | void inode_allocate_indirect(struct ext4_inode *inode, unsigned long len); 23 | u8 *inode_allocate_data_indirect(struct ext4_inode *inode, unsigned long len, 24 | unsigned long backing_len); 25 | void inode_attach_resize(struct ext4_inode *inode, 26 | struct block_allocation *alloc); 27 | void free_indirect_blocks(); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /ext4_utils/key_control.cpp: -------------------------------------------------------------------------------- 1 | #include "key_control.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | static long keyctl(int cmd, ...) 9 | { 10 | va_list va; 11 | unsigned long arg2, arg3, arg4, arg5; 12 | 13 | va_start(va, cmd); 14 | arg2 = va_arg(va, unsigned long); 15 | arg3 = va_arg(va, unsigned long); 16 | arg4 = va_arg(va, unsigned long); 17 | arg5 = va_arg(va, unsigned long); 18 | va_end(va); 19 | return syscall(__NR_keyctl, cmd, arg2, arg3, arg4, arg5); 20 | } 21 | 22 | key_serial_t add_key(const char *type, 23 | const char *description, 24 | const void *payload, 25 | size_t plen, 26 | key_serial_t ringid) 27 | { 28 | return syscall(__NR_add_key, type, description, payload, plen, ringid); 29 | } 30 | 31 | long keyctl_revoke(key_serial_t id) 32 | { 33 | return keyctl(KEYCTL_REVOKE, id); 34 | } 35 | 36 | long keyctl_setperm(key_serial_t id, int permissions) 37 | { 38 | return keyctl(KEYCTL_SETPERM, id, permissions); 39 | } 40 | 41 | long keyctl_search(key_serial_t ringid, const char *type, 42 | const char *description, key_serial_t destringid) 43 | { 44 | return keyctl(KEYCTL_SEARCH, ringid, type, description, destringid); 45 | } 46 | -------------------------------------------------------------------------------- /ext4_utils/key_control.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | __BEGIN_DECLS 5 | 6 | // ext4enc:TODO - get these keyring standard definitions from proper system file 7 | // keyring serial number type 8 | typedef int32_t key_serial_t; 9 | 10 | // special process keyring shortcut IDs 11 | #define KEY_SPEC_THREAD_KEYRING -1 // key ID for thread-specific keyring 12 | #define KEY_SPEC_PROCESS_KEYRING -2 // key ID for process-specific keyring 13 | #define KEY_SPEC_SESSION_KEYRING -3 // key ID for session-specific keyring 14 | #define KEY_SPEC_USER_KEYRING -4 // key ID for UID-specific keyring 15 | #define KEY_SPEC_USER_SESSION_KEYRING -5 // key ID for UID-session keyring 16 | #define KEY_SPEC_GROUP_KEYRING -6 // key ID for GID-specific keyring 17 | 18 | key_serial_t add_key(const char *type, 19 | const char *description, 20 | const void *payload, 21 | size_t plen, 22 | key_serial_t ringid); 23 | 24 | long keyctl_revoke(key_serial_t id); 25 | 26 | long keyctl_setperm(key_serial_t id, int permissions); 27 | 28 | long keyctl_search(key_serial_t ringid, const char *type, 29 | const char *description, key_serial_t destringid); 30 | 31 | __END_DECLS 32 | -------------------------------------------------------------------------------- /ext4_utils/make_ext4fs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _MAKE_EXT4FS_H_ 18 | #define _MAKE_EXT4FS_H_ 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | struct selabel_handle; 25 | 26 | int make_ext4fs(const char *filename, long long len, 27 | const char *mountpoint, struct selabel_handle *sehnd); 28 | int make_ext4fs_directory(const char *filename, long long len, 29 | const char *mountpoint, struct selabel_handle *sehnd, 30 | const char *directory); 31 | int make_ext4fs_sparse_fd(int fd, long long len, 32 | const char *mountpoint, struct selabel_handle *sehnd); 33 | int make_ext4fs_sparse_fd_directory(int fd, long long len, 34 | const char *mountpoint, struct selabel_handle *sehnd, 35 | const char *directory); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /ext4_utils/sha1.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: sha1.h,v 1.13 2005/12/26 18:41:36 perry Exp $ */ 2 | 3 | /* 4 | * SHA-1 in C 5 | * By Steve Reid 6 | * 100% Public Domain 7 | */ 8 | 9 | #ifndef _SYS_SHA1_H_ 10 | #define _SYS_SHA1_H_ 11 | 12 | #include 13 | #include 14 | 15 | #ifdef USE_MINGW 16 | typedef unsigned char u_char; 17 | typedef unsigned int uint32_t; 18 | typedef unsigned int u_int32_t; 19 | typedef unsigned int u_int; 20 | 21 | #define __BEGIN_DECLS 22 | #define __END_DECLS 23 | #else 24 | #include 25 | #endif 26 | 27 | #define SHA1_DIGEST_LENGTH 20 28 | #define SHA1_DIGEST_STRING_LENGTH 41 29 | 30 | typedef struct { 31 | uint32_t state[5]; 32 | uint32_t count[2]; 33 | u_char buffer[64]; 34 | } SHA1_CTX; 35 | 36 | __BEGIN_DECLS 37 | void SHA1Transform(uint32_t[5], const u_char[64]); 38 | void SHA1Init(SHA1_CTX *); 39 | void SHA1Update(SHA1_CTX *, const u_char *, u_int); 40 | void SHA1Final(u_char[SHA1_DIGEST_LENGTH], SHA1_CTX *); 41 | __END_DECLS 42 | 43 | #endif /* _SYS_SHA1_H_ */ 44 | -------------------------------------------------------------------------------- /ext4_utils/test_ext4fixup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | typeset -i I ITERATIONS PHASE LOC COUNT MAXCOUNT 4 | 5 | ME=`basename $0` 6 | 7 | if [ "$#" -ne 3 ] 8 | then 9 | echo "$ME: Usage: $ME " >&2 10 | exit 1; 11 | fi 12 | 13 | ITERATIONS="$1" 14 | MAXCOUNT="$2" 15 | ORIG_FS_IMAGE="$3" 16 | FIXED_FS_IMAGE="/tmp/fixedfsimage.$$" 17 | NEW_FS_IMAGE="/tmp/newfsimage.$$" 18 | 19 | if [ ! -f "$ORIG_FS_IMAGE" ] 20 | then 21 | echo "$ME: Filesystem image $NEW_FS_IMAGE does not exist" >&2 22 | exit 1 23 | fi 24 | 25 | trap "rm -f $NEW_FS_IMAGE $FIXED_FS_IMAGE" 0 1 2 3 15 26 | 27 | rm -f "$NEW_FS_IMAGE" "$FIXED_FS_IMAGE" 28 | 29 | # Create the fixed image to compare against 30 | cp "$ORIG_FS_IMAGE" "$FIXED_FS_IMAGE" 31 | ext4fixup "$FIXED_FS_IMAGE" 32 | 33 | if [ "$?" -ne 0 ] 34 | then 35 | echo "$ME: ext4fixup failed!\n" 36 | exit 1 37 | fi 38 | 39 | I=0 40 | while [ "$I" -lt "$ITERATIONS" ] 41 | do 42 | # There is also a phase 4, which is writing out the updated superblocks and 43 | # block group descriptors. Test the with a separate script. 44 | let PHASE="$RANDOM"%3 # 0 to 2 45 | let PHASE++ # 1 to 3 46 | let LOC="$RANDOM"%2 # 0 to 1 47 | let LOC++ # 1 to 2 48 | let COUNT="$RANDOM"%"$MAXCOUNT" 49 | 50 | # Make a copy of the original image to fixup 51 | cp "$ORIG_FS_IMAGE" "$NEW_FS_IMAGE" 52 | 53 | # Run the fixup tool, but die partway through to see if we can recover 54 | ext4fixup -d "$PHASE,$LOC,$COUNT" "$NEW_FS_IMAGE" 2>/dev/null 55 | 56 | # run it again without -d to have it finish the job 57 | ext4fixup "$NEW_FS_IMAGE" 58 | 59 | if cmp "$FIXED_FS_IMAGE" "$NEW_FS_IMAGE" 60 | then 61 | : 62 | else 63 | echo "$ME: test failed with parameters $PHASE, $LOC, $COUNT" 64 | exit 1 65 | fi 66 | 67 | rm -f "$NEW_FS_IMAGE" 68 | 69 | let I++ 70 | done 71 | 72 | -------------------------------------------------------------------------------- /ext4_utils/wipe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _WIPE_H_ 18 | #define _WIPE_H_ 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | #include "ext4_utils.h" 25 | 26 | /* Set WIPE_IS_SUPPORTED to 1 if the current platform supports 27 | * wiping of block devices. 0 otherwise. For now, only Linux does. 28 | */ 29 | #ifdef __linux__ 30 | # define WIPE_IS_SUPPORTED 1 31 | #else 32 | # define WIPE_IS_SUPPORTED 0 33 | #endif 34 | 35 | int wipe_block_device(int fd, s64 len); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /ext4_utils/xattr.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef _SYSTEM_EXTRAS_EXT4_UTILS_XATTR_H 4 | #define _SYSTEM_EXTRAS_EXT4_UTILS_XATTR_H 1 5 | 6 | #define EXT4_XATTR_MAGIC 0xEA020000 7 | #define EXT4_XATTR_INDEX_SECURITY 6 8 | 9 | struct ext4_xattr_header { 10 | __le32 h_magic; 11 | __le32 h_refcount; 12 | __le32 h_blocks; 13 | __le32 h_hash; 14 | __le32 h_checksum; 15 | __u32 h_reserved[3]; 16 | }; 17 | 18 | struct ext4_xattr_ibody_header { 19 | __le32 h_magic; 20 | }; 21 | 22 | struct ext4_xattr_entry { 23 | __u8 e_name_len; 24 | __u8 e_name_index; 25 | __le16 e_value_offs; 26 | __le32 e_value_block; 27 | __le32 e_value_size; 28 | __le32 e_hash; 29 | char e_name[0]; 30 | }; 31 | 32 | #define EXT4_XATTR_PAD_BITS 2 33 | #define EXT4_XATTR_PAD (1<e_name_len))) 41 | #define EXT4_XATTR_SIZE(size) \ 42 | (((size) + EXT4_XATTR_ROUND) & ~EXT4_XATTR_ROUND) 43 | #define IS_LAST_ENTRY(entry) (*(uint32_t *)(entry) == 0) 44 | 45 | #endif /* !_SYSTEM_EXTRAS_EXT4_UTILS_XATTR_H */ 46 | -------------------------------------------------------------------------------- /f2fs_utils/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/f2fs_utils/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /f2fs_utils/make_f2fs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _MAKE_F2FS_H_ 18 | #define _MAKE_F2FS_H_ 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | struct selabel_handle; 25 | 26 | int make_f2fs_sparse_fd(int fd, long long len, 27 | const char *mountpoint, struct selabel_handle *sehnd); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /f2fs_utils/mkf2fsuserimg.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # To call this script, make sure make_f2fs is somewhere in PATH 4 | 5 | function usage() { 6 | cat< 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #include "tasklist.h" 29 | 30 | template 31 | static bool ScanPidsInDir(std::string name, Func f) { 32 | std::unique_ptr dir(opendir(name.c_str()), closedir); 33 | if (!dir) { 34 | return false; 35 | } 36 | 37 | dirent* entry; 38 | while ((entry = readdir(dir.get())) != nullptr) { 39 | if (isdigit(entry->d_name[0])) { 40 | pid_t pid = atoi(entry->d_name); 41 | f(pid); 42 | } 43 | } 44 | 45 | return true; 46 | } 47 | 48 | bool TaskList::Scan(std::map>& tgid_map) { 49 | tgid_map.clear(); 50 | 51 | return ScanPidsInDir("/proc", [&tgid_map](pid_t tgid) { 52 | std::vector pid_list; 53 | if (ScanPid(tgid, pid_list)) { 54 | tgid_map.insert({tgid, pid_list}); 55 | } 56 | }); 57 | } 58 | 59 | bool TaskList::ScanPid(pid_t tgid, std::vector& pid_list) { 60 | std::string filename = android::base::StringPrintf("/proc/%d/task", tgid); 61 | 62 | return ScanPidsInDir(filename, [&pid_list](pid_t pid) { 63 | pid_list.push_back(pid); 64 | }); 65 | } 66 | -------------------------------------------------------------------------------- /iotop/tasklist.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 The Android Open Source Project 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | 18 | #ifndef _IOTOP_TASKLIST_H 19 | #define _IOTOP_TASKLIST_H 20 | 21 | class TaskList { 22 | public: 23 | static bool Scan(std::map>&); 24 | 25 | private: 26 | TaskList() {} 27 | static bool ScanPid(pid_t pid, std::vector&); 28 | }; 29 | 30 | #endif // _IOTOP_TASKLIST_H 31 | -------------------------------------------------------------------------------- /kexec_tools/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2013 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # Copyright The Android Open Source Project 15 | 16 | LOCAL_PATH := $(call my-dir) 17 | 18 | include $(CLEAR_VARS) 19 | LOCAL_MODULE := kexecload 20 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 21 | LOCAL_MODULE_TAGS := eng 22 | LOCAL_SRC_FILES := kexecload.c 23 | include $(BUILD_EXECUTABLE) 24 | -------------------------------------------------------------------------------- /kexec_tools/kexec.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_KEXEC_H 2 | #define _SYS_KEXEC_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "kexec.h" 9 | 10 | #define KEXEC_SEGMENT_MAX 16 11 | 12 | #define KEXEC_TYPE_DEFAULT 0 13 | #define KEXEC_TYPE_CRASH 1 14 | 15 | /* 16 | * Prototypes 17 | */ 18 | 19 | static inline long kexec_load(unsigned int entry, unsigned long nr_segments, 20 | struct kexec_segment *segment, unsigned long flags) { 21 | return syscall(__NR_kexec_load, entry, nr_segments, segment, flags); 22 | } 23 | 24 | #endif /* _SYS_KEXEC_H */ 25 | -------------------------------------------------------------------------------- /ksmutils/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2013 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:= $(call my-dir) 16 | 17 | include $(CLEAR_VARS) 18 | LOCAL_SRC_FILES := ksminfo.c lookup3.c 19 | LOCAL_SHARED_LIBRARIES := libpagemap 20 | LOCAL_MODULE := ksminfo 21 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 22 | LOCAL_MODULE_TAGS := debug 23 | include $(BUILD_EXECUTABLE) 24 | -------------------------------------------------------------------------------- /ksmutils/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/ksmutils/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /latencytop/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:= $(call my-dir) 16 | include $(CLEAR_VARS) 17 | 18 | LOCAL_SRC_FILES := latencytop.c 19 | 20 | LOCAL_MODULE := latencytop 21 | 22 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 23 | 24 | LOCAL_MODULE_TAGS := debug 25 | 26 | LOCAL_CFLAGS := -Wno-unused-parameter 27 | 28 | include $(BUILD_EXECUTABLE) 29 | -------------------------------------------------------------------------------- /latencytop/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/latencytop/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /libfec/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Android Open Source Project 2 | # 3 | LOCAL_PATH := $(call my-dir) 4 | 5 | common_cflags := -Wall -Werror -O3 6 | 7 | common_c_includes := \ 8 | $(LOCAL_PATH)/include \ 9 | external/fec \ 10 | system/extras/ext4_utils \ 11 | system/extras/squashfs_utils 12 | 13 | common_src_files := \ 14 | fec_open.cpp \ 15 | fec_read.cpp \ 16 | fec_verity.cpp \ 17 | fec_process.cpp 18 | 19 | common_static_libraries := \ 20 | libcrypto_utils_static \ 21 | libcrypto_static \ 22 | libcutils \ 23 | libbase 24 | 25 | include $(CLEAR_VARS) 26 | LOCAL_CFLAGS := $(common_cflags) 27 | LOCAL_C_INCLUDES := $(common_c_includes) 28 | LOCAL_CLANG := true 29 | LOCAL_SANITIZE := integer 30 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include 31 | LOCAL_MODULE := libfec 32 | LOCAL_SRC_FILES := $(common_src_files) 33 | LOCAL_STATIC_LIBRARIES := \ 34 | libfec_rs \ 35 | libext4_utils_static \ 36 | libsquashfs_utils \ 37 | libcutils \ 38 | $(common_static_libraries) 39 | include $(BUILD_STATIC_LIBRARY) 40 | 41 | include $(CLEAR_VARS) 42 | LOCAL_CFLAGS := $(common_cflags) -D_GNU_SOURCE -DFEC_NO_KLOG 43 | LOCAL_C_INCLUDES := $(common_c_includes) 44 | LOCAL_CLANG := true 45 | ifeq ($(HOST_OS),linux) 46 | LOCAL_SANITIZE := integer 47 | endif 48 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include 49 | LOCAL_MODULE := libfec_host 50 | LOCAL_SRC_FILES := $(common_src_files) 51 | LOCAL_STATIC_LIBRARIES := \ 52 | libfec_rs_host \ 53 | libext4_utils_host \ 54 | libsquashfs_utils_host \ 55 | $(common_static_libraries) 56 | include $(BUILD_HOST_STATIC_LIBRARY) 57 | 58 | include $(LOCAL_PATH)/test/Android.mk 59 | -------------------------------------------------------------------------------- /libfec/test/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | ifeq ($(HOST_OS),linux) 4 | 5 | include $(CLEAR_VARS) 6 | LOCAL_CLANG := true 7 | LOCAL_SANITIZE := integer 8 | LOCAL_MODULE := fec_test_read 9 | LOCAL_SRC_FILES := test_read.cpp 10 | LOCAL_MODULE_TAGS := optional 11 | LOCAL_STATIC_LIBRARIES := \ 12 | libfec_host \ 13 | libfec_rs_host \ 14 | libcrypto_utils_static \ 15 | libcrypto_static \ 16 | libext4_utils_host \ 17 | libsquashfs_utils_host \ 18 | libbase 19 | LOCAL_CFLAGS := -Wall -Werror -D_GNU_SOURCE 20 | include $(BUILD_HOST_EXECUTABLE) 21 | 22 | include $(CLEAR_VARS) 23 | LOCAL_CLANG := true 24 | LOCAL_SANITIZE := integer 25 | LOCAL_MODULE := fec_test_rs 26 | LOCAL_SRC_FILES := test_rs.c 27 | LOCAL_MODULE_TAGS := optional 28 | LOCAL_STATIC_LIBRARIES := libfec_rs_host 29 | LOCAL_CFLAGS := -Wall -Werror -D_GNU_SOURCE 30 | LOCAL_C_INCLUDES += external/fec 31 | include $(BUILD_HOST_EXECUTABLE) 32 | 33 | endif # HOST_OS == linux 34 | -------------------------------------------------------------------------------- /libfec/test/test_read.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | using namespace std; 24 | const unsigned bufsize = 2 * 1024 * FEC_BLOCKSIZE; 25 | 26 | int main(int argc, char **argv) 27 | { 28 | if (argc != 3) { 29 | cerr << "usage: " << argv[0] << " input output" << endl; 30 | return 1; 31 | } 32 | 33 | unique_ptr buffer(new (nothrow) uint8_t[bufsize]); 34 | 35 | if (!buffer) { 36 | cerr << "failed to allocate buffer" << endl; 37 | return 1; 38 | } 39 | 40 | fec::io input(argv[1]); 41 | 42 | if (!input) { 43 | return 1; 44 | } 45 | 46 | ofstream output(argv[2], ios::binary | ios::trunc); 47 | 48 | if (!output) { 49 | cerr << "failed to open " << argv[2] << endl; 50 | return 1; 51 | } 52 | 53 | ssize_t count; 54 | 55 | do { 56 | count = input.read(buffer.get(), bufsize); 57 | 58 | if (count == -1) { 59 | return 1; 60 | } else if (count > 0) { 61 | output.write(reinterpret_cast(buffer.get()), count); 62 | 63 | if (!output) { 64 | cerr << "write" << endl; 65 | return 1; 66 | } 67 | } 68 | } while (count > 0); 69 | 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /libpagemap/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH := $(call my-dir) 16 | 17 | pagemap_src_files := \ 18 | pm_kernel.c \ 19 | pm_process.c \ 20 | pm_map.c \ 21 | pm_memusage.c \ 22 | 23 | include $(CLEAR_VARS) 24 | LOCAL_MODULE := libpagemap 25 | LOCAL_MODULE_TAGS := debug 26 | LOCAL_SRC_FILES := $(pagemap_src_files) 27 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/include 28 | LOCAL_CFLAGS := -Wno-unused-parameter 29 | LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include 30 | include $(BUILD_SHARED_LIBRARY) 31 | 32 | include $(CLEAR_VARS) 33 | LOCAL_MODULE := pagemap_test 34 | LOCAL_SRC_FILES := pagemap_test.cpp 35 | LOCAL_SHARED_LIBRARIES := libpagemap 36 | include $(BUILD_NATIVE_TEST) 37 | -------------------------------------------------------------------------------- /libpagemap/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/libpagemap/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /libpagemap/pagemap_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include 20 | 21 | #include 22 | 23 | TEST(pagemap, maps) { 24 | pm_kernel_t* kernel; 25 | ASSERT_EQ(0, pm_kernel_create(&kernel)); 26 | 27 | pm_process_t* process; 28 | ASSERT_EQ(0, pm_process_create(kernel, getpid(), &process)); 29 | 30 | pm_map_t** maps; 31 | size_t num_maps; 32 | ASSERT_EQ(0, pm_process_maps(process, &maps, &num_maps)); 33 | 34 | bool found_heap = false; 35 | bool found_stack = false; 36 | for (size_t i = 0; i < num_maps; i++) { 37 | std::string name(maps[i]->name); 38 | if (name == "[heap]" || name == "[anon:libc_malloc]") found_heap = true; 39 | if (name == "[stack]") found_stack = true; 40 | } 41 | 42 | ASSERT_TRUE(found_heap); 43 | ASSERT_TRUE(found_stack); 44 | 45 | free(maps); 46 | pm_process_destroy(process); 47 | pm_kernel_destroy(kernel); 48 | } 49 | -------------------------------------------------------------------------------- /libpagemap/pm_map.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _LIBS_PAGEMAP_PM_MAP_H 18 | #define _LIBS_PAGEMAP_PM_MAP_H 19 | 20 | #include 21 | 22 | int pm_map_destroy(pm_map_t *map); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /librank/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:= $(call my-dir) 16 | 17 | include $(CLEAR_VARS) 18 | LOCAL_SRC_FILES := librank.c 19 | LOCAL_SHARED_LIBRARIES := libpagemap 20 | LOCAL_MODULE := librank 21 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 22 | LOCAL_MODULE_TAGS := debug 23 | include $(BUILD_EXECUTABLE) 24 | -------------------------------------------------------------------------------- /librank/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/librank/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /memcpy-perf/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_CLANG := true 5 | LOCAL_MODULE := memcpy-perf 6 | LOCAL_CFLAGS += -g -Wall -Werror -std=c++11 -Wno-missing-field-initializers -Wno-sign-compare -O3 7 | LOCAL_SRC_FILES := memcpy-perf.cpp test-funcs.cpp 8 | LOCAL_FORCE_STATIC_EXECUTABLE := true 9 | LOCAL_CXX_STL := libc++_static 10 | LOCAL_STATIC_LIBRARIES := libc 11 | include $(BUILD_EXECUTABLE) 12 | -------------------------------------------------------------------------------- /memcpy-perf/graph_memcpy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import subprocess 3 | import matplotlib.pyplot as plt 4 | import time 5 | import argparse 6 | 7 | parser = argparse.ArgumentParser(description="Graph memcpy perf") 8 | parser.add_argument("--files", nargs='+', type=str, help="files to graph", default=None) 9 | args = parser.parse_args() 10 | 11 | fig, ax = plt.subplots(nrows=1) 12 | ax.set_xscale('log') 13 | 14 | plt.xlabel("size in bytes") 15 | plt.ylabel("BW in GB/s") 16 | plt.title("size vs. bw") 17 | plt.tight_layout() 18 | 19 | for arg in args.files: 20 | f = open(arg) 21 | size = [] 22 | perf = [] 23 | for line in f: 24 | # size: 11430912, perf: 6.76051GB/s, iter: 5 25 | line_split = line.split(",") 26 | size.append(float(line_split[0].split(":")[1])) 27 | perf.append(float(line_split[1].split(":")[1].split("G")[0])) 28 | 29 | line, = ax.plot(size, perf, '-', linewidth=0.2, label=arg) 30 | 31 | legend = plt.legend() 32 | plt.show() 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /memcpy-perf/test-funcs.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void __attribute__((noinline)) memcpy_noinline(void *dst, void *src, size_t size) 4 | { 5 | memcpy(dst,src,size); 6 | } 7 | 8 | void __attribute__((noinline)) memset_noinline(void *dst, int value, size_t size) 9 | { 10 | memset(dst, value, size); 11 | } 12 | 13 | uint64_t __attribute__((noinline)) sum(volatile void *src, size_t size) 14 | { 15 | uint64_t *src_ptr = (uint64_t*)src; 16 | uint64_t sum = 0; 17 | size_t len = size / sizeof(uint64_t); 18 | for (size_t i = 0; i < len; i+=1) 19 | sum += src_ptr[i]; 20 | return sum; 21 | } 22 | -------------------------------------------------------------------------------- /memory_replay/Action.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _MEMORY_REPLAY_ACTION_H 18 | #define _MEMORY_REPLAY_ACTION_H 19 | 20 | #include 21 | 22 | class Pointers; 23 | 24 | class Action { 25 | public: 26 | Action() {} 27 | virtual ~Action() {} 28 | 29 | virtual uint64_t Execute(Pointers* pointers) = 0; 30 | 31 | bool IsError() { return is_error_; }; 32 | 33 | virtual bool EndThread() { return false; } 34 | 35 | virtual bool DoesFree() { return false; } 36 | 37 | static size_t MaxActionSize(); 38 | static Action* CreateAction(uintptr_t key_pointer, const char* type, 39 | const char* line, void* action_memory); 40 | 41 | protected: 42 | bool is_error_ = false; 43 | }; 44 | 45 | #endif // _MEMORY_REPLAY_ACTION_H 46 | -------------------------------------------------------------------------------- /memory_replay/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | memory_replay_src_files := \ 4 | Action.cpp \ 5 | LineBuffer.cpp \ 6 | NativeInfo.cpp \ 7 | Pointers.cpp \ 8 | Thread.cpp \ 9 | Threads.cpp \ 10 | 11 | include $(CLEAR_VARS) 12 | 13 | LOCAL_SRC_FILES := $(memory_replay_src_files) main.cpp 14 | LOCAL_CFLAGS := -Wall -Wextra -Werror 15 | LOCAL_MODULE_TAGS := debug 16 | LOCAL_MODULE := memory_replay 17 | LOCAL_MULTILIB := both 18 | LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32 19 | LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64 20 | include $(BUILD_EXECUTABLE) 21 | 22 | include $(CLEAR_VARS) 23 | 24 | LOCAL_SRC_FILES := $(memory_replay_src_files) main.cpp 25 | LOCAL_CFLAGS := -Wall -Wextra -Werror 26 | LOCAL_MODULE_TAGS := debug 27 | LOCAL_MODULE := memory_replay 28 | LOCAL_MODULE_HOST_OS := linux 29 | LOCAL_LDLIBS := -lrt 30 | include $(BUILD_HOST_EXECUTABLE) 31 | 32 | memory_replay_test_src_files := \ 33 | tests/ActionTest.cpp \ 34 | tests/LineBufferTest.cpp \ 35 | tests/NativeInfoTest.cpp \ 36 | tests/PointersTest.cpp \ 37 | tests/ThreadTest.cpp \ 38 | tests/ThreadsTest.cpp \ 39 | 40 | include $(CLEAR_VARS) 41 | 42 | LOCAL_SRC_FILES := \ 43 | $(memory_replay_src_files) \ 44 | $(memory_replay_test_src_files) \ 45 | 46 | LOCAL_CFLAGS := -Wall -Wextra -Werror 47 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/tests 48 | LOCAL_MODULE_TAGS := debug 49 | LOCAL_MODULE := memory_replay_tests 50 | 51 | LOCAL_SHARED_LIBRARIES := libbase 52 | 53 | LOCAL_MULTILIB := both 54 | LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32 55 | LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64 56 | include $(BUILD_NATIVE_TEST) 57 | 58 | include $(CLEAR_VARS) 59 | 60 | LOCAL_SRC_FILES := \ 61 | $(memory_replay_src_files) \ 62 | $(memory_replay_test_src_files) \ 63 | 64 | LOCAL_CFLAGS := -Wall -Wextra -Werror 65 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/tests 66 | LOCAL_MODULE_TAGS := debug 67 | LOCAL_MODULE := memory_replay_tests 68 | LOCAL_MODULE_HOST_OS := linux 69 | 70 | LOCAL_SHARED_LIBRARIES := libbase 71 | LOCAL_LDLIBS := -lrt 72 | 73 | LOCAL_MULTILIB := both 74 | LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32 75 | LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64 76 | include $(BUILD_HOST_NATIVE_TEST) 77 | 78 | memory_replay_src_files := 79 | memory_replay_test_src_files := 80 | -------------------------------------------------------------------------------- /memory_replay/LineBuffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include "LineBuffer.h" 22 | 23 | LineBuffer::LineBuffer(int fd, char* buffer, size_t buffer_len) : fd_(fd), buffer_(buffer), buffer_len_(buffer_len) { 24 | } 25 | 26 | bool LineBuffer::GetLine(char** line, size_t* line_len) { 27 | while (true) { 28 | if (bytes_ > 0) { 29 | char* newline = reinterpret_cast(memchr(buffer_ + start_, '\n', bytes_)); 30 | if (newline != nullptr) { 31 | *newline = '\0'; 32 | *line = buffer_ + start_; 33 | start_ = newline - buffer_ + 1; 34 | bytes_ -= newline - *line + 1; 35 | *line_len = newline - *line; 36 | return true; 37 | } 38 | } 39 | if (start_ > 0) { 40 | // Didn't find anything, copy the current to the front of the buffer. 41 | memmove(buffer_, buffer_ + start_, bytes_); 42 | start_ = 0; 43 | } 44 | ssize_t bytes = TEMP_FAILURE_RETRY(read(fd_, buffer_ + bytes_, buffer_len_ - bytes_ - 1)); 45 | if (bytes <= 0) { 46 | if (bytes_ > 0) { 47 | // The read data might not contain a nul terminator, so add one. 48 | buffer_[bytes_] = '\0'; 49 | *line = buffer_ + start_; 50 | *line_len = bytes_; 51 | bytes_ = 0; 52 | start_ = 0; 53 | return true; 54 | } 55 | return false; 56 | } 57 | bytes_ += bytes; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /memory_replay/LineBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _MEMORY_REPLAY_LINE_BUFFER_H 18 | #define _MEMORY_REPLAY_LINE_BUFFER_H 19 | 20 | #include 21 | 22 | class LineBuffer { 23 | public: 24 | LineBuffer(int fd, char* buffer, size_t buffer_len); 25 | 26 | bool GetLine(char** line, size_t* line_len); 27 | 28 | private: 29 | int fd_; 30 | char* buffer_ = nullptr; 31 | size_t buffer_len_ = 0; 32 | size_t start_ = 0; 33 | size_t bytes_ = 0; 34 | }; 35 | 36 | #endif // _MEMORY_REPLAY_LINE_BUFFER_H 37 | -------------------------------------------------------------------------------- /memory_replay/NativeInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _MEMORY_REPLAY_NATIVE_INFO_H 18 | #define _MEMORY_REPLAY_NATIVE_INFO_H 19 | 20 | // This function is not re-entrant. 21 | void GetNativeInfo(int smaps_fd, size_t* pss_bytes, size_t* va_bytes); 22 | 23 | // This function is not re-entrant. 24 | void PrintNativeInfo(const char* preamble); 25 | 26 | #endif // _MEMORY_REPLAY_NATIVE_INFO_H 27 | -------------------------------------------------------------------------------- /memory_replay/Pointers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _MEMORY_REPLAY_POINTERS_H 18 | #define _MEMORY_REPLAY_POINTERS_H 19 | 20 | #include 21 | #include 22 | 23 | struct pointer_data { 24 | std::atomic_uintptr_t key_pointer; 25 | void* pointer; 26 | }; 27 | 28 | class Pointers { 29 | public: 30 | Pointers(size_t max_allocs); 31 | virtual ~Pointers(); 32 | 33 | void Add(uintptr_t key_pointer, void* pointer); 34 | 35 | void* Remove(uintptr_t key_pointer); 36 | 37 | size_t max_pointers() { return max_pointers_; } 38 | 39 | void FreeAll(); 40 | 41 | private: 42 | pointer_data* FindEmpty(uintptr_t key_pointer); 43 | pointer_data* Find(uintptr_t key_pointer); 44 | size_t GetHash(uintptr_t key_pointer); 45 | 46 | pointer_data* pointers_ = nullptr; 47 | size_t pointers_size_ = 0; 48 | size_t max_pointers_ = 0; 49 | }; 50 | 51 | #endif // _MEMORY_REPLAY_POINTERS_H 52 | -------------------------------------------------------------------------------- /memory_replay/Thread.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include "Action.h" 20 | #include "Thread.h" 21 | 22 | Thread::Thread() { 23 | pthread_cond_init(&cond_, nullptr); 24 | } 25 | 26 | Thread::~Thread() { 27 | pthread_cond_destroy(&cond_); 28 | } 29 | 30 | void Thread::WaitForReady() { 31 | pthread_mutex_lock(&mutex_); 32 | while (pending_) { 33 | pthread_cond_wait(&cond_, &mutex_); 34 | } 35 | pthread_mutex_unlock(&mutex_); 36 | } 37 | 38 | void Thread::WaitForPending() { 39 | pthread_mutex_lock(&mutex_); 40 | while (!pending_) { 41 | pthread_cond_wait(&cond_, &mutex_); 42 | } 43 | pthread_mutex_unlock(&mutex_); 44 | } 45 | 46 | void Thread::SetPending() { 47 | pthread_mutex_lock(&mutex_); 48 | pending_ = true; 49 | pthread_mutex_unlock(&mutex_); 50 | pthread_cond_signal(&cond_); 51 | } 52 | 53 | void Thread::ClearPending() { 54 | pthread_mutex_lock(&mutex_); 55 | pending_ = false; 56 | pthread_mutex_unlock(&mutex_); 57 | pthread_cond_signal(&cond_); 58 | } 59 | 60 | Action* Thread::CreateAction(uintptr_t key_pointer, const char* type, const char* line) { 61 | return Action::CreateAction(key_pointer, type, line, action_memory_); 62 | } 63 | -------------------------------------------------------------------------------- /memory_replay/Thread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _MEMORY_REPLAY_THREAD_H 18 | #define _MEMORY_REPLAY_THREAD_H 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | class Action; 25 | class Pointers; 26 | 27 | constexpr size_t ACTION_MEMORY_SIZE = 128; 28 | 29 | class Thread { 30 | public: 31 | Thread(); 32 | virtual ~Thread(); 33 | 34 | void WaitForReady(); 35 | void WaitForPending(); 36 | void SetPending(); 37 | void ClearPending(); 38 | 39 | Action* CreateAction(uintptr_t key_pointer, const char* type, const char* line); 40 | void AddTimeNsecs(uint64_t nsecs) { total_time_nsecs_ += nsecs; } 41 | 42 | void set_pointers(Pointers* pointers) { pointers_ = pointers; } 43 | Pointers* pointers() { return pointers_; } 44 | 45 | Action* GetAction() { return reinterpret_cast(action_memory_); } 46 | 47 | private: 48 | pthread_mutex_t mutex_ = PTHREAD_MUTEX_INITIALIZER; 49 | pthread_cond_t cond_; 50 | bool pending_ = false; 51 | 52 | pthread_t thread_id_; 53 | pid_t tid_ = 0; 54 | uint64_t total_time_nsecs_ = 0; 55 | 56 | Pointers* pointers_ = nullptr; 57 | 58 | // Per thread memory for an Action. Only one action can be processed. 59 | // at a time. 60 | static constexpr size_t ACTION_SIZE = 128; 61 | uint8_t action_memory_[ACTION_SIZE]; 62 | 63 | friend class Threads; 64 | }; 65 | 66 | #endif // _MEMORY_REPLAY_THREAD_H 67 | -------------------------------------------------------------------------------- /memory_replay/Threads.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _MEMORY_REPLAY_THREADS_H 18 | #define _MEMORY_REPLAY_THREADS_H 19 | 20 | #include 21 | #include 22 | 23 | class Pointers; 24 | class Thread; 25 | 26 | class Threads { 27 | public: 28 | Threads(Pointers* pointers, size_t max_threads); 29 | virtual ~Threads(); 30 | 31 | Thread* CreateThread(pid_t tid); 32 | Thread* FindThread(pid_t tid); 33 | void WaitForAllToQuiesce(); 34 | void Finish(Thread* thread); 35 | void FinishAll(); 36 | 37 | size_t num_threads() { return num_threads_; } 38 | size_t max_threads() { return max_threads_; } 39 | uint64_t total_time_nsecs() { return total_time_nsecs_; } 40 | 41 | private: 42 | Pointers* pointers_ = nullptr; 43 | Thread* threads_ = nullptr; 44 | size_t data_size_ = 0; 45 | size_t max_threads_ = 0; 46 | size_t num_threads_= 0; 47 | uint64_t total_time_nsecs_ = 0; 48 | 49 | Thread* FindEmptyEntry(pid_t tid); 50 | size_t GetHashEntry(pid_t tid); 51 | 52 | void ClearData(); 53 | 54 | friend Thread; 55 | }; 56 | 57 | #endif // _MEMORY_REPLAY_THREADS_H 58 | -------------------------------------------------------------------------------- /memory_replay/dumps/README: -------------------------------------------------------------------------------- 1 | The files in this directory are a collection of recordings of 2 | the memory allocations of a set of apps. 3 | 4 | In order to run these files through the tool, they will need to be placed 5 | unzipped on the device. 6 | 7 | Format of dumps: 8 | 9 | : [] 10 | 11 | 12 | The pid_t value that is the gettid() value recorded during the run. 13 | 14 | 15 | One of: 16 | malloc - Allocate memory using the malloc function. 17 | calloc - Allocate memory using the calloc function. 18 | memalign - Allocate memory using the memalign function. This is used 19 | during recording for either memalign or posix_memalign. 20 | realloc - Allocate memory using the realloc function. 21 | free - Free memory allocated using one of the above actions. 22 | thread_done - Terminate the thread with the given tid. 23 | 24 | Format of each action: 25 | 26 | : malloc 27 | Allocation made by malloc(). is the value returned by malloc. 28 | 29 | Example: 30 | 31 | 100: malloc 0xb48390a0 48 32 | 33 | : calloc 34 | Allocation made by calloc(, . is the value returned 35 | by calloc. 36 | 37 | Example: 38 | 39 | 200: calloc 0xb48c1100 32 8 40 | 41 | :realloc 42 | Allocation made by realloc(, ). can be 0x0 43 | to indicate a realloc with a nullptr. is the value returned 44 | by realloc. 45 | 46 | Example: 47 | 48 | 300: realloc 0x96b90920 0x93605280 150 49 | 50 | :memalign 51 | Allocation made by memalign(, ). is the value 52 | returned by memalign. 53 | 54 | Example: 55 | 56 | 400: memalign 0xae42d080 16 104 57 | 58 | : free 59 | Find a previously allocated pointer and call free(). 60 | can be 0x0 to indicate the freeing of a nullptr. 61 | 62 | Example: 63 | 64 | 500: free 0xb4827400 65 | 66 | : thread_done 0x0 67 | Indicates that the thread has completed. 68 | 69 | Example: 70 | 71 | 600: thread_done 0x0 72 | -------------------------------------------------------------------------------- /memory_replay/dumps/camera.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/memory_replay/dumps/camera.zip -------------------------------------------------------------------------------- /memory_replay/dumps/gmail.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/memory_replay/dumps/gmail.zip -------------------------------------------------------------------------------- /memory_replay/dumps/maps.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/memory_replay/dumps/maps.zip -------------------------------------------------------------------------------- /memory_replay/dumps/surfaceflinger.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/memory_replay/dumps/surfaceflinger.zip -------------------------------------------------------------------------------- /memory_replay/dumps/system_server.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/memory_replay/dumps/system_server.zip -------------------------------------------------------------------------------- /memory_replay/dumps/systemui.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/memory_replay/dumps/systemui.zip -------------------------------------------------------------------------------- /memory_replay/dumps/youtube.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/memory_replay/dumps/youtube.zip -------------------------------------------------------------------------------- /memory_replay/fast/.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: Google 2 | AllowShortBlocksOnASingleLine: false 3 | AllowShortFunctionsOnASingleLine: false 4 | 5 | ColumnLimit: 100 6 | CommentPragmas: NOLINT:.* 7 | DerivePointerAlignment: false 8 | IndentWidth: 2 9 | ContinuationIndentWidth: 2 10 | PointerAlignment: Left 11 | TabWidth: 2 12 | UseTab: Never 13 | PenaltyExcessCharacter: 32 14 | 15 | Cpp11BracedListStyle: false 16 | -------------------------------------------------------------------------------- /memtrack/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2013 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:= $(call my-dir) 16 | 17 | src_files := \ 18 | memtrack.cpp 19 | 20 | include $(CLEAR_VARS) 21 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 22 | 23 | LOCAL_SRC_FILES := $(src_files) 24 | 25 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 26 | LOCAL_MODULE := memtrack_share 27 | 28 | LOCAL_C_INCLUDES += $(includes) 29 | LOCAL_SHARED_LIBRARIES := \ 30 | liblog \ 31 | 32 | include $(BUILD_EXECUTABLE) 33 | 34 | include $(CLEAR_VARS) 35 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 36 | 37 | LOCAL_SRC_FILES := $(src_files) 38 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 39 | LOCAL_MODULE := memtrack 40 | 41 | LOCAL_FORCE_STATIC_EXECUTABLE := true 42 | LOCAL_STATIC_LIBRARIES := \ 43 | libc \ 44 | liblog \ 45 | libc++abi \ 46 | libdl \ 47 | 48 | LOCAL_CXX_STL := libc++_static 49 | 50 | # Bug: 18389563 - Today, libc++_static and libgcc have duplicate sybols for 51 | # __aeabi_uidiv(). Allowing multiple definitions lets the build proceed, but 52 | # updating compiler-rt to be a superset of libgcc will allow this WAR to be 53 | # removed. 54 | LOCAL_LDFLAGS := -Wl,-z,muldefs 55 | 56 | include $(BUILD_EXECUTABLE) 57 | -------------------------------------------------------------------------------- /micro_bench/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_SRC_FILES := micro_bench.cpp 5 | 6 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 7 | LOCAL_MODULE_TAGS := debug 8 | LOCAL_MODULE := micro_bench 9 | 10 | LOCAL_MULTILIB := both 11 | LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE) 12 | LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64 13 | include $(BUILD_EXECUTABLE) 14 | 15 | include $(CLEAR_VARS) 16 | 17 | LOCAL_SRC_FILES := micro_bench.cpp 18 | 19 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 20 | LOCAL_MODULE_TAGS := debug 21 | LOCAL_MODULE := micro_bench_static 22 | LOCAL_STATIC_LIBRARIES = libc libm 23 | LOCAL_FORCE_STATIC_EXECUTABLE := true 24 | 25 | LOCAL_MULTILIB := both 26 | LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE) 27 | LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64 28 | include $(BUILD_EXECUTABLE) 29 | -------------------------------------------------------------------------------- /mkimage/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_SRC_FILES := mkimage.c crc32.c 5 | LOCAL_MODULE_TAGS := optional 6 | LOCAL_MODULE := mkimage 7 | 8 | include $(BUILD_HOST_EXECUTABLE) 9 | -------------------------------------------------------------------------------- /mmap-perf/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2014 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | LOCAL_PATH:= $(call my-dir) 18 | include $(CLEAR_VARS) 19 | 20 | LOCAL_SRC_FILES := mmapPerf.cpp 21 | LOCAL_MODULE := mmapPerf 22 | LOCAL_MULTILIB := both 23 | LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE) 24 | LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64 25 | LOCAL_CLANG := true 26 | LOCAL_CFLAGS += -g -Wall -Werror -std=c++11 -Wno-missing-field-initializers -Wno-sign-compare -O3 27 | LOCAL_FORCE_STATIC_EXECUTABLE := true 28 | LOCAL_CXX_STL := libc++_static 29 | LOCAL_STATIC_LIBRARIES := libc 30 | include $(BUILD_NATIVE_BENCHMARK) 31 | -------------------------------------------------------------------------------- /mmap-perf/unsupported.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | fprintf(stderr, "mmap-perf is unsupported for 32-bit architectures\n"); 5 | return -1; 6 | } 7 | -------------------------------------------------------------------------------- /multinetwork/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | # The PDK build does not have access to frameworks/native elements. 4 | ifneq ($(TARGET_BUILD_PDK), true) 5 | 6 | # Sample util binaries. 7 | include $(CLEAR_VARS) 8 | LOCAL_MODULE := dnschk 9 | 10 | LOCAL_C_INCLUDES += frameworks/native/include external/libcxx/include 11 | LOCAL_CPPFLAGS += -std=c++11 12 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 13 | LOCAL_MODULE_TAGS := debug 14 | LOCAL_SHARED_LIBRARIES := libandroid libbase libc++ 15 | LOCAL_SRC_FILES := dnschk.cpp common.cpp 16 | include $(BUILD_EXECUTABLE) 17 | 18 | include $(CLEAR_VARS) 19 | LOCAL_MODULE := httpurl 20 | 21 | LOCAL_C_INCLUDES += frameworks/native/include external/libcxx/include 22 | LOCAL_CPPFLAGS += -std=c++11 23 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 24 | LOCAL_MODULE_TAGS := debug 25 | LOCAL_SHARED_LIBRARIES := libandroid libbase libc++ 26 | LOCAL_SRC_FILES := httpurl.cpp common.cpp 27 | include $(BUILD_EXECUTABLE) 28 | 29 | endif # ifneq ($(TARGET_BUILD_PDK), true) 30 | -------------------------------------------------------------------------------- /multinetwork/common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | #ifndef SYSTEM_EXTRAS_MULTINETWORK_COMMON_H_ 19 | #define SYSTEM_EXTRAS_MULTINETWORK_COMMON_H_ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | enum class ApiMode { 28 | EXPLICIT, 29 | PROCESS, 30 | }; 31 | 32 | 33 | struct Arguments { 34 | Arguments() : nethandle(NETWORK_UNSPECIFIED), 35 | api_mode(ApiMode::EXPLICIT), 36 | family(AF_UNSPEC), 37 | arg1(nullptr) {} 38 | ~Arguments(); 39 | 40 | bool parseArguments(int argc, const char* argv[]); 41 | 42 | net_handle_t nethandle; 43 | ApiMode api_mode; 44 | sa_family_t family; 45 | const char* arg1; 46 | }; 47 | 48 | 49 | void printUsage(const char *progname); 50 | 51 | // If port is non-zero returns strings of the form "192.0.2.1:port" or 52 | // "[2001:db8::1]:port", else it returns the bare IP string literal. 53 | std::string inetSockaddrToString(const sockaddr* sa); 54 | 55 | 56 | struct FdAutoCloser { 57 | FdAutoCloser() : fd(-1) {} 58 | /* not explicit */ FdAutoCloser(int fd) : fd(fd) {} 59 | ~FdAutoCloser() { 60 | if (fd > -1) { 61 | close(fd); 62 | } 63 | fd = -1; 64 | } 65 | 66 | int fd; 67 | }; 68 | 69 | #endif // SYSTEM_EXTRAS_MULTINETWORK_COMMON_H_ 70 | -------------------------------------------------------------------------------- /multinetwork/quick_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | nethandle=0 4 | 5 | readonly TEST_HOST="connectivitycheck.gstatic.com" 6 | readonly TEST_PATH="/generate_204" 7 | readonly PREFIX=">>>" 8 | 9 | function getUrls() { 10 | if [ ! -z $(echo "$1" | sed -e 's/[^:]//g') ]; then 11 | echo "http://[$1]$TEST_PATH" 12 | echo "http://[$1]:80$TEST_PATH" 13 | else 14 | echo "http://$1$TEST_PATH" 15 | echo "http://$1:80$TEST_PATH" 16 | fi 17 | } 18 | 19 | function toHex() { 20 | readonly local hexValue=$(bc -q 2>/dev/null << EOT 21 | obase=16 22 | $1 23 | EOT 24 | ) 25 | if [ ! -z "$hexValue" ]; then 26 | echo "0x$hexValue" 27 | fi 28 | } 29 | 30 | 31 | if [ ! -z "$1" ]; then 32 | nethandle="$1" 33 | fi 34 | echo "$PREFIX Using nethandle $nethandle ($(toHex $nethandle))" 35 | echo "" 36 | 37 | readonly IPADDRESSES=$( 38 | adb shell /system/xbin/dnschk --nethandle $nethandle $TEST_HOST | 39 | sed -e 's/#.*//' -e '/^$/d') 40 | 41 | 42 | for host in $TEST_HOST $IPADDRESSES; do 43 | urls=$(getUrls $host) 44 | for url in $urls; do 45 | echo "$PREFIX Checking $url" >&2 46 | adb shell /system/xbin/httpurl --nethandle $nethandle "$url" 47 | done 48 | done 49 | -------------------------------------------------------------------------------- /pagecache/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Android Open Source Project 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_SRC_FILES:= dumpcache.c 7 | LOCAL_SHARED_LIBRARIES := libcutils 8 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 9 | LOCAL_MODULE_TAGS := debug 10 | LOCAL_MODULE:= dumpcache 11 | 12 | include $(BUILD_EXECUTABLE) 13 | 14 | -------------------------------------------------------------------------------- /pagecache/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/pagecache/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /pagecache/README: -------------------------------------------------------------------------------- 1 | Pagecache tools. 2 | 3 | dumpcache.c: dumps complete pagecache of device. 4 | pagecache.py: shows live info on files going in/out of pagecache. 5 | -------------------------------------------------------------------------------- /perfprofd/cpuconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** Copyright 2015, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | // 19 | // Helper class to perform cpu setup (if needed) prior to a profile collection. 20 | // 21 | class HardwireCpuHelper { 22 | public: 23 | 24 | // The constructor for this class checks to see if the 'mpdecision' 25 | // service is running; if so (and if 'perform' is TRUE), then it 26 | // disables the service and on-lines all of the available cores/cpus 27 | // (anything listed in /sys/devices/system/cpu/possible). The 28 | // destructor will re-enable the mpdecision service if it was 29 | // previously disabled. 30 | HardwireCpuHelper(bool perform); 31 | virtual ~HardwireCpuHelper(); 32 | 33 | private: 34 | bool mpdecision_stopped_; 35 | 36 | // Collect the number of available cpus/cores from /sys/devices/system/cpu/possible 37 | int GetNumCores(); 38 | 39 | // Returns TRUE if the system service 'mpdecision' is running 40 | bool GetMpdecisionRunning(); 41 | 42 | // Online/offline the specified cpu 43 | void OnlineCore(int whichCore, int onoff); 44 | 45 | // Enable/disable the mpdecision service via the equivalent of 46 | // setprop ctl.start mpdecision 47 | // setprop ctl.stop mpdecision 48 | void StopMpdecision(); 49 | void RestartMpdecision(); 50 | }; 51 | -------------------------------------------------------------------------------- /perfprofd/perf_data_converter.h: -------------------------------------------------------------------------------- 1 | #ifndef WIRELESS_ANDROID_LOGGING_AWP_PERF_DATA_CONVERTER_H_ 2 | #define WIRELESS_ANDROID_LOGGING_AWP_PERF_DATA_CONVERTER_H_ 3 | 4 | #include "perf_profile.pb.h" 5 | 6 | #include 7 | 8 | namespace wireless_android_logging_awp { 9 | 10 | wireless_android_play_playlog::AndroidPerfProfile 11 | RawPerfDataToAndroidPerfProfile(const std::string &perf_file); 12 | 13 | } // namespace wireless_android_logging_awp 14 | 15 | #endif // WIRELESS_ANDROID_LOGGING_AWP_PERF_DATA_CONVERTER_H_ 16 | -------------------------------------------------------------------------------- /perfprofd/perfprofd.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration file for perf profile collection daemon (perfprofd) 3 | # 4 | #------------------------------------------------------------------------ 5 | # 6 | # Destination directory for profiles 7 | # 8 | destination_directory=/data/misc/perfprofd 9 | # 10 | # Config directory for perfprofd 11 | # 12 | config_directory=/data/data/com.google.android.gms/files 13 | # 14 | # Sampling period (for perf -c option) 15 | # 16 | sampling_period=500000 17 | # 18 | # Average interval to wait between profile collection attempts (seconds) 19 | # 20 | collection_interval=86400 21 | # 22 | # Number of seconds of profile data to collect 23 | # 24 | sample_duration=3 25 | -------------------------------------------------------------------------------- /perfprofd/perfprofd.rc: -------------------------------------------------------------------------------- 1 | service perfprofd /system/xbin/perfprofd 2 | class late_start 3 | user root 4 | group root wakelock 5 | oneshot 6 | writepid /dev/cpuset/system-background/tasks 7 | -------------------------------------------------------------------------------- /perfprofd/perfprofdmain.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** Copyright 2015, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | extern int perfprofd_main(int argc, char** argv); 19 | 20 | int main(int argc, char** argv) 21 | { 22 | return perfprofd_main(argc, argv); 23 | } 24 | -------------------------------------------------------------------------------- /perfprofd/perfprofdutils.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** Copyright 2015, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | #define LOG_TAG "perfprofd" 19 | 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | #include "perfprofdutils.h" 26 | 27 | void perfprofd_log_error(const char *fmt, ...) 28 | { 29 | va_list ap; 30 | va_start(ap, fmt); 31 | LOG_PRI_VA(ANDROID_LOG_ERROR, LOG_TAG, fmt, ap); 32 | va_end(ap); 33 | } 34 | 35 | void perfprofd_log_warning(const char *fmt, ...) 36 | { 37 | va_list ap; 38 | va_start(ap, fmt); 39 | LOG_PRI_VA(ANDROID_LOG_WARN, LOG_TAG, fmt, ap); 40 | va_end(ap); 41 | } 42 | 43 | void perfprofd_log_info(const char *fmt, ...) 44 | { 45 | va_list ap; 46 | va_start(ap, fmt); 47 | LOG_PRI_VA(ANDROID_LOG_INFO, LOG_TAG, fmt, ap); 48 | va_end(ap); 49 | } 50 | 51 | void perfprofd_sleep(int seconds) 52 | { 53 | sleep(seconds); 54 | } 55 | -------------------------------------------------------------------------------- /perfprofd/perfprofdutils.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** Copyright 2015, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | #include 19 | 20 | __BEGIN_DECLS 21 | 22 | // 23 | // These routines are separated out from the core perfprofd so 24 | // as to be used as part of the unit test (see the README.txt 25 | // alongside the unit test for more info). 26 | // 27 | extern void perfprofd_log_error(const char *fmt, ...); 28 | extern void perfprofd_log_warning(const char *fmt, ...); 29 | extern void perfprofd_log_info(const char *fmt, ...); 30 | extern void perfprofd_sleep(int seconds); 31 | 32 | #define W_ALOGE perfprofd_log_error 33 | #define W_ALOGW perfprofd_log_warning 34 | #define W_ALOGI perfprofd_log_info 35 | 36 | __END_DECLS 37 | -------------------------------------------------------------------------------- /perfprofd/quipper/base/port.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef BASE_PORT_H_ 6 | #define BASE_PORT_H_ 7 | 8 | #include 9 | #include "quipper/build/build_config.h" 10 | 11 | // DEPRECATED: Use ...LL and ...ULL suffixes. 12 | // TODO(viettrungluu): Delete these. These are only here until |GG_(U)INT64_C| 13 | // are deleted (some other header files (re)define |GG_(U)INT64_C|, so our 14 | // definitions of them must exactly match theirs). 15 | #ifdef COMPILER_MSVC 16 | #define GG_LONGLONG(x) x##I64 17 | #define GG_ULONGLONG(x) x##UI64 18 | #else 19 | #define GG_LONGLONG(x) x##LL 20 | #define GG_ULONGLONG(x) x##ULL 21 | #endif 22 | 23 | // DEPRECATED: In Chromium, we force-define __STDC_CONSTANT_MACROS, so you can 24 | // just use the regular (U)INTn_C macros from . 25 | // TODO(viettrungluu): Remove the remaining GG_(U)INTn_C macros. 26 | #define GG_INT64_C(x) GG_LONGLONG(x) 27 | #define GG_UINT64_C(x) GG_ULONGLONG(x) 28 | 29 | // It's possible for functions that use a va_list, such as StringPrintf, to 30 | // invalidate the data in it upon use. The fix is to make a copy of the 31 | // structure before using it and use that copy instead. va_copy is provided 32 | // for this purpose. MSVC does not provide va_copy, so define an 33 | // implementation here. It is not guaranteed that assignment is a copy, so the 34 | // StringUtil.VariableArgsFunc unit test tests this capability. 35 | #if defined(COMPILER_GCC) 36 | #define GG_VA_COPY(a, b) (va_copy(a, b)) 37 | #elif defined(COMPILER_MSVC) 38 | #define GG_VA_COPY(a, b) (a = b) 39 | #endif 40 | 41 | // Define an OS-neutral wrapper for shared library entry points 42 | #if defined(OS_WIN) 43 | #define API_CALL __stdcall 44 | #else 45 | #define API_CALL 46 | #endif 47 | 48 | #endif // BASE_PORT_H_ 49 | -------------------------------------------------------------------------------- /perfprofd/quipper/kernel-headers/tools/perf/util/build-id.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef PERF_BUILD_ID_H_ 20 | #define PERF_BUILD_ID_H_ 1 21 | #define BUILD_ID_SIZE 20 22 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 23 | struct dso; 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /perfprofd/quipper/kernel-headers/tools/perf/util/include/linux/types.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef _PERF_LINUX_TYPES_H_ 20 | #define _PERF_LINUX_TYPES_H_ 21 | #ifndef __bitwise 22 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 23 | #define __bitwise 24 | #endif 25 | #ifndef __le32 26 | typedef __u32 __bitwise __le32; 27 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 28 | #endif 29 | #define DECLARE_BITMAP(name,bits) unsigned long name[BITS_TO_LONGS(bits)] 30 | struct list_head { 31 | struct list_head * next, * prev; 32 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 33 | }; 34 | struct hlist_head { 35 | struct hlist_node * first; 36 | }; 37 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 38 | struct hlist_node { 39 | struct hlist_node * next, * * pprev; 40 | }; 41 | #endif 42 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 43 | 44 | -------------------------------------------------------------------------------- /perfprofd/quipper/kernel-headers/tools/perf/util/types.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | **************************************************************************** 3 | *** 4 | *** This header was automatically generated from a Linux kernel header 5 | *** of the same name, to make information necessary for userspace to 6 | *** call into the kernel available to libc. It contains only constants, 7 | *** structures, and macros generated from the original header, and thus, 8 | *** contains no copyrightable information. 9 | *** 10 | *** To edit the content of this header, modify the corresponding 11 | *** source file (e.g. under external/kernel-headers/original/) then 12 | *** run bionic/libc/kernel/tools/update_all.py 13 | *** 14 | *** Any manual change here will be lost the next time this script will 15 | *** be run. You've been warned! 16 | *** 17 | **************************************************************************** 18 | ****************************************************************************/ 19 | #ifndef __PERF_TYPES_H 20 | #define __PERF_TYPES_H 21 | typedef uint64_t u64; 22 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 23 | typedef int64_t s64; 24 | typedef unsigned int u32; 25 | typedef signed int s32; 26 | typedef unsigned short u16; 27 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 28 | typedef signed short s16; 29 | typedef unsigned char u8; 30 | typedef signed char s8; 31 | union u64_swap { 32 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 33 | u64 val64; 34 | u32 val32[2]; 35 | }; 36 | #endif 37 | /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 38 | 39 | -------------------------------------------------------------------------------- /perfprofd/quipper/original-kernel-headers/tools/perf/util/build-id.h: -------------------------------------------------------------------------------- 1 | #ifndef PERF_BUILD_ID_H_ 2 | #define PERF_BUILD_ID_H_ 1 3 | 4 | #define BUILD_ID_SIZE 20 5 | 6 | #include "tool.h" 7 | #include "types.h" 8 | 9 | extern struct perf_tool build_id__mark_dso_hit_ops; 10 | struct dso; 11 | 12 | int build_id__sprintf(const u8 *build_id, int len, char *bf); 13 | char *dso__build_id_filename(struct dso *self, char *bf, size_t size); 14 | 15 | int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event, 16 | struct perf_sample *sample, struct perf_evsel *evsel, 17 | struct machine *machine); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /perfprofd/quipper/original-kernel-headers/tools/perf/util/include/linux/types.h: -------------------------------------------------------------------------------- 1 | #ifndef _PERF_LINUX_TYPES_H_ 2 | #define _PERF_LINUX_TYPES_H_ 3 | 4 | #include 5 | 6 | #ifndef __bitwise 7 | #define __bitwise 8 | #endif 9 | 10 | #ifndef __le32 11 | typedef __u32 __bitwise __le32; 12 | #endif 13 | 14 | #define DECLARE_BITMAP(name,bits) \ 15 | unsigned long name[BITS_TO_LONGS(bits)] 16 | 17 | struct list_head { 18 | struct list_head *next, *prev; 19 | }; 20 | 21 | struct hlist_head { 22 | struct hlist_node *first; 23 | }; 24 | 25 | struct hlist_node { 26 | struct hlist_node *next, **pprev; 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /perfprofd/quipper/original-kernel-headers/tools/perf/util/target.h: -------------------------------------------------------------------------------- 1 | #ifndef _PERF_TARGET_H 2 | #define _PERF_TARGET_H 3 | 4 | #include 5 | #include 6 | 7 | struct perf_target { 8 | const char *pid; 9 | const char *tid; 10 | const char *cpu_list; 11 | const char *uid_str; 12 | uid_t uid; 13 | bool system_wide; 14 | bool uses_mmap; 15 | }; 16 | 17 | enum perf_target_errno { 18 | PERF_ERRNO_TARGET__SUCCESS = 0, 19 | 20 | /* 21 | * Choose an arbitrary negative big number not to clash with standard 22 | * errno since SUS requires the errno has distinct positive values. 23 | * See 'Issue 6' in the link below. 24 | * 25 | * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html 26 | */ 27 | __PERF_ERRNO_TARGET__START = -10000, 28 | 29 | 30 | /* for perf_target__validate() */ 31 | PERF_ERRNO_TARGET__PID_OVERRIDE_CPU = __PERF_ERRNO_TARGET__START, 32 | PERF_ERRNO_TARGET__PID_OVERRIDE_UID, 33 | PERF_ERRNO_TARGET__UID_OVERRIDE_CPU, 34 | PERF_ERRNO_TARGET__PID_OVERRIDE_SYSTEM, 35 | PERF_ERRNO_TARGET__UID_OVERRIDE_SYSTEM, 36 | 37 | /* for perf_target__parse_uid() */ 38 | PERF_ERRNO_TARGET__INVALID_UID, 39 | PERF_ERRNO_TARGET__USER_NOT_FOUND, 40 | 41 | __PERF_ERRNO_TARGET__END, 42 | }; 43 | 44 | enum perf_target_errno perf_target__validate(struct perf_target *target); 45 | enum perf_target_errno perf_target__parse_uid(struct perf_target *target); 46 | 47 | int perf_target__strerror(struct perf_target *target, int errnum, char *buf, 48 | size_t buflen); 49 | 50 | static inline bool perf_target__has_task(struct perf_target *target) 51 | { 52 | return target->tid || target->pid || target->uid_str; 53 | } 54 | 55 | static inline bool perf_target__has_cpu(struct perf_target *target) 56 | { 57 | return target->system_wide || target->cpu_list; 58 | } 59 | 60 | static inline bool perf_target__none(struct perf_target *target) 61 | { 62 | return !perf_target__has_task(target) && !perf_target__has_cpu(target); 63 | } 64 | 65 | #endif /* _PERF_TARGET_H */ 66 | -------------------------------------------------------------------------------- /perfprofd/quipper/original-kernel-headers/tools/perf/util/types.h: -------------------------------------------------------------------------------- 1 | #ifndef __PERF_TYPES_H 2 | #define __PERF_TYPES_H 3 | 4 | #include 5 | 6 | /* 7 | * We define u64 as uint64_t for every architecture 8 | * so that we can print it with "%"PRIx64 without getting warnings. 9 | */ 10 | typedef uint64_t u64; 11 | typedef int64_t s64; 12 | typedef unsigned int u32; 13 | typedef signed int s32; 14 | typedef unsigned short u16; 15 | typedef signed short s16; 16 | typedef unsigned char u8; 17 | typedef signed char s8; 18 | 19 | union u64_swap { 20 | u64 val64; 21 | u32 val32[2]; 22 | }; 23 | 24 | #endif /* __PERF_TYPES_H */ 25 | -------------------------------------------------------------------------------- /perfprofd/quipper/quipper_string.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef QUIPPER_STRING_ 6 | #define QUIPPER_STRING_ 7 | 8 | #ifndef HAS_GLOBAL_STRING 9 | using std::string; 10 | using std::stringstream; 11 | #endif 12 | 13 | #endif // QUIPPER_STRING_ 14 | -------------------------------------------------------------------------------- /perfprofd/quipper/quipper_test.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | #ifndef QUIPPER_TEST_H_ 6 | #define QUIPPER_TEST_H_ 7 | 8 | #include 9 | 10 | #endif // QUIPPER_TEST_H_ 11 | -------------------------------------------------------------------------------- /perfprofd/tests/Android.mk: -------------------------------------------------------------------------------- 1 | # Build the unit tests. 2 | LOCAL_PATH := $(call my-dir) 3 | 4 | perfprofd_test_cppflags := -Wall -Wno-sign-compare -Wno-unused-parameter -Werror -std=gnu++11 5 | 6 | # 7 | # Static library with mockup utilities layer (called by unit test). 8 | # 9 | include $(CLEAR_VARS) 10 | LOCAL_CLANG := true 11 | LOCAL_CPP_EXTENSION := .cc 12 | LOCAL_CXX_STL := libc++ 13 | LOCAL_C_INCLUDES += system/extras/perfprofd 14 | LOCAL_MODULE := libperfprofdmockutils 15 | LOCAL_CPPFLAGS += $(perfprofd_test_cppflags) 16 | LOCAL_SRC_FILES := perfprofdmockutils.cc 17 | include $(BUILD_STATIC_LIBRARY) 18 | 19 | # 20 | # Canned perf.data files needed by unit test. 21 | # 22 | include $(CLEAR_VARS) 23 | LOCAL_MODULE := canned.perf.data 24 | LOCAL_MODULE_TAGS := optional 25 | LOCAL_MODULE_CLASS := DATA 26 | LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest/perfprofd_test 27 | LOCAL_SRC_FILES := canned.perf.data 28 | include $(BUILD_PREBUILT) 29 | 30 | # 31 | # Unit test for perfprofd 32 | # 33 | include $(CLEAR_VARS) 34 | LOCAL_CLANG := true 35 | LOCAL_CPP_EXTENSION := .cc 36 | LOCAL_CXX_STL := libc++ 37 | LOCAL_STATIC_LIBRARIES := libperfprofdcore libperfprofdmockutils libgtest libbase 38 | LOCAL_SHARED_LIBRARIES := libprotobuf-cpp-lite 39 | LOCAL_C_INCLUDES += system/extras/perfprofd external/protobuf/src 40 | LOCAL_SRC_FILES := perfprofd_test.cc 41 | LOCAL_CPPFLAGS += $(perfprofd_test_cppflags) 42 | LOCAL_SHARED_LIBRARIES += libcutils 43 | LOCAL_MODULE := perfprofd_test 44 | include $(BUILD_NATIVE_TEST) 45 | 46 | # Clean temp vars 47 | perfprofd_test_cppflags := 48 | -------------------------------------------------------------------------------- /perfprofd/tests/README.txt: -------------------------------------------------------------------------------- 1 | Native tests for 'perfprofd'. Please run with 'runtest perfprofd' 2 | (a.k.a. "$ANDROID_BUILD_TOP"/development/testrunner/runtest.py). 3 | 4 | Notes: 5 | 6 | 1. One of the testpoints in this test suite performs a live 'perf' 7 | run on the device; before invoking the test be sure that 'perf' 8 | has been built and installed on the device in /system/bin/perf 9 | 10 | 2. The daemon under test, perfprofd, is broken into a main function, a 11 | "core" library, and a "utils library. Picture: 12 | 13 | +-----------+ perfprofdmain.o 14 | | perfprofd | 15 | | main() | 1-liner; calls perfprofd_main() 16 | +-----------+ 17 | | 18 | v 19 | +-----------+ perfprofdcore.a 20 | | perfprofd | 21 | | core | most of the interesting code is here; 22 | | | calls into utils library when for 23 | +-----------+ operations such as sleep, log, etc 24 | | 25 | v 26 | +-----------+ perfprofdutils.a 27 | | perfprofd | 28 | | utils | real implementations of perfprofd_sleep, 29 | | | perfprofd_log_* etc 30 | +-----------+ 31 | 32 | Because the daemon tends to spend a lot of time sleeping/waiting, 33 | it is impractical to try to test it directly. Instead we insert a 34 | mock utilities layer and then have a test driver that invokes the 35 | daemon main function. Picture for perfprofd_test: 36 | 37 | +----------------+ perfprofd_test.cc 38 | | perfprofd_test | 39 | | | makes calls into perfprofd_main(), 40 | +----------------+ then verifies behavior 41 | | 42 | v 43 | +-----------+ perfprofdcore.a 44 | | perfprofd | 45 | | core | same as above 46 | +-----------+ 47 | | 48 | v 49 | +-----------+ perfprofdmockutils.a 50 | | perfprofd | 51 | | mockutils | mock implementations of perfprofd_sleep, 52 | | | perfprofd_log_* etc 53 | +-----------+ 54 | 55 | The mockup versions of perfprofd_sleep() and perfprofd_log_* do 56 | simply log the fact that they are called; the test driver can 57 | then examine the log to make sure that the daemon is doing 58 | what it is supposed to be doing. 59 | -------------------------------------------------------------------------------- /perfprofd/tests/canned.perf.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/perfprofd/tests/canned.perf.data -------------------------------------------------------------------------------- /perfprofd/tests/perfprofdmockutils.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** 3 | ** Copyright 2015, The Android Open Source Project 4 | ** 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); 6 | ** you may not use this file except in compliance with the License. 7 | ** You may obtain a copy of the License at 8 | ** 9 | ** http://www.apache.org/licenses/LICENSE-2.0 10 | ** 11 | ** Unless required by applicable law or agreed to in writing, software 12 | ** distributed under the License is distributed on an "AS IS" BASIS, 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | ** See the License for the specific language governing permissions and 15 | ** limitations under the License. 16 | */ 17 | 18 | /// 19 | /// Set up mock utilities layer prior to unit test execution 20 | /// 21 | extern void mock_perfprofdutils_init(); 22 | 23 | /// 24 | /// Set up mock utilities layer prior to unit test execution 25 | /// 26 | extern void mock_perfprofdutils_finish(); 27 | 28 | /// 29 | /// Return string containing things logged to logd, plus sleep instances 30 | /// 31 | extern std::string mock_perfprofdutils_getlogged(); 32 | -------------------------------------------------------------------------------- /postinst/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | LOCAL_PATH:= $(call my-dir) 18 | 19 | include $(CLEAR_VARS) 20 | LOCAL_MODULE:= postinst_example 21 | LOCAL_MODULE_TAGS := optional 22 | LOCAL_MODULE_CLASS := EXECUTABLES 23 | LOCAL_SRC_FILES := postinst.sh 24 | 25 | # Create a symlink from /postinst to our default post-install script in the 26 | # same filesystem as /postinst. 27 | # TODO(deymo): Remove this symlink and add the path to the product config. 28 | LOCAL_POST_INSTALL_CMD := \ 29 | $(hide) ln -sf bin/postinst_example $(TARGET_OUT)/postinst 30 | include $(BUILD_PREBUILT) 31 | -------------------------------------------------------------------------------- /postinst/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/postinst/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /postinst/postinst.sh: -------------------------------------------------------------------------------- 1 | #!/system/bin/sh 2 | 3 | # 4 | # Copyright (C) 2015 The Android Open Source Project 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # http://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | # This is an example post-install script. This script will be executed by the 20 | # update_engine right after finishing writing all the partitions, but before 21 | # marking the new slot as active. 22 | # 23 | # This script receives no arguments. argv[0] will include the absolute path to 24 | # the script, including the temporary directory where the new partition was 25 | # mounted. 26 | # 27 | # This script will run in the context of the old kernel and old system. Note 28 | # that the absolute path used in first line of this script (/system/bin/sh) is 29 | # indeed the old system's sh binary. If you use a compiled program, you might 30 | # want to link it statically or use a wrapper script to use the new ldso to run 31 | # your program (see the --generate-wrappers option in lddtree.py for example). 32 | # 33 | # If the exit code of this program is an error code (different from 0), the 34 | # update will fail and the new slot will not be marked as active. 35 | 36 | exit 0 37 | -------------------------------------------------------------------------------- /preopt2cachename/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:= $(call my-dir) 16 | 17 | include $(CLEAR_VARS) 18 | 19 | LOCAL_MODULE:= preopt2cachename 20 | 21 | LOCAL_SRC_FILES := \ 22 | preopt2cachename.cpp 23 | 24 | LOCAL_SHARED_LIBRARIES := \ 25 | libsysutils \ 26 | liblog \ 27 | libcutils \ 28 | libbase 29 | 30 | LOCAL_CFLAGS := -Werror -Wall 31 | 32 | include $(BUILD_EXECUTABLE) 33 | -------------------------------------------------------------------------------- /procmem/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:= $(call my-dir) 16 | 17 | include $(CLEAR_VARS) 18 | LOCAL_SRC_FILES := procmem.c 19 | LOCAL_SHARED_LIBRARIES := libpagemap 20 | LOCAL_MODULE := procmem 21 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 22 | LOCAL_MODULE_TAGS := debug 23 | include $(BUILD_EXECUTABLE) 24 | -------------------------------------------------------------------------------- /procmem/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/procmem/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /procrank/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH:= $(call my-dir) 16 | 17 | include $(CLEAR_VARS) 18 | LOCAL_SRC_FILES := procrank.c 19 | LOCAL_CFLAGS := -Wall -Wextra -Wformat=2 -Werror 20 | LOCAL_SHARED_LIBRARIES := libpagemap 21 | LOCAL_MODULE := procrank 22 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 23 | LOCAL_MODULE_TAGS := debug 24 | include $(BUILD_EXECUTABLE) 25 | -------------------------------------------------------------------------------- /procrank/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/procrank/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /puncture_fs/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2014 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH := $(call my-dir) 16 | 17 | include $(CLEAR_VARS) 18 | 19 | LOCAL_SRC_FILES := puncture_fs.c 20 | 21 | LOCAL_C_INCLUDES += system/core/logwrapper/include 22 | 23 | LOCAL_SHARED_LIBRARIES := libc liblog liblogwrap 24 | 25 | LOCAL_MODULE := puncture_fs 26 | 27 | LOCAL_MODULE_TAGS := debug 28 | 29 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 30 | 31 | include $(BUILD_EXECUTABLE) 32 | -------------------------------------------------------------------------------- /sane_schedstat/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_SRC_FILES := sane_schedstat.c 6 | 7 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 8 | LOCAL_MODULE_TAGS := debug 9 | LOCAL_MODULE := sane_schedstat 10 | LOCAL_CFLAGS := -Wno-unused-parameter 11 | 12 | include $(BUILD_EXECUTABLE) 13 | -------------------------------------------------------------------------------- /showmap/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2006 The Android Open Source Project 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_SRC_FILES:= showmap.cpp 7 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 8 | LOCAL_MODULE_TAGS := debug 9 | LOCAL_MODULE:= showmap 10 | 11 | include $(BUILD_EXECUTABLE) 12 | 13 | -------------------------------------------------------------------------------- /showmap/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/showmap/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /showslab/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2007 The Android Open Source Project 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_SRC_FILES:= showslab.c 7 | LOCAL_SHARED_LIBRARIES := 8 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 9 | 10 | LOCAL_MODULE_TAGS := debug 11 | 12 | LOCAL_MODULE:= showslab 13 | 14 | include $(BUILD_EXECUTABLE) 15 | 16 | -------------------------------------------------------------------------------- /showslab/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/showslab/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /simpleperf/callchain.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SIMPLE_PERF_CALLCHAIN_H_ 18 | #define SIMPLE_PERF_CALLCHAIN_H_ 19 | 20 | #include 21 | #include 22 | 23 | struct SampleEntry; 24 | 25 | struct CallChainNode { 26 | uint64_t period; 27 | uint64_t children_period; 28 | std::vector chain; 29 | std::vector> children; 30 | }; 31 | 32 | struct CallChainRoot { 33 | uint64_t children_period; 34 | std::vector> children; 35 | 36 | CallChainRoot() : children_period(0) { 37 | } 38 | 39 | void AddCallChain(const std::vector& callchain, uint64_t period); 40 | void SortByPeriod(); 41 | }; 42 | 43 | #endif // SIMPLE_PERF_CALLCHAIN_H_ 44 | -------------------------------------------------------------------------------- /simpleperf/cmd_dumprecord_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include "command.h" 20 | #include "get_test_data.h" 21 | 22 | static std::unique_ptr DumpCmd() { 23 | return CreateCommandInstance("dump"); 24 | } 25 | 26 | TEST(cmd_dump, record_file_option) { 27 | ASSERT_TRUE(DumpCmd()->Run({GetTestData("perf.data")})); 28 | } 29 | -------------------------------------------------------------------------------- /simpleperf/cmd_list_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include "command.h" 20 | 21 | class ListCommandTest : public ::testing::Test { 22 | protected: 23 | virtual void SetUp() { 24 | list_cmd = CreateCommandInstance("list"); 25 | ASSERT_TRUE(list_cmd != nullptr); 26 | } 27 | 28 | std::unique_ptr list_cmd; 29 | }; 30 | 31 | TEST_F(ListCommandTest, no_options) { 32 | ASSERT_TRUE(list_cmd->Run({})); 33 | } 34 | 35 | TEST_F(ListCommandTest, one_option) { 36 | ASSERT_TRUE(list_cmd->Run({"sw"})); 37 | } 38 | 39 | TEST_F(ListCommandTest, multiple_options) { 40 | ASSERT_TRUE(list_cmd->Run({"hw", "tracepoint"})); 41 | } 42 | -------------------------------------------------------------------------------- /simpleperf/command_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | #include "command.h" 20 | 21 | class MockCommand : public Command { 22 | public: 23 | MockCommand() : Command("mock", "mock_short_help", "mock_long_help") { 24 | } 25 | 26 | bool Run(const std::vector&) override { 27 | return true; 28 | } 29 | }; 30 | 31 | TEST(command, CreateCommandInstance) { 32 | ASSERT_TRUE(CreateCommandInstance("mock1") == nullptr); 33 | RegisterCommand("mock1", [] { return std::unique_ptr(new MockCommand); }); 34 | ASSERT_TRUE(CreateCommandInstance("mock1") != nullptr); 35 | UnRegisterCommand("mock1"); 36 | ASSERT_TRUE(CreateCommandInstance("mock1") == nullptr); 37 | } 38 | 39 | TEST(command, GetAllCommands) { 40 | size_t command_count = GetAllCommandNames().size(); 41 | RegisterCommand("mock1", [] { return std::unique_ptr(new MockCommand); }); 42 | ASSERT_EQ(command_count + 1, GetAllCommandNames().size()); 43 | UnRegisterCommand("mock1"); 44 | ASSERT_EQ(command_count, GetAllCommandNames().size()); 45 | } 46 | -------------------------------------------------------------------------------- /simpleperf/dwarf_unwind.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SIMPLE_PERF_DWARF_UNWIND_H_ 18 | #define SIMPLE_PERF_DWARF_UNWIND_H_ 19 | 20 | #include 21 | 22 | #include "perf_regs.h" 23 | 24 | namespace simpleperf { 25 | struct ThreadEntry; 26 | } 27 | 28 | using ThreadEntry = simpleperf::ThreadEntry; 29 | 30 | std::vector UnwindCallChain(ArchType arch, const ThreadEntry& thread, const RegSet& regs, 31 | const std::vector& stack); 32 | 33 | #endif // SIMPLE_PERF_DWARF_UNWIND_H_ 34 | -------------------------------------------------------------------------------- /simpleperf/environment_fake.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Add fake functions to build successfully on non-linux environments. 18 | #include "environment.h" 19 | 20 | bool ProcessKernelSymbols(const std::string&, std::function) { 21 | return false; 22 | } 23 | 24 | bool GetKernelBuildId(BuildId*) { 25 | return false; 26 | } 27 | -------------------------------------------------------------------------------- /simpleperf/event_attr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SIMPLE_PERF_EVENT_ATTR_H_ 18 | #define SIMPLE_PERF_EVENT_ATTR_H_ 19 | 20 | #include 21 | 22 | #include "perf_event.h" 23 | 24 | struct EventType; 25 | 26 | perf_event_attr CreateDefaultPerfEventAttr(const EventType& event_type); 27 | void DumpPerfEventAttr(const perf_event_attr& attr, size_t indent = 0); 28 | 29 | #endif // SIMPLE_PERF_EVENT_ATTR_H_ 30 | -------------------------------------------------------------------------------- /simpleperf/nonlinux_support/include/asm/byteorder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | -------------------------------------------------------------------------------- /simpleperf/nonlinux_support/include/linux/ioctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #define __IO(type, nr) 18 | #define __IOR(type, nr, size) 19 | #define __IOW(type, nr, size) 20 | -------------------------------------------------------------------------------- /simpleperf/nonlinux_support/include/linux/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | 19 | typedef uint8_t __u8; 20 | typedef uint16_t __u16; 21 | typedef uint32_t __u32; 22 | typedef int32_t __s32; 23 | typedef uint64_t __u64; 24 | typedef int64_t __s64; 25 | -------------------------------------------------------------------------------- /simpleperf/nonlinux_support/nonlinux_support.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | // Add fake functions to build successfully on darwin. 18 | #include 19 | 20 | #include "dwarf_unwind.h" 21 | #include "environment.h" 22 | 23 | std::vector UnwindCallChain(ArchType, const ThreadEntry&, const RegSet&, 24 | const std::vector&) { 25 | return std::vector(); 26 | } 27 | 28 | bool ProcessKernelSymbols(const std::string&, std::function) { 29 | return false; 30 | } 31 | 32 | bool GetKernelBuildId(BuildId*) { 33 | return false; 34 | } 35 | -------------------------------------------------------------------------------- /simpleperf/perf_event.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SIMPLE_PERF_PERF_EVENT_H_ 18 | #define SIMPLE_PERF_PERF_EVENT_H_ 19 | 20 | #if defined(USE_BIONIC_UAPI_HEADERS) 21 | #include 22 | #else 23 | #include 24 | #endif 25 | 26 | #endif // SIMPLE_PERF_PERF_EVENT_H_ 27 | -------------------------------------------------------------------------------- /simpleperf/record_equal_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | static void CheckMmapRecordDataEqual(const MmapRecord& r1, const MmapRecord& r2) { 18 | ASSERT_EQ(0, memcmp(&r1.data, &r2.data, sizeof(r1.data))); 19 | ASSERT_EQ(r1.filename, r2.filename); 20 | } 21 | 22 | static void CheckCommRecordDataEqual(const CommRecord& r1, const CommRecord& r2) { 23 | ASSERT_EQ(0, memcmp(&r1.data, &r2.data, sizeof(r1.data))); 24 | ASSERT_EQ(r1.comm, r2.comm); 25 | } 26 | 27 | static void CheckBuildIdRecordDataEqual(const BuildIdRecord& r1, const BuildIdRecord& r2) { 28 | ASSERT_EQ(r1.pid, r2.pid); 29 | ASSERT_EQ(r1.build_id, r2.build_id); 30 | ASSERT_EQ(r1.filename, r2.filename); 31 | } 32 | 33 | static void CheckRecordEqual(const Record& r1, const Record& r2) { 34 | ASSERT_EQ(0, memcmp(&r1.header, &r2.header, sizeof(r1.header))); 35 | ASSERT_EQ(0, memcmp(&r1.sample_id, &r2.sample_id, sizeof(r1.sample_id))); 36 | if (r1.header.type == PERF_RECORD_MMAP) { 37 | CheckMmapRecordDataEqual(static_cast(r1), static_cast(r2)); 38 | } else if (r1.header.type == PERF_RECORD_COMM) { 39 | CheckCommRecordDataEqual(static_cast(r1), static_cast(r2)); 40 | } else if (r1.header.type == PERF_RECORD_BUILD_ID) { 41 | CheckBuildIdRecordDataEqual(static_cast(r1), 42 | static_cast(r2)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /simpleperf/runtest/Android.build.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | # -O0 is need to prevent optimizations like function inlining in runtest executables. 18 | simpleperf_runtest_cppflags := -Wall -Wextra -Werror -Wunused \ 19 | -O0 \ 20 | 21 | include $(CLEAR_VARS) 22 | LOCAL_CLANG := true 23 | LOCAL_CPPFLAGS := $(simpleperf_runtest_cppflags) 24 | LOCAL_SRC_FILES := $(module_src_files) 25 | LOCAL_MODULE := $(module) 26 | LOCAL_STRIP_MODULE := false 27 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.build.mk 28 | include $(BUILD_EXECUTABLE) 29 | 30 | ifeq ($(HOST_OS),linux) 31 | include $(CLEAR_VARS) 32 | LOCAL_CLANG := true 33 | LOCAL_CPPFLAGS := $(simpleperf_runtest_cppflags) 34 | LOCAL_SRC_FILES := $(module_src_files) 35 | LOCAL_MODULE := $(module) 36 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.build.mk 37 | include $(BUILD_HOST_EXECUTABLE) 38 | endif -------------------------------------------------------------------------------- /simpleperf/runtest/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | LOCAL_PATH := $(call my-dir) 18 | 19 | module := simpleperf_runtest_one_function 20 | module_src_files := one_function.cpp 21 | include $(LOCAL_PATH)/Android.build.mk 22 | 23 | module := simpleperf_runtest_two_functions 24 | module_src_files := two_functions.cpp 25 | include $(LOCAL_PATH)/Android.build.mk 26 | 27 | module := simpleperf_runtest_function_fork 28 | module_src_files := function_fork.cpp 29 | include $(LOCAL_PATH)/Android.build.mk 30 | 31 | module := simpleperf_runtest_function_pthread 32 | module_src_files := function_pthread.cpp 33 | include $(LOCAL_PATH)/Android.build.mk 34 | 35 | module := simpleperf_runtest_comm_change 36 | module_src_files := comm_change.cpp 37 | include $(LOCAL_PATH)/Android.build.mk 38 | 39 | module := simpleperf_runtest_function_recursive 40 | module_src_files := function_recursive.cpp 41 | include $(LOCAL_PATH)/Android.build.mk 42 | 43 | module := simpleperf_runtest_function_indirect_recursive 44 | module_src_files := function_indirect_recursive.cpp 45 | include $(LOCAL_PATH)/Android.build.mk -------------------------------------------------------------------------------- /simpleperf/runtest/comm_change.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | constexpr int LOOP_COUNT = 100000000; 4 | 5 | void Function1() { 6 | for (volatile int i = 0; i < LOOP_COUNT; ++i) { 7 | } 8 | } 9 | 10 | int main() { 11 | prctl(PR_SET_NAME, reinterpret_cast("RUN_COMM1"), 0, 0, 0); 12 | Function1(); 13 | prctl(PR_SET_NAME, reinterpret_cast("RUN_COMM2"), 0, 0, 0); 14 | Function1(); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /simpleperf/runtest/function_fork.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | constexpr int LOOP_COUNT = 100000000; 4 | 5 | void ParentFunction() { 6 | for (volatile int i = 0; i < LOOP_COUNT; ++i) { 7 | } 8 | } 9 | 10 | void ChildFunction() { 11 | for (volatile int i = 0; i < LOOP_COUNT; ++i) { 12 | } 13 | } 14 | 15 | int main() { 16 | pid_t pid = fork(); 17 | if (pid == 0) { 18 | ChildFunction(); 19 | return 0; 20 | } else { 21 | ParentFunction(); 22 | } 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /simpleperf/runtest/function_indirect_recursive.cpp: -------------------------------------------------------------------------------- 1 | constexpr int LOOP_COUNT = 5000000; 2 | 3 | void FunctionRecursiveTwo(int loop); 4 | 5 | void FunctionRecursiveOne(int loop) { 6 | for (volatile int i = 0; i < LOOP_COUNT; ++i) { 7 | } 8 | if (loop >= 0) { 9 | FunctionRecursiveTwo(loop); 10 | } 11 | } 12 | 13 | void FunctionRecursiveTwo(int loop) { 14 | for (volatile int i = 0; i < LOOP_COUNT; ++i) { 15 | } 16 | if (loop > 0) { 17 | FunctionRecursiveOne(loop - 1); 18 | } 19 | } 20 | 21 | int main() { 22 | FunctionRecursiveOne(10); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /simpleperf/runtest/function_pthread.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | constexpr int LOOP_COUNT = 100000000; 7 | 8 | void* ChildThreadFunction(void*) { 9 | for (volatile int i = 0; i < LOOP_COUNT; ++i) { 10 | } 11 | return nullptr; 12 | } 13 | 14 | void MainThreadFunction() { 15 | for (volatile int i = 0; i < LOOP_COUNT; ++i) { 16 | } 17 | } 18 | 19 | int main() { 20 | pthread_t thread; 21 | int ret = pthread_create(&thread, nullptr, ChildThreadFunction, nullptr); 22 | if (ret != 0) { 23 | fprintf(stderr, "pthread_create failed: %s\n", strerror(ret)); 24 | exit(1); 25 | } 26 | MainThreadFunction(); 27 | ret = pthread_join(thread, nullptr); 28 | if (ret != 0) { 29 | fprintf(stderr, "pthread_join failed: %s\n", strerror(ret)); 30 | exit(1); 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /simpleperf/runtest/function_recursive.cpp: -------------------------------------------------------------------------------- 1 | constexpr int LOOP_COUNT = 5000000; 2 | 3 | void FunctionRecursive(int loop) { 4 | for (volatile int i = 0; i < LOOP_COUNT; ++i) { 5 | } 6 | if (loop > 0) { 7 | FunctionRecursive(loop - 1); 8 | } 9 | for (volatile int i = 0; i < LOOP_COUNT; ++i) { 10 | } 11 | } 12 | 13 | int main() { 14 | FunctionRecursive(10); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /simpleperf/runtest/one_function.cpp: -------------------------------------------------------------------------------- 1 | constexpr int LOOP_COUNT = 100000000; 2 | 3 | void Function1() { 4 | for (volatile int i = 0; i < LOOP_COUNT; ++i) { 5 | } 6 | } 7 | 8 | int main() { 9 | Function1(); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /simpleperf/runtest/two_functions.cpp: -------------------------------------------------------------------------------- 1 | constexpr int LOOP_COUNT = 100000000; 2 | 3 | void Function1() { 4 | for (volatile int i = 0; i < LOOP_COUNT; ++i) { 5 | } 6 | } 7 | 8 | void Function2() { 9 | for (volatile int i = 0; i < LOOP_COUNT; ++i) { 10 | } 11 | } 12 | 13 | int main() { 14 | Function1(); 15 | Function2(); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /simpleperf/scoped_signal_handler.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SIMPLE_PERF_SCOPED_SIGNAL_HANDLER_H_ 18 | #define SIMPLE_PERF_SCOPED_SIGNAL_HANDLER_H_ 19 | 20 | #include 21 | 22 | #include 23 | 24 | class ScopedSignalHandler { 25 | public: 26 | ScopedSignalHandler(const std::vector& signums, void (*handler)(int)) { 27 | for (auto& sig : signums) { 28 | sig_t old_handler = signal(sig, handler); 29 | saved_signal_handlers_.push_back(std::make_pair(sig, old_handler)); 30 | } 31 | } 32 | 33 | ~ScopedSignalHandler() { 34 | for (auto& pair : saved_signal_handlers_) { 35 | signal(pair.first, pair.second); 36 | } 37 | } 38 | 39 | private: 40 | std::vector> saved_signal_handlers_; 41 | }; 42 | 43 | #endif // SIMPLE_PERF_SCOPED_SIGNAL_HANDLER_H_ 44 | -------------------------------------------------------------------------------- /simpleperf/test_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | #include "read_elf.h" 21 | #include "workload.h" 22 | 23 | static const std::string SLEEP_SEC = "0.001"; 24 | 25 | void CreateProcesses(size_t count, std::vector>* workloads); 26 | 27 | void ParseSymbol(const ElfFileSymbol& symbol, std::map* symbols); 28 | void CheckElfFileSymbols(const std::map& symbols); 29 | -------------------------------------------------------------------------------- /simpleperf/testdata/data/app/com.example.hellojni-1/base.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/simpleperf/testdata/data/app/com.example.hellojni-1/base.apk -------------------------------------------------------------------------------- /simpleperf/testdata/elf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/simpleperf/testdata/elf -------------------------------------------------------------------------------- /simpleperf/testdata/elf_file_source.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | volatile int GlobalVar; 4 | 5 | extern "C" void CalledFunc() { 6 | GlobalVar++; 7 | } 8 | 9 | extern "C" void GlobalFunc() { 10 | for (int i = 0; i < 1000000; ++i) { 11 | CalledFunc(); 12 | } 13 | } 14 | 15 | int main() { 16 | while (true) { 17 | GlobalFunc(); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /simpleperf/testdata/has_embedded_native_libs_apk_perf.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/simpleperf/testdata/has_embedded_native_libs_apk_perf.data -------------------------------------------------------------------------------- /simpleperf/testdata/perf.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/simpleperf/testdata/perf.data -------------------------------------------------------------------------------- /simpleperf/testdata/perf_b.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/simpleperf/testdata/perf_b.data -------------------------------------------------------------------------------- /simpleperf/testdata/perf_g_fp.data: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/simpleperf/testdata/perf_g_fp.data -------------------------------------------------------------------------------- /simpleperf/workload.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef SIMPLE_PERF_WORKLOAD_H_ 18 | #define SIMPLE_PERF_WORKLOAD_H_ 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | class Workload { 28 | private: 29 | enum WorkState { 30 | NotYetCreateNewProcess, 31 | NotYetStartNewProcess, 32 | Started, 33 | }; 34 | 35 | public: 36 | static std::unique_ptr CreateWorkload(const std::vector& args); 37 | 38 | ~Workload(); 39 | 40 | bool Start(); 41 | pid_t GetPid() { 42 | return work_pid_; 43 | } 44 | 45 | private: 46 | Workload(const std::vector& args) 47 | : work_state_(NotYetCreateNewProcess), 48 | args_(args), 49 | work_pid_(-1), 50 | start_signal_fd_(-1), 51 | exec_child_fd_(-1) { 52 | } 53 | 54 | bool CreateNewProcess(); 55 | bool WaitChildProcess(bool wait_forever); 56 | 57 | WorkState work_state_; 58 | std::vector args_; 59 | pid_t work_pid_; 60 | int start_signal_fd_; // The parent process writes 1 to start workload in the child process. 61 | int exec_child_fd_; // The child process writes 1 to notify that execvp() failed. 62 | 63 | DISALLOW_COPY_AND_ASSIGN(Workload); 64 | }; 65 | 66 | #endif // SIMPLE_PERF_WORKLOAD_H_ 67 | -------------------------------------------------------------------------------- /slideshow/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Android Open Source Project 2 | 3 | LOCAL_PATH := $(call my-dir) 4 | 5 | include $(CLEAR_VARS) 6 | LOCAL_SRC_FILES := slideshow.cpp 7 | LOCAL_MODULE := slideshow 8 | LOCAL_MODULE_TAGS := optional 9 | LOCAL_FORCE_STATIC_EXECUTABLE := true 10 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN) 11 | LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED) 12 | 13 | LOCAL_CFLAGS := -D__STDC_LIMIT_MACROS -Werror 14 | LOCAL_C_INCLUDES := bootable/recovery 15 | LOCAL_STATIC_LIBRARIES := libminui libpng libz libutils libstdc++ libcutils liblog libm libc 16 | include $(BUILD_EXECUTABLE) 17 | -------------------------------------------------------------------------------- /sound/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_MODULE := sound 5 | LOCAL_SRC_FILES := playwav.c 6 | LOCAL_CFLAGS := -Wno-unused-parameter 7 | include $(BUILD_EXECUTABLE) 8 | 9 | -------------------------------------------------------------------------------- /squashfs_utils/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Android Open Source Project 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | 5 | include $(CLEAR_VARS) 6 | LOCAL_SRC_FILES := squashfs_utils.c 7 | LOCAL_STATIC_LIBRARIES := libcutils 8 | LOCAL_C_INCLUDES := external/squashfs-tools/squashfs-tools 9 | LOCAL_MODULE := libsquashfs_utils 10 | include $(BUILD_STATIC_LIBRARY) 11 | 12 | include $(CLEAR_VARS) 13 | LOCAL_SRC_FILES := squashfs_utils.c 14 | LOCAL_STATIC_LIBRARIES := libcutils 15 | LOCAL_C_INCLUDES := external/squashfs-tools/squashfs-tools 16 | LOCAL_CFLAGS := -Wall -Werror -D_GNU_SOURCE -DSQUASHFS_NO_KLOG 17 | LOCAL_MODULE := libsquashfs_utils_host 18 | include $(BUILD_HOST_STATIC_LIBRARY) 19 | 20 | include $(CLEAR_VARS) 21 | LOCAL_MODULE := mksquashfsimage.sh 22 | LOCAL_SRC_FILES := mksquashfsimage.sh 23 | LOCAL_MODULE_CLASS := EXECUTABLES 24 | # We don't need any additional suffix. 25 | LOCAL_MODULE_SUFFIX := 26 | LOCAL_BUILT_MODULE_STEM := $(notdir $(LOCAL_SRC_FILES)) 27 | LOCAL_IS_HOST_MODULE := true 28 | LOCAL_MODULE_HOST_OS := linux darwin 29 | include $(BUILD_PREBUILT) 30 | -------------------------------------------------------------------------------- /squashfs_utils/squashfs_utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _SQUASHFS_UTILS_H_ 18 | #define _SQUASHFS_UTILS_H_ 19 | 20 | #include 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | struct squashfs_info { 28 | uint32_t block_size; 29 | uint32_t inodes; 30 | uint64_t bytes_used; 31 | uint64_t bytes_used_4K_padded; 32 | }; 33 | 34 | size_t squashfs_get_sb_size(); 35 | int squashfs_parse_sb_buffer(const void *data, struct squashfs_info *info); 36 | int squashfs_parse_sb(const char *blk_device, struct squashfs_info *info); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /taskstats/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Android Open Source Project 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_SRC_FILES := \ 7 | taskstats.c 8 | 9 | LOCAL_SHARED_LIBRARIES := \ 10 | libnl 11 | 12 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 13 | LOCAL_MODULE_TAGS := debug 14 | LOCAL_MODULE:= taskstats 15 | 16 | include $(BUILD_EXECUTABLE) 17 | -------------------------------------------------------------------------------- /taskstats/MODULE_LICENSE_APACHE2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CyanogenMod/android_system_extras/19661b488954d9f90aca41f17f089b98c3dd8c3c/taskstats/MODULE_LICENSE_APACHE2 -------------------------------------------------------------------------------- /tests/Android.mk: -------------------------------------------------------------------------------- 1 | include $(call all-subdir-makefiles) 2 | -------------------------------------------------------------------------------- /tests/audio/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2013 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | include $(call all-subdir-makefiles) 18 | -------------------------------------------------------------------------------- /tests/audio/alsa/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2013 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | LOCAL_PATH := $(call my-dir) 18 | 19 | include $(CLEAR_VARS) 20 | LOCAL_MODULE_TAGS := tests 21 | LOCAL_MODULE := pcmtest 22 | LOCAL_SRC_FILES := pcmtest.cpp 23 | LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libtinyalsa 24 | LOCAL_STATIC_LIBRARIES += libtestUtil 25 | LOCAL_C_INCLUDES += system/extras/tests/include external/tinyalsa/include 26 | 27 | include $(BUILD_NATIVE_TEST) 28 | -------------------------------------------------------------------------------- /tests/binder/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2010 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | include $(call all-subdir-makefiles) 18 | -------------------------------------------------------------------------------- /tests/binder/benchmarks/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2010 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | LOCAL_PATH:= $(call my-dir) 18 | 19 | include $(CLEAR_VARS) 20 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk 21 | 22 | LOCAL_MODULE_TAGS := eng tests 23 | 24 | LOCAL_STATIC_LIBRARIES += \ 25 | libtestUtil 26 | 27 | LOCAL_SHARED_LIBRARIES += \ 28 | libutils \ 29 | liblog \ 30 | libbinder 31 | 32 | LOCAL_C_INCLUDES += \ 33 | system/extras/tests/include \ 34 | frameworks/base/include 35 | 36 | LOCAL_MODULE := binderAddInts 37 | LOCAL_SRC_FILES := binderAddInts.cpp 38 | 39 | include $(BUILD_NATIVE_BENCHMARK) 40 | -------------------------------------------------------------------------------- /tests/bootloader/shelltest.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2016 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import adb 16 | import os 17 | import unittest 18 | 19 | class ShellTest(unittest.TestCase): 20 | def __init__(self, *args, **kwargs): 21 | super(ShellTest, self).__init__(*args, **kwargs) 22 | self.device = adb.get_device(os.getenv("BOOTLOADER_TEST_SERIAL")); 23 | -------------------------------------------------------------------------------- /tests/cpueater/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # Copyright The Android Open Source Project 15 | 16 | LOCAL_PATH := $(call my-dir) 17 | 18 | include $(CLEAR_VARS) 19 | LOCAL_MODULE := cpueater 20 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 21 | LOCAL_MODULE_TAGS := eng 22 | LOCAL_SRC_FILES := cpueater.c 23 | LOCAL_CFLAGS := -Wno-unused-parameter 24 | include $(BUILD_EXECUTABLE) 25 | 26 | include $(CLEAR_VARS) 27 | LOCAL_MODULE := daemonize 28 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 29 | LOCAL_MODULE_TAGS := eng 30 | LOCAL_SRC_FILES := daemonize.c 31 | LOCAL_SHARED_LIBRARIES := libhardware_legacy 32 | include $(BUILD_EXECUTABLE) 33 | 34 | -------------------------------------------------------------------------------- /tests/crypto/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Android Open Source Project 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | 5 | include $(CLEAR_VARS) 6 | 7 | LOCAL_SRC_FILES:= get_dm_versions.c 8 | LOCAL_MODULE:= get_dm_versions 9 | LOCAL_MODULE_TAGS := optional 10 | LOCAL_CFLAGS := -Wno-unused-parameter 11 | include $(BUILD_EXECUTABLE) 12 | -------------------------------------------------------------------------------- /tests/crypto/get_dm_versions.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #define DM_CRYPT_BUF_SIZE 4096 10 | 11 | static void ioctl_init(struct dm_ioctl *io, size_t dataSize, const char *name, unsigned flags) 12 | { 13 | memset(io, 0, dataSize); 14 | io->data_size = dataSize; 15 | io->data_start = sizeof(struct dm_ioctl); 16 | io->version[0] = 4; 17 | io->version[1] = 0; 18 | io->version[2] = 0; 19 | io->flags = flags; 20 | if (name) { 21 | strncpy(io->name, name, sizeof(io->name)); 22 | } 23 | } 24 | 25 | int main(int argc, char *argv[]) 26 | { 27 | char buffer[DM_CRYPT_BUF_SIZE]; 28 | struct dm_ioctl *io; 29 | struct dm_target_versions *v; 30 | int i; 31 | int fd; 32 | 33 | fd = open("/dev/device-mapper", O_RDWR); 34 | if (fd < 0) { 35 | fprintf(stderr, "Cannot open /dev/device-mapper\n"); 36 | exit(1); 37 | } 38 | 39 | io = (struct dm_ioctl *) buffer; 40 | 41 | ioctl_init(io, DM_CRYPT_BUF_SIZE, NULL, 0); 42 | 43 | if (ioctl(fd, DM_LIST_VERSIONS, io)) { 44 | fprintf(stderr, "ioctl(DM_LIST_VERSIONS) returned an error\n"); 45 | exit(1); 46 | } 47 | 48 | /* Iterate over the returned versions, and print each subsystem's version */ 49 | v = (struct dm_target_versions *) &buffer[sizeof(struct dm_ioctl)]; 50 | while (v->next) { 51 | printf("%s: %d.%d.%d\n", v->name, v->version[0], v->version[1], v->version[2]); 52 | v = (struct dm_target_versions *)(((char *)v) + v->next); 53 | } 54 | 55 | close(fd); 56 | exit(0); 57 | } 58 | 59 | -------------------------------------------------------------------------------- /tests/directiotest/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_MODULE := directiotest 5 | LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) 6 | LOCAL_MODULE_TAGS := eng 7 | LOCAL_SRC_FILES := directiotest.c 8 | include $(BUILD_EXECUTABLE) 9 | -------------------------------------------------------------------------------- /tests/ext4/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2012 The Android Open Source Project 2 | 3 | local_target_dir := $(TARGET_OUT_DATA)/local/tmp 4 | LOCAL_PATH:= $(call my-dir) 5 | include $(CLEAR_VARS) 6 | 7 | LOCAL_SRC_FILES:= rand_emmc_perf.c 8 | LOCAL_MODULE:= rand_emmc_perf 9 | LOCAL_MULTILIB := both 10 | LOCAL_MODULE_STEM_32:= rand_emmc_perf 11 | LOCAL_MODULE_STEM_64:= rand_emmc_perf64 12 | LOCAL_MODULE_TAGS := optional 13 | LOCAL_MODULE_PATH := $(local_target_dir) 14 | LOCAL_FORCE_STATIC_EXECUTABLE := true 15 | LOCAL_STATIC_LIBRARIES := libm libc 16 | 17 | include $(BUILD_EXECUTABLE) 18 | 19 | -------------------------------------------------------------------------------- /tests/framebuffer/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_SRC_FILES:= \ 5 | refresh.c 6 | 7 | LOCAL_SHARED_LIBRARIES := \ 8 | libcutils 9 | 10 | LOCAL_MODULE:= test-fb-refresh 11 | 12 | LOCAL_CFLAGS := -Wno-unused-parameter 13 | 14 | include $(BUILD_EXECUTABLE) 15 | 16 | ## 17 | 18 | include $(CLEAR_VARS) 19 | LOCAL_SRC_FILES := fb_test.c 20 | LOCAL_MODULE = test-fb-simple 21 | LOCAL_FORCE_STATIC_EXECUTABLE := true 22 | LOCAL_STATIC_LIBRARIES := libc 23 | LOCAL_CFLAGS := -Wno-unused-parameter 24 | include $(BUILD_EXECUTABLE) 25 | -------------------------------------------------------------------------------- /tests/framebuffer/minui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef _MINUI_H_ 18 | #define _MINUI_H_ 19 | 20 | int gr_init(void); 21 | void gr_exit(void); 22 | 23 | int gr_fb_width(void); 24 | int gr_fb_height(void); 25 | void gr_flip(void); 26 | 27 | void gr_color(unsigned char r, unsigned char g, unsigned char b); 28 | void gr_fill(int x, int y, int w, int h); 29 | int gr_text(int x, int y, const char *s); 30 | int gr_measure(const char *s); 31 | 32 | 33 | typedef struct event event; 34 | 35 | struct event 36 | { 37 | unsigned type; 38 | unsigned code; 39 | unsigned value; 40 | }; 41 | 42 | int ev_init(void); 43 | void ev_exit(void); 44 | 45 | int ev_get(event *ev, unsigned dont_wait); 46 | 47 | #define TYPE_KEY 1 48 | 49 | #define KEY_UP 103 50 | #define KEY_DOWN 108 51 | #define KEY_LEFT 105 52 | #define KEY_RIGHT 106 53 | #define KEY_CENTER 232 54 | #define KEY_ENTER 28 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /tests/fstest/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2008 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | LOCAL_PATH := $(call my-dir) 16 | 17 | include $(CLEAR_VARS) 18 | LOCAL_MODULE_TAGS := tests 19 | LOCAL_MODULE := recovery_test 20 | LOCAL_SRC_FILES := recovery_test.cpp 21 | LOCAL_SHARED_LIBRARIES += libcutils libutils liblog liblogwrap 22 | LOCAL_STATIC_LIBRARIES += libtestUtil libfs_mgr 23 | LOCAL_C_INCLUDES += system/extras/tests/include \ 24 | system/extras/ext4_utils \ 25 | system/core/logwrapper/include 26 | include $(BUILD_NATIVE_TEST) 27 | -------------------------------------------------------------------------------- /tests/icachetest/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2006 The Android Open Source Project 2 | ifeq ($(TARGET_ARCH),arm) 3 | LOCAL_PATH:= $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_SRC_FILES:= icache_main.c icache.S icache2.S 7 | 8 | LOCAL_SHARED_LIBRARIES := libc 9 | 10 | LOCAL_MODULE:= icache 11 | 12 | LOCAL_MODULE_TAGS := optional 13 | 14 | include $(BUILD_EXECUTABLE) 15 | endif 16 | -------------------------------------------------------------------------------- /tests/icachetest/icache_main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern void icache_test(long count, long step); 5 | extern void icache_test2(long count); 6 | 7 | int main() 8 | { 9 | printf("[bytes]\t[us]\n"); 10 | 11 | struct timeval now, tm; 12 | long long t; 13 | long MBs; 14 | long i; 15 | long step = 32; 16 | for (i=0 ; step<=2048 ; i++, step+=32) 17 | { 18 | long value; 19 | gettimeofday(&now, 0); 20 | icache_test(0x800000L, step); 21 | gettimeofday(&tm, 0); 22 | t = (tm.tv_sec*1000000LL+tm.tv_usec) - (now.tv_sec*1000000LL+now.tv_usec); 23 | printf("%6ld\t%lld\n", step*32, t); 24 | } 25 | 26 | gettimeofday(&now, 0); 27 | icache_test2(0x800000L / 2048); 28 | gettimeofday(&tm, 0); 29 | t = (tm.tv_sec*1000000LL+tm.tv_usec) - (now.tv_sec*1000000LL+now.tv_usec); 30 | MBs = (8388608LL*32*1000000) / (t * (1024*1024)); 31 | printf("\n%6lld us\t%ld MB/s\n", t, MBs); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /tests/include/testUtil.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | #ifndef _TESTUTIL_H_ 19 | #define _TESTUTIL_H_ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | __BEGIN_DECLS 26 | 27 | // Time Utilities 28 | struct timespec double2ts(double amt); 29 | struct timeval double2tv(double amt); 30 | double ts2double(const struct timespec *val); 31 | double tv2double(const struct timeval *val); 32 | struct timespec tsDelta(const struct timespec *first, 33 | const struct timespec *second); 34 | struct timeval tvDelta(const struct timeval *first, 35 | const struct timeval *second); 36 | 37 | void testDelay(float amt); 38 | void testDelaySpin(float amt); 39 | 40 | // Pseudo Random Utilities 41 | int testRandBool(void); 42 | uint32_t testRand(void); 43 | uint32_t testRandMod(uint32_t mod); 44 | double testRandFract(void); 45 | 46 | // Testcase Output 47 | void testSetLogCatTag(const char *tag); 48 | const char *testGetLogCatTag(void); 49 | void testPrint(FILE *stream, const char *fmt, ...); 50 | #define testPrintI(...) do { \ 51 | testPrint(stdout, __VA_ARGS__); \ 52 | } while (0) 53 | #define testPrintE(...) do { \ 54 | testPrint(stderr, __VA_ARGS__); \ 55 | } while (0) 56 | 57 | // Hex Dump 58 | void testXDump(const void *buf, size_t size); 59 | void testXDumpSetIndent(uint8_t indent); 60 | uint8_t testXDumpGetIndent(void); 61 | void testXDumpSetOffset(uint64_t offset); 62 | uint64_t testXDumpGetOffset(void); 63 | 64 | // Command Execution 65 | void testExecCmd(const char *cmd); 66 | 67 | __END_DECLS 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /tests/iptables/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2011 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | include $(call all-subdir-makefiles) 18 | -------------------------------------------------------------------------------- /tests/iptables/qtaguid/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2011 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | LOCAL_PATH := $(call my-dir) 18 | 19 | include $(CLEAR_VARS) 20 | LOCAL_MODULE_TAGS := tests 21 | LOCAL_MODULE := socketTag 22 | LOCAL_SRC_FILES := socketTag.cpp 23 | LOCAL_SHARED_LIBRARIES += libcutils libutils liblog 24 | LOCAL_STATIC_LIBRARIES += libtestUtil 25 | LOCAL_C_INCLUDES += system/extras/tests/include 26 | LOCAL_CFLAGS += -fno-strict-aliasing 27 | 28 | include $(BUILD_NATIVE_TEST) 29 | -------------------------------------------------------------------------------- /tests/kernel.config/AndroidTest.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | 22 | 23 | 26 | 27 | -------------------------------------------------------------------------------- /tests/kernel.config/logger_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | 18 | #include 19 | 20 | TEST(kernel_config, NOT_CONFIG_ANDROID_LOGGER) { 21 | EXPECT_NE(0, access("/dev/log/main", F_OK)); 22 | EXPECT_NE(0, access("/dev/log_main", F_OK)); 23 | EXPECT_NE(0, access("/dev/log/radio", F_OK)); 24 | EXPECT_NE(0, access("/dev/log_radio", F_OK)); 25 | EXPECT_NE(0, access("/dev/log/events", F_OK)); 26 | EXPECT_NE(0, access("/dev/log_events", F_OK)); 27 | EXPECT_NE(0, access("/dev/log/system", F_OK)); 28 | EXPECT_NE(0, access("/dev/log_system", F_OK)); 29 | } 30 | -------------------------------------------------------------------------------- /tests/kernel.config/mmc_max_speed_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | 18 | #include 19 | 20 | TEST(kernel_config, CONFIG_MMC_BLOCK_MAX_SPEED) { 21 | EXPECT_EQ(0, access("/sys/block/mmcblk0/max_read_speed", F_OK)); 22 | EXPECT_EQ(0, access("/sys/block/mmcblk0/max_write_speed", F_OK)); 23 | EXPECT_EQ(0, access("/sys/block/mmcblk0/cache_size", F_OK)); 24 | } 25 | -------------------------------------------------------------------------------- /tests/kernel.config/multicast_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | 18 | #include 19 | 20 | TEST(kernel_config, CONFIG_IPV6) { 21 | EXPECT_EQ(0, access("/proc/net/igmp6", F_OK)); 22 | } 23 | 24 | TEST(kernel_config, CONFIG_IP_MULTICAST) { 25 | EXPECT_EQ(0, access("/proc/net/igmp", F_OK)); 26 | } 27 | -------------------------------------------------------------------------------- /tests/kernel.config/pstore_test.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) 2016 The Android Open Source Project 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | #include 18 | 19 | #include 20 | 21 | TEST(kernel_config, CONFIG_PSTORE) { 22 | EXPECT_EQ(0, access("/sys/fs/pstore", F_OK)); 23 | } 24 | 25 | TEST(kernel_config, CONFIG_PSTORE_CONSOLE) { 26 | EXPECT_EQ(0, access("/sys/fs/pstore/console-ramoops", F_OK)); 27 | } 28 | 29 | TEST(kernel_config, CONFIG_PSTORE_PMSG) { 30 | EXPECT_EQ(0, access("/dev/pmsg0", F_OK)); 31 | EXPECT_EQ(0, access("/sys/fs/pstore/pmsg-ramoops-0", F_OK)); 32 | } 33 | -------------------------------------------------------------------------------- /tests/kernel.config/scrape_mmap_addr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc, char * argv[]) { 9 | if (argc != 2) { 10 | std::cerr << "usage: " << argv[0] << ": libname\n"; 11 | return -1; 12 | } 13 | std::regex reg(std::string("^([a-f0-9]+)\\-[0-9a-f]+\\s+.+\\s+(\\d+)\\s+.+\\s+\\d+\\s+") + std::string(argv[1]) + std::string("\\s*$")); 14 | 15 | /* open /proc/self/maps */ 16 | std::string ln; 17 | std::ifstream m_file("/proc/self/maps"); 18 | if (!m_file) { 19 | std::cerr << "Unable to open /proc/self/maps " << strerror(errno) << "\n"; 20 | return -1; 21 | } 22 | while (getline(m_file, ln)) { 23 | std::smatch sm; 24 | if (std::regex_match (ln,sm, reg)) { 25 | if (std::stoi(sm[2]) == 0) { 26 | std::cout << sm[1]; 27 | return 0; 28 | } 29 | } 30 | } 31 | return -1; 32 | } 33 | -------------------------------------------------------------------------------- /tests/kernel.config/sysvipc_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | #include 17 | #ifdef HAS_KCMP 18 | #include 19 | #include 20 | #endif 21 | #include 22 | 23 | #include 24 | 25 | #ifdef HAS_KCMP 26 | int kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) { 27 | return syscall(SYS_kcmp, pid1, pid2, type, 0, idx1, idx2); 28 | } 29 | #endif 30 | 31 | TEST(kernel_config, NOT_CONFIG_SYSVIPC) { 32 | #ifdef HAS_KCMP 33 | pid_t pid = getpid(); 34 | int ret = kcmp(pid, pid, KCMP_SYSVSEM, 0, 0); 35 | int error = (ret == -1) ? (errno == ENOSYS) ? EOPNOTSUPP : errno : 0; 36 | EXPECT_EQ(-1, kcmp(pid, pid, KCMP_SYSVSEM, 0, 0)); 37 | EXPECT_EQ(EOPNOTSUPP, error); 38 | #endif 39 | EXPECT_EQ(-1, access("/proc/sysvipc", F_OK)); 40 | EXPECT_EQ(-1, access("/proc/sysvipc/msg", F_OK)); 41 | EXPECT_EQ(-1, access("/proc/sysvipc/sem", F_OK)); 42 | EXPECT_EQ(-1, access("/proc/sysvipc/shm", F_OK)); 43 | } 44 | 45 | -------------------------------------------------------------------------------- /tests/lib/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2010 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | LOCAL_PATH:= $(call my-dir) 18 | include $(call all-subdir-makefiles) 19 | -------------------------------------------------------------------------------- /tests/lib/testUtil/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2010 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | LOCAL_PATH:= $(call my-dir) 18 | 19 | include $(CLEAR_VARS) 20 | LOCAL_MODULE_TAGS := tests 21 | LOCAL_MODULE:= libtestUtil 22 | LOCAL_SRC_FILES:= testUtil.c 23 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../include 24 | LOCAL_CFLAGS += -std=c99 25 | LOCAL_SHARED_LIBRARIES += libcutils libutils 26 | 27 | 28 | include $(BUILD_STATIC_LIBRARY) 29 | -------------------------------------------------------------------------------- /tests/memtest/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2006 The Android Open Source Project 2 | ifneq ($(filter $(TARGET_ARCH),arm arm64),) 3 | 4 | LOCAL_PATH:= $(call my-dir) 5 | 6 | include $(CLEAR_VARS) 7 | 8 | LOCAL_SRC_FILES := \ 9 | memtest.cpp \ 10 | fptest.cpp \ 11 | thumb.cpp \ 12 | bandwidth.cpp \ 13 | 14 | LOCAL_MODULE := memtest 15 | LOCAL_MODULE_TAGS := debug 16 | LOCAL_CFLAGS += \ 17 | -fomit-frame-pointer \ 18 | -Wall \ 19 | -Werror \ 20 | 21 | LOCAL_MULTILIB := 32 22 | 23 | LOCAL_SANITIZE := never 24 | 25 | include $(BUILD_EXECUTABLE) 26 | endif 27 | -------------------------------------------------------------------------------- /tests/memtest/memtest.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef __MEMTEST_H__ 18 | #define __MEMTEST_H__ 19 | 20 | typedef long long nsecs_t; 21 | 22 | // Function prototypes. 23 | nsecs_t system_time(); 24 | 25 | #endif // __MEMTEST_H__ 26 | -------------------------------------------------------------------------------- /tests/memtest/thumb.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern "C" void arm_function_3(int* p); 5 | extern "C" void thumb_function_1(int* p); 6 | extern "C" void thumb_function_2(int* p); 7 | 8 | extern "C" _Unwind_Reason_Code trace_function(_Unwind_Context* context, void *) { 9 | printf("0x%x\n", _Unwind_GetIP(context)); 10 | fflush(stdout); 11 | return _URC_NO_REASON; 12 | } 13 | 14 | void thumb_function_1(int*) { 15 | int a = 0; 16 | arm_function_3(&a); 17 | } 18 | 19 | void thumb_function_2(int*) { 20 | printf("unwinding...\n"); 21 | _Unwind_Backtrace(trace_function, (void*) "backtrace!"); 22 | } 23 | -------------------------------------------------------------------------------- /tests/mmc_tracepoints/README: -------------------------------------------------------------------------------- 1 | The code in this directory is used to process data from the mmc tracepoints 2 | in the kernel. To turn on mmc tracing, do this: 3 | 4 | adb shell echo 1 >/d/tracing/events/mmc/enable 5 | adb shell echo 1 >/d/tracing/tracing_on 6 | 7 | To get the trace: 8 | 9 | adb pull /d/tracing/trace 10 | 11 | To turn it back off, do: 12 | 13 | adb shell echo 0 >/d/tracing/tracing_enabled 14 | 15 | The output is in a form of start/stop pairs. The ops with rw in the name are 16 | read or write ops, and the ones with erase in the name are the various erase 17 | opts. 18 | 19 | The mmc_trace_reduce script will take the output from the kernel, and convert it 20 | to a single line per event, which includes the duration of the event. 21 | 22 | This can then be fed into other tools for further analysis. 23 | 24 | The file mmc_trace_sample_data contains sample mmc trace data from a Nexus 10. 25 | It includes read, write and discard entries. The discard entries came from 26 | invoking fstrim in vold with "vdc fstrim dotrim". 27 | 28 | -------------------------------------------------------------------------------- /tests/net_test/all_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2014 The Android Open Source Project 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | readonly PREFIX="#####" 18 | 19 | function maybePlural() { 20 | # $1 = integer to use for plural check 21 | # $2 = singular string 22 | # $3 = plural string 23 | if [ $1 -ne 1 ]; then 24 | echo "$3" 25 | else 26 | echo "$2" 27 | fi 28 | } 29 | 30 | 31 | readonly tests=$(find . -name '*_test.py' -type f -executable) 32 | readonly count=$(echo $tests | wc -w) 33 | echo "$PREFIX Found $count $(maybePlural $count test tests)." 34 | 35 | exit_code=0 36 | 37 | i=0 38 | for test in $tests; do 39 | i=$((i + 1)) 40 | echo "" 41 | echo "$PREFIX $test ($i/$count)" 42 | echo "" 43 | $test || exit_code=$(( exit_code + 1 )) 44 | echo "" 45 | done 46 | 47 | echo "$PREFIX $exit_code failed $(maybePlural $exit_code test tests)." 48 | exit $exit_code 49 | -------------------------------------------------------------------------------- /tests/net_test/cstruct_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # 3 | # Copyright 2016 The Android Open Source Project 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | import unittest 18 | 19 | import cstruct 20 | 21 | 22 | # These aren't constants, they're classes. So, pylint: disable=invalid-name 23 | TestStructA = cstruct.Struct("TestStructA", "=BI", "byte1 int2") 24 | TestStructB = cstruct.Struct("TestStructB", "=BI", "byte1 int2") 25 | 26 | 27 | class CstructTest(unittest.TestCase): 28 | 29 | def CheckEquals(self, a, b): 30 | self.assertEquals(a, b) 31 | self.assertEquals(b, a) 32 | assert a == b 33 | assert b == a 34 | assert not (a != b) # pylint: disable=g-comparison-negation,superfluous-parens 35 | assert not (b != a) # pylint: disable=g-comparison-negation,superfluous-parens 36 | 37 | def CheckNotEquals(self, a, b): 38 | self.assertNotEquals(a, b) 39 | self.assertNotEquals(b, a) 40 | assert a != b 41 | assert b != a 42 | assert not (a == b) # pylint: disable=g-comparison-negation,superfluous-parens 43 | assert not (b == a) # pylint: disable=g-comparison-negation,superfluous-parens 44 | 45 | def testEqAndNe(self): 46 | a1 = TestStructA((1, 2)) 47 | a2 = TestStructA((2, 3)) 48 | a3 = TestStructA((1, 2)) 49 | b = TestStructB((1, 2)) 50 | self.CheckNotEquals(a1, b) 51 | self.CheckNotEquals(a2, b) 52 | self.CheckNotEquals(a1, a2) 53 | self.CheckNotEquals(a2, a3) 54 | for i in [a1, a2, a3, b]: 55 | self.CheckEquals(i, i) 56 | self.CheckEquals(a1, a3) 57 | 58 | 59 | if __name__ == "__main__": 60 | unittest.main() 61 | -------------------------------------------------------------------------------- /tests/net_test/net_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # In case IPv6 is compiled as a module. 4 | [ -f /proc/net/if_inet6 ] || insmod $DIR/kernel/net-next/net/ipv6/ipv6.ko 5 | 6 | # Minimal network setup. 7 | ip link set lo up 8 | ip link set lo mtu 16436 9 | ip link set eth0 up 10 | 11 | # Allow people to run ping. 12 | echo "0 65536" > /proc/sys/net/ipv4/ping_group_range 13 | 14 | # Fall out to a shell once the test completes or if there's an error. 15 | trap "exec /bin/bash" ERR EXIT 16 | 17 | # Find and run the test. 18 | test=$(cat /proc/cmdline | sed -re 's/.*net_test=([^ ]*).*/\1/g') 19 | echo -e "Running $test\n" 20 | $test 21 | -------------------------------------------------------------------------------- /tests/net_test/ping6_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Minimal network initialization. 4 | ip link set eth0 up 5 | 6 | # Wait for autoconf and DAD to complete. 7 | sleep 3 & 8 | 9 | # Block on starting DHCPv4. 10 | udhcpc -i eth0 11 | 12 | # If DHCPv4 took less than 3 seconds, keep waiting. 13 | wait 14 | 15 | # Run the test. 16 | $(dirname $0)/ping6_test.py 17 | -------------------------------------------------------------------------------- /tests/pagingtest/Android.mk: -------------------------------------------------------------------------------- 1 | local_target_dir := $(TARGET_OUT_DATA)/local/tmp 2 | LOCAL_PATH:= $(call my-dir) 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_SRC_FILES:= \ 6 | pagingtest.c \ 7 | mmap_test.c \ 8 | pageinout_test.c \ 9 | thrashing_test.c 10 | 11 | LOCAL_CFLAGS := -std=gnu11 12 | 13 | LOCAL_MODULE:= pagingtest 14 | 15 | LOCAL_MODULE_TAGS := tests 16 | 17 | LOCAL_MODULE_PATH := $(local_target_dir) 18 | LOCAL_MULTILIB := both 19 | LOCAL_MODULE_STEM_32 := pagingtest 20 | LOCAL_MODULE_STEM_64 := pagingtest64 21 | 22 | include $(BUILD_EXECUTABLE) 23 | -------------------------------------------------------------------------------- /tests/pagingtest/mmap_test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "pagingtest.h" 9 | 10 | int mmap_test(int test_runs, unsigned long long alloc_size) { 11 | void *buf; 12 | int ret = -1; 13 | int rc; 14 | int i; 15 | struct timeval begin_time, end_time, elapsed_time; 16 | struct timeval total_time_mmap, total_time_munmap, total_time_in, total_time_out; 17 | 18 | timerclear(&total_time_mmap); 19 | timerclear(&total_time_munmap); 20 | timerclear(&total_time_in); 21 | timerclear(&total_time_out); 22 | 23 | for (i = 0; i < test_runs; i++) { 24 | gettimeofday(&begin_time, NULL); 25 | buf = mmap(NULL, alloc_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 26 | gettimeofday(&end_time, NULL); 27 | if (buf == ((void *)-1)) { 28 | fprintf(stderr, "Failed to mmap anonymous memory: %s\n", strerror(errno)); 29 | goto err_map; 30 | } 31 | timersub(&end_time, &begin_time, &elapsed_time); 32 | timeradd(&total_time_mmap, &elapsed_time, &total_time_mmap); 33 | 34 | gettimeofday(&begin_time, NULL); 35 | munmap(buf, alloc_size); 36 | gettimeofday(&end_time, NULL); 37 | timersub(&end_time, &begin_time, &elapsed_time); 38 | timeradd(&total_time_mmap, &elapsed_time, &total_time_mmap); 39 | } 40 | 41 | printf("mmap: %llu us\n", total_time_mmap.tv_sec * USEC_PER_SEC + total_time_mmap.tv_usec); 42 | printf("munmap: %llu us\n", total_time_munmap.tv_sec * USEC_PER_SEC + total_time_munmap.tv_usec); 43 | 44 | ret = 0; 45 | goto end; 46 | err: 47 | munmap(buf, alloc_size); 48 | end: 49 | err_map: 50 | return ret; 51 | } 52 | -------------------------------------------------------------------------------- /tests/pagingtest/pagingtest.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #ifndef __PAGINGTEST_H__ 5 | #define __PAGINGTEST_H__ 6 | #define USEC_PER_SEC 1000000ULL 7 | #define mincore_vec_len(size) (((size) + sysconf(_SC_PAGE_SIZE) - 1) / sysconf(_SC_PAGE_SIZE)) 8 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) 9 | 10 | //Helpers 11 | int create_tmp_file(char *filename, off_t size); 12 | unsigned char *alloc_mincore_vec(size_t size); 13 | bool check_caching(void *buf, unsigned char *vec, size_t size, bool is_cached); 14 | 15 | //Tests 16 | int mmap_test(int test_runs, unsigned long long alloc_size); 17 | int pageinout_test(int test_runs, unsigned long long file_size); 18 | int thrashing_test(int test_runs); 19 | 20 | #endif //__PAGINGTEST_H__ 21 | -------------------------------------------------------------------------------- /tests/pftest/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2010 The Android Open Source Project 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_SRC_FILES:= pftest.c.arm 7 | 8 | 9 | LOCAL_SHARED_LIBRARIES := libc 10 | 11 | LOCAL_MODULE:= pftest 12 | 13 | LOCAL_MODULE_TAGS := optional 14 | 15 | ## LOCAL_CFLAGS += -fstack-protector-all 16 | LOCAL_CFLAGS += -fomit-frame-pointer 17 | 18 | include $(BUILD_EXECUTABLE) 19 | -------------------------------------------------------------------------------- /tests/schedtest/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_SRC_FILES := \ 6 | schedtest.c 7 | 8 | LOCAL_MODULE := schedtest 9 | LOCAL_CFLAGS := -Wno-unused-parameter 10 | 11 | include $(BUILD_EXECUTABLE) 12 | -------------------------------------------------------------------------------- /tests/schedtest/schedtest.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright 2008 The Android Open Source Project 3 | ** 4 | ** Licensed under the Apache License, Version 2.0 (the "License"); 5 | ** you may not use this file except in compliance with the License. 6 | ** You may obtain a copy of the License at 7 | ** 8 | ** http://www.apache.org/licenses/LICENSE-2.0 9 | ** 10 | ** Unless required by applicable law or agreed to in writing, software 11 | ** distributed under the License is distributed on an "AS IS" BASIS, 12 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | ** See the License for the specific language governing permissions and 14 | ** limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | int main(int argc, char **argv) { 25 | int i; 26 | 27 | struct timeval tv1; 28 | struct timeval tv2; 29 | long max = 0; 30 | long avg = 0; 31 | 32 | for(i = 1; ; i++) { 33 | gettimeofday(&tv1, NULL); 34 | usleep(1000); 35 | gettimeofday(&tv2, NULL); 36 | 37 | long usec = (tv2.tv_sec - tv1.tv_sec) * 1000000 + tv2.tv_usec - tv1.tv_usec; 38 | avg += usec; 39 | 40 | if (usec > max) max = usec; 41 | if (!(i % 1000)) { 42 | avg /= 1000; 43 | printf("max %ld\tavg %ld\n", max, avg); 44 | max = 0; 45 | avg = 0; 46 | } 47 | } 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /tests/sdcard/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2009 The Android Open Source Project 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # 15 | # Build control file for Bionic's test programs 16 | # define the BIONIC_TESTS environment variable to build the test programs 17 | # 18 | 19 | ifdef SDCARD_TESTS 20 | 21 | LOCAL_PATH:= $(call my-dir) 22 | 23 | include $(CLEAR_VARS) 24 | 25 | LOCAL_SRC_FILES = \ 26 | stopwatch.cpp \ 27 | sysutil.cpp \ 28 | sdcard_perf_test.cpp \ 29 | testcase.cpp 30 | 31 | LOCAL_MODULE := sdcard_perf_test 32 | LOCAL_MODULE_TAGS := eng tests 33 | LOCAL_SHARED_LIBRARIES := libutils libhardware_legacy 34 | 35 | include $(BUILD_EXECUTABLE) 36 | 37 | endif # SDCARD_TESTS 38 | -------------------------------------------------------------------------------- /tests/sdcard/README: -------------------------------------------------------------------------------- 1 | This directory contains tools to profile the sdcard performance. 2 | 3 | There are 2 parts to the tool: 4 | * A binary that runs on the device, exercises the sdcard and send 5 | measurment data back to the host (sdcard_perf_test). 6 | * A host python script to plot the data. 7 | 8 | Additionally, there is script 'profile_sdcard.sh' that allows you 9 | to check how the sdcard scale with the number of processes. 10 | 11 | INSTALLATION 12 | ============ 13 | Build, install and mount debugfs. In this directory with a properly 14 | configured enviroment: 15 | 16 | mm SDCARD_TESTS=1 17 | adb remount 18 | adb push $ANDROID_PRODUCT_OUT/system/bin/sdcard_perf_test /system/bin/sdcard_perf_test 19 | adb shell mount -t debugfs none /sys/kernel/debug 20 | 21 | If you want to graph the results you need gnuplot and numpy: 22 | 23 | sudo apt-get install gnuplot python-numpy python-numeric 24 | 25 | You need Gnuplot.py version 1.8 (not the one coming with ubuntu). 26 | Download it from the Gnuplot.py web site. Extract to a temp 27 | directory, chdir and run: 28 | 29 | sudo python setup.py install 30 | 31 | 32 | INVOCATION 33 | ========== 34 | 35 | Run a simple test: 36 | 37 | adb shell sdcard_perf_test --test=write --size=1000 --chunk-size=100 --procnb=1 --iterations=100 38 | 39 | This test will write 1000kbyte (1M) files using writes of 100kbytes (so 10 writes per file) using 40 | only 1 process for 100 times (100 files will be written on the sdcard). 41 | The test will not call sync to flush the writes. 42 | At the end of the test, some stats for the 'open' and 'write' system calls are written. 43 | 44 | If you want to plot the data, you need to use the --dump option and provide a file: 45 | 46 | adb shell sdcard_perf_test --test=write --size=1000 --chunk-size=100 --procnb=1 --iterations=100 --dump >/tmp/data.txt 47 | 48 | PLOTTING 49 | ======== 50 | 51 | To plot the result using the iter number of the x axis: 52 | 53 | plot_sdcard.py -i /tmp/data.txt 54 | 55 | To plot the result using time for the x axis: 56 | 57 | plot_sdcard.py -t /tmp/data.txt 58 | 59 | To plot the result from the profiler: 60 | 61 | profile_sdcard.sh 62 | plot_sdcard.py -p 63 | 64 | -------------------------------------------------------------------------------- /tests/storage/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2013 The Android Open Source Project 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | include $(CLEAR_VARS) 5 | 6 | include $(CLEAR_VARS) 7 | LOCAL_SRC_FILES := opentest.c 8 | LOCAL_MODULE := opentest 9 | LOCAL_MODULE_TAGS := optional 10 | include $(BUILD_EXECUTABLE) 11 | 12 | include $(CLEAR_VARS) 13 | LOCAL_SRC_FILES := wipe_blkdev.c 14 | LOCAL_MODULE := wipe_blkdev 15 | LOCAL_MODULE_TAGS := optional 16 | include $(BUILD_EXECUTABLE) 17 | 18 | -------------------------------------------------------------------------------- /tests/suspend_stress/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_SRC_FILES := suspend_stress.cpp 5 | LOCAL_MODULE := suspend_stress 6 | LOCAL_CFLAGS := -Wall -Werror 7 | LOCAL_FORCE_STATIC_EXECUTABLE := true 8 | LOCAL_STATIC_LIBRARIES := libc libcutils 9 | include $(BUILD_EXECUTABLE) 10 | -------------------------------------------------------------------------------- /tests/tcp_nuke_addr/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_MODULE := tcp_nuke_addr_test 5 | 6 | LOCAL_C_INCLUDES += frameworks/native/include external/libcxx/include 7 | LOCAL_CPPFLAGS += -std=c++11 -Wall -Werror 8 | LOCAL_SHARED_LIBRARIES := libc++ 9 | LOCAL_SRC_FILES := tcp_nuke_addr_test.cpp 10 | LOCAL_MODULE_TAGS := eng tests 11 | 12 | include $(BUILD_NATIVE_TEST) 13 | -------------------------------------------------------------------------------- /tests/timetest/Android.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2006 The Android Open Source Project 2 | 3 | LOCAL_PATH:= $(call my-dir) 4 | 5 | include $(CLEAR_VARS) 6 | 7 | LOCAL_SRC_FILES:= timetest.c 8 | 9 | LOCAL_MODULE:= timetest 10 | 11 | LOCAL_MODULE_TAGS := optional 12 | 13 | LOCAL_FORCE_STATIC_EXECUTABLE := true 14 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN) 15 | LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED) 16 | 17 | LOCAL_STATIC_LIBRARIES := libc 18 | 19 | include $(BUILD_EXECUTABLE) 20 | 21 | # ----------------------------------------------------------------------------- 22 | # Unit tests. 23 | # ----------------------------------------------------------------------------- 24 | 25 | test_c_flags := \ 26 | -fstack-protector-all \ 27 | -g \ 28 | -Wall -Wextra \ 29 | -Werror \ 30 | -fno-builtin \ 31 | -std=gnu++11 32 | 33 | test_src_files := \ 34 | rtc_test.cpp 35 | 36 | include $(CLEAR_VARS) 37 | LOCAL_MODULE := time-unit-tests 38 | LOCAL_MODULE_TAGS := tests 39 | LOCAL_CFLAGS += $(test_c_flags) 40 | LOCAL_SRC_FILES := $(test_src_files) 41 | include $(BUILD_NATIVE_TEST) 42 | 43 | -------------------------------------------------------------------------------- /tests/uevents/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | LOCAL_SRC_FILES := uevents.c 5 | 6 | LOCAL_SHARED_LIBRARIES += libcutils 7 | LOCAL_MODULE:= uevents 8 | 9 | LOCAL_CFLAGS := -Wno-unused-parameter 10 | 11 | include $(BUILD_EXECUTABLE) 12 | -------------------------------------------------------------------------------- /tests/uevents/uevents.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #include 18 | #include 19 | 20 | #define UEVENT_MSG_LEN 1024 21 | 22 | int main(int argc, char *argv[]) 23 | { 24 | int device_fd; 25 | char msg[UEVENT_MSG_LEN+2]; 26 | int n; 27 | int i; 28 | 29 | device_fd = uevent_open_socket(64*1024, true); 30 | if(device_fd < 0) 31 | return -1; 32 | 33 | while ((n = uevent_kernel_multicast_recv(device_fd, msg, UEVENT_MSG_LEN)) > 0) { 34 | msg[n] = '\0'; 35 | msg[n+1] = '\0'; 36 | 37 | for (i = 0; i < n; i++) 38 | if (msg[i] == '\0') 39 | msg[i] = ' '; 40 | 41 | printf("%s\n", msg); 42 | } 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /tests/wifi/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2010 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # 16 | 17 | include $(call all-subdir-makefiles) 18 | -------------------------------------------------------------------------------- /tests/wifi/stress/Android.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2010 The Android Open Source Project 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | # Copyright The Android Open Source Project 16 | 17 | LOCAL_PATH := $(call my-dir) 18 | 19 | include $(CLEAR_VARS) 20 | LOCAL_MODULE_TAGS := tests 21 | LOCAL_MODULE := wifiLoadScanAssoc 22 | LOCAL_SRC_FILES := wifiLoadScanAssoc.c 23 | LOCAL_SHARED_LIBRARIES += libcutils libutils liblog libhardware_legacy 24 | LOCAL_STATIC_LIBRARIES += libtestUtil 25 | LOCAL_C_INCLUDES += system/extras/tests/include \ 26 | hardware/libhardware_legacy/include 27 | 28 | include $(BUILD_NATIVE_TEST) 29 | -------------------------------------------------------------------------------- /tests/workloads/atrace-uncompress.py: -------------------------------------------------------------------------------- 1 | # 2 | # Uncompress a file generated via atrace -z 3 | # 4 | # Usage: python atrace-uncompress.py infile > outfile 5 | # 6 | import sys, zlib 7 | 8 | def main(): 9 | 10 | if len(sys.argv) != 2: 11 | print >> sys.stderr, ('Usage: %s inputfile' % sys.argv[0]) 12 | sys.exit(1) 13 | 14 | infile = open(sys.argv[1], "rb") 15 | out = infile.read() 16 | parts = out.split('\nTRACE:', 1) 17 | 18 | data = ''.join(parts[1]) 19 | 20 | # Remove CR characters 21 | if data.startswith('\r\n'): 22 | data = data.replace('\r\n', '\n') 23 | 24 | # Skip the initial newline. 25 | data = data[1:] 26 | 27 | if not data: 28 | print >> sys.stderr, ('No trace data found') 29 | sys.exit(1) 30 | 31 | out = zlib.decompress(data) 32 | print(out) 33 | 34 | if __name__ == '__main__': 35 | main() 36 | -------------------------------------------------------------------------------- /tests/workloads/capture.sh: -------------------------------------------------------------------------------- 1 | # Capture and display input events and coordinates 2 | # 3 | # Usage: ./capture.sh 4 | # 5 | 6 | # do a throw-away adb in case the server is out-of-date 7 | adb devices -l 2>&1 >/dev/null 8 | 9 | while [ $# -gt 0 ] 10 | do 11 | case "$1" in 12 | (-d) DEVICE=$2; shift;; 13 | (*) 14 | echo Unknown option $1 15 | exit 1;; 16 | esac 17 | shift 18 | done 19 | 20 | if [ "$DEVICE" = "" ]; then 21 | devInfo=$(adb devices -l | grep -v ^List | head -1) 22 | set -- $devInfo 23 | echo devInfo=$devInfo 24 | DEVICE=$(echo $4 | sed 's/product://') 25 | fi 26 | 27 | function convert { 28 | in=$1 29 | max=$2 30 | scale=$3 31 | if [ $max -eq 0 ]; then 32 | echo $in 33 | else 34 | ((out=in*scale/max)) 35 | echo $out 36 | fi 37 | } 38 | 39 | 40 | case $DEVICE in 41 | (shamu|hammerhead|bullhead|ariel) 42 | # no scaling necessary 43 | xmax=0 44 | ymax=0;; 45 | (volantis) 46 | xmax=3060 47 | xscale=1500 48 | ymax=2304 49 | yscale=1950;; 50 | (*) 51 | echo "Error: No display information available for $DEVICE" 52 | exit 1;; 53 | esac 54 | 55 | echo Capturing input for $DEVICE... 56 | stdbuf -o0 adb shell getevent -t | 57 | stdbuf -o0 grep "event.: 0003" | 58 | stdbuf -o0 grep "0003 003[0156a9]" | 59 | stdbuf -o0 tr ':[] ' ' ' | while read line 60 | do 61 | set -- $line 62 | code=$4 63 | value=$((16#$5)) 64 | case $code in 65 | (0035) x=$(convert $value $xmax $xscale);; 66 | (0036) y=$(convert $value $ymax $yscale);; 67 | (0030) tag="majorTouch";; 68 | (0031) tag="minorTouch";; 69 | (003a) tag="pressure";; 70 | (0039) tag="trackingId";; 71 | (--) echo unknown code=$code;; 72 | esac 73 | printf "%-10s %-4d %-4d\n" $tag $x $y 74 | done 75 | -------------------------------------------------------------------------------- /tests/workloads/powerave.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | import sys 4 | import getopt 5 | 6 | def usage(): 7 | print "powersum.py [OPTIONS] HZ VOLTAGE [FILE]" 8 | print "OPTIONS: " 9 | print "-o OFFSET: subtract OFFSET from all data points" 10 | print "\nHZ: samples per second in FILE or stdin" 11 | sys.exit(0) 12 | 13 | offset = 0.0 14 | voltage = 4.3 15 | 16 | parsedargv,argvrem = getopt.getopt(sys.argv[1:], "vo:w:l:h", ["help"]) 17 | for o,a in parsedargv: 18 | if o == '-o': offset = float(a) 19 | if o == '-h' or o == '--help': usage() 20 | 21 | hz = float(argvrem[0]) 22 | voltage = float(argvrem[1]) 23 | if len(argvrem) > 1: 24 | f = open(argvrem[2], "r") 25 | else: 26 | f = sys.stdin 27 | 28 | totalpower = 0.0 29 | samplectr = 0 30 | 31 | for line in f: 32 | try: 33 | val = float(line.split(" ")[1]) # xxx take 2nd arg in line 34 | val -= offset 35 | except: 36 | print "Can't parse data line, did you remember the timestamp?" 37 | print "data was: %s" % line 38 | sys.exit(1) 39 | 40 | samplectr+=1 41 | totalpower += val/hz 42 | 43 | avecurrent = totalpower * hz *1000 / samplectr 44 | avepower = avecurrent * voltage 45 | 46 | print "%.3f %.3f" % (avecurrent, avepower) 47 | -------------------------------------------------------------------------------- /verity/BootSignature.mf: -------------------------------------------------------------------------------- 1 | Main-Class: com.android.verity.BootSignature 2 | -------------------------------------------------------------------------------- /verity/KeystoreSigner.mf: -------------------------------------------------------------------------------- 1 | Main-Class: com.android.verity.BootKeystore 2 | -------------------------------------------------------------------------------- /verity/VeritySigner.mf: -------------------------------------------------------------------------------- 1 | Main-Class: com.android.verity.VeritySigner 2 | -------------------------------------------------------------------------------- /verity/VerityVerifier.mf: -------------------------------------------------------------------------------- 1 | Main-Class: com.android.verity.VerityVerifier 2 | -------------------------------------------------------------------------------- /verity/boot_signer: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # Start-up script for BootSigner 4 | 5 | BOOTSIGNER_HOME=`dirname "$0"` 6 | BOOTSIGNER_HOME=`dirname "$BOOTSIGNER_HOME"` 7 | 8 | java -Xmx512M -jar "$BOOTSIGNER_HOME"/framework/BootSignature.jar "$@" -------------------------------------------------------------------------------- /verity/fec/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_CLANG := true 5 | ifeq ($(HOST_OS),linux) 6 | LOCAL_SANITIZE := integer 7 | endif 8 | LOCAL_MODULE := fec 9 | LOCAL_SRC_FILES := main.cpp image.cpp 10 | LOCAL_MODULE_TAGS := optional 11 | LOCAL_STATIC_LIBRARIES := \ 12 | libsparse_host \ 13 | libz \ 14 | libcrypto_utils_static \ 15 | libcrypto_static \ 16 | libfec_host \ 17 | libfec_rs_host \ 18 | libext4_utils_host \ 19 | libsquashfs_utils_host 20 | LOCAL_SHARED_LIBRARIES := libbase 21 | LOCAL_CFLAGS += -Wall -Werror -O3 22 | LOCAL_C_INCLUDES += external/fec 23 | include $(BUILD_HOST_EXECUTABLE) 24 | 25 | include $(CLEAR_VARS) 26 | LOCAL_CLANG := true 27 | LOCAL_SANITIZE := integer 28 | LOCAL_MODULE := fec 29 | LOCAL_FORCE_STATIC_EXECUTABLE := true 30 | LOCAL_SRC_FILES := main.cpp image.cpp 31 | LOCAL_MODULE_TAGS := optional 32 | LOCAL_STATIC_LIBRARIES := \ 33 | libcrypto_utils_static \ 34 | libcrypto_static \ 35 | libfec \ 36 | libfec_rs \ 37 | libbase \ 38 | libext4_utils_static \ 39 | libsquashfs_utils \ 40 | libcutils 41 | LOCAL_CFLAGS += -Wall -Werror -O3 -DIMAGE_NO_SPARSE=1 42 | LOCAL_C_INCLUDES += external/fec 43 | include $(BUILD_EXECUTABLE) 44 | -------------------------------------------------------------------------------- /verity/keystore_signer: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # Start-up script for KeystoreSigner 4 | 5 | KEYSTORESIGNER_HOME=`dirname "$0"` 6 | KEYSTORESIGNER_HOME=`dirname "$KEYSTORESIGNER_HOME"` 7 | 8 | java -Xmx512M -jar "$KEYSTORESIGNER_HOME"/framework/BootKeystoreSigner.jar "$@" 9 | -------------------------------------------------------------------------------- /verity/verity_signer: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # Start-up script for VeritySigner 4 | 5 | VERITYSIGNER_HOME=`dirname "$0"` 6 | VERITYSIGNER_HOME=`dirname "$VERITYSIGNER_HOME"` 7 | 8 | java -Xmx512M -jar "$VERITYSIGNER_HOME"/framework/VeritySigner.jar "$@" -------------------------------------------------------------------------------- /verity/verity_verifier: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Start-up script for VerityVerifier 4 | 5 | VERITYVERIFIER_HOME=`dirname "$0"` 6 | VERITYVERIFIER_HOME=`dirname "$VERITYVERIFIER_HOME"` 7 | 8 | java -Xmx512M -jar "$VERITYVERIFIER_HOME"/framework/VerityVerifier.jar "$@" 9 | -------------------------------------------------------------------------------- /zram-perf/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_CLANG := true 5 | LOCAL_MODULE := zram-perf 6 | LOCAL_CFLAGS += -g -Wall -Werror -std=c++11 -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-parameter 7 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include 8 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/.. 9 | LOCAL_SRC_FILES := \ 10 | zram-perf.cpp 11 | include $(BUILD_EXECUTABLE) 12 | --------------------------------------------------------------------------------