From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id E8124138334 for ; Sun, 27 Oct 2019 12:47:35 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 29EAAE0839; Sun, 27 Oct 2019 12:47:35 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 005C9E0839 for ; Sun, 27 Oct 2019 12:47:34 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C183D34C3BF for ; Sun, 27 Oct 2019 12:47:33 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 73974A8 for ; Sun, 27 Oct 2019 12:47:32 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1572180366.27f35b8a59b2afcc090c5e576a69ad7f1eb14b12.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: /, tests/qlop/ X-VCS-Repository: proj/portage-utils X-VCS-Files: qlop.c tests/qlop/dotest tests/qlop/list10.good X-VCS-Directories: tests/qlop/ / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 27f35b8a59b2afcc090c5e576a69ad7f1eb14b12 X-VCS-Branch: master Date: Sun, 27 Oct 2019 12:47:32 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: a48a2500-cb36-42a8-96f6-67dd0fcc11c3 X-Archives-Hash: fe5834cf5ed8fe6f658f6b7268b73097 commit: 27f35b8a59b2afcc090c5e576a69ad7f1eb14b12 Author: Fabian Groffen gentoo org> AuthorDate: Sun Oct 27 12:46:06 2019 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Sun Oct 27 12:46:06 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=27f35b8a qlop: allow forcing non-proc running mode using -rr for testing Adapt test to use -rr to force falling back to scanning emerge.log, and give -d to the data range in which things happen, such that the 10-day cutoff can be calculated based on that for deterministic output. Signed-off-by: Fabian Groffen gentoo.org> qlop.c | 25 ++++++++++++++----------- tests/qlop/dotest | 4 ++-- tests/qlop/list10.good | 6 +++--- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/qlop.c b/qlop.c index 6cb2c04..7083ea7 100644 --- a/qlop.c +++ b/qlop.c @@ -344,7 +344,6 @@ New format: 1550953125: *** exiting successfully. 1550953125: *** terminating. - Currently running merges can be found in the /proc filesystem: - Linux: readlink(/proc//fd/X) - Solaris: readlink(/proc//path/X) @@ -846,16 +845,18 @@ static int do_emerge_log( if (flags->do_running) { time_t cutofftime; + tstart = time(NULL); + /* emerge.log can be interrupted, incorrect and hopelessly lost, * so to eliminate some unfinished crap from there, we just * ignore anything that's > cutofftime, 10 days for now. */ cutofftime = 10 * 24 * 60 * 60; /* when we consider entries stale */ + cutofftime = (tbegin > 0 ? tbegin : tstart) - cutofftime; /* can't report endtime for non-finished operations */ flags->do_endtime = 0; - tstart = time(NULL); sync_time /= sync_cnt; - if (sync_start >= tstart - cutofftime) { + if (sync_start >= cutofftime) { elapsed = tstart - sync_start; if (elapsed >= sync_time) sync_time = 0; @@ -878,7 +879,7 @@ static int do_emerge_log( time_t maxtime = 0; bool isMax = false; - if (pkgw->tbegin < tstart - cutofftime) + if (pkgw->tbegin < cutofftime) continue; snprintf(afmt, sizeof(afmt), "%s/%s", @@ -925,7 +926,7 @@ static int do_emerge_log( time_t maxtime = 0; bool isMax = false; - if (pkgw->tbegin < tstart - cutofftime) + if (pkgw->tbegin < cutofftime) continue; snprintf(afmt, sizeof(afmt), "%s/%s", @@ -1140,6 +1141,7 @@ int qlop_main(int argc, char **argv) char *q; depend_atom *atom; DECLARE_ARRAY(atoms); + int runningmode = 0; start_time = 0; end_time = LONG_MAX; @@ -1173,7 +1175,8 @@ int qlop_main(int argc, char **argv) m.show_lastmerge = 1; m.show_emerge = 1; verbose = 1; break; - case 'r': m.do_running = 1; break; + case 'r': m.do_running = 1; + runningmode++; break; case 'a': m.do_average = 1; break; case 'c': m.do_summary = 1; break; case 'H': m.do_human = 1; break; @@ -1312,14 +1315,14 @@ int qlop_main(int argc, char **argv) if (m.do_running) { array_t *new_atoms = probe_proc(atoms); - if (new_atoms != NULL && array_cnt(new_atoms) == 0) { - /* proc supported, found nothing running */ - start_time = LONG_MAX; - } else { + if (runningmode > 1 || new_atoms == NULL) { warn("/proc not available, deducing running " "merges from emerge.log"); + } else if (array_cnt(new_atoms) == 0) { + /* proc supported, found nothing running */ + start_time = LONG_MAX; } - + /* NOTE: new_atoms == atoms when new_atoms != NULL */ } if (start_time < LONG_MAX) diff --git a/tests/qlop/dotest b/tests/qlop/dotest index bf5edc0..321f7d2 100755 --- a/tests/qlop/dotest +++ b/tests/qlop/dotest @@ -10,7 +10,7 @@ test() { local num=$1 exp=$2 ret=0 shift 2 eval "$@" > list || ret=$? - if ! diff -u list ${as}/list${num}.good ; then + if ! diff -u ${as}/list${num}.good list ; then tfail "output does not match" fi if [[ ${exp} -ne ${ret} ]] ; then @@ -48,7 +48,7 @@ test 09 0 "qlop -Hacv automake -f ${as}/aborts.log" # https://bugs.gentoo.org/697068: a parallel emerge finishing should # wipe the outstanding emerges from other emerges -test 10 0 "qlop -r -f ${as}/parallel.log" +test 10 0 "qlop -Mrr -f ${as}/parallel.log" -d 1568976528 cleantmpdir diff --git a/tests/qlop/list10.good b/tests/qlop/list10.good index 845573f..348992a 100644 --- a/tests/qlop/list10.good +++ b/tests/qlop/list10.good @@ -1,3 +1,3 @@ -2019-09-20T12:27:40 >>> dev-qt/qtmultimedia... (96 of 129) ETA: unknown -2019-09-20T16:17:50 >>> kde-frameworks/kxmlgui... (98 of 129) ETA: unknown -2019-09-20T16:18:28 >>> net-analyzer/wireshark... (99 of 129) ETA: unknown +1568982460 >>> dev-qt/qtmultimedia... (96 of 129) ETA: unknown +1568996270 >>> kde-frameworks/kxmlgui... (98 of 129) ETA: unknown +1568996308 >>> net-analyzer/wireshark... (99 of 129) ETA: unknown