[tor-bugs] #16792 [Tor]: Have a way to mark lines as "unreachable by unit tests"

Tor Bug Tracker & Wiki blackhole at torproject.org
Thu Aug 27 21:56:13 UTC 2015


#16792: Have a way to mark lines as "unreachable by unit tests"
-----------------------------+--------------------------------
     Reporter:  nickm        |      Owner:  nickm
         Type:  enhancement  |     Status:  accepted
     Priority:  normal       |  Milestone:  Tor: 0.2.8.x-final
    Component:  Tor          |    Version:
   Resolution:               |   Keywords:  SponsorS, testing
Actual Points:               |  Parent ID:
       Points:               |
-----------------------------+--------------------------------

Comment (by tdruiva):

 Hi,

 We can use the lcov exclusion markers like: LCOV_EXCL_LINE,
 LCOV_EXCL_START, LCOV_EXCL_STOP,
 LCOV_EXCL_BR_LINE, LCOV_EXCL_BR_START and, LCOV_EXCL_BR_STOP.

 The usage will be something like this:
 /* LCOV_EXCL_START */
   if (!options->Tor2webMode) {
     log_err(LD_CONFIG, "This copy of Tor was compiled to run in "
             "'tor2web mode'. It can only be run with the Tor2webMode torrc
 "
             "option enabled.");
     return -1;
   }
 /* LCOV_EXCL_STOP */


 What do you think if we use macros to have this markers only if the
 coverage is enable?

 Something like:
 switch(some_value){
   case 1:
     // something
     break;
   case 0:
     // something else
     break;
   case -1:
     TOR_COV_UNREACHABLE_BEGIN
     //unreachable code
     TOR_COV_UNREACHABLE_ENF
 }

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/16792#comment:3>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list