From: "Fabian Groffen" <grobian@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage-utils:master commit in: tests/qlop/, /
Date: Sat, 31 Mar 2018 18:31:02 +0000 (UTC) [thread overview]
Message-ID: <1522520839.9b91c470b01b140c71d1cad71460c63c50faa342.grobian@gentoo> (raw)
commit: 9b91c470b01b140c71d1cad71460c63c50faa342
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 31 18:27:19 2018 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Mar 31 18:27:19 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9b91c470
qlop: document and format to fit on 80 chars, some style
qlop.c | 99 +++++++++++++++++++++++++++++++-------------------
tests/qlop/aborts.log | 71 ++++++++++++++++++++++++++++++++++++
tests/qlop/list09.good | 3 ++
3 files changed, 136 insertions(+), 37 deletions(-)
diff --git a/qlop.c b/qlop.c
index c01b3be..c7ad42f 100644
--- a/qlop.c
+++ b/qlop.c
@@ -89,6 +89,7 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea
count = merge_time = 0;
cat[0] = 0;
+ /* setup cat and pkg vars */
if ((p = strchr(package, '/')) != NULL) {
pkg = p + 1;
strncpy(cat, package, sizeof(cat));
@@ -103,51 +104,62 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea
return 1;
}
+ /* loop over lines searching for cat/pkg */
while (fgets(buf[0], sizeof(buf[0]), fp) != NULL) {
- if (strstr(buf[0], pkg) == NULL)
- continue;
-
if ((p = strchr(buf[0], '\n')) != NULL)
- *p = 0;
+ *p = '\0';
if ((p = strchr(buf[0], ':')) == NULL)
continue;
- *p = 0;
+ *p++ = '\0';
+ if (strstr(p, pkg) == NULL)
+ continue;
+
t[0] = atol(buf[0]);
if (t[0] < start_time || t[0] > end_time)
continue;
- strcpy(buf[1], p + 1);
+
+ /* copy message (stripping timestamp) */
+ strncpy(buf[1], p, BUFSIZ);
rmspace(buf[1]);
if (strncmp(buf[1], ">>> emerge (", 12) == 0) {
+ /* construct the matching end marker */
snprintf(ep, BUFSIZ, "completed %s", &buf[1][4]);
- char matched = 0;
- if ((p = strchr(buf[1], ')')) == NULL)
+ /* skip over "(X of Y)" */
+ if ((p = strchr(buf[1], ')')) == NULL) {
+ *ep = '\0';
continue;
- *p = 0;
- strcpy(buf[0], p + 1);
+ }
+ *p++ = '\0';
+
+ /* get the package as atom */
+ strncpy(buf[0], p, BUFSIZ);
rmspace(buf[0]);
- if ((p = strchr(buf[0], ' ')) == NULL)
+ if ((p = strchr(buf[0], ' ')) == NULL) {
+ *ep = '\0';
continue;
- *p = 0;
- if ((atom = atom_explode(buf[0])) == NULL)
+ }
+ *p = '\0';
+ if ((atom = atom_explode(buf[0])) == NULL) {
+ *ep = '\0';
continue;
+ }
- if (*cat) {
- if ((strcmp(cat, atom->CATEGORY) == 0) && (strcmp(pkg, atom->PN) == 0))
- matched = 1;
- } else if (strcmp(pkg, atom->PN) == 0)
- matched = 1;
-
- if (matched) {
+ /* match atom against our search */
+ if ((*cat && ((strcmp(cat, atom->CATEGORY) == 0) &&
+ (strcmp(pkg, atom->PN) == 0))) ||
+ (strcmp(pkg, atom->PN) == 0))
+ {
parallel_emerge = 0;
while (fgets(buf[0], sizeof(buf[0]), fp) != NULL) {
if ((p = strchr(buf[0], '\n')) != NULL)
- *p = 0;
+ *p = '\0';
if ((p = strchr(buf[0], ':')) == NULL)
continue;
- *p = 0;
+ *p++ = '\0';
+
t[1] = atol(buf[0]);
- strcpy(buf[1], p + 1);
+ strcpy(buf[1], p);
rmspace(buf[1]);
if (strncmp(buf[1], "Started emerge on:", 18) == 0) {
@@ -166,19 +178,25 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea
break;
}
- /*
- * pay attention to malformed log files (when the end of an emerge process
- * is not indicated by the line '*** terminating'). We assume than the log is
- * malformed when we find a parallel emerge process which is trying to
- * emerge the same package
+ /* pay attention to malformed log files (when the
+ * end of an emerge process is not indicated by the
+ * line '*** terminating'). We assume than the log
+ * is malformed when we find a parallel emerge
+ * process which is trying to emerge the same
+ * package
*/
- if (strncmp(buf[1], ">>> emerge (", 12) == 0 && parallel_emerge > 0) {
+ if (strncmp(buf[1], ">>> emerge (", 12) == 0 &&
+ parallel_emerge > 0)
+ {
+ /* find package name */
p = strchr(buf[1], ')');
q = strchr(ep, ')');
if (!p || !q)
continue;
- if (!strcmp(p, q)) {
+ /* is this emerge doing the same thing as we're
+ * looking for? that means we failed */
+ if (strcmp(p, q) == 0) {
parallel_emerge--;
/* update the main emerge reference data */
snprintf(ep, BUFSIZ, "completed %s", &buf[1][4]);
@@ -186,21 +204,28 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea
}
}
- if (strncmp(&buf[1][4], ep, BUFSIZ) == 0) {
+ /* if this line matches "completed emerge (X of Y) ..."
+ * we're finally somewhere */
+ if (strncmp(&buf[1][4], ep, BUFSIZ - 4) == 0) {
if (!average) {
- strcpy(buf[1], "");
+ buf[1][0] = '\0';
if (verbose) {
if (atom->PR_int)
- snprintf(buf[1], sizeof(buf[1]), "-%s-r%i", atom->PV, atom->PR_int);
+ snprintf(buf[1], sizeof(buf[1]),
+ "-%s-r%i", atom->PV, atom->PR_int);
else
- snprintf(buf[1], sizeof(buf[1]), "-%s", atom->PV);
+ snprintf(buf[1], sizeof(buf[1]),
+ "-%s", atom->PV);
}
- printf("%s%s%s%s: %s: ", BLUE, atom->PN, buf[1], NORM, chop_ctime(t[0]));
+ printf("%s%s%s%s: %s: ",
+ BLUE, atom->PN, buf[1], NORM,
+ chop_ctime(t[0]));
if (human_readable)
print_seconds_for_earthlings(t[1] - t[0]);
else
- printf("%s%"PRIu64"%s seconds", GREEN, (uint64_t)(t[1] - t[0]), NORM);
- puts("");
+ printf("%s%"PRIu64"%s seconds",
+ GREEN, (uint64_t)(t[1] - t[0]), NORM);
+ printf("\n");
}
merge_time += (t[1] - t[0]);
count++;
diff --git a/tests/qlop/aborts.log b/tests/qlop/aborts.log
new file mode 100644
index 0000000..1808cc6
--- /dev/null
+++ b/tests/qlop/aborts.log
@@ -0,0 +1,71 @@
+1364819649: >>> emerge (6 of 12) sys-devel/automake-1.11.6 to /
+1364819649: === (6 of 12) Cleaning (sys-devel/automake-1.11.6::/usr/portage/sys-devel/automake/automake-1.11.6.ebuild)
+1364819649: === (6 of 12) Compiling/Merging (sys-devel/automake-1.11.6::/usr/portage/sys-devel/automake/automake-1.11.6.ebuild)
+1364822878: === (6 of 12) Merging (sys-devel/automake-1.11.6::/usr/portage/sys-devel/automake/automake-1.11.6.ebuild)
+1364822879: >>> AUTOCLEAN: sys-devel/automake:1.11
+1364822879: === Unmerging... (sys-devel/automake-1.11.6)
+1364822879: >>> unmerge success: sys-devel/automake-1.11.6
+1364822881: === (6 of 12) Post-Build Cleaning (sys-devel/automake-1.11.6::/usr/portage/sys-devel/automake/automake-1.11.6.ebuild)
+1364822881: ::: completed emerge (6 of 12) sys-devel/automake-1.11.6 to /
+1364822881: >>> emerge (7 of 12) sys-devel/automake-1.9.6-r3 to /
+1364822881: === (7 of 12) Cleaning (sys-devel/automake-1.9.6-r3::/usr/portage/sys-devel/automake/automake-1.9.6-r3.ebuild)
+1364822881: === (7 of 12) Compiling/Merging (sys-devel/automake-1.9.6-r3::/usr/portage/sys-devel/automake/automake-1.9.6-r3.ebuild)
+1364823762: Started emerge on: Apr 01, 2013 15:42:41
+1364823762: *** emerge --update --verbose --rebuild-if-new-rev --newuse --complete-graph --with-bdeps=y --deep world
+1364823859: >>> emerge (1 of 3) app-arch/libarchive-3.1.2-r1 to /
+1364823859: === (1 of 3) Cleaning (app-arch/libarchive-3.1.2-r1::/usr/portage/app-arch/libarchive/libarchive-3.1.2-r1.ebuild)
+1364823860: === (1 of 3) Compiling/Merging (app-arch/libarchive-3.1.2-r1::/usr/portage/app-arch/libarchive/libarchive-3.1.2-r1.ebuild)
+1364823988: === (1 of 3) Merging (app-arch/libarchive-3.1.2-r1::/usr/portage/app-arch/libarchive/libarchive-3.1.2-r1.ebuild)
+1364823989: >>> AUTOCLEAN: app-arch/libarchive:0
+1364823989: === Unmerging... (app-arch/libarchive-3.0.4-r1)
+1364823991: >>> unmerge success: app-arch/libarchive-3.0.4-r1
+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)
+1364823992: ::: completed emerge (1 of 3) app-arch/libarchive-3.1.2-r1 to /
+1364823992: >>> emerge (2 of 3) app-emulation/winetricks-947 to /
+1364823992: === (2 of 3) Cleaning (app-emulation/winetricks-947::/usr/portage/app-emulation/winetricks/winetricks-947.ebuild)
+1364823992: === (2 of 3) Compiling/Merging (app-emulation/winetricks-947::/usr/portage/app-emulation/winetricks/winetricks-947.ebuild)
+1364823995: === (2 of 3) Merging (app-emulation/winetricks-947::/usr/portage/app-emulation/winetricks/winetricks-947.ebuild)
+1364823996: >>> AUTOCLEAN: app-emulation/winetricks:0
+1364823996: === Unmerging... (app-emulation/winetricks-941)
+1364823996: >>> unmerge success: app-emulation/winetricks-941
+1364823997: === (2 of 3) Post-Build Cleaning (app-emulation/winetricks-947::/usr/portage/app-emulation/winetricks/winetricks-947.ebuild)
+1364823997: ::: completed emerge (2 of 3) app-emulation/winetricks-947 to /
+1364823997: >>> emerge (3 of 3) dev-util/cmake-2.8.9 to /
+1364823997: === (3 of 3) Cleaning (dev-util/cmake-2.8.9::/usr/portage/dev-util/cmake/cmake-2.8.9.ebuild)
+1364823997: === (3 of 3) Compiling/Merging (dev-util/cmake-2.8.9::/usr/portage/dev-util/cmake/cmake-2.8.9.ebuild)
+1364824573: === (3 of 3) Merging (dev-util/cmake-2.8.9::/usr/portage/dev-util/cmake/cmake-2.8.9.ebuild)
+1364824576: >>> AUTOCLEAN: dev-util/cmake:0
+1364824576: === Unmerging... (dev-util/cmake-2.8.9)
+1364824577: >>> unmerge success: dev-util/cmake-2.8.9
+1364824578: === (3 of 3) Post-Build Cleaning (dev-util/cmake-2.8.9::/usr/portage/dev-util/cmake/cmake-2.8.9.ebuild)
+1364824578: ::: completed emerge (3 of 3) dev-util/cmake-2.8.9 to /
+1364824578: *** Finished. Cleaning up...
+1364824580: *** exiting successfully.
+1364824580: *** terminating.
+1368795479: Started emerge on: May 17, 2013 14:57:59
+1368795479: *** emerge --update --verbose --rebuild-if-new-rev --newuse --complete-graph --with-bdeps=y --deep world
+1368795519: >>> emerge (1 of 2) sys-devel/automake-1.9.6-r3 to /
+1368795519: === (1 of 2) Cleaning (sys-devel/automake-1.9.6-r3::/usr/portage/sys-devel/automake/automake-1.9.6-r3.ebuild)
+1368795519: === (1 of 2) Compiling/Merging (sys-devel/automake-1.9.6-r3::/usr/portage/sys-devel/automake/automake-1.9.6-r3.ebuild)
+1368796964: === (1 of 2) Merging (sys-devel/automake-1.9.6-r3::/usr/portage/sys-devel/automake/automake-1.9.6-r3.ebuild)
+1368796965: >>> AUTOCLEAN: sys-devel/automake:1.9
+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)
+1368796966: ::: completed emerge (1 of 2) sys-devel/automake-1.9.6-r3 to /
+1368796966: >>> emerge (2 of 2) app-mobilephone/obexftp-0.23-r1 to /
+1368796966: === (2 of 2) Cleaning (app-mobilephone/obexftp-0.23-r1::/usr/portage/app-mobilephone/obexftp/obexftp-0.23-r1.ebuild)
+1368796966: === (2 of 2) Compiling/Merging (app-mobilephone/obexftp-0.23-r1::/usr/portage/app-mobilephone/obexftp/obexftp-0.23-r1.ebuild)
+1368796985: === (2 of 2) Merging (app-mobilephone/obexftp-0.23-r1::/usr/portage/app-mobilephone/obexftp/obexftp-0.23-r1.ebuild)
+1368796986: >>> AUTOCLEAN: app-mobilephone/obexftp:0
+1368796986: === Unmerging... (app-mobilephone/obexftp-0.23-r1)
+1368796987: >>> unmerge success: app-mobilephone/obexftp-0.23-r1
+1368796988: === (2 of 2) Post-Build Cleaning (app-mobilephone/obexftp-0.23-r1::/usr/portage/app-mobilephone/obexftp/obexftp-0.23-r1.ebuild)
+1368796988: ::: completed emerge (2 of 2) app-mobilephone/obexftp-0.23-r1 to /
+1368796988: *** Finished. Cleaning up...
+1368796990: *** exiting successfully.
+1368796990: *** terminating.
+1368799175: Started emerge on: May 17, 2013 15:59:35
+1368799175: *** emerge --oneshot automake:1.12 automake:1.11 automake:1.9 libtool:2 binutils glibc:2.2 gcc:4.6
+1368799182: >>> emerge (1 of 7) sys-devel/automake-1.12.6 to /
+1368799182: === (1 of 7) Cleaning (sys-devel/automake-1.12.6::/usr/portage/sys-devel/automake/automake-1.12.6.ebuild)
+1368799183: === (1 of 7) Compiling/Merging (sys-devel/automake-1.12.6::/usr/portage/sys-devel/automake/automake-1.12.6.ebuild)
+1368799266: *** terminating.
diff --git a/tests/qlop/list09.good b/tests/qlop/list09.good
new file mode 100644
index 0000000..333d7ad
--- /dev/null
+++ b/tests/qlop/list09.good
@@ -0,0 +1,3 @@
+automake-1.11.6: Mon Apr 1 12:34:09 2013: 53 minutes, 52 seconds
+automake-1.9.6-r3: Fri May 17 12:58:39 2013: 24 minutes, 7 seconds
+automake: 2 times
next reply other threads:[~2018-03-31 18:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-31 18:31 Fabian Groffen [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-12-27 20:42 [gentoo-commits] proj/portage-utils:master commit in: tests/qlop/, / Fabian Groffen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1522520839.9b91c470b01b140c71d1cad71460c63c50faa342.grobian@gentoo \
--to=grobian@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox