From cb6226ea65cde3156590cfa62b1d6fcbe9b05bfe Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 14 Jan 2007 17:47:01 +0000 Subject: [PATCH] * Added -v/--verbose (unused yet). --- doc/zzuf.1 | 12 ++++++++---- src/zzuf.c | 21 ++++++++++++++------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/doc/zzuf.1 b/doc/zzuf.1 index 241e58b..e9d16d7 100644 --- a/doc/zzuf.1 +++ b/doc/zzuf.1 @@ -2,13 +2,13 @@ .SH NAME zzuf \- multiple purpose fuzzer .SH SYNOPSIS -\fBzzuf\fR [\fB\-AcdiMnqSx\fR] [\fB\-r\fR \fIratio\fR] [\fB\-s\fR \fIseed\fR|\fB\-s\fR \fIstart:stop\fR] +\fBzzuf\fR [\fB\-AcdiMnqSvx\fR] [\fB\-r\fR \fIratio\fR] [\fB\-s\fR \fIseed\fR|\fB\-s\fR \fIstart:stop\fR] .br - [\fB\-D\fR \fIdelay\fR] [\fB\-F\fR \fIforks\fR] [\fB\-C\fR \fIcrashes\fR] [\fB\-B\fR \fIbytes\fR] + [\fB\-D\fR \fIdelay\fR] [\fB\-F\fR \fIforks\fR] [\fB\-C\fR \fIcrashes\fR] [\fB\-B\fR \fIbytes\fR] .br - [\fB\-T\fR \fIseconds\fR] [\fB\-M\fR \fImegabytes\fR] [\fB\-P\fR \fIprotect\fR] [\fB\-R\fR \fIrefuse\fR] + [\fB\-T\fR \fIseconds\fR] [\fB\-M\fR \fImegabytes\fR] [\fB\-P\fR \fIprotect\fR] [\fB\-R\fR \fIrefuse\fR] .br - [\fB\-I\fR \fIinclude\fR] [\fB\-E\fR \fIexclude\fR] [\fIPROGRAM\fR [\fB\-\-\fR] [\fIARGS\fR]...] + [\fB\-I\fR \fIinclude\fR] [\fB\-E\fR \fIexclude\fR] [\fIPROGRAM\fR [\fB\-\-\fR] [\fIARGS\fR]...] .br \fBzzuf \-h\fR | \fB\-\-help\fR .br @@ -207,6 +207,10 @@ Automatically terminate child processes that run for more than \fIn\fR seconds. This is useful to detect infinite loops or processes stuck in other situations. See also the \fB\-B\fR flag. .TP +\fB\-v\fR, \fB\-\-verbose\fR +Print information during the run, such as the current seed, what processes +get run, their exit status, etc. +.TP \fB\-x\fR, \fB\-\-check\-exit\fR Report processes that exit with a non-zero status. By default only processes that crash due to a signal are reported. diff --git a/src/zzuf.c b/src/zzuf.c index 3b3dc12..6e149c3 100644 --- a/src/zzuf.c +++ b/src/zzuf.c @@ -86,6 +86,7 @@ static int quiet = 0; static int maxbytes = -1; static int md5 = 0; static int checkexit = 0; +static int verbose = 0; static int maxmem = -1; static int64_t maxtime = -1; static int64_t delay = 0; @@ -112,7 +113,7 @@ int main(int argc, char *argv[]) #if defined(HAVE_GETOPT_H) for(;;) { -# define OPTSTR "AB:cC:dD:E:F:iI:mM:nP:qr:R:s:ST:xhV" +# define OPTSTR "AB:cC:dD:E:F:iI:mM:nP:qr:R:s:ST:vxhV" # ifdef HAVE_GETOPT_LONG # define MOREINFO "Try `%s --help' for more information.\n" int option_index = 0; @@ -139,6 +140,7 @@ int main(int argc, char *argv[]) { "seed", 1, NULL, 's' }, { "signal", 0, NULL, 'S' }, { "max-time", 1, NULL, 'T' }, + { "verbose", 0, NULL, 'v' }, { "check-exit", 0, NULL, 'x' }, { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, @@ -232,6 +234,9 @@ int main(int argc, char *argv[]) case 'x': /* --check-exit */ checkexit = 1; break; + case 'v': /* --verbose */ + verbose = 1; + break; case 'h': /* --help */ usage(); return 0; @@ -536,7 +541,7 @@ static void clean_children(void) if(child_list[i].status == STATUS_RUNNING && maxbytes >= 0 && child_list[i].bytes > maxbytes) { - fprintf(stdout, "zzuf[seed=%i]: data exceeded, sending SIGTERM\n", + fprintf(stdout, "zzuf[seed=%i]: data output exceeded, sending SIGTERM\n", child_list[i].seed); kill(child_list[i].pid, SIGTERM); child_list[i].date = now; @@ -547,7 +552,7 @@ static void clean_children(void) && maxtime >= 0 && now > child_list[i].date + maxtime) { - fprintf(stdout, "zzuf[seed=%i]: time exceeded, sending SIGTERM\n", + fprintf(stdout, "zzuf[seed=%i]: running time exceeded, sending SIGTERM\n", child_list[i].seed); kill(child_list[i].pid, SIGTERM); child_list[i].date = now; @@ -763,10 +768,10 @@ static void version(void) #if defined(HAVE_GETOPT_H) static void usage(void) { - printf("Usage: zzuf [-AcdimnqSx] [-r ratio] [-s seed | -s start:stop]\n"); - printf(" [-D delay] [-F forks] [-C crashes] [-B bytes]\n"); - printf(" [-T seconds] [-M bytes] [-P protect] [-R refuse]\n"); - printf(" [-I include] [-E exclude] [PROGRAM [--] [ARGS]...]\n"); + printf("Usage: zzuf [-AcdimnqSvx] [-r ratio] [-s seed | -s start:stop]\n"); + printf(" [-D delay] [-F forks] [-C crashes] [-B bytes]\n"); + printf(" [-T seconds] [-M bytes] [-P protect] [-R refuse]\n"); + printf(" [-I include] [-E exclude] [PROGRAM [--] [ARGS]...]\n"); # ifdef HAVE_GETOPT_LONG printf(" zzuf -h | --help\n"); printf(" zzuf -V | --version\n"); @@ -799,6 +804,7 @@ static void usage(void) printf(" --seed specify a seed range\n"); printf(" -S, --signal prevent children from diverting crashing signals\n"); printf(" -T, --max-time kill children that run for more than seconds\n"); + printf(" -v, --verbose print information during the run\n"); printf(" -x, --check-exit report processes that exit with a non-zero status\n"); printf(" -h, --help display this help and exit\n"); printf(" -V, --version output version information and exit\n"); @@ -824,6 +830,7 @@ static void usage(void) printf(" specify a seed range\n"); printf(" -S prevent children from diverting crashing signals\n"); printf(" -T kill children that run for more than seconds\n"); + printf(" -v print information during the run\n"); printf(" -x report processes that exit with a non-zero status\n"); printf(" -h display this help and exit\n"); printf(" -V output version information and exit\n");