blob: 5616dfc5f6dbcc67b744a6283aefc7ffe9c1da05 (
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 "lsattr file" "lsattr file" "$_A file\n" "" ""
testing "lsattr file_path" "lsattr $_p/file" "$_A $_p/file\n" "" ""
testing "lsattr -R file" "lsattr -R file" "$_A file\n" "" ""
testing "lsattr -R file_path" "lsattr -R $_p/file" "$_A $_p/file\n" "" ""
testing "lsattr -a file" "lsattr -a file" "$_A file\n" "" ""
testing "lsattr -a file_path" "lsattr -a $_p/file" "$_A $_p/file\n" "" ""
testing "lsattr -d ." "lsattr -d ." "$_b .\n" "" ""
testing "lsattr -d dir_path" "lsattr -d $_p" "$_b $_p\n" "" ""
testing "lsattr -d file" "lsattr -d file" "$_A file\n" "" ""
testing "lsattr -d file_path" "lsattr -d $_p/file" "$_A $_p/file\n" "" ""
sp_44=" "
testing "lsattr -l file" "lsattr -l file" "file $sp_44 No_Atime\n" "" ""
_v="12345"
testing "lsattr -v file" "chattr -v $_v * && lsattr -v file" \
"$_v $_A file\n" "" ""
testing "lsattr -v file_path" "chattr -v $_v * && lsattr -v $_p/file" \
"$_v $_A $_p/file\n" "" ""
testing "lsattr -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
|