mirror of
https://github.com/systemd/systemd
synced 2024-07-21 18:24:38 +00:00
Merge pull request #32708 from DaanDeMeyer/fix-race
Fix race conditions in tests
This commit is contained in:
commit
0a9ce6251d
|
@ -10,6 +10,7 @@
|
|||
#include "bus-error.h"
|
||||
#include "bus-message.h"
|
||||
#include "bus-wait-for-jobs.h"
|
||||
#include "daemon-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "log.h"
|
||||
#include "missing_syscall.h"
|
||||
|
@ -152,6 +153,10 @@ int main(int argc, char *argv[]) {
|
|||
pids[i] = TAKE_PIDREF(pidref);
|
||||
}
|
||||
|
||||
r = sd_notify(false, NOTIFY_READY);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to send readiness notification: %m");
|
||||
|
||||
r = sd_event_loop(event);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to run event loop: %m");
|
||||
|
|
|
@ -2512,7 +2512,7 @@ static int item_do(
|
|||
fdaction_t action) {
|
||||
|
||||
struct stat st;
|
||||
int r = 0, q;
|
||||
int r = 0, q = 0;
|
||||
|
||||
assert(c);
|
||||
assert(i);
|
||||
|
@ -2547,9 +2547,10 @@ static int item_do(
|
|||
continue;
|
||||
|
||||
de_fd = openat(fd, de->d_name, O_NOFOLLOW|O_CLOEXEC|O_PATH);
|
||||
if (de_fd < 0)
|
||||
q = log_error_errno(errno, "Failed to open() file '%s': %m", de->d_name);
|
||||
else {
|
||||
if (de_fd < 0) {
|
||||
if (errno != -ENOENT)
|
||||
q = log_error_errno(errno, "Failed to open file '%s': %m", de->d_name);
|
||||
} else {
|
||||
_cleanup_free_ char *de_path = NULL;
|
||||
|
||||
de_path = path_join(path, de->d_name);
|
||||
|
|
|
@ -6,4 +6,4 @@ mkdir /sys/fs/cgroup/system.slice/delegated-cgroup-filtering.service/the_child
|
|||
|
||||
echo "parent_process: hello, world!"
|
||||
echo "parent_process: hello, people!"
|
||||
sleep .15
|
||||
sleep 2
|
||||
|
|
|
@ -72,7 +72,7 @@ run_and_list() {
|
|||
ls -lR "$out_dir"
|
||||
|
||||
if [[ -n "${environ:-}" ]]; then
|
||||
umount /proc/1/environ
|
||||
umount /proc/1/environ --lazy
|
||||
rm -f "$environ"
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ if ! grep -q pidfd_open /proc/kallsyms; then
|
|||
fi
|
||||
|
||||
systemd-run --unit test-aux-scope.service \
|
||||
-p Slice=aux.slice -p Type=exec -p TasksMax=99 -p CPUWeight=199 -p IPAccounting=yes \
|
||||
--service-type notify -p Slice=aux.slice -p TasksMax=99 -p CPUWeight=199 -p IPAccounting=yes \
|
||||
/usr/lib/systemd/tests/unit-tests/manual/test-aux-scope
|
||||
kill -s USR1 "$(systemctl show --value --property MainPID test-aux-scope.service)"
|
||||
|
||||
|
|
|
@ -32,8 +32,9 @@ systemd-mount --list --quiet
|
|||
|
||||
# Set up a simple block device for further tests
|
||||
dd if=/dev/zero of="$WORK_DIR/simple.img" bs=1M count=16
|
||||
mkfs.ext4 -L sd-mount-test "$WORK_DIR/simple.img"
|
||||
LOOP="$(losetup --show --find "$WORK_DIR/simple.img")"
|
||||
mkfs.ext4 -L sd-mount-test "$LOOP"
|
||||
udevadm wait --timeout 60 --settle "$LOOP"
|
||||
mkdir "$WORK_DIR/mnt"
|
||||
mount "$LOOP" "$WORK_DIR/mnt"
|
||||
touch "$WORK_DIR/mnt/foo.bar"
|
||||
|
@ -130,8 +131,9 @@ systemd-umount "$WORK_DIR/simple.img"
|
|||
# Create a vfat image, as ext4 doesn't support uid=/gid= fixating for all
|
||||
# files/directories
|
||||
dd if=/dev/zero of="$WORK_DIR/owner-vfat.img" bs=1M count=16
|
||||
mkfs.vfat -n owner-vfat "$WORK_DIR/owner-vfat.img"
|
||||
LOOP="$(losetup --show --find "$WORK_DIR/owner-vfat.img")"
|
||||
mkfs.vfat -n owner-vfat "$LOOP"
|
||||
udevadm wait --timeout 60 --settle "$LOOP"
|
||||
# Mount it and check the UID/GID
|
||||
[[ "$(stat -c "%U:%G" "$WORK_DIR/mnt")" == "root:root" ]]
|
||||
systemd-mount --owner=testuser "$LOOP" "$WORK_DIR/mnt"
|
||||
|
|
|
@ -85,5 +85,5 @@ PID1_ENVIRON="SYSTEMD_GETTY_AUTO=0" run_and_list "$GENERATOR_BIN" "$OUT_DIR"
|
|||
[[ "$(find "$OUT_DIR" ! -type d | wc -l)" -eq 0 ]]
|
||||
|
||||
# Cleanup
|
||||
umount /sys/class/tty/console/active
|
||||
umount /sys/class/tty/console/active --lazy
|
||||
rm -f "${DUMMY_CONSOLES[@]/#//dev/}" /dev/notatty99
|
||||
|
|
Loading…
Reference in a new issue