Skip to content

Commit a1ee177

Browse files
authored
Merge pull request qualcomm-linux#62 from smuppand/kselftest
Add initial run.sh for Kernel_Selftests with basic execution and result logging
2 parents 5f0e933 + c65d35f commit a1ee177

File tree

3 files changed

+425
-0
lines changed

3 files changed

+425
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
acct:acct_syscall
2+
arm64:btitest
3+
arm64:check_prctl
4+
arm64:fake_sigreturn_bad_magic
5+
arm64:fake_sigreturn_bad_size
6+
arm64:fake_sigreturn_bad_size_for_magic0
7+
arm64:fake_sigreturn_duplicated_fpsimd
8+
arm64:fake_sigreturn_misaligned_sp
9+
arm64:fake_sigreturn_missing_fpsimd
10+
arm64:fpmr_siginfo
11+
arm64:fp-ptrace
12+
arm64:hwcap
13+
arm64:mangle_pstate_invalid_compat_toggle
14+
arm64:mangle_pstate_invalid_daif_bits
15+
arm64:mangle_pstate_invalid_mode_el1h
16+
arm64:mangle_pstate_invalid_mode_el1t
17+
arm64:mangle_pstate_invalid_mode_el2h
18+
arm64:mangle_pstate_invalid_mode_el2t
19+
arm64:mangle_pstate_invalid_mode_el3h
20+
arm64:mangle_pstate_invalid_mode_el3t
21+
arm64:nobtitest
22+
arm64:pac
23+
arm64:poe_siginfo
24+
arm64:ptrace
25+
arm64:sme_trap_za
26+
arm64:syscall-abi
27+
arm64:tags_test
28+
arm64:tpidr2
29+
arm64:tpidr2_siginfo
30+
arm64:vec-syscfg
31+
arm64:za-fork
32+
breakpoints:breakpoint_test_arm64
33+
cachestat:test_cachestat
34+
cgroup:test_core
35+
cgroup:test_cpuset
36+
cgroup:test_freezer
37+
cgroup:test_kill
38+
clone3:clone3
39+
clone3:clone3_clear_sighand
40+
clone3:clone3_set_tid
41+
clone3:close_range_test
42+
damon:sysfs.sh
43+
damon:sysfs_update_removed_scheme_dir.sh
44+
net:forwarding/router_mpath_nh_res.sh
45+
net:forwarding/router_mpath_nh.sh
46+
net:hsr/hsr_ping.sh
47+
net:hsr/hsr_redbox.sh
48+
net:netfilter/bridge_brouter.sh
49+
net:netfilter/br_netfilter_queue.sh
50+
net:netfilter/br_netfilter.sh
51+
net:netfilter/conntrack_icmp_related.sh
52+
net:netfilter/conntrack_sctp_collision.sh
53+
net:netfilter/conntrack_tcp_unreplied.sh
54+
net:netfilter/conntrack_vrf.sh
55+
net:netfilter/nf_conntrack_packetdrill.sh
56+
net:netfilter/nft_conntrack_helper.sh
57+
net:netfilter/nft_fib.sh
58+
net:netfilter/nft_nat.sh
59+
net:netfilter/nft_nat_zones.sh
60+
net:netfilter/nft_queue.sh
61+
net:netfilter/nft_tproxy_tcp.sh
62+
net:netfilter/nft_tproxy_udp.sh
63+
net:netfilter/nft_zones_many.sh
64+
pidfd:pidfd_fdinfo_test
65+
pidfd:pidfd_file_handle_test
66+
pidfd:pidfd_getfd_test
67+
pidfd:pidfd_open_test
68+
pidfd:pidfd_poll_test
69+
pidfd:pidfd_setns_test
70+
pidfd:pidfd_test
71+
pidfd:pidfd_wait
72+
proc:fd-001-lookup
73+
proc:fd-002-posix-eq
74+
proc:fd-003-kthread
75+
proc:proc-2-is-kthread
76+
proc:proc-loadavg-001
77+
proc:proc-self-isnt-kthread
78+
proc:proc-self-map-files-001
79+
proc:proc-self-map-files-002
80+
proc:proc-self-syscall
81+
proc:proc-self-wchan
82+
proc:proc-subset-pid
83+
proc:proc-tid0
84+
proc:proc-uptime-001
85+
proc:proc-uptime-002
86+
timers:inconsistency-check
87+
timers:nanosleep
88+
timers:nsleep-lat

0 commit comments

Comments
 (0)