|
| 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 | + |
| 29 | +# Always source functestlib.sh, using $TOOLS exported by init_env |
| 30 | +# shellcheck disable=SC1090,SC1091 |
| 31 | +. "$TOOLS/functestlib.sh" |
| 32 | + |
| 33 | +TESTNAME="gdsp_remoteproc" |
| 34 | +test_path=$(find_test_case_by_name "$TESTNAME") |
| 35 | +cd "$test_path" || exit 1 |
| 36 | +res_file="./$TESTNAME.res" |
| 37 | + |
| 38 | +log_info "-----------------------------------------------------------------------------------------" |
| 39 | +log_info "-------------------Starting $TESTNAME Testcase----------------------------" |
| 40 | +log_info "=== Test Initialization ===" |
| 41 | + |
| 42 | +# Loop through all remoteproc firmware entries to find gpdsp0 and gpdsp1 |
| 43 | +for gdsp_firmware in gpdsp0 gpdsp1; do |
| 44 | + for fw_path in /sys/class/remoteproc/remoteproc*/firmware; do |
| 45 | + if grep -q "$gdsp_firmware" "$fw_path"; then |
| 46 | + remoteproc_path=$(dirname "$fw_path") |
| 47 | + log_info "Found $gdsp_firmware at $remoteproc_path" |
| 48 | + |
| 49 | + state1=$(cat "$remoteproc_path/state") |
| 50 | + if [ "$state1" != "running" ]; then |
| 51 | + log_fail "$gdsp_firmware not running initially" |
| 52 | + echo "$TESTNAME FAIL" > "$res_file" |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | + |
| 56 | + echo stop > "$remoteproc_path/state" |
| 57 | + state2=$(cat "$remoteproc_path/state") |
| 58 | + if [ "$state2" != "offline" ]; then |
| 59 | + log_fail "$gdsp_firmware stop failed" |
| 60 | + echo "$TESTNAME FAIL" > "$res_file" |
| 61 | + exit 1 |
| 62 | + else |
| 63 | + log_pass "$gdsp_firmware stop successful" |
| 64 | + fi |
| 65 | + |
| 66 | + log_info "Restarting $gdsp_firmware" |
| 67 | + echo start > "$remoteproc_path/state" |
| 68 | + state3=$(cat "$remoteproc_path/state") |
| 69 | + if [ "$state3" != "running" ]; then |
| 70 | + log_fail "$gdsp_firmware start failed" |
| 71 | + echo "$TESTNAME FAIL" > "$res_file" |
| 72 | + exit 1 |
| 73 | + fi |
| 74 | + |
| 75 | + log_pass "$gdsp_firmware PASS" |
| 76 | + fi |
| 77 | + done |
| 78 | +done |
| 79 | + |
| 80 | +echo "$TESTNAME PASS" > "$res_file" |
| 81 | +log_info "-------------------Completed $TESTNAME Testcase----------------------------" |
| 82 | +exit 0 |
0 commit comments