Skip to content

Commit e6c52e9

Browse files
authored
Merge pull request #63 from smuppand/probe_fail
Add Probe_Failure_Check test to detect driver probe issues in dmesg
2 parents 2e3cc0d + 5a69659 commit e6c52e9

File tree

4 files changed

+131
-3
lines changed

4 files changed

+131
-3
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2-
# SPDX-License-Identifier: BSD-3-Clause-Clear
3-
41
# Linux Feature Validation Framework
52

63
## Overview
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Probe Failure Check Test
2+
3+
This directory contains the **Probe_Failure_Check** test suite for the Qualcomm Linux Testkit. This test verifies that no device driver probe errors occurred during the most recent system boot.
4+
5+
## Test Overview
6+
7+
- **Test Name:** Probe_Failure_Check
8+
- **Purpose:** Scan the kernel log for any "probe failed", "failed to probe", or "probe error" messages, indicating a driver failed to initialize.
9+
- **Results:**
10+
- On success: a result file `Probe_Failure_Check.res` is written with `Probe_Failure_Check PASS`.
11+
- On failure: a `probe_failures.log` file is created containing the matching log entries, and `Probe_Failure_Check.res` is written with `Probe_Failure_Check FAIL`.
12+
13+
## Files
14+
15+
- **run.sh**: The main test script. Execute to perform the check.
16+
- **probe_failures.log**: (Generated on failure) Contains all discovered probe failure messages.
17+
- **Probe_Failure_Check.res**: Test result file with PASS or FAIL.
18+
19+
## Usage
20+
21+
1. Ensure the testkit environment is set up and the board has booted.
22+
2. From this directory, make sure the script is executable:
23+
```sh
24+
chmod +x run.sh
25+
```
26+
3. Run the test:
27+
```sh
28+
./run.sh
29+
```
30+
4. Check the result:
31+
- If the test passes, look for `Probe_Failure_Check.res` containing `PASS`.
32+
- If the test fails, examine `probe_failures.log` for details.
33+
34+
## Integration
35+
36+
This test integrates with the top-level runner in `Runner/run-test.sh` and can be invoked as:
37+
38+
```sh
39+
cd Runner
40+
./run-test.sh Probe_Failure_Check
41+
```
42+
43+
The `.res` file will be parsed by CI/LAVA to determine overall test status.
44+
45+
## Dependencies
46+
47+
- **shell**: POSIX compliant (`/bin/sh`)
48+
- **journalctl** (optional): for collecting kernel logs. Falls back to `dmesg` or `/var/log/kern.log` if unavailable.
49+
- **grep**: for pattern matching.
50+
51+
## Shellcheck Compliance
52+
53+
The script is tested with `shellcheck` and disables SC2039 and SC1091 where sourcing dynamic paths.
54+
55+
## License
56+
57+
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
58+
SPDX-License-Identifier: BSD-3-Clause-Clear
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
# SPDX-License-Identifier: BSD-3-Clause-Clear
5+
6+
# Robustly source init_env and functestlib.sh
7+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8+
INIT_ENV=""
9+
SEARCH="$SCRIPT_DIR"
10+
while [ "$SEARCH" != "/" ]; do
11+
if [ -f "$SEARCH/init_env" ]; then
12+
INIT_ENV="$SEARCH/init_env"
13+
break
14+
fi
15+
SEARCH=$(dirname "$SEARCH")
16+
done
17+
18+
if [ -z "$INIT_ENV" ]; then
19+
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
20+
exit 1
21+
fi
22+
23+
if [ -z "$__INIT_ENV_LOADED" ]; then
24+
# shellcheck disable=SC1090
25+
. "$INIT_ENV"
26+
fi
27+
28+
# shellcheck disable=SC1090,SC1091
29+
. "$TOOLS/functestlib.sh"
30+
31+
TESTNAME="Probe_Failure_Check"
32+
test_path=$(find_test_case_by_name "$TESTNAME")
33+
cd "$test_path" || exit 1
34+
35+
res_file="./$TESTNAME.res"
36+
log_file="./probe_failures.log"
37+
38+
log_info "-----------------------------------------------------------------------------------------"
39+
log_info "------------------- Starting $TESTNAME Testcase ----------------------------"
40+
41+
rm -f "$res_file" "$log_file"
42+
{
43+
echo "Probe Failure Report - $(date)"
44+
echo "--------------------------------------------------"
45+
} > "$log_file"
46+
47+
if get_kernel_log 2>/dev/null | \
48+
grep -iE '([[:alnum:]_.-]+:)?[[:space:]]*(probe failed|failed to probe|probe error)' \
49+
>> "$log_file"; then
50+
log_error "Probe failures detected; see $log_file"
51+
log_fail "$TESTNAME : Probe failures found"
52+
echo "$TESTNAME FAIL" > "$res_file"
53+
exit 1
54+
else
55+
rm -f "$log_file"
56+
log_pass "$TESTNAME : No probe failures found"
57+
echo "$TESTNAME PASS" > "$res_file"
58+
exit 0
59+
fi

Runner/utils/functestlib.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ log_error() { log "ERROR" "$@"; }
1616
log_skip() { log "SKIP" "$@"; }
1717
log_warn() { log "WARN" "$@"; }
1818

19+
# --- Kernel Log Collection ---
20+
get_kernel_log() {
21+
if command -v journalctl >/dev/null 2>&1; then
22+
journalctl -k -b
23+
elif command -v dmesg >/dev/null 2>&1; then
24+
dmesg
25+
elif [ -f /var/log/kern.log ]; then
26+
cat /var/log/kern.log
27+
else
28+
log_warn "No kernel log source found"
29+
return 1
30+
fi
31+
}
32+
1933
# --- Dependency check ---
2034
check_dependencies() {
2135
missing=0

0 commit comments

Comments
 (0)