Skip to content

Commit 522ed05

Browse files
committed
Add PCIe test script with capability checks ,README and result logging
This patch introduces a new PCIe test script that validates the presence of key PCIe attributes using `lspci -vvv`. It checks for: - Device tree node - Capabilities - Kernel driver in use The script logs detailed info and warnings for each check and writes a simple PASS/FAIL result to a .res file. It follows the existing test framework structure and uses functestlib logging utilities. Signed-off-by: Sai-teja573 <122cs0573@nitrkl.ac.in>
1 parent 7433bb9 commit 522ed05

File tree

2 files changed

+142
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)