xref: /aosp_15_r20/external/ltp/doc/old/Maintainer-Patch-Review-Checklist.asciidoc (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker# Patch Review
2*49cdfc7eSAndroid Build Coastguard Worker
3*49cdfc7eSAndroid Build Coastguard WorkerAnyone can and should review patches. It's the only way to get good at
4*49cdfc7eSAndroid Build Coastguard Workerpatch review and for the project to scale.
5*49cdfc7eSAndroid Build Coastguard Worker
6*49cdfc7eSAndroid Build Coastguard Worker## Goals of patch review
7*49cdfc7eSAndroid Build Coastguard Worker
8*49cdfc7eSAndroid Build Coastguard Worker1. Prevent false positive test results
9*49cdfc7eSAndroid Build Coastguard Worker2. Prevent false negative test results
10*49cdfc7eSAndroid Build Coastguard Worker3. Keep the code as simple as possible, but no simpler
11*49cdfc7eSAndroid Build Coastguard Worker
12*49cdfc7eSAndroid Build Coastguard Worker## How to find clear errors
13*49cdfc7eSAndroid Build Coastguard Worker
14*49cdfc7eSAndroid Build Coastguard WorkerA clear error is one where there is unlikely to be any argument if you
15*49cdfc7eSAndroid Build Coastguard Workerprovide evidence of it. Evidence being an error trace or logical proof
16*49cdfc7eSAndroid Build Coastguard Workerthat an error will occur in a common situation.
17*49cdfc7eSAndroid Build Coastguard Worker
18*49cdfc7eSAndroid Build Coastguard WorkerThe following are examples and may not be appropriate for all tests.
19*49cdfc7eSAndroid Build Coastguard Worker
20*49cdfc7eSAndroid Build Coastguard Worker* Merge the patch locally. It should apply cleanly to master.
21*49cdfc7eSAndroid Build Coastguard Worker* Compile the patch with default and non-default configurations.
22*49cdfc7eSAndroid Build Coastguard Worker  - Use sanitizers e.g. undefined behaviour, address.
23*49cdfc7eSAndroid Build Coastguard Worker  - Compile on non-x86
24*49cdfc7eSAndroid Build Coastguard Worker  - Compile on x86 with -m32
25*49cdfc7eSAndroid Build Coastguard Worker  - Compile testing patches with GitHub Actions in LTP repo fork can cover
26*49cdfc7eSAndroid Build Coastguard Worker    various distros/architectures
27*49cdfc7eSAndroid Build Coastguard Worker* Use `make check`
28*49cdfc7eSAndroid Build Coastguard Worker* Run effected tests in a VM
29*49cdfc7eSAndroid Build Coastguard Worker  - Use single vCPU
30*49cdfc7eSAndroid Build Coastguard Worker  - Use many vCPUs and enable NUMA
31*49cdfc7eSAndroid Build Coastguard Worker  - Restrict RAM to < 1GB.
32*49cdfc7eSAndroid Build Coastguard Worker* Run effected tests on an embedded device
33*49cdfc7eSAndroid Build Coastguard Worker* Run effected tests on non-x86 machine in general
34*49cdfc7eSAndroid Build Coastguard Worker* Run reproducers on a kernel where the bug is present
35*49cdfc7eSAndroid Build Coastguard Worker* Run tests with "-i0" and "-i2"
36*49cdfc7eSAndroid Build Coastguard Worker* Compare usage of system calls with man page descriptions
37*49cdfc7eSAndroid Build Coastguard Worker* Compare usage of system calls with kernel code
38*49cdfc7eSAndroid Build Coastguard Worker* Double check commit message
39*49cdfc7eSAndroid Build Coastguard Worker* Search the LTP library for existing helper functions
40*49cdfc7eSAndroid Build Coastguard Worker* Check doc formatting, i.e. make doc && chromium docparse/metadata.html
41*49cdfc7eSAndroid Build Coastguard Worker
42*49cdfc7eSAndroid Build Coastguard Worker## How to find subtle errors
43*49cdfc7eSAndroid Build Coastguard Worker
44*49cdfc7eSAndroid Build Coastguard WorkerA subtle error is one where you can expect some argument because you
45*49cdfc7eSAndroid Build Coastguard Workerdo not have clear evidence of an error. It is best to state these as
46*49cdfc7eSAndroid Build Coastguard Workerquestions and not make assertions if possible.
47*49cdfc7eSAndroid Build Coastguard Worker
48*49cdfc7eSAndroid Build Coastguard WorkerAlthough if it is a matter of style or "taste" then senior maintainers
49*49cdfc7eSAndroid Build Coastguard Workercan assert what is correct to avoid bike shedding.
50*49cdfc7eSAndroid Build Coastguard Worker
51*49cdfc7eSAndroid Build Coastguard Worker* Ask what happens if there is an error, could it be debugged just
52*49cdfc7eSAndroid Build Coastguard Worker  with the test output?
53*49cdfc7eSAndroid Build Coastguard Worker* Are we testing undefined behavior?
54*49cdfc7eSAndroid Build Coastguard Worker  - Could future kernel behaviour change without "breaking userland"?
55*49cdfc7eSAndroid Build Coastguard Worker  - Does the kernel behave differently depending on hardware?
56*49cdfc7eSAndroid Build Coastguard Worker  - Does it behave differently depending on kernel configuration?
57*49cdfc7eSAndroid Build Coastguard Worker  - Does it behave differently depending on the compiler?
58*49cdfc7eSAndroid Build Coastguard Worker  - Would it behave differently if the order of checks on syscall parameters
59*49cdfc7eSAndroid Build Coastguard Worker    changed in the kernel?
60*49cdfc7eSAndroid Build Coastguard Worker* Will it scale to tiny and huge systems?
61*49cdfc7eSAndroid Build Coastguard Worker  - What happens if there are 100+ CPUs?
62*49cdfc7eSAndroid Build Coastguard Worker  - What happens if each CPU core is very slow?
63*49cdfc7eSAndroid Build Coastguard Worker  - What happens if there are 2TB of RAM?
64*49cdfc7eSAndroid Build Coastguard Worker* Are we repeating a pattern that can be turned into a library function?
65*49cdfc7eSAndroid Build Coastguard Worker* Is a single test trying to do too much?
66*49cdfc7eSAndroid Build Coastguard Worker* Could multiple similar tests be merged?
67*49cdfc7eSAndroid Build Coastguard Worker* Race conditions
68*49cdfc7eSAndroid Build Coastguard Worker  - What happens if a process gets preempted?
69*49cdfc7eSAndroid Build Coastguard Worker  - Could checkpoints or fuzzsync by used instead?
70*49cdfc7eSAndroid Build Coastguard Worker  - Note, usually you can insert a sleep to prove a race condition
71*49cdfc7eSAndroid Build Coastguard Worker    exists however finding them is hard
72*49cdfc7eSAndroid Build Coastguard Worker* Is there a simpler way to achieve the same kernel coverage?
73*49cdfc7eSAndroid Build Coastguard Worker
74*49cdfc7eSAndroid Build Coastguard Worker## How to get patches merged
75*49cdfc7eSAndroid Build Coastguard Worker
76*49cdfc7eSAndroid Build Coastguard WorkerOnce you think a patch is good enough you should add your Reviewed-by
77*49cdfc7eSAndroid Build Coastguard Workerand/or Tested-by tags. This means you will get some credit for getting
78*49cdfc7eSAndroid Build Coastguard Workerthe patch merged. Also some blame if there are problems.
79*49cdfc7eSAndroid Build Coastguard Worker
80*49cdfc7eSAndroid Build Coastguard WorkerIf you ran the test you can add the Tested-by tag. If you read the
81*49cdfc7eSAndroid Build Coastguard Workercode or used static analysis tools on it, you can add the Reviewed-by
82*49cdfc7eSAndroid Build Coastguard Workertag.
83*49cdfc7eSAndroid Build Coastguard Worker
84*49cdfc7eSAndroid Build Coastguard WorkerIn addition you can expect others to review your patches and add their
85*49cdfc7eSAndroid Build Coastguard Workertags. This will speed up the process of getting your patches merged.
86*49cdfc7eSAndroid Build Coastguard Worker
87*49cdfc7eSAndroid Build Coastguard Worker## Maintainers Checklist
88*49cdfc7eSAndroid Build Coastguard Worker
89*49cdfc7eSAndroid Build Coastguard WorkerPatchset should be tested locally and ideally also in maintainer's fork in
90*49cdfc7eSAndroid Build Coastguard WorkerGitHub Actions on GitHub.
91*49cdfc7eSAndroid Build Coastguard Worker
92*49cdfc7eSAndroid Build Coastguard WorkerNOTE: GitHub Actions do only build testing, passing the CI means only that
93*49cdfc7eSAndroid Build Coastguard Worker      the test compiles fine on variety of different distributions and releases.
94*49cdfc7eSAndroid Build Coastguard Worker
95*49cdfc7eSAndroid Build Coastguard WorkerThe test should be executed at least once locally and should PASS as well.
96*49cdfc7eSAndroid Build Coastguard Worker
97*49cdfc7eSAndroid Build Coastguard WorkerCommit messages should have
98*49cdfc7eSAndroid Build Coastguard Worker
99*49cdfc7eSAndroid Build Coastguard Worker* Author's `Signed-off-by` tag
100*49cdfc7eSAndroid Build Coastguard Worker* Committer's `Reviewed-by` or `Signed-off-by` tag
101*49cdfc7eSAndroid Build Coastguard Worker* Check also mailing lists for other reviewers / testers tags, notes and failure reports
102*49cdfc7eSAndroid Build Coastguard Worker* `Fixes: hash` if it fixes particular LTP commit
103*49cdfc7eSAndroid Build Coastguard Worker* `Fixes: #N` if it fixes github issue number N, so it's automatically closed
104*49cdfc7eSAndroid Build Coastguard Worker* LTP WIKI (git: https://github.com/linux-test-project/ltp.wiki.git) should be kept up to date.
105*49cdfc7eSAndroid Build Coastguard Worker
106*49cdfc7eSAndroid Build Coastguard WorkerAfter patch is accepted or rejected, set correct state and archive in
107*49cdfc7eSAndroid Build Coastguard Workerhttps://patchwork.ozlabs.org/project/ltp/list/[LTP patchwork instance].
108*49cdfc7eSAndroid Build Coastguard Worker
109*49cdfc7eSAndroid Build Coastguard Worker## New tests
110*49cdfc7eSAndroid Build Coastguard WorkerNew test should
111*49cdfc7eSAndroid Build Coastguard Worker
112*49cdfc7eSAndroid Build Coastguard Worker* Have a record in runtest file
113*49cdfc7eSAndroid Build Coastguard Worker* Test should work fine with more than one iteration
114*49cdfc7eSAndroid Build Coastguard Worker  (e.g. run with `-i 100`)
115*49cdfc7eSAndroid Build Coastguard Worker* Run with `-i 0` to check that setup and cleanup are coded properly (no test is being run)
116*49cdfc7eSAndroid Build Coastguard Worker* Have a brief description
117*49cdfc7eSAndroid Build Coastguard Worker* License: the default license for new tests is GPL v2 or later, use
118*49cdfc7eSAndroid Build Coastguard Worker  GPL-2.0-or-later; the licence for test (e.g. GPL-2.0) should not change
119*49cdfc7eSAndroid Build Coastguard Worker  unless test is completely rewritten
120*49cdfc7eSAndroid Build Coastguard Worker* Old copyrights should be kept unless test is completely rewritten
121*49cdfc7eSAndroid Build Coastguard Worker
122*49cdfc7eSAndroid Build Coastguard Worker### C tests
123*49cdfc7eSAndroid Build Coastguard Worker* Use new https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#22-writing-a-test-in-c[C API]
124*49cdfc7eSAndroid Build Coastguard Worker* Test binaries are added into corresponding `.gitignore` files
125*49cdfc7eSAndroid Build Coastguard Worker* Check coding style with `make check`
126*49cdfc7eSAndroid Build Coastguard Worker  (more in https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#21-c-coding-style[C coding style])
127*49cdfc7eSAndroid Build Coastguard Worker* Docparse documentation
128*49cdfc7eSAndroid Build Coastguard Worker* If a test is a regression test it should include tags
129*49cdfc7eSAndroid Build Coastguard Worker  (more in https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#2238-test-tags[Test tags])
130*49cdfc7eSAndroid Build Coastguard Worker
131*49cdfc7eSAndroid Build Coastguard Worker### Shell tests
132*49cdfc7eSAndroid Build Coastguard Worker* Use new https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#23-writing-a-testcase-in-shell[shell API]
133*49cdfc7eSAndroid Build Coastguard Worker* Check coding style with `make check`
134*49cdfc7eSAndroid Build Coastguard Worker  (more in https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#132-shell-coding-style[Shell coding style])
135*49cdfc7eSAndroid Build Coastguard Worker* If a test is a regression test it should include related kernel or glibc commits as a comment
136*49cdfc7eSAndroid Build Coastguard Worker
137*49cdfc7eSAndroid Build Coastguard Worker## LTP library
138*49cdfc7eSAndroid Build Coastguard WorkerFor patchset touching library please check also
139*49cdfc7eSAndroid Build Coastguard Workerhttps://github.com/linux-test-project/ltp/wiki/LTP-Library-API-Writing-Guidelines[LTP Library API Writing Guidelines].
140