Skip to content

Commit 61c81a2

Browse files
Merge pull request #261 from smuppand/camera-yavta
camera(Camera_NHX): add NHX validation + CAMX helpers + LAVA integration Signed-off-by: Rohan Dutta <rohadutt@qti.qualcomm.com>
2 parents 5867b6c + d12c7e0 commit 61c81a2

File tree

9 files changed

+1312
-24
lines changed

9 files changed

+1312
-24
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
metadata:
2+
name: Coresight-Sink-Source-Test
3+
format: "Lava-Test Test Definition 1.0"
4+
description: "This test iterates through all CoreSight sources and sinks to validate end‑to‑end trace path accessibility. It ensures trace data capture works correctly and that all sources are cleanly disabled after execution."
5+
os:
6+
- linux
7+
scope:
8+
- coresight
9+
- kernel
10+
11+
run:
12+
steps:
13+
- REPO_PATH=$PWD || true
14+
- cd Runner/suites/Kernel/DEBUG/Coresight-Sink-Source-Test || true
15+
- ./run.sh || true
16+
- $REPO_PATH/Runner/utils/send-to-lava.sh Coresight-Sink-Source-Test.res || true
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Coresight-Sink-Source-Test
2+
3+
## Overview
4+
The `Coresight-Sink-Source-Test` test iterates through all CoreSight sources and sinks to validate end‑to‑end trace path accessibility. It ensures trace data capture works correctly and that all sources are cleanly disabled after execution.
5+
6+
## Test Goals
7+
8+
- Verify that the CoreSight sink correctly switches to ETF mode.
9+
- Validate STM trace data routing to ETF via Ftrace integration.
10+
- Ensure sched_switch events are captured and stored in the ETF buffer.
11+
- Confirm valid trace data generation by checking ETF output size.
12+
13+
## Prerequisites
14+
15+
- Coresight framework enabled in the kernel with `sysfs` and `debugfs` accessible
16+
- Multiple Coresight sink and source devices should be present
17+
- Coresight STM, ETM, ETF devices must be included
18+
- Root priviledges
19+
20+
## Script Location
21+
22+
```
23+
Runner/suites/Kernel/DEBUG/Coresight-Sink-Source-Test/run.sh
24+
```
25+
26+
## Files
27+
28+
- `run.sh` - Main test script
29+
- `Coresight-Sink-Source-Test.res` - Summary result file with PASS/FAIL
30+
- `Coresight-Sink-Source-Test.log` - Full execution log.
31+
32+
## How it works
33+
1. Parses input parameters, sources common utilities, gathers all CoreSight devices, and configures the ETR sink to memory output mode.
34+
2. Loops over all valid CoreSight sinks and sources, optionally skipping remote ETMs and unsupported TPDM sources.
35+
3. Resets all sources and sinks, enables one sink at a time, then enables each applicable source to form a complete trace path.
36+
4. Reads trace data from each sink device and verifies successful data capture based on output file size.
37+
5. Resets the system again and checks that all sources are properly disabled before reporting pass or fail status.
38+
39+
## Usage
40+
41+
Run the script directly. No iterations or special arguments are required for this basic test.
42+
43+
```bash
44+
./run.sh
45+
```
46+
47+
## Example Output
48+
49+
```
50+
[INFO] 2026-04-06 05:17:08 - ---------------------------Coresight-Sink-Source-Test Starting---------------------------
51+
[INFO] 2026-04-06 05:17:08 - Starting iteration: 1
52+
[INFO] 2026-04-06 05:17:08 - Sink Active:- tmc_etf0
53+
[INFO] 2026-04-06 05:17:09 - Source: etm0 with trace captured of size 65536 bytes
54+
[INFO] 2026-04-06 05:17:10 - Source: etm1 with trace captured of size 65536 bytes
55+
[INFO] 2026-04-06 05:17:11 - Source: etm2 with trace captured of size 65536 bytes
56+
.........
57+
[INFO] 2026-04-06 05:20:15 - Source: tpdm7 with trace captured of size 96 bytes
58+
[INFO] 2026-04-06 05:20:16 - Source: tpdm8 with trace captured of size 96 bytes
59+
[INFO] 2026-04-06 05:20:17 - Source: tpdm9 with trace captured of size 80 bytes
60+
[INFO] 2026-04-06 05:20:17 - PASS: coresight source/sink path test
61+
[INFO] 2026-04-06 05:20:17 - ---------------------------Coresight-Sink-Source-Test Finished---------------------------
62+
```
63+
64+
## Return Code
65+
66+
- `0` — All test cases passed
67+
- `1` — One or more test cases failed
68+
69+
## Integration in CI
70+
71+
- Can be run standalone or via LAVA
72+
- Result file `Coresight-Sink-Source-Test.res` will be parsed by `result_parse.sh`
73+
74+
## Notes
75+
76+
- Remote ETM sources and unsupported TPDM sources are conditionally skipped during testing.
77+
- Trace validity is confirmed by checking a minimum output file size from each sink.
78+
79+
## License
80+
81+
SPDX-License-Identifier: BSD-3-Clause.
82+
(c) Qualcomm Technologies, Inc. and/or its subsidiaries.
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
7+
INIT_ENV=""
8+
SEARCH="$SCRIPT_DIR"
9+
while [ "$SEARCH" != "/" ]; do
10+
if [ -f "$SEARCH/init_env" ]; then
11+
INIT_ENV="$SEARCH/init_env"
12+
break
13+
fi
14+
SEARCH=$(dirname "$SEARCH")
15+
done
16+
17+
if [ -z "$INIT_ENV" ]; then
18+
echo "[ERROR] Could not find init_env" >&2
19+
exit 1
20+
fi
21+
22+
if [ -z "$__INIT_ENV_LOADED" ]; then
23+
# shellcheck disable=SC1090
24+
. "$INIT_ENV"
25+
__INIT_ENV_LOADED=1
26+
fi
27+
28+
# shellcheck disable=SC1090,SC1091
29+
. "$TOOLS/functestlib.sh"
30+
# shellcheck disable=SC1090,SC1091
31+
. "$TOOLS/coresight_helper.sh"
32+
33+
TESTNAME="Coresight-Sink-Source-Test"
34+
test_path=$(find_test_case_by_name "$TESTNAME")
35+
cd "$test_path" || exit 1
36+
res_file="./$TESTNAME.res"
37+
log_info "---------------------------$TESTNAME Starting---------------------------"
38+
no_remote_etm=0
39+
if [ "$#" -eq 1 ]; then
40+
no_remote_etm=1
41+
fi
42+
cs_base="/sys/bus/coresight/devices"
43+
fail=0
44+
45+
if [ ! -d "$cs_base" ]; then
46+
log_warn "Coresight directory $cs_base not found. Skipping test."
47+
echo "$TESTNAME SKIP" > "$res_file"
48+
exit 0
49+
fi
50+
51+
cleanup() {
52+
reset_coresight
53+
}
54+
trap cleanup EXIT HUP INT TERM
55+
56+
reset_coresight
57+
sinks=""
58+
sources=""
59+
for node in "$cs_base"/*; do
60+
[ ! -d "$node" ] && continue
61+
node_name=$(basename "$node")
62+
63+
if [ -f "$node/enable_sink" ]; then
64+
[ "$node_name" = "tmc_etf1" ] && continue
65+
sinks="$sinks $node"
66+
67+
if [ -f "$node/out_mode" ]; then
68+
echo mem > "$node/out_mode" 2>/dev/null || true
69+
fi
70+
fi
71+
72+
if [ -f "$node/enable_source" ]; then
73+
sources="$sources $node"
74+
fi
75+
done
76+
77+
sinks=${sinks# }
78+
sources=${sources# }
79+
if [ -z "$sinks" ]; then
80+
log_warn "No Coresight sinks found. Skipping test."
81+
echo "$TESTNAME SKIP" > "$res_file"
82+
exit 0
83+
fi
84+
85+
if [ -z "$sources" ]; then
86+
log_warn "No Coresight sources found. Skipping test."
87+
echo "$TESTNAME SKIP" > "$res_file"
88+
exit 0
89+
fi
90+
91+
i=0
92+
while [ "$i" -le 2 ]; do
93+
log_info "Starting iteration: $((i+1))"
94+
for sink_node in $sinks; do
95+
sink_dev=$(basename "$sink_node")
96+
log_info "Sink Active:- $sink_dev"
97+
98+
for source_node in $sources; do
99+
dev_name=$(basename "$source_node")
100+
101+
case "$dev_name" in
102+
*etm*)
103+
if [ "$no_remote_etm" -eq 1 ]; then
104+
continue
105+
fi
106+
;;
107+
*tpdm-vsense* | *tpdm-qm*)
108+
continue
109+
;;
110+
esac
111+
reset_coresight
112+
113+
[ -f "$sink_node/enable_sink" ] && echo 1 > "$sink_node/enable_sink" 2>/dev/null
114+
if [ -f "$source_node/enable_source" ]; then
115+
echo 1 > "$source_node/enable_source" 2>/dev/null
116+
ret=$(tr -d ' ' < "$source_node/enable_source")
117+
if [ "$ret" = "0" ]; then
118+
log_fail "FAIL: enable source in $dev_name"
119+
fail=1
120+
continue
121+
fi
122+
fi
123+
sleep 1
124+
reset_coresight
125+
126+
rm -f "/tmp/$sink_dev.bin"
127+
if [ -c "/dev/$sink_dev" ]; then
128+
cat "/dev/$sink_dev" > "/tmp/$sink_dev.bin" 2>/dev/null
129+
outfilesize=$(wc -c < "/tmp/$sink_dev.bin" 2>/dev/null | tr -d ' ')
130+
else
131+
log_warn "Character device /dev/$sink_dev not found! Skipping read."
132+
outfilesize=0
133+
fi
134+
135+
if [ -n "$outfilesize" ] && [ "$outfilesize" -ge 64 ]; then
136+
log_info "Source: $dev_name with trace captured of size $outfilesize bytes"
137+
else
138+
log_fail "Source: $dev_name with no traces captured of size ${outfilesize:-0}"
139+
fail=1
140+
fi
141+
done
142+
done
143+
i=$((i + 1))
144+
done
145+
reset_coresight
146+
147+
for source_node in $sources; do
148+
dev_name=$(basename "$source_node")
149+
if [ -f "$source_node/enable_source" ]; then
150+
ret=$(tr -d ' ' < "$source_node/enable_source")
151+
if [ "$ret" = "1" ]; then
152+
log_fail "fail to disable source in $dev_name during final verification"
153+
fail=1
154+
fi
155+
fi
156+
done
157+
158+
if [ "$fail" -eq 0 ]; then
159+
log_pass "$TESTNAME : Test Passed"
160+
echo "$TESTNAME PASS" > "$res_file"
161+
else
162+
log_fail "$TESTNAME : Test Failed"
163+
echo "$TESTNAME FAIL" > "$res_file"
164+
fi
165+
166+
log_info "---------------------------$TESTNAME Finished---------------------------"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
metadata:
2+
name: camera_nhx
3+
format: "Lava-Test Test Definition 1.0"
4+
description: "Camera NHX preview validation"
5+
os:
6+
- yocto
7+
scope:
8+
- functional
9+
10+
run:
11+
steps:
12+
- REPO_PATH=$PWD
13+
- cd Runner/suites/Multimedia/Camera/Camera_NHX
14+
- ./run.sh || true
15+
- $REPO_PATH/Runner/utils/send-to-lava.sh Camera_NHX.res

0 commit comments

Comments
 (0)