From 2ca7bab7c07fd6abebe0313fb9aab14f70f01c32 Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Fri, 8 Feb 2013 12:07:56 +1030 Subject: [PATCH] Improve test framework: create_file --append --- testframework.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/testframework.sh b/testframework.sh index b906d577..50b378fd 100644 --- a/testframework.sh +++ b/testframework.sh @@ -594,12 +594,19 @@ matches_rexp() { } # Create a file with the given size (default 0). -# Usage: create_file [] +# Usage: create_file [--append] [] # where: is of the form Nu # N is decimal integer # u is one of kKmMgG (k=10^3, K=2^10, m=10^6, M=2^20, g=10^9, G=2^30) create_file() { - tfw_createfile --label="$1" ${2:+--size=$2} >"$1" || error "failed command: create_file $@" + local args=("$@") + case "$1" in + --append) shift;; + *) rm -f "$1";; + esac + local path="$1" + local size="$2" + tfw_createfile --label="$path" ${size:+--size=$size} >>"$path" || error "failed command: create_file ${args[*]}" } # Executes its arguments as a command: