1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

tests: harness updates

This commit is contained in:
Zdenek Kabelac 2013-06-12 14:16:25 +02:00
parent 036d4f2982
commit fa5d4bc780

View File

@ -93,9 +93,11 @@ static int outline(FILE *out, char *buf, int start, int force) {
if (!strncmp(from, "@TESTDIR=", 9)) { if (!strncmp(from, "@TESTDIR=", 9)) {
subst[0].key = "@TESTDIR@"; subst[0].key = "@TESTDIR@";
free(subst[0].value);
subst[0].value = strndup(from + 9, next - from - 9 - 1); subst[0].value = strndup(from + 9, next - from - 9 - 1);
} else if (!strncmp(from, "@PREFIX=", 8)) { } else if (!strncmp(from, "@PREFIX=", 8)) {
subst[1].key = "@PREFIX@"; subst[1].key = "@PREFIX@";
free(subst[1].value);
subst[1].value = strndup(from + 8, next - from - 8 - 1); subst[1].value = strndup(from + 8, next - from - 8 - 1);
} else { } else {
char *line = strndup(from, next - from); char *line = strndup(from, next - from);
@ -150,6 +152,7 @@ static void trickle(FILE *out, int *last, int *counter) {
static void clear(void) { static void clear(void) {
readbuf_used = 0; readbuf_used = 0;
fullbuffer = 0;
} }
static int64_t _get_time_us(void) static int64_t _get_time_us(void)
@ -389,13 +392,14 @@ static void run(int i, char *f) {
failed(i, f, st); failed(i, f, st);
} else } else
failed(i, f, st); failed(i, f, st);
clear();
if (outfile) if (outfile)
fclose(outfile); fclose(outfile);
if (fullbuffer) if (fullbuffer)
printf("\nTest was interrupted, output has got too large (>%u) (loop:%u)\n" printf("\nTest was interrupted, output has got too large (>%u) (loop:%u)\n"
"Set LVM_TEST_UNLIMITED=1 for unlimited log.\n", "Set LVM_TEST_UNLIMITED=1 for unlimited log.\n",
(unsigned) readbuf_sz, fullbuffer); (unsigned) readbuf_sz, fullbuffer);
clear();
} }
} }
@ -433,16 +437,21 @@ int main(int argc, char **argv) {
} }
/* set up signal handlers */ /* set up signal handlers */
for (i = 0; i <= 32; ++i) { for (i = 0; i <= 32; ++i)
if (i == SIGCHLD || i == SIGWINCH || i == SIGURG) switch (i) {
continue; case SIGCHLD: case SIGWINCH: case SIGURG:
signal(i, handler); case SIGKILL: case SIGSTOP: break;
default: signal(i, handler);
} }
/* run the tests */ /* run the tests */
for (i = 1; !die && i < argc; ++i) for (i = 1; !die && i < argc; ++i)
run(i, argv[i]); run(i, argv[i]);
free(subst[0].value);
free(subst[1].value);
free(readbuf);
printf("\n## %d tests %s : %d OK, %d warnings, %d failures, %d known failures; " printf("\n## %d tests %s : %d OK, %d warnings, %d failures, %d known failures; "
"%d skipped, %d interrupted\n", "%d skipped, %d interrupted\n",
s.nwarned + s.npassed + s.nfailed + s.nskipped + s.ninterrupted, s.nwarned + s.npassed + s.nfailed + s.nskipped + s.ninterrupted,
@ -490,7 +499,5 @@ int main(int argc, char **argv) {
return (s.nfailed > 0) || (s.ninterrupted > 0) || die; return (s.nfailed > 0) || (s.ninterrupted > 0) || die;
} }
free(readbuf);
return die; return die;
} }