OSDN Git Service

Merge remote-tracking branch 'toybox/master' into HEAD
[android-x86/external-toybox.git] / tests / du.test
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"
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" "" ""
20 testing "du -L follows symlinks" "du -ksL du_test" "16\tdu_test\n" "" ""
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
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" "" ""
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" "" ""
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