Home | History | Annotate | Download | only in tests
      1 #!/bin/bash
      2 
      3 [ -f testing.sh ] && . testing.sh
      4 
      5 #testing "name" "command" "result" "infile" "stdin"
      6 
      7 # lsattr - Testcases
      8 mkdir dir && cd dir && touch file
      9 chattr +A file &>/dev/null
     10 
     11 _p=$PWD
     12 _b="-------------"
     13 _A="-------A-----"
     14 
     15 testing "file" "lsattr file" "$_A file\n" "" ""
     16 testing "file_path" "lsattr $_p/file" "$_A $_p/file\n" "" ""
     17 testing "-R file" "lsattr -R file" "$_A file\n" "" ""
     18 testing "-R file_path" "lsattr -R $_p/file" "$_A $_p/file\n" "" ""
     19 testing "-a file" "lsattr -a file" "$_A file\n" "" ""
     20 testing "-a file_path" "lsattr -a $_p/file" "$_A $_p/file\n" "" ""
     21 testing "-d ." "lsattr -d ." "$_b .\n" "" ""
     22 testing "-d dir_path" "lsattr -d $_p" "$_b $_p\n" "" ""
     23 testing "-d file" "lsattr -d file" "$_A file\n" "" ""
     24 testing "-d file_path" "lsattr -d $_p/file" "$_A $_p/file\n" "" ""
     25 sp_44="                                            "
     26 testing "-l file" "lsattr -l file" "file  $sp_44 No_Atime\n" "" ""
     27 _v="12345"
     28 testing "-v file" "chattr -v $_v * && lsattr -v file" \
     29   "$_v $_A file\n" "" ""
     30 testing "-v file_path" "chattr -v $_v * && lsattr -v $_p/file" \
     31   "$_v $_A $_p/file\n" "" ""
     32 testing "-Radlv file1 file2" "chattr -v $_v * &&
     33    lsattr -Radlv file input" \
     34   "$_v file  $sp_44 No_Atime\n$_v input $sp_44 ---\n" "" ""
     35 
     36 # Cleanup
     37 chattr -AacDdijsStTu file && cd ..
     38 rm -rf dir
     39