blob: 81fb52824feaf8a270d775cf48ede32973e9eb1d [file] [log] [blame]
Isaac Dunham8b3b9aa2014-06-01 17:47:19 -05001#!/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
11mkdir -p du_test/test du_2/foo
12testing "du (no options)" "du -k du_test" "4\tdu_test/test\n8\tdu_test\n" "" ""
13testing "du -s" "du -k -s du_test" "8\tdu_test\n" "" ""
14ln -s ../du_2 du_test/xyz
15# "du shall count the size of the symbolic link"
Felix Janda986805c2014-09-22 08:22:12 -050016# 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.
19testing "du counts symlinks without following" "du -ks du_test" "8\tdu_test\n" "" ""
Isaac Dunham8b3b9aa2014-06-01 17:47:19 -050020testing "du -L follows symlinks" "du -ksL du_test" "16\tdu_test\n" "" ""
Rob Landley10e0d862014-12-01 12:52:55 -060021ln -s . du_test/up
22testing "du -L avoid endless loop" "du -ksL du_test" "16\tdu_test\n" "" ""
23rm du_test/up
Isaac Dunham8b3b9aa2014-06-01 17:47:19 -050024# if -H and -L are specified, the last takes priority
25testing "du -HL follows symlinks" "du -ksHL du_test" "16\tdu_test\n" "" ""
Felix Janda986805c2014-09-22 08:22:12 -050026testing "du -H does not follow unspecified symlinks" "du -ksH du_test" "8\tdu_test\n" "" ""
27testing "du -LH does not follow unspecified symlinks" "du -ksLH du_test" "8\tdu_test\n" "" ""
Isaac Dunham8b3b9aa2014-06-01 17:47:19 -050028testing "du -H follows specified symlinks" "du -ksH du_test/xyz" "8\tdu_test/xyz\n" "" ""
29
30rm -rf du_test du_2
31