From 52041ad2c6096799c694282bc0dbed475ff9dcf7 Mon Sep 17 00:00:00 2001 From: Vamsee Narapareddi Date: Wed, 28 May 2025 09:41:53 +0530 Subject: [PATCH 1/4] Added check_kernel_config in functestlib This commit is to add check_kernel_config function in common functions This function will check if the corresponding configs are enabled in /proc/config.gz Added check_driver_loaded to check if any driver is loaded. Added check_dt_nodes to check if DT nodes are present Signed-off-by: Vamsee Narapareddi --- Runner/utils/functestlib.sh | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/Runner/utils/functestlib.sh b/Runner/utils/functestlib.sh index 2ae67037..1e90a13c 100755 --- a/Runner/utils/functestlib.sh +++ b/Runner/utils/functestlib.sh @@ -49,6 +49,56 @@ find_test_case_script_by_name() { find "$base_dir" -type d -iname "$test_name" -print -quit 2>/dev/null } +check_kernel_config() { + configs="$1" + for config_key in $configs; do + if zcat /proc/config.gz | grep -qE "^$config_key=(y|m)"; then + log_pass "Kernel config $config_key is enabled" + else + log_fail "Kernel config $config_key is missing or not enabled" + return 1 + fi + done + return 0 +} + +check_dt_nodes() { + node_paths="$1" + log_info "$node_paths" + found=false + for node in $node_paths; do + log_info "$node" + if [ -d "$node" ] || [ -f "$node" ]; then + log_pass "Device tree node exists: $node" + found=true + fi + done + + if [ "$found" = true ]; then + return 0 + else + log_fail "Device tree node(s) missing: $node_paths" + return 1 + fi +} + +check_driver_loaded() { + drivers="$1" + for driver in $drivers; do + if [ -z "$driver" ]; then + log_fail "No driver/module name provided to check_driver_loaded" + return 1 + fi + if grep -qw "$driver" /proc/modules || lsmod | awk '{print $1}' | grep -qw "$driver"; then + log_pass "Driver/module '$driver' is loaded" + return 0 + else + log_fail "Driver/module '$driver' is not loaded" + return 1 + fi + done +} + # --- Optional: POSIX-safe repo root detector --- detect_runner_root() { path=$1 From 4caff2be1667b0038c9b9b8f4bb9480074994eca Mon Sep 17 00:00:00 2001 From: Vamsee Narapareddi Date: Mon, 26 May 2025 09:58:20 +0530 Subject: [PATCH 2/4] Added DCVS testcase This testcase vaildates configs like CONFIG_CPU_FREQ CONFIG_CPU_FREQ_GOV_SCHEDUTIL CONFIG_CPU_FREQ_GOV_PERFORMANCE and checks cpu frequencies` before and after a load is applied Signed-off-by: Vamsee Narapareddi --- .../DCVS/Freq_Scaling/README.md | 37 +++++++ .../FunctionalArea/DCVS/Freq_Scaling/run.sh | 97 +++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 Runner/suites/Kernel/FunctionalArea/DCVS/Freq_Scaling/README.md create mode 100755 Runner/suites/Kernel/FunctionalArea/DCVS/Freq_Scaling/run.sh diff --git a/Runner/suites/Kernel/FunctionalArea/DCVS/Freq_Scaling/README.md b/Runner/suites/Kernel/FunctionalArea/DCVS/Freq_Scaling/README.md new file mode 100644 index 00000000..eeb57119 --- /dev/null +++ b/Runner/suites/Kernel/FunctionalArea/DCVS/Freq_Scaling/README.md @@ -0,0 +1,37 @@ +# DCVS Frequency Scaling Validation Test + +This test validates the DCVS support and runtime status on Qualcomm platforms with Yocto builds. + +## Overview + +The test script performs these functional checks: + +1. **Kernel Configuration**: + - Validates presence of `CONFIG_CPU_FREQ`, `CONFIG_CPU_FREQ_GOV_PERFORMANCE` and `CONFIG_CPU_FREQ_GOV_SCHEDUTIL*` entries in `/proc/config.gz`. + +2. **Runtime Verification**: + - Checks `/sys/devices/system/cpu/cpu0/cpufreq` before and after a load is applied. + +## How to Run + +```sh +source init_env +cd suites/Kernel/FunctionalArea/DCVS/Freq_Scaling +./run.sh +``` + +## Prerequisites + +- `dmesg`, `grep`, `zgrep`, `lsmod` must be available +- Root access may be required for complete validation + +## Result Format + +Test result will be saved in `Freq_Scaling.res` as: +- `DCVS scaling appears functional. Test Passed` – if all validations pass +- `DCVS did not scale as expected. Test Failed` – if any check fails + +## License + +SPDX-License-Identifier: BSD-3-Clause-Clear +(C) Qualcomm Technologies, Inc. and/or its subsidiaries. diff --git a/Runner/suites/Kernel/FunctionalArea/DCVS/Freq_Scaling/run.sh b/Runner/suites/Kernel/FunctionalArea/DCVS/Freq_Scaling/run.sh new file mode 100755 index 00000000..ed10c1a8 --- /dev/null +++ b/Runner/suites/Kernel/FunctionalArea/DCVS/Freq_Scaling/run.sh @@ -0,0 +1,97 @@ +#!/bin/sh +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear + +# Robustly find and source init_env +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + 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 +# Always source functestlib.sh, using $TOOLS exported by init_env +# shellcheck disable=SC1090,SC1091 +. "$TOOLS/functestlib.sh" + +TESTNAME="Freq_Scaling" +test_path=$(find_test_case_by_name "$TESTNAME") +cd "$test_path" || exit 1 +# shellcheck disable=SC2034 +res_file="./$TESTNAME.res" + +log_info "-------------------------------------------------" +log_info "----------- Starting $TESTNAME Test -------------" + +check_dependencies zcat grep + +CONFIGS="CONFIG_CPU_FREQ CONFIG_CPU_FREQ_GOV_SCHEDUTIL CONFIG_CPU_FREQ_GOV_PERFORMANCE" +check_kernel_config "$CONFIGS" || { + log_fail "Kernel config validation failed." + echo "$TESTNAME FAIL" > "$res_file" + exit 1 +} + +CPUFREQ_BASE_PATH="/sys/devices/system/cpu" +i=0 + +miss=0 + +for cpu_dir in /sys/devices/system/cpu/cpu[0-8]*; do + CPUFREQ_PATH="$cpu_dir/cpufreq" + if [ -d "$CPUFREQ_PATH" ]; then + cpu_name="${cpu_dir##*/}" + log_pass "$cpu_name has cpufreq interface" + else + miss=1 + fi +done + +if [ "$miss" -eq 1 ]; then + echo "CPUFreq interface not found. Test Failed" + echo "$TESTNAME FAIL" > "$res_file" + exit 1 +fi + +log_info "Reading scaling governor..." +GOVERNOR=$(cat $CPUFREQ_PATH/scaling_governor) +log_info "Current governor: $GOVERNOR" + +log_info "Reading min/max frequencies" +MIN_FREQ=$(cat $CPUFREQ_PATH/cpuinfo_min_freq) +MAX_FREQ=$(cat $CPUFREQ_PATH/cpuinfo_max_freq) +log_info "CPU frequency range: $MIN_FREQ - $MAX_FREQ" + +log_info "Triggering frequency update via governor" +dd if=/dev/urandom of=/dev/null bs=1M count=1000 & +LOAD_PID=$! +sleep 2 + +CURRENT_FREQ=$(cat $CPUFREQ_PATH/scaling_cur_freq) +log_info "Observed frequency under load: $CURRENT_FREQ" + +kill $LOAD_PID + +if [ "$CURRENT_FREQ" -gt "$MIN_FREQ" ]; then + log_pass "DCVS scaling appears functional. Test Passed" + echo "$TESTNAME PASS" > "$res_file" +else + log_fail "DCVS did not scale as expected. Test Failed" + echo "$TESTNAME FAIL" > "$res_file" +fi + +log_info "----------- Completed $TESTNAME Test ------------" From 7c6317ca50e7d52651fdadd0c5029748535cf852 Mon Sep 17 00:00:00 2001 From: Vamsee Narapareddi Date: Mon, 26 May 2025 10:11:16 +0530 Subject: [PATCH 3/4] Added Scheduler testcase This test validates the Scheduler support by checking corresponding SCHED configs and checks cpu affinity by creating a CPU-bound background task Signed-off-by: Vamsee Narapareddi --- .../Scheduler/CPU_affinity/README.md | 37 ++++++++ .../Scheduler/CPU_affinity/run.sh | 93 +++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 Runner/suites/Kernel/FunctionalArea/Scheduler/CPU_affinity/README.md create mode 100755 Runner/suites/Kernel/FunctionalArea/Scheduler/CPU_affinity/run.sh diff --git a/Runner/suites/Kernel/FunctionalArea/Scheduler/CPU_affinity/README.md b/Runner/suites/Kernel/FunctionalArea/Scheduler/CPU_affinity/README.md new file mode 100644 index 00000000..40bd9049 --- /dev/null +++ b/Runner/suites/Kernel/FunctionalArea/Scheduler/CPU_affinity/README.md @@ -0,0 +1,37 @@ +# Scheduler CPU Affinity validation Test + +This test validates the Scheduler support and runtime status on Qualcomm platforms with Yocto builds. + +## Overview + +The test script performs these functional checks: + +1. **Kernel Configuration**: + - Validates presence of `CONFIG_SCHED_DEBUG`, `CONFIG_CGROUP_SCHED` and `CONFIG_SMP*` entries in `/proc/config.gz`. + +2. **Runtime Verification**: + - Checks cpu affinity by creating a CPU-bound background task + +## How to Run + +```sh +source init_env +cd suites/Kernel/FunctionalArea/Scheduler/CPU_affinity +./run.sh +``` + +## Prerequisites + +- `taskset`, `grep`, `zgrep`, `top`, `chrt` must be available +- Root access may be required for complete validation + +## Result Format + +Test result will be saved in `CPU_affinity.res` as: +- `Default scheduling policy detected. Test passed` – if all validations pass +- `Unexpected scheduling policy. Test Failed` – if any check fails + +## License + +SPDX-License-Identifier: BSD-3-Clause-Clear +(C) Qualcomm Technologies, Inc. and/or its subsidiaries. diff --git a/Runner/suites/Kernel/FunctionalArea/Scheduler/CPU_affinity/run.sh b/Runner/suites/Kernel/FunctionalArea/Scheduler/CPU_affinity/run.sh new file mode 100755 index 00000000..22308ced --- /dev/null +++ b/Runner/suites/Kernel/FunctionalArea/Scheduler/CPU_affinity/run.sh @@ -0,0 +1,93 @@ +#!/bin/sh +# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +# SPDX-License-Identifier: BSD-3-Clause-Clear + +# Robustly find and source init_env +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +INIT_ENV="" +SEARCH="$SCRIPT_DIR" +while [ "$SEARCH" != "/" ]; do + if [ -f "$SEARCH/init_env" ]; then + INIT_ENV="$SEARCH/init_env" + break + 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 +# Always source functestlib.sh, using $TOOLS exported by init_env +# shellcheck disable=SC1090,SC1091 +. "$TOOLS/functestlib.sh" + +TESTNAME="CPU_affinity" +test_path=$(find_test_case_by_name "$TESTNAME") +cd "$test_path" || exit 1 +# shellcheck disable=SC2034 +res_file="./$TESTNAME.res" + +log_info "----------------------------------------------------" +log_info "-------- Starting $TESTNAME Functional Test --------" + +check_dependencies taskset top chrt zcat grep + +REQUIRED_CONFIGS="CONFIG_SCHED_DEBUG CONFIG_CGROUP_SCHED CONFIG_SMP" +for config in $REQUIRED_CONFIGS; do + if check_kernel_config "$config"; then + log_pass "$config is enabled" + echo "$TESTNAME PASS" > "$res_file" + else + log_fail "$config is missing" + echo "$TESTNAME FAIL" > "$res_file" + exit 1 + fi +done + +log_info "Creating a CPU-bound background task..." +cpu_task() { + while true; do :; done +} +cpu_task & +TASK_PID=$! +sleep 2 + +log_info "Checking CPU affinity of task $TASK_PID..." +CPU_AFFINITY=$(taskset -p $TASK_PID | awk -F: '{print $2}' | xargs) +log_info "CPU affinity: $CPU_AFFINITY" + +log_info "Setting affinity to CPU 0" +taskset -pc 0 $TASK_PID > /dev/null +sleep 1 + +NEW_AFFINITY=$(taskset -p $TASK_PID | awk -F: '{print $2}' | xargs) +if [ "$NEW_AFFINITY" = "1" ]; then + log_pass "Successfully set CPU affinity" + echo "$TESTNAME PASS" > "$res_file" +else + log_fail "Failed to set CPU affinity" + echo "$TESTNAME FAIL" > "$res_file" +fi + +log_info "Checking scheduling policy of task..." +SCHED_POLICY=$(chrt -p $TASK_PID | grep "scheduling policy" | awk -F: '{print $2}' | xargs) +log_info "Scheduling Policy: $SCHED_POLICY" + +if echo "$SCHED_POLICY" | grep -q "SCHED_OTHER"; then + log_pass "Default scheduling policy detected. Test passed" + echo "$TESTNAME PASS" > "$res_file" +else + log_fail "Unexpected scheduling policy. Test Failed" + echo "$TESTNAME FAIL" > "$res_file" +fi + +kill $TASK_PID +echo "$TESTNAME PASS" > $test_path/$TESTNAME.res +log_info "-------- Completed $TESTNAME Functional Test --------" From 7a491eb273b4f15dccb233bbe81b18e3730fed33 Mon Sep 17 00:00:00 2001 From: Vamsee Narapareddi Date: Mon, 26 May 2025 10:13:17 +0530 Subject: [PATCH 4/4] Modified iommu testcase and readme This test validates the IOMMU (Input-Output Memory Management Unit) support by checking IOMMU configs and checks if the corresponding drivers are loaded instead of just checking the dmesg logs. Signed-off-by: Vamsee Narapareddi --- .../FunctionalArea/baseport/iommu/README.md | 43 +++++++++++++++++++ .../FunctionalArea/baseport/iommu/run.sh | 41 ++++++++++++++++-- 2 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 Runner/suites/Kernel/FunctionalArea/baseport/iommu/README.md diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/iommu/README.md b/Runner/suites/Kernel/FunctionalArea/baseport/iommu/README.md new file mode 100644 index 00000000..6807c595 --- /dev/null +++ b/Runner/suites/Kernel/FunctionalArea/baseport/iommu/README.md @@ -0,0 +1,43 @@ +# IOMMU Validation Test + +This test validates the IOMMU (Input-Output Memory Management Unit) support and runtime status on Qualcomm platforms with Yocto builds. + +## Overview + +The test script performs these functional checks: + +1. **Kernel Configuration**: + - Validates presence of `CONFIG_IOMMU_SUPPORT` and `CONFIG_ARM_SMMU*` entries in `/proc/config.gz`. + +2. **Driver Loading**: + - Confirms SMMU/IOMMU-related drivers are loaded via `/proc/modules`. + +3. **Device Tree Nodes**: + - Verifies IOMMU/SMMU-related nodes in `/proc/device-tree`. + +4. **Runtime Verification**: + - Checks `dmesg` for any runtime IOMMU initialization or fault logs. + +## How to Run + +```sh +source init_env +cd suites/Kernel/FunctionalArea/IOMMU_Validation +./run.sh +``` + +## Prerequisites + +- `dmesg`, `grep`, `zgrep`, `lsmod` must be available +- Root access may be required for complete validation + +## Result Format + +Test result will be saved in `IOMMU.res` as: +- `IOMMU PASS` – if all validations pass +- `IOMMU FAIL` – if any check fails + +## License + +SPDX-License-Identifier: BSD-3-Clause-Clear +(C) Qualcomm Technologies, Inc. and/or its subsidiaries. diff --git a/Runner/suites/Kernel/FunctionalArea/baseport/iommu/run.sh b/Runner/suites/Kernel/FunctionalArea/baseport/iommu/run.sh index 855e6bb4..e211a06f 100755 --- a/Runner/suites/Kernel/FunctionalArea/baseport/iommu/run.sh +++ b/Runner/suites/Kernel/FunctionalArea/baseport/iommu/run.sh @@ -39,15 +39,48 @@ log_info "---------------------------------------------------------------------- log_info "-------------------Starting $TESTNAME Testcase----------------------------" log_info "=== Test Initialization ===" -# Run the command and capture the output -OUTPUT=$(dmesg | grep iommu) +check_runtime_behavior() { + if dmesg | grep -i -q "msm_iommu.*enabled"; then + log_info "Runtime logs show Qualcomm MSM IOMMU is active" + elif dmesg | grep -i -q "iommu.*enabled"; then + log_info "Runtime logs show IOMMU is active" + else + log_fail "No runtime indication of IOMMU being active" + return 1 + fi + return 0 +} + +pass=true + +CONFIGS="CONFIG_IOMMU_SUPPORT CONFIG_QCOM_IOMMU CONFIG_ARM_SMMU" +check_kernel_config "$CONFIGS" || { + log_fail "Kernel config validation failed." + echo "$TESTNAME FAIL" > "$res_file" + exit 1 +} +LOADED_MODULES="msm_iommu arm_smmu" +check_driver_loaded "$LOADED_MODULES" || { + log_fail "Failed to load required driver modules" + echo "$TESTNAME FAIL" > "$res_file" + exit 1 +} + +DT_NODES="/proc/device-tree/soc@0/iommu@15000000 /proc/device-tree/soc/iommu@15000000" +check_dt_nodes "$DT_NODES" || { + log_fail "Device tree validation failed." + echo "$TESTNAME FAIL" > "$res_file" + exit 1 +} + +check_runtime_behavior || pass=false -# Check if the output is null -if [ -z "$OUTPUT" ]; then +if $pass; then log_pass "$TESTNAME : Test Passed" echo "$TESTNAME PASS" > "$res_file" else log_fail "$TESTNAME : Test Failed" echo "$TESTNAME FAIL" > "$res_file" fi + log_info "-------------------Completed $TESTNAME Testcase----------------------------"