From: Joakim NohlgÄrd Date: Fri, 29 Dec 2023 14:06:50 +0000 (+0100) Subject: udevadm: Propagate return code from verb result X-Git-Tag: v256-rc1~1365^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ba340e2a75a0a16031fcb7efa05cfd250e859f17;p=thirdparty%2Fsystemd.git udevadm: Propagate return code from verb result udevadm lock did not propagate the return code from the child process because all positive values were treated as success. v2: Now 'udevadm test-builtin' ignores all positive return values from the builtin commands. Otherwise, as the hwdb builtin returns an positive value when a matching entry found, 'udevadm test-builtin hwdb' will fail. v3: Initialize partition table before calling 'sfdisk --delete'. Co-authored-by: Yu Watanabe --- diff --git a/src/udev/udevadm-test-builtin.c b/src/udev/udevadm-test-builtin.c index 5d1fafbd039..f5498a1e5b1 100644 --- a/src/udev/udevadm-test-builtin.c +++ b/src/udev/udevadm-test-builtin.c @@ -104,9 +104,12 @@ int builtin_main(int argc, char *argv[], void *userdata) { } r = udev_builtin_run(event, cmd, arg_command, true); - if (r < 0) + if (r < 0) { log_debug_errno(r, "Builtin command '%s' fails: %m", arg_command); + goto finish; + } + r = 0; finish: udev_builtin_exit(); return r; diff --git a/src/udev/udevadm.c b/src/udev/udevadm.c index 51dc041a29c..687b927f721 100644 --- a/src/udev/udevadm.c +++ b/src/udev/udevadm.c @@ -137,4 +137,4 @@ static int run(int argc, char *argv[]) { return udevadm_main(argc, argv); } -DEFINE_MAIN_FUNCTION(run); +DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run); diff --git a/test/units/testsuite-64.sh b/test/units/testsuite-64.sh index 81edb0ab7a1..65e5f6cd91f 100755 --- a/test/units/testsuite-64.sh +++ b/test/units/testsuite-64.sh @@ -396,6 +396,11 @@ EOF udevadm control --reload + # initialize partition table + for disk in {0..9}; do + echo 'label: gpt' | udevadm lock --device="${devices[$disk]}" sfdisk -q "${devices[$disk]}" + done + # Delete the partitions, immediately recreate them, wait for udev to settle # down, and then check if we have any dangling symlinks in /dev/disk/. Rinse # and repeat.