Skip to content

Commit af3d3c5

Browse files
committed
kernel: use shared interrupt parsing helpers in irq test
Update the irq test to use shared interrupt parsing helpers from functestlib.sh instead of assuming a fixed number of CPU interrupt columns. The test now: - locates the arch_timer line through a shared helper - extracts only numeric per-CPU interrupt counters - validates the detected counter count before comparison Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
1 parent fbc509e commit af3d3c5

1 file changed

Lines changed: 36 additions & 10 deletions

File tree

  • Runner/suites/Kernel/Baseport/irq

Runner/suites/Kernel/Baseport/irq/run.sh

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ log_info "=== Test Initialization ==="
4040

4141
# Function to get the timer count
4242
get_timer_count() {
43-
grep arch_timer /proc/interrupts
43+
get_interrupt_line_by_name "arch_timer"
4444
}
4545

4646
# Get the initial timer count
@@ -61,27 +61,53 @@ log_info "Comparing timer counts:"
6161
while IFS= read -r line; do
6262
[ -n "$line" ] || continue
6363

64-
cpu=$(printf '%s\n' "$line" | awk '{print $1}')
65-
initial_values=$(printf '%s\n' "$line" | awk '{for(i=2;i<=9;i++) print $i}')
66-
final_values=$(printf '%s\n' "$final_count" | awk -v cpu="$cpu" '$1 == cpu {for(i=2;i<=9;i++) print $i}')
64+
irq_id=$(printf '%s\n' "$line" | awk '{print $1}')
65+
final_line=$(printf '%s\n' "$final_count" | awk -v irq="$irq_id" '$1 == irq { print; exit }')
66+
67+
if [ -z "$final_line" ]; then
68+
log_fail "Could not find matching final timer line for IRQ $irq_id"
69+
log_fail "$TESTNAME : Test Failed"
70+
echo "$TESTNAME FAIL" > "$res_file"
71+
exit 1
72+
fi
73+
74+
initial_values=$(extract_interrupt_cpu_counts "$line")
75+
final_values=$(extract_interrupt_cpu_counts "$final_line")
76+
77+
initial_cpu_count=$(count_interrupt_cpu_counts "$initial_values")
78+
final_cpu_count=$(count_interrupt_cpu_counts "$final_values")
79+
80+
log_info "Detected timer counters: initial=${initial_cpu_count} final=${final_cpu_count}"
81+
82+
if [ "$initial_cpu_count" -eq 0 ] || [ "$final_cpu_count" -eq 0 ]; then
83+
log_fail "No per-CPU timer counters could be parsed from /proc/interrupts"
84+
log_fail "$TESTNAME : Test Failed"
85+
echo "$TESTNAME FAIL" > "$res_file"
86+
exit 1
87+
fi
88+
89+
if [ "$initial_cpu_count" -ne "$final_cpu_count" ]; then
90+
log_fail "Mismatch in parsed CPU timer counters: initial=${initial_cpu_count} final=${final_cpu_count}"
91+
log_fail "$TESTNAME : Test Failed"
92+
echo "$TESTNAME FAIL" > "$res_file"
93+
exit 1
94+
fi
6795

6896
fail_test=false
6997
i=0
7098

71-
while IFS= read -r initial_value; do
72-
[ -n "$initial_value" ] || continue
73-
99+
while [ "$i" -lt "$initial_cpu_count" ]; do
100+
initial_value=$(printf '%s\n' "$initial_values" | sed -n "$((i + 1))p")
74101
final_value=$(printf '%s\n' "$final_values" | sed -n "$((i + 1))p")
102+
75103
if [ "$initial_value" -lt "$final_value" ]; then
76104
log_pass "CPU $i: Timer count has incremented. Test PASSED"
77105
else
78106
log_fail "CPU $i: Timer count has not incremented. Test FAILED"
79107
fail_test=true
80108
fi
81109
i=$((i + 1))
82-
done <<EOF
83-
$initial_values
84-
EOF
110+
done
85111

86112
if [ "$fail_test" = false ]; then
87113
log_pass "$TESTNAME : Test Passed"

0 commit comments

Comments
 (0)