Skip to contentSkip to conversation

generic/126: run it inside its own subdirectory

PATCH In review Jeff Layton 2 participants 2 messages Feb 20, 2025 – Feb 21, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 generic/126: run it inside its own subdirectory

I had been seeing some failures in generic/126 when running on NFS under kdevops. The problem turned out to be that kdevops makes the root of the NFS export mode 01777 by default (i.e. with the sticky bit set). This causes some of these permission tests to fail because the open() is called with the O_CREAT bit set.

Make the outcome of this test not depend on the permissions on $TEST_DIR. Create a new directory to do these tests in, and clean it up when done.

---
Changes in v3:
- Add comment explaining the weird setup
- Move all of the cleanup into _cleanup()
- rm -rf $testdir before doing mkdir
- add call to _require_chmod helper
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- add commands to _cleanup() to clean up test directory (Thanks Darrick!)
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 tests/generic/126 | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
tests/generic/126 +14 -3
index 142d2bb97db706bafd2152856ef0993c5c273441..97b4a07344bd5d3d5e06b36831978c9ad314b9d7 100755
@@ -13,6 +13,7 @@ _begin_fstest perms auto quick
 _cleanup()
 {
     cd /
+    test -n "$testdir" && rm -rf "$testdir"
 }
 
 # Import common functions.
@@ -20,10 +21,22 @@ _cleanup()
 
 _require_test
 _require_chown
+_require_chmod
 
 QA_FS_PERMS=$here/src/fs_perms
 
-cd $TEST_DIR
+#
+# This test is testing filesystem permissions. If the sticky bit is set on
+# the directory, that can affect the outcome. Create a new directory with
+# known permissions in which to run this test.
+#
+testdir="$TEST_DIR/generic-126.$$"
+rm -rf $testdir
+mkdir $testdir
+chown 0:0 $testdir
+chmod 0755 $testdir
+cd $testdir
+
 cp $here/src/testx ./testx.file
 
 # file_perm owner_uid owner_gid tester_uid tester_gid perm_to_test expected_result pass=1
@@ -46,7 +59,5 @@ $QA_FS_PERMS 200 99 99 200 99 w 1
 $QA_FS_PERMS 040 99 99 99 500 r 1
 $QA_FS_PERMS 400 99 99 200 99 r 1
 
-rm -f ./testx.file
-
 status=0
 exit

---
base-commit: 8467552f09e1672a02712653b532a84bd46ea10e
change-id: 20250219-generic126-f81b3022c4b7

Best regards,

Signature · 1 line
Jeff Layton <[email protected]>
Reviewed-by on v3 1/1
#1 lore raw
Quoted 44 lines · Jeff Layton

I had been seeing some failures in generic/126 when running on NFS under kdevops. The problem turned out to be that kdevops makes the root of the NFS export mode 01777 by default (i.e. with the sticky bit set). This causes some of these permission tests to fail because the open() is called with the O_CREAT bit set.

Make the outcome of this test not depend on the permissions on $TEST_DIR. Create a new directory to do these tests in, and clean it up when done.

---
Changes in v3:
- Add comment explaining the weird setup
- Move all of the cleanup into _cleanup()
- rm -rf $testdir before doing mkdir
- add call to _require_chmod helper
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- add commands to _cleanup() to clean up test directory (Thanks Darrick!)
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 tests/generic/126 | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
tests/generic/126 +2 -0
index 142d2bb97db706bafd2152856ef0993c5c273441..97b4a07344bd5d3d5e06b36831978c9ad314b9d7 100755
@@ -13,6 +13,7 @@ _begin_fstest perms auto quick
 _cleanup()
 {
     cd /
+    test -n "$testdir" && rm -rf "$testdir"
 }
 
 # Import common functions.
@@ -20,10 +21,22 @@ _cleanup()
 
 _require_test
 _require_chown
+_require_chmod

tests/generic/126 _cleanup() · line 33

Quoted 10 lines
tests/generic/126 +6 -1
 
 QA_FS_PERMS=$here/src/fs_perms
 
-cd $TEST_DIR
+#
+# This test is testing filesystem permissions. If the sticky bit is set on
+# the directory, that can affect the outcome. Create a new directory with
+# known permissions in which to run this test.
+#
+testdir="$TEST_DIR/generic-126.$$"

I'll change the 126 to ${seq}, others good to me. Thanks!

Quoted 26 lines
tests/generic/126 +6 -3
+rm -rf $testdir
+mkdir $testdir
+chown 0:0 $testdir
+chmod 0755 $testdir
+cd $testdir
+
 cp $here/src/testx ./testx.file
 
 # file_perm owner_uid owner_gid tester_uid tester_gid perm_to_test expected_result pass=1
@@ -46,7 +59,5 @@ $QA_FS_PERMS 200 99 99 200 99 w 1
 $QA_FS_PERMS 040 99 99 99 500 r 1
 $QA_FS_PERMS 400 99 99 200 99 r 1
 
-rm -f ./testx.file
-
 status=0
 exit
 
---

base-commit: 8467552f09e1672a02712653b532a84bd46ea10e
change-id: 20250219-generic126-f81b3022c4b7

Best regards,

Signature · 1 line
Jeff Layton <[email protected]>