From f79b72761f4950021cf97e8c683830d1ff969ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thi=C3=A9baud=20Weksteen?= Date: Mon, 19 Feb 2024 11:09:49 +1100 Subject: [PATCH] Update getfattr/setfattr tests In commit 2c96060, the tests for getfattr and setfattr were updated to only query specific names and avoid any unexpected extended attributes. Reintroduce the generic tests by filtering out any attribute in the `security` namespace. --- tests/getfattr.test | 15 ++++++++++++--- tests/setfattr.test | 22 +++++++++++++--------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/tests/getfattr.test b/tests/getfattr.test index 0ac0a41f..2bec8354 100644 --- a/tests/getfattr.test +++ b/tests/getfattr.test @@ -4,14 +4,23 @@ #testing "name" "command" "result" "infile" "stdin" +function clean() +{ + # The filesystem may include some extended attributes by default (for + # instance, security.selinux). Skip them. + grep -v "security\." +} + mkdir attrs touch attrs/file setfattr -n user.empty attrs/file setfattr -n user.data -v hello attrs/file +setfattr -n user.more -v world attrs/file -# The filesystem may include some extended attributes by default (for -# instance, security.selinux). Use the -n option to limit the output. - +testing "" "getfattr attrs/file | clean" \ + "# file: attrs/file\nuser.data\nuser.empty\nuser.more\n\n" "" "" +testing "-d" "getfattr -d attrs/file | clean" \ + "# file: attrs/file\nuser.data=\"hello\"\nuser.empty\nuser.more=\"world\"\n\n" "" "" testing "-n" "getfattr -n user.empty attrs/file" \ "# file: attrs/file\nuser.empty\n\n" "" "" testing "-d -n" "getfattr -d -n user.data attrs/file" \ diff --git a/tests/setfattr.test b/tests/setfattr.test index 6bbb3ec8..58801b0e 100644 --- a/tests/setfattr.test +++ b/tests/setfattr.test @@ -4,21 +4,25 @@ #testing "name" "command" "result" "infile" "stdin" +function clean() +{ + # The filesystem may include some extended attributes by default (for + # instance, security.selinux). Skip them. + grep -v "security\." +} + mkdir attrs touch attrs/file setfattr -n user.empty attrs/file setfattr -n user.data -v hello attrs/file setfattr -n user.delete-me -v hello attrs/file -# The filesystem may include some extended attributes by default (for -# instance, security.selinux). Use the -n option to limit the output. - testing "-x" \ - "setfattr -x user.delete-me attrs/file && getfattr -n user.delete-me attrs/file" \ - "# file: attrs/file\n\n" "" "" -testing "-n" "setfattr -n user.new attrs/file && getfattr -n user.new -d attrs/file" \ - "# file: attrs/file\nuser.new\n\n" "" "" -testing "-n -v" "setfattr -n user.new -v data attrs/file && getfattr -n user.new -d attrs/file" \ - "# file: attrs/file\nuser.new=\"data\"\n\n" "" "" + "setfattr -x user.delete-me attrs/file && getfattr attrs/file | clean" \ + "# file: attrs/file\nuser.data\nuser.empty\n\n" "" "" +testing "-n" "setfattr -n user.new attrs/file && getfattr -d attrs/file | clean" \ + "# file: attrs/file\nuser.data=\"hello\"\nuser.empty\nuser.new\n\n" "" "" +testing "-n -v" "setfattr -n user.new -v data attrs/file && getfattr -d attrs/file | clean" \ + "# file: attrs/file\nuser.data=\"hello\"\nuser.empty\nuser.new=\"data\"\n\n" "" "" rm -rf attrs -- 2.39.2