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 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" 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. 19testing "du counts symlinks without following" "du -ks du_test" "8\tdu_test\n" "" "" 20testing "du -L follows symlinks" "du -ksL du_test" "16\tdu_test\n" "" "" 21ln -s . du_test/up 22testing "du -L avoid endless loop" "du -ksL du_test" "16\tdu_test\n" "" "" 23rm du_test/up 24# if -H and -L are specified, the last takes priority 25testing "du -HL follows symlinks" "du -ksHL du_test" "16\tdu_test\n" "" "" 26testing "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" "" "" 28testing "du -H follows specified symlinks" "du -ksH du_test/xyz" "8\tdu_test/xyz\n" "" "" 29 30rm -rf du_test du_2 31 32