mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Add the VdbeCoverageNeverTaken() macro, and comments that better describe how
the VDBE branch coverage measurement works. Add some tags to provide 100% VDBE branch coverage. FossilOrigin-Name: c1e94169dd8eb80b4d18c73be9f81585330d11ad
This commit is contained in:
27
src/vdbe.h
27
src/vdbe.h
@@ -241,14 +241,39 @@ void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
|
||||
# define VdbeModuleComment(X)
|
||||
#endif
|
||||
|
||||
/* Set the Opcode.iSrcline field of the previous opcode */
|
||||
/*
|
||||
** The VdbeCoverage macros are used to set a coverage testing point
|
||||
** for VDBE branch instructions. The coverage testing points are line
|
||||
** numbers in the sqlite3.c source file. VDBE branch coverage testing
|
||||
** only works with an amalagmation build. That's ok since a VDBE branch
|
||||
** coverage build designed for testing the test suite only. No application
|
||||
** should ever ship with VDBE branch coverage measuring turned on.
|
||||
**
|
||||
** VdbeCoverage(v) // Mark the previously coded instruction
|
||||
** // as a branch
|
||||
**
|
||||
** VdbeCoverageIf(v, conditional) // Mark previous if conditional true
|
||||
**
|
||||
** VdbeCoverageAlwaysTaken(v) // Previous branch is always taken
|
||||
**
|
||||
** VdbeCoverageNeverTaken(v) // Previous branch is never taken
|
||||
**
|
||||
** Every VDBE branch operation must be tagged with one of the macros above.
|
||||
** If not, then when "make test" is run with -DSQLITE_VDBE_COVERAGE and
|
||||
** -DSQLITE_DEBUG then an ALWAYS() will fail in the vdbeTakeBranch()
|
||||
** routine in vdbe.c, alerting the developer to the missed tag.
|
||||
*/
|
||||
#ifdef SQLITE_VDBE_COVERAGE
|
||||
void sqlite3VdbeSetLineNumber(Vdbe*,int);
|
||||
# define VdbeCoverage(v) sqlite3VdbeSetLineNumber(v,__LINE__)
|
||||
# define VdbeCoverageIf(v,x) if(x)sqlite3VdbeSetLineNumber(v,__LINE__)
|
||||
# define VdbeCoverageAlwaysTaken(v) sqlite3VdbeSetLineNumber(v,2);
|
||||
# define VdbeCoverageNeverTaken(v) sqlite3VdbeSetLineNumber(v,1);
|
||||
#else
|
||||
# define VdbeCoverage(v)
|
||||
# define VdbeCoverageIf(v,x)
|
||||
# define VdbeCoverageAlwaysTaken(v)
|
||||
# define VdbeCoverageNeverTaken(v)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user