1 |
commit: 27f35b8a59b2afcc090c5e576a69ad7f1eb14b12 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Oct 27 12:46:06 2019 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Oct 27 12:46:06 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=27f35b8a |
7 |
|
8 |
qlop: allow forcing non-proc running mode using -rr for testing |
9 |
|
10 |
Adapt test to use -rr to force falling back to scanning emerge.log, and |
11 |
give -d to the data range in which things happen, such that the 10-day |
12 |
cutoff can be calculated based on that for deterministic output. |
13 |
|
14 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
15 |
|
16 |
qlop.c | 25 ++++++++++++++----------- |
17 |
tests/qlop/dotest | 4 ++-- |
18 |
tests/qlop/list10.good | 6 +++--- |
19 |
3 files changed, 19 insertions(+), 16 deletions(-) |
20 |
|
21 |
diff --git a/qlop.c b/qlop.c |
22 |
index 6cb2c04..7083ea7 100644 |
23 |
--- a/qlop.c |
24 |
+++ b/qlop.c |
25 |
@@ -344,7 +344,6 @@ New format: |
26 |
1550953125: *** exiting successfully. |
27 |
1550953125: *** terminating. |
28 |
|
29 |
- |
30 |
Currently running merges can be found in the /proc filesystem: |
31 |
- Linux: readlink(/proc/<pid>/fd/X) |
32 |
- Solaris: readlink(/proc/<pid>/path/X) |
33 |
@@ -846,16 +845,18 @@ static int do_emerge_log( |
34 |
if (flags->do_running) { |
35 |
time_t cutofftime; |
36 |
|
37 |
+ tstart = time(NULL); |
38 |
+ |
39 |
/* emerge.log can be interrupted, incorrect and hopelessly lost, |
40 |
* so to eliminate some unfinished crap from there, we just |
41 |
* ignore anything that's > cutofftime, 10 days for now. */ |
42 |
cutofftime = 10 * 24 * 60 * 60; /* when we consider entries stale */ |
43 |
+ cutofftime = (tbegin > 0 ? tbegin : tstart) - cutofftime; |
44 |
|
45 |
/* can't report endtime for non-finished operations */ |
46 |
flags->do_endtime = 0; |
47 |
- tstart = time(NULL); |
48 |
sync_time /= sync_cnt; |
49 |
- if (sync_start >= tstart - cutofftime) { |
50 |
+ if (sync_start >= cutofftime) { |
51 |
elapsed = tstart - sync_start; |
52 |
if (elapsed >= sync_time) |
53 |
sync_time = 0; |
54 |
@@ -878,7 +879,7 @@ static int do_emerge_log( |
55 |
time_t maxtime = 0; |
56 |
bool isMax = false; |
57 |
|
58 |
- if (pkgw->tbegin < tstart - cutofftime) |
59 |
+ if (pkgw->tbegin < cutofftime) |
60 |
continue; |
61 |
|
62 |
snprintf(afmt, sizeof(afmt), "%s/%s", |
63 |
@@ -925,7 +926,7 @@ static int do_emerge_log( |
64 |
time_t maxtime = 0; |
65 |
bool isMax = false; |
66 |
|
67 |
- if (pkgw->tbegin < tstart - cutofftime) |
68 |
+ if (pkgw->tbegin < cutofftime) |
69 |
continue; |
70 |
|
71 |
snprintf(afmt, sizeof(afmt), "%s/%s", |
72 |
@@ -1140,6 +1141,7 @@ int qlop_main(int argc, char **argv) |
73 |
char *q; |
74 |
depend_atom *atom; |
75 |
DECLARE_ARRAY(atoms); |
76 |
+ int runningmode = 0; |
77 |
|
78 |
start_time = 0; |
79 |
end_time = LONG_MAX; |
80 |
@@ -1173,7 +1175,8 @@ int qlop_main(int argc, char **argv) |
81 |
m.show_lastmerge = 1; |
82 |
m.show_emerge = 1; |
83 |
verbose = 1; break; |
84 |
- case 'r': m.do_running = 1; break; |
85 |
+ case 'r': m.do_running = 1; |
86 |
+ runningmode++; break; |
87 |
case 'a': m.do_average = 1; break; |
88 |
case 'c': m.do_summary = 1; break; |
89 |
case 'H': m.do_human = 1; break; |
90 |
@@ -1312,14 +1315,14 @@ int qlop_main(int argc, char **argv) |
91 |
if (m.do_running) { |
92 |
array_t *new_atoms = probe_proc(atoms); |
93 |
|
94 |
- if (new_atoms != NULL && array_cnt(new_atoms) == 0) { |
95 |
- /* proc supported, found nothing running */ |
96 |
- start_time = LONG_MAX; |
97 |
- } else { |
98 |
+ if (runningmode > 1 || new_atoms == NULL) { |
99 |
warn("/proc not available, deducing running " |
100 |
"merges from emerge.log"); |
101 |
+ } else if (array_cnt(new_atoms) == 0) { |
102 |
+ /* proc supported, found nothing running */ |
103 |
+ start_time = LONG_MAX; |
104 |
} |
105 |
- |
106 |
+ /* NOTE: new_atoms == atoms when new_atoms != NULL */ |
107 |
} |
108 |
|
109 |
if (start_time < LONG_MAX) |
110 |
|
111 |
diff --git a/tests/qlop/dotest b/tests/qlop/dotest |
112 |
index bf5edc0..321f7d2 100755 |
113 |
--- a/tests/qlop/dotest |
114 |
+++ b/tests/qlop/dotest |
115 |
@@ -10,7 +10,7 @@ test() { |
116 |
local num=$1 exp=$2 ret=0 |
117 |
shift 2 |
118 |
eval "$@" > list || ret=$? |
119 |
- if ! diff -u list ${as}/list${num}.good ; then |
120 |
+ if ! diff -u ${as}/list${num}.good list ; then |
121 |
tfail "output does not match" |
122 |
fi |
123 |
if [[ ${exp} -ne ${ret} ]] ; then |
124 |
@@ -48,7 +48,7 @@ test 09 0 "qlop -Hacv automake -f ${as}/aborts.log" |
125 |
|
126 |
# https://bugs.gentoo.org/697068: a parallel emerge finishing should |
127 |
# wipe the outstanding emerges from other emerges |
128 |
-test 10 0 "qlop -r -f ${as}/parallel.log" |
129 |
+test 10 0 "qlop -Mrr -f ${as}/parallel.log" -d 1568976528 |
130 |
|
131 |
cleantmpdir |
132 |
|
133 |
|
134 |
diff --git a/tests/qlop/list10.good b/tests/qlop/list10.good |
135 |
index 845573f..348992a 100644 |
136 |
--- a/tests/qlop/list10.good |
137 |
+++ b/tests/qlop/list10.good |
138 |
@@ -1,3 +1,3 @@ |
139 |
-2019-09-20T12:27:40 >>> dev-qt/qtmultimedia... (96 of 129) ETA: unknown |
140 |
-2019-09-20T16:17:50 >>> kde-frameworks/kxmlgui... (98 of 129) ETA: unknown |
141 |
-2019-09-20T16:18:28 >>> net-analyzer/wireshark... (99 of 129) ETA: unknown |
142 |
+1568982460 >>> dev-qt/qtmultimedia... (96 of 129) ETA: unknown |
143 |
+1568996270 >>> kde-frameworks/kxmlgui... (98 of 129) ETA: unknown |
144 |
+1568996308 >>> net-analyzer/wireshark... (99 of 129) ETA: unknown |