Opened 16 months ago

Last modified 14 months ago

#30968 new enhancement

Refactor unit test asserts so they log context

Reported by: teor Owned by:
Priority: Medium Milestone: Tor: unspecified
Component: Core Tor/Tor Version:
Severity: Normal Keywords: refactor, technical-debt, ipv6, tor-dns, sponsor-31-maybe
Cc: gaba, catalyst 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.)

Child Tickets

Change History (3)

comment:1 Changed 16 months ago by teor

Keywords: sponsor-31-maybe added

gaba, I don't know if we want to do this refactor as part of sponsor 31.

comment:2 Changed 16 months ago by catalyst

Cc: catalyst added

comment:3 Changed 14 months ago by catalyst

#31354 is a persistent compiler warning due to the large function sizes produced by expansion of those macros.

Note: See TracTickets for help on using tickets.