From 9e262ef92e40dc761675055866a421a4a4acc84b Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 14 May 2024 22:14:27 +0200 Subject: [PATCH] test: Enable TEST-54-CREDS on mkosi --- .../usr/lib/systemd/system/initrdcred.service | 9 +++++++ mkosi.images/system/mkosi.conf | 3 +++ test/TEST-54-CREDS/meson.build | 25 ++++++++++++++++++- .../systemd.extra-unit.my-service.service | 5 ++++ .../systemd.unit-dropin.my-service.service | 4 +++ ...dropin.my-service.service~30-named.service | 4 +++ test/TEST-55-OOMD/meson.build | 4 +-- test/meson.build | 10 ++++++++ 8 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 mkosi.images/system/initrd/mkosi.extra/usr/lib/systemd/system/initrdcred.service create mode 100644 test/TEST-54-CREDS/systemd.extra-unit.my-service.service create mode 100644 test/TEST-54-CREDS/systemd.unit-dropin.my-service.service create mode 100644 test/TEST-54-CREDS/systemd.unit-dropin.my-service.service~30-named.service diff --git a/mkosi.images/system/initrd/mkosi.extra/usr/lib/systemd/system/initrdcred.service b/mkosi.images/system/initrd/mkosi.extra/usr/lib/systemd/system/initrdcred.service new file mode 100644 index 00000000000..2c709bccc4f --- /dev/null +++ b/mkosi.images/system/initrd/mkosi.extra/usr/lib/systemd/system/initrdcred.service @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Unit] +Description=populate initrd credential dir for TEST-54-CREDS + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=sh -c "mkdir -m 0755 -p /run/credentials && mkdir -m 0700 /run/credentials/@initrd && umask 0077 && echo guatemala > /run/credentials/@initrd/myinitrdcred" diff --git a/mkosi.images/system/mkosi.conf b/mkosi.images/system/mkosi.conf index 4d3d2d9aa16..65e5de379fe 100644 --- a/mkosi.images/system/mkosi.conf +++ b/mkosi.images/system/mkosi.conf @@ -6,6 +6,9 @@ Dependencies= minimal-0 minimal-1 +InitrdInclude= + initrd/ + [Output] @Format=directory RepartDirectories=mkosi.repart diff --git a/test/TEST-54-CREDS/meson.build b/test/TEST-54-CREDS/meson.build index d53dbe562c5..8edb043a512 100644 --- a/test/TEST-54-CREDS/meson.build +++ b/test/TEST-54-CREDS/meson.build @@ -3,6 +3,29 @@ integration_tests += [ integration_test_template + { 'name' : fs.name(meson.current_source_dir()), - 'enabled' : false, + 'cmdline' : integration_test_template['cmdline'] + [ + 'systemd.set_credential=kernelcmdlinecred:uff', + 'systemd.set_credential=sysctl.extra:kernel.domainname=sysctltest', + 'systemd.set_credential=login.motd:hello', + 'systemd.set_credential=login.issue:welcome', + 'systemd.set_credential_binary=waldi:d29vb29mZmZ3dWZmZnd1ZmYK', + 'rd.systemd.import_credentials=no', + 'rd.systemd.wants=initrdcred.service', + ], + 'credentials' : integration_test_template['credentials'] + [ + 'mynspawncredential=strangevalue', + files('systemd.extra-unit.my-service.service'), + files('systemd.unit-dropin.my-service.service'), + files('systemd.unit-dropin.my-service.service~30-named.service'), + ], + 'qemu-args' : integration_test_template['qemu-args'] + [ + '-fw_cfg', 'name=opt/io.systemd.credentials/myqemucredential,string=othervalue', + '-smbios', 'type=11,value=io.systemd.credential:smbioscredential=magicdata', + '-smbios', 'type=11,value=io.systemd.credential.binary:binarysmbioscredential=bWFnaWNiaW5hcnlkYXRh', + '-smbios', 'type=11,value=io.systemd.credential.binary:sysusers.extra=dSBjcmVkdGVzdHVzZXIK', + '-smbios', 'type=11,value=io.systemd.credential.binary:tmpfiles.extra=ZiAvdG1wL3NvdXJjZWRmcm9tY3JlZGVudGlhbCAtIC0gLSAtIHRtcGZpbGVzc2VjcmV0Cg==', + '-smbios', 'type=11,value=io.systemd.credential.binary:fstab.extra=aW5qZWN0ZWQgL2luamVjdGVkIHRtcGZzIFgtbW91bnQubWtkaXIgMCAwCg==', + '-smbios', 'type=11,value=io.systemd.credential:getty.ttys.container=idontexist', + ], }, ] diff --git a/test/TEST-54-CREDS/systemd.extra-unit.my-service.service b/test/TEST-54-CREDS/systemd.extra-unit.my-service.service new file mode 100644 index 00000000000..e29d0ee3eb1 --- /dev/null +++ b/test/TEST-54-CREDS/systemd.extra-unit.my-service.service @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Service] +Type=oneshot +ExecStart=touch /tmp/unit-cred diff --git a/test/TEST-54-CREDS/systemd.unit-dropin.my-service.service b/test/TEST-54-CREDS/systemd.unit-dropin.my-service.service new file mode 100644 index 00000000000..279a941b1bc --- /dev/null +++ b/test/TEST-54-CREDS/systemd.unit-dropin.my-service.service @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Service] +ExecStart=touch /tmp/unit-dropin diff --git a/test/TEST-54-CREDS/systemd.unit-dropin.my-service.service~30-named.service b/test/TEST-54-CREDS/systemd.unit-dropin.my-service.service~30-named.service new file mode 100644 index 00000000000..67d87ca8802 --- /dev/null +++ b/test/TEST-54-CREDS/systemd.unit-dropin.my-service.service~30-named.service @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Service] +ExecStart=touch /tmp/unit-named-dropin diff --git a/test/TEST-55-OOMD/meson.build b/test/TEST-55-OOMD/meson.build index 9aef9165cfd..71014a3158a 100644 --- a/test/TEST-55-OOMD/meson.build +++ b/test/TEST-55-OOMD/meson.build @@ -3,8 +3,8 @@ integration_tests += [ integration_test_template + { 'name' : fs.name(meson.current_source_dir()), - 'mkosi-args' : integration_test_template['mkosi-args'] + [ - '--credential=@0@'.format(meson.current_source_dir() / 'systemd.unit-dropin.init.scope') + 'credentials' : integration_test_template['credentials'] + [ + files('systemd.unit-dropin.init.scope'), ] }, ] diff --git a/test/meson.build b/test/meson.build index 60d42efee65..2a07d120faf 100644 --- a/test/meson.build +++ b/test/meson.build @@ -290,6 +290,8 @@ integration_test_template = { 'after' : '', }, 'cmdline' : [], + 'credentials' : [], + 'qemu-args' : [], } testdata_subdirs = [ 'auxv', @@ -410,6 +412,14 @@ foreach integration_test : integration_tests ] endif + foreach credential : integration_test['credentials'] + integration_test_args += ['--credential', credential] + endforeach + + if integration_test['qemu-args'].length() > 0 + integration_test_args += ['--qemu-args=@0@'.format(' '.join(integration_test['qemu-args']))] + endif + integration_test_args += integration_test['mkosi-args'] integration_test_env = {} -- 2.47.3