Mercurial > hg > toybox
annotate tests/du.test @ 1766:190ecf70fbe5 draft
Fix an obvious typo in Makefile.
author | Elliott Hughes <enh@google.com> |
---|---|
date | Sat, 28 Mar 2015 13:13:42 -0500 |
parents | a016421051e4 |
children |
rev | line source |
---|---|
1332
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
1 #!/bin/bash |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
2 |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
3 [ -f testing.sh ] && . testing.sh |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
4 |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
5 #testing "name" "command" "result" "infile" "stdin" |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
6 |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
7 # we only test with -k since getting POSIX version is variable |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
8 # POSIXLY_CORRECT is sometimes needed, sometimes -P is needed, |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
9 # while -k is the default on most Linux systems |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
10 |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
11 mkdir -p du_test/test du_2/foo |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
12 testing "du (no options)" "du -k du_test" "4\tdu_test/test\n8\tdu_test\n" "" "" |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
13 testing "du -s" "du -k -s du_test" "8\tdu_test\n" "" "" |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
14 ln -s ../du_2 du_test/xyz |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
15 # "du shall count the size of the symbolic link" |
1497
f64ca21ed444
Fix du test: du symlink -> "0\tsymlink"
Felix Janda <felix.janda@posteo.de>
parents:
1485
diff
changeset
|
16 # The tests assume that like for most POSIX systems symbolic |
f64ca21ed444
Fix du test: du symlink -> "0\tsymlink"
Felix Janda <felix.janda@posteo.de>
parents:
1485
diff
changeset
|
17 # links are stored directly in the inode so that the |
f64ca21ed444
Fix du test: du symlink -> "0\tsymlink"
Felix Janda <felix.janda@posteo.de>
parents:
1485
diff
changeset
|
18 # allocated file space is zero. |
f64ca21ed444
Fix du test: du symlink -> "0\tsymlink"
Felix Janda <felix.janda@posteo.de>
parents:
1485
diff
changeset
|
19 testing "du counts symlinks without following" "du -ks du_test" "8\tdu_test\n" "" "" |
1332
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
20 testing "du -L follows symlinks" "du -ksL du_test" "16\tdu_test\n" "" "" |
1591
a016421051e4
Ashwini Sharma pointed out that "mkdir sub; ln -s . sub/up; du -L sub" shouldn't loop endlessly.
Rob Landley <rob@landley.net>
parents:
1497
diff
changeset
|
21 ln -s . du_test/up |
a016421051e4
Ashwini Sharma pointed out that "mkdir sub; ln -s . sub/up; du -L sub" shouldn't loop endlessly.
Rob Landley <rob@landley.net>
parents:
1497
diff
changeset
|
22 testing "du -L avoid endless loop" "du -ksL du_test" "16\tdu_test\n" "" "" |
a016421051e4
Ashwini Sharma pointed out that "mkdir sub; ln -s . sub/up; du -L sub" shouldn't loop endlessly.
Rob Landley <rob@landley.net>
parents:
1497
diff
changeset
|
23 rm du_test/up |
1332
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
24 # if -H and -L are specified, the last takes priority |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
25 testing "du -HL follows symlinks" "du -ksHL du_test" "16\tdu_test\n" "" "" |
1497
f64ca21ed444
Fix du test: du symlink -> "0\tsymlink"
Felix Janda <felix.janda@posteo.de>
parents:
1485
diff
changeset
|
26 testing "du -H does not follow unspecified symlinks" "du -ksH du_test" "8\tdu_test\n" "" "" |
f64ca21ed444
Fix du test: du symlink -> "0\tsymlink"
Felix Janda <felix.janda@posteo.de>
parents:
1485
diff
changeset
|
27 testing "du -LH does not follow unspecified symlinks" "du -ksLH du_test" "8\tdu_test\n" "" "" |
1332
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
28 testing "du -H follows specified symlinks" "du -ksH du_test/xyz" "8\tdu_test/xyz\n" "" "" |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
29 |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
30 rm -rf du_test du_2 |
7e0c577a977e
The tests for link and du are attached.
Isaac Dunham <ibid.ag@gmail.com>
parents:
diff
changeset
|
31 |