summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorDenys Vlasenko2024-01-01 22:22:15 +0100
committerDenys Vlasenko2024-01-01 22:24:42 +0100
commit1cac2585217f830d29f7e9d2a1226d55c80886b6 (patch)
treefb40d7a0720871587ab806cb9b36c2da6626777f /testsuite
parent01e80ff9ebaf42f2fb9b4ddddc75d37bc9a403aa (diff)
downloadbusybox-1cac2585217f830d29f7e9d2a1226d55c80886b6.zip
busybox-1cac2585217f830d29f7e9d2a1226d55c80886b6.tar.gz
time: implement %% and \escapes in -f FMT
function old new delta time_main 1217 1316 +99 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'testsuite')
-rwxr-xr-xtestsuite/time.tests37
1 files changed, 37 insertions, 0 deletions
diff --git a/testsuite/time.tests b/testsuite/time.tests
new file mode 100755
index 0000000..4e31b38
--- /dev/null
+++ b/testsuite/time.tests
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+# Copyright 2024 by Denys Vlasenko <vda.linux@googlemail.com>
+# Licensed under GPLv2, see file LICENSE in this source tree.
+
+. ./testing.sh
+
+# testing "description" "arguments" "result" "infile" "stdin"
+
+testing "time -f trailing backslash" \
+ "time -f 'abc\' sleep 0 2>&1" \
+ 'abc?\sleep\n' '' ''
+# ^^^^^^^^^^^^^^ this is what GNU time version 1.9 prints
+
+testing "time -f trailing percent" \
+ "time -f 'abc%' sleep 0 2>&1" \
+ 'abc?' '' ''
+
+testing "time -f undefined backslash" \
+ "time -f 'abc\^def' sleep 0 2>&1" \
+ 'abc?\^def\n' '' ''
+
+testing "time -f undefined percent" \
+ "time -f 'abc%^def' sleep 0 2>&1" \
+ 'abc?^def\n' '' ''
+
+testing "time -f backslash tab and newline" \
+ "time -f 'abc\ndef\txyz' sleep 0 2>&1" \
+ 'abc
+def xyz
+' '' ''
+
+testing "time -f percent percent" \
+ "time -f 'abc%%def' sleep 0 2>&1" \
+ 'abc%def\n' '' ''
+
+exit $FAILCOUNT