blob: ee2b2bb8ee2871bdac3bf275db336e95a2f5794f [file] [log] [blame]
Rob Landley789665d2015-04-28 12:18:17 -05001#!/bin/bash
2
3[ -f testing.sh ] && . testing.sh
4
5#testing "name" "command" "result" "infile" "stdin"
6
7SIZE='&& stat -c %s freep'
8testing "truncate 0" "truncate -s 0 freep $SIZE" "0\n" "" ""
9testing "truncate 12345" "truncate -s 12345 freep $SIZE" "12345\n" "" ""
10testing "truncate 1m" "truncate -s 1m freep $SIZE" "1048576\n" "" ""
11testing "truncate is sparse" "truncate -s 1g freep && stat -c %b freep" \
12 "0\n" "" ""
13testing "truncate +" "truncate -s 1k freep && truncate -s +1k freep $SIZE" \
14 "2048\n" "" ""
15testing "truncate -" "truncate -s 4k freep && truncate -s -1k freep $SIZE" \
16 "3072\n" "" ""
17testing "truncate < hit" \
18 "truncate -s 5k freep && truncate -s \<4k freep $SIZE" "4096\n" "" ""
19testing "truncate < miss" \
20 "truncate -s 4k freep && truncate -s \<6k freep $SIZE" "4096\n" "" ""
21testing "truncate > hit" \
22 "truncate -s 3k freep && truncate -s \>4k freep $SIZE" "4096\n" "" ""
23testing "truncate > miss" \
24 "truncate -s 4k freep && truncate -s \>2k freep $SIZE" "4096\n" "" ""
25testing "truncate /" "truncate -s 7k freep && truncate -s /3k freep $SIZE" \
26 "6144\n" "" ""
27testing "truncate %" "truncate -s 7k freep && truncate -s %3k freep $SIZE" \
28 "9216\n" "" ""