Skip to content

Commit

Permalink
Ensure the right number of tests are performed against the given log.
Browse files Browse the repository at this point in the history
  • Loading branch information
allinurl committed Feb 28, 2018
1 parent 16f8a13 commit 28e0874
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ parse_long_opt (const char *name, const char *oarg)
int tests = strtol (oarg, &sEnd, 10);
if (oarg == sEnd || *sEnd != '\0' || errno == ERANGE)
return;
conf.num_tests = tests;
conf.num_tests = tests >= 0 ? tests : 0;
}

/* process and exit */
Expand Down
9 changes: 8 additions & 1 deletion src/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2560,16 +2560,23 @@ static int
read_line (GLog * glog, char *line, int *test, int *cnt, int dry_run)
{
int ret = 0;
int tests = conf.num_tests;

/* start processing log line */
if ((ret = pre_process_log (glog, line, dry_run)) == 0 && *test)
*test = 0;

/* soft ignores */
if (ret == -1)
return 0;

/* glog->processed can actually be less than conf.num_tests, so we make sure
* (cnt) compares to the right number */
tests = MIN (conf.num_tests, glog->processed);

/* reached num of lines to test and no valid records were found, log
* format is likely not matching */
if (conf.num_tests >= 0 && ++(*cnt) == conf.num_tests && *test) {
if (conf.num_tests && ++(*cnt) == tests && *test) {
uncount_processed (glog);
uncount_invalid (glog);
return 1;
Expand Down
2 changes: 1 addition & 1 deletion src/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@ typedef struct GConf_
int no_parsing_spinner; /* disable parsing spinner */
int no_progress; /* disable progress metrics */
int no_tab_scroll; /* don't scroll dashboard on tab */
int num_tests; /* number of lines to test */
int output_stdout; /* outputting to stdout */
int process_and_exit; /* parse and exit without outputting */
int real_os; /* show real OSs */
int real_time_html; /* enable real-time HTML output */
int skip_term_resolver; /* no terminal resolver */
uint32_t num_tests; /* number of lines to test */
uint64_t log_size; /* log size override */

/* Internal flags */
Expand Down

0 comments on commit 28e0874

Please sign in to comment.