Chase Qi | 48f4a4a | 2017-04-14 17:23:55 +0800 | [diff] [blame] | 1 | #!/system/bin/sh |
| 2 | # shellcheck disable=SC2181 |
Milosz Wasilewski | b52bb27 | 2025-01-14 19:21:37 +0000 | [diff] [blame^] | 3 | # shellcheck disable=SC2320 |
Chase Qi | 48f4a4a | 2017-04-14 17:23:55 +0800 | [diff] [blame] | 4 | # |
| 5 | # script to start and stop bootchart test. |
| 6 | # |
| 7 | # Copyright (C) 2014, Linaro Limited. |
Milosz Wasilewski | b52bb27 | 2025-01-14 19:21:37 +0000 | [diff] [blame^] | 8 | # Copyright (C) 2025, Qualcomm Inc. |
Chase Qi | 48f4a4a | 2017-04-14 17:23:55 +0800 | [diff] [blame] | 9 | # |
| 10 | # This program is free software; you can redistribute it and/or |
| 11 | # modify it under the terms of the GNU General Public License |
| 12 | # as published by the Free Software Foundation; either version 2 |
| 13 | # of the License, or (at your option) any later version. |
| 14 | # |
| 15 | # This program is distributed in the hope that it will be useful, |
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | # GNU General Public License for more details. |
| 19 | # |
| 20 | # You should have received a copy of the GNU General Public License |
| 21 | # along with this program; if not, write to the Free Software |
| 22 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
| 23 | # USA. |
| 24 | # |
| 25 | # owner: yongqin.liu@linaro.org |
| 26 | # |
| 27 | ############################################################################### |
| 28 | |
| 29 | LOGROOT="/data/bootchart" |
| 30 | start_f="${LOGROOT}/start" |
| 31 | enabled_f="${LOGROOT}/enabled" |
| 32 | stop_f="${LOGROOT}/stop" |
| 33 | |
| 34 | start_bootchart(){ |
| 35 | echo "${BOOTCHART_TIME}" > ${start_f} |
| 36 | if [ $? -ne 0 ]; then |
| 37 | echo "start_bootchart: fail" |
| 38 | else |
| 39 | echo "start_bootchart: pass" |
| 40 | fi |
| 41 | } |
| 42 | |
| 43 | enabled_bootchart(){ |
| 44 | touch ${enabled_f} |
| 45 | if [ $? -ne 0 ]; then |
| 46 | echo "enabled_bootchart: fail" |
| 47 | else |
| 48 | echo "enabled_bootchart: pass" |
| 49 | fi |
| 50 | } |
| 51 | |
| 52 | stop_bootchart(){ |
| 53 | echo 1 > ${stop_f} |
| 54 | if [ $? -ne 0 ]; then |
| 55 | echo "stop_bootchart: fail" |
| 56 | else |
| 57 | echo "stop_bootchart: pass" |
| 58 | fi |
| 59 | rm -fr ${start_f} ${enabled_f} |
| 60 | if [ $? -ne 0 ]; then |
| 61 | echo "rm_start_file: fail" |
| 62 | else |
| 63 | echo "rm_start_file: pass" |
| 64 | fi |
| 65 | } |
| 66 | |
| 67 | main(){ |
| 68 | OPERATION="${1}" |
| 69 | if [ "X${OPERATION}" = "X" ]; then |
| 70 | OPERATION="stop" |
| 71 | fi |
| 72 | BOOTCHART_TIME="${2}" |
| 73 | if [ "X${BOOTCHART_TIME}" = "X" ]; then |
| 74 | BOOTCHART_TIME=120 |
| 75 | fi |
| 76 | export BOOTCHART_TIME |
| 77 | |
| 78 | case "X${OPERATION}" in |
| 79 | "Xstart") |
| 80 | start_bootchart |
| 81 | enabled_bootchart |
| 82 | ;; |
| 83 | "Xstop") |
| 84 | stop_bootchart |
| 85 | # Wait the file to be sync disk completely |
| 86 | sleep 5 |
| 87 | # copy bootchart logs to /data/local/tmp so that we can pull them |
| 88 | # without root permissoin. |
| 89 | cp -r /data/bootchart /data/local/tmp/ |
| 90 | ;; |
| 91 | *) |
| 92 | echo "bootchart: fail" |
| 93 | ;; |
| 94 | esac |
| 95 | } |
| 96 | |
| 97 | main "$@" |