Use upstream patch for POSIX mode
This commit is contained in:
parent
bae30a5c92
commit
79e8678313
@ -0,0 +1,78 @@
|
||||
From 84648ef7951047728909a89333a85a0b27f22019 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
||||
Date: Thu, 9 Nov 2017 12:18:34 +0100
|
||||
Subject: [PATCH] Accept numeric values in tests/time-posix-quiet.sh
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
tests/time-posix-quiet.sh failed randomly:
|
||||
|
||||
> --- out-q 2017-11-09 11:50:52.652813081 +0100
|
||||
> +++ exp-q 2017-11-09 11:50:52.646813087 +0100
|
||||
> @@ -1,2 +1,2 @@
|
||||
> -user system :elapsed %CPU (avgtext+avgdata maxresident)k
|
||||
> +user system :elapsed ?%CPU (avgtext+avgdata maxresident)k
|
||||
> inputs+outputs (major+minor)pagefaults swaps
|
||||
> FAIL tests/time-posix-quiet.sh (exit status: 1)
|
||||
|
||||
because the CPU usage was sometimes "0%CPU or "100%CPU" instead of expcted
|
||||
"?%CPU".
|
||||
|
||||
This patch corrects the test.
|
||||
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||
---
|
||||
tests/time-posix-quiet.sh | 10 +++++-----
|
||||
1 file changed, 5 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/tests/time-posix-quiet.sh b/tests/time-posix-quiet.sh
|
||||
index 1e6f653..2a61d08 100755
|
||||
--- a/tests/time-posix-quiet.sh
|
||||
+++ b/tests/time-posix-quiet.sh
|
||||
@@ -35,14 +35,14 @@ fail=
|
||||
|
||||
cat<<EOF > exp-default || framework_failure_ "failed to write exp-default"
|
||||
Command exited with non-zero status
|
||||
-user system :elapsed ?%CPU (avgtext+avgdata maxresident)k
|
||||
+user system :elapsed %CPU (avgtext+avgdata maxresident)k
|
||||
inputs+outputs (major+minor)pagefaults swaps
|
||||
EOF
|
||||
|
||||
returns_ 1 env time -o out-def1 false || fail=1
|
||||
|
||||
# Remove the actual values (they'll differ every run)
|
||||
-sed -e 's/[0-9.]*//g' -e 's/ *$//' out-def1 > out-default \
|
||||
+sed -e 's/[0-9.?]*//g' -e 's/ *$//' out-def1 > out-default \
|
||||
|| framework_failure_ "sed failed on out-def1"
|
||||
|
||||
compare_ out-default exp-default || fail=1
|
||||
@@ -56,14 +56,14 @@ compare_ out-default exp-default || fail=1
|
||||
## originally from Debian, "-q" supresses the "command exited..." message
|
||||
|
||||
cat<<EOF > exp-q || framework_failure_ "failed to write exp-q"
|
||||
-user system :elapsed ?%CPU (avgtext+avgdata maxresident)k
|
||||
+user system :elapsed %CPU (avgtext+avgdata maxresident)k
|
||||
inputs+outputs (major+minor)pagefaults swaps
|
||||
EOF
|
||||
|
||||
returns_ 1 env time -q -o out-q1 false || fail=1
|
||||
|
||||
# Remove the actual values (they'll differ every run)
|
||||
-sed -e 's/[0-9.]*//g' -e 's/ *$//' out-q1 > out-q \
|
||||
+sed -e 's/[0-9.?]*//g' -e 's/ *$//' out-q1 > out-q \
|
||||
|| framework_failure_ "sed failed on out-q"
|
||||
|
||||
compare_ out-q exp-q || fail=1
|
||||
@@ -82,7 +82,7 @@ EOF
|
||||
returns_ 1 env time -p -o out-posix1 false || fail=1
|
||||
|
||||
# Remove the actual values (they'll differ every run)
|
||||
-sed -e 's/[0-9.]*//g' -e 's/ *$//' out-posix1 > out-posix \
|
||||
+sed -e 's/[0-9.?]*//g' -e 's/ *$//' out-posix1 > out-posix \
|
||||
|| framework_failure_ "sed failed on out-posix1"
|
||||
|
||||
compare_ out-posix exp-posix || fail=1
|
||||
--
|
||||
2.13.6
|
||||
|
||||
@ -1,41 +0,0 @@
|
||||
From ca7e5b4eed72b74b0e5c0001adc3b7348d247342 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
|
||||
Date: Wed, 8 Nov 2017 17:34:03 +0100
|
||||
Subject: [PATCH] Do not report command failure in POSIX mode
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
POSIX allows only an empty line before the time usage report. time-1.8
|
||||
violates it:
|
||||
|
||||
$ ./time-1.8/time -p /usr/bin/false
|
||||
Command exited with non-zero status 1
|
||||
real 0.00
|
||||
user 0.00
|
||||
sys 0.00
|
||||
|
||||
This patch disables reporting the command failure if -p option is
|
||||
specified.
|
||||
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||
---
|
||||
src/time.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/time.c b/src/time.c
|
||||
index cba2c32..c6d557d 100644
|
||||
--- a/src/time.c
|
||||
+++ b/src/time.c
|
||||
@@ -431,7 +431,7 @@ summarize (fp, fmt, command, resp)
|
||||
unsigned long ru; /* Elapsed real microseconds. */
|
||||
unsigned long vu; /* Elapsed virtual (CPU) microseconds. */
|
||||
|
||||
- if (!quiet)
|
||||
+ if (!quiet && output_format != posix_format)
|
||||
{
|
||||
if (WIFSTOPPED (resp->waitstatus))
|
||||
fprintf (fp, "Command stopped by signal %d\n",
|
||||
--
|
||||
2.13.6
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
From 0962ebfcb9d30d0898ee4c108e71a1b6bca0785e Mon Sep 17 00:00:00 2001
|
||||
From 5891844448acf635b95c6299c18391d4d68f0355 Mon Sep 17 00:00:00 2001
|
||||
From: "H.J. Lu" <hongjiu.lu@intel.com>
|
||||
Date: Wed, 8 Nov 2017 16:50:21 +0100
|
||||
Subject: [PATCH] Recompute CPU usage at microsecond level
|
||||
@ -31,19 +31,19 @@ index a5edfaa..b21e2ad 100644
|
||||
|
||||
|
||||
diff --git a/src/time.c b/src/time.c
|
||||
index a6d99fb..cba2c32 100644
|
||||
index 9047374..9a3b042 100644
|
||||
--- a/src/time.c
|
||||
+++ b/src/time.c
|
||||
@@ -428,6 +428,8 @@ summarize (fp, fmt, command, resp)
|
||||
@@ -429,6 +429,8 @@ summarize (fp, fmt, command, resp)
|
||||
{
|
||||
unsigned long r; /* Elapsed real milliseconds. */
|
||||
unsigned long v; /* Elapsed virtual (CPU) milliseconds. */
|
||||
+ unsigned long ru; /* Elapsed real microseconds. */
|
||||
+ unsigned long vu; /* Elapsed virtual (CPU) microseconds. */
|
||||
|
||||
if (!quiet)
|
||||
if (!quiet && output_format != posix_format)
|
||||
{
|
||||
@@ -452,6 +454,17 @@ summarize (fp, fmt, command, resp)
|
||||
@@ -453,6 +455,17 @@ summarize (fp, fmt, command, resp)
|
||||
v = resp->ru.ru_utime.tv_sec * 1000 + resp->ru.ru_utime.TV_MSEC +
|
||||
resp->ru.ru_stime.tv_sec * 1000 + resp->ru.ru_stime.TV_MSEC;
|
||||
|
||||
@ -61,7 +61,7 @@ index a6d99fb..cba2c32 100644
|
||||
while (*fmt)
|
||||
{
|
||||
switch (*fmt)
|
||||
@@ -509,6 +522,8 @@ summarize (fp, fmt, command, resp)
|
||||
@@ -510,6 +523,8 @@ summarize (fp, fmt, command, resp)
|
||||
/* % cpu is (total cpu time)/(elapsed time). */
|
||||
if (r > 0)
|
||||
fprintf (fp, "%lu%%", (v * 100 / r));
|
||||
|
||||
@ -0,0 +1,171 @@
|
||||
From c5e97663cc9976e11ffa8491a6fdcb31702856ee Mon Sep 17 00:00:00 2001
|
||||
From: Assaf Gordon <assafgordon@gmail.com>
|
||||
Date: Wed, 8 Nov 2017 14:29:00 -0700
|
||||
Subject: [PATCH] time: remove "Command exited with non-zero status" in POSIX
|
||||
(-p) mode
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Suggested by Petr Pisar in
|
||||
https://lists.gnu.org/archive/html/bug-time/2017-11/msg00001.html .
|
||||
|
||||
* src/time.c (summarize): Don't print the message in posix mode.
|
||||
* tests/time-posix-quiet.sh: Test the output with -p and -q.
|
||||
* Makefile.am (TESTS): Add new test.
|
||||
* NEWS: Mention change.
|
||||
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||
---
|
||||
Makefile.am | 3 +-
|
||||
NEWS | 10 ++++++
|
||||
src/time.c | 2 +-
|
||||
tests/time-posix-quiet.sh | 91 +++++++++++++++++++++++++++++++++++++++++++++++
|
||||
4 files changed, 104 insertions(+), 2 deletions(-)
|
||||
create mode 100755 tests/time-posix-quiet.sh
|
||||
|
||||
diff --git a/Makefile.am b/Makefile.am
|
||||
index 30868db..861c3ae 100644
|
||||
--- a/Makefile.am
|
||||
+++ b/Makefile.am
|
||||
@@ -75,7 +75,8 @@ tests_time_aux_CFLAGS =
|
||||
|
||||
TESTS = tests/help-version.sh \
|
||||
tests/time-max-rss.sh \
|
||||
- tests/time-exit-codes.sh
|
||||
+ tests/time-exit-codes.sh \
|
||||
+ tests/time-posix-quiet.sh
|
||||
|
||||
TEST_EXTENSIONS = .sh
|
||||
|
||||
diff --git a/NEWS b/NEWS
|
||||
index 06a75bc..d05206f 100644
|
||||
--- a/NEWS
|
||||
+++ b/NEWS
|
||||
@@ -1,3 +1,13 @@
|
||||
+* Noteworthy changes in release ?.? (?-?-?) []
|
||||
+
|
||||
+** Changes in behaviour
|
||||
+
|
||||
+ "time -p" no longers adds the "Command exited with non-zero status" message.
|
||||
+ This is a backward-incompatible change for better POSIX compliance.
|
||||
+ Many downstream distributions previously patched 'time' to behave this way
|
||||
+ (Debian added '-q', Fedora patched '-p').
|
||||
+
|
||||
+
|
||||
* Noteworthy changes in release 1.8 (2017-11-07) [stable]
|
||||
|
||||
** Licensing
|
||||
diff --git a/src/time.c b/src/time.c
|
||||
index a6d99fb..6fa6c87 100644
|
||||
--- a/src/time.c
|
||||
+++ b/src/time.c
|
||||
@@ -429,7 +429,7 @@ summarize (fp, fmt, command, resp)
|
||||
unsigned long r; /* Elapsed real milliseconds. */
|
||||
unsigned long v; /* Elapsed virtual (CPU) milliseconds. */
|
||||
|
||||
- if (!quiet)
|
||||
+ if (!quiet && output_format != posix_format)
|
||||
{
|
||||
if (WIFSTOPPED (resp->waitstatus))
|
||||
fprintf (fp, "Command stopped by signal %d\n",
|
||||
diff --git a/tests/time-posix-quiet.sh b/tests/time-posix-quiet.sh
|
||||
new file mode 100755
|
||||
index 0000000..1e6f653
|
||||
--- /dev/null
|
||||
+++ b/tests/time-posix-quiet.sh
|
||||
@@ -0,0 +1,91 @@
|
||||
+#!/bin/sh
|
||||
+
|
||||
+# Test output quietness with -q and -p
|
||||
+
|
||||
+# Copyright (C) 2017 Assaf Gordon <assafgordon@gmail.com>
|
||||
+#
|
||||
+# This file is part of GNU Time.
|
||||
+#
|
||||
+# GNU Time is free software: you can redistribute it and/or modify
|
||||
+# it under the terms of the GNU General Public License as published by
|
||||
+# the Free Software Foundation, either version 3 of the License, or
|
||||
+# (at your option) any later version.
|
||||
+#
|
||||
+# GNU Time is distributed in the hope that it will be useful,
|
||||
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+# GNU General Public License for more details.
|
||||
+#
|
||||
+# You should have received a copy of the GNU General Public License
|
||||
+# along with GNU time. If not, see <http://www.gnu.org/licenses/>.
|
||||
+
|
||||
+# Written by Assaf Gordon
|
||||
+. "${test_dir=.}/init.sh"
|
||||
+
|
||||
+which false > /dev/null || skip_ "'false' program required for this test"
|
||||
+which sed > /dev/null || skip_ "'sed' program required for this test"
|
||||
+
|
||||
+fail=
|
||||
+
|
||||
+
|
||||
+##
|
||||
+## Default output
|
||||
+##
|
||||
+## Has extra "command exited with non-zero status" message
|
||||
+
|
||||
+cat<<EOF > exp-default || framework_failure_ "failed to write exp-default"
|
||||
+Command exited with non-zero status
|
||||
+user system :elapsed ?%CPU (avgtext+avgdata maxresident)k
|
||||
+inputs+outputs (major+minor)pagefaults swaps
|
||||
+EOF
|
||||
+
|
||||
+returns_ 1 env time -o out-def1 false || fail=1
|
||||
+
|
||||
+# Remove the actual values (they'll differ every run)
|
||||
+sed -e 's/[0-9.]*//g' -e 's/ *$//' out-def1 > out-default \
|
||||
+ || framework_failure_ "sed failed on out-def1"
|
||||
+
|
||||
+compare_ out-default exp-default || fail=1
|
||||
+
|
||||
+
|
||||
+
|
||||
+
|
||||
+##
|
||||
+## -q output
|
||||
+##
|
||||
+## originally from Debian, "-q" supresses the "command exited..." message
|
||||
+
|
||||
+cat<<EOF > exp-q || framework_failure_ "failed to write exp-q"
|
||||
+user system :elapsed ?%CPU (avgtext+avgdata maxresident)k
|
||||
+inputs+outputs (major+minor)pagefaults swaps
|
||||
+EOF
|
||||
+
|
||||
+returns_ 1 env time -q -o out-q1 false || fail=1
|
||||
+
|
||||
+# Remove the actual values (they'll differ every run)
|
||||
+sed -e 's/[0-9.]*//g' -e 's/ *$//' out-q1 > out-q \
|
||||
+ || framework_failure_ "sed failed on out-q"
|
||||
+
|
||||
+compare_ out-q exp-q || fail=1
|
||||
+
|
||||
+
|
||||
+##
|
||||
+## -p (POSIX) output
|
||||
+##
|
||||
+## versions 1.8 and older add "Command exited with non-zero status" message.
|
||||
+cat<<EOF > exp-posix || framework_failure_ "failed to write exp-posix"
|
||||
+real
|
||||
+user
|
||||
+sys
|
||||
+EOF
|
||||
+
|
||||
+returns_ 1 env time -p -o out-posix1 false || fail=1
|
||||
+
|
||||
+# Remove the actual values (they'll differ every run)
|
||||
+sed -e 's/[0-9.]*//g' -e 's/ *$//' out-posix1 > out-posix \
|
||||
+ || framework_failure_ "sed failed on out-posix1"
|
||||
+
|
||||
+compare_ out-posix exp-posix || fail=1
|
||||
+
|
||||
+
|
||||
+exit $fail
|
||||
--
|
||||
2.13.6
|
||||
|
||||
22
time.spec
22
time.spec
@ -1,7 +1,7 @@
|
||||
Summary: A GNU utility for monitoring a program's use of system resources
|
||||
Name: time
|
||||
Version: 1.8
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
# src/time.c: GPLv3+
|
||||
# COPYING: GPLv3 text
|
||||
# doc/time.texi: GFDL
|
||||
@ -30,14 +30,17 @@ Release: 1%{?dist}
|
||||
License: GPLv3+ and GFDL
|
||||
Url: http://www.gnu.org/software/%{name}/
|
||||
Source: ftp://prep.ai.mit.edu/pub/gnu/%{name}/%{name}-%{version}.tar.gz
|
||||
# Do not print command failure in POSIX mode, in upstream after 1.8
|
||||
# <https://lists.gnu.org/archive/html/bug-time/2017-11/msg00001.html>
|
||||
Patch0: time-1.8-time-remove-Command-exited-with-non-zero-status-in-P.patch
|
||||
# Correct test added in
|
||||
# time-remove-Command-exited-with-non-zero-status-in-P.patch
|
||||
Patch1: time-1.8-Accept-numeric-values-in-tests-time-posix-quiet.sh.patch
|
||||
# Bug #527276
|
||||
Patch0: time-1.8-Recompute-CPU-usage-at-microsecond-level.patch
|
||||
Patch2: time-1.8-Recompute-CPU-usage-at-microsecond-level.patch
|
||||
# Fix measuring time when a clock experiences a jump, bug #1004416,
|
||||
# <http://lists.gnu.org/archive/html/bug-gnu-utils/2013-09/msg00003.html>
|
||||
Patch1: time-1.8-Prefer-clock_gettime-CLOCK_MONOTONIC.patch
|
||||
# Do not print command failure in POSIX mode,
|
||||
# <http://lists.gnu.org/archive/html/bug-gnu-utils/2017-11/msg00000.html>
|
||||
Patch2: time-1.8-Do-not-report-command-failure-in-POSIX-mode.patch
|
||||
Patch3: time-1.8-Prefer-clock_gettime-CLOCK_MONOTONIC.patch
|
||||
BuildRequires: autoconf
|
||||
BuildRequires: automake
|
||||
BuildRequires: bash
|
||||
@ -45,6 +48,8 @@ BuildRequires: coreutils
|
||||
BuildRequires: gcc
|
||||
BuildRequires: make
|
||||
BuildRequires: texinfo
|
||||
# Tests
|
||||
BuildRequires: sed
|
||||
Requires(post): /sbin/install-info
|
||||
Requires(preun): /sbin/install-info
|
||||
|
||||
@ -56,8 +61,10 @@ the results.
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0 -p1
|
||||
chmod +x tests/time-posix-quiet.sh
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
autoreconf -fi
|
||||
|
||||
%build
|
||||
@ -89,6 +96,9 @@ fi
|
||||
%{_infodir}/time.info*
|
||||
|
||||
%changelog
|
||||
* Thu Nov 09 2017 Petr Pisar <ppisar@redhat.com> - 1.8-2
|
||||
- Use upstream patch for POSIX mode
|
||||
|
||||
* Wed Nov 08 2017 Petr Pisar <ppisar@redhat.com> - 1.8-1
|
||||
- 1.8 bump
|
||||
- License changed from GPLv2+ to (GPLv3+ and GFDL)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user