Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,27 @@ jobs:
exit "$rc"
' sh < "$files_list"

- name: Check for trailing whitespace in .sh files (pull_request)
if: github.event_name == 'pull_request'
env:
BASE_BRANCH: ${{ github.base_ref }}
run: |
set -eu

if [ -z "$BASE_BRANCH" ]; then
echo "BASE_BRANCH is empty"
exit 1
fi

if ! git check-ref-format --branch "$BASE_BRANCH" >/dev/null 2>&1; then
echo "Invalid base branch name: $BASE_BRANCH"
exit 1
fi

git fetch --no-tags origin "+refs/heads/${BASE_BRANCH}:refs/remotes/origin/${BASE_BRANCH}"

MERGE_BASE="$(git merge-base HEAD "refs/remotes/origin/${BASE_BRANCH}")"

git diff --check "${MERGE_BASE}"...HEAD \
&& echo "No trailing whitespace found." \
|| { echo "ERROR: Trailing whitespace or space/tab conflict found!"; exit 1; }
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ fi

if [ -z "$ADAPTER" ]; then
log_warn "No HCI adapter found."

if [ "$FAIL_COUNT" -gt 0 ]; then
echo "$TESTNAME FAIL" > "$RES_FILE"
else
Expand Down
6 changes: 3 additions & 3 deletions Runner/suites/Kernel/Baseport/BWMON/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ initial_votes=$(extract_votes)
log_info "$initial_votes"
log_info "$initial_votes"

log_info "Running bw_mem tool..."
log_info "Running bw_mem tool..."
bw_mem 4000000000 frd &

sleep 2

log_info "Vote check while bw_mem tool is running:"
log_info "Vote check while bw_mem tool is running:"
final_votes=$(extract_votes)
log_info "$final_votes"

Expand All @@ -81,7 +81,7 @@ done

if $incremented; then
log_pass "$TESTNAME : Test Passed"
echo "$TESTNAME PASS" > "$res_file"
echo "$TESTNAME PASS" > "$res_file"
exit 0
else
log_fail "$TESTNAME : Test Failed"
Expand Down
2 changes: 1 addition & 1 deletion Runner/suites/Kernel/Baseport/Buses/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ if echo "$output" | grep -q "Reading"; then
else
log_fail "$TESTNAME : Test Failed"
echo "$TESTNAME FAIL" > "$res_file"
exit 1
exit 1
fi
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ cleanup() {
rm -f "$PROFILE_TMP_LIST" 2>/dev/null
fi
}

trap 'cleanup' EXIT INT TERM

while [ $# -gt 0 ]; do
Expand Down
10 changes: 5 additions & 5 deletions Runner/suites/Kernel/Baseport/Reboot_health_check/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,24 @@ fi
RETRY_COUNT=$(cat "$RETRY_FILE")

log_info "--------------------------------------------"
log_info "Boot Health Check Started - $(date)"
log_info "Boot Health Check Started - $(date)"
log_info "Current Retry Count: $RETRY_COUNT"

# Health Check: You can expand this check
if [ "$(whoami)" = "root" ]; then
log_pass "System booted successfully and root shell obtained."
log_info "Test Completed Successfully after $RETRY_COUNT retries."

# Optional: clean retry counter after success
echo "0" > "$RETRY_FILE"

exit 0
else
log_fail "Root shell not available!"

RETRY_COUNT=$((RETRY_COUNT + 1))
echo "$RETRY_COUNT" > "$RETRY_FILE"

if [ "$RETRY_COUNT" -ge "$MAX_RETRIES" ]; then
log_error "[ERROR] Maximum retries ($MAX_RETRIES) reached. Stopping test."
exit 1
Expand Down
2 changes: 1 addition & 1 deletion Runner/suites/Kernel/Baseport/Timer/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Options:

Example:
$0 --binary-path=/custom/path/posix_timers
$0
$0

EOF
}
Expand Down
10 changes: 5 additions & 5 deletions Runner/suites/Kernel/Baseport/UserDataEncryption/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ cleanup() {
else
log_info "removed key $key_id from $FS_PATH"
fi
fi
fi



if [ -n "${KEY_FILE:-}" ]; then
if ! rm -f "$KEY_FILE" 2>/dev/null; then
log_warn "Failed to remove key file: $KEY_FILE"
fi
fi
fi

scan_dmesg_errors "$test_path" "fscrypt" ""
}
Expand Down Expand Up @@ -218,7 +218,7 @@ fi
log_info "Key ID: $key_id"

