1
0
mirror of https://github.com/systemd/systemd synced 2025-11-20 17:24:45 +01:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Daan De Meyer
e8a0463c16
test: fixes for debian unstable and TEST-50-DISSECT (#39331)
Test failed in a weird way, turns out we don't use pipefail and an
intermediate command was moved to a different package so it wasn't in
the minimal image anymore. Add it, and use pipefail so in the future
it's easier to spot.
2025-10-16 08:45:46 +02:00
Zbigniew Jędrzejewski-Szmek
1929f43199 test-tar-extract: add a binary wrapping tar_x() for manual testing
We'll probably want to turn this into a test in the integration tests.
2025-10-16 08:22:33 +02:00
Luca Boccassi
0ce88a9132 test: call bash with -o pipefail when piping commands in TEST-50-DISSECT
We want the tests to fail if one of the intermediate commands fails,
otherwise it is hard to spot failures
2025-10-15 22:58:19 +01:00
Luca Boccassi
2a5e68e27d test: install bsdextrautils in debian minimal img
'rev' moved to bsdextrautils and TEST-50-DISSECT uses it, so it now
fails:

[   83.534905] bash[3581]: +++ grep '^now' /proc/timer_list
[   83.535479] bash[3582]: +++ cut '-d ' -f3
[   83.535774] bash[3583]: +++ rev
[   83.535774] bash[3583]: bash: line 1: rev: command not found
2025-10-15 22:54:51 +01:00
4 changed files with 51 additions and 8 deletions

View File

@ -7,6 +7,7 @@ Distribution=|ubuntu
[Content] [Content]
PrepareScripts=%D/mkosi/mkosi.conf.d/debian-ubuntu/systemd.prepare PrepareScripts=%D/mkosi/mkosi.conf.d/debian-ubuntu/systemd.prepare
Packages= Packages=
bsdextrautils
hostname hostname
iproute2 iproute2
mount mount

View File

@ -93,6 +93,10 @@ executables += [
'name' : 'systemd-import-generator', 'name' : 'systemd-import-generator',
'sources' : files('import-generator.c'), 'sources' : files('import-generator.c'),
}, },
test_template + {
'sources' : files('test-tar-extract.c'),
'type' : 'manual',
},
test_template + { test_template + {
'sources' : files('test-qcow2.c'), 'sources' : files('test-qcow2.c'),
'objects' : ['systemd-importd'], 'objects' : ['systemd-importd'],
@ -100,6 +104,7 @@ executables += [
'conditions' : ['HAVE_ZLIB'], 'conditions' : ['HAVE_ZLIB'],
'type' : 'manual', 'type' : 'manual',
}, },
] ]
install_data('org.freedesktop.import1.conf', install_data('org.freedesktop.import1.conf',

View File

@ -0,0 +1,37 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "fd-util.h"
#include "libarchive-util.h"
#include "main-func.h"
#include "tar-util.h"
#include "tests.h"
static int run(int argc, char **argv) {
int r;
test_setup_logging(LOG_DEBUG);
if (argc != 3)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Need two arguments exactly: <input> <output>");
r = dlopen_libarchive();
if (r < 0)
return r;
_cleanup_close_ int input_fd = open(argv[1], O_RDONLY | O_CLOEXEC);
if (input_fd < 0)
return log_error_errno(input_fd, "Cannot open %s: %m", argv[1]);
_cleanup_close_ int output_fd = open(argv[2], O_DIRECTORY | O_CLOEXEC);
if (output_fd < 0)
return log_error_errno(output_fd, "Cannot open %s: %m", argv[2]);
r = tar_x(input_fd, output_fd, /* flags= */ TAR_SELINUX);
if (r < 0)
return log_error_errno(r, "tar_x failed: %m");
return 0;
}
DEFINE_MAIN_FUNCTION(run);

View File

@ -472,8 +472,8 @@ RootImage=$MINIMAL_IMAGE.raw
ExtensionImages=/tmp/app0.raw /tmp/app1.raw:nosuid ExtensionImages=/tmp/app0.raw /tmp/app1.raw:nosuid
# Relevant only for sanitizer runs # Relevant only for sanitizer runs
UnsetEnvironment=LD_PRELOAD UnsetEnvironment=LD_PRELOAD
ExecStart=bash -c '/opt/script0.sh | grep ID' ExecStart=bash -o pipefail -c '/opt/script0.sh | grep ID'
ExecStart=bash -c '/opt/script1.sh | grep ID' ExecStart=bash -o pipefail -c '/opt/script1.sh | grep ID'
Type=oneshot Type=oneshot
RemainAfterExit=yes RemainAfterExit=yes
EOF EOF
@ -490,7 +490,7 @@ mkdir "$VDIR" "$EMPTY_VDIR"
ln -s /tmp/app0.raw "$VDIR/${VBASE}_0.raw" ln -s /tmp/app0.raw "$VDIR/${VBASE}_0.raw"
ln -s /tmp/app1.raw "$VDIR/${VBASE}_1.raw" ln -s /tmp/app1.raw "$VDIR/${VBASE}_1.raw"
systemd-run -P -p ExtensionImages="$VDIR -$EMPTY_VDIR -$NONEXISTENT_VDIR" bash -c '/opt/script1.sh | grep ID' systemd-run -P -p ExtensionImages="$VDIR -$EMPTY_VDIR -$NONEXISTENT_VDIR" bash -o pipefail -c '/opt/script1.sh | grep ID'
rm -rf "$VDIR" "$EMPTY_VDIR" rm -rf "$VDIR" "$EMPTY_VDIR"
@ -587,7 +587,7 @@ EnvironmentFile=-/usr/lib/systemd/systemd-asan-env
PrivateTmp=disconnected PrivateTmp=disconnected
BindPaths=/tmp/markers/ BindPaths=/tmp/markers/
ExtensionDirectories=-${VDIR} ExtensionDirectories=-${VDIR}
ExecStart=bash -x -c ' \\ ExecStart=bash -o pipefail -x -c ' \\
trap "{ \\ trap "{ \\
systemd-notify --reloading; \\ systemd-notify --reloading; \\
(ls /etc | grep marker || echo no-marker) >/tmp/markers/50g; \\ (ls /etc | grep marker || echo no-marker) >/tmp/markers/50g; \\
@ -628,7 +628,7 @@ EnvironmentFile=-/usr/lib/systemd/systemd-asan-env
PrivateTmp=disconnected PrivateTmp=disconnected
BindPaths=/tmp/markers/ BindPaths=/tmp/markers/
ExtensionImages=-$VDIR2 ExtensionImages=-$VDIR2
ExecStart=bash -x -c ' \\ ExecStart=bash -o pipefail -x -c ' \\
trap "{ \\ trap "{ \\
systemd-notify --reloading; \\ systemd-notify --reloading; \\
(ls /etc | grep marker || echo no-marker) >/tmp/markers/50h; \\ (ls /etc | grep marker || echo no-marker) >/tmp/markers/50h; \\
@ -666,7 +666,7 @@ BindPaths=/tmp/markers/
RootImage=$MINIMAL_IMAGE.raw RootImage=$MINIMAL_IMAGE.raw
ExtensionDirectories=-${VDIR} ExtensionDirectories=-${VDIR}
NotifyAccess=all NotifyAccess=all
ExecStart=bash -x -c ' \ ExecStart=bash -x -o pipefail -c ' \
trap '"'"' \ trap '"'"' \
now=\$\$(grep "^now" /proc/timer_list | cut -d" " -f3 | rev | cut -c 4- | rev); \ now=\$\$(grep "^now" /proc/timer_list | cut -d" " -f3 | rev | cut -c 4- | rev); \
stdbuf -o1K printf "RELOADING=1\\nMONOTONIC_USEC=\$\${now}\\n" | socat -t 5 - UNIX-SENDTO:\$\$NOTIFY_SOCKET; \ stdbuf -o1K printf "RELOADING=1\\nMONOTONIC_USEC=\$\${now}\\n" | socat -t 5 - UNIX-SENDTO:\$\$NOTIFY_SOCKET; \
@ -701,7 +701,7 @@ BindPaths=/tmp/markers/
RootDirectory=/tmp/vpickminimg RootDirectory=/tmp/vpickminimg
ExtensionDirectories=-${VDIR} ExtensionDirectories=-${VDIR}
NotifyAccess=all NotifyAccess=all
ExecStart=bash -x -c ' \ ExecStart=bash -x -o pipefail -c ' \
trap '"'"' \ trap '"'"' \
now=\$\$(grep "^now" /proc/timer_list | cut -d" " -f3 | rev | cut -c 4- | rev); \ now=\$\$(grep "^now" /proc/timer_list | cut -d" " -f3 | rev | cut -c 4- | rev); \
stdbuf -o1K printf "RELOADING=1\\nMONOTONIC_USEC=\$\${now}\\n" | socat -t 5 - UNIX-SENDTO:\$\$NOTIFY_SOCKET; \ stdbuf -o1K printf "RELOADING=1\\nMONOTONIC_USEC=\$\${now}\\n" | socat -t 5 - UNIX-SENDTO:\$\$NOTIFY_SOCKET; \
@ -731,7 +731,7 @@ RootImage=$MINIMAL_IMAGE.raw
ExtensionImages=-$VDIR2 /tmp/app0.raw ExtensionImages=-$VDIR2 /tmp/app0.raw
PrivateUsers=yes PrivateUsers=yes
NotifyAccess=all NotifyAccess=all
ExecStart=bash -x -c ' \ ExecStart=bash -x -o pipefail -c ' \
trap '"'"' \ trap '"'"' \
now=\$\$(grep "^now" /proc/timer_list | cut -d" " -f3 | rev | cut -c 4- | rev); \ now=\$\$(grep "^now" /proc/timer_list | cut -d" " -f3 | rev | cut -c 4- | rev); \
stdbuf -o1K printf "RELOADING=1\\nMONOTONIC_USEC=\$\${now}\\n" | socat -t 5 - UNIX-SENDTO:\$\$NOTIFY_SOCKET; \ stdbuf -o1K printf "RELOADING=1\\nMONOTONIC_USEC=\$\${now}\\n" | socat -t 5 - UNIX-SENDTO:\$\$NOTIFY_SOCKET; \