From 442980f1c9aedcb6840868bec11163ba838e20bb Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 12 Dec 2023 13:56:25 -0800 Subject: [PATCH] Add project ID tests Signed-off-by: Zach Brown --- tests/golden/projects | 24 +++++++++++++++++++ tests/sequence | 1 + tests/tests/projects.sh | 52 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 tests/golden/projects create mode 100644 tests/tests/projects.sh diff --git a/tests/golden/projects b/tests/golden/projects new file mode 100644 index 00000000..4cb6b5ce --- /dev/null +++ b/tests/golden/projects @@ -0,0 +1,24 @@ +== default new files don't have project +0 +== set new project on files and dirs +8675309 +8675309 +== non-root can see id +8675309 +== can use IDs around long width limits +2147483647 +2147483648 +4294967295 +9223372036854775807 +9223372036854775808 +18446744073709551615 +== created files and dirs inherit project id +8675309 +8675309 +== inheritance continues +8675309 +== clearing project id stops inheritance +0 +0 +== o_tmpfile creations inherit dir +8675309 diff --git a/tests/sequence b/tests/sequence index 448f0473..317404c5 100644 --- a/tests/sequence +++ b/tests/sequence @@ -12,6 +12,7 @@ data-prealloc.sh setattr_more.sh offline-extent-waiting.sh move-blocks.sh +projects.sh large-fragmented-free.sh format-version-forward-back.sh enospc.sh diff --git a/tests/tests/projects.sh b/tests/tests/projects.sh new file mode 100644 index 00000000..105f3e6a --- /dev/null +++ b/tests/tests/projects.sh @@ -0,0 +1,52 @@ + +# notable id to recognize in output +ID=8675309 + +echo "== default new files don't have project" +touch "$T_D0/file" +scoutfs get-attr-x -p "$T_D0/file" + +echo "== set new project on files and dirs" +mkdir "$T_D0/dir" +scoutfs set-attr-x -p $ID "$T_D0/file" +scoutfs set-attr-x -p $ID "$T_D0/dir" +scoutfs get-attr-x -p "$T_D0/file" +scoutfs get-attr-x -p "$T_D0/dir" + +echo "== non-root can see id" +chmod 644 "$T_D0/file" +setpriv --ruid=12345 --euid=12345 scoutfs get-attr-x -p "$T_D0/file" + +echo "== can use IDs around long width limits" +touch "$T_D0/ids" +for id in 0x7FFFFFFF 0x80000000 0xFFFFFFFF \ + 0x7FFFFFFFFFFFFFFF 0x8000000000000000 0xFFFFFFFFFFFFFFFF; do + scoutfs set-attr-x -p $id "$T_D0/ids" + scoutfs get-attr-x -p "$T_D0/ids" +done + +echo "== created files and dirs inherit project id" +touch "$T_D0/dir/file" +mkdir "$T_D0/dir/sub" +scoutfs get-attr-x -p "$T_D0/dir/file" +scoutfs get-attr-x -p "$T_D0/dir/sub" + +echo "== inheritance continues" +mkdir "$T_D0/dir/sub/more" +scoutfs get-attr-x -p "$T_D0/dir/sub/more" + +# .. just inherits 0 :) +echo "== clearing project id stops inheritance" +scoutfs set-attr-x -p 0 "$T_D0/dir" +touch "$T_D0/dir/another-file" +mkdir "$T_D0/dir/another-sub" +scoutfs get-attr-x -p "$T_D0/dir/another-file" +scoutfs get-attr-x -p "$T_D0/dir/another-sub" + +echo "== o_tmpfile creations inherit dir" +scoutfs set-attr-x -p $ID "$T_D0/dir" +o_tmpfile_linkat "$T_D0/dir" "$T_D0/dir/tmpfile" +scoutfs get-attr-x -p "$T_D0/dir/tmpfile" + + +t_pass