# Step 4: Check key status
log_info "Checking key status"
log_info "Checking key status"
status=$("$FSCRYPTCTL" key_status "$key_id" "$FS_PATH" 2>&1)
rc=$?

Expand Down Expand Up @@ -256,7 +256,7 @@ rc=$?
if [ "$rc" -ne 0 ] || [ -z "${policy_output:-}" ]; then
log_fail "fscryptctl get_policy failed for $MOUNT_DIR: $policy_output"
echo "$TESTNAME FAIL" > "$res_file"
exit 0
exit 0
fi

not_encrypted=$(echo "$policy_output" | awk '/file or directory not encrypted/ {print 1}')
Expand Down
16 changes: 8 additions & 8 deletions Runner/suites/Kernel/Baseport/etm_trace/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ res_file="./$TESTNAME.res"
log_info "-----------------------------------------------------------------------------------------"
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
log_info "=== Test Initialization ==="

pass=true

# Step 1: Check required kernel config
required_configs="CONFIG_CORESIGHT_SOURCE_ETM4X"
check_kernel_config "$required_configs" || {
log_skip "$TESTNAME : Required kernel config missing"
echo "$TESTNAME SKIP" > "$res_file"
exit 0
}

# Step 2: Enable CoreSight sink
log_info "Enabling CoreSight sink (tmc_etr0)..."
echo 1 > /sys/bus/coresight/devices/tmc_etr0/enable_sink
Expand All @@ -57,7 +57,7 @@ else
log_fail "Failed to enable sink."
pass=false
fi

# Step 3: Enable CoreSight source
log_info "Enabling CoreSight source (etm0)..."
echo 1 > /sys/bus/coresight/devices/etm0/enable_source
Expand All @@ -67,7 +67,7 @@ else
log_fail "Failed to enable source."
pass=false
fi

# Step 4: Capture trace data
TRACE_FILE="/tmp/qdss.bin"
log_info "Capturing trace data to $TRACE_FILE..."
Expand All @@ -77,15 +77,15 @@ else
log_fail "Failed to capture trace data."
pass=false
fi

# Step 5: Validate trace output
if [ -s "$TRACE_FILE" ]; then
log_info "Trace file is not empty."
else
log_fail "Trace file is empty."
pass=false
fi

# Final result and cleanup
if $pass; then
log_pass "$TESTNAME : Test Passed"
Expand All @@ -100,5 +100,5 @@ else
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
exit 1
fi


2 changes: 1 addition & 1 deletion Runner/suites/Kernel/Baseport/irq/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ case "$IRQ_SKIP_ISOLATED" in
esac

deps_list="awk sed grep tr sleep taskset"

log_info "Checking dependencies: $deps_list"
if ! check_dependencies "$deps_list"; then
log_skip "$TESTNAME SKIP - missing one or more dependencies: $deps_list"
Expand Down
8 changes: 4 additions & 4 deletions Runner/suites/Kernel/Baseport/smmu/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ fi

TESTNAME="smmu"
test_path="$(find_test_case_by_name "$TESTNAME")"

if [ -z "$test_path" ] || [ ! -d "$test_path" ]; then
log_fail "$TESTNAME, test directory not found"
exit 1
fi

cd "$test_path" || exit 1
res_file="./$TESTNAME.res"
rm -f "$res_file"
Expand Down Expand Up @@ -80,13 +80,13 @@ else
fi

log_info "Checking IOMMU groups path"

if ! wait_for_path "/sys/kernel/iommu_groups" 3; then
log_fail "/sys/kernel/iommu_groups is not present"
echo "$TESTNAME FAIL" > "$res_file"
exit 0
fi

log_pass "/sys/kernel/iommu_groups is present"

group_count="$(find /sys/kernel/iommu_groups -mindepth 1 -maxdepth 1 -type d 2>/dev/null | wc -l | awk '{print $1}')"
Expand Down
39 changes: 19 additions & 20 deletions Runner/suites/Kernel/Baseport/stm_cpu/run.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause
# SPDX-License-Identifier: BSD-3-Clause
# Robustly find and source init_env
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
INIT_ENV=""
Expand All @@ -13,30 +13,30 @@ while [ "$SEARCH" != "/" ]; do
fi
SEARCH=$(dirname "$SEARCH")
done

