Isaac Dunham | 8b3b9aa | 2014-06-01 17:47:19 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | [ -f testing.sh ] && . testing.sh |
| 4 | |
| 5 | #testing "name" "command" "result" "infile" "stdin" |
| 6 | |
| 7 | # we only test with -k since getting POSIX version is variable |
| 8 | # POSIXLY_CORRECT is sometimes needed, sometimes -P is needed, |
| 9 | # while -k is the default on most Linux systems |
| 10 | |
| 11 | mkdir -p du_test/test du_2/foo |
| 12 | testing "du (no options)" "du -k du_test" "4\tdu_test/test\n8\tdu_test\n" "" "" |
| 13 | testing "du -s" "du -k -s du_test" "8\tdu_test\n" "" "" |
| 14 | ln -s ../du_2 du_test/xyz |
| 15 | # "du shall count the size of the symbolic link" |
Felix Janda | 986805c | 2014-09-22 08:22:12 -0500 | [diff] [blame] | 16 | # The tests assume that like for most POSIX systems symbolic |
| 17 | # links are stored directly in the inode so that the |
| 18 | # allocated file space is zero. |
| 19 | testing "du counts symlinks without following" "du -ks du_test" "8\tdu_test\n" "" "" |
Isaac Dunham | 8b3b9aa | 2014-06-01 17:47:19 -0500 | [diff] [blame] | 20 | testing "du -L follows symlinks" "du -ksL du_test" "16\tdu_test\n" "" "" |
Rob Landley | 10e0d86 | 2014-12-01 12:52:55 -0600 | [diff] [blame] | 21 | ln -s . du_test/up |
| 22 | testing "du -L avoid endless loop" "du -ksL du_test" "16\tdu_test\n" "" "" |
| 23 | rm du_test/up |
Isaac Dunham | 8b3b9aa | 2014-06-01 17:47:19 -0500 | [diff] [blame] | 24 | # if -H and -L are specified, the last takes priority |
| 25 | testing "du -HL follows symlinks" "du -ksHL du_test" "16\tdu_test\n" "" "" |
Felix Janda | 986805c | 2014-09-22 08:22:12 -0500 | [diff] [blame] | 26 | testing "du -H does not follow unspecified symlinks" "du -ksH du_test" "8\tdu_test\n" "" "" |
| 27 | testing "du -LH does not follow unspecified symlinks" "du -ksLH du_test" "8\tdu_test\n" "" "" |
Isaac Dunham | 8b3b9aa | 2014-06-01 17:47:19 -0500 | [diff] [blame] | 28 | testing "du -H follows specified symlinks" "du -ksH du_test/xyz" "8\tdu_test/xyz\n" "" "" |
| 29 | |
| 30 | rm -rf du_test du_2 |
| 31 | |