1#!/bin/bash 2 3PERF="rand_emmc_perf" 4 5if [ ! -r "$PERF" ] 6then 7 echo "Cannot read $PERF test binary" 8fi 9 10if [ ! -r "$PERF_OSYNC" ] 11then 12 echo "Cannot read $PERF_OSYNC test binary" 13fi 14 15if ! adb shell true >/dev/null 2>&1 16then 17 echo "No device detected over adb" 18fi 19 20HARDWARE=`adb shell getprop ro.hardware | tr -d "\r"` 21 22case "$HARDWARE" in 23 tuna | steelhead) 24 CPUFREQ="/sys/devices/system/cpu/cpu0/cpufreq" 25 CACHE="/dev/block/platform/omap/omap_hsmmc.0/by-name/cache" 26 ;; 27 28 stingray | wingray) 29 CPUFREQ="/sys/devices/system/cpu/cpu0/cpufreq" 30 CACHE="/dev/block/platform/sdhci-tegra.3/by-name/cache" 31 ;; 32 33 herring) 34 echo "This test will wipe the userdata partition on $HARDWARE devices." 35 read -p "Do you want to proceed? " ANSWER 36 37 if [ "$ANSWER" != "yes" ] 38 then 39 echo "aborting test" 40 exit 1 41 fi 42 43 CPUFREQ="/sys/devices/system/cpu/cpu0/cpufreq" 44 CACHE="/dev/block/platform/s3c-sdhci.0/by-name/userdata" 45 ;; 46 47 grouper) 48 CPUFREQ="/sys/devices/system/cpu/cpu0/cpufreq" 49 CACHE="/dev/block/platform/sdhci-tegra.3/by-name/CAC" 50 ;; 51 52 *) 53 echo "Unknown hardware $HARDWARE. Exiting." 54 exit 1 55esac 56 57# prepare the device 58adb root 59adb wait-for-device 60adb push "$PERF" /dev 61adb push "$PERF_OSYNC" /dev 62adb shell stop 63adb shell stop sdcard 64adb shell stop ril-daemon 65adb shell stop media 66adb shell stop drm 67adb shell stop keystore 68adb shell stop tf_daemon 69adb shell stop bluetoothd 70adb shell stop hciattach 71adb shell umount /sdcard >/dev/null 2>&1 72adb shell umount /data >/dev/null 2>&1 73adb shell umount /cache >/dev/null 2>&1 74# Add more services here that other devices need to stop. 75# So far, this list is sufficient for: 76# Prime 77 78# At this point, the device is quiescent, need to crank up the cpu speed, 79# then run tests 80adb shell "cat $CPUFREQ/cpuinfo_max_freq > $CPUFREQ/scaling_max_freq" 81adb shell "cat $CPUFREQ/cpuinfo_max_freq > $CPUFREQ/scaling_min_freq" 82 83# Start the tests 84 85# Sequential read test 86for I in 1 2 3 87do 88 echo "Sequential read test $I" 89 adb shell dd if="$CACHE" of=/dev/null bs=1048576 count=200 90done 91 92# Sequential write test 93for I in 1 2 3 94do 95 echo "Sequential write test $I" 96 adb shell dd if=/dev/zero of="$CACHE" bs=1048576 count=200 97done 98 99# Random read test 100for I in 1 2 3 101do 102 echo "Random read test $I" 103 adb shell /dev/"$PERF" -r 100 "$CACHE" 104done 105 106# Random write test 107for I in 1 2 3 108do 109 echo "Random write test $I" 110 adb shell /dev/"$PERF" -w 100 "$CACHE" 111done 112 113# Random write test with O_SYNC 114for I in 1 2 3 115do 116 echo "Random write with o_sync test $I" 117 adb shell /dev/"$PERF" -w 100 -o "$CACHE" 118done 119 120# Make a new empty /cache filesystem 121adb shell make_ext4fs "$CACHE" 122 123