]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
test(SYSTEMD): do not use test with globbing main
authorBenjamin Drung <benjamin.drung@canonical.com>
Mon, 3 Aug 2026 10:41:29 +0000 (12:41 +0200)
committerdevkontrol <dev@kontrol.dev>
Mon, 3 Aug 2026 13:51:29 +0000 (09:51 -0400)
There might be multiple files matching the globbing as it can be seen on
`arch:latest`:

```
./test.sh: line 49: [: /usr/lib/libfido2.so.1: binary operator expected
```

Use `compgen` to check if the glob pattern matches one or more files
without failing on multiple matches.

Follow-up for 48e4665c97b3c71f485b95426e5bf00dae3ab1ab

test/TEST-40-SYSTEMD/test.sh

index bbec030d2f770bad619c215ce91f4347601c0ee5..117ae80f7f9bd06a993938591ab1f59895e48bc7 100755 (executable)
@@ -46,7 +46,7 @@ test_setup() {
 
     # shellcheck disable=SC2144 # We're not installing multilib libfido2, so
     # glob will only match once. More matches would break the test anyway.
-    if is_systemd_version_greater_or_equal 257 && [ -e /usr/lib*/libfido2.so.1 ] \
+    if is_systemd_version_greater_or_equal 257 && compgen -G /usr/lib*/libfido2.so.1 > /dev/null \
         && ! lsinitrd "$TESTDIR"/initramfs.testing | grep -E ' usr/lib[^/]*/libfido2\.so\.1\b' > /dev/null; then
         echo "Error: libfido2.so.1 should have been included in the initramfs" >&2
         return 1