1
0
mirror of https://github.com/systemd/systemd synced 2026-03-13 08:34:47 +01:00

Compare commits

...

5 Commits

Author SHA1 Message Date
Lennart Poettering
a53e369786
tests: don't use dd anymore for allocating empty test disk images (#40583) 2026-02-06 21:03:55 +01:00
Lennart Poettering
43ef7c944c CODING_STYLE: document how to handle kernel compat
Let's define a way how to mark codepaths that are subject to
deletion once the kernel baseline reaches a certain version, to make it
easier to find these cases.

WHile we are at it, introuce a whole section in CODING_STYLE about
kernel version compat.

I followed the new scheme in #39621, but we can merge the coding style
guidelines on this already.
2026-02-06 21:01:37 +01:00
Lennart Poettering
0c9de6daee inhibit: drop redundant table_set_header() caller
The immediately following table_print_with_pager() call already
processes arg_legend, no need to do this manually first.
2026-02-06 20:10:24 +01:00
Lennart Poettering
ab89fad427 test: bump disk sizes for some test cases
In my testing I switched building my locally run CI integration tests to
ArchLinux and realized that for that the default sizes don't work
anymore, the images are larger than the space allocated. Let's bump the
size by 50% for the relevant disk images.
2026-02-06 18:19:33 +01:00
Lennart Poettering
dd2676c1ab tests: don't use "dd" to allocate empty files
Let's use truncate -s … to create empty files (if they can be sparse)

Let's use fallocate -l … to create empty non-sparse files.

This should reduce the disk footprint of our tests a bit, given that in
most cases we won't use the allocate disk space in full, not even
remotely.
2026-02-06 18:19:33 +01:00
11 changed files with 47 additions and 14 deletions

View File

@ -1033,3 +1033,38 @@ SPDX-License-Identifier: LGPL-2.1-or-later
- Never use `grep -q` in a pipeline, use `grep >/dev/null` instead. The former
will generate `SIGPIPE` for the previous command in the pipeline when it finds
a match which will cause the test to fail unexpectedly.
## Kernel Version Dependencies
- For entirely new functionality it's fine to rely on features of very recent
(released!) kernel versions. If a feature is added to the upstream kernel,
and a stable release is made, then it's immediately OK to merge *new*
functionality into systemd relying on it, as long as that functionality is
optional. (In some cases, it might be OK to merge a feature into systemd
slightly before the final kernel release that it is based on, as long as the
kernel development cycle has already progressed far enough that the feature
is unlikely to be still reverted for example once RC2 of the kernel release
has been released.)
- For components that already have been released in a stable version
compatibility with older kernels must be retained, down to the "minimum
baseline" version as listed in the README, or the version current when the
component was added to our tree, whichever is newer.
- When adding a fallback path, please avoid checking for kernel versions, as
downstream distributions tend to backport features, and version checks are
not great replacements for feature checks hence.
- When adding a compatibility code path for an older kernel version, please add
a comment in the following style to the relevant codepath:
```c
// FIXME: This compatibility code path shall be removed once kernel X.Y
// becomes the new minimal baseline
```
When this syntax is followed we'll have an easier time tracking down these
codepaths and removing them when bumping baselines.
- Whenever support for a new kernel API feature is added, please update the
kernel feature/version list in README as well (as part of the same PR).

View File

@ -153,8 +153,6 @@ static int print_inhibitors(sd_bus *bus) {
if (r < 0)
return table_log_sort_error(r);
table_set_header(table, arg_legend);
r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend);
if (r < 0)
return r;

View File

