blob: db332a122c9c4ddc5dba1049a0582f063183bbe5 [file] [log] [blame]
Chase Qi48f4a4a2017-04-14 17:23:55 +08001#!/system/bin/sh
2# shellcheck disable=SC2181
Milosz Wasilewskib52bb272025-01-14 19:21:37 +00003# shellcheck disable=SC2320
Chase Qi48f4a4a2017-04-14 17:23:55 +08004#
5# script to start and stop bootchart test.
6#
7# Copyright (C) 2014, Linaro Limited.
Milosz Wasilewskib52bb272025-01-14 19:21:37 +00008# Copyright (C) 2025, Qualcomm Inc.
Chase Qi48f4a4a2017-04-14 17:23:55 +08009#
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
29LOGROOT="/data/bootchart"
30start_f="${LOGROOT}/start"
31enabled_f="${LOGROOT}/enabled"
32stop_f="${LOGROOT}/stop"
33
34start_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
43enabled_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
52stop_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
67main(){
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
97main "$@"