]>
Commit | Line | Data |
---|---|---|
1 | --- | |
2 | title: Code Quality Tools | |
3 | category: Contributing | |
4 | layout: default | |
5 | --- | |
6 | ||
7 | # Code Quality Tools | |
8 | ||
9 | The systemd project has a number of code quality tools set up in the source | |
10 | tree and on the github infrastructure. Here's an incomprehensive list of the | |
11 | available functionality: | |
12 | ||
13 | 1. Use `ninja -C build test` to run the unit tests. Some tests are skipped if | |
14 | no privileges are available, hence consider also running them with `sudo | |
15 | ninja -C build test`. A couple of unit tests are considered "unsafe" (as | |
16 | they change system state); to run those too, build with `meson | |
17 | -Dtests=unsafe`. Finally, some unit tests are considered to be very slow, | |
18 | build them too with `meson -Dslow-tests=true`. (Note that there are a couple | |
19 | of manual tests in addition to these unit tests.) | |
20 | ||
21 | 2. Use `./test/run-integration-tests.sh` to run the full integration test | |
22 | suite. This will build OS images with a number of integration tests and run | |
23 | them in nspawn and qemu. Requires root. | |
24 | ||
25 | 3. Use `./coccinelle/run-coccinelle.sh` to run all | |
26 | [Coccinelle](http://coccinelle.lip6.fr/) semantic patch scripts we ship. The | |
27 | output will show false positives, hence take it with a pinch of salt. | |
28 | ||
29 | 4. Use `./tools/find-double-newline.sh recdiff` to find double newlines. Use | |
30 | `./tools/find-double-newline.sh recpatch` to fix them. Take this with a grain | |
31 | of salt, in particular as we generally leave foreign header files we include in | |
32 | our tree unmodified, if possible. | |
33 | ||
34 | 5. Similar use `./tools/find-tabs.sh recdiff` to find TABs, and | |
35 | `./tools/find-tabs.sh recpatch` to fix them. (Again, grain of salt, foreign | |
36 | headers should usually be left unmodified.) | |
37 | ||
38 | 6. Use `ninja -C build check-api-docs` to compare the list of exported | |
39 | symbols of `libsystemd.so` and `libudev.so` with the list of man pages. Symbols | |
40 | lacking documentation are highlighted. | |
41 | ||
42 | 7. Use `ninja -C build hwdb-update` to automatically download and import the | |
43 | PCI, USB and OUI databases into hwdb. | |
44 | ||
45 | 8. Use `ninja -C build man/update-man-rules` to update the meson rules for | |
46 | building man pages automatically from the docbook XML files included in | |
47 | `man/`. | |
48 | ||
49 | 9. There are multiple CI systems in use that run on every github PR submission. | |
50 | ||
51 | 10. [Coverity](https://scan.coverity.com/) is analyzing systemd master in | |
52 | regular intervals. The reports are available | |
53 | [online](https://scan.coverity.com/projects/systemd). | |
54 | ||
55 | 11. [oss-fuzz](https://oss-fuzz.com/) is continuously fuzzing the | |
56 | codebase. Reports are available | |
57 | [online](https://oss-fuzz.com/v2/testcases?project=systemd). | |
58 | ||
59 | 12. Our tree includes `.editorconfig`, `.dir-locals.el` and `.vimrc` files, to | |
60 | ensure that editors follow the right indentiation styles automatically. | |
61 | ||
62 | 13. When building systemd from a git checkout the build scripts will | |
63 | automatically enable a git commit hook that ensures whitespace cleanliness. | |
64 | ||
65 | 14. [LGTM](https://lgtm.com/) analyzes every commit pushed to master. The list | |
66 | of active alerts can be found | |
67 | [here](https://lgtm.com/projects/g/systemd/systemd/alerts/?mode=list). | |
68 | ||
69 | 15. Each PR is automatically tested with [Address Sanitizer](https://clang.llvm.org/docs/AddressSanitizer.html) | |
70 | and [Undefined Behavior Sanitizer](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html). | |
71 | See [Testing systemd using sanitizers](https://systemd.io/TESTING_WITH_SANITIZERS) | |
72 | for more information. | |
73 | ||
74 | 16. Fossies provides [source code misspelling reports](https://fossies.org/features.html#codespell). | |
75 | The systemd report can be found [here](https://fossies.org/linux/test/systemd-master.tar.gz/codespell.html). | |
76 | ||
77 | Access to Coverity and oss-fuzz reports is limited. Please reach out to the | |
78 | maintainers if you need access. |