1#!/bin/bash 2 3[ -f testing.sh ] && . testing.sh 4 5#testing "name" "command" "result" "infile" "stdin" 6 7function clean() 8{ 9 # The filesystem may include some extended attributes by default (for 10 # instance, security.selinux). Skip them. 11 grep -v "security\." 12} 13 14mkdir attrs 15touch attrs/file 16setfattr -n user.empty attrs/file 17setfattr -n user.data -v hello attrs/file 18setfattr -n user.more -v world attrs/file 19 20testing "" "getfattr attrs/file | clean" \ 21 "# file: attrs/file\nuser.data\nuser.empty\nuser.more\n\n" "" "" 22testing "-d" "getfattr -d attrs/file | clean" \ 23 "# file: attrs/file\nuser.data=\"hello\"\nuser.empty\nuser.more=\"world\"\n\n" "" "" 24testing "-n" "getfattr -n user.empty attrs/file" \ 25 "# file: attrs/file\nuser.empty\n\n" "" "" 26testing "-d -n" "getfattr -d -n user.data attrs/file" \ 27 "# file: attrs/file\nuser.data=\"hello\"\n\n" "" "" 28testing "--only-values -n" "getfattr --only-values -n user.data attrs/file" \ 29 "hello" "" "" 30 31rm -rf attrs 32