This is an improved version of some of the tidying/refactoring in #1170.
I think it’s enough to deserve a separate PR. Once this is merged, I’ll get back to the actual goal of #1170 (namely, forbidding cloning and randomizing static contexts.)
This PR is a general clean up of the context tests. A notable change is that this avoids a code smell where run_context_tests()
would use the global ctx
variable like a local one (i.e., create a context in it and destroy it afterwards). After this PR, the global ctx
is properly initialized for all the other tests, and they can decide whether they want to use it or not. Same for a global sttc
, which is a memcpy of the static context (we need a writable copy in order to be able to set callbacks).
Note that this touches code which is also affected by #1167 but I refrained from trying to solve this issue. The goal of this PR is simply not to worsen the situation w.r.t. #1167. We should really introduce a macro to solve #1167 but that’s another PR.