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