]> git.ipfire.org Git - thirdparty/systemd.git/blame - docs/CODE_QUALITY.md
Merge pull request #32520 from YHNdnzj/sd-daemon-followup
[thirdparty/systemd.git] / docs / CODE_QUALITY.md
CommitLineData
c3e270f4
FB
1---
2title: Code Quality Tools
4cdca0af 3category: Contributing
b41a3f66 4layout: default
0aff7b75 5SPDX-License-Identifier: LGPL-2.1-or-later
c3e270f4
FB
6---
7
7c2c028c
LP
8# Code Quality Tools
9
10The systemd project has a number of code quality tools set up in the source
11tree and on the github infrastructure. Here's an incomprehensive list of the
12available functionality:
13
8b08be40 141. Use `meson test -C build` to run the unit tests. Some tests are skipped if
7c2c028c 15 no privileges are available, hence consider also running them with `sudo
8b08be40
LP
16 meson test -C build`. A couple of unit tests are considered "unsafe" (as
17 they change system state); to run those too, build with `meson setup
7c2c028c 18 -Dtests=unsafe`. Finally, some unit tests are considered to be very slow,
8b08be40
LP
19 build them too with `meson setup -Dslow-tests=true`. (Note that there are a
20 couple of manual tests in addition to these unit tests.) (Also note: you can
21 change these flags for an already set up build tree, too, with "meson
22 configure -C build -D…".)
7c2c028c
LP
23
242. Use `./test/run-integration-tests.sh` to run the full integration test
25 suite. This will build OS images with a number of integration tests and run
bed1feaf 26 them using `systemd-nspawn` and `qemu`. Requires root.
7c2c028c
LP
27
283. Use `./coccinelle/run-coccinelle.sh` to run all
29 [Coccinelle](http://coccinelle.lip6.fr/) semantic patch scripts we ship. The
30 output will show false positives, hence take it with a pinch of salt.
31
324. Use `./tools/find-double-newline.sh recdiff` to find double newlines. Use
33 `./tools/find-double-newline.sh recpatch` to fix them. Take this with a grain
34 of salt, in particular as we generally leave foreign header files we include in
35 our tree unmodified, if possible.
36
375. Similar use `./tools/find-tabs.sh recdiff` to find TABs, and
38 `./tools/find-tabs.sh recpatch` to fix them. (Again, grain of salt, foreign
39 headers should usually be left unmodified.)
40
e8a68817
ZJS
416. Use `ninja -C build check-api-docs` to compare the list of exported symbols
42 of `libsystemd.so` and `libudev.so` with the list of man pages. Symbols
7c2c028c
LP
43 lacking documentation are highlighted.
44
e8a68817
ZJS
457. Use `ninja -C build update-hwdb` and `ninja -C build update-hwdb-autosuspend`
46 to automatically download and import the PCI, USB, and OUI databases and the
47 autosuspend quirks into the hwdb.
7c2c028c 48
e8a68817
ZJS
498. Use `ninja -C build update-man-rules` to update the meson rules for building
50 man pages automatically from the docbook XML files included in `man/`.
7c2c028c 51
e8a68817
ZJS
529. There are multiple CI systems in use that run on every github pull request
53 submission or update.
7c2c028c 54
df1f621b
ZJS
5510. [Coverity](https://scan.coverity.com/) is analyzing systemd `main` branch
56 in regular intervals. The reports are available
7c2c028c
LP
57 [online](https://scan.coverity.com/projects/systemd).
58
7d7c92ef 5911. [OSS-Fuzz](https://github.com/google/oss-fuzz) is continuously fuzzing the
7c2c028c 60 codebase. Reports are available
7d7c92ef
EV
61 [online](https://oss-fuzz.com/testcases?project=systemd&open=yes).
62 It also builds
63 [coverage reports](https://oss-fuzz.com/coverage-report/job/libfuzzer_asan_systemd/latest)
64 daily.
7c2c028c 65
8b9e4b21 6612. Our tree includes `.editorconfig`, `.dir-locals.el` and `.vimrc` files, to
5cadf58e 67 ensure that editors follow the right indentiation styles automatically.
8b9e4b21
LP
68
6913. When building systemd from a git checkout the build scripts will
5cadf58e 70 automatically enable a git commit hook that ensures whitespace cleanliness.
8b9e4b21 71
0b0cdb16
YW
7214. [CodeQL](https://codeql.github.com/) analyzes each PR and every commit
73 pushed to `main`. The list of active alerts can be found
74 [here](https://github.com/systemd/systemd/security/code-scanning).
8cc9d188 75
c9a95378
FS
7615. Each PR is automatically tested with [Address Sanitizer](https://clang.llvm.org/docs/AddressSanitizer.html)
77 and [Undefined Behavior Sanitizer](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html).
0d592a5e 78 See [Testing systemd using sanitizers](/TESTING_WITH_SANITIZERS)
c9a95378
FS
79 for more information.
80
2f0a427b 8116. Fossies provides [source code misspelling reports](https://fossies.org/features.html#codespell).
df1f621b 82 The systemd report can be found [here](https://fossies.org/linux/misc/systemd/codespell.html).
2f0a427b 83
8cc9d188
EV
84Access to Coverity and oss-fuzz reports is limited. Please reach out to the
85maintainers if you need access.