From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage-utils:master commit in: tests/qlop/, /, tests/
Date: Tue, 19 May 2015 17:37:24 +0000 (UTC) [thread overview]
Message-ID: <1432054204.ce0ebbec90f6a49648784ce106a4fbaf4def4d7e.vapier@gentoo> (raw)
commit: ce0ebbec90f6a49648784ce106a4fbaf4def4d7e
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue May 19 16:50:04 2015 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue May 19 16:50:04 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ce0ebbec
qlop: support new sync log format
Portage updated the format of sync entries, so update the parser as well.
URL: https://bugs.gentoo.org/540400
Reported-by: Albert W. Hopkins <marduk <AT> python.net>
qlop.c | 54 ++++++++++++++++++++++++++++++++++++++------------
tests/Makefile | 2 +-
tests/qlop/Makefile | 11 ++++++++++
tests/qlop/dotest | 30 ++++++++++++++++++++++++++++
tests/qlop/list01.good | 2 ++
tests/qlop/sync.log | 13 ++++++++++++
6 files changed, 98 insertions(+), 14 deletions(-)
diff --git a/qlop.c b/qlop.c
index a2541e2..93dbcc8 100644
--- a/qlop.c
+++ b/qlop.c
@@ -304,12 +304,31 @@ show_emerge_history(char listflag, int argc, char **argv, const char *logfile)
fclose(fp);
}
+/* The format of the sync log has changed over time.
+
+Old format:
+1106804103: Started emerge on: Jan 27, 2005 05:35:03
+1106804103: *** emerge sync
+1106804103: === sync
+1106804103: >>> starting rsync with rsync://192.168.0.5/gentoo-portage
+1106804537: === Sync completed with rsync://192.168.0.5/gentoo-portage
+1106804538: *** terminating.
+
+New format:
+1431764402: Started emerge on: May 16, 2015 04:20:01
+1431764402: *** emerge --quiet --keep-going --verbose --nospinner --oneshot --quiet-build=n --sync
+1431764402: === sync
+1431764402: >>> Syncing repository 'gentoo' into '/usr/portage'...
+1431764402: >>> Starting rsync with rsync://[2a01:90:200:10::1a]/gentoo-portage
+1431764460: === Sync completed for gentoo
+1431764493: *** terminating.
+*/
_q_static void
show_sync_history(const char *logfile)
{
FILE *fp;
- size_t buflen;
- char *buf, *p, *q;
+ size_t buflen, len;
+ char *buf, *p;
time_t t;
if ((fp = fopen(logfile, "r")) == NULL) {
@@ -318,26 +337,35 @@ show_sync_history(const char *logfile)
}
buf = NULL;
+ /* Just find the finish lines. */
while (getline(&buf, &buflen, fp) != -1) {
- if (strlen(buf) < 35)
- continue;
- if (strncmp(buf+12, "=== Sync completed with", 23) != 0)
+ len = strlen(buf);
+ /* This cuts out like ~10% of the log. */
+ if (len < 35)
continue;
- if ((p = strchr(buf, '\n')) != NULL)
- *p = 0;
+ /* Make sure there's a timestamp in here. */
if ((p = strchr(buf, ':')) == NULL)
continue;
- *p = 0;
- q = p+2;
+ p += 2;
+
+ if (strncmp(p, "=== Sync completed ", 19) != 0)
+ continue;
+ p += 19;
+
+ if (buf[len - 1] == '\n')
+ buf[len - 1] = '\0';
t = (time_t)atol(buf);
- if ((p = strstr(q, "with")) == NULL)
+ if (!strncmp(p, "with ", 5))
+ p += 5;
+ else if (!strncmp(p, "for ", 4))
+ /* This shows just the repo name not the remote host ... */
+ p += 4;
+ else
continue;
- q = p + 5;
-
- printf("%s >>> %s%s%s\n", chop_ctime(t), GREEN, q, NORM);
+ printf("%s >>> %s%s%s\n", chop_ctime(t), GREEN, p, NORM);
}
free(buf);
diff --git a/tests/Makefile b/tests/Makefile
index c0aedb4..b4d6005 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,6 +1,6 @@
TESTS = \
reinitialize atom_compare atom_explode mkdir \
- qcheck qdepends qfile qlist qmerge qtbz2 quse qxpak \
+ qcheck qdepends qfile qlist qlop qmerge qtbz2 quse qxpak \
install profile source
all: check
diff --git a/tests/qlop/Makefile b/tests/qlop/Makefile
new file mode 100644
index 0000000..11a6921
--- /dev/null
+++ b/tests/qlop/Makefile
@@ -0,0 +1,11 @@
+thisdir = qlop
+include ../subdir.mk
+
+all: check
+
+test check:
+ $(Q)$(s)/dotest
+
+clean:
+
+.PHONY: all check clean test
diff --git a/tests/qlop/dotest b/tests/qlop/dotest
new file mode 100755
index 0000000..8182e67
--- /dev/null
+++ b/tests/qlop/dotest
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+. ../init.sh
+
+set -e
+
+mktmpdir
+
+test() {
+ local num=$1 exp=$2 ret=0
+ shift 2
+ eval "$@" > list || ret=$?
+ if ! diff -u list ${as}/list${num}.good ; then
+ tfail "output does not match"
+ fi
+ if [[ ${exp} -ne ${ret} ]] ; then
+ tfail "exit code (${ret}) does not match expected (${exp})"
+ fi
+ tend $? "$*"
+}
+
+# We output dates, so make sure it matches our logs.
+export LC_TIME="C"
+
+# simple install check
+test 01 0 "qlop -s -f ${as}/sync.log"
+
+cleantmpdir
+
+end
diff --git a/tests/qlop/list01.good b/tests/qlop/list01.good
new file mode 100644
index 0000000..458c751
--- /dev/null
+++ b/tests/qlop/list01.good
@@ -0,0 +1,2 @@
+Thu Jan 27 00:42:17 2005 >>> rsync://192.168.0.5/gentoo-portage
+Sat May 16 04:21:00 2015 >>> gentoo
diff --git a/tests/qlop/sync.log b/tests/qlop/sync.log
new file mode 100644
index 0000000..fc31edb
--- /dev/null
+++ b/tests/qlop/sync.log
@@ -0,0 +1,13 @@
+1106804103: Started emerge on: Jan 27, 2005 05:35:03
+1106804103: *** emerge sync
+1106804103: === sync
+1106804103: >>> starting rsync with rsync://192.168.0.5/gentoo-portage
+1106804537: === Sync completed with rsync://192.168.0.5/gentoo-portage
+1106804538: *** terminating.
+1431764402: Started emerge on: May 16, 2015 04:20:01
+1431764402: *** emerge --quiet --keep-going --verbose --nospinner --oneshot --quiet-build=n --sync
+1431764402: === sync
+1431764402: >>> Syncing repository 'gentoo' into '/usr/portage'...
+1431764402: >>> Starting rsync with rsync://[2a01:90:200:10::1a]/gentoo-portage
+1431764460: === Sync completed for gentoo
+1431764493: *** terminating.
reply other threads:[~2015-05-19 17:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1432054204.ce0ebbec90f6a49648784ce106a4fbaf4def4d7e.vapier@gentoo \
--to=vapier@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