diff options
author | Elliott Hughes <enh@google.com> | 2020-01-27 20:21:47 -0800 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2020-01-28 02:00:04 -0600 |
commit | 3d4a1f6a0eccf8f910919c4605a3b17b9f5a1070 (patch) | |
tree | 22689403eebc86987776ccf1dd0984f9df5a49b3 /tests | |
parent | 7348ee6049cb4207cfb13b7b31de2a41292941bc (diff) | |
download | toybox-3d4a1f6a0eccf8f910919c4605a3b17b9f5a1070.tar.gz |
lsattr: fix tests.
I'm trying to switch Android over to toybox chattr/lsattr from
e2fsprogs. Remove those tests that relied on being able to use
chattr(1), remove the duplication that tested both a bare name and a
full path, take into account all the flags that lsattr can now output,
and cope with the fact that the exact flags you'll see depend on your
file system. (Unfortunately this means trusting lsattr in the lsattr
tests, which isn't ideal, but without a known environment I don't think
we can do any better.)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lsattr.test | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/tests/lsattr.test b/tests/lsattr.test index c2c7c617..7a7256b7 100644 --- a/tests/lsattr.test +++ b/tests/lsattr.test @@ -4,35 +4,28 @@ #testing "name" "command" "result" "infile" "stdin" -# lsattr - Testcases +# 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 -chattr +A file &>/dev/null +_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" -_p=$PWD -_b="-------------" -_A="-------A-----" +chattr +A file &>/dev/null testing "file" "lsattr file" "$_A file\n" "" "" -testing "file_path" "lsattr $_p/file" "$_A $_p/file\n" "" "" testing "-R file" "lsattr -R file" "$_A file\n" "" "" -testing "-R file_path" "lsattr -R $_p/file" "$_A $_p/file\n" "" "" testing "-a file" "lsattr -a file" "$_A file\n" "" "" -testing "-a file_path" "lsattr -a $_p/file" "$_A $_p/file\n" "" "" testing "-d ." "lsattr -d ." "$_b .\n" "" "" -testing "-d dir_path" "lsattr -d $_p" "$_b $_p\n" "" "" testing "-d file" "lsattr -d file" "$_A file\n" "" "" -testing "-d file_path" "lsattr -d $_p/file" "$_A $_p/file\n" "" "" -sp_44=" " -testing "-l file" "lsattr -l file" "file $sp_44 No_Atime\n" "" "" -_v="12345" -testing "-v file" "chattr -v $_v * && lsattr -v file" \ - "$_v $_A file\n" "" "" -testing "-v file_path" "chattr -v $_v * && lsattr -v $_p/file" \ - "$_v $_A $_p/file\n" "" "" -testing "-Radlv file1 file2" "chattr -v $_v * && - lsattr -Radlv file input" \ - "$_v file $sp_44 No_Atime\n$_v input $sp_44 ---\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" "" "" -# Cleanup chattr -AacDdijsStTu file && cd .. rm -rf dir |