mirror of
https://github.com/systemd/systemd
synced 2026-04-25 08:25:12 +02:00
Compare commits
3 Commits
70e723c000
...
5662811e34
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5662811e34 | ||
|
|
98f8c31638 | ||
|
|
b1aca4da60 |
@ -17,6 +17,7 @@ struct state {
|
||||
int rcode;
|
||||
const char *error_message;
|
||||
const char *success_message;
|
||||
const char *eexist_message;
|
||||
};
|
||||
|
||||
static int generic_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
|
||||
@ -30,7 +31,9 @@ static int generic_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userda
|
||||
errno = 0;
|
||||
|
||||
r = sd_netlink_message_get_errno(m);
|
||||
if (r < 0)
|
||||
if (r == -EEXIST && s->eexist_message)
|
||||
log_debug_errno(r, "%s", s->eexist_message);
|
||||
else if (r < 0)
|
||||
log_debug_errno(r, "%s: %m", s->error_message);
|
||||
else
|
||||
log_debug("%s", s->success_message);
|
||||
@ -157,9 +160,11 @@ int loopback_setup(void) {
|
||||
struct state state_4 = {
|
||||
.error_message = "Failed to add address 127.0.0.1 to loopback interface",
|
||||
.success_message = "Successfully added address 127.0.0.1 to loopback interface",
|
||||
.eexist_message = "127.0.0.1 has already been added to loopback interface",
|
||||
}, state_6 = {
|
||||
.error_message = "Failed to add address ::1 to loopback interface",
|
||||
.success_message = "Successfully added address ::1 to loopback interface",
|
||||
.eexist_message = "::1 has already been added to loopback interface",
|
||||
}, state_up = {
|
||||
.error_message = "Failed to bring loopback interface up",
|
||||
.success_message = "Successfully brought loopback interface up",
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
#include "device-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fs-util.h"
|
||||
#include "inotify-util.h"
|
||||
#include "parse-util.h"
|
||||
#include "path-util.h"
|
||||
@ -48,22 +49,25 @@ static int check_device(const char *path) {
|
||||
|
||||
assert(path);
|
||||
|
||||
if (arg_wait_until == WAIT_UNTIL_REMOVED) {
|
||||
r = laccess(path, F_OK);
|
||||
if (r == -ENOENT)
|
||||
return true;
|
||||
if (r < 0)
|
||||
return r;
|
||||
return false;
|
||||
}
|
||||
|
||||
r = sd_device_new_from_path(&dev, path);
|
||||
if (r == -ENODEV)
|
||||
return arg_wait_until == WAIT_UNTIL_REMOVED;
|
||||
return false;
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
switch (arg_wait_until) {
|
||||
case WAIT_UNTIL_INITIALIZED:
|
||||
if (arg_wait_until == WAIT_UNTIL_INITIALIZED)
|
||||
return sd_device_get_is_initialized(dev);
|
||||
case WAIT_UNTIL_ADDED:
|
||||
return true;
|
||||
case WAIT_UNTIL_REMOVED:
|
||||
return false;
|
||||
default:
|
||||
assert_not_reached();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool check(void) {
|
||||
|
||||
@ -489,7 +489,7 @@ testcase_iscsi_lvm() {
|
||||
}
|
||||
|
||||
testcase_long_sysfs_path() {
|
||||
local link logfile mpoint
|
||||
local cursor link logfile mpoint
|
||||
local expected_symlinks=(
|
||||
"/dev/disk/by-label/data_vol"
|
||||
"/dev/disk/by-label/swap_vol"
|
||||
@ -500,6 +500,12 @@ testcase_long_sysfs_path() {
|
||||
"/dev/disk/by-uuid/deadbeef-dead-dead-beef-222222222222"
|
||||
)
|
||||
|
||||
# Create a cursor file to skip messages generated by udevd in initrd, as it
|
||||
# might not be the same up-to-date version as we currently run (hence generating
|
||||
# messages we check for later and making the test fail)
|
||||
cursor="$(mktemp)"
|
||||
journalctl --cursor-file="${cursor:?}" -n0 -q
|
||||
|
||||
# Make sure the test device is connected and show its "wonderful" path
|
||||
stat /sys/block/vda
|
||||
readlink -f /sys/block/vda/dev
|
||||
@ -526,13 +532,20 @@ testcase_long_sysfs_path() {
|
||||
udevadm settle
|
||||
|
||||
logfile="$(mktemp)"
|
||||
[[ "$(journalctl -b -q --no-pager -o short-monotonic -p info --grep "Device path.*vda.?' too long to fit into unit name" | wc -l)" -eq 0 ]]
|
||||
# Check state of affairs after https://github.com/systemd/systemd/pull/22759
|
||||
# Note: can't use `--cursor-file` here, since we don't want to update the cursor
|
||||
# after using it
|
||||
[[ "$(journalctl --after-cursor="$(<"$cursor")" -q --no-pager -o short-monotonic -p info --grep "Device path.*vda.?' too long to fit into unit name" | wc -l)" -eq 0 ]]
|
||||
[[ "$(journalctl --after-cursor="$(<"$cursor")" -q --no-pager -o short-monotonic --grep "Unit name .*vda.?\.device\" too long, falling back to hashed unit name" | wc -l)" -gt 0 ]]
|
||||
# Check if the respective "hashed" units exist and are active (plugged)
|
||||
systemctl status --no-pager "$(readlink -f /sys/block/vda/vda1)"
|
||||
systemctl status --no-pager "$(readlink -f /sys/block/vda/vda2)"
|
||||
# Make sure we don't unnecessarily spam the log
|
||||
{ journalctl -b -q --no-pager -o short-monotonic -p info --grep "/sys/devices/.+/vda[0-9]?" _PID=1 + UNIT=systemd-udevd.service || :;} | tee "$logfile"
|
||||
[[ "$(wc -l <"$logfile")" -lt 10 ]]
|
||||
|
||||
: >/etc/fstab
|
||||
rm -fr "${logfile:?}" "${mpoint:?}"
|
||||
rm -fr "${cursor:?}" "${logfile:?}" "${mpoint:?}"
|
||||
}
|
||||
|
||||
testcase_mdadm_basic() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user