Opened 6 years ago

Closed 6 years ago

#9363 closed defect (implemented)

test_pt_configure_proxy() tests should be improved.

Reported by: nickm Owned by: asn
Priority: Medium Milestone: Tor: 0.2.5.x-final
Component: Core Tor/Tor Version:
Severity: Keywords: tor-pt
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

From #9288:

Could we expand the unit tests so that they actually *check* the expected outputs? That is, I expect that configuring a proxy is supposed to result in some changes to the proxy, to the or_state_t object, calls to other function, and changes or calls to other stuff. There are lots of bugs that could lurk here that wouldn't get tested if all we check for is "return 0 five times, then return 1."

Child Tickets

Change History (6)

comment:1 Changed 6 years ago by nickm

Owner: set to asn
Status: newassigned

comment:2 in reply to:  1 Changed 6 years ago by asn

Status: assignedneeds_review

See my branch bug9363 for a bit more robust unit test.

Unfortunately, I couldn't test the or_state_t transport registration since it depends on statefile.c:global_state which is a global variable and hence not easily testable.

Also, I'm getting a compile error when I try to build with coverage:

/usr/bin/ld: tor_main.o: relocation R_X86_64_32 against '.data' can not be used when making a shared object; recompile with -fPIC

Any idea what's up with this?

comment:3 Changed 6 years ago by asn

Do you feel that this branch is sufficient for this ticket?

Maybe we should open another ticket for improving test coverage in src/or/transports.c. Now that the mocking framework is in, we might be able to improve its coverage a lot.

comment:4 Changed 6 years ago by nickm

You CAN test stuff that messes with globals. I'm not sure why you think you can't. If you want the changes to that variable to be isolated to a single unit test, use the TT_FORK flag to run that unit test in its own process. You can access that variable by using get_or_state().

Also, I'm getting a compile error when I try to build with coverage:

First try 'make clean'. If that doesn't work, do a search for "relocation R_X86_64_32 against '.data' can not be used when making a shared object; recompile with -fPIC" . Maybe there's an additional option we need for your host? (What kind of system, building how?)

comment:5 Changed 6 years ago by asn

Please see branch bug9363_take2 in https://git.torproject.org/user/asn/tor.git.

It also tests the registration of server-side transports to Tor's state.

comment:6 Changed 6 years ago by nickm

Resolution: implemented
Status: needs_reviewclosed

Added; thanks!

Note: See TracTickets for help on using tickets.