immunant / IA2-Phase2

5 stars 0 forks source link

Replace use of prebuilt criterion with our test runner #439

Closed ayrtonm closed 1 month ago

ayrtonm commented 1 month ago

When using either criterion or our fake criterion lib we turn each Test macro into a function that has its address taken so the test runner can call it. When we rewrite the test sources each Test function has a wrapper generated (with real criterion it seems like it's a static fn so the wrapper is defined at the bottom of the test .c). Since the callsite for the function pointers is in libcriterion.so there's no corresponding IA2_CALL so we should make sure that the pointer points to the original function, not the wrapper. I think it should be the case since the function pointer is assigned inside of the Test macro but we should double check.

This potential bug also applies to our fake criterion but in that case the test functions are not static so the wrappers aren't defined in the rewritten test sources. Also fake criterion is just a static lib that the tests link against so I don't think it gets rewritten (and we should probably keep it that way). @fw-immunant have you thought about these issues?

ayrtonm commented 1 month ago

I don't expect to make big changes to the test runner, just make sure it gets used on x86 (which may require removing "criterion" from its headers to make sure the system header doesn't get picked up). It may also make sense to move test_fault_handler.h to the misc directory and remove the DEFINE_TEST_HANDLER macro (which should also simplify the process for writing a new test).