-
Notifications
You must be signed in to change notification settings - Fork 21
Add etm_trace test script and README documentation #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# ETM_Trace Validation test | ||
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
SPDX-License-Identifier: BSD-3-Clause-Clear | ||
|
||
## Overview | ||
This test case validates the CoreSight Embedded Trace Macrocell (ETM) trace capture functionality on the target device. It ensures that the ETM source and TMC sink are properly enabled and that trace data can be successfully captured and validated. | ||
|
||
## Test Performs : | ||
1. Verifies the presence of required kernel configuration (CONFIG_CORESIGHT_SOURCE_ETM4X) | ||
2. Enables the CoreSight sink (tmc_etr0) | ||
3. Enables the CoreSight source (etm0) | ||
4. Captures trace data from /dev/tmc_etr0 into a binary file | ||
5. Validates that the trace file is non-empty | ||
|
||
## Usage | ||
Instructions: | ||
1. **Copy repo to Target Device**: Use `scp` to transfer the scripts from the host to the target device. The scripts should be copied to any directory on the target device. | ||
2. **Verify Transfer**: Ensure that the repo has been successfully copied to the target device. | ||
3. **Run Scripts**: Navigate to the directory where these files are copied on the target device and execute the scripts as needed. | ||
|
||
Run the etm_trace test using: | ||
--- | ||
|
||
#### Quick Example | ||
```sh | ||
git clone <this-repo> | ||
cd <this-repo> | ||
scp -r common Runner user@target_device_ip:<Path in device> | ||
ssh user@target_device_ip | ||
cd <Path in device>/Runner && ./run-test.sh etm_trace | ||
``` | ||
--- | ||
|
||
## Prerequisites | ||
1. The kernel must be built with CONFIG_CORESIGHT_SOURCE_ETM4X enabled. | ||
2. CoreSight devices (etm0, tmc_etr0) must be exposed in /sys/bus/coresight/devices/. | ||
3. Root access may be required to access /dev/tmc_etr0 and write to system paths. | ||
--- | ||
|
||
## Result Format | ||
Test result will be saved in `etm_trace.res` as: | ||
|
||
## Output | ||
A .res file is generated in the same directory: | ||
`etm_trace PASS` OR `etm_trace FAIL` OR `etm_trace SKIP` | ||
|
||
## Skip Criteria | ||
1. If the required kernel configuration is missing, the result will be: | ||
2. `etm_trace SKIP` | ||
|
||
## Sample Log | ||
``` | ||
[INFO] 1980-01-06 00:04:29 - ----------------------------------------------------------------------------------------- | ||
[INFO] 1980-01-06 00:04:29 - -------------------Starting etm_trace Testcase---------------------------- | ||
[INFO] 1980-01-06 00:04:29 - === Test Initialization === | ||
[INFO] 1980-01-06 00:04:29 - Enabling CoreSight sink (tmc_etr0)... | ||
[INFO] 1980-01-06 00:04:29 - Sink enabled successfully. | ||
[INFO] 1980-01-06 00:04:29 - Enabling CoreSight source (etm0)... | ||
[INFO] 1980-01-06 00:04:29 - Source enabled successfully. | ||
[INFO] 1980-01-06 00:04:29 - Capturing trace data to /tmp/qdss.bin... | ||
[INFO] 1980-01-06 00:04:29 - Trace data captured successfully. | ||
[PASS] 1980-01-06 00:04:29 - etm_trace : Test Passed | ||
sh-5.2# ls | ||
etm_trace.res run.sh | ||
sh-5.2# cat etm_trace.res | ||
etm_trace PASS | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/bin/sh | ||
|
||
# Copyright (c) Qualcomm Technologies, Inc. | ||
# SPDX-License-Identifier: BSD-3-Clause-Clear | ||
|
||
# Robustly find and source init_env | ||
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 (starting at $SCRIPT_DIR)" >&2 | ||
exit 1 | ||
fi | ||
|
||
# Only source if not already loaded (idempotent) | ||
if [ -z "$__INIT_ENV_LOADED" ]; then | ||
# shellcheck disable=SC1090 | ||
. "$INIT_ENV" | ||
fi | ||
|
||
# Always source functestlib.sh, using $TOOLS exported by init_env | ||
# shellcheck disable=SC1090,SC1091 | ||
. "$TOOLS/functestlib.sh" | ||
|
||
TESTNAME="etm_trace" | ||
test_path=$(find_test_case_by_name "$TESTNAME") | ||
cd "$test_path" || exit 1 | ||
res_file="./$TESTNAME.res" | ||
|
||
log_info "-----------------------------------------------------------------------------------------" | ||
log_info "-------------------Starting $TESTNAME Testcase----------------------------" | ||
log_info "=== Test Initialization ===" | ||
|
||
pass=true | ||
|
||
# Step 1: Check required kernel config | ||
required_configs="CONFIG_CORESIGHT_SOURCE_ETM4X" | ||
check_kernel_config "$required_configs" || { | ||
log_skip "$TESTNAME : Required kernel config missing" | ||
echo "$TESTNAME SKIP" > "$res_file" | ||
exit 0 | ||
} | ||
|
||
# Step 2: Enable CoreSight sink | ||
log_info "Enabling CoreSight sink (tmc_etr0)..." | ||
echo 1 > /sys/bus/coresight/devices/tmc_etr0/enable_sink | ||
if [ "$(cat /sys/bus/coresight/devices/tmc_etr0/enable_sink)" -eq 1 ]; then | ||
log_info "Sink enabled successfully." | ||
else | ||
log_fail "Failed to enable sink." | ||
pass=false | ||
fi | ||
|
||
# Step 3: Enable CoreSight source | ||
log_info "Enabling CoreSight source (etm0)..." | ||
echo 1 > /sys/bus/coresight/devices/etm0/enable_source | ||
if [ "$(cat /sys/bus/coresight/devices/etm0/enable_source)" -eq 1 ]; then | ||
log_info "Source enabled successfully." | ||
else | ||
log_fail "Failed to enable source." | ||
pass=false | ||
fi | ||
|
||
# Step 4: Capture trace data | ||
TRACE_FILE="/tmp/qdss.bin" | ||
log_info "Capturing trace data to $TRACE_FILE..." | ||
if cat /dev/tmc_etr0 > "$TRACE_FILE"; then | ||
log_info "Trace data captured successfully." | ||
else | ||
log_fail "Failed to capture trace data." | ||
pass=false | ||
fi | ||
|
||
# Step 5: Validate trace output | ||
if [ -s "$TRACE_FILE" ]; then | ||
log_info "Trace file is not empty." | ||
else | ||
log_fail "Trace file is empty." | ||
pass=false | ||
fi | ||
|
||
# Final result and cleanup | ||
if $pass; then | ||
log_pass "$TESTNAME : Test Passed" | ||
echo "$TESTNAME PASS" > "$res_file" | ||
rm -f "$TRACE_FILE" | ||
log_info "-------------------Completed $TESTNAME Testcase----------------------------" | ||
exit 0 | ||
else | ||
log_fail "$TESTNAME : Test Failed" | ||
echo "$TESTNAME FAIL" > "$res_file" | ||
rm -f "$TRACE_FILE" | ||
log_info "-------------------Completed $TESTNAME Testcase----------------------------" | ||
exit 1 | ||
fi | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.