scriptreplay: add --summary

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2019-06-28 10:19:40 +02:00
parent 70c2cd9a60
commit 4a4f4a6260
2 changed files with 28 additions and 9 deletions

View File

@ -77,6 +77,12 @@ Set the maximum delay between transcript updates to
of seconds. The argument is a floating point number. This can be used to of seconds. The argument is a floating point number. This can be used to
avoid long pauses in the transcript replay. avoid long pauses in the transcript replay.
.TP .TP
.BR " \-\-summary "
Display details about session recorded in the specified timing file and exit. The session has
to be recorded by "advanced" format (see
.B script (1)
option \fB\-\-logging\-format\fR for more details).
.TP
.BR \-x , " \-\-stream " \fItype\fR .BR \-x , " \-\-stream " \fItype\fR
Forces scriptreplay to print only specified stream. The supported stream types Forces scriptreplay to print only specified stream. The supported stream types
are 'in' or 'out'. This option is recommended for multi-stream logs (e.g. --log-io) are 'in' or 'out'. This option is recommended for multi-stream logs (e.g. --log-io)

View File

@ -342,7 +342,7 @@ static int replay_get_next_step(struct replay_setup *stp, char *streams, struct
assert(stp); assert(stp);
assert(stp->timing_fp); assert(stp->timing_fp);
assert(xstep && *xstep); assert(xstep);
step = &stp->step; step = &stp->step;
*xstep = NULL; *xstep = NULL;
@ -434,7 +434,7 @@ static int replay_emit_step_data(struct replay_setup *stp, struct replay_step *s
assert(step->name); assert(step->name);
assert(step->value); assert(step->value);
dprintf(fd, "%10s: %s\n", step->name, step->value); dprintf(fd, "%10s: %s\n", step->name, step->value);
DBG(LOG, ul_debug("log signal emited")); DBG(LOG, ul_debug("log header emited"));
return 0; return 0;
default: default:
break; /* continue with real data */ break; /* continue with real data */
@ -518,6 +518,7 @@ usage(void)
fputs(_(" -s, --typescript <file> deprecated alist to -O\n"), out); fputs(_(" -s, --typescript <file> deprecated alist to -O\n"), out);
fputs(USAGE_SEPARATOR, out); fputs(USAGE_SEPARATOR, out);
fputs(_(" --summary display overview about recorded session and exit\n"), out);
fputs(_(" -d, --divisor <num> speed up or slow down execution with time divisor\n"), out); fputs(_(" -d, --divisor <num> speed up or slow down execution with time divisor\n"), out);
fputs(_(" -m, --maxdelay <num> wait at most this many seconds between updates\n"), out); fputs(_(" -m, --maxdelay <num> wait at most this many seconds between updates\n"), out);
fputs(_(" -x, --stream <name> stream type (out, in, signal or info)\n"), out); fputs(_(" -x, --stream <name> stream type (out, in, signal or info)\n"), out);
@ -580,7 +581,7 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
struct replay_setup setup = { .nlogs = 0 }; struct replay_setup setup = { .nlogs = 0 };
struct replay_step *step; struct replay_step *step = NULL;
char streams[6] = {0}; /* IOSI - in, out, signal,info */ char streams[6] = {0}; /* IOSI - in, out, signal,info */
const char *log_out = NULL, const char *log_out = NULL,
*log_in = NULL, *log_in = NULL,
@ -588,7 +589,10 @@ main(int argc, char *argv[])
*log_tm = NULL; *log_tm = NULL;
double divi = 1, maxdelay = 0; double divi = 1, maxdelay = 0;
int diviopt = FALSE, maxdelayopt = FALSE, idx; int diviopt = FALSE, maxdelayopt = FALSE, idx;
int ch, rc, crmode = REPLAY_CRMODE_AUTO; int ch, rc, crmode = REPLAY_CRMODE_AUTO, summary = 0;
enum {
OPT_SUMMARY = CHAR_MAX + 1
};
static const struct option longopts[] = { static const struct option longopts[] = {
{ "cr-mode", required_argument, 0, 'c' }, { "cr-mode", required_argument, 0, 'c' },
@ -600,6 +604,7 @@ main(int argc, char *argv[])
{ "divisor", required_argument, 0, 'd' }, { "divisor", required_argument, 0, 'd' },
{ "maxdelay", required_argument, 0, 'm' }, { "maxdelay", required_argument, 0, 'm' },
{ "stream", required_argument, 0, 'x' }, { "stream", required_argument, 0, 'x' },
{ "summary", no_argument, 0, OPT_SUMMARY },
{ "version", no_argument, 0, 'V' }, { "version", no_argument, 0, 'V' },
{ "help", no_argument, 0, 'h' }, { "help", no_argument, 0, 'h' },
{ NULL, 0, 0, 0 } { NULL, 0, 0, 0 }
@ -670,6 +675,9 @@ main(int argc, char *argv[])
else else
errx(EXIT_FAILURE, _("unsupported stream name: '%s'"), optarg); errx(EXIT_FAILURE, _("unsupported stream name: '%s'"), optarg);
break; break;
case OPT_SUMMARY:
summary = 1;
break;
case 'V': case 'V':
print_version(EXIT_SUCCESS); print_version(EXIT_SUCCESS);
case 'h': case 'h':
@ -682,6 +690,9 @@ main(int argc, char *argv[])
argv += optind; argv += optind;
idx = 0; idx = 0;
if (summary)
streams[0] = 'H', streams[1] = '\0';
if (!log_tm && idx < argc) if (!log_tm && idx < argc)
log_tm = argv[idx++]; log_tm = argv[idx++];
if (!log_out && !log_in && !log_io) if (!log_out && !log_in && !log_io)
@ -726,11 +737,13 @@ main(int argc, char *argv[])
if (rc) if (rc)
break; break;
step->delay /= divi; if (!summary) {
if (maxdelayopt && step->delay > maxdelay) step->delay /= divi;
step->delay = maxdelay; if (maxdelayopt && step->delay > maxdelay)
if (step->delay > SCRIPT_MIN_DELAY) step->delay = maxdelay;
delay_for(step->delay); if (step->delay > SCRIPT_MIN_DELAY)
delay_for(step->delay);
}
rc = replay_emit_step_data(&setup, step, STDOUT_FILENO); rc = replay_emit_step_data(&setup, step, STDOUT_FILENO);
} while (rc == 0); } while (rc == 0);