1#!/bin/bash
2
3[ -f testing.sh ] && . testing.sh
4
5#testing "name" "command" "result" "infile" "stdin"
6
7mkdir attrs
8touch attrs/file
9setfattr -n user.empty attrs/file
10setfattr -n user.data -v hello attrs/file
11setfattr -n user.delete-me -v hello attrs/file
12
13testing "-x" \
14    "setfattr -x user.delete-me attrs/file && getfattr attrs/file" \
15    "# file: attrs/file\nuser.data\nuser.empty\n\n" "" ""
16testing "-n" "setfattr -n user.new attrs/file && getfattr -d attrs/file" \
17    "# file: attrs/file\nuser.data=\"hello\"\nuser.empty\nuser.new\n\n" "" ""
18testing "-n -v" "setfattr -n user.new -v data attrs/file && getfattr -d attrs/file" \
19    "# file: attrs/file\nuser.data=\"hello\"\nuser.empty\nuser.new=\"data\"\n\n" "" ""
20
21rm -rf attrs
22