]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: drop Disk (Size|Free|Floor|Ceiling) fields prior comparing
authorFrantisek Sumsal <frantisek@sumsal.cz>
Sun, 19 Apr 2020 14:20:03 +0000 (16:20 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 21 Apr 2020 20:09:35 +0000 (22:09 +0200)
The disk attributes can take some time to update on certain filesystems,
so let's strip them from inputs of both `homectl` and `userdbctl` before
comparing them to avoid unexpected fails.

Also, switch from `cmp` to `diff` to make a potential test fail a bit more
debuggable.

Fixes: #14755
test/units/testsuite-46.sh

index 9ef9f30f1e9ac5149078fe7fd0d77081b32d863f..00bbdf507e62f79b4a4c2878dacbeebfe50fe2bd 100755 (executable)
@@ -9,9 +9,16 @@ if ! test -x /usr/bin/homectl ; then
 fi
 
 inspect() {
+        # As updating disk-size-related attributes can take some time on
+        # some filesystems, let's drop these fields before comparing the
+        # outputs to avoid unexpected fails. To see the full outputs of both
+        # homectl & userdbctl (for debugging purposes) drop the fields just
+        # before the comparison.
         homectl inspect $1 | tee /tmp/a
         userdbctl user $1 | tee /tmp/b
-        cmp /tmp/a /tmp/b
+
+        local PATTERN='/^\s*Disk (Size|Free|Floor|Ceiling):/d'
+        diff <(sed -r "$PATTERN" /tmp/a) <(sed -r "$PATTERN" /tmp/b)
         rm /tmp/a /tmp/b
 }