diff --git a/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/README.md b/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/README.md new file mode 100644 index 00000000..745d6c1b --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/README.md @@ -0,0 +1,81 @@ +# Coresight TGU Enable/Disable Test + +## Overview +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). + +## Test Goals + +- Validate the functionality of TGU drivers in the Coresight subsystem. +- Ensure TGUs can be successfully enabled and disabled via sysfs. +- Verify proper operation when TGUs are paired and routed to standard sinks (ETR and ETF). +- Confirm that enabling/disabling TGUs does not return unexpected I/O errors. + +## Prerequisites + +- Kernel must be built with Coresight support. +- `sysfs` access to `/sys/bus/coresight/devices/`. +- Root priviledges needed. + +## Script Location + +``` +Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/run.sh +``` + +## Files + +- `run.sh` - Main test script +- `TGU-Enable-Disable.res` - Summary result file with PASS/FAIL +- `TGU-Enable-Disable.log` - Full execution log. + +## How it Works +1. **Discovery**: + * Scans `/sys/bus/coresight/devices/` for devices matching `tgu` (e.g., `coresight-tgu`). + * Identifies available sinks (`tmc_etr`, `tmc_etf`, or `coresight-tmc-*` variants). +2. **Outer Loop (Sinks)**: + * Iterates through available sinks (ETR, then ETF). + * Resets the Coresight topology (`reset_source_sink`). + * Enables the current sink. +3. **Inner Loop (TGUs)**: + * **Enable**: Writes `1` to `enable_tgu`. + * **Verify**: Checks the exit code of the write operation. + * **Disable**: Writes `0` to `enable_tgu`. + * **Verify**: Checks the exit code. +4. **Cleanup**: Disables the sink before the next iteration. + +## Usage + +Run the script directly. No iterations or special arguments are required for this basic test. + +```bash +./run.sh +``` + +## Example Output + +``` +[INFO] 2026-03-24 05:58:32 - ----------------------------------------------------------------------------------------- +[INFO] 2026-03-24 05:58:32 - -------------------Starting TGU-Enable-Disable Testcase---------------------------- +[WARN] 2026-03-24 05:58:32 - No TGU (Trace Generation Unit) devices found. Skipping test. +[INFO] 2026-03-24 05:58:32 - Cleaning up... +[INFO] 2026-03-24 05:58:32 - -------------------TGU-Enable-Disable Testcase Finished---------------------------- +``` + +## Return Code + +- `0` — All TGUs are enabled and disabled successfully across all tested sinks +- `1` — One or more TGUs failed to enable or disable + +## Integration in CI + +- Can be run standalone or via LAVA +- Result file `TGU-Enable-Disable.res` will be parsed by `result_parse.sh` + +## Notes + +- The test systematically pairs TGUs with different sinks to ensure that the Coresight routing topology functions correctly for each configuration. + +## License + +SPDX-License-Identifier: BSD-3-Clause. +(c) Qualcomm Technologies, Inc. and/or its subsidiaries. \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/TGU-Enable-Disable.yaml b/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/TGU-Enable-Disable.yaml new file mode 100644 index 00000000..3b18ece4 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/TGU-Enable-Disable.yaml @@ -0,0 +1,16 @@ +metadata: + name: TGU-Enable-Disable + format: "Lava-Test Test Definition 1.0" + description: "Verifies Trace Generation Unit (TGU) functionality by enabling and disabling TGUs while routing to ETR and ETF sinks." + os: + - linux + scope: + - coresight + - kernel + +run: + steps: + - REPO_PATH=$PWD || true + - cd Runner/suites/Kernel/DEBUG/TGU-Enable-Disable || true + - ./run.sh || true + - $REPO_PATH/Runner/utils/send-to-lava.sh TGU-Enable-Disable.res || true \ No newline at end of file diff --git a/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/run.sh b/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/run.sh new file mode 100755 index 00000000..acf96d81 --- /dev/null +++ b/Runner/suites/Kernel/DEBUG/TGU-Enable-Disable/run.sh @@ -0,0 +1,144 @@ +#!/bin/sh + +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + fi + SEARCH=$(dirname "$SEARCH") +done + +if [ -z "$INIT_ENV" ]; then + echo "[ERROR] Could not find init_env" >&2 + exit 1 +fi + +if [ -z "$__INIT_ENV_LOADED" ]; then + # shellcheck disable=SC1090 + . "$INIT_ENV" +fi + +# shellcheck disable=SC1090,SC1091 +. "$TOOLS/functestlib.sh" + +TESTNAME="TGU-Enable-Disable" +if command -v find_test_case_by_name >/dev/null 2>&1; then + test_path=$(find_test_case_by_name "$TESTNAME") + cd "$test_path" || exit 1 +else + cd "$SCRIPT_DIR" || exit 1 +fi + +res_file="./$TESTNAME.res" +log_info "-----------------------------------------------------------------------------------------" +log_info "-------------------Starting $TESTNAME Testcase----------------------------" +cs_base="/sys/bus/coresight/devices" +fail_count=0 + +reset_coresight() { + for _dev in "$cs_base"/*; do + [ -d "$_dev" ] || continue + + if [ -f "$_dev/enable_sink" ]; then + echo 0 > "$_dev/enable_sink" 2>/dev/null || true + fi + + if [ -f "$_dev/enable_tgu" ]; then + echo 0 > "$_dev/enable_tgu" 2>/dev/null || true + fi + done +} + +cleanup() { + log_info "Cleaning up..." + reset_coresight +} + +trap cleanup EXIT HUP INT TERM + +if [ ! -d "$cs_base" ]; then + log_fail "Coresight directory not found" + echo "$TESTNAME FAIL" > "$res_file" + exit 1 +fi + +set -- "$cs_base"/* +if [ ! -e "$1" ]; then + log_fail "No Coresight devices found inside $cs_base" + echo "$TESTNAME FAIL" > "$res_file" + exit 1 +fi + +reset_coresight + +tgu_list="" +for _d in "$cs_base"/tgu*; do + [ -d "$_d" ] || continue + tgu_list="$tgu_list $(basename "$_d")" +done +tgu_list="${tgu_list# }" + +if [ -z "$tgu_list" ]; then + log_warn "No TGU (Trace Generation Unit) devices found. Skipping test." + echo "$TESTNAME SKIP" > "$res_file" + exit 0 +fi + +log_info "Found TGUs: $tgu_list" + +sink_count=0 +for _d in "$cs_base"/*; do + [ -d "$_d" ] || continue + + if [ -f "$_d/enable_sink" ]; then + if echo 1 > "$_d/enable_sink" 2>/dev/null; then + sink_count=1 + log_info "Dynamically found and enabled sink: $(basename "$_d")" + break + fi + fi +done + +if [ "$sink_count" -eq 0 ]; then + log_warn "No sink enabled — proceeding with TGU test anyway" +fi + +for tgu in $tgu_list; do + tgu_path="$cs_base/$tgu" + + if [ ! -f "$tgu_path/enable_tgu" ]; then + log_warn "No enable_tgu node for $tgu — skipping" + continue + fi + + if ! echo 1 > "$tgu_path/enable_tgu" 2>/dev/null; then + log_fail "Failed to enable TGU: $tgu" + fail_count=$((fail_count + 1)) + else + log_info "Enabled $tgu OK" + fi + + if ! echo 0 > "$tgu_path/enable_tgu" 2>/dev/null; then + log_fail "Failed to disable TGU: $tgu" + fail_count=$((fail_count + 1)) + else + log_info "Disabled $tgu OK" + fi +done + +if [ "$fail_count" -eq 0 ]; then + log_pass "TGU Enable/Disable Test PASS" + echo "$TESTNAME PASS" > "$res_file" +else + log_fail "TGU Enable/Disable Test FAIL ($fail_count errors)" + echo "$TESTNAME FAIL" > "$res_file" +fi + +log_info "-------------------$TESTNAME Testcase Finished----------------------------" +