-
Notifications
You must be signed in to change notification settings - Fork 17
Add PCIe test script with capability checks and result logging #87
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
Open
Sai-teja573
wants to merge
3
commits into
qualcomm-linux:main
Choose a base branch
from
Sai-teja573:pcie-test-script
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
65 changes: 65 additions & 0 deletions
65
Runner/suites/Kernel/FunctionalArea/baseport/PCIe/README.md
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,65 @@ | ||
# PCIe Validation Test | ||
|
||
© Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
SPDX-License-Identifier: BSD-3-Clause-Clear | ||
|
||
## Overview | ||
|
||
This test case validates the PCIe interface on the target device by checking for the presence of key PCIe attributes using the `lspci -vvv` command. It ensures that the PCIe subsystem is correctly enumerated and functional. | ||
|
||
### The test checks for: | ||
- Presence of **Device Tree Node** | ||
- Availability of **PCIe Capabilities** | ||
- Binding of a **Kernel Driver** | ||
|
||
These checks help confirm that the PCIe root port is properly initialized and ready for use. | ||
|
||
--- | ||
|
||
## Usage | ||
|
||
### Instructions: | ||
|
||
1. **Copy the test suite to the target device** using `scp` or any preferred method. | ||
2. **Navigate to the test directory** on the target device. | ||
3. **Run the test script** using the test runner or directly. | ||
|
||
--- | ||
|
||
### Quick Example | ||
|
||
```bash | ||
git clone <this-repo> | ||
cd <this-repo> | ||
scp -r common Runner user@target_device_ip:<path-on-device> | ||
ssh user@target_device_ip | ||
cd <path-on-device>/Runner && ./run-test.sh pcie | ||
``` | ||
--- | ||
### Prerequisites | ||
1. `lspci` must be available on the target device | ||
2. PCIe interface must be exposed and initialized | ||
3. Root access may be required depending on system configuration | ||
--- | ||
## Result Format | ||
Test result will be saved in `pcie.res` as: | ||
|
||
|
||
|
||
## Output | ||
A .res file is generated in the same directory: | ||
|
||
`pcie PASS` OR `pcie FAIL` | ||
|
||
## Sample Log | ||
``` | ||
Output | ||
|
||
[INFO] 1980-01-06 01:51:08 - -------------------------------------------------------- | ||
[INFO] 1980-01-06 01:51:08 - -------------------Starting pcie Testcase---------------------------- | ||
[INFO] 1980-01-06 01:51:08 - === Test Initialization === | ||
[INFO] 1980-01-06 01:51:08 - Running PCIe Test | ||
[INFO] 1980-01-06 01:51:08 - Yes, 'Device tree node:' is found | ||
[INFO] 1980-01-06 01:51:08 - Yes, 'Capabilities:' is found | ||
[INFO] 1980-01-06 01:51:09 - Yes, 'Kernel driver in use:' is found | ||
[PASS] 1980-01-06 01:51:09 - pcie : Test Passed |
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,77 @@ | ||
#!/bin/sh | ||
|
||
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
# 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="pcie" | ||
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 ===" | ||
|
||
log_info "Running PCIe " | ||
lspci_output=$(lspci -vvv) | ||
|
||
missing="" | ||
|
||
if echo "$lspci_output" | grep -q "Device tree node:"; then | ||
log_info "Yes, 'Device tree node:' is found" | ||
else | ||
log_warn "No, 'Device tree node:' is missing" | ||
missing=1 | ||
fi | ||
|
||
if echo "$lspci_output" | grep -q "Capabilities:"; then | ||
log_info "Yes, 'Capabilities:' is found" | ||
else | ||
log_warn "No, 'Capabilities:' is missing" | ||
missing=1 | ||
fi | ||
|
||
if echo "$lspci_output" | grep -q "Kernel driver in use:"; then | ||
log_info "Yes, 'Kernel driver in use:' is found" | ||
else | ||
log_warn "No, 'Kernel driver in use:' is missing" | ||
missing=1 | ||
fi | ||
|
||
if [ -z "$missing" ]; then | ||
log_pass "$TESTNAME : Test Passed" | ||
echo "$TESTNAME PASS" > "$res_file" | ||
exit 0 | ||
else | ||
log_fail "$TESTNAME : Test Failed" | ||
echo "$TESTNAME FAIL" > "$res_file" | ||
exit 1 | ||
fi | ||
|
||
log_info "-------------------Completed $TESTNAME Testcase----------------------------" |
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.