@ -190,7 +190,7 @@ test ! -d /var/lib/machines/.hidden1
# Prepare a simple raw container
mkdir -p /tmp/mnt
dd if=/dev/zero of=/var/tmp/container.raw bs=1M count=256
truncate -s 384M /var/tmp/container.raw
mkfs.ext4 /var/tmp/container.raw
mount -o loop /var/tmp/container.raw /tmp/mnt
cp -r /var/lib/machines/container1/* /tmp/mnt

View File

@ -77,7 +77,7 @@ testcase_sanity() {
create_dummy_container "$template"
# Create a simple image from the just created container template
image="$(mktemp /var/lib/machines/TEST-13-NSPAWN.image-XXX.img)"
dd if=/dev/zero of="$image" bs=1M count=256
truncate -s 384M "$image"
mkfs.ext4 "$image"
mkdir -p /mnt
mount -o loop "$image" /mnt
@ -810,7 +810,7 @@ testcase_rootidmap() {
root="$(mktemp -d /var/lib/machines/TEST-13-NSPAWN.rootidmap-path.XXX)"
# Create ext4 image, as ext4 supports idmapped-mounts.
mkdir -p /tmp/rootidmap/bind
dd if=/dev/zero of=/tmp/rootidmap/ext4.img bs=4k count=2048
truncate -s $((4096*2048)) /tmp/rootidmap/ext4.img
mkfs.ext4 /tmp/rootidmap/ext4.img
mount /tmp/rootidmap/ext4.img /tmp/rootidmap/bind
trap "rootidmap_cleanup /tmp/rootidmap/" RETURN
@ -854,7 +854,7 @@ testcase_owneridmap() {
root="$(mktemp -d /var/lib/machines/TEST-13-NSPAWN.owneridmap-path.XXX)"
# Create ext4 image, as ext4 supports idmapped-mounts.
mkdir -p /tmp/owneridmap/bind
dd if=/dev/zero of=/tmp/owneridmap/ext4.img bs=4k count=2048
truncate -s $((4096*2048)) /tmp/owneridmap/ext4.img
mkfs.ext4 /tmp/owneridmap/ext4.img
mount /tmp/owneridmap/ext4.img /tmp/owneridmap/bind
trap "owneridmap_cleanup /tmp/owneridmap/" RETURN

View File

@ -25,7 +25,7 @@ netdev=hoge
ip link add $netdev type dummy
blk="$(mktemp)"
dd if=/dev/zero of="$blk" bs=1M count=1
truncate -s 1M "$blk"
loopdev="$(losetup --show -f "$blk")"
# Wait for devices created in the above being processed.

View File

@ -153,7 +153,7 @@ root_size="$(du --apparent-size -k "$MINIMAL_IMAGE.raw" | cut -f1)"
verity_size="$(du --apparent-size -k "$MINIMAL_IMAGE.verity" | cut -f1)"
signature_size=4
# 4MB seems to be the minimum size blkid will accept, below that probing fails
dd if=/dev/zero of="$MINIMAL_IMAGE.gpt" bs=512 count=$((8192+root_size*2+verity_size*2+signature_size*2))
truncate -s $(((8192+root_size*2+verity_size*2+signature_size*2)*512)) "$MINIMAL_IMAGE.gpt"
# sfdisk seems unhappy if the size overflows into the next unit, eg: 1580KiB will be interpreted as 1MiB
# so do some basic rounding up if the minimal image is more than 1 MB
if [[ "$root_size" -ge 1024 ]]; then

View File

@ -26,7 +26,7 @@ if systemd-detect-virt --vm --quiet; then
if [[ "$(findmnt -n -o FSTYPE /)" == btrfs ]]; then
btrfs filesystem mkswapfile -s 64M /swapfile
else
dd if=/dev/zero of=/swapfile bs=1M count=64
fallocate -l 64M /swapfile
chmod 0600 /swapfile
mkswap /swapfile
fi

View File

@ -1708,7 +1708,7 @@ testcase_btrfs_compression() {
# Must not be in tmpfs due to exclusions. It also must be large and
# compressible so that the compression check succeeds later.
src=/etc/test-source-file
dd if=/dev/zero of="$src" bs=1M count=1 2>/dev/null
fallocate -l 1M "$src"
tee "$defs/btrfs-compressed.conf" <<EOF
[Partition]

View File

@ -1013,7 +1013,7 @@ testcase_iscsi_lvm() {
udevadm wait --settle --timeout=30 "${devices[0]}"
mount "${devices[0]}" "$mpoint"
for i in {1..4}; do
dd if=/dev/zero of="$mpoint/lun$i.img" bs=1M count=32
truncate -s 32M "$mpoint/lun$i.img"
done
# Initialize a new iSCSI target <$target_name> consisting of 4 LUNs, each
# backed by a file

View File

@ -48,8 +48,8 @@ EOF
udevadm control --reload
TMP_DIR="$(mktemp -d -t -p / integrity.tmp.XXXXXX)"
dd if=/dev/zero of="${TMP_DIR}/image" bs=1048576 count=64
dd if=/dev/zero of="${TMP_DIR}/data" bs=1048576 count=64
truncate -s 64M "${TMP_DIR}/image"
truncate -s 64M "${TMP_DIR}/data"
LOOP="$(losetup --show -f "${TMP_DIR}/image")"
udevadm wait --timeout=30 --settle "${LOOP}"

View File

@ -43,7 +43,7 @@ test -e "$WORK_DIR/upper/foo"
systemd-umount "$WORK_DIR/overlay"
# Set up a simple block device for further tests
dd if=/dev/zero of="$WORK_DIR/simple.img" bs=1M count=16
truncate -s 16M "$WORK_DIR/simple.img"
mkfs.ext4 -L sd-mount-test "$WORK_DIR/simple.img"
LOOP="$(losetup --show --find "$WORK_DIR/simple.img")"
udevadm wait --timeout=60 --settle "$LOOP"