aboutsummaryrefslogtreecommitdiff
path: root/tests/lsattr.test
blob: c2c7c617ad2f893c9abe3929013c91b0f551014d (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
32
33
34
35
36
37
38
#!/bin/bash

[ -f testing.sh ] && . testing.sh

#testing "name" "command" "result" "infile" "stdin"

# lsattr - Testcases
mkdir dir && cd dir && touch file
chattr +A file &>/dev/null

_p=$PWD
_b="-------------"
_A="-------A-----"

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" "" ""

# Cleanup
chattr -AacDdijsStTu file && cd ..
rm -rf dir