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