aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2018-11-28 16:14:17 -0800
committerRob Landley <rob@landley.net>2018-11-28 21:28:23 -0600
commit40a09367f6f96c4ea1a70fdb0a33b38c9d98cd80 (patch)
treeb5298fbbb961d8a2ad294891280a6b4289755a51 /tests
parenta38fcb7587d5be68656a7e9492617200249770c9 (diff)
downloadtoybox-40a09367f6f96c4ea1a70fdb0a33b38c9d98cd80.tar.gz
mktemp: add -t and fix behavior.
The new tests pass on the host (coreutils 8.28) and with toybox after this patch is applied.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/mktemp.test21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/mktemp.test b/tests/mktemp.test
new file mode 100755
index 00000000..d09d2c4c
--- /dev/null
+++ b/tests/mktemp.test
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+[ -f testing.sh ] && . testing.sh
+
+#testing "name" "command" "result" "infile" "stdin"
+
+# mktemp by default should use tmp.XXXXXXXXXX as the template,
+# and $TMPDIR as the directory.
+testing "mktemp" "TMPDIR=/t mktemp -u | grep -q '^/t/tmp\...........$' && echo yes" "yes\n" "" ""
+
+# mktemp with a template should *not* use $TMPDIR.
+testing "mktemp TEMPLATE" "TMPDIR=/t mktemp -u hello.XXXXXXXX | grep -q '^hello\.........$' && echo yes" "yes\n" "" ""
+
+# mktemp with -t and a template should use $TMPDIR.
+testing "mktemp -t TEMPLATE" "TMPDIR=/t mktemp -u -t hello.XXXXXXXX | grep -q '^/t/hello\.........$' && echo yes" "yes\n" "" ""
+
+# mktemp with -p DIR and a template should use DIR.
+testing "mktemp -p DIR TEMPLATE" "TMPDIR=/t mktemp -u -p DIR hello.XXXXXXXX | grep -q '^DIR/hello\.........$' && echo yes" "yes\n" "" ""
+
+# mktemp -p DIR and -t: -t wins.
+testing "mktemp -p DIR -t TEMPLATE" "TMPDIR=/t mktemp -u -p DIR -t hello.XXXXXXXX | grep -q '^/t/hello\.........$' && echo yes" "yes\n" "" ""