From 8b3b9aa1bdbd3a1d721873e4359f650ff52427e5 Mon Sep 17 00:00:00 2001 From: Isaac Dunham Date: Sun, 1 Jun 2014 17:47:19 -0500 Subject: The tests for link and du are attached. --- scripts/test/du.test | 26 ++++++++++++++++++++++++++ scripts/test/link.test | 8 ++++++++ 2 files changed, 34 insertions(+) create mode 100755 scripts/test/du.test create mode 100755 scripts/test/link.test (limited to 'scripts') diff --git a/scripts/test/du.test b/scripts/test/du.test new file mode 100755 index 00000000..ee4867b8 --- /dev/null +++ b/scripts/test/du.test @@ -0,0 +1,26 @@ +#!/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" +# I assume this means the space used to store the link name +testing "du counts symlinks without following" "du -ks du_test" "12\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" "12\tdu_test\n" "" "" +testing "du -LH does not follow unspecified symlinks" "du -ksLH du_test" "12\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 + diff --git a/scripts/test/link.test b/scripts/test/link.test new file mode 100755 index 00000000..3bfdc1f1 --- /dev/null +++ b/scripts/test/link.test @@ -0,0 +1,8 @@ +#!/bin/bash + +[ -e testing.sh ] && . testing.sh + +echo "" >foo +testing "link has same inode" "link foo bar && stat -c '%DI%i bar'" "stat -c '%DI%i' foo" "" "" +testing "link fails on non-existent file" "link foo/foo baz || echo GOOD" "GOOD\n" "" "" +rm -f foo bar -- cgit v1.2.3