From ddd4f65ddcbe26c442d792d553ff46b93524c8d3 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 10 Aug 2017 23:33:47 -0400 Subject: [PATCH 9/9] Exclude flex-generated code from coverage testing Flex generates a lot of functions that are not actually used. In order to avoid coverage figures being ruined by that, mark up the part of the .l files where the generated code appears by lcov exclusion markers. That way, lcov will typically only reported on coverage for the .l file, which is under our control, but not for the .c file. --- contrib/cube/cubescan.l | 4 ++++ contrib/seg/segscan.l | 4 ++++ src/backend/bootstrap/bootscanner.l | 3 +++ src/backend/parser/scan.l | 5 +++++ src/backend/replication/repl_scanner.l | 3 +++ src/backend/replication/syncrep_scanner.l | 3 +++ src/backend/utils/misc/guc-file.l | 4 +++- src/bin/pgbench/exprscan.l | 4 ++++ src/bin/psql/psqlscanslash.l | 4 ++++ src/fe_utils/psqlscan.l | 4 ++++ src/interfaces/ecpg/preproc/pgc.l | 6 ++++++ src/test/isolation/specscanner.l | 4 ++++ 12 files changed, 47 insertions(+), 1 deletion(-) diff --git a/contrib/cube/cubescan.l b/contrib/cube/cubescan.l index dada917820..bd400e3684 100644 --- a/contrib/cube/cubescan.l +++ b/contrib/cube/cubescan.l @@ -4,6 +4,8 @@ * contrib/cube/cubescan.l */ +/* LCOV_EXCL_START */ + /* No reason to constrain amount of data slurped */ #define YY_READ_BUF_SIZE 16777216 @@ -56,6 +58,8 @@ NaN [nN][aA][nN] %% +/* LCOV_EXCL_STOP */ + /* result is not used, but Bison expects this signature */ void yyerror(NDBOX **result, const char *message) diff --git a/contrib/seg/segscan.l b/contrib/seg/segscan.l index 6db24fdd1f..5f6595e9eb 100644 --- a/contrib/seg/segscan.l +++ b/contrib/seg/segscan.l @@ -3,6 +3,8 @@ * A scanner for EMP-style numeric ranges */ +/* LCOV_EXCL_START */ + /* No reason to constrain amount of data slurped */ #define YY_READ_BUF_SIZE 16777216 @@ -51,6 +53,8 @@ float ({integer}|{real})([eE]{integer})? %% +/* LCOV_EXCL_STOP */ + void yyerror(SEG *result, const char *message) { diff --git a/src/backend/bootstrap/bootscanner.l b/src/backend/bootstrap/bootscanner.l index 6467882fa3..4fd23f932c 100644 --- a/src/backend/bootstrap/bootscanner.l +++ b/src/backend/bootstrap/bootscanner.l @@ -38,6 +38,7 @@ /* Not needed now that this file is compiled as part of bootparse. */ /* #include "bootparse.h" */ +/* LCOV_EXCL_START */ /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */ #undef fprintf @@ -134,6 +135,8 @@ insert { return(INSERT_TUPLE); } %% +/* LCOV_EXCL_STOP */ + void yyerror(const char *message) { diff --git a/src/backend/parser/scan.l b/src/backend/parser/scan.l index 634bfa512f..6af2199cdc 100644 --- a/src/backend/parser/scan.l +++ b/src/backend/parser/scan.l @@ -41,6 +41,9 @@ } %{ + +/* LCOV_EXCL_START */ + /* Avoid exit() on fatal scanner errors (a bit ugly -- see yy_fatal_error) */ #undef fprintf #define fprintf(file, fmt, msg) fprintf_to_ereport(fmt, msg) @@ -1011,6 +1014,8 @@ other . %% +/* LCOV_EXCL_STOP */ + /* * Arrange access to yyextra for subroutines of the main yylex() function. * We expect each subroutine to have a yyscanner parameter. Rather than diff --git a/src/backend/replication/repl_scanner.l b/src/backend/replication/repl_scanner.l index 52ae7b343f..9c2f5fdd65 100644 --- a/src/backend/replication/repl_scanner.l +++ b/src/backend/replication/repl_scanner.l @@ -38,6 +38,8 @@ static char *litbufdup(void); static void addlit(char *ytext, int yleng); static void addlitchar(unsigned char ychar); +/* LCOV_EXCL_START */ + %} %option 8bit @@ -185,6 +187,7 @@ USE_SNAPSHOT { return K_USE_SNAPSHOT; } } %% +/* LCOV_EXCL_STOP */ static void startlit(void) diff --git a/src/backend/replication/syncrep_scanner.l b/src/backend/replication/syncrep_scanner.l index d1d1b26a48..1fbc936aa6 100644 --- a/src/backend/replication/syncrep_scanner.l +++ b/src/backend/replication/syncrep_scanner.l @@ -32,6 +32,8 @@ static YY_BUFFER_STATE scanbufhandle; static StringInfoData xdbuf; +/* LCOV_EXCL_START */ + %} %option 8bit @@ -112,6 +114,7 @@ xdinside [^"]+ . { return JUNK; } %% +/* LCOV_EXCL_STOP */ /* Needs to be here for access to yytext */ void diff --git a/src/backend/utils/misc/guc-file.l b/src/backend/utils/misc/guc-file.l index f01b814c6e..3de8e791f2 100644 --- a/src/backend/utils/misc/guc-file.l +++ b/src/backend/utils/misc/guc-file.l @@ -57,6 +57,8 @@ static void record_config_file_error(const char *errmsg, static int GUC_flex_fatal(const char *msg); static char *GUC_scanstr(const char *s); +/* LCOV_EXCL_START */ + %} %option 8bit @@ -107,7 +109,7 @@ STRING \'([^'\\\n]|\\.|\'\')*\' %% - +/* LCOV_EXCL_STOP */ /* * Exported function to read and process the configuration file. The diff --git a/src/bin/pgbench/exprscan.l b/src/bin/pgbench/exprscan.l index dc1367bbdb..15cedd3c9d 100644 --- a/src/bin/pgbench/exprscan.l +++ b/src/bin/pgbench/exprscan.l @@ -43,6 +43,8 @@ static bool last_was_newline = false; extern int expr_yyget_column(yyscan_t yyscanner); extern void expr_yyset_column(int column_no, yyscan_t yyscanner); +/* LCOV_EXCL_START */ + %} /* Except for the prefix, these options should match psqlscan.l */ @@ -190,6 +192,8 @@ continuation \\{newline} %% +/* LCOV_EXCL_STOP */ + void expr_yyerror_more(yyscan_t yyscanner, const char *message, const char *more) { diff --git a/src/bin/psql/psqlscanslash.l b/src/bin/psql/psqlscanslash.l index db7a1b9eea..080dc37a2f 100644 --- a/src/bin/psql/psqlscanslash.l +++ b/src/bin/psql/psqlscanslash.l @@ -67,6 +67,8 @@ static void evaluate_backtick(PsqlScanState state); extern int slash_yyget_column(yyscan_t yyscanner); extern void slash_yyset_column(int column_no, yyscan_t yyscanner); +/* LCOV_EXCL_START */ + %} /* Except for the prefix, these options should match psqlscan.l */ @@ -450,6 +452,8 @@ other . %% +/* LCOV_EXCL_STOP */ + /* * Scan the command name of a psql backslash command. This should be called * after psql_scan() returns PSCAN_BACKSLASH. It is assumed that the input diff --git a/src/fe_utils/psqlscan.l b/src/fe_utils/psqlscan.l index 27689d72da..205756a2fe 100644 --- a/src/fe_utils/psqlscan.l +++ b/src/fe_utils/psqlscan.l @@ -71,6 +71,8 @@ typedef int YYSTYPE; extern int psql_yyget_column(yyscan_t yyscanner); extern void psql_yyset_column(int column_no, yyscan_t yyscanner); +/* LCOV_EXCL_START */ + %} %option reentrant @@ -884,6 +886,8 @@ other . %% +/* LCOV_EXCL_STOP */ + /* * Create a lexer working state struct. * diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l index 7b2bfdccc9..8602748faa 100644 --- a/src/interfaces/ecpg/preproc/pgc.l +++ b/src/interfaces/ecpg/preproc/pgc.l @@ -79,6 +79,8 @@ static struct _if_value short else_branch; } stacked_if_value[MAX_NESTED_IF]; +/* LCOV_EXCL_START */ + %} %option 8bit @@ -1249,7 +1251,11 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+ } } {other}|\n { mmfatal(PARSE_ERROR, "internal error: unreachable state; please report this to "); } + %% + +/* LCOV_EXCL_STOP */ + void lex_init(void) { diff --git a/src/test/isolation/specscanner.l b/src/test/isolation/specscanner.l index aed9269c63..7c571bc101 100644 --- a/src/test/isolation/specscanner.l +++ b/src/test/isolation/specscanner.l @@ -17,6 +17,8 @@ static int litbufpos = 0; static void addlitchar(char c); +/* LCOV_EXCL_START */ + %} %option 8bit @@ -93,6 +95,8 @@ teardown { return(TEARDOWN); } } %% +/* LCOV_EXCL_STOP */ + static void addlitchar(char c) { -- 2.14.0