summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEric Blake <ebb9@byu.net>2009-11-04 14:02:20 -0700
committerEric Blake <ebb9@byu.net>2009-11-05 06:53:21 -0700
commit41b3a8ed8b2480ca12baaa6c692a7fba3ebd53cf (patch)
treea75c662443607e08f1d457081957bd4cf25bdbc1 /tests
parentcd65f11c4f5fbfff1f35df56d8afa708c8ac2066 (diff)
downloadcoreutils-41b3a8ed8b2480ca12baaa6c692a7fba3ebd53cf.tar.xz
mktemp: don't leave file behind on write failure
* src/mktemp.c (main): Remove just-created file if stdout had problems. * bootstrap.conf (gnulib_modules): Add remove. * tests/misc/close-stdout: Test it. * NEWS: Document it.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/misc/close-stdout6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/misc/close-stdout b/tests/misc/close-stdout
index fec1addc8..852c3c822 100755
--- a/tests/misc/close-stdout
+++ b/tests/misc/close-stdout
@@ -50,12 +50,18 @@ if "$p/src/test" -w /dev/stdout >/dev/null &&
"$p/src/test" ! -w /dev/stdout >&-; then
"$p/src/printf" 'foo' >&- 2>/dev/null && fail=1
cp --verbose a b >&- 2>/dev/null && fail=1
+ rm -Rf tmpfile-?????? || fail=1
+ mktemp tmpfile-XXXXXX >&- 2>/dev/null && fail=1
+ test -e tmpfile-?????? && fail=1
fi
# Likewise for /dev/full, if /dev/full works.
if test -w /dev/full && test -c /dev/full; then
"$p/src/printf" 'foo' >/dev/full 2>/dev/null && fail=1
cp --verbose a b >/dev/full 2>/dev/null && fail=1
+ rm -Rf tmpdir-?????? || fail=1
+ mktemp -d tmpdir-XXXXXX >/dev/full 2>/dev/null && fail=1
+ test -e tmpdir-?????? && fail=1
fi
Exit $fail