|
| 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