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.
This commit is contained in:
Benjamin Sago 2017-07-04 17:42:16 +01:00
parent 4c41141cb9
commit 882ac489ce
3 changed files with 74 additions and 39 deletions

53
Vagrantfile vendored
View File

@ -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
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"
for dir in "#{test_dir}/attributes/dirs/"*two-files*; do
touch $dir/this-file
touch $dir/that-file
done
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/"*/*
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
# 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

View File

@ -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

View File

@ -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