Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: tests/qlop/, /
Date: Sat, 31 Mar 2018 18:31:07
Message-Id: 1522520839.9b91c470b01b140c71d1cad71460c63c50faa342.grobian@gentoo
1 commit: 9b91c470b01b140c71d1cad71460c63c50faa342
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Sat Mar 31 18:27:19 2018 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Sat Mar 31 18:27:19 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9b91c470
7
8 qlop: document and format to fit on 80 chars, some style
9
10 qlop.c | 99 +++++++++++++++++++++++++++++++-------------------
11 tests/qlop/aborts.log | 71 ++++++++++++++++++++++++++++++++++++
12 tests/qlop/list09.good | 3 ++
13 3 files changed, 136 insertions(+), 37 deletions(-)
14
15 diff --git a/qlop.c b/qlop.c
16 index c01b3be..c7ad42f 100644
17 --- a/qlop.c
18 +++ b/qlop.c
19 @@ -89,6 +89,7 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea
20 count = merge_time = 0;
21 cat[0] = 0;
22
23 + /* setup cat and pkg vars */
24 if ((p = strchr(package, '/')) != NULL) {
25 pkg = p + 1;
26 strncpy(cat, package, sizeof(cat));
27 @@ -103,51 +104,62 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea
28 return 1;
29 }
30
31 + /* loop over lines searching for cat/pkg */
32 while (fgets(buf[0], sizeof(buf[0]), fp) != NULL) {
33 - if (strstr(buf[0], pkg) == NULL)
34 - continue;
35 -
36 if ((p = strchr(buf[0], '\n')) != NULL)
37 - *p = 0;
38 + *p = '\0';
39 if ((p = strchr(buf[0], ':')) == NULL)
40 continue;
41 - *p = 0;
42 + *p++ = '\0';
43 + if (strstr(p, pkg) == NULL)
44 + continue;
45 +
46 t[0] = atol(buf[0]);
47 if (t[0] < start_time || t[0] > end_time)
48 continue;
49 - strcpy(buf[1], p + 1);
50 +
51 + /* copy message (stripping timestamp) */
52 + strncpy(buf[1], p, BUFSIZ);
53 rmspace(buf[1]);
54 if (strncmp(buf[1], ">>> emerge (", 12) == 0) {
55 + /* construct the matching end marker */
56 snprintf(ep, BUFSIZ, "completed %s", &buf[1][4]);
57
58 - char matched = 0;
59 - if ((p = strchr(buf[1], ')')) == NULL)
60 + /* skip over "(X of Y)" */
61 + if ((p = strchr(buf[1], ')')) == NULL) {
62 + *ep = '\0';
63 continue;
64 - *p = 0;
65 - strcpy(buf[0], p + 1);
66 + }
67 + *p++ = '\0';
68 +
69 + /* get the package as atom */
70 + strncpy(buf[0], p, BUFSIZ);
71 rmspace(buf[0]);
72 - if ((p = strchr(buf[0], ' ')) == NULL)
73 + if ((p = strchr(buf[0], ' ')) == NULL) {
74 + *ep = '\0';
75 continue;
76 - *p = 0;
77 - if ((atom = atom_explode(buf[0])) == NULL)
78 + }
79 + *p = '\0';
80 + if ((atom = atom_explode(buf[0])) == NULL) {
81 + *ep = '\0';
82 continue;
83 + }
84
85 - if (*cat) {
86 - if ((strcmp(cat, atom->CATEGORY) == 0) && (strcmp(pkg, atom->PN) == 0))
87 - matched = 1;
88 - } else if (strcmp(pkg, atom->PN) == 0)
89 - matched = 1;
90 -
91 - if (matched) {
92 + /* match atom against our search */
93 + if ((*cat && ((strcmp(cat, atom->CATEGORY) == 0) &&
94 + (strcmp(pkg, atom->PN) == 0))) ||
95 + (strcmp(pkg, atom->PN) == 0))
96 + {
97 parallel_emerge = 0;
98 while (fgets(buf[0], sizeof(buf[0]), fp) != NULL) {
99 if ((p = strchr(buf[0], '\n')) != NULL)
100 - *p = 0;
101 + *p = '\0';
102 if ((p = strchr(buf[0], ':')) == NULL)
103 continue;
104 - *p = 0;
105 + *p++ = '\0';
106 +
107 t[1] = atol(buf[0]);
108 - strcpy(buf[1], p + 1);
109 + strcpy(buf[1], p);
110 rmspace(buf[1]);
111
112 if (strncmp(buf[1], "Started emerge on:", 18) == 0) {
113 @@ -166,19 +178,25 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea
114 break;
115 }
116
117 - /*
118 - * pay attention to malformed log files (when the end of an emerge process
119 - * is not indicated by the line '*** terminating'). We assume than the log is
120 - * malformed when we find a parallel emerge process which is trying to
121 - * emerge the same package
122 + /* pay attention to malformed log files (when the
123 + * end of an emerge process is not indicated by the
124 + * line '*** terminating'). We assume than the log
125 + * is malformed when we find a parallel emerge
126 + * process which is trying to emerge the same
127 + * package
128 */
129 - if (strncmp(buf[1], ">>> emerge (", 12) == 0 && parallel_emerge > 0) {
130 + if (strncmp(buf[1], ">>> emerge (", 12) == 0 &&
131 + parallel_emerge > 0)
132 + {
133 + /* find package name */
134 p = strchr(buf[1], ')');
135 q = strchr(ep, ')');
136 if (!p || !q)
137 continue;
138
139 - if (!strcmp(p, q)) {
140 + /* is this emerge doing the same thing as we're
141 + * looking for? that means we failed */
142 + if (strcmp(p, q) == 0) {
143 parallel_emerge--;
144 /* update the main emerge reference data */
145 snprintf(ep, BUFSIZ, "completed %s", &buf[1][4]);
146 @@ -186,21 +204,28 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea
147 }
148 }
149
150 - if (strncmp(&buf[1][4], ep, BUFSIZ) == 0) {
151 + /* if this line matches "completed emerge (X of Y) ..."
152 + * we're finally somewhere */
153 + if (strncmp(&buf[1][4], ep, BUFSIZ - 4) == 0) {
154 if (!average) {
155 - strcpy(buf[1], "");
156 + buf[1][0] = '\0';
157 if (verbose) {
158 if (atom->PR_int)
159 - snprintf(buf[1], sizeof(buf[1]), "-%s-r%i", atom->PV, atom->PR_int);
160 + snprintf(buf[1], sizeof(buf[1]),
161 + "-%s-r%i", atom->PV, atom->PR_int);
162 else
163 - snprintf(buf[1], sizeof(buf[1]), "-%s", atom->PV);
164 + snprintf(buf[1], sizeof(buf[1]),
165 + "-%s", atom->PV);
166 }
167 - printf("%s%s%s%s: %s: ", BLUE, atom->PN, buf[1], NORM, chop_ctime(t[0]));
168 + printf("%s%s%s%s: %s: ",
169 + BLUE, atom->PN, buf[1], NORM,
170 + chop_ctime(t[0]));
171 if (human_readable)
172 print_seconds_for_earthlings(t[1] - t[0]);
173 else
174 - printf("%s%"PRIu64"%s seconds", GREEN, (uint64_t)(t[1] - t[0]), NORM);
175 - puts("");
176 + printf("%s%"PRIu64"%s seconds",
177 + GREEN, (uint64_t)(t[1] - t[0]), NORM);
178 + printf("\n");
179 }
180 merge_time += (t[1] - t[0]);
181 count++;
182
183 diff --git a/tests/qlop/aborts.log b/tests/qlop/aborts.log
184 new file mode 100644
185 index 0000000..1808cc6
186 --- /dev/null
187 +++ b/tests/qlop/aborts.log
188 @@ -0,0 +1,71 @@
189 +1364819649: >>> emerge (6 of 12) sys-devel/automake-1.11.6 to /
190 +1364819649: === (6 of 12) Cleaning (sys-devel/automake-1.11.6::/usr/portage/sys-devel/automake/automake-1.11.6.ebuild)
191 +1364819649: === (6 of 12) Compiling/Merging (sys-devel/automake-1.11.6::/usr/portage/sys-devel/automake/automake-1.11.6.ebuild)
192 +1364822878: === (6 of 12) Merging (sys-devel/automake-1.11.6::/usr/portage/sys-devel/automake/automake-1.11.6.ebuild)
193 +1364822879: >>> AUTOCLEAN: sys-devel/automake:1.11
194 +1364822879: === Unmerging... (sys-devel/automake-1.11.6)
195 +1364822879: >>> unmerge success: sys-devel/automake-1.11.6
196 +1364822881: === (6 of 12) Post-Build Cleaning (sys-devel/automake-1.11.6::/usr/portage/sys-devel/automake/automake-1.11.6.ebuild)
197 +1364822881: ::: completed emerge (6 of 12) sys-devel/automake-1.11.6 to /
198 +1364822881: >>> emerge (7 of 12) sys-devel/automake-1.9.6-r3 to /
199 +1364822881: === (7 of 12) Cleaning (sys-devel/automake-1.9.6-r3::/usr/portage/sys-devel/automake/automake-1.9.6-r3.ebuild)
200 +1364822881: === (7 of 12) Compiling/Merging (sys-devel/automake-1.9.6-r3::/usr/portage/sys-devel/automake/automake-1.9.6-r3.ebuild)
201 +1364823762: Started emerge on: Apr 01, 2013 15:42:41
202 +1364823762: *** emerge --update --verbose --rebuild-if-new-rev --newuse --complete-graph --with-bdeps=y --deep world
203 +1364823859: >>> emerge (1 of 3) app-arch/libarchive-3.1.2-r1 to /
204 +1364823859: === (1 of 3) Cleaning (app-arch/libarchive-3.1.2-r1::/usr/portage/app-arch/libarchive/libarchive-3.1.2-r1.ebuild)
205 +1364823860: === (1 of 3) Compiling/Merging (app-arch/libarchive-3.1.2-r1::/usr/portage/app-arch/libarchive/libarchive-3.1.2-r1.ebuild)
206 +1364823988: === (1 of 3) Merging (app-arch/libarchive-3.1.2-r1::/usr/portage/app-arch/libarchive/libarchive-3.1.2-r1.ebuild)
207 +1364823989: >>> AUTOCLEAN: app-arch/libarchive:0
208 +1364823989: === Unmerging... (app-arch/libarchive-3.0.4-r1)
209 +1364823991: >>> unmerge success: app-arch/libarchive-3.0.4-r1
210 +1364823992: === (1 of 3) Post-Build Cleaning (app-arch/libarchive-3.1.2-r1::/usr/portage/app-arch/libarchive/libarchive-3.1.2-r1.ebuild)
211 +1364823992: ::: completed emerge (1 of 3) app-arch/libarchive-3.1.2-r1 to /
212 +1364823992: >>> emerge (2 of 3) app-emulation/winetricks-947 to /
213 +1364823992: === (2 of 3) Cleaning (app-emulation/winetricks-947::/usr/portage/app-emulation/winetricks/winetricks-947.ebuild)
214 +1364823992: === (2 of 3) Compiling/Merging (app-emulation/winetricks-947::/usr/portage/app-emulation/winetricks/winetricks-947.ebuild)
215 +1364823995: === (2 of 3) Merging (app-emulation/winetricks-947::/usr/portage/app-emulation/winetricks/winetricks-947.ebuild)
216 +1364823996: >>> AUTOCLEAN: app-emulation/winetricks:0
217 +1364823996: === Unmerging... (app-emulation/winetricks-941)
218 +1364823996: >>> unmerge success: app-emulation/winetricks-941
219 +1364823997: === (2 of 3) Post-Build Cleaning (app-emulation/winetricks-947::/usr/portage/app-emulation/winetricks/winetricks-947.ebuild)
220 +1364823997: ::: completed emerge (2 of 3) app-emulation/winetricks-947 to /
221 +1364823997: >>> emerge (3 of 3) dev-util/cmake-2.8.9 to /
222 +1364823997: === (3 of 3) Cleaning (dev-util/cmake-2.8.9::/usr/portage/dev-util/cmake/cmake-2.8.9.ebuild)
223 +1364823997: === (3 of 3) Compiling/Merging (dev-util/cmake-2.8.9::/usr/portage/dev-util/cmake/cmake-2.8.9.ebuild)
224 +1364824573: === (3 of 3) Merging (dev-util/cmake-2.8.9::/usr/portage/dev-util/cmake/cmake-2.8.9.ebuild)
225 +1364824576: >>> AUTOCLEAN: dev-util/cmake:0
226 +1364824576: === Unmerging... (dev-util/cmake-2.8.9)
227 +1364824577: >>> unmerge success: dev-util/cmake-2.8.9
228 +1364824578: === (3 of 3) Post-Build Cleaning (dev-util/cmake-2.8.9::/usr/portage/dev-util/cmake/cmake-2.8.9.ebuild)
229 +1364824578: ::: completed emerge (3 of 3) dev-util/cmake-2.8.9 to /
230 +1364824578: *** Finished. Cleaning up...
231 +1364824580: *** exiting successfully.
232 +1364824580: *** terminating.
233 +1368795479: Started emerge on: May 17, 2013 14:57:59
234 +1368795479: *** emerge --update --verbose --rebuild-if-new-rev --newuse --complete-graph --with-bdeps=y --deep world
235 +1368795519: >>> emerge (1 of 2) sys-devel/automake-1.9.6-r3 to /
236 +1368795519: === (1 of 2) Cleaning (sys-devel/automake-1.9.6-r3::/usr/portage/sys-devel/automake/automake-1.9.6-r3.ebuild)
237 +1368795519: === (1 of 2) Compiling/Merging (sys-devel/automake-1.9.6-r3::/usr/portage/sys-devel/automake/automake-1.9.6-r3.ebuild)
238 +1368796964: === (1 of 2) Merging (sys-devel/automake-1.9.6-r3::/usr/portage/sys-devel/automake/automake-1.9.6-r3.ebuild)
239 +1368796965: >>> AUTOCLEAN: sys-devel/automake:1.9
240 +1368796966: === (1 of 2) Post-Build Cleaning (sys-devel/automake-1.9.6-r3::/usr/portage/sys-devel/automake/automake-1.9.6-r3.ebuild)
241 +1368796966: ::: completed emerge (1 of 2) sys-devel/automake-1.9.6-r3 to /
242 +1368796966: >>> emerge (2 of 2) app-mobilephone/obexftp-0.23-r1 to /
243 +1368796966: === (2 of 2) Cleaning (app-mobilephone/obexftp-0.23-r1::/usr/portage/app-mobilephone/obexftp/obexftp-0.23-r1.ebuild)
244 +1368796966: === (2 of 2) Compiling/Merging (app-mobilephone/obexftp-0.23-r1::/usr/portage/app-mobilephone/obexftp/obexftp-0.23-r1.ebuild)
245 +1368796985: === (2 of 2) Merging (app-mobilephone/obexftp-0.23-r1::/usr/portage/app-mobilephone/obexftp/obexftp-0.23-r1.ebuild)
246 +1368796986: >>> AUTOCLEAN: app-mobilephone/obexftp:0
247 +1368796986: === Unmerging... (app-mobilephone/obexftp-0.23-r1)
248 +1368796987: >>> unmerge success: app-mobilephone/obexftp-0.23-r1
249 +1368796988: === (2 of 2) Post-Build Cleaning (app-mobilephone/obexftp-0.23-r1::/usr/portage/app-mobilephone/obexftp/obexftp-0.23-r1.ebuild)
250 +1368796988: ::: completed emerge (2 of 2) app-mobilephone/obexftp-0.23-r1 to /
251 +1368796988: *** Finished. Cleaning up...
252 +1368796990: *** exiting successfully.
253 +1368796990: *** terminating.
254 +1368799175: Started emerge on: May 17, 2013 15:59:35
255 +1368799175: *** emerge --oneshot automake:1.12 automake:1.11 automake:1.9 libtool:2 binutils glibc:2.2 gcc:4.6
256 +1368799182: >>> emerge (1 of 7) sys-devel/automake-1.12.6 to /
257 +1368799182: === (1 of 7) Cleaning (sys-devel/automake-1.12.6::/usr/portage/sys-devel/automake/automake-1.12.6.ebuild)
258 +1368799183: === (1 of 7) Compiling/Merging (sys-devel/automake-1.12.6::/usr/portage/sys-devel/automake/automake-1.12.6.ebuild)
259 +1368799266: *** terminating.
260
261 diff --git a/tests/qlop/list09.good b/tests/qlop/list09.good
262 new file mode 100644
263 index 0000000..333d7ad
264 --- /dev/null
265 +++ b/tests/qlop/list09.good
266 @@ -0,0 +1,3 @@
267 +automake-1.11.6: Mon Apr 1 12:34:09 2013: 53 minutes, 52 seconds
268 +automake-1.9.6-r3: Fri May 17 12:58:39 2013: 24 minutes, 7 seconds
269 +automake: 2 times