From eee28e7b5851a6eb16f7969393d8c6292b1f8754 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 3 May 2018 15:09:14 -0700 Subject: Support fractional seconds (and other time units) in `top -d`. LTP uses `top -d 0.1`, which isn't convincingly useful, but general support for other time units might be useful, and switching to xparsetime addresses both at once. Also fix 3169d948c049664bcf7216d4c4ae751881099d3e where I mistakenly treated `rev` and `toys.optflags&FLAG_b` as interchangeable. (Without this second fix, `top -b` looks fine but `top` is broken!) Also fix xparsetime to reject input such as "monkey" or "1monkey". --- tests/top.test | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/top.test b/tests/top.test index 11eea33b..3c3b5977 100755 --- a/tests/top.test +++ b/tests/top.test @@ -5,3 +5,9 @@ #testing "name" "command" "result" "infile" "stdin" testing "batch termination" "top -b -n1 | tail -c 1" "\n" "" "" +testing "fractional seconds" "top -b -d 8.5 -n1 | tail -c 1" "\n" "" "" + +# These are unit tests of xparsetime. +testing "-d invalid input" "top -b -d monkey -n1 2>&1 >/dev/null" "top: Not a number 'monkey'\n" "" "" +testing "-d unknown suffix" "top -b -d 1u -n1 2>&1 >/dev/null" "top: Unknown suffix 'u'\n" "" "" +testing "-d suffix trailing junk" "top -b -d 1monkey -n1 2>&1 >/dev/null" "top: Unknown suffix 'monkey'\n" "" "" -- cgit v1.2.3