aboutsummaryrefslogtreecommitdiff
path: root/tests/mktemp.test
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2018-12-06 11:06:55 -0800
committerRob Landley <rob@landley.net>2018-12-06 13:24:22 -0600
commitcc906e2a063d80e5c4459aab17c685642302c319 (patch)
treefc9d6018fc84cd57c84ac9bd459e86b496d797f8 /tests/mktemp.test
parent71900746fb1e6ec4abe18a23bc26ad0a467355be (diff)
downloadtoybox-cc906e2a063d80e5c4459aab17c685642302c319.tar.gz
mktemp: just the missing tests.
Diffstat (limited to 'tests/mktemp.test')
-rwxr-xr-xtests/mktemp.test17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/mktemp.test b/tests/mktemp.test
index ee7702dc..0c235469 100755
--- a/tests/mktemp.test
+++ b/tests/mktemp.test
@@ -6,11 +6,20 @@
# mktemp by default should use tmp.XXXXXXXXXX as the template,
# and $TMPDIR as the directory.
-testing "default" "TMPDIR=/t mktemp -u | grep -q '^/t/tmp\...........$' && echo yes" "yes\n" "" ""
+testing "default" "TMPDIR=. mktemp | grep -q '^./tmp\...........$' && echo yes" "yes\n" "" ""
+
+# Test that -d creates a directory and the default is a file.
+testing "dir" "test -d `TMPDIR=. mktemp -d` && echo yes" "yes\n" "" ""
+testing "file" "test -f `TMPDIR=. mktemp` && echo yes" "yes\n" "" ""
# mktemp with a template should *not* use $TMPDIR.
testing "TEMPLATE" "TMPDIR=/t mktemp -u hello.XXXXXXXX | grep -q '^hello\.........$' && echo yes" "yes\n" "" ""
+# mktemp with a template that includes a '/' should ignore $TMPDIR
+testing "/ TEMPLATE" "TMPDIR=/t mktemp -u /x/hello.XXXXXXXX | grep -q '^/x/hello\.........$' && echo yes" "yes\n" "" ""
+# ...and setting DIR is an error.
+testing "/ TEMPLATE -p DIR" "TMPDIR=/t mktemp -p DIR -u /x/hello.XXXXXXXX || echo error" "error\n" "" ""
+
# mktemp with -t and a template should use $TMPDIR.
testing "-t TEMPLATE" "TMPDIR=/t mktemp -u -t hello.XXXXXXXX | grep -q '^/t/hello\.........$' && echo yes" "yes\n" "" ""
@@ -28,3 +37,9 @@ testing "-p DIR -t TEMPLATE but no TMPDIR" "TMPDIR= mktemp -u -p DIR -t hello.XX
# mktemp -u doesn't need to be able to write to the directory.
testing "-u" "mktemp -u -p /proc | grep -q '^/proc/tmp\...........$' && echo yes" "yes\n" "" ""
+
+# mktemp needs at least XX in the template.
+testing "bad template" "mktemp -u helloX || echo error" "error\n" "" ""
+
+# mktemp -q shouldn't print the path.
+testing "-q" "mktemp -p /proc -q || echo only-failure" "only-failure\n" "" ""