|
| 1 | +# Kernel Selftest Runner |
| 2 | + |
| 3 | +This directory contains the automation scripts for running **Linux Kernel Selftests** on Qualcomm-based platforms (e.g., RB3GEN2) using the standardized `qcom-linux-testkit` framework. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The selftest runner (`run.sh`) is designed to: |
| 8 | +- Automatically detect and run enabled kernel selftests using a whitelist file (`enabled_tests.list`) |
| 9 | +- Ensure all required dependencies and directories are present |
| 10 | +- Log detailed test results for CI/CD integration |
| 11 | +- Support both standalone execution and integration with LAVA/automated test infrastructure |
| 12 | + |
| 13 | +## Files |
| 14 | + |
| 15 | +- **run.sh**: Main test runner script. Executes all tests listed in `enabled_tests.list` and produces `.res` and `.run` result files. |
| 16 | +- **enabled_tests.list**: Whitelist of test suites or binaries to run (one per line). Supports comments and blank lines. |
| 17 | +- **Kernel_Selftests.res**: Detailed result file, capturing PASS/FAIL/SKIP for each test or subtest. |
| 18 | +- **Kernel_Selftests.run**: Cumulative PASS or FAIL summary, used by CI pipelines for quick parsing. |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +- `/kselftest` directory must be present on the device/target. This is where the selftest binaries are located (usually deployed by the build or CI). |
| 23 | +- All test scripts must have the executable bit set (`chmod +x run.sh`), enforced by GitHub Actions. |
| 24 | +- `enabled_tests.list` must exist and contain at least one non-comment, non-blank entry. |
| 25 | + |
| 26 | +## Script Flow |
| 27 | + |
| 28 | +1. **Environment Setup**: |
| 29 | + Dynamically locates and sources `init_env` and `functestlib.sh` to ensure robust, path-independent execution. |
| 30 | + |
| 31 | +2. **Dependency Checks**: |
| 32 | + - Checks for required commands (e.g., `find`) |
| 33 | + - Ensures `/kselftest` directory exists |
| 34 | + - Validates `enabled_tests.list` is present and usable |
| 35 | + |
| 36 | +3. **Test Discovery & Execution**: |
| 37 | + - Parses `enabled_tests.list`, ignoring comments and blanks |
| 38 | + - Supports both directory and subtest (e.g., `timers/thread_test`) entries |
| 39 | + - Executes test binaries or `run_test.sh` for each listed test |
| 40 | + - Logs individual and summary results |
| 41 | + |
| 42 | +4. **Result Logging**: |
| 43 | + - Writes detailed results to `Kernel_Selftests.res` |
| 44 | + - Writes overall PASS/FAIL to `Kernel_Selftests.run` |
| 45 | + |
| 46 | +5. **CI Compatibility**: |
| 47 | + - Designed for direct invocation by LAVA or any CI/CD harness |
| 48 | + - Fails early and logs meaningful errors if prerequisites are missing |
| 49 | + |
| 50 | +## enabled_tests.list Format |
| 51 | + |
| 52 | +```text |
| 53 | +# This is a comment |
| 54 | +timers |
| 55 | +thread |
| 56 | +timers/thread_test |
| 57 | +# Add more test names or subtests as needed |
| 58 | +``` |
| 59 | + |
| 60 | +- Each non-comment, non-blank line specifies a test directory or a test binary under `/kselftest`. |
| 61 | + |
| 62 | +## Example Usage |
| 63 | + |
| 64 | +```sh |
| 65 | +sh run.sh |
| 66 | +``` |
| 67 | + |
| 68 | +or from a higher-level testkit runner: |
| 69 | + |
| 70 | +```sh |
| 71 | +./run-test.sh Kernel_Selftests |
| 72 | +``` |
| 73 | + |
| 74 | +## Troubleshooting |
| 75 | + |
| 76 | +- **Missing executable bit**: |
| 77 | + If you see permission errors, ensure all scripts are `chmod +x`. |
| 78 | + |
| 79 | +- **Missing `/kselftest` directory**: |
| 80 | + Ensure selftests are built and deployed to the target system. |
| 81 | + |
| 82 | +- **Missing or empty `enabled_tests.list`**: |
| 83 | + Add test entries as needed. The runner will fail if this file is absent or empty. |
| 84 | + |
| 85 | +## Contribution Guidelines |
| 86 | + |
| 87 | +- Update `enabled_tests.list` as test coverage expands. |
| 88 | +- Follow the coding and structure conventions enforced by CI (see `CONTRIBUTING.md`). |
| 89 | +- All changes should pass permission checks and shellcheck lints in CI. |
| 90 | + |
| 91 | +## License |
| 92 | + |
| 93 | +SPDX-License-Identifier: BSD-3-Clause-Clear |
| 94 | +Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. |
0 commit comments