Skip to content

Commit c0ddc36

Browse files
authored
Merge pull request qualcomm-linux#87 from Sai-teja573/pcie-test-script
Add PCIe test script with capability checks and result logging
2 parents 529677e + 1bb6ec5 commit c0ddc36

File tree

2 files changed

+127
-0
lines changed

2 files changed

+127
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# PCIe Validation Test
2+
© Qualcomm Technologies, Inc. and/or its subsidiaries.
3+
SPDX-License-Identifier: BSD-3-Clause-Clear
4+
## Overview
5+
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
6+
### The test checks for:
7+
- Presence of **Device Tree Node**
8+
- Availability of **PCIe Capabilities**
9+
- Binding of a **Kernel Driver**
10+
11+
These checks help confirm that the PCIe root port is properly initialized and ready for use
12+
## Usage
13+
### Instructions:
14+
1. **Copy the test suite to the target device** using `scp` or any preferred method.
15+
2. **Navigate to the test directory** on the target device.
16+
3. **Run the test script** using the test runner or directly.
17+
---
18+
### Quick Example
19+
```bash
20+
git clone <this-repo>
21+
cd <this-repo>
22+
scp -r common Runner user@target_device_ip:<path-on-device>
23+
ssh user@target_device_ip
24+
cd <path-on-device>/Runner && ./run-test.sh PCIe
25+
```
26+
---
27+
### Prerequisites
28+
1. `lspci` must be available on the target device
29+
2. PCIe interface must be exposed and initialized
30+
3. Root access may be required depending on system configuration
31+
---
32+
## Result Format
33+
Test result will be saved in `PCIe.res` as:
34+
## Output
35+
A .res file is generated in the same directory:
36+
`PCIe PASS` OR `PCIe FAIL`
37+
## Sample Log
38+
```
39+
[INFO] 1980-01-06 00:43:54 - -----------------------------------------------------------------------------------------
40+
[INFO] 1980-01-06 00:43:54 - -------------------Starting PCIe Testcase----------------------------
41+
[INFO] 1980-01-06 00:43:54 - === Test Initialization ===
42+
[INFO] 1980-01-06 00:43:54 - Checking if required tools are available
43+
[INFO] 1980-01-06 00:43:54 - Running PCIe
44+
[INFO] 1980-01-06 00:43:54 - DT node is present
45+
[INFO] 1980-01-06 00:43:54 - Yes, 'Capabilities:' is found
46+
[INFO] 1980-01-06 00:43:54 - Driver is loaded
47+
[PASS] 1980-01-06 00:43:54 - PCIe : Test Passed
48+
```
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
# SPDX-License-Identifier: BSD-3-Clause-Clear
5+
6+
# Robustly find and source init_env
7+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8+
INIT_ENV=""
9+
SEARCH="$SCRIPT_DIR"
10+
while [ "$SEARCH" != "/" ]; do
11+
if [ -f "$SEARCH/init_env" ]; then
12+
INIT_ENV="$SEARCH/init_env"
13+
break
14+
fi
15+
SEARCH=$(dirname "$SEARCH")
16+
done
17+
18+
if [ -z "$INIT_ENV" ]; then
19+
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
20+
exit 1
21+
fi
22+
23+
# Only source if not already loaded (idempotent)
24+
if [ -z "$__INIT_ENV_LOADED" ]; then
25+
# shellcheck disable=SC1090
26+
. "$INIT_ENV"
27+
fi
28+
# Always source functestlib.sh, using $TOOLS exported by init_env
29+
# shellcheck disable=SC1090,SC1091
30+
. "$TOOLS/functestlib.sh"
31+
32+
TESTNAME="PCIe"
33+
test_path=$(find_test_case_by_name "$TESTNAME")
34+
cd "$test_path" || exit 1
35+
res_file="./$TESTNAME.res"
36+
37+
log_info "-----------------------------------------------------------------------------------------"
38+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
39+
log_info "=== Test Initialization ==="
40+
log_info "Checking if required tools are available"
41+
42+
check_dependencies "lspci"
43+
log_info "Running PCIe "
44+
lspci_output=$(lspci -vvv)
45+
46+
missing=""
47+
48+
if echo "$lspci_output" | grep -q "Device tree node:"; then
49+
log_info "DT node is present"
50+
else
51+
log_warn "DT node is not present"
52+
missing=1
53+
fi
54+
55+
if echo "$lspci_output" | grep -q "Capabilities:"; then
56+
log_info "Yes, 'Capabilities:' is found"
57+
else
58+
log_warn "No, 'Capabilities:' is missing"
59+
missing=1
60+
fi
61+
62+
if echo "$lspci_output" | grep -q "Kernel driver in use:"; then
63+
log_info "Driver is loaded"
64+
else
65+
log_warn "Driver is not loaded"
66+
missing=1
67+
fi
68+
69+
if [ -z "$missing" ]; then
70+
log_pass "$TESTNAME : Test Passed"
71+
echo "$TESTNAME PASS" > "$res_file"
72+
exit 0
73+
else
74+
log_fail "$TESTNAME : Test Failed"
75+
echo "$TESTNAME FAIL" > "$res_file"
76+
exit 1
77+
fi
78+
79+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"

0 commit comments

Comments
 (0)