diff options
author | Ng Zhi An <zhin@google.com> | 2018-03-29 14:31:57 -0700 |
---|---|---|
committer | Ng Zhi An <zhin@google.com> | 2018-04-05 22:33:36 -0700 |
commit | 2dff99d9095672954e36dab44e0900c5aefb6ee3 (patch) | |
tree | 373da8d469570b5e88bfb17b38351f506593119e /app-launcher | |
parent | 27a16b1a541bbf06a30f0307d4b988ef630a4b9b (diff) | |
download | extras-2dff99d9095672954e36dab44e0900c5aefb6ee3.tar.gz |
ShellCheck warnings cleanup
Test: manual, run app-launcher
Change-Id: I82debf5e2bfc5ec9257ca0089328655141516097
Diffstat (limited to 'app-launcher')
-rwxr-xr-x | app-launcher/app-launcher | 129 |
1 files changed, 63 insertions, 66 deletions
diff --git a/app-launcher/app-launcher b/app-launcher/app-launcher index 77eaae9e..525e06ac 100755 --- a/app-launcher/app-launcher +++ b/app-launcher/app-launcher @@ -324,55 +324,55 @@ get_go_devnames () { system_stats_before() { if [ $system_bdev_set == true ]; then # 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 }'` + 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) }'` + 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 - uptime=`$adb shell 'cat /proc/uptime'` - uptime_before_ms=`echo $uptime | awk '{ print ($1 * 1000) }'` - device_util_before_ms=`echo $system | awk '{ print ($13) }'` + uptime=$($adb shell 'cat /proc/uptime') + uptime_before_ms=$(echo "$uptime" | awk '{ print ($1 * 1000) }') + device_util_before_ms=$(echo "$system" | awk '{ print ($13) }') fi } system_stats_after() { if [ $system_bdev_set == true ]; then # 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 }'` + 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) }'` + 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 - uptime=`$adb shell 'cat /proc/uptime'` - uptime_after_ms=`echo $uptime | awk '{ print ($1 * 1000) }'` - device_util_after_ms=`echo $system | awk '{ print ($13) }'` + uptime=$($adb shell 'cat /proc/uptime') + uptime_after_ms=$(echo "$uptime" | awk '{ print ($1 * 1000) }') + device_util_after_ms=$(echo "$system" | awk '{ print ($13) }') 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` + READ_KB_SYSTEM=$((AFTER_RD_SECTORS_SYSTEM - BEFORE_RD_SECTORS_SYSTEM)) + READ_KB_SYSTEM=$((READ_KB_SYSTEM / 2)) + echo Read IOs /system = $((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_ms $device_util_after_ms $uptime_before_ms $uptime_after_ms | 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) }' + 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_ms" "$device_util_after_ms" "$uptime_before_ms" "$uptime_after_ms" | 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 } @@ -384,12 +384,12 @@ launch_app() { printf "Testing %s: \n" "$package" 1>&2 i=0 - while [ $i -lt $iterations ] + while [ $i -lt "$iterations" ] do if [ $pagecached == false ]; then $adb shell 'echo 3 > /proc/sys/vm/drop_caches' fi - printf '[ %d%% ]\r' "$(($i * 100 / $iterations))" 1>&2 + 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' @@ -400,42 +400,42 @@ launch_app() { sleep 1 $adb shell "am force-stop $package" sleep 1 - i=`expr $i + 1` + i=$((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 > $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_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 > $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 + 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 } launch_go_apps() { - launch_app com.android.chrome com.google.android.apps.chrome.Main > $BASHPID-chrome-$model - getstats $BASHPID-chrome-$model Chrome - launch_app com.google.android.gm.lite com.google.android.gm.ConversationListActivityGmail > $BASHPID-gmailgo-$model - getstats $BASHPID-gmailgo-$model GmailGo - launch_app com.google.android.apps.youtube.mango com.google.android.apps.youtube.lite.frontend.activities.SplashActivity > $BASHPID-youtubego-$model - getstats $BASHPID-youtubego-$model YouTubeGo - launch_app com.android.vending com.google.android.finsky.activities.MainActivity > $BASHPID-play-$model - getstats $BASHPID-play-$model Play - launch_app com.android.settings com.android.settings.Settings > $BASHPID-settings-$model - getstats $BASHPID-settings-$model Settings + launch_app com.android.chrome com.google.android.apps.chrome.Main > "$BASHPID-chrome-$model" + getstats "$BASHPID-chrome-$model" Chrome + launch_app com.google.android.gm.lite com.google.android.gm.ConversationListActivityGmail > "$BASHPID-gmailgo-$model" + getstats "$BASHPID-gmailgo-$model" GmailGo + launch_app com.google.android.apps.youtube.mango com.google.android.apps.youtube.lite.frontend.activities.SplashActivity > "$BASHPID-youtubego-$model" + getstats "$BASHPID-youtubego-$model" YouTubeGo + launch_app com.android.vending com.google.android.finsky.activities.MainActivity > "$BASHPID-play-$model" + getstats "$BASHPID-play-$model" Play + launch_app com.android.settings com.android.settings.Settings > "$BASHPID-settings-$model" + getstats "$BASHPID-settings-$model" Settings } usage() { @@ -487,19 +487,17 @@ if [ $# -lt 2 ]; then usage fi -which computestats > /dev/null -if [ $? != 0 ]; then +if ! which computestats > /dev/null ; then echo "ERROR: Please add computestats utiliy to your PATH" exit 1 fi -which computestatsf > /dev/null -if [ $? != 0 ]; then +if ! which computestatsf > /dev/null ; then echo "Error: Please add computestatsf utility to your PATH" exit 1 fi -parseoptions $@ +parseoptions "$@" $adb root && $adb wait-for-device @@ -512,9 +510,8 @@ else echo "User Experience: Default Configs. No changes to cpufreq settings" fi -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]*$//') +model=$($adb shell getprop ro.product.name | sed 's/[ \t\r\n]*$//') echo "Found $model Device" |