Skip to content

Commit 2b2be7b

Browse files
Added TGU Enable/Disable Validation Script
* TGU-Enable-Disable: This script validates the state transtions of Coresight TGU devices. It dynamically discovers all the nodes and tries to toggle them on (1) or off (0) and checks for errors. Signed-off-by: Rohan Dutta <rohadutt@qti.qualcomm.com>
2 parents 5867b6c + d12c7e0 commit 2b2be7b

File tree

8 files changed

+1250
-24
lines changed

8 files changed

+1250
-24
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Coresight TGU Enable/Disable Test
2+
3+
## Overview
4+
This test validates the **Trace Generation Unit (TGU)** drivers in the Coresight subsystem. It ensures that TGUs can be enabled and disabled successfully when paired with standard sinks (ETR and ETF).
5+
6+
## Test Goals
7+
8+
- Validate the functionality of TGU drivers in the Coresight subsystem.
9+
- Ensure TGUs can be successfully enabled and disabled via sysfs.
10+
- Verify proper operation when TGUs are paired and routed to standard sinks (ETR and ETF).
11+
- Confirm that enabling/disabling TGUs does not return unexpected I/O errors.
12+
13+
## Prerequisites
14+
15+
- Kernel must be built with Coresight support.
16+
- `sysfs` access to `/sys/bus/coresight/devices/`.
17+
- Root priviledges needed.
18+
19+
## Script Location
20+
21+
```
22+
Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/run.sh
23+
```
24+
25+
## Files
26+
27+
- `run.sh` - Main test script
28+
- `TGU-Enable-Disable.res` - Summary result file with PASS/FAIL
29+
- `TGU-Enable-Disable.log` - Full execution log.
30+
31+
## How it Works
32+
1. **Discovery**:
33+
* Scans `/sys/bus/coresight/devices/` for devices matching `tgu` (e.g., `coresight-tgu`).
34+
* Identifies available sinks (`tmc_etr`, `tmc_etf`, or `coresight-tmc-*` variants).
35+
2. **Outer Loop (Sinks)**:
36+
* Iterates through available sinks (ETR, then ETF).
37+
* Resets the Coresight topology (`reset_source_sink`).
38+
* Enables the current sink.
39+
3. **Inner Loop (TGUs)**:
40+
* **Enable**: Writes `1` to `enable_tgu`.
41+
* **Verify**: Checks the exit code of the write operation.
42+
* **Disable**: Writes `0` to `enable_tgu`.
43+
* **Verify**: Checks the exit code.
44+
4. **Cleanup**: Disables the sink before the next iteration.
45+
46+
## Usage
47+
48+
Run the script directly. No iterations or special arguments are required for this basic test.
49+
50+
```bash
51+
./run.sh
52+
```
53+
54+
## Example Output
55+
56+
```
57+
[INFO] 2026-03-24 05:58:32 - -----------------------------------------------------------------------------------------
58+
[INFO] 2026-03-24 05:58:32 - -------------------Starting TGU-Enable-Disable Testcase----------------------------
59+
[WARN] 2026-03-24 05:58:32 - No TGU (Trace Generation Unit) devices found. Skipping test.
60+
[INFO] 2026-03-24 05:58:32 - Cleaning up...
61+
[INFO] 2026-03-24 05:58:32 - -------------------TGU-Enable-Disable Testcase Finished----------------------------
62+
```
63+
64+
## Return Code
65+
66+
- `0` — All TGUs are enabled and disabled successfully across all tested sinks
67+
- `1` — One or more TGUs failed to enable or disable
68+
69+
## Integration in CI
70+
71+
- Can be run standalone or via LAVA
72+
- Result file `TGU-Enable-Disable.res` will be parsed by `result_parse.sh`
73+
74+
## Notes
75+
76+
- The test systematically pairs TGUs with different sinks to ensure that the Coresight routing topology functions correctly for each configuration.
77+
78+
## License
79+
80+
SPDX-License-Identifier: BSD-3-Clause.
81+
(c) Qualcomm Technologies, Inc. and/or its subsidiaries.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
metadata:
2+
name: TGU-Enable-Disable
3+
format: "Lava-Test Test Definition 1.0"
4+
description: "Verifies Trace Generation Unit (TGU) functionality by enabling and disabling TGUs while routing to ETR and ETF sinks."
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/TGU-Enable-Disable || true
15+
- ./run.sh || true
16+
- $REPO_PATH/Runner/utils/send-to-lava.sh TGU-Enable-Disable.res || true
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
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+
fi
26+
27+
# shellcheck disable=SC1090,SC1091
28+
. "$TOOLS/functestlib.sh"
29+
30+
TESTNAME="TGU-Enable-Disable"
31+
if command -v find_test_case_by_name >/dev/null 2>&1; then
32+
test_path=$(find_test_case_by_name "$TESTNAME")
33+
cd "$test_path" || exit 1
34+
else
35+
cd "$SCRIPT_DIR" || exit 1
36+
fi
37+
38+
res_file="./$TESTNAME.res"
39+
log_info "-----------------------------------------------------------------------------------------"
40+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
41+
cs_base="/sys/bus/coresight/devices"
42+
fail_count=0
43+
44+
reset_coresight() {
45+
for _dev in "$cs_base"/*; do
46+
[ -d "$_dev" ] || continue
47+
48+
if [ -f "$_dev/enable_sink" ]; then
49+
echo 0 > "$_dev/enable_sink" 2>/dev/null || true
50+
fi
51+
52+
if [ -f "$_dev/enable_tgu" ]; then
53+
echo 0 > "$_dev/enable_tgu" 2>/dev/null || true
54+
fi
55+
done
56+
}
57+
58+
cleanup() {
59+
log_info "Cleaning up..."
60+
reset_coresight
61+
}
62+
63+
trap cleanup EXIT HUP INT TERM
64+
65+
if [ ! -d "$cs_base" ]; then
66+
log_fail "Coresight directory not found"
67+
echo "$TESTNAME FAIL" > "$res_file"
68+
exit 1
69+
fi
70+
71+
set -- "$cs_base"/*
72+
if [ ! -e "$1" ]; then
73+
log_fail "No Coresight devices found inside $cs_base"
74+
echo "$TESTNAME FAIL" > "$res_file"
75+
exit 1
76+
fi
77+
78+
reset_coresight
79+
80+
tgu_list=""
81+
for _d in "$cs_base"/tgu*; do
82+
[ -d "$_d" ] || continue
83+
tgu_list="$tgu_list $(basename "$_d")"
84+
done
85+
tgu_list="${tgu_list# }"
86+
87+
if [ -z "$tgu_list" ]; then
88+
log_warn "No TGU (Trace Generation Unit) devices found. Skipping test."
89+
echo "$TESTNAME SKIP" > "$res_file"
90+
exit 0
91+
fi
92+
93+
log_info "Found TGUs: $tgu_list"
94+
95+
sink_count=0
96+
for _d in "$cs_base"/*; do
97+
[ -d "$_d" ] || continue
98+
99+
if [ -f "$_d/enable_sink" ]; then
100+
if echo 1 > "$_d/enable_sink" 2>/dev/null; then
101+
sink_count=1
102+
log_info "Dynamically found and enabled sink: $(basename "$_d")"
103+
break
104+
fi
105+
fi
106+
done
107+
108+
if [ "$sink_count" -eq 0 ]; then
109+
log_warn "No sink enabled — proceeding with TGU test anyway"
110+
fi
111+
112+
for tgu in $tgu_list; do
113+
tgu_path="$cs_base/$tgu"
114+
115+
if [ ! -f "$tgu_path/enable_tgu" ]; then
116+
log_warn "No enable_tgu node for $tgu — skipping"
117+
continue
118+
fi
119+
120+
if ! echo 1 > "$tgu_path/enable_tgu" 2>/dev/null; then
121+
log_fail "Failed to enable TGU: $tgu"
122+
fail_count=$((fail_count + 1))
123+
else
124+
log_info "Enabled $tgu OK"
125+
fi
126+
127+
if ! echo 0 > "$tgu_path/enable_tgu" 2>/dev/null; then
128+
log_fail "Failed to disable TGU: $tgu"
129+
fail_count=$((fail_count + 1))
130+
else
131+
log_info "Disabled $tgu OK"
132+
fi
133+
done
134+
135+
if [ "$fail_count" -eq 0 ]; then
136+
log_pass "TGU Enable/Disable Test PASS"
137+
echo "$TESTNAME PASS" > "$res_file"
138+
else
139+
log_fail "TGU Enable/Disable Test FAIL ($fail_count errors)"
140+
echo "$TESTNAME FAIL" > "$res_file"
141+
fi
142+
143+
log_info "-------------------$TESTNAME Testcase Finished----------------------------"
144+
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)