blob: 7a7256b7421d5f2233891b4cd931eea23c4d5896 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/bin/bash
[ -f testing.sh ] && . testing.sh
#testing "name" "command" "result" "infile" "stdin"
# We don't know whether the fs will have extents (e, typically true on the
# desktop) or be encrypted (E, typically true on Android), so ask.
# Unfortunately, this requires that we trust lsattr...
mkdir dir && cd dir && touch file
_b=$(lsattr -d . | awk '{print $1}')
_A=$(lsattr file | sed 's/^--------/-------A/' | awk '{print $1}')
attrs="No_Atime"
lsattr -d . | grep -q e && attrs="$attrs, Extents"
lsattr -d . | grep -q E && attrs="$attrs, Encrypted"
chattr +A file &>/dev/null
testing "file" "lsattr file" "$_A file\n" "" ""
testing "-R file" "lsattr -R file" "$_A file\n" "" ""
testing "-a file" "lsattr -a file" "$_A file\n" "" ""
testing "-d ." "lsattr -d ." "$_b .\n" "" ""
testing "-d file" "lsattr -d file" "$_A file\n" "" ""
NOSPACE=1 testing "-l file" "lsattr -l file" "file $attrs\n" "" ""
NOSPACE=1 testing "-v file" "lsattr -v file | sed 's/^[0-9]*/_/'" \
"_ $_A file\n" "" ""
NOSPACE=1 testing "-lv file" "lsattr -lv file | sed 's/^[0-9]*/_/'" \
"_ file $attrs\n" "" ""
chattr -AacDdijsStTu file && cd ..
rm -rf dir
|