[tor-bugs] #30968 [Core Tor/Tor]: Refactor unit test asserts so they log context

Tor Bug Tracker & Wiki blackhole at torproject.org
Tue Jun 25 01:57:55 UTC 2019


#30968: Refactor unit test asserts so they log context
-------------------------+-------------------------------------------------
     Reporter:  teor     |      Owner:  (none)
         Type:           |     Status:  new
  enhancement            |
     Priority:  Medium   |  Milestone:  Tor: unspecified
    Component:  Core     |    Version:
  Tor/Tor                |   Keywords:  refactor, technical-debt, ipv6,
     Severity:  Normal   |  tor-dns
Actual Points:           |  Parent ID:
       Points:  2        |   Reviewer:
      Sponsor:           |
-------------------------+-------------------------------------------------
 In #30721, I created some complex macros to preserve line numbers when the
 unit tests fail.

 We could refactor these macros into functions, if the tiny test assertions
 supported context.

 catalyst suggests allowing file and line numbers (and functions?):
 > I think I see that the problem is buried in the `TT_DECLARE()` macro in
 `tinytest_macros.h`. I think it's possible to work around it, but it might
 be nontrivial. (Rough sketch: redefine `TT_DECLARE()` in helper functions
 to read file and line info from function parameters, and make file and
 line numbers explicit parameters to helper functions.)

 I suggest allowing a format string, which could also print the data that
 we're testing. (For the tor_addr_port_lookup() tests, the best context is
 the address string.)

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


More information about the tor-bugs mailing list