blob: 1c5c371f2ce52bb0941fec34862666acb0449f66 [file] [log] [blame]
Primiano Tuccib7cca202018-01-29 16:30:47 +00001#!/bin/bash
2# Copyright (C) 2018 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15set -e
16
Hector Dearmanc9c183a2018-02-08 12:01:12 +000017function is_monolithic() {
18 local out=$1
19 gn args $out --list --short | grep 'monolithic_binaries = true' > /dev/null
20 return $?
21}
22
Primiano Tuccib7cca202018-01-29 16:30:47 +000023# If not set guess the OUT dir using the latest directory.
24if [ ! -f "$OUT/args.gn" ]; then
25 echo "OUT=$OUT doesn't look like an output directory."
26 echo "Please specify a directory by doing: export OUT=out/xxx"
27 exit 1
28fi
29
Hector Dearmanc88a66d2018-02-01 14:07:14 +000030# You can set the config to one of the files under test/configs e.g.
31# CONFIG=ftrace.cfg or to :test. Defaults to :test.
32CONFIG="${CONFIG:-:test}"
33
34ninja -C $OUT traced traced_probes perfetto trace_to_text test/configs
Primiano Tuccib7cca202018-01-29 16:30:47 +000035
36set -x
37adb push $OUT/traced /data/local/tmp/
38adb push $OUT/traced_probes /data/local/tmp/
39adb push $OUT/perfetto /data/local/tmp/
40set +x
41
Hector Dearmanc9c183a2018-02-08 12:01:12 +000042PREFIX=""
43if ! is_monolithic $OUT; then
44 PREFIX="LD_LIBRARY_PATH=/data/local/tmp"
45 set -x
46 adb push $OUT/libtraced_shared.so /data/local/tmp/
47 set +x
48fi
49
Hector Dearmanc88a66d2018-02-01 14:07:14 +000050CONFIG_DEVICE_PATH=$CONFIG
51if [[ "$CONFIG" != ":test" ]]; then
52 CONFIG_DEVICE_PATH=/data/local/tmp/$CONFIG.protobuf
53 CONFIG_PATH=$OUT/$CONFIG.protobuf;
54 if [[ ! -f $CONFIG_PATH ]]; then
55 echo 'Config "'$CONFIG_PATH'" not known.'
56 exit 1
57 fi
58 set -x
59 adb push $CONFIG_PATH /data/local/tmp/
60 set +x
61fi
62
Primiano Tuccib7cca202018-01-29 16:30:47 +000063if tmux has-session -t demo; then
64 tmux kill-session -t demo
65fi
66tmux -2 new-session -d -s demo
67
68if tmux -V | awk '{split($2, ver, "."); if (ver[1] < 2) exit 1 ; else if (ver[1] == 2 && ver[2] < 1) exit 1 }'; then
69 tmux set-option -g mouse on
70else
71 tmux set-option -g mode-mouse on
72 tmux set-option -g mouse-resize-pane on
73 tmux set-option -g mouse-select-pane on
74 tmux set-option -g mouse-select-window on
75fi
76
77tmux split-window -v
78tmux split-window -v
79
80tmux select-layout even-vertical
81
82tmux select-pane -t 0
83tmux send-keys "clear" C-m
84tmux send-keys "adb shell" C-m
85
86tmux select-pane -t 1
87tmux send-keys "clear" C-m
88tmux send-keys "adb shell" C-m
89
90tmux select-pane -t 2
91tmux send-keys "clear" C-m
92tmux send-keys "adb shell" C-m
93
Hector Dearmanc88a66d2018-02-01 14:07:14 +000094sleep 2
Primiano Tuccib7cca202018-01-29 16:30:47 +000095
96tmux select-pane -t 1
Hector Dearmanc9c183a2018-02-08 12:01:12 +000097tmux send-keys "$PREFIX /data/local/tmp/traced" Enter
Primiano Tuccib7cca202018-01-29 16:30:47 +000098
Primiano Tuccib7cca202018-01-29 16:30:47 +000099tmux select-pane -t 0
Hector Dearmanc9c183a2018-02-08 12:01:12 +0000100tmux send-keys "$PREFIX /data/local/tmp/traced_probes" Enter
Primiano Tuccib7cca202018-01-29 16:30:47 +0000101
102tmux select-pane -t 2
Hector Dearmanc9c183a2018-02-08 12:01:12 +0000103tmux send-keys "$PREFIX /data/local/tmp/perfetto -c $CONFIG_DEVICE_PATH -o /data/local/tmp/trace"
Primiano Tuccib7cca202018-01-29 16:30:47 +0000104
105# Select consumer pane.
106tmux select-pane -t 2
107
108tmux -2 attach-session -t demo
109
110TRACE=$HOME/Downloads/trace.json
111echo -e "\n\x1b[32mPulling trace into $TRACE\x1b[0m"
112set -x
113adb pull /data/local/tmp/trace /tmp/trace.protobuf
114$OUT/trace_to_text systrace < /tmp/trace.protobuf > $TRACE