if [ -z "$INIT_ENV" ]; then
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
exit 1
fi

# Only source if not already loaded (idempotent)
if [ -z "$__INIT_ENV_LOADED" ]; then
# shellcheck disable=SC1090
. "$INIT_ENV"
fi

# shellcheck disable=SC1090,SC1091
. "$TOOLS/functestlib.sh"

TESTNAME="stm_cpu"
test_path=$(find_test_case_by_name "$TESTNAME")
cd "$test_path" || exit 1
res_file="./$TESTNAME.res"

log_info "-----------------------------------------------------------------------------------------"
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
log_info "=== Test Initialization ==="

# Step 1: Check required kernel configs individually
CONFIGS="CONFIG_STM_PROTO_BASIC CONFIG_STM_PROTO_SYS_T CONFIG_STM_DUMMY CONFIG_STM_SOURCE_CONSOLE CONFIG_STM_SOURCE_HEARTBEAT"
for cfg in $CONFIGS; do
Expand All @@ -47,7 +47,7 @@ for cfg in $CONFIGS; do
exit 1
fi
done

# Step 2: Mount configfs if not mounted
if ! mountpoint -q /sys/kernel/config 2>/dev/null && [ -z "$(ls /sys/kernel/config 2>/dev/null)" ]; then
mount -t configfs configfs /sys/kernel/config || {
Expand All @@ -56,14 +56,14 @@ if ! mountpoint -q /sys/kernel/config 2>/dev/null && [ -z "$(ls /sys/kernel/conf
exit 0
}
fi

# Step 3: Create STM policy directories
mkdir -p /sys/kernel/config/stp-policy/stm0_basic.policy/default || {
log_skip "$TESTNAME : Failed to create STM policy directories"
echo "$TESTNAME SKIP" > "$res_file"
exit 0
}

# Step 4: Enable ETF sink only if not already enabled
if [ "$(cat /sys/bus/coresight/devices/tmc_etf0/enable_sink)" != "1" ]; then
echo 1 > /sys/bus/coresight/devices/tmc_etf0/enable_sink || {
Expand All @@ -72,7 +72,7 @@ if [ "$(cat /sys/bus/coresight/devices/tmc_etf0/enable_sink)" != "1" ]; then
exit 0
}
fi

# Step 5: Load STM modules
for mod in stm_heartbeat stm_console stm_ftrace; do
mod_path=$(find_kernel_module "$mod")
Expand All @@ -82,10 +82,10 @@ for mod in stm_heartbeat stm_console stm_ftrace; do
exit 0
}
done

# Step 6: Link STM source to ftrace
echo stm0 > /sys/class/stm_source/ftrace/stm_source_link

# Step 7: Mount debugfs if not mounted
if ! mountpoint -q /sys/kernel/debug 2>/dev/null && [ -z "$(ls /sys/kernel/debug 2>/dev/null)" ]; then
mount -t debugfs nodev /sys/kernel/debug || {
Expand All @@ -94,24 +94,24 @@ if ! mountpoint -q /sys/kernel/debug 2>/dev/null && [ -z "$(ls /sys/kernel/debug
exit 0
}
fi

# Step 8: Enable tracing
echo 1 > /sys/kernel/debug/tracing/tracing_on
echo 1 > /sys/kernel/debug/tracing/events/sched/sched_switch/enable
echo 1 > /sys/bus/coresight/devices/stm0/enable_source

# Step 9: Capture trace output
trace_output="/tmp/qdss_etf_stm.bin"
rm -f "$trace_output"

if [ ! -e /dev/tmc_etf0 ]; then
log_skip "$TESTNAME : Trace device /dev/tmc_etf0 not found"
echo "$TESTNAME SKIP" > "$res_file"
exit 0
fi

cat /dev/tmc_etf0 > "$trace_output"

# Step 10: Validate trace output is not empty
if [ -s "$trace_output" ]; then
log_pass "$TESTNAME : Trace captured successfully"
Expand All @@ -126,4 +126,3 @@ else
log_info "------------------- Completed $TESTNAME Testcase ----------------------------"
exit 1
fi

Loading