diff options
author | Jelle van der Waa <jvanderwaa@redhat.com> | 2023-01-13 17:33:12 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2023-01-19 21:57:06 +0100 |
commit | ad8858c1f7dbbf53f5b7da282173fb64cd46b5d1 (patch) | |
tree | 2cd13a0e8383f0144faa326c227fe5d78f7f0ef5 /test/units/testsuite-71.sh | |
parent | Merge pull request #26103 from lnussel/bootctl (diff) | |
download | systemd-ad8858c1f7dbbf53f5b7da282173fb64cd46b5d1.tar.xz systemd-ad8858c1f7dbbf53f5b7da282173fb64cd46b5d1.zip |
hostnamed: expose FirmwareDate as timestamp in dbus
Offer the firmware date as an epoch instead of the literal DMI string.
Closes #25679
Diffstat (limited to '')
-rwxr-xr-x | test/units/testsuite-71.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/units/testsuite-71.sh b/test/units/testsuite-71.sh index 2382cccb3a..221068f284 100755 --- a/test/units/testsuite-71.sh +++ b/test/units/testsuite-71.sh @@ -89,10 +89,51 @@ test_chassis() { fi } +restore_sysfs_dmi() { + umount /sys/class/dmi/id + rm -rf /run/systemd/system/systemd-hostnamed.service.d + systemctl daemon-reload + systemctl stop systemd-hostnamed +} + +test_firmware_date() { + # No DMI on s390x or ppc + if [[ ! -d /sys/class/dmi/id ]]; then + echo "/sys/class/dmi/id not found, skipping firmware date tests." + return 0 + fi + + trap restore_sysfs_dmi RETURN + + # Ignore /sys being mounted as tmpfs + mkdir -p /run/systemd/system/systemd-hostnamed.service.d/ + cat >/run/systemd/system/systemd-hostnamed.service.d/override.conf <<EOF +[Service] +Environment="SYSTEMD_DEVICE_VERIFY_SYSFS=0" +EOF + systemctl daemon-reload + + mount -t tmpfs none /sys/class/dmi/id + echo '1' > /sys/class/dmi/id/uevent + + echo '01/01/2000' > /sys/class/dmi/id/bios_date + systemctl stop systemd-hostnamed + assert_in '2000-01-01' "$(hostnamectl)" + + echo '2022' > /sys/class/dmi/id/bios_date + systemctl stop systemd-hostnamed + assert_not_in 'Firmware Date' "$(hostnamectl)" + + echo 'garbage' > /sys/class/dmi/id/bios_date + systemctl stop systemd-hostnamed + assert_not_in 'Firmware Date' "$(hostnamectl)" +} + : >/failed test_hostname test_chassis +test_firmware_date touch /testok rm /failed |