Mercurial > hg > toybox
view tests/du.test @ 1572:da1bf31ed322 draft
Tweak the "ignoring return value" fortify workaround for readlinkat.
We zero the buffer and if the link read fails that's left alone, so
it's ok for the symlink not to be there. Unfortunately, typecasting the
return value to (void) doesn't shut up gcc, and having an if(); with the
semicolon on the same line doesn't shut up llvm. (The semicolon on a new
line would, but C does not have significant whitespace and I'm not going
to humor llvm if it plans to start.)
So far, empty curly brackets consistently get the warning to shut up.
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 24 Nov 2014 17:23:23 -0600 |
parents | f64ca21ed444 |
children | a016421051e4 |
line wrap: on
line source
#!/bin/bash [ -f testing.sh ] && . testing.sh #testing "name" "command" "result" "infile" "stdin" # we only test with -k since getting POSIX version is variable # POSIXLY_CORRECT is sometimes needed, sometimes -P is needed, # while -k is the default on most Linux systems mkdir -p du_test/test du_2/foo testing "du (no options)" "du -k du_test" "4\tdu_test/test\n8\tdu_test\n" "" "" testing "du -s" "du -k -s du_test" "8\tdu_test\n" "" "" ln -s ../du_2 du_test/xyz # "du shall count the size of the symbolic link" # The tests assume that like for most POSIX systems symbolic # links are stored directly in the inode so that the # allocated file space is zero. testing "du counts symlinks without following" "du -ks du_test" "8\tdu_test\n" "" "" testing "du -L follows symlinks" "du -ksL du_test" "16\tdu_test\n" "" "" # if -H and -L are specified, the last takes priority testing "du -HL follows symlinks" "du -ksHL du_test" "16\tdu_test\n" "" "" testing "du -H does not follow unspecified symlinks" "du -ksH du_test" "8\tdu_test\n" "" "" testing "du -LH does not follow unspecified symlinks" "du -ksLH du_test" "8\tdu_test\n" "" "" testing "du -H follows specified symlinks" "du -ksH du_test/xyz" "8\tdu_test/xyz\n" "" "" rm -rf du_test du_2