mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-13 17:21:05 +00:00
btrfs-progs: tests: add helpers for creating temporary file
For convenience add helpers that will create a temporary file in the $TMPDIR with a given additional tag in the name for later identification. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
6e888a7a6c
commit
ded1e50cd3
24
tests/common
24
tests/common
@ -868,4 +868,28 @@ check_test_results()
|
||||
fi
|
||||
}
|
||||
|
||||
# Create at temporary file in $TMPDIR
|
||||
# $1: optional identifier that'll be part of the name
|
||||
_mktemp() {
|
||||
local tmp
|
||||
local name
|
||||
|
||||
name="btrfs-progs${1:+-$1}.XXXXXX"
|
||||
_log "Create temporary file $name"
|
||||
tmp=$(mktemp --tmpdir "$name")
|
||||
echo -n "$tmp"
|
||||
}
|
||||
|
||||
# Create at temporary directory in $TMPDIR
|
||||
# $1: optional identifier that'll be part of the name
|
||||
_mktemp_dir() {
|
||||
local tmp
|
||||
local name
|
||||
|
||||
name="btrfs-progs${1:+-$1}.XXXXXX"
|
||||
_log "Create temporary file $name"
|
||||
tmp=$(mktemp -d --tmpdir "$name")
|
||||
echo -n "$tmp"
|
||||
}
|
||||
|
||||
init_env
|
||||
|
Loading…
Reference in New Issue
Block a user