[CDRIVER-2767] Check type of passed skip functions Created: 25/Jul/18  Updated: 31/Mar/22

Status: Backlog
Project: C Driver
Component/s: tests
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Kevin Albertson Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: CDRIVER-2733

 Description   

The culprit of CDRIVER-2759 was passing a function with the wrong type to a variadic list. Reading variadic arguments in C is not type safe, so there was no compiler warning/error.

We could do type checking when TestSuite_AddFull is called by wrapping the variadic arguments with no-op function calls using preprocessor defines. E.g. something along the lines of this:

 

#define TestSuite_AddFull(_suite, _name, _func, _dtor, _ctx, ...) \
 _TestSuite_AddFull (_suite, _name, _func, _dtor, _ctx, FOREACH(TypeCheck, __VA_ARGS__) NULL)
 

Where this would expand to:

_TestSuite_AddFull (_suite, _name, _func, _dtor, _ctx, TypeCheck(chk1), TypeCheck(chk2), TypeCheck(chk3), null)

Therefore, the caller does the type check. We don't have any mechanism for doing a foreach with the preprocessor. See this example and P99_FOR.


Generated at Wed Feb 07 21:16:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.