Skip to content

Commit e6c44a0

Browse files
committed
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 <[email protected]>
1 parent 184f700 commit e6c44a0

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

Runner/utils/functestlib.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,56 @@ find_test_case_script_by_name() {
4848
find "$base_dir" -type d -iname "$test_name" -print -quit 2>/dev/null
4949
}
5050

51+
check_kernel_config() {
52+
configs="$1"
53+
for config_key in $configs; do
54+
if zcat /proc/config.gz | grep -qE "^$config_key=(y|m)"; then
55+
log_pass "Kernel config $config_key is enabled"
56+
else
57+
log_fail "Kernel config $config_key is missing or not enabled"
58+
return 1
59+
fi
60+
done
61+
return 0
62+
}
63+
64+
check_dt_nodes() {
65+
node_paths="$1"
66+
log_info "$node_paths"
67+
found=false
68+
for node in $node_paths; do
69+
log_info "$node"
70+
if [ -d "$node" ] || [ -f "$node" ]; then
71+
log_pass "Device tree node exists: $node"
72+
found=true
73+
fi
74+
done
75+
76+
if [ "$found" = true ]; then
77+
return 0
78+
else
79+
log_fail "Device tree node(s) missing: $node_paths"
80+
return 1
81+
fi
82+
}
83+
84+
check_driver_loaded() {
85+
drivers="$1"
86+
for driver in $drivers; do
87+
if [ -z "$driver" ]; then
88+
log_fail "No driver/module name provided to check_driver_loaded"
89+
return 1
90+
fi
91+
if grep -qw "$driver" /proc/modules || lsmod | awk '{print $1}' | grep -qw "$driver"; then
92+
log_pass "Driver/module '$driver' is loaded"
93+
return 0
94+
else
95+
log_fail "Driver/module '$driver' is not loaded"
96+
return 1
97+
fi
98+
done
99+
}
100+
51101
# --- Optional: POSIX-safe repo root detector ---
52102
detect_runner_root() {
53103
path=$1

0 commit comments

Comments
 (0)