Skip to content

Commit e39ea74

Browse files
authored
Merge pull request #48 from vnarapar/main
Added Kernel Level testcases
2 parents c599df0 + 7a491eb commit e39ea74

File tree

7 files changed

+394
-4
lines changed

7 files changed

+394
-4
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# DCVS Frequency Scaling Validation Test
2+
3+
This test validates the DCVS support and runtime status on Qualcomm platforms with Yocto builds.
4+
5+
## Overview
6+
7+
The test script performs these functional checks:
8+
9+
1. **Kernel Configuration**:
10+
- Validates presence of `CONFIG_CPU_FREQ`, `CONFIG_CPU_FREQ_GOV_PERFORMANCE` and `CONFIG_CPU_FREQ_GOV_SCHEDUTIL*` entries in `/proc/config.gz`.
11+
12+
2. **Runtime Verification**:
13+
- Checks `/sys/devices/system/cpu/cpu0/cpufreq` before and after a load is applied.
14+
15+
## How to Run
16+
17+
```sh
18+
source init_env
19+
cd suites/Kernel/FunctionalArea/DCVS/Freq_Scaling
20+
./run.sh
21+
```
22+
23+
## Prerequisites
24+
25+
- `dmesg`, `grep`, `zgrep`, `lsmod` must be available
26+
- Root access may be required for complete validation
27+
28+
## Result Format
29+
30+
Test result will be saved in `Freq_Scaling.res` as:
31+
- `DCVS scaling appears functional. Test Passed` – if all validations pass
32+
- `DCVS did not scale as expected. Test Failed` – if any check fails
33+
34+
## License
35+
36+
SPDX-License-Identifier: BSD-3-Clause-Clear
37+
(C) Qualcomm Technologies, Inc. and/or its subsidiaries.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/sh
2+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
3+
# SPDX-License-Identifier: BSD-3-Clause-Clear
4+
5+
# Robustly find and source init_env
6+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
7+
INIT_ENV=""
8+
SEARCH="$SCRIPT_DIR"
9+
while [ "$SEARCH" != "/" ]; do
10+
if [ -f "$SEARCH/init_env" ]; then
11+
INIT_ENV="$SEARCH/init_env"
12+
break
13+
fi
14+
SEARCH=$(dirname "$SEARCH")
15+
done
16+
17+
if [ -z "$INIT_ENV" ]; then
18+
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
19+
exit 1
20+
fi
21+
22+
# Only source if not already loaded (idempotent)
23+
if [ -z "$__INIT_ENV_LOADED" ]; then
24+
# shellcheck disable=SC1090
25+
. "$INIT_ENV"
26+
fi
27+
# Always source functestlib.sh, using $TOOLS exported by init_env
28+
# shellcheck disable=SC1090,SC1091
29+
. "$TOOLS/functestlib.sh"
30+
31+
TESTNAME="Freq_Scaling"
32+
test_path=$(find_test_case_by_name "$TESTNAME")
33+
cd "$test_path" || exit 1
34+
# shellcheck disable=SC2034
35+
res_file="./$TESTNAME.res"
36+
37+
log_info "-------------------------------------------------"
38+
log_info "----------- Starting $TESTNAME Test -------------"
39+
40+
check_dependencies zcat grep
41+
42+
CONFIGS="CONFIG_CPU_FREQ CONFIG_CPU_FREQ_GOV_SCHEDUTIL CONFIG_CPU_FREQ_GOV_PERFORMANCE"
43+
check_kernel_config "$CONFIGS" || {
44+
log_fail "Kernel config validation failed."
45+
echo "$TESTNAME FAIL" > "$res_file"
46+
exit 1
47+
}
48+
49+
CPUFREQ_BASE_PATH="/sys/devices/system/cpu"
50+
i=0
51+
52+
miss=0
53+
54+
for cpu_dir in /sys/devices/system/cpu/cpu[0-8]*; do
55+
CPUFREQ_PATH="$cpu_dir/cpufreq"
56+
if [ -d "$CPUFREQ_PATH" ]; then
57+
cpu_name="${cpu_dir##*/}"
58+
log_pass "$cpu_name has cpufreq interface"
59+
else
60+
miss=1
61+
fi
62+
done
63+
64+
if [ "$miss" -eq 1 ]; then
65+
echo "CPUFreq interface not found. Test Failed"
66+
echo "$TESTNAME FAIL" > "$res_file"
67+
exit 1
68+
fi
69+
70+
log_info "Reading scaling governor..."
71+
GOVERNOR=$(cat $CPUFREQ_PATH/scaling_governor)
72+
log_info "Current governor: $GOVERNOR"
73+
74+
log_info "Reading min/max frequencies"
75+
MIN_FREQ=$(cat $CPUFREQ_PATH/cpuinfo_min_freq)
76+
MAX_FREQ=$(cat $CPUFREQ_PATH/cpuinfo_max_freq)
77+
log_info "CPU frequency range: $MIN_FREQ - $MAX_FREQ"
78+
79+
log_info "Triggering frequency update via governor"
80+
dd if=/dev/urandom of=/dev/null bs=1M count=1000 &
81+
LOAD_PID=$!
82+
sleep 2
83+
84+
CURRENT_FREQ=$(cat $CPUFREQ_PATH/scaling_cur_freq)
85+
log_info "Observed frequency under load: $CURRENT_FREQ"
86+
87+
kill $LOAD_PID
88+
89+
if [ "$CURRENT_FREQ" -gt "$MIN_FREQ" ]; then
90+
log_pass "DCVS scaling appears functional. Test Passed"
91+
echo "$TESTNAME PASS" > "$res_file"
92+
else
93+
log_fail "DCVS did not scale as expected. Test Failed"
94+
echo "$TESTNAME FAIL" > "$res_file"
95+
fi
96+
97+
log_info "----------- Completed $TESTNAME Test ------------"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Scheduler CPU Affinity validation Test
2+
3+
This test validates the Scheduler support and runtime status on Qualcomm platforms with Yocto builds.
4+
5+
## Overview
6+
7+
The test script performs these functional checks:
8+
9+
1. **Kernel Configuration**:
10+
- Validates presence of `CONFIG_SCHED_DEBUG`, `CONFIG_CGROUP_SCHED` and `CONFIG_SMP*` entries in `/proc/config.gz`.
11+
12+
2. **Runtime Verification**:
13+
- Checks cpu affinity by creating a CPU-bound background task
14+
15+
## How to Run
16+
17+
```sh
18+
source init_env
19+
cd suites/Kernel/FunctionalArea/Scheduler/CPU_affinity
20+
./run.sh
21+
```
22+
23+
## Prerequisites
24+
25+
- `taskset`, `grep`, `zgrep`, `top`, `chrt` must be available
26+
- Root access may be required for complete validation
27+
28+
## Result Format
29+
30+
Test result will be saved in `CPU_affinity.res` as:
31+
- `Default scheduling policy detected. Test passed` – if all validations pass
32+
- `Unexpected scheduling policy. Test Failed` – if any check fails
33+
34+
## License
35+
36+
SPDX-License-Identifier: BSD-3-Clause-Clear
37+
(C) Qualcomm Technologies, Inc. and/or its subsidiaries.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#!/bin/sh
2+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
3+
# SPDX-License-Identifier: BSD-3-Clause-Clear
4+
5+
# Robustly find and source init_env
6+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
7+
INIT_ENV=""
8+
SEARCH="$SCRIPT_DIR"
9+
while [ "$SEARCH" != "/" ]; do
10+
if [ -f "$SEARCH/init_env" ]; then
11+
INIT_ENV="$SEARCH/init_env"
12+
break
13+
fi
14+
SEARCH=$(dirname "$SEARCH")
15+
done
16+
17+
if [ -z "$INIT_ENV" ]; then
18+
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
19+
exit 1
20+
fi
21+
22+
# Only source if not already loaded (idempotent)
23+
if [ -z "$__INIT_ENV_LOADED" ]; then
24+
# shellcheck disable=SC1090
25+
. "$INIT_ENV"
26+
fi
27+
# Always source functestlib.sh, using $TOOLS exported by init_env
28+
# shellcheck disable=SC1090,SC1091
29+
. "$TOOLS/functestlib.sh"
30+
31+
TESTNAME="CPU_affinity"
32+
test_path=$(find_test_case_by_name "$TESTNAME")
33+
cd "$test_path" || exit 1
34+
# shellcheck disable=SC2034
35+
res_file="./$TESTNAME.res"
36+
37+
log_info "----------------------------------------------------"
38+
log_info "-------- Starting $TESTNAME Functional Test --------"
39+
40+
check_dependencies taskset top chrt zcat grep
41+
42+
REQUIRED_CONFIGS="CONFIG_SCHED_DEBUG CONFIG_CGROUP_SCHED CONFIG_SMP"
43+
for config in $REQUIRED_CONFIGS; do
44+
if check_kernel_config "$config"; then
45+
log_pass "$config is enabled"
46+
echo "$TESTNAME PASS" > "$res_file"
47+
else
48+
log_fail "$config is missing"
49+
echo "$TESTNAME FAIL" > "$res_file"
50+
exit 1
51+
fi
52+
done
53+
54+
log_info "Creating a CPU-bound background task..."
55+
cpu_task() {
56+
while true; do :; done
57+
}
58+
cpu_task &
59+
TASK_PID=$!
60+
sleep 2
61+
62+
log_info "Checking CPU affinity of task $TASK_PID..."
63+
CPU_AFFINITY=$(taskset -p $TASK_PID | awk -F: '{print $2}' | xargs)
64+
log_info "CPU affinity: $CPU_AFFINITY"
65+
66+
log_info "Setting affinity to CPU 0"
67+
taskset -pc 0 $TASK_PID > /dev/null
68+
sleep 1
69+
70+
NEW_AFFINITY=$(taskset -p $TASK_PID | awk -F: '{print $2}' | xargs)
71+
if [ "$NEW_AFFINITY" = "1" ]; then
72+
log_pass "Successfully set CPU affinity"
73+
echo "$TESTNAME PASS" > "$res_file"
74+
else
75+
log_fail "Failed to set CPU affinity"
76+
echo "$TESTNAME FAIL" > "$res_file"
77+
fi
78+
79+
log_info "Checking scheduling policy of task..."
80+
SCHED_POLICY=$(chrt -p $TASK_PID | grep "scheduling policy" | awk -F: '{print $2}' | xargs)
81+
log_info "Scheduling Policy: $SCHED_POLICY"
82+
83+
if echo "$SCHED_POLICY" | grep -q "SCHED_OTHER"; then
84+
log_pass "Default scheduling policy detected. Test passed"
85+
echo "$TESTNAME PASS" > "$res_file"
86+
else
87+
log_fail "Unexpected scheduling policy. Test Failed"
88+
echo "$TESTNAME FAIL" > "$res_file"
89+
fi
90+
91+
kill $TASK_PID
92+
echo "$TESTNAME PASS" > $test_path/$TESTNAME.res
93+
log_info "-------- Completed $TESTNAME Functional Test --------"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# IOMMU Validation Test
2+
3+
This test validates the IOMMU (Input-Output Memory Management Unit) support and runtime status on Qualcomm platforms with Yocto builds.
4+
5+
## Overview
6+
7+
The test script performs these functional checks:
8+
9+
1. **Kernel Configuration**:
10+
- Validates presence of `CONFIG_IOMMU_SUPPORT` and `CONFIG_ARM_SMMU*` entries in `/proc/config.gz`.
11+
12+
2. **Driver Loading**:
13+
- Confirms SMMU/IOMMU-related drivers are loaded via `/proc/modules`.
14+
15+
3. **Device Tree Nodes**:
16+
- Verifies IOMMU/SMMU-related nodes in `/proc/device-tree`.
17+
18+
4. **Runtime Verification**:
19+
- Checks `dmesg` for any runtime IOMMU initialization or fault logs.
20+
21+
## How to Run
22+
23+
```sh
24+
source init_env
25+
cd suites/Kernel/FunctionalArea/IOMMU_Validation
26+
./run.sh
27+
```
28+
29+
## Prerequisites
30+
31+
- `dmesg`, `grep`, `zgrep`, `lsmod` must be available
32+
- Root access may be required for complete validation
33+
34+
## Result Format
35+
36+
Test result will be saved in `IOMMU.res` as:
37+
- `IOMMU PASS` – if all validations pass
38+
- `IOMMU FAIL` – if any check fails
39+
40+
## License
41+
42+
SPDX-License-Identifier: BSD-3-Clause-Clear
43+
(C) Qualcomm Technologies, Inc. and/or its subsidiaries.

Runner/suites/Kernel/FunctionalArea/baseport/iommu/run.sh

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,48 @@ log_info "----------------------------------------------------------------------
3939
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
4040
log_info "=== Test Initialization ==="
4141

42-
# Run the command and capture the output
43-
OUTPUT=$(dmesg | grep iommu)
42+
check_runtime_behavior() {
43+
if dmesg | grep -i -q "msm_iommu.*enabled"; then
44+
log_info "Runtime logs show Qualcomm MSM IOMMU is active"
45+
elif dmesg | grep -i -q "iommu.*enabled"; then
46+
log_info "Runtime logs show IOMMU is active"
47+
else
48+
log_fail "No runtime indication of IOMMU being active"
49+
return 1
50+
fi
51+
return 0
52+
}
53+
54+
pass=true
55+
56+
CONFIGS="CONFIG_IOMMU_SUPPORT CONFIG_QCOM_IOMMU CONFIG_ARM_SMMU"
57+
check_kernel_config "$CONFIGS" || {
58+
log_fail "Kernel config validation failed."
59+
echo "$TESTNAME FAIL" > "$res_file"
60+
exit 1
61+
}
62+
LOADED_MODULES="msm_iommu arm_smmu"
63+
check_driver_loaded "$LOADED_MODULES" || {
64+
log_fail "Failed to load required driver modules"
65+
echo "$TESTNAME FAIL" > "$res_file"
66+
exit 1
67+
}
68+
69+
DT_NODES="/proc/device-tree/soc@0/iommu@15000000 /proc/device-tree/soc/iommu@15000000"
70+
check_dt_nodes "$DT_NODES" || {
71+
log_fail "Device tree validation failed."
72+
echo "$TESTNAME FAIL" > "$res_file"
73+
exit 1
74+
}
75+
76+
check_runtime_behavior || pass=false
4477

45-
# Check if the output is null
46-
if [ -z "$OUTPUT" ]; then
78+
if $pass; then
4779
log_pass "$TESTNAME : Test Passed"
4880
echo "$TESTNAME PASS" > "$res_file"
4981
else
5082
log_fail "$TESTNAME : Test Failed"
5183
echo "$TESTNAME FAIL" > "$res_file"
5284
fi
85+
5386
log_info "-------------------Completed $TESTNAME Testcase----------------------------"

0 commit comments

Comments
 (0)