]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - HACKING
Merge pull request #8025 from sourcejedi/pid1_journal_or2
[thirdparty/systemd.git] / HACKING
diff --git a/HACKING b/HACKING
index 3ee1c7e340a8297e7063b89c42400b79bfea0360..e9a159ba9f9033bdbd0afc1a5f0047e637286bd1 100644 (file)
--- a/HACKING
+++ b/HACKING
@@ -11,6 +11,15 @@ CODING_STYLE for details. Also have a look at our Contribution Guidelines:
 
         https://github.com/systemd/systemd/blob/master/.github/CONTRIBUTING.md
 
+When adding new functionality, tests should be added. For shared functionality
+(in src/basic and src/shared) unit tests should be sufficient. The general
+policy is to keep tests in matching files underneath src/test,
+e.g. src/test/test-path-util.c contains tests for any functions in
+src/basic/path-util.c. If adding a new source file, consider adding a matching
+test executable. For features at a higher level, tests in src/test/ are very
+strongly recommended. If that is no possible, integration tests in test/ are
+encouraged.
+
 Please always test your work before submitting a PR. For many of the components
 of systemd testing is straight-forward as you can simply compile systemd and
 run the relevant tool from the build directory.
@@ -30,7 +39,7 @@ systemd-nspawn or in an UEFI-capable VM:
 
 or:
 
-        # qemu-kvm -m 512 -smp 2 -bios /usr/share/edk2/ovmf/OVMF_CODE.fd -hda image.raw
+        # qemu-system-x86_64 -enable-kvm -m 512 -smp 2 -bios /usr/share/edk2/ovmf/OVMF_CODE.fd -hda image.raw
 
 Every time you rerun the "mkosi" command a fresh image is built, incorporating
 all current changes you made to the project tree.
@@ -51,18 +60,57 @@ systemd's build dependencies:
 Putting this all together, here's a series of commands for preparing a patch
 for systemd (this example is for Fedora):
 
+        $ sudo dnf builddep systemd            # install build dependencies
+        $ sudo dnf install mkosi               # install tool to quickly build images
         $ git clone https://github.com/systemd/systemd.git
         $ cd systemd
         $ vim src/core/main.c                  # or wherever you'd like to make your changes
-        $ dnf builddep systemd                 # install build dependencies
-        $ ./autogen.sh c                       # configure the source tree
-        $ make -j `nproc`                      # build it locally, see if everything compiles fine
+        $ meson build                          # configure the build
+        $ ninja -C build                       # build it locally, see if everything compiles fine
+        $ ninja -C build test                  # run some simple regression tests
         $ sudo mkosi                           # build a test image
         $ sudo systemd-nspawn -bi image.raw    # boot up the test image
         $ git add -p                           # interactively put together your patch
         $ git commit                           # commit it
-        $ ...
+        $ git push REMOTE HEAD:refs/heads/BRANCH
+                                               # where REMOTE is your "fork" on github
+                                               # and BRANCH is a branch name.
 
-And after that, please submit your branch as PR to systemd via github.
+And after that, head over to your repo on github and click "Compare & pull request"
 
 Happy hacking!
+
+
+FUZZERS
+
+systemd includes fuzzers in src/fuzz that use libFuzzer and are automatically
+run by OSS-Fuzz (https://github.com/google/oss-fuzz) with sanitizers. To add a
+fuzz target, create a new src/fuzz/fuzz-foo.c file with a LLVMFuzzerTestOneInput
+function and add it to the list in src/fuzz/meson.build.
+
+Whenever possible, a seed corpus and a dictionary should also be added with new
+fuzz targets. The dictionary should be named src/fuzz/fuzz-foo.dict and the seed
+corpus should be built and exported as $OUT/fuzz-foo_seed_corpus.zip in
+scripts/oss-fuzz.sh.
+
+The fuzzers can be built locally if you have libFuzzer installed by running
+scripts/oss-fuzz.sh. You should also confirm that the fuzzer runs in the
+OSS-Fuzz environment by checking out the OSS-Fuzz repo, and then running
+commands like this:
+
+        python infra/helper.py build_image systemd
+        python infra/helper.py build_fuzzers --sanitizer memory systemd ../systemd
+        python infra/helper.py run_fuzzer systemd fuzz-foo
+
+If you find a bug that impacts the security of systemd, please follow the
+guidance in .github/CONTRIBUTING.md on how to report a security vulnerability.
+
+For more details on building fuzzers and integrating with OSS-Fuzz, visit:
+
+        https://github.com/google/oss-fuzz/blob/master/docs/new_project_guide.md
+
+        https://llvm.org/docs/LibFuzzer.html
+
+        https://github.com/google/fuzzer-test-suite/blob/master/tutorial/libFuzzerTutorial.md
+
+        https://chromium.googlesource.com/chromium/src/testing/libfuzzer/+/HEAD/efficient_fuzzer.md