mirror of
https://github.com/kdave/btrfs-progs
synced 2024-12-26 16:12:34 +00:00
btrfs-progs: tests: add helper for creating local temporary file
Some tests don't use the /tmp temporary files and store it locally in the test directory. To support NFS this needs to be created by a few commands. To avoid accidental breakage add a convenience helper. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
bd94a00de0
commit
500f826f31
17
tests/common
17
tests/common
@ -870,4 +870,21 @@ _mktemp_dir() {
|
||||
echo -n "$tmp"
|
||||
}
|
||||
|
||||
# Create temporary file of the given name in the local test directory (eg. when
|
||||
# it's a large image and not suitable for /tmp), this also supports NFS where
|
||||
# the file needs to be created by regular user and made available for roo
|
||||
# $1: file name
|
||||
# $2: optional size (argument suitable for truncate)
|
||||
_mktemp_local() {
|
||||
local name
|
||||
local size
|
||||
|
||||
name="$1"
|
||||
size="${2:-0}"
|
||||
_log "Create local temporary file $name"
|
||||
rm -f -- "$name"
|
||||
run_check truncate -s "$size" -- "$name"
|
||||
run_check chmod a+w -- "$name"
|
||||
}
|
||||
|
||||
init_env
|
||||
|
Loading…
Reference in New Issue
Block a user