aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lsattr.test45
1 files changed, 27 insertions, 18 deletions
diff --git a/tests/lsattr.test b/tests/lsattr.test
index 7a7256b7..bbb21dcf 100644
--- a/tests/lsattr.test
+++ b/tests/lsattr.test
@@ -4,28 +4,37 @@
#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
+_A='-------A------------'
+_d='--------------------'
-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" "" ""
+function clean()
+{
+ # 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 strip out both
+ # the long and short forms of those.
+ # We also don't want to rely on chattr(1) to set a known version number or
+ # project number, so blank out any numbers.
+ sed 's/, Encrypted//' | \
+ sed 's/-E-/---/' | \
+ sed 's/, Extents//' | \
+ sed 's/-e-/---/' | \
+ sed -E 's/[0-9]+/_/g'
+}
+
+testing "file" "lsattr file | clean" "$_A file\n" "" ""
+testing "-R file" "lsattr -R file | clean" "$_A file\n" "" ""
+testing "-a file" "lsattr -a file | clean" "$_A file\n" "" ""
+testing "-d ." "lsattr -d . | clean" "$_d .\n" "" ""
+testing "-d file" "lsattr -d file | clean" "$_A file\n" "" ""
+NOSPACE=1 testing "-l file" "lsattr -l file | clean" "file No_Atime\n" "" ""
+NOSPACE=1 testing "-v file" "lsattr -v file | clean" "_ $_A file\n" "" ""
+NOSPACE=1 testing "-lv file" "lsattr -lv file | clean" "_ file No_Atime\n" "" ""
+NOSPACE=1 testing "-p file" "lsattr -p file | clean" "_ $_A file\n" "" ""
+NOSPACE=1 testing "-lp file" "lsattr -lp file | clean" "_ file No_Atime\n" "" ""
+NOSPACE=1 testing "-vp file" "lsattr -vp file | clean" "_ _ $_A file\n" "" ""
chattr -AacDdijsStTu file && cd ..
rm -rf dir