summaryrefslogtreecommitdiff
path: root/docker/scripts/app-diag.sh
blob: 804d68aca82e943cfb52c6e57c2d9d8f6e5c6624 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
# Author:  cirakg & claude ai
# Summary: Run the debug app on each device in the headless simulator and check start-up time or memory budgets.
#
# Usage:   app-diag.sh perf|mem DEVICE [DEVICE ...]
# Output:  build/diag/<DEVICE>.log (console with DIAG and HARNESS lines) and
#          build/diag/<perf|mem>-summary.json; verdict from tools/check_budgets.py.
set -euo pipefail
# shellcheck source=ciq-env.sh
source "$(dirname "${BASH_SOURCE[0]}")/ciq-env.sh"

kind="${1:?usage: app-diag.sh perf|mem DEVICE [DEVICE ...]}"
shift
[[ "${kind}" == perf || "${kind}" == mem ]] || die "unknown kind '${kind}' (use perf or mem)"
(($# > 0)) || die "usage: app-diag.sh perf|mem DEVICE [DEVICE ...]"
ciq_require_sdk
ciq_require_key

for device in "$@"; do
  build-app.sh debug "${device}"
done

ciq_start_display
ciq_start_simulator

out="${BUILD_DIR}/diag"
mkdir -p "${out}"
logs=()
for device in "$@"; do
  log "starting the app on ${device}"
  ciq_launch_app "${device}" "${out}/${device}.log" || log "no first frame on ${device} within ${FIRST_FRAME_TIMEOUT_S} s"
  ciq_stop_app
  logs+=("${out}/${device}.log")
done

python3 /work/tools/check_budgets.py "${kind}" "${logs[@]}" --summary "${out}/${kind}-summary.json"