aboutsummaryrefslogtreecommitdiff
path: root/tests/truncate.test
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2015-04-28 12:18:17 -0500
committerRob Landley <rob@landley.net>2015-04-28 12:18:17 -0500
commit789665dc51c85f6fabfaf6f70f12d54b9df117df (patch)
tree17bfcabc2f272156a62605b10539bfb2675b0721 /tests/truncate.test
parent89701da1fef87dad77927d30194ab28f19d26366 (diff)
downloadtoybox-789665dc51c85f6fabfaf6f70f12d54b9df117df.tar.gz
Fix truncate prefix bug and add truncate test suite entry.
Diffstat (limited to 'tests/truncate.test')
-rwxr-xr-xtests/truncate.test28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/truncate.test b/tests/truncate.test
new file mode 100755
index 00000000..ee2b2bb8
--- /dev/null
+++ b/tests/truncate.test
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+[ -f testing.sh ] && . testing.sh
+
+#testing "name" "command" "result" "infile" "stdin"
+
+SIZE='&& stat -c %s freep'
+testing "truncate 0" "truncate -s 0 freep $SIZE" "0\n" "" ""
+testing "truncate 12345" "truncate -s 12345 freep $SIZE" "12345\n" "" ""
+testing "truncate 1m" "truncate -s 1m freep $SIZE" "1048576\n" "" ""
+testing "truncate is sparse" "truncate -s 1g freep && stat -c %b freep" \
+ "0\n" "" ""
+testing "truncate +" "truncate -s 1k freep && truncate -s +1k freep $SIZE" \
+ "2048\n" "" ""
+testing "truncate -" "truncate -s 4k freep && truncate -s -1k freep $SIZE" \
+ "3072\n" "" ""
+testing "truncate < hit" \
+ "truncate -s 5k freep && truncate -s \<4k freep $SIZE" "4096\n" "" ""
+testing "truncate < miss" \
+ "truncate -s 4k freep && truncate -s \<6k freep $SIZE" "4096\n" "" ""
+testing "truncate > hit" \
+ "truncate -s 3k freep && truncate -s \>4k freep $SIZE" "4096\n" "" ""
+testing "truncate > miss" \
+ "truncate -s 4k freep && truncate -s \>2k freep $SIZE" "4096\n" "" ""
+testing "truncate /" "truncate -s 7k freep && truncate -s /3k freep $SIZE" \
+ "6144\n" "" ""
+testing "truncate %" "truncate -s 7k freep && truncate -s %3k freep $SIZE" \
+ "9216\n" "" ""