Skip to content

Commit 148ed60

Browse files
authored
Merge pull request #1 from vnarapar/main
Initial Kernel Sanity testcases
2 parents 44149d1 + 9b67d80 commit 148ed60

69 files changed

Lines changed: 5379 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Runner/init_env

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Source this file to setup the test suite environment
2+
if [ -e '/var/Runner' ];then
3+
export BASEDIR='/var/Runner'
4+
export TOOLS='/var/Runner/utils'
5+
export SUITES='/var/Runner/suites'
6+
export CALIBRATION='/var/Runner/calib.txt'
7+
export FTRACE_EVENTS='/var/Runner/ftrace_events'
8+
export PATH=$PATH:'/bin'
9+
export PATH=$PATH:'/sbin'
10+
fi
11+

Runner/run-test.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/sh
2+
# Import test suite definitions
3+
source /var/Runner/init_env
4+
5+
#import test functions library
6+
source $TOOLS/functestlib.sh
7+
8+
9+
# Find test case path by name
10+
find_test_case_by_name() {
11+
local test_name="$1"
12+
find /var/Runner/suites -type d -iname "$test_name" 2>/dev/null
13+
}
14+
15+
# Execute a test case
16+
execute_test_case() {
17+
local test_path="$1"
18+
if [ -d "$test_path" ]; then
19+
run_script="$test_path/run.sh"
20+
if [ -f "$run_script" ]; then
21+
log "Executing test case: $test_path"
22+
sh "$run_script" 2>&1
23+
# if [ $? -eq 0 ]; then
24+
# log "Test case $test_path passed."
25+
# else
26+
# log "Test case $test_path failed."
27+
# fi
28+
else
29+
log "No run.sh found in $test_path"
30+
fi
31+
else
32+
log "Test case directory not found: $test_path"
33+
fi
34+
}
35+
36+
# Function to run a specific test case by name
37+
run_specific_test_by_name() {
38+
local test_name="$1"
39+
test_path=$(find_test_case_by_name "$test_name")
40+
if [ -z "$test_path" ]; then
41+
log "Test case with name $test_name not found."
42+
else
43+
execute_test_case "$test_path"
44+
fi
45+
}
46+
47+
# Main script logic
48+
if [ "$#" -eq 0 ]; then
49+
log "Usage: $0 [all | <testcase_name>]"
50+
exit 1
51+
fi
52+
53+
54+
run_specific_test_by_name "$1"
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/sh
2+
# Import test suite definitions
3+
/var/Runner/init_env
4+
TESTNAME="BWMON"
5+
6+
#import test functions library
7+
source $TOOLS/functestlib.sh
8+
test_path=$(find_test_case_by_name "$TESTNAME")
9+
log_info "--------------------------------------------------------------------------"
10+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
11+
12+
log_info "Fetching te interconnect summary"
13+
extract_votes() {
14+
cat /sys/kernel/debug/interconnect/interconnect_summary | grep -i pmu | awk '{print $NF}'
15+
}
16+
log_info "Initial vote check:"
17+
sleep 5
18+
log_info "Initial vote check:"
19+
initial_votes=$(extract_votes)
20+
log_info "$initial_votes"
21+
log_info "$initial_votes"
22+
23+
log_info "Running bw_mem tool..."
24+
/var/common/bins/bw_mem 4000000000 frd &
25+
26+
sleep 2
27+
28+
log_info "Vote check while bw_mem tool is running:"
29+
final_votes=$(extract_votes)
30+
log_info "$final_votes"
31+
32+
wait
33+
34+
log_info "Comparing votes"
35+
36+
37+
incremented=true
38+
for i in $(seq 2 $(echo "$initial_votes" | wc -l)); do
39+
initial_vote=$(echo "$initial_votes" | sed -n "${i}p")
40+
final_vote=$(echo "$final_votes" | sed -n "${i}p")
41+
if [ "$final_vote" -le "$initial_vote" ]; then
42+
incremented=false
43+
log_pass "Vote did not increment for row $i: initial=$initial_vote, final=$final_vote"
44+
else
45+
log_pass "Vote incremented for row $i: initial=$initial_vote, final=$final_vote"
46+
fi
47+
done
48+
49+
if $incremented; then
50+
log_pass "$TESTNAME : Test Passed"
51+
echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res
52+
else
53+
log_fail "$TESTNAME : Test Failed"
54+
echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res
55+
fi
56+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
# Import test suite definitions
3+
/var/Runner/init_env
4+
TESTNAME="Buses"
5+
6+
#import test functions library
7+
source $TOOLS/functestlib.sh
8+
test_path=$(find_test_case_by_name "$TESTNAME")
9+
log_info "-----------------------------------------------------------------------------------------"
10+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
11+
12+
log_info "running i2c binary"
13+
output=$(/var/common/bins/buses/i2c-msm-test -v -D /dev/i2c-0 -l | grep "ret:1")
14+
15+
16+
if echo "$output" | grep -q "Reading"; then
17+
log_pass "$TESTNAME : Test Passed"
18+
echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res
19+
else
20+
log_fail "$TESTNAME : Test Failed"
21+
echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res
22+
fi
23+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/bin/bash
2+
3+
# CPUFreq Validator: Parallel, Colorized
4+
/var/Runner/init_env
5+
TESTNAME="CPUFreq_Validation"
6+
7+
#import test functions library
8+
source $TOOLS/functestlib.sh
9+
test_path=$(find_test_case_by_name "$TESTNAME")
10+
log_info "-----------------------------------------------------------------------------------------"
11+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
12+
log_info "=== CPUFreq Frequency Walker with Validation ==="
13+
14+
# Color codes
15+
GREEN="\e[32m"
16+
RED="\e[31m"
17+
YELLOW="\e[33m"
18+
BLUE="\e[34m"
19+
NC="\e[0m" # No Color
20+
21+
NUM_CPUS=$(nproc)
22+
echo -e "${YELLOW}Detected $NUM_CPUS CPU cores.${NC}"
23+
24+
overall_pass=true
25+
declare -A core_status
26+
27+
validate_cpu_core() {
28+
local cpu=$1
29+
local core_id=$2
30+
31+
echo -e "${BLUE}Processing $cpu...${NC}"
32+
33+
if [ ! -d "$cpu/cpufreq" ]; then
34+
echo -e "${BLUE}[SKIP]${NC} $cpu does not support cpufreq."
35+
core_status["$core_id"]="skip"
36+
return
37+
fi
38+
39+
available_freqs=$(cat "$cpu/cpufreq/scaling_available_frequencies" 2>/dev/null)
40+
41+
if [ -z "$available_freqs" ]; then
42+
echo -e "${YELLOW}[INFO]${NC} No available frequencies for $cpu. Skipping..."
43+
core_status["$core_id"]="skip"
44+
return
45+
fi
46+
47+
# Set governor to userspace
48+
if echo "userspace" | tee "$cpu/cpufreq/scaling_governor" > /dev/null; then
49+
echo -e "${YELLOW}[INFO]${NC} Set governor to userspace."
50+
else
51+
echo -e "${RED}[ERROR]${NC} Cannot set userspace governor for $cpu."
52+
core_status["$core_id"]="fail"
53+
return
54+
fi
55+
56+
core_status["$core_id"]="pass" # Assume pass unless a failure happens
57+
58+
for freq in $available_freqs; do
59+
log_info "Setting $cpu to frequency $freq kHz..."
60+
if echo $freq | tee "$cpu/cpufreq/scaling_setspeed" > /dev/null; then
61+
sleep 0.2
62+
actual_freq=$(cat "$cpu/cpufreq/scaling_cur_freq")
63+
if [ "$actual_freq" == "$freq" ]; then
64+
echo -e "${GREEN}[PASS]${NC} $cpu set to $freq kHz."
65+
else
66+
echo -e "${RED}[FAIL]${NC} Tried to set $cpu to $freq kHz, but current is $actual_freq kHz."
67+
core_status["$core_id"]="fail"
68+
fi
69+
else
70+
echo -e "${RED}[ERROR]${NC} Failed to set $cpu to $freq kHz."
71+
core_status["$core_id"]="fail"
72+
fi
73+
done
74+
75+
# Restore governor
76+
echo "Restoring $cpu governor to 'ondemand'..."
77+
echo "ondemand" | sudo tee "$cpu/cpufreq/scaling_governor" > /dev/null
78+
}
79+
80+
# Launch validation per CPU in parallel
81+
cpu_index=0
82+
for cpu in /sys/devices/system/cpu/cpu[0-9]*; do
83+
validate_cpu_core "$cpu" "$cpu_index" &
84+
((cpu_index++))
85+
done
86+
87+
# Wait for all background jobs to finish
88+
wait
89+
90+
# Summary
91+
log_info ""
92+
log_info "=== Per-Core Test Summary ==="
93+
for idx in "${!core_status[@]}"; do
94+
status=${core_status[$idx]}
95+
case "$status" in
96+
pass)
97+
echo -e "CPU$idx: ${GREEN}[PASS]${NC}"
98+
;;
99+
fail)
100+
echo -e "CPU$idx: ${RED}[FAIL]${NC}"
101+
overall_pass=false
102+
;;
103+
skip)
104+
echo -e "CPU$idx: ${BLUE}[SKIPPED]${NC}"
105+
;;
106+
*)
107+
echo -e "CPU$idx: ${RED}[UNKNOWN STATUS]${NC}"
108+
overall_pass=false
109+
;;
110+
esac
111+
done
112+
113+
# Overall result
114+
log_info ""
115+
log_info "=== Overall CPUFreq Validation Result ==="
116+
if $overall_pass; then
117+
echo -e "${GREEN}[OVERALL PASS]${NC} All CPUs validated successfully."
118+
log_pass "$TESTNAME : Test Passed"
119+
echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res
120+
exit 0
121+
else
122+
echo -e "${RED}[OVERALL FAIL]${NC} Some CPUs failed frequency validation."
123+
log_fail "$TESTNAME : Test Failed"
124+
echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res
125+
exit 1
126+
fi
127+
128+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/sh
2+
# Import test suite definitions
3+
/var/Runner/init_env
4+
TESTNAME="GIC"
5+
6+
#import test functions library
7+
source $TOOLS/functestlib.sh
8+
test_path=$(find_test_case_by_name "$TESTNAME")
9+
log_info "-----------------------------------------------------------------------------------------"
10+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
11+
12+
# Function to get the timer count
13+
get_timer_count() {
14+
cat /proc/interrupts | grep arch_timer
15+
}
16+
17+
# Get the initial timer count
18+
echo "Initial timer count:"
19+
initial_count=$(get_timer_count)
20+
echo "$initial_count"
21+
22+
# Wait for 2 minutes
23+
sleep 120
24+
25+
# Get the timer count after 2 minutes
26+
echo "Timer count after 2 minutes:"
27+
final_count=$(get_timer_count)
28+
echo "$final_count"
29+
30+
# Compare the initial and final counts
31+
echo "Comparing timer counts:"
32+
echo "$initial_count" | while read -r line; do
33+
cpu=$(echo "$line" | awk '{print $1}')
34+
initial_values=$(echo "$line" | awk '{for(i=2;i<=9;i++) print $i}')
35+
final_values=$(echo "$final_count" | grep "$cpu" | awk '{for(i=2;i<=9;i++) print $i}')
36+
37+
fail_test=false
38+
initial_values_list=$(echo "$initial_values" | tr ' ' '\n')
39+
final_values_list=$(echo "$final_values" | tr ' ' '\n')
40+
41+
i=0
42+
echo "$initial_values_list" | while read -r initial_value; do
43+
final_value=$(echo "$final_values_list" | sed -n "$((i+1))p")
44+
if [ "$initial_value" -lt "$final_value" ]; then
45+
echo "CPU $i: Timer count has incremented. Test PASSED"
46+
log_pass "CPU $i: Timer count has incremented. Test PASSED"
47+
else
48+
echo "CPU $i: Timer count has not incremented. Test FAILED"
49+
log_fail "CPU $i: Timer count has not incremented. Test FAILED"
50+
fail_test=true
51+
fi
52+
i=$((i+1))
53+
done
54+
echo $fail_test
55+
if [ "$fail_test" = false ]; then
56+
log_pass "$TESTNAME : Test Passed"
57+
echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res
58+
else
59+
log_fail "$TESTNAME : Test Failed"
60+
echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res
61+
fi
62+
done
63+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/sh
2+
# Import test suite definitions
3+
source /var/Runner/init_env
4+
TESTNAME="IPA"
5+
#import test functions library
6+
log() {
7+
local level="$1"
8+
shift
9+
# echo "$(date '+%Y-%m-%d %H:%M:%S') - $message" | tee -a /var/test_framework.log
10+
echo "[$level] $(/bin/date '+%Y-%m-%d %H:%M:%S') - $*" | /usr/bin/tee -a /var/test_output.log
11+
}
12+
# Find test case path by name
13+
find_test_case_by_name() {
14+
local test_name="$1"
15+
find /var/Runner/suites -type d -name "$test_name" 2>/dev/null
16+
}
17+
# Logging levels
18+
log_info() { log "INFO" "$@"; }
19+
log_pass() { log "PASS" "$@"; }
20+
log_fail() { log "FAIL" "$@"; }
21+
log_error() { log "ERROR" "$@"; }
22+
23+
test_path=$(find_test_case_by_name "$TESTNAME")
24+
log_info "-----------------------------------------------------------------------------------------"
25+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
26+
27+
PATH=$(find / -name "ipa.ko" 2>/dev/null)
28+
29+
# Check if the file was found
30+
if [ -z "$PATH" ]; then
31+
log_error "ipa.ko file not found."
32+
exit 1
33+
fi
34+
35+
# Insert the module
36+
TEST=$(/sbin/insmod "$PATH")
37+
log_info "output of insmod $TEST"
38+
39+
if /sbin/lsmod | /bin/grep "ipa"; then
40+
log_info "$(/sbin/lsmod | /bin/grep "ipa")"
41+
log_pass "$TESTNAME : Test Passed"
42+
echo "$TESTNAME : Test Passed" > $test_path/$TESTNAME.res
43+
else
44+
log_error "rmnet module not running"
45+
log_fail "$TESTNAME : Test Failed"
46+
echo "$TESTNAME : Test Failed" > $test_path/$TESTNAME.res
47+
fi
48+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"

0 commit comments

Comments
 (0)