OSDN Git Service

Merge "simpleperf: add test for recording cpu-clock." am: 9dc8dd6de2 am: 4f5d2f4357
authorYabin Cui <yabinc@google.com>
Thu, 13 Jul 2017 01:37:41 +0000 (01:37 +0000)
committerandroid-build-merger <android-build-merger@google.com>
Thu, 13 Jul 2017 01:37:41 +0000 (01:37 +0000)
am: 3e74919c11

Change-Id: Id3c2a2d54fbf9f8181dc6777846d64ea9edea8fd

14 files changed:
app-launcher/README
app-launcher/app-launcher
cppreopts/cppreopts.sh
ext4_utils/Android.mk
f2fs_utils/f2fs_dlutils.c
f2fs_utils/f2fs_ioutils.c
f2fs_utils/f2fs_utils.c
preopt2cachename/preopt2cachename.cpp
tests/Android.bp [new file with mode: 0644]
tests/lib/Android.bp [new file with mode: 0644]
tests/lib/Android.mk [deleted file]
tests/lib/testUtil/Android.bp [new file with mode: 0644]
tests/lib/testUtil/Android.mk [deleted file]
tests/lib/testUtil/include/testUtil.h [moved from tests/include/testUtil.h with 100% similarity]

index cca58aa..863a749 100644 (file)
@@ -5,14 +5,25 @@ Introduction: app-launcher is a script that launches apps many times,
 measures various system metrics, computes basic stats for the metrics
 and reports that stats.
 
+Setup:
+1) Make sure the device is seen via 'adb devices' and authorize adb via the
+popup dialog.
+2) Clear the setup wizard.
+3) Login to an android user test account.
+4) Clear the first time user dialogs on supported apps for your device (see
+below).
+5) Enable wifi and connect to a network (ex. GoogleGuest).
+
 Launching app-launcher :
-app-launcher -a|-b|-u [-v] num-iterations
+app-launcher -a|-b|-u [-c|-v|-s <serial number>] num-iterations
 -a:Run on all cores
 -b:Run only big cores
 -c:pagecached. Don't drop pagecache before each launch (not default)
 -h:Dump help menu'
 -u:user experience, no change to cpu/gpu frequencies or governors'
--v : Optional, Verbose mode, prints stats on a lot of metrics.
+-v:Optional, Verbose mode, prints stats on a lot of metrics.
+-s <serial number>:Optional, specify serial number if multiple devices are
+                   attached to host
 num-iterations : Must be >= 100 to get statistically valid data.
 
 Note, under -a|-b, we lock the CPU and GPU frequencies.
index f02b3dc..703aafa 100755 (executable)
@@ -7,36 +7,44 @@ parseoptions() {
     iterations=0
     pagecached=false
 
+    adb="adb"
     while [ $# -gt 1 ]
     do
-       case $1 in
-           -a)
-               ;;
-           -b)
-               little_cores_off=true
-               ;;
-           -c)
-               pagecached=true
-               ;;
-           -h)
-               usage
-               ;;
-           -u)
-               user_experience=true
-               ;;
-           -v)
-               verbose=true
-               ;;
-           *)
-               usage
-               ;;
-           esac
-       shift
+        case $1 in
+            -a)
+                ;;
+            -b)
+                little_cores_off=true
+                ;;
+            -c)
+                pagecached=true
+                ;;
+            -h)
+                usage
+                ;;
+            -s)
+                if [ -z $2 ]; then
+                    usage
+                fi
+                adb="adb -s $2"
+                shift
+                ;;
+            -u)
+                user_experience=true
+                ;;
+            -v)
+                verbose=true
+                ;;
+            *)
+                usage
+                ;;
+            esac
+        shift
     done
 
     iterations=$1
     if [ $iterations -lt 100 ]; then
-       usage
+        usage
     fi
 }
 
@@ -66,32 +74,32 @@ getstats () {
     fgrep 'Sys CPU util' $infile | awk '{print $5}' | computestatsf
 
     if [ $verbose == true ]; then
-       echo "instructions : "
-       fgrep instructions $infile | awk '{print $1}' | sed s/,//g | computestats
+        echo "instructions : "
+        fgrep instructions $infile | awk '{print $1}' | sed s/,//g | computestats
 
-       echo "cycles per instruction : "
-       fgrep instructions $infile | awk '{print $4}' | sed s/,//g | computestatsf
+        echo "cycles per instruction : "
+        fgrep instructions $infile | awk '{print $4}' | sed s/,//g | computestatsf
 
-       echo "branch-misses : "
-       fgrep branch-misses $infile | awk '{print $1}' | sed s/,//g | computestats
+        echo "branch-misses : "
+        fgrep branch-misses $infile | awk '{print $1}' | sed s/,//g | computestats
 
-       echo "context-switches : "
-       fgrep context-switches $infile | awk '{print $1}' | sed s/,//g | computestats
+        echo "context-switches : "
+        fgrep context-switches $infile | awk '{print $1}' | sed s/,//g | computestats
 
-       echo "page-faults : "
-       fgrep page-faults $infile | awk '{print $1}' | sed s/,//g | computestats
+        echo "page-faults : "
+        fgrep page-faults $infile | awk '{print $1}' | sed s/,//g | computestats
     fi
 
     if [ $system_bdev_set == true ]; then
-       # (Storage) Data from /proc we've collected
-       echo "KB read for $system_block_device blkdev :"
-       fgrep KB $infile | grep system | awk '{print $5}' | computestats
+        # (Storage) Data from /proc we've collected
+        echo "KB read for $system_block_device blkdev :"
+        fgrep KB $infile | grep system | awk '{print $5}' | computestats
 
-       echo "iowait% :"
-       fgrep IOwait $infile | awk '{print $3}' | computestatsf
+        echo "iowait% :"
+        fgrep IOwait $infile | awk '{print $3}' | computestatsf
 
-       echo "Device util% for $system_block_device blkdev :"
-       fgrep 'Device util' $infile | awk '{print $4}' | computestatsf
+        echo "Device util% for $system_block_device blkdev :"
+        fgrep 'Device util' $infile | awk '{print $4}' | computestatsf
     fi
 }
 
@@ -105,9 +113,9 @@ cpufreq_volantis() {
     num_cores=2
     while [ $i -lt  $num_cores ]
     do
-        adb shell "echo performance  > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_g\
+        $adb shell "echo performance  > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_g\
 overnor"
-        adb shell "echo 2499000 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_fr\
+        $adb shell "echo 2499000 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_fr\
 eq"
         i=`expr $i + 1`
     done
@@ -119,89 +127,135 @@ eq"
 cpufreq_fugu() {
     echo "Setting Governor to performance"
     if [ $little_cores_off == true ]; then
-       echo "Cannot turn off Little cores on $model"
-       exit 1
+        echo "Cannot turn off Little cores on $model"
+        exit 1
     fi
     i=0
     num_cores=4
     while [ $i -lt  $num_cores ]
     do
-       adb shell "echo performance  > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor"
-       adb shell "echo 1833000 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq"
-       i=`expr $i + 1`
+        $adb shell "echo performance  > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor"
+        $adb shell "echo 1833000 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq"
+        i=`expr $i + 1`
     done
 }
 
+cpufreq_taimen_walleye () {
+    echo "Setting Governor to performance"
+    # GPU Governor and Frequency
+    $adb shell 'echo performance > /sys/class/kgsl/kgsl-3d0/devfreq/governor'
+    $adb shell 'echo 624000000 > /sys/class/kgsl/kgsl-3d0/devfreq/max_freq'
+    if [ $little_cores_off == true ]; then
+        # Disable Little Cores, force app to run on big cores
+        echo "Disabling Little Cores"
+        $adb shell 'echo 0 > /sys/devices/system/cpu/cpu0/online'
+        $adb shell 'echo 0 > /sys/devices/system/cpu/cpu1/online'
+        $adb shell 'echo 0 > /sys/devices/system/cpu/cpu2/online'
+        $adb shell 'echo 0 > /sys/devices/system/cpu/cpu3/online'
+    else
+        echo "Enabling All Cores"
+        $adb shell 'echo 1 > /sys/devices/system/cpu/cpu0/online'
+        $adb shell 'echo 1 > /sys/devices/system/cpu/cpu1/online'
+        $adb shell 'echo 1 > /sys/devices/system/cpu/cpu2/online'
+        $adb shell 'echo 1 > /sys/devices/system/cpu/cpu3/online'
+        $adb shell 'echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'
+        $adb shell 'echo 1900800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq'
+    fi
+    # Set Governor to performance, up scaling_max_frequency to highest
+    $adb shell 'echo performance  > /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor'
+    # Only necessary to set max_freq on cpu4, cpu5-7 are in same cluster and will
+    # automatically get the same settings
+    $adb shell 'echo 2457600 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq'
+}
+
 cpufreq_marlin_sailfish () {
     echo "Setting Governor to performance"
     # GPU Governor and Frequency
-    adb shell 'echo performance > /sys/class/kgsl/kgsl-3d0/devfreq/governor'
-    adb shell 'echo 624000000 > /sys/class/kgsl/kgsl-3d0/devfreq/max_freq'
+    $adb shell 'echo performance > /sys/class/kgsl/kgsl-3d0/devfreq/governor'
+    $adb shell 'echo 624000000 > /sys/class/kgsl/kgsl-3d0/devfreq/max_freq'
     if [ $little_cores_off == true ]; then
-       # Disable Little Cores, force app to run on big cores
-       echo "Disabling Little Cores"
-       adb shell 'echo 0 > /sys/devices/system/cpu/cpu0/online'
-       adb shell 'echo 0 > /sys/devices/system/cpu/cpu1/online'
+        # Disable Little Cores, force app to run on big cores
+        echo "Disabling Little Cores"
+        $adb shell 'echo 0 > /sys/devices/system/cpu/cpu0/online'
+        $adb shell 'echo 0 > /sys/devices/system/cpu/cpu1/online'
     else
-       echo "Enabling All Cores"
-       adb shell 'echo 1 > /sys/devices/system/cpu/cpu0/online'
-       adb shell 'echo 1 > /sys/devices/system/cpu/cpu1/online'
-       adb shell 'echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'
-       adb shell 'echo 1996800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq'
-       # cpu1 needed ?
-       adb shell 'echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor'
-       adb shell 'echo 1996800 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq'
+        echo "Enabling All Cores"
+        $adb shell 'echo 1 > /sys/devices/system/cpu/cpu0/online'
+        $adb shell 'echo 1 > /sys/devices/system/cpu/cpu1/online'
+        $adb shell 'echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor'
+        $adb shell 'echo 1996800 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq'
+        # cpu1 needed ?
+        $adb shell 'echo performance > /sys/devices/system/cpu/cpu1/cpufreq/scaling_governor'
+        $adb shell 'echo 1996800 > /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq'
     fi
     # Set Governor to performance, up scaling_max_frequency to highest
-    adb shell 'echo performance  > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor'
+    $adb shell 'echo performance  > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor'
     # Only necessary to set max_freq on cpu2, cpu3 is in same cluster and will
     # automatically get the same settings
-    adb shell 'echo 2150400 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq'
+    $adb shell 'echo 2150400 > /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq'
 }
 
 cpufreq_angler () {
     echo "Setting Governor and Frequency"
     # GPU Governor and Frequency
-    adb shell "echo performance > /sys/class/kgsl/kgsl-3d0/devfreq/governor"
-    adb shell "echo 0 > /sys/class/kgsl/kgsl-3d0/bus_split"
-    adb shell "echo 1 > /sys/class/kgsl/kgsl-3d0/force_clk_on"
-    adb shell "echo 10000 > /sys/class/kgsl/kgsl-3d0/idle_timer"
+    $adb shell "echo performance > /sys/class/kgsl/kgsl-3d0/devfreq/governor"
+    $adb shell "echo 0 > /sys/class/kgsl/kgsl-3d0/bus_split"
+    $adb shell "echo 1 > /sys/class/kgsl/kgsl-3d0/force_clk_on"
+    $adb shell "echo 10000 > /sys/class/kgsl/kgsl-3d0/idle_timer"
     if [ $little_cores_off == true ]; then
-       # Disable Little Cores, force app to run on big cores
-       echo "Disabling Little Cores"
-       i=0
-       num_cores=4
-       while [ $i -lt $num_cores ]
-       do
-           adb shell "echo 0 > /sys/devices/system/cpu/cpu$i/online"
-           i=`expr $i + 1`
-       done
+        # Disable Little Cores, force app to run on big cores
+        echo "Disabling Little Cores"
+        i=0
+        num_cores=4
+        while [ $i -lt $num_cores ]
+        do
+            $adb shell "echo 0 > /sys/devices/system/cpu/cpu$i/online"
+            i=`expr $i + 1`
+        done
     else
-       echo "Enabling All Cores"
-       # Enable Little cores here, set governor to performance
-       # Lock frequency of little cores
-       i=0
-       num_cores=4
-       while [ $i -lt $num_cores ]
-       do
-           adb shell "echo 1 > /sys/devices/system/cpu/cpu$i/online"
-           adb shell "echo performance > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor"
-           # Lock frequency of little cores
-           adb shell "echo 1555200 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq"
-           i=`expr $i + 1`
-       done
+        echo "Enabling All Cores"
+        # Enable Little cores here, set governor to performance
+        # Lock frequency of little cores
+        i=0
+        num_cores=4
+        while [ $i -lt $num_cores ]
+        do
+            $adb shell "echo 1 > /sys/devices/system/cpu/cpu$i/online"
+            $adb shell "echo performance > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor"
+            # Lock frequency of little cores
+            $adb shell "echo 1555200 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq"
+            i=`expr $i + 1`
+        done
     fi
     i=4
     num_cores=8
     while [ $i -lt $num_cores ]
     do
-       adb shell "echo performance > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor"
-       # Lock frequency of big cores
-       adb shell "echo 1958400 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq"
-       i=`expr $i + 1`
+        $adb shell "echo performance > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor"
+        # Lock frequency of big cores
+        $adb shell "echo 1958400 > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq"
+        i=`expr $i + 1`
     done
 }
 
+get_taimen_walleye_devnames () {
+    # This bit of code required to get the block dev for /system and /vendor
+    # Suffix can be _a or _b, depending on what the active /system partition is
+#    suffix=`$adb shell getprop ro.boot.slot_suffix`
+    # Get the blockdevice using the suffix we got above
+#    system_block_device=`$adb shell ls -l /dev/block/platform/soc/*ufs*/by-name/system$suffix | awk '{ print $10 }' `
+    # Vendor is more straightforward, but we don't use it right now
+#    vendor_block_device=`$adb shell df /vendor | grep -v Filesystem | awk '{print $1}' `
+    # finally extract the last component of the absolute device pathname we got above
+#    system_block_device=`echo $system_block_device | awk 'BEGIN { FS ="/" } ; { print $4 }' `
+#    vendor_block_device=`echo $vendor_block_device | awk 'BEGIN { FS ="/" } ; { print $4 }' `
+    system_bdev_set=true
+#   For now, hardcode sda for Marlin/Sailfish block device
+#   XXX - We'll get stats for entire device
+    system_block_device=sda
+    echo Block Device $system_block_device
+}
+
 #
 # This strange bit of logic is needed to get the underlying block devices for /system
 # for Marlin/Sailfish
@@ -209,11 +263,11 @@ cpufreq_angler () {
 get_marlin_sailfish_devnames () {
     # This bit of code required to get the block dev for /system and /vendor
     # Suffix can be _a or _b, depending on what the active /system partition is
-#    suffix=`adb shell getprop ro.boot.slot_suffix`
+#    suffix=`$adb shell getprop ro.boot.slot_suffix`
     # Get the blockdevice using the suffix we got above
-#    system_block_device=`adb shell ls -l /dev/block/platform/soc/*ufs*/by-name/system$suffix | awk '{ print $10 }' `
+#    system_block_device=`$adb shell ls -l /dev/block/platform/soc/*ufs*/by-name/system$suffix | awk '{ print $10 }' `
     # Vendor is more straightforward, but we don't use it right now
-#    vendor_block_device=`adb shell df /vendor | grep -v Filesystem | awk '{print $1}' `
+#    vendor_block_device=`$adb shell df /vendor | grep -v Filesystem | awk '{print $1}' `
     # finally extract the last component of the absolute device pathname we got above
 #    system_block_device=`echo $system_block_device | awk 'BEGIN { FS ="/" } ; { print $4 }' `
 #    vendor_block_device=`echo $vendor_block_device | awk 'BEGIN { FS ="/" } ; { print $4 }' `
@@ -226,19 +280,19 @@ get_marlin_sailfish_devnames () {
 
 get_angler_devnames () {
     # Get the underlying bdev from the "by-name" mapping
-    system_block_device=`adb shell 'find /dev/block/platform -name by-name | xargs ls -l' | grep system | awk '{ print $10 }' `
+    system_block_device=`$adb shell 'find /dev/block/platform -name by-name | xargs ls -l' | grep system | awk '{ print $10 }' `
     # extract the last component of the absolute device pathname we got above
     system_block_device=`echo $system_block_device | awk 'BEGIN { FS ="/" } ; { print $4 }' `
     # vendor is unused right now, but get the bdev anyway in case we decide to use it
     # Get the underlying bdev from the "by-name" mapping
-    vendor_block_device=`adb shell 'find /dev/block/platform -name by-name | xargs ls -l' | grep vendor | awk '{ print $10 }' `
+    vendor_block_device=`$adb shell 'find /dev/block/platform -name by-name | xargs ls -l' | grep vendor | awk '{ print $10 }' `
     # extract the last component of the absolute device pathname we got above
    vendor_block_device=`echo $vendor_block_device | awk 'BEGIN { FS ="/" } ; { print $4 }' `
    system_bdev_set=true
 }
 
 get_fugu_devnames () {
-    system_block_device=`adb shell ls -l /dev/block/by-name/system | awk '{ print $10 }' `
+    system_block_device=`$adb shell ls -l /dev/block/by-name/system | awk '{ print $10 }' `
     system_block_device=`echo $system_block_device | awk 'BEGIN { FS ="/" } ; { print $4 }' `
     system_bdev_set=true
 }
@@ -251,117 +305,121 @@ get_volantis_devnames () {
 
 system_stats_before() {
     if [ $system_bdev_set == true ]; then
-       # Get BEFORE read stats for /system
-       adb shell 'cat /proc/diskstats' | grep -w $system_block_device > /tmp/$model-system
-       BEFORE_RD_IOS_SYSTEM=`awk '{ print $4 }' /tmp/$model-system`
-       BEFORE_RD_SECTORS_SYSTEM=`awk '{ print $6 }' /tmp/$model-system`
-       # iowait% computation
-       adb shell 'cat /proc/stat' | grep -w cpu > /tmp/procstat
-       user_ticks_before=`awk '{ print ($2 + $3) }' /tmp/procstat`
-       sys_ticks_before=`awk '{ print ($4 + $7 + $8) }' /tmp/procstat`
-       cpubusy_ticks_before=`awk '{ print ($2 + $3 + $4 + $7 + $8) }' /tmp/procstat`
-       iowait_ticks_before=`awk '{ print $6 }' /tmp/procstat`
-       total_ticks_before=`awk '{ print ($2 + $3 + $4 + $5 + $7 + $8) }' /tmp/procstat`
-       # Device util% computation
-       # Note hz=100, so multiplying uptime (in seconds) by 100, gives us
-       # the uptime in hz.
-       adb shell 'cat /proc/uptime' > /tmp/uptime
-       uptime_before_hz=`awk '{ print ($1 * 100) }' /tmp/uptime`
-       # Note that the device (busy) ticks is in ms. Since hz=100, dividing
-       # device (busy) ticks by 10, gives us this in the correct ticks units
-       device_util_before_hz=`awk '{ print ($13 / 10) }' /tmp/$model-system`
+        # Get BEFORE read stats for /system
+        system=`$adb shell 'cat /proc/diskstats' | grep -w $system_block_device`
+        BEFORE_RD_IOS_SYSTEM=`echo $system | awk '{ print $4 }'`
+        BEFORE_RD_SECTORS_SYSTEM=`echo $system | awk '{ print $6 }'`
+        # iowait% computation
+        procstat=`$adb shell 'cat /proc/stat' | grep -w cpu`
+        user_ticks_before=`echo $procstat | awk '{ print ($2 + $3) }'`
+        sys_ticks_before=`echo $procstat | awk '{ print ($4 + $7 + $8) }'`
+        cpubusy_ticks_before=`echo $procstat | awk '{ print ($2 + $3 + $4 + $7 + $8) }'`
+        iowait_ticks_before=`echo $procstat | awk '{ print $6 }'`
+        total_ticks_before=`echo $procstat | awk '{ print ($2 + $3 + $4 + $5 + $7 + $8) }'`
+        # Device util% computation
+        # Note hz=100, so multiplying uptime (in seconds) by 100, gives us
+        # the uptime in hz.
+        uptime=`$adb shell 'cat /proc/uptime'`
+        uptime_before_hz=`echo $uptime | awk '{ print ($1 * 100) }'`
+        # Note that the device (busy) ticks is in ms. Since hz=100, dividing
+        # device (busy) ticks by 10, gives us this in the correct ticks units
+        device_util_before_hz=`echo $uptime | awk '{ print ($13 / 10) }'`
     fi
 }
 
 system_stats_after() {
     if [ $system_bdev_set == true ]; then
-       # Get AFTER read stats for /system
-       adb shell 'cat /proc/diskstats' | grep -w $system_block_device > /tmp/$model-system
-       AFTER_RD_IOS_SYSTEM=`awk '{ print $4 }' /tmp/$model-system`
-       AFTER_RD_SECTORS_SYSTEM=`awk '{ print $6 }' /tmp/$model-system`
-       # iowait% computation
-       adb shell 'cat /proc/stat' | grep -w cpu > /tmp/procstat
-       user_ticks_after=`awk '{ print ($2 + $3) }' /tmp/procstat`
-       sys_ticks_after=`awk '{ print ($4 + $7 + $8) }' /tmp/procstat`
-       cpubusy_ticks_after=`awk '{ print ($2 + $3 + $4 + $7 + $8) }' /tmp/procstat`
-       iowait_ticks_after=`awk '{ print $6 }' /tmp/procstat`
-       total_ticks_after=`awk '{ print ($2 + $3 + $4 + $5 + $7 + $8) }' /tmp/procstat`
-       # Device util% computation
-       # Note hz=100, so multiplying uptime (in seconds) by 100, gives us
-       # the uptime in hz.
-       adb shell 'cat /proc/uptime' > /tmp/uptime
-       uptime_after_hz=`awk '{ print ($1 * 100) }' /tmp/uptime`
-       # Note that the device (busy) ticks is in ms. Since hz=100, dividing
-       # device (busy) ticks by 10, gives us this in the correct ticks units
-       device_util_after_hz=`awk '{ print ($13 / 10) }' /tmp/$model-system`
+        # Get AFTER read stats for /system
+        system=`$adb shell 'cat /proc/diskstats' | grep -w $system_block_device`
+        AFTER_RD_IOS_SYSTEM=`echo $system | awk '{ print $4 }'`
+        AFTER_RD_SECTORS_SYSTEM=`echo $system | awk '{ print $6 }'`
+        # iowait% computation
+        procstat=`$adb shell 'cat /proc/stat' | grep -w cpu`
+        user_ticks_after=`echo $procstat | awk '{ print ($2 + $3) }'`
+        sys_ticks_after=`echo $procstat | awk '{ print ($4 + $7 + $8) }'`
+        cpubusy_ticks_after=`echo $procstat | awk '{ print ($2 + $3 + $4 + $7 + $8) }'`
+        iowait_ticks_after=`echo $procstat | awk '{ print $6 }'`
+        total_ticks_after=`echo $procstat | awk '{ print ($2 + $3 + $4 + $5 + $7 + $8) }'`
+        # Device util% computation
+        # Note hz=100, so multiplying uptime (in seconds) by 100, gives us
+        # the uptime in hz.
+        uptime=`$adb shell 'cat /proc/uptime'`
+        uptime_after_hz=`echo $uptime | awk '{ print ($1 * 100) }'`
+        # Note that the device (busy) ticks is in ms. Since hz=100, dividing
+        # device (busy) ticks by 10, gives us this in the correct ticks units
+        device_util_after_hz=`echo $system | awk '{ print ($13 / 10) }'`
     fi
 }
 
 system_stats_delta() {
     if [ $system_bdev_set == true ]; then
-       # Sectors to KB
-       READ_KB_SYSTEM=`expr $AFTER_RD_SECTORS_SYSTEM - $BEFORE_RD_SECTORS_SYSTEM`
-       READ_KB_SYSTEM=`expr $READ_KB_SYSTEM / 2`
-       echo Read IOs /system = `expr $AFTER_RD_IOS_SYSTEM - $BEFORE_RD_IOS_SYSTEM`
-       echo Read KB /system = $READ_KB_SYSTEM
-       echo $iowait_ticks_before $iowait_ticks_after $total_ticks_before $total_ticks_after | awk '{ printf "IOwait = %.2f\n", (($2 - $1) * 100.0) / ($4 - $3) }'
-       echo $device_util_before_hz $device_util_after_hz $uptime_before_hz $uptime_after_hz | awk '{ printf "Device util% = %.2f\n", (($2 - $1) * 100.0) / ($4 - $3) }'
-       echo $user_ticks_after $user_ticks_before $total_ticks_after $total_ticks_before | awk '{ printf "User CPU util% = %.2f\n", (($1 - $2) * 100.0) / ($3 - $4) }'
-       echo $sys_ticks_after $sys_ticks_before $total_ticks_after $total_ticks_before | awk '{ printf "Sys CPU util% = %.2f\n", (($1 - $2) * 100.0) / ($3 - $4) }'
-       echo $cpubusy_ticks_after $cpubusy_ticks_before $total_ticks_after $total_ticks_before | awk '{ printf "Total CPU util% = %.2f\n", (($1 - $2) * 100.0) / ($3 - $4) }'
+        # Sectors to KB
+        READ_KB_SYSTEM=`expr $AFTER_RD_SECTORS_SYSTEM - $BEFORE_RD_SECTORS_SYSTEM`
+        READ_KB_SYSTEM=`expr $READ_KB_SYSTEM / 2`
+        echo Read IOs /system = `expr $AFTER_RD_IOS_SYSTEM - $BEFORE_RD_IOS_SYSTEM`
+        echo Read KB /system = $READ_KB_SYSTEM
+        echo $iowait_ticks_before $iowait_ticks_after $total_ticks_before $total_ticks_after | awk '{ printf "IOwait = %.2f\n", (($2 - $1) * 100.0) / ($4 - $3) }'
+        echo $device_util_before_hz $device_util_after_hz $uptime_before_hz $uptime_after_hz | awk '{ printf "Device util% = %.2f\n", (($2 - $1) * 100.0) / ($4 - $3) }'
+        echo $user_ticks_after $user_ticks_before $total_ticks_after $total_ticks_before | awk '{ printf "User CPU util% = %.2f\n", (($1 - $2) * 100.0) / ($3 - $4) }'
+        echo $sys_ticks_after $sys_ticks_before $total_ticks_after $total_ticks_before | awk '{ printf "Sys CPU util% = %.2f\n", (($1 - $2) * 100.0) / ($3 - $4) }'
+        echo $cpubusy_ticks_after $cpubusy_ticks_before $total_ticks_after $total_ticks_before | awk '{ printf "Total CPU util% = %.2f\n", (($1 - $2) * 100.0) / ($3 - $4) }'
     fi
 }
 
 launch_app() {
     package=$1
     activity=$2
-    adb shell "am force-stop $package"
+    $adb shell "am force-stop $package"
     sleep 1
 
+    printf "Testing %s: \n" "$package" 1>&2
     i=0
     while [ $i -lt $iterations ]
     do
-       if [ $pagecached == false ]; then
-           adb shell 'echo 3 > /proc/sys/vm/drop_caches'
-       fi
-       # The -W argument to am start forces am start to wait till the launch completes.
-       # The -S argument forces it to kill any existing app that is running first
-       # eg. adb shell 'am start -W -S -n com.android.chrome/com.google.android.apps.chrome.Main'
-       system_stats_before
-       adb shell "simpleperf stat -a am start -W -n $package/$activity"
-       system_stats_after
-       system_stats_delta
-       sleep 1
-       adb shell "am force-stop $package"
-       sleep 1
-       i=`expr $i + 1`
+        if [ $pagecached == false ]; then
+            $adb shell 'echo 3 > /proc/sys/vm/drop_caches'
+        fi
+        printf '[ %d%% ]\r' "$(($i * 100 / $iterations))" 1>&2
+        # The -W argument to am start forces am start to wait till the launch completes.
+        # The -S argument forces it to kill any existing app that is running first
+        # eg. adb shell 'am start -W -S -n com.android.chrome/com.google.android.apps.chrome.Main'
+        system_stats_before
+        $adb shell "simpleperf stat -a am start -W -n $package/$activity"
+        system_stats_after
+        system_stats_delta
+        sleep 1
+        $adb shell "am force-stop $package"
+        sleep 1
+        i=`expr $i + 1`
     done
+    printf "\n" 1>&2
 }
 
 launch_fugu_apps() {
-    launch_app com.google.android.youtube.tv com.google.android.apps.youtube.tv.activity.TvGuideActivity > youtube-$model
-    getstats youtube-$model YouTube
-    launch_app com.google.android.play.games com.google.android.gms.games.pano.activity.PanoGamesOnboardHostActivity > games-$model
-    getstats games-$model Games
-    launch_app com.google.android.music com.android.music.activitymanagement.TopLevelActivity > music-$model
-    getstats music-$model Music
+    launch_app com.google.android.youtube.tv com.google.android.apps.youtube.tv.activity.TvGuideActivity > $BASHPID-youtube-$model
+    getstats $BASHPID-youtube-$model YouTube
+    launch_app com.google.android.play.games com.google.android.gms.games.pano.activity.PanoGamesOnboardHostActivity > $BASHPID-games-$model
+    getstats $BASHPID-games-$model Games
+    launch_app com.google.android.music com.android.music.activitymanagement.TopLevelActivity > $BASHPID-music-$model
+    getstats $BASHPID-music-$model Music
 }
 
 launch_phone_apps() {
-    launch_app com.android.chrome com.google.android.apps.chrome.Main > chrome-$model
-    getstats chrome-$model Chrome
-    launch_app com.google.android.GoogleCamera com.android.camera.CameraActivity > camera-$model
-    getstats camera-$model Camera
-    launch_app com.google.android.apps.maps com.google.android.maps.MapsActivity > maps-$model
-    getstats maps-$model Maps
-    launch_app com.google.android.youtube com.google.android.apps.youtube.app.WatchWhileActivity > youtube-$model
-    getstats youtube-$model YouTube
+    launch_app com.android.chrome com.google.android.apps.chrome.Main > $BASHPID-chrome-$model
+    getstats $BASHPID-chrome-$model Chrome
+    launch_app com.google.android.GoogleCamera com.android.camera.CameraActivity > $BASHPID-camera-$model
+    getstats $BASHPID-camera-$model Camera
+    launch_app com.google.android.apps.maps com.google.android.maps.MapsActivity > $BASHPID-maps-$model
+    getstats $BASHPID-maps-$model Maps
+    launch_app com.google.android.youtube com.google.android.apps.youtube.app.WatchWhileActivity > $BASHPID-youtube-$model
+    getstats $BASHPID-youtube-$model YouTube
 }
 
 usage() {
-    echo 'Usage: app-launcher [-c|-v] -a|-b|-u num-iterations'
+    echo 'Usage: app-launcher [-c|-v|-s <serial num>] -a|-b|-u num-iterations'
     echo 'where num-iterations >= 100'
     echo '-v (optional) for verbose stats dump'
+    echo '-s <serial num> (optional) run test on specific device'
     echo '-a|-b|-u required:'
     echo '        -a:all cores'
     echo '        -b:only big cores'
@@ -373,6 +431,31 @@ usage() {
     exit 1
 }
 
+setup() {
+    echo "Setting up device"
+    # Set developer options, will automatically 'Stay Awake'
+    $adb shell 'am start -n com.android.settings/.DevelopmentSettings'
+    # Set screen timeout to 30 minutes
+    $adb shell 'settings put system screen_off_timeout 1800000'
+
+    # TODO: Consider rebooting device to start with a clean state
+
+    # Disable automatic rotation and NFC
+    # This works on OC, but haven't tested on NYC or earlier
+    $adb shell 'content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0'
+    $adb shell 'svc nfc disable'
+
+    # Clear all notifications
+    $adb shell 'service call notification 1'
+    # Go to home screen
+    $adb shell 'input keyevent KEYCODE_WAKEUP' && sleep 0.5
+    $adb shell 'input keyevent KEYCODE_MENU'   && sleep 0.5
+    $adb shell 'input keyevent KEYCODE_HOME'   && sleep 0.5
+    sleep 2
+    # TODO: kill all background apps
+    # TODO: clear popups
+}
+
 #
 # The main() part of the script follows :
 #
@@ -395,18 +478,18 @@ fi
 
 parseoptions $@
 
-adb root && sleep 2
+$adb root && $adb wait-for-device
 
 if [ $user_experience == false ]; then
     # Important to stop the thermal-engine to prevent throttling while test is running
     # and stop perfd
-    adb shell 'stop thermal-engine'
-    adb shell 'stop perfd'
+    $adb shell 'stop thermal-engine'
+    $adb shell 'stop perfd'
 else
     echo "User Experience: Default Configs. No changes to cpufreq settings"
 fi
 
-model=`adb shell getprop ro.product.name`
+model=`$adb shell getprop ro.product.name`
 # Releases are inconsistent with various trailing characters, remove them all
 model=`echo $model | sed 's/[ \t\r\n]*$//' `
 
@@ -414,11 +497,17 @@ echo Found $model Device
 
 system_bdev_set=false
 case $model in
+    taimen | muskie | walleye)
+        if [ $user_experience == false ]; then
+            cpufreq_taimen_walleye
+        fi
+        get_taimen_walleye_devnames
+        ;;
     marlin | sailfish)
         if [ $user_experience == false ]; then
             cpufreq_marlin_sailfish
         fi
-       get_marlin_sailfish_devnames
+        get_marlin_sailfish_devnames
         ;;
     angler)
         if [ $user_experience == false ]; then
@@ -444,6 +533,7 @@ case $model in
         ;;
 esac
 
+setup
 
 #
 # launch each app in turn
@@ -453,3 +543,6 @@ if [ $model == "fugu" ]; then
 else # Phone Apps
     launch_phone_apps
 fi
+
+# cleanup
+rm $BASHPID*
index 9f21ac7..76f25d1 100644 (file)
@@ -50,7 +50,7 @@ if [ $# -eq 1 ]; then
   # For each odex and vdex file do the copy task
   # NOTE: this implementation will break in any path with spaces to favor
   # background copy tasks
-  for file in $(find ${mountpoint} -type f -name "*.odex" -o -type f -name "*.vdex"); do
+  for file in $(find ${mountpoint} -type f -name "*.odex" -o -type f -name "*.vdex" -o -type f -name "*.art"); do
     real_name=${file/${mountpoint}/\/system}
     dest_name=$(preopt2cachename ${real_name})
     if ! test $? -eq 0 ; then
index e59eb4a..a80e473 100644 (file)
@@ -102,4 +102,20 @@ LOCAL_BUILT_MODULE_STEM := $(notdir $(LOCAL_SRC_FILES))
 LOCAL_IS_HOST_MODULE := true
 include $(BUILD_PREBUILT)
 
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := mke2fs.conf
+LOCAL_SRC_FILES := $(LOCAL_MODULE)
+LOCAL_MODULE_CLASS := EXECUTABLES
+LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/etc
+include $(BUILD_PREBUILT)
+
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := mke2fs.conf
+LOCAL_SRC_FILES := $(LOCAL_MODULE)
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)
+include $(BUILD_PREBUILT)
+
 endif
index 2ba3f7c..4b5e13e 100644 (file)
@@ -39,7 +39,6 @@
 
 int (*f2fs_format_device_dl)(void);
 void (*f2fs_init_configuration_dl)(void);
-struct f2fs_configuration *c_dl;
 
 int f2fs_format_device(void) {
        assert(f2fs_format_device_dl);
@@ -59,8 +58,7 @@ int dlopenf2fs() {
        }
        f2fs_format_device_dl = dlsym(f2fs_lib, "f2fs_format_device");
        f2fs_init_configuration_dl = dlsym(f2fs_lib, "f2fs_init_configuration");
-       c_dl = dlsym(f2fs_lib, "c");
-       if (!f2fs_format_device_dl || !f2fs_init_configuration_dl || !c_dl) {
+       if (!f2fs_format_device_dl || !f2fs_init_configuration_dl) {
                return -1;
        }
        return 0;
index d3bc727..c9275ff 100644 (file)
@@ -83,7 +83,7 @@ struct selabel_handle;
 
 #endif
 
-extern struct f2fs_configuration *c_dl;
+struct f2fs_configuration c;
 struct sparse_file *f2fs_sparse_file;
 
 struct buf_item {
@@ -94,11 +94,29 @@ struct buf_item {
 
 struct buf_item *buf_list;
 
+static int __get_device_fd(__u64 *offset)
+{
+       __u64 blk_addr = *offset >> F2FS_BLKSIZE_BITS;
+       int i;
+
+       for (i = 0; i < c.ndevs; i++) {
+               if (c.devices[i].start_blkaddr <= blk_addr &&
+                               c.devices[i].end_blkaddr >= blk_addr) {
+                       *offset -=
+                               c.devices[i].start_blkaddr << F2FS_BLKSIZE_BITS;
+                       return c.devices[i].fd;
+               }
+       }
+       return -1;
+}
+
 static int dev_write_fd(void *buf, __u64 offset, size_t len)
 {
-       if (lseek64(c_dl->devices[0].fd, (off64_t)offset, SEEK_SET) < 0)
+       int fd = __get_device_fd(&offset);
+
+       if (lseek64(fd, (off64_t)offset, SEEK_SET) < 0)
                return -1;
-       ssize_t written = write(c_dl->devices[0].fd, buf, len);
+       ssize_t written = write(fd, buf, len);
        if (written == -1)
                return -1;
        if ((size_t)written != len)
@@ -138,11 +156,11 @@ static int dev_write_sparse(void *buf, __u64 byte_offset, size_t byte_len)
        return 0;
 }
 
-void f2fs_finalize_device()
+void f2fs_finalize_device(void)
 {
 }
 
-int f2fs_trim_device()
+int f2fs_trim_devices(void)
 {
        return 0;
 }
@@ -160,24 +178,39 @@ int dev_read(void  *buf, __u64 offset, size_t len)
        return 0;
 }
 
+int dev_readahead(__u64 offset, size_t len)
+{
+       return 0;
+}
+
 int dev_write(void *buf, __u64 offset, size_t len)
 {
-       if (c_dl->devices[0].fd >= 0) {
+       int fd = __get_device_fd(&offset);
+
+       if (fd >= 0) {
                return dev_write_fd(buf, offset, len);
        } else {
                return dev_write_sparse(buf, offset, len);
        }
 }
 
-int dev_write_block(void *buf, __u64 offset)
+int dev_write_block(void *buf, __u64 blk_addr)
+{
+       assert(false); // Must not be invoked.
+       return 0;
+}
+
+int dev_write_dump(void *buf, __u64 offset, size_t len)
 {
-       return dev_write(buf, offset << F2FS_BLKSIZE_BITS, F2FS_BLKSIZE);
+       assert(false); // Must not be invoked.
+       return 0;
 }
 
 int dev_fill(void *buf, __u64 offset, size_t len)
 {
+       int fd = __get_device_fd(&offset);
        int ret;
-       if (c_dl->devices[0].fd >= 0) {
+       if (fd >= 0) {
                return dev_write_fd(buf, offset, len);
        }
         // sparse file fills with zero by default.
@@ -185,6 +218,12 @@ int dev_fill(void *buf, __u64 offset, size_t len)
        return 0;
 }
 
+int dev_fill_block(void *buf, __u64 blk_addr)
+{
+       assert(false); // Must not be invoked.
+       return 0;
+}
+
 int dev_read_block(void *buf, __u64 blk_addr)
 {
        assert(false); // Must not be invoked.
@@ -197,3 +236,8 @@ int dev_read_blocks(void *buf, __u64 addr, __u32 nr_blks)
        return 0;
 }
 
+int dev_reada_block(__u64 blk_addr)
+{
+       assert(false); // Must not be invoked.
+       return 0;
+}
index 5223680..0aa2f7a 100644 (file)
@@ -42,11 +42,12 @@ struct selabel_handle;
 
 extern void flush_sparse_buffs();
 
-extern struct f2fs_configuration *c_dl;
+struct f2fs_configuration c;
 struct sparse_file *f2fs_sparse_file;
 extern int dlopenf2fs();
 
 static void reset_f2fs_info() {
+       memset(&c, 0, sizeof(c));
        if (f2fs_sparse_file) {
                sparse_file_destroy(f2fs_sparse_file);
                f2fs_sparse_file = NULL;
@@ -62,13 +63,9 @@ int make_f2fs_sparse_fd(int fd, long long len,
        reset_f2fs_info();
        f2fs_init_configuration();
        len &= ~((__u64)(F2FS_BLKSIZE - 1));
-       c_dl->ndevs = 1;
-       c_dl->devices[0].total_sectors = len / c_dl->devices[0].sector_size;
-       c_dl->sector_size = c_dl->devices[0].sector_size;
-       c_dl->sectors_per_blk = F2FS_BLKSIZE / c_dl->sector_size;
-       c_dl->total_sectors = c_dl->devices[0].total_sectors;
-       c_dl->start_sector = 0;
-       c_dl->trim = 0;
+       c.sector_size = DEFAULT_SECTOR_SIZE;
+       c.total_sectors = len / c.sector_size;
+       c.start_sector = 0;
        f2fs_sparse_file = sparse_file_new(F2FS_BLKSIZE, len);
        f2fs_format_device();
        sparse_file_write(f2fs_sparse_file, fd, /*gzip*/0, /*sparse*/1, /*crc*/0);
index f9a12ff..3fb887b 100644 (file)
@@ -26,6 +26,7 @@
 static const char* kDalvikCacheDir = "/data/dalvik-cache/";
 static const char* kOdexCacheSuffix = "@classes.dex";
 static const char* kVdexCacheSuffix = "@classes.vdex";
+static const char* kArtCacheSuffix = "@classes.art";
 
 // Returns the ISA extracted from the file_location.
 // file_location is formatted like /system/app/<app_name>/oat/<isa>/<app_name>.{odex,vdex}
@@ -88,10 +89,17 @@ static bool SystemBFilenameToCacheFile(const std::string& file_location,
     LOG(ERROR) << "Unable to determine apk name from file name '" << file_location << "'";
     return false;
   }
+  std::string::size_type pos = file_location.find_last_of(".");
+  if (pos == std::string::npos) {
+    LOG(ERROR) << "Invalid file location '" << file_location << "'";
+    return false;
+  }
   cache_file += apk_name;
-  if (file_location.size() >= 5 &&
-      file_location.substr(file_location.size() - 5) == std::string(".vdex")) {
+  std::string extension(file_location.substr(pos));
+  if (extension == ".vdex") {
     cache_file += kVdexCacheSuffix;
+  } else if (extension == ".art") {
+    cache_file += kArtCacheSuffix;
   } else {
     cache_file += kOdexCacheSuffix;
   }
diff --git a/tests/Android.bp b/tests/Android.bp
new file mode 100644 (file)
index 0000000..1e0d8c8
--- /dev/null
@@ -0,0 +1,3 @@
+subdirs = [
+    "lib",
+]
diff --git a/tests/lib/Android.bp b/tests/lib/Android.bp
new file mode 100644 (file)
index 0000000..7a8ee5d
--- /dev/null
@@ -0,0 +1 @@
+subdirs = [ "*" ]
diff --git a/tests/lib/Android.mk b/tests/lib/Android.mk
deleted file mode 100644 (file)
index db16ed2..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(call all-subdir-makefiles)
diff --git a/tests/lib/testUtil/Android.bp b/tests/lib/testUtil/Android.bp
new file mode 100644 (file)
index 0000000..35678d4
--- /dev/null
@@ -0,0 +1,25 @@
+//
+// Copyright (C) 2010 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+cc_library_static {
+    name: "libtestUtil",
+    srcs: ["testUtil.c"],
+    export_include_dirs: ["include"],
+    shared_libs: [
+        "libcutils",
+        "libutils",
+    ],
+}
diff --git a/tests/lib/testUtil/Android.mk b/tests/lib/testUtil/Android.mk
deleted file mode 100644 (file)
index c5ae26d..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-include $(CLEAR_VARS)
-LOCAL_MODULE_TAGS := tests
-LOCAL_MODULE:= libtestUtil
-LOCAL_SRC_FILES:= testUtil.c
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../include
-LOCAL_SHARED_LIBRARIES += libcutils libutils
-
-
-include $(BUILD_STATIC_LIBRARY)