From: zkabelac@sourceware.org <zkabelac@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2/test/lib harness.c
Date: 28 Jan 2011 16:05:38 -0000 [thread overview]
Message-ID: <20110128160538.27414.qmail@sourceware.org> (raw)
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: zkabelac at sourceware.org 2011-01-28 16:05:38
Modified files:
test/lib : harness.c
Log message:
Display duration of tests when it passed.
Enhance output with info about the test duration.
Cleanup few declarations in the code.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lib/harness.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6
--- LVM2/test/lib/harness.c 2011/01/13 15:03:28 1.5
+++ LVM2/test/lib/harness.c 2011/01/28 16:05:38 1.6
@@ -20,6 +20,7 @@
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
+#include <time.h>
static pid_t pid;
static int fds[2];
@@ -82,9 +83,9 @@
char *line = strndup(from, next - from);
char *a = line, *b;
do {
- b = line + strlen(line);
int idx = -1;
int i;
+ b = line + strlen(line);
for ( i = 0; i < 2; ++i ) {
if (subst[i].key) {
// printf("trying: %s -> %s\n", subst[i].value, subst[i].key);
@@ -145,15 +146,24 @@
}
}
-static void passed(int i, char *f) {
+static const char *duration(time_t start)
+{
+ static char buf[16];
+ int t = (int)(time(NULL) - start);
+
+ sprintf(buf, "%2d:%02d", t / 60, t % 60);
+ return buf;
+}
+
+static void passed(int i, char *f, time_t t) {
if (strstr(readbuf, "TEST WARNING")) {
++s.nwarned;
s.status[i] = WARNED;
- printf("warnings\n");
+ printf("warnings %s\n", duration(t));
} else {
++ s.npassed;
s.status[i] = PASSED;
- printf("passed.\n");
+ printf("passed. %s\n", duration(t));
}
}
@@ -192,12 +202,13 @@
fflush(stderr);
_exit(202);
} else {
+ int st, w;
+ time_t start = time(NULL);
char buf[128];
snprintf(buf, 128, "%s ...", f);
buf[127] = 0;
printf("Running %-40s ", buf);
fflush(stdout);
- int st, w;
while ((w = waitpid(pid, &st, WNOHANG)) == 0) {
drain();
usleep(20000);
@@ -209,7 +220,7 @@
drain();
if (WIFEXITED(st)) {
if (WEXITSTATUS(st) == 0) {
- passed(i, f);
+ passed(i, f, start);
} else if (WEXITSTATUS(st) == 200) {
skipped(i, f);
} else {
@@ -223,6 +234,8 @@
}
int main(int argc, char **argv) {
+ const char *be_verbose = getenv("VERBOSE");
+ time_t start = time(NULL);
int i;
if (argc >= MAX) {
@@ -230,9 +243,6 @@
exit(1);
}
- s.nwarned = s.nfailed = s.npassed = s.nskipped = 0;
-
- char *be_verbose = getenv("VERBOSE");
if (be_verbose && atoi(be_verbose))
verbose = 1; // XXX
@@ -260,8 +270,9 @@
break;
}
- printf("\n## %d tests: %d OK, %d warnings, %d failures; %d skipped\n",
+ printf("\n## %d tests %s : %d OK, %d warnings, %d failures; %d skipped\n",
s.nwarned + s.npassed + s.nfailed + s.nskipped,
+ duration(start),
s.npassed, s.nwarned, s.nfailed, s.nskipped);
/* print out a summary */
@@ -279,5 +290,6 @@
printf("\n");
return s.nfailed > 0 || die;
}
+
return die;
}
next reply other threads:[~2011-01-28 16:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-28 16:05 zkabelac [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-03-12 14:24 LVM2/test/lib harness.c zkabelac
2012-02-15 1:31 mornfall
2011-11-07 17:02 mornfall
2011-09-24 21:12 zkabelac
2011-03-10 14:47 zkabelac
2011-01-13 15:03 zkabelac
2011-01-13 11:02 zkabelac
2011-01-10 13:25 zkabelac
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=20110128160538.27414.qmail@sourceware.org \
--to=zkabelac@sourceware.org \
--cc=lvm-devel@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.