]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: change partition label to test if the outdated devlinks are removed 28255/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 5 Jul 2023 03:05:45 +0000 (12:05 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 5 Jul 2023 14:46:01 +0000 (23:46 +0900)
The change is intended to reproduce the issue #27983, though the
original issue is highly racy, and the test does not reproduce it
reliably. But, anyway, it is better to change the partition label to
test the devlink removal.

test/units/testsuite-64.sh

index ad502a229c108eaee7f1bb2b620f3e0f03ccec66..789f24f98d1ed02faf6adc5b4178339913a266f6 100755 (executable)
@@ -444,10 +444,14 @@ EOF
 }
 
 testcase_simultaneous_events_2() {
-    local disk expected i iterations key link num_part part partscript target timeout
+    local disk expected i iterations key link num_part part script_dir target timeout
     local -a devices symlinks
     local -A running
 
+    script_dir="$(mktemp --directory "/tmp/test-udev-storage.script.XXXXXXXXXX")"
+    # shellcheck disable=SC2064
+    trap "rm -rf '$script_dir'" RETURN
+
     if [[ -v ASAN_OPTIONS || "$(systemd-detect-virt -v)" == "qemu" ]]; then
         num_part=20
         iterations=1
@@ -469,13 +473,11 @@ testcase_simultaneous_events_2() {
         devices+=("$target")
     done
 
-    symlinks=("/dev/disk/by-partlabel/testlabel")
-
-    partscript="$(mktemp)"
-
-    cat >"$partscript" <<EOF
-$(for ((part = 1; part <= num_part; part++)); do printf 'name="testlabel", size=1M\n'; done)
+    for ((i = 1; i <= iterations; i++)); do
+        cat >"$script_dir/partscript-$i" <<EOF
+$(for ((part = 1; part <= num_part; part++)); do printf 'name="testlabel-%d", size=1M\n' "$i"; done)
 EOF
+    done
 
     echo "## $iterations iterations start: $(date '+%H:%M:%S.%N')"
     for ((i = 1; i <= iterations; i++)); do
@@ -491,7 +493,7 @@ EOF
         done
 
         for disk in {0..9}; do
-            udevadm lock --device="${devices[$disk]}" sfdisk -q -X gpt "${devices[$disk]}" <"$partscript" &
+            udevadm lock --device="${devices[$disk]}" sfdisk -q -X gpt "${devices[$disk]}" <"$script_dir/partscript-$i" &
             running[$disk]=$!
         done
 
@@ -500,7 +502,7 @@ EOF
             unset "running[$key]"
         done
 
-        udevadm wait --settle --timeout="$timeout" "${devices[@]}" "${symlinks[@]}"
+        udevadm wait --settle --timeout="$timeout" "${devices[@]}" "/dev/disk/by-partlabel/testlabel-$i"
     done
     echo "## $iterations iterations end: $(date '+%H:%M:%S.%N')"
 }