1--- 2title: Code Quality Tools 3category: Contributing 4layout: default 5SPDX-License-Identifier: LGPL-2.1-or-later 6--- 7 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 141. Use `meson test -C build` to run the unit tests. Some tests are skipped if 15 no privileges are available, hence consider also running them with `sudo 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 18 -Dtests=unsafe`. Finally, some unit tests are considered to be very slow, 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…".) 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 26 them in nspawn and qemu. Requires root. 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 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 43 lacking documentation are highlighted. 44 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. 48 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/`. 51 529. There are multiple CI systems in use that run on every github pull request 53 submission or update. 54 5510. [Coverity](https://scan.coverity.com/) is analyzing systemd `main` branch 56 in regular intervals. The reports are available 57 [online](https://scan.coverity.com/projects/systemd). 58 5911. [oss-fuzz](https://oss-fuzz.com/) is continuously fuzzing the 60 codebase. Reports are available 61 [online](https://oss-fuzz.com/v2/testcases?project=systemd). 62 6312. Our tree includes `.editorconfig`, `.dir-locals.el` and `.vimrc` files, to 64 ensure that editors follow the right indentiation styles automatically. 65 6613. When building systemd from a git checkout the build scripts will 67 automatically enable a git commit hook that ensures whitespace cleanliness. 68 6914. [LGTM](https://lgtm.com/) analyzes every commit pushed to `main`. The list 70 of active alerts can be found 71 [here](https://lgtm.com/projects/g/systemd/systemd/alerts/?mode=list). 72 7315. Each PR is automatically tested with [Address Sanitizer](https://clang.llvm.org/docs/AddressSanitizer.html) 74 and [Undefined Behavior Sanitizer](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html). 75 See [Testing systemd using sanitizers](TESTING_WITH_SANITIZERS.md) 76 for more information. 77 7816. Fossies provides [source code misspelling reports](https://fossies.org/features.html#codespell). 79 The systemd report can be found [here](https://fossies.org/linux/misc/systemd/codespell.html). 80 81Access to Coverity and oss-fuzz reports is limited. Please reach out to the 82maintainers if you need access. 83