Skip to content

Commit ba2943d

Browse files
author
Jeevanandan Sandan
committed
feat: added qrtr_lookup test
Signed-off-by: Jeevanandan Sandan <sandanka@qti.qualcomm.com>
1 parent 2a4860a commit ba2943d

5 files changed

Lines changed: 269 additions & 1 deletion

File tree

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# qrtr-lookup Validation Test
2+
3+
## Overview
4+
This script verifies the existence of Qualcomm IPC Router (QRTR) services on a Linux target. It utilizes the `qrtr-lookup` command to scan for active nodes and validates that specific subsystems (ADSP, CDSP, Modem, etc.) are up and registered with the correct Instance IDs.
5+
6+
## Prerequisites
7+
* **Target Device:** Qualcomm Linux Device (e.g., QCS6490, QCS9100, etc.)
8+
* **Software:** `qrtr-lookup` binary must be installed and in the system `$PATH`.
9+
* **Shell:** Standard `/bin/sh` or `/bin/bash`.
10+
11+
## Usage
12+
13+
### 1. Default Mode (ADSP Root)
14+
### 1. Default Mode (Any Service Scan)
15+
Running the script without arguments will scan for **any** active service labeled "Test service" in the `qrtr-lookup` output. The test passes if **at least one** service is found.
16+
```bash
17+
./run.sh
18+
19+
### 2. Targeted Mode (Recommended)
20+
Use the `-t` flag to check a specific subsystem by name. This handles ID mapping automatically.
21+
```bash
22+
./run.sh -t <target_name>
23+
```
24+
**Examples:**
25+
```bash
26+
./run.sh -t audio # Checks ADSP Audio PD (ID 33)
27+
./run.sh -t adsp root # Checks ADSP Root PD (ID 32)
28+
./run.sh -t cdsp # Checks CDSP Root (ID 64)
29+
./run.sh -t wpss # Checks WPSS (ID 128)
30+
./run.sh -t gpdsp0 # Checks GPDSP0 (ID 112)
31+
```
32+
33+
### 3. Manual Override
34+
Use the `-i` flag if you need to check a specific Instance ID that is not yet mapped in the script.
35+
```bash
36+
./run.sh -i 99
37+
```
38+
39+
## Supported Targets
40+
The following aliases are supported via the `-t` flag:
41+
42+
| Subsystem | Target Names (Case Insensitive) | Instance ID |
43+
| :--- | :--- | :--- |
44+
| **ADSP** | `adsp`, `adsp-root` | **32** (Default) |
45+
| **ADSP Audio** | `audio`, `adsp-audiopd` | **33** |
46+
| **ADSP Sensor** | `sensor`, `adsp-sensorpd` | **34** |
47+
| **ADSP Charger** | `charger`, `adsp-chargerpd` | **35** |
48+
| **CDSP** | `cdsp` | **64** |
49+
| **CDSP 1** | `cdsp1` | **72** |
50+
| **GPDSP 0** | `gpdsp0`, `gpdsp0-root` | **112** |
51+
| **GPDSP 0 User**| `gpdsp0-user` | **113** |
52+
| **GPDSP 1** | `gpdsp1`, `gpdsp1-root` | **120** |
53+
| **GPDSP 1 User**| `gpdsp1-user` | **121** |
54+
| **WPSS** | `wpss` | **128** |
55+
| **SOC CP** | `soccp` | **141** |
56+
| **DCP** | `dcp` | **142** |
57+
| **MODEM** | `mpss`, `modem` | **5** |
58+
| **MODEM OEM** | `mpss-oempd`, `modem-oempd` | **6** |
59+
60+
## Outputs
61+
* **Console:** Prints `PASS` or `FAIL` with details about the found ID.
62+
* **Result File:** Generates `qrtr-lookup_validation.res` in the current directory containing:
63+
* `qrtr-lookup_validation PASS`
64+
* `qrtr-lookup_validation FAIL`
65+
66+
## LAVA Integration
67+
To include this in a LAVA test definition (`.yaml`), simply call the script multiple times for the subsystems you wish to validate:
68+
69+
\`\`\`yaml
70+
run:
71+
steps:
72+
- chmod +x run.sh
73+
- ./run.sh # Validates ADSP Root (Default)
74+
- ./run.sh -t audio # Validates Audio
75+
- ./run.sh -t cdsp # Validates CDSP
76+
- ./run.sh -t cdsp1 # Validates CDSP1
77+
- ./run.sh -t gpdsp0 # Validates GPDSP0
78+
- ./run.sh -t gpdsp1 # Validates GPDSP1
79+
- ./run.sh -t gpdsp0-user # Validates GPDSP0 User PD
80+
- ./run.sh -t gpdsp1-user # Validates GPDSP1 User PD
81+
- ./run.sh -t mpss # Validates Modem Root
82+
- ./run.sh -t mpss-oempd # Validates Modem OEM PD
83+
\`\`\`
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
metadata:
2+
name: qrtr_lookup_validation
3+
format: "Lava-Test Test Definition 1.0"
4+
description: "Validates existence of QRTR services for various subsystems"
5+
os:
6+
- linux
7+
scope:
8+
- functional
9+
params:
10+
REMOTE_PROC: "adsp"
11+
run:
12+
steps:
13+
- REPO_PATH=$PWD
14+
- cd Runner/suites/Kernel/Baseport/IPC/qrtr_lookup_validation
15+
- ./run.sh -t "$REMOTE_PROC"
16+
- $REPO_PATH/Runner/utils/send-to-lava.sh qrtr_lookup_validation.res
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
#!/bin/sh
2+
# run.sh - Verification for qrtr-lookup service
3+
4+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5+
# SPDX-License-Identifier: BSD-3-Clause
6+
7+
# Robustly find and source init_env
8+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
9+
INIT_ENV=""
10+
SEARCH="$SCRIPT_DIR"
11+
while [ "$SEARCH" != "/" ]; do
12+
if [ -f "$SEARCH/init_env" ]; then
13+
INIT_ENV="$SEARCH/init_env"
14+
break
15+
fi
16+
SEARCH=$(dirname "$SEARCH")
17+
done
18+
19+
if [ -z "$INIT_ENV" ]; then
20+
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
21+
exit 1
22+
fi
23+
24+
# Only source if not already loaded
25+
if [ -z "$__INIT_ENV_LOADED" ]; then
26+
# shellcheck disable=SC1090
27+
. "$INIT_ENV"
28+
export __INIT_ENV_LOADED=1
29+
fi
30+
31+
# Always source functestlib.sh
32+
# shellcheck disable=SC1090,SC1091
33+
. "$TOOLS/functestlib.sh"
34+
35+
TESTNAME="qrtr_lookup_validation"
36+
test_path=$(find_test_case_by_name "$TESTNAME")
37+
cd "$test_path" || exit 1
38+
res_file="./$TESTNAME.res"
39+
40+
log_info "--------------------------------------------------"
41+
log_info "------------- Starting $TESTNAME Test ------------"
42+
43+
check_dependencies qrtr-lookup
44+
45+
# --- Argument Parsing ---
46+
TARGET_NAME=""
47+
INSTANCE_ID=""
48+
49+
while getopts "t:i:" opt; do
50+
case ${opt} in
51+
t) TARGET_NAME=$OPTARG ;;
52+
i) INSTANCE_ID=$OPTARG ;;
53+
\?)
54+
log_fail "Invalid option: -$OPTARG"
55+
echo "$TESTNAME FAIL" > "$res_file"
56+
exit 0
57+
;;
58+
esac
59+
done
60+
61+
# Resolve Target Name to ID if provided
62+
if [ -n "$TARGET_NAME" ]; then
63+
MAPPED_ID=$(get_qrtr_id_from_name "$TARGET_NAME")
64+
if [ -n "$MAPPED_ID" ]; then
65+
INSTANCE_ID=$MAPPED_ID
66+
log_info "Mapped target '$TARGET_NAME' to Instance ID $INSTANCE_ID"
67+
else
68+
log_fail "Unknown target name '$TARGET_NAME'"
69+
echo "$TESTNAME FAIL" > "$res_file"
70+
exit 0
71+
fi
72+
fi
73+
74+
# --- Main Logic ---
75+
76+
if [ -n "$INSTANCE_ID" ]; then
77+
# --- MODE 1: Specific Verification ---
78+
log_info "Verifying specific Instance ID: $INSTANCE_ID"
79+
80+
if qrtr_id_exists "$INSTANCE_ID"; then
81+
scan_dmesg_errors "qrtr" "$PWD"
82+
log_pass "Found service for ID $INSTANCE_ID"
83+
echo "$TESTNAME PASS" > "$res_file"
84+
else
85+
log_fail "Instance ID $INSTANCE_ID not found in qrtr-lookup output."
86+
echo "$TESTNAME FAIL" > "$res_file"
87+
fi
88+
89+
else
90+
# --- MODE 2: Default (Auto-Detect Any) ---
91+
log_info "No specific target provided. Scanning for ANY Test services..."
92+
93+
# Get all lines containing "Test service", extract ID (Col 3)
94+
FOUND_IDS=$(qrtr-lookup | grep "Test service" | awk '{print $3}')
95+
96+
if [ -n "$FOUND_IDS" ]; then
97+
log_info "Found the following active Test Services:"
98+
99+
for id in $FOUND_IDS; do
100+
name=$(get_qrtr_name_from_id "$id")
101+
log_info " - ID $id : $name"
102+
done
103+
104+
# Pass if at least one is found
105+
scan_dmesg_errors "qrtr" "$PWD"
106+
log_pass "Found active qrtr-lookup test services"
107+
echo "$TESTNAME PASS" > "$res_file"
108+
else
109+
log_fail "No 'Test service' lines found in qrtr-lookup output."
110+
echo "$TESTNAME FAIL" > "$res_file"
111+
fi
112+
fi
113+
114+
exit 0

Runner/utils/functestlib.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4558,3 +4558,58 @@ get_pid() {
45584558
log_info "Process '$process_name' not found."
45594559
return 1
45604560
}
4561+
4562+
# Check if a specific Node ID (column 3) exists
4563+
qrtr_id_exists() {
4564+
target=$1
4565+
qrtr-lookup 2>/dev/null | awk -v target="$target" '
4566+
NR > 1 && $3 ~ /^[0-9]+$/ && $3 == target { found = 1; exit }
4567+
END { exit(found ? 0 : 1) }
4568+
'
4569+
}
4570+
4571+
# Map human-readable names to IDs
4572+
get_qrtr_id_from_name() {
4573+
key=$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')
4574+
case "$key" in
4575+
"adsp" | "adsp-root") echo "32" ;;
4576+
"adsp-audiopd" | "audio") echo "33" ;;
4577+
"adsp-sensorpd" | "sensor") echo "34" ;;
4578+
"adsp-chargerpd" | "charger") echo "35" ;;
4579+
"mpss" | "modem") echo "5" ;;
4580+
"mpss-oempd" | "modem-oempd") echo "6" ;;
4581+
"cdsp") echo "64" ;;
4582+
"cdsp1") echo "72" ;;
4583+
"gpdsp0" | "gpdsp0-root") echo "112" ;;
4584+
"gpdsp0-user") echo "113" ;;
4585+
"gpdsp1" | "gpdsp1-root") echo "120" ;;
4586+
"gpdsp1-user") echo "121" ;;
4587+
"soccp") echo "141" ;;
4588+
"dcp") echo "142" ;;
4589+
"wpss") echo "128" ;;
4590+
*) echo "" ;;
4591+
esac
4592+
}
4593+
4594+
# Reverse mapping for display
4595+
get_qrtr_name_from_id() {
4596+
id="$1"
4597+
case "$id" in
4598+
"32") echo "ADSP Root" ;;
4599+
"33") echo "ADSP AudioPD" ;;
4600+
"34") echo "ADSP SensorPD" ;;
4601+
"35") echo "ADSP ChargerPD" ;;
4602+
"5") echo "MPSS Modem" ;;
4603+
"6") echo "MPSS OEMPD" ;;
4604+
"64") echo "CDSP Root" ;;
4605+
"72") echo "CDSP1" ;;
4606+
"112") echo "GPDSP0 Root" ;;
4607+
"113") echo "GPDSP0 User" ;;
4608+
"120") echo "GPDSP1 Root" ;;
4609+
"121") echo "GPDSP1 User" ;;
4610+
"141") echo "SOCCP" ;;
4611+
"142") echo "DCP" ;;
4612+
"128") echo "WPSS" ;;
4613+
*) echo "Unknown Subsystem" ;;
4614+
esac
4615+
}

Runner/utils/lib_gstreamer.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
3-
# SPDX-License-Identifier: BSD-3-Clause#
3+
# SPDX-License-Identifier: BSD-3-Clause
44
# Runner/utils/lib_gstreamer.sh
55
#
66
# GStreamer helpers.

0 commit comments

Comments
 (0)