Răsfoiți Sursa

Much more thorough xattr testing

It now tests a lot more combinations of xattrs on files, as well as xattrs and files and errors as the children of directories.

The recent code changes have touched the part where directories’ xattrs and children are displayed at the same tree level, and there weren’t enough tests for this.
Benjamin Sago 8 ani în urmă
părinte
comite
882ac489ce
3 a modificat fișierele cu 74 adăugiri și 39 ștergeri
  1. 27 26
      Vagrantfile
  2. 45 12
      xtests/attributes
  3. 2 1
      xtests/run.sh

+ 27 - 26
Vagrantfile

@@ -324,43 +324,44 @@ Vagrant.configure(2) do |config|
 
 
     # Awkward extended attribute testcases.
+    # We need to test combinations of various numbers of files *and*
+    # extended attributes in directories. Turns out, the easiest way to
+    # do this is to generate all combinations of files with “one-xattr”
+    # or “two-xattrs” in their name and directories with “empty” or
+    # “one-file” in their name, then just give the right number of
+    # xattrs and children to those.
     config.vm.provision :shell, privileged: false, inline: <<-EOF
         set -xe
         mkdir "#{test_dir}/attributes"
 
-        touch "#{test_dir}/attributes/none"
-
-        touch "#{test_dir}/attributes/one"
-        setfattr -n user.greeting -v hello "#{test_dir}/attributes/one"
-
-        touch "#{test_dir}/attributes/two"
-        setfattr -n user.greeting -v hello "#{test_dir}/attributes/two"
-        setfattr -n user.another_greeting -v hi "#{test_dir}/attributes/two"
-
-        #touch "#{test_dir}/attributes/forbidden"
-        #setfattr -n user.greeting -v hello "#{test_dir}/attributes/forbidden"
-        #chmod +a "$YOU deny readextattr" "#{test_dir}/attributes/forbidden"
+        mkdir "#{test_dir}/attributes/files"
+        touch "#{test_dir}/attributes/files/"{no-xattrs,one-xattr,two-xattrs}{,_forbidden}
 
         mkdir "#{test_dir}/attributes/dirs"
+        mkdir "#{test_dir}/attributes/dirs/"{no-xattrs,one-xattr,two-xattrs}_{empty,one-file,two-files}{,_forbidden}
 
-        mkdir "#{test_dir}/attributes/dirs/empty-with-attribute"
-        setfattr -n user.greeting -v hello "#{test_dir}/attributes/dirs/empty-with-attribute"
+        setfattr -n user.greeting         -v hello "#{test_dir}/attributes"/**/*{one-xattr,two-xattrs}*
+        setfattr -n user.another_greeting -v hi    "#{test_dir}/attributes"/**/*two-xattrs*
 
-        mkdir "#{test_dir}/attributes/dirs/full-with-attribute"
-        touch "#{test_dir}/attributes/dirs/full-with-attribute/file"
-        setfattr -n user.greeting -v hello "#{test_dir}/attributes/dirs/full-with-attribute"
+        for dir in "#{test_dir}/attributes/dirs/"*one-file*; do
+            touch $dir/file-in-question
+        done
+
+        for dir in "#{test_dir}/attributes/dirs/"*two-files*; do
+            touch $dir/this-file
+            touch $dir/that-file
+        done
 
-        mkdir "#{test_dir}/attributes/dirs/full-but-forbidden"
-        touch "#{test_dir}/attributes/dirs/full-but-forbidden/file"
-        #setfattr -n user.greeting -v hello "#{test_dir}/attributes/dirs/full-but-forbidden"
-        #chmod 000 "#{test_dir}/attributes/dirs/full-but-forbidden"
-        #chmod +a "$YOU deny readextattr" "#{test_dir}/attributes/dirs/full-but-forbidden"
+        touch -t #{some_date} "#{test_dir}/attributes"         # there's probably
+        touch -t #{some_date} "#{test_dir}/attributes"/*       # a better
+        touch -t #{some_date} "#{test_dir}/attributes"/*/*     # way to
+        touch -t #{some_date} "#{test_dir}/attributes"/*/*/*   # do this
 
-        touch -t #{some_date} "#{test_dir}/attributes"
-        touch -t #{some_date} "#{test_dir}/attributes/"*
-        touch -t #{some_date} "#{test_dir}/attributes/dirs/"*
-        touch -t #{some_date} "#{test_dir}/attributes/dirs/"*/*
+        # I want to use the following to test,
+        # but it only works on macos:
+        #chmod +a "#{user} deny readextattr" "#{test_dir}/attributes"/**/*_forbidden
 
+        sudo chmod 000                "#{test_dir}/attributes"/**/*_forbidden
         sudo chown #{user}:#{user} -R "#{test_dir}/attributes"
     EOF
 

+ 45 - 12
xtests/attributes

@@ -1,15 +1,48 @@
 drwxrwxr-x  - cassowary  1 Jan 12:34 /testcases/attributes
 drwxrwxr-x  - cassowary  1 Jan 12:34 ├── dirs
-drwxrwxr-x@ - cassowary  1 Jan 12:34 │  ├── empty-with-attribute
+drwxrwxr-x  - cassowary  1 Jan 12:34 │  ├── no-xattrs_empty
+d---------  - cassowary  1 Jan 12:34 │  ├── no-xattrs_empty_forbidden
+drwxrwxr-x  - cassowary  1 Jan 12:34 │  ├── no-xattrs_one-file
+.rw-rw-r--  0 cassowary  1 Jan 12:34 │  │  └── file-in-question
+d---------  - cassowary  1 Jan 12:34 │  ├── no-xattrs_one-file_forbidden
+drwxrwxr-x  - cassowary  1 Jan 12:34 │  ├── no-xattrs_two-files
+.rw-rw-r--  0 cassowary  1 Jan 12:34 │  │  ├── that-file
+.rw-rw-r--  0 cassowary  1 Jan 12:34 │  │  └── this-file
+d---------  - cassowary  1 Jan 12:34 │  ├── no-xattrs_two-files_forbidden
+drwxrwxr-x@ - cassowary  1 Jan 12:34 │  ├── one-xattr_empty
                                      │  │  └── user.greeting (len 5)
-drwxrwxr-x  - cassowary  1 Jan 12:34 │  ├── full-but-forbidden
-.rw-rw-r--  0 cassowary  1 Jan 12:34 │  │  └── file
-drwxrwxr-x@ - cassowary  1 Jan 12:34 │  └── full-with-attribute
-                                     │     ├── user.greeting (len 5)
-.rw-rw-r--  0 cassowary  1 Jan 12:34 │     └── file
-.rw-rw-r--  0 cassowary  1 Jan 12:34 ├── none
-.rw-rw-r--@ 0 cassowary  1 Jan 12:34 ├── one
-                                     │  └── user.greeting (len 5)
-.rw-rw-r--@ 0 cassowary  1 Jan 12:34 └── two
-                                        ├── user.greeting (len 5)
-                                        └── user.another_greeting (len 2)
+d---------  - cassowary  1 Jan 12:34 │  ├── one-xattr_empty_forbidden
+drwxrwxr-x@ - cassowary  1 Jan 12:34 │  ├── one-xattr_one-file
+                                     │  │  ├── user.greeting (len 5)
+.rw-rw-r--  0 cassowary  1 Jan 12:34 │  │  └── file-in-question
+d---------  - cassowary  1 Jan 12:34 │  ├── one-xattr_one-file_forbidden
+drwxrwxr-x@ - cassowary  1 Jan 12:34 │  ├── one-xattr_two-files
+                                     │  │  ├── user.greeting (len 5)
+.rw-rw-r--  0 cassowary  1 Jan 12:34 │  │  ├── that-file
+.rw-rw-r--  0 cassowary  1 Jan 12:34 │  │  └── this-file
+d---------  - cassowary  1 Jan 12:34 │  ├── one-xattr_two-files_forbidden
+drwxrwxr-x@ - cassowary  1 Jan 12:34 │  ├── two-xattrs_empty
+                                     │  │  ├── user.greeting (len 5)
+                                     │  │  └── user.another_greeting (len 2)
+d---------  - cassowary  1 Jan 12:34 │  ├── two-xattrs_empty_forbidden
+drwxrwxr-x@ - cassowary  1 Jan 12:34 │  ├── two-xattrs_one-file
+                                     │  │  ├── user.greeting (len 5)
+                                     │  │  ├── user.another_greeting (len 2)
+.rw-rw-r--  0 cassowary  1 Jan 12:34 │  │  └── file-in-question
+d---------  - cassowary  1 Jan 12:34 │  ├── two-xattrs_one-file_forbidden
+drwxrwxr-x@ - cassowary  1 Jan 12:34 │  ├── two-xattrs_two-files
+                                     │  │  ├── user.greeting (len 5)
+                                     │  │  ├── user.another_greeting (len 2)
+.rw-rw-r--  0 cassowary  1 Jan 12:34 │  │  ├── that-file
+.rw-rw-r--  0 cassowary  1 Jan 12:34 │  │  └── this-file
+d---------  - cassowary  1 Jan 12:34 │  └── two-xattrs_two-files_forbidden
+drwxrwxr-x  - cassowary  1 Jan 12:34 └── files
+.rw-rw-r--  0 cassowary  1 Jan 12:34    ├── no-xattrs
+.---------  0 cassowary  1 Jan 12:34    ├── no-xattrs_forbidden
+.rw-rw-r--@ 0 cassowary  1 Jan 12:34    ├── one-xattr
+                                        │  └── user.greeting (len 5)
+.---------  0 cassowary  1 Jan 12:34    ├── one-xattr_forbidden
+.rw-rw-r--@ 0 cassowary  1 Jan 12:34    ├── two-xattrs
+                                        │  ├── user.greeting (len 5)
+                                        │  └── user.another_greeting (len 2)
+.---------  0 cassowary  1 Jan 12:34    └── two-xattrs_forbidden

+ 2 - 1
xtests/run.sh

@@ -27,7 +27,7 @@ $exa $testcases/files -l   | diff -q - $results/files_l     || exit 1
 $exa $testcases/files -lh  | diff -q - $results/files_lh    || exit 1
 $exa $testcases/files -lhb | diff -q - $results/files_lhb   || exit 1
 $exa $testcases/files -lhB | diff -q - $results/files_lhb2  || exit 1
-$exa $testcases/attributes/dirs/empty-with-attribute -lh | diff -q - $results/empty  || exit 1
+$exa $testcases/attributes/dirs/no-xattrs_empty -lh | diff -q - $results/empty  || exit 1
 
 $exa --color-scale         $testcases/files -l | diff -q - $results/files_l_scale  || exit 1
 
@@ -57,6 +57,7 @@ COLUMNS=200 $exa $testcases/files/* -lG | diff -q - $results/files_star_lG_200
 
 
 # Attributes
+# (there are many tests, but they're all done in one go)
 $exa $testcases/attributes -l@T | diff -q - $results/attributes  || exit 1