]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
overlay/026: Fix test expectation for newer kernels
authorAlexander Larsson <alexl@redhat.com>
Wed, 22 Nov 2023 15:20:13 +0000 (17:20 +0200)
committerZorro Lang <zlang@kernel.org>
Sat, 9 Dec 2023 05:52:36 +0000 (13:52 +0800)
The test checks the expectaion from old kernels that set/get of
trusted.overlay.* xattrs is not supported on an overlayfs filesystem.

New kernels support set/get xattr of trusted.overlay.* xattrs, so adapt
the test to check that either both set and get work on new kernel, or
neither work on old kernel.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/overlay
tests/overlay/026
tests/overlay/026.out

index 7004187f2c53837f9c5162de5cb1666f9f46d2e4..8f2752286302e87f733d4cbec686f41accd94ab7 100644 (file)
@@ -201,6 +201,25 @@ _require_scratch_overlay_features()
        _scratch_unmount
 }
 
+_check_scratch_overlay_xattr_escapes()
+{
+       local testfile=$1
+
+       touch $testfile
+       ! ($GETFATTR_PROG -n trusted.overlay.foo $testfile 2>&1 | grep -E -q "not (permitted|supported)")
+}
+
+_require_scratch_overlay_xattr_escapes()
+{
+       _scratch_mkfs > /dev/null 2>&1
+       _scratch_mount
+
+        _check_scratch_overlay_xattr_escapes $SCRATCH_MNT/file || \
+                  _notrun "xattr escaping is not supported by overlay"
+
+       _scratch_unmount
+}
+
 _require_scratch_overlay_verity()
 {
        local lowerdirs="$OVL_BASE_SCRATCH_MNT/$OVL_UPPER:$OVL_BASE_SCRATCH_MNT/$OVL_LOWER"
index 77030d20013e9ece77f899f819f9b60145054756..25c70bc870c0931cc6a3c6d56c368f13e057b677 100755 (executable)
@@ -52,26 +52,42 @@ touch $SCRATCH_MNT/testf1
 # getfattr    ok         no attr     ok    ok
 #
 $SETFATTR_PROG -n "trusted.overlayfsrz" -v "n" \
-  $SCRATCH_MNT/testf0 2>&1 | _filter_scratch
+  $SCRATCH_MNT/testf0 2>&1 | tee -a $seqres.full | _filter_scratch
 
 _getfattr --absolute-names -n "trusted.overlayfsrz" \
-  $SCRATCH_MNT/testf0 2>&1 | _filter_scratch
+  $SCRATCH_MNT/testf0 2>&1 | tee -a $seqres.full | _filter_scratch
 
-# {s,g}etfattr of "trusted.overlay.xxx" should fail.
+# {s,g}etfattr of "trusted.overlay.xxx" fail on older kernels
 # The errno returned varies among kernel versions,
-#            v4.3/7   v4.8-rc1    v4.8       v4.10
-# setfattr  not perm  not perm   not perm   not supp
-# getfattr  no attr   no attr    not perm   not supp
+#            v4.3/7   v4.8-rc1    v4.8       v4.10     v6.7
+# setfattr  not perm  not perm   not perm   not supp  ok
+# getfattr  no attr   no attr    not perm   not supp  ok
 #
-# Consider "Operation not {supported,permitted}" pass.
+# Consider "Operation not {supported,permitted}" pass for old kernels.
 #
-$SETFATTR_PROG -n "trusted.overlay.fsz" -v "n" \
-  $SCRATCH_MNT/testf1 2>&1 | _filter_scratch | \
-  sed -e 's/permitted/supported/g'
+if _check_scratch_overlay_xattr_escapes $SCRATCH_MNT/testf0; then
+       setexp=""
+       getexp="No such attribute"
+else
+       setexp="Operation not supported"
+       getexp="Operation not supported"
+fi
 
-_getfattr --absolute-names -n "trusted.overlay.fsz" \
-  $SCRATCH_MNT/testf1 2>&1 | _filter_scratch | \
-  sed -e 's/permitted/supported/g'
+getres=$(_getfattr --absolute-names -n "trusted.overlay.fsz" \
+  $SCRATCH_MNT/testf1 2>&1 | tee -a $seqres.full | _filter_scratch | \
+  sed 's/permitted/supported/')
+
+[[ "$getres" =~ "$getexp" ]] || echo unexpected getattr result: $getres
+
+setres=$($SETFATTR_PROG -n "trusted.overlay.fsz" -v "n" \
+  $SCRATCH_MNT/testf1 2>&1 | tee -a $seqres.full |_filter_scratch | \
+  sed -e 's/permitted/supported/g')
+
+if [ "$setexp" ]; then
+       [[ "$setres" =~ "$expres" ]] || echo unexpected setattr result: $setres
+else
+       [[ "$setres" == "" ]] || echo unexpected setattr result: $setres
+fi
 
 # success, all done
 status=0
index c4572d6708f10deebba7170ff63b2327c202bbe5..5303000931031a9a0f08f212767d684579d3ed80 100644 (file)
@@ -2,5 +2,3 @@ QA output created by 026
 # file: SCRATCH_MNT/testf0
 trusted.overlayfsrz="n"
 
-setfattr: SCRATCH_MNT/testf1: Operation not supported
-SCRATCH_MNT/testf1: trusted.overlay.fsz: Operation not supported