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