Azure / c-testrunnerswitcher

C test runner switcher repo to be broken off from azure-c-shared-utility so it can be reused in several of our IoT repos
8 stars 12 forks source link

TEST_MUTEX_HANDLE / TEST_MUTEX_CREATE / TEST_MUTEX_ACQUIRE / TEST_MUTEX_DESTROY #23

Open anporumb opened 5 years ago

anporumb commented 5 years ago

Since they can only be used in one way and one way only, it points to them as being part of the TEST_SUITE_INITIALIZE / TEST_SUITE_CLEANUP / TEST_FUNCTION_INITIALIZE / TEST_FUNCTION_CLEANUP.

That is the "testrunner"/(?switcher) should ensure that there is just a single test executing at a time. And if the usage based on "let's run all tests in parallel" is (ever) needed, it can be enabled at a later time.

Best Regards, Andrei Porumb

dcristoloveanu commented 5 years ago

ctest is single threaded. So it does by default ensure that only one test runs at a time. The cppunittest runner allows running tests in parallel.

I agree that we should not need to write this mutex code all over our tests, since it can be contained into one place. That place is ctestrunnerswitcher (because ctest would never care about such business).

Ideally we should have 2 sets of macros:

The one for parallel execution would error out when using ctest obviously. That way it would be explicit how the tests are intended to be run.

For now I think we should add to TEST_SUITE_INITIALIZE / TEST_SUITE_CLEANUP / TEST_FUNCTION_INITIALIZE / TEST_FUNCTION_CLEANUP the mutex support for the cppunittest side.

And then we can add TEST_SUITE_INITIALIZE_PARALLEL/ TEST_SUITE_CLEANUP_PARALLEL / TEST_FUNCTION_INITIALIZE_PARALLEL / TEST_FUNCTION_CLEANUP_PARALLEL later as a separate feature.