blob: 1d19aa1be70a66ec552e3188dca1d4ca70a6f2a8 [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'
Rob Landley336c44a2016-03-02 15:20:04 -06008testing "0" "truncate -s 0 freep $SIZE" "0\n" "" ""
9testing "12345" "truncate -s 12345 freep $SIZE" "12345\n" "" ""
10testing "1m" "truncate -s 1m freep $SIZE" "1048576\n" "" ""
11testing "is sparse" "truncate -s 1g freep && stat -c %b freep" \
Rob Landley789665d2015-04-28 12:18:17 -050012 "0\n" "" ""
Rob Landley336c44a2016-03-02 15:20:04 -060013testing "+" "truncate -s 1k freep && truncate -s +1k freep $SIZE" \
Rob Landley789665d2015-04-28 12:18:17 -050014 "2048\n" "" ""
Rob Landley336c44a2016-03-02 15:20:04 -060015testing "-" "truncate -s 4k freep && truncate -s -1k freep $SIZE" \
Rob Landley789665d2015-04-28 12:18:17 -050016 "3072\n" "" ""
Rob Landley336c44a2016-03-02 15:20:04 -060017testing "< hit" \
Rob Landley789665d2015-04-28 12:18:17 -050018 "truncate -s 5k freep && truncate -s \<4k freep $SIZE" "4096\n" "" ""
Rob Landley336c44a2016-03-02 15:20:04 -060019testing "< miss" \
Rob Landley789665d2015-04-28 12:18:17 -050020 "truncate -s 4k freep && truncate -s \<6k freep $SIZE" "4096\n" "" ""
Rob Landley336c44a2016-03-02 15:20:04 -060021testing "> hit" \
Rob Landley789665d2015-04-28 12:18:17 -050022 "truncate -s 3k freep && truncate -s \>4k freep $SIZE" "4096\n" "" ""
Rob Landley336c44a2016-03-02 15:20:04 -060023testing "> miss" \
Rob Landley789665d2015-04-28 12:18:17 -050024 "truncate -s 4k freep && truncate -s \>2k freep $SIZE" "4096\n" "" ""
Rob Landley336c44a2016-03-02 15:20:04 -060025testing "/" "truncate -s 7k freep && truncate -s /3k freep $SIZE" \
Rob Landley789665d2015-04-28 12:18:17 -050026 "6144\n" "" ""
Rob Landley336c44a2016-03-02 15:20:04 -060027testing "%" "truncate -s 7k freep && truncate -s %3k freep $SIZE" \
Rob Landley789665d2015-04-28 12:18:17 -050028 "9216\n" "" ""