Skip to content

Added Kernel Level testcases #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 4, 2025
Merged
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
37 changes: 37 additions & 0 deletions Runner/suites/Kernel/FunctionalArea/DCVS/Freq_Scaling/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# DCVS Frequency Scaling Validation Test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test name is wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated test name

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.
97 changes: 97 additions & 0 deletions Runner/suites/Kernel/FunctionalArea/DCVS/Freq_Scaling/run.sh
Original file line number Diff line number Diff line change
@@ -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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add checks similar to IOMMU test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the required checks

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 ------------"
Original file line number Diff line number Diff line change
@@ -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.
93 changes: 93 additions & 0 deletions Runner/suites/Kernel/FunctionalArea/Scheduler/CPU_affinity/run.sh
Original file line number Diff line number Diff line change
@@ -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 --------"
43 changes: 43 additions & 0 deletions Runner/suites/Kernel/FunctionalArea/baseport/iommu/README.md
Original file line number Diff line number Diff line change
@@ -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.
41 changes: 37 additions & 4 deletions Runner/suites/Kernel/FunctionalArea/baseport/iommu/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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----------------------------"
Loading
Loading