@@ -231,8 +231,6 @@ static inline void acl_list_remove (ACL_ListNode* item)
231231#pragma GCC diagnostic push
232232#pragma GCC diagnostic ignored "-Wunused-function"
233233
234- #ifndef YUKTI_TEST_NO_MUST_CALL
235-
236234void YT__add_callrecord (ACL_ListNode * head , int sourceLineNumber , const char * const sourceFileName ,
237235 int n , const char * const fn , ...);
238236
@@ -243,26 +241,23 @@ typedef struct YT__Arg {
243241 uintptr_t val ; // A type large enough to hold both integers & addresses
244242} YT__Arg ;
245243
246- #define YT__ARG_FIELDS_COUNT 2
244+ #define YT__ARG_FIELDS_COUNT 2
247245
248- #define YT__RECORD_CALL_X (...) YT__FCALL_WRAP_ARGS_X (YT_V, ##__VA_ARGS__)
246+ #define YT__RECORD_CALL_X (...) YT__FCALL_WRAP_ARGS_X (YT_V, ##__VA_ARGS__)
249247
250- #define YT_V (v ) \
251- (YT__Arg) \
252- { \
253- .isOpt = false, .val = (uintptr_t)(v) \
254- }
255- #define _ (YT__Arg){ .isOpt = true, .val = 0 }
248+ #define YT_V (v ) \
249+ (YT__Arg) \
250+ { \
251+ .isOpt = false, .val = (uintptr_t)(v) \
252+ }
253+ #define _ (YT__Arg){ .isOpt = true, .val = 0 }
256254
257- #define YT__RECORD_CALL (n , f , ...) \
258- do { \
259- YT__add_callrecord (&YT__actualCallListHead, __LINE__, __FILE__, \
260- YT__COUNT_ARGS (__VA_ARGS__), \
261- #f __VA_OPT__ (, YT__RECORD_CALL_X (__VA_ARGS__))); \
262- } while (0)
263- #else
264- #define YT__RECORD_CALL (...) (void)0
265- #endif /* YUKTI_TEST_NO_MUST_CALL */
255+ #define YT__RECORD_CALL (n , f , ...) \
256+ do { \
257+ YT__add_callrecord (&YT__actualCallListHead, __LINE__, __FILE__, \
258+ YT__COUNT_ARGS (__VA_ARGS__), \
259+ #f __VA_OPT__ (, YT__RECORD_CALL_X (__VA_ARGS__))); \
260+ } while (0)
266261
267262/*
268263 * ========================================================================================
@@ -477,60 +472,46 @@ static void YT__free_testRecord (YT__TestRecord* trecord)
477472 * 2.2: FUNCTION & MACROS TO TEST EXPECTATIONS ON FUNCTION CALLS
478473 * ========================================================================================
479474 * */
480- #ifdef YUKTI_TEST_NO_MUST_CALL
481- // Compilation will fail since the these macros will expand to invalid C code.
482- #define YT__ERROR_MESSAGE Invalid when YUKTI_TEST_NO_MUST_CALL is defined
483-
484- #define YT_IN_SEQUENCE (n ) YT__ERROR_MESSAGE
485- #define YT_MUST_CALL_IN_ORDER (...) YT__ERROR_MESSAGE
486- #define YT_MUST_CALL_IN_ORDER_ATLEAST_TIMES (...) YT__ERROR_MESSAGE
487- #define YT_MUST_CALL_ANY_ORDER (...) YT__ERROR_MESSAGE
488- #define YT_MUST_CALL_ANY_ORDER_ATLEAST_TIMES (...) YT__ERROR_MESSAGE
489-
490- #define YT__validate_expectations () (void)0
491- #define YT__teardown () (void)0
492- #define YT__ec_init () (void)0
493- #else
494- #define YT_IN_SEQUENCE (n ) for (int i = 0; i < (n); i++)
495-
496- #define YT_MUST_NEVER_CALL (f , ...) \
497- do { \
498- YT__current_testrecord->total_exp_count++; \
499- YT__add_callrecord (&YT__neverCallExceptationsListHead, __LINE__, __FILE__, \
500- YT__COUNT_ARGS (__VA_ARGS__) / YT__ARG_FIELDS_COUNT, #f, \
501- ##__VA_ARGS__); \
502- } while (0)
475+ #define YT_IN_SEQUENCE (n ) for (int i = 0; i < (n); i++)
476+
477+ #define YT_MUST_NEVER_CALL (f , ...) \
478+ do { \
479+ YT__current_testrecord->total_exp_count++; \
480+ YT__add_callrecord (&YT__neverCallExceptationsListHead, __LINE__, __FILE__, \
481+ YT__COUNT_ARGS (__VA_ARGS__) / YT__ARG_FIELDS_COUNT, #f, \
482+ ##__VA_ARGS__); \
483+ } while (0)
503484
504- #define YT_MUST_CALL_IN_ORDER (f , ...) \
505- do { \
506- YT__current_testrecord->total_exp_count++; \
507- YT__add_callrecord (&YT__orderedExceptationListHead, __LINE__, __FILE__, \
508- YT__COUNT_ARGS (__VA_ARGS__) / YT__ARG_FIELDS_COUNT, #f, \
509- ##__VA_ARGS__); \
510- } while (0)
485+ #define YT_MUST_CALL_IN_ORDER (f , ...) \
486+ do { \
487+ YT__current_testrecord->total_exp_count++; \
488+ YT__add_callrecord (&YT__orderedExceptationListHead, __LINE__, __FILE__, \
489+ YT__COUNT_ARGS (__VA_ARGS__) / YT__ARG_FIELDS_COUNT, #f, \
490+ ##__VA_ARGS__); \
491+ } while (0)
511492
512- #define YT_MUST_CALL_IN_ORDER_ATLEAST_TIMES (n , f , ...) \
513- for (int i = n; i; i--) { \
514- YT_MUST_CALL_IN_ORDER (f, ##__VA_ARGS__); \
515- }
493+ #define YT_MUST_CALL_IN_ORDER_ATLEAST_TIMES (n , f , ...) \
494+ for (int i = n; i; i--) { \
495+ YT_MUST_CALL_IN_ORDER (f, ##__VA_ARGS__); \
496+ }
516497
517- #define YT_MUST_CALL_ANY_ORDER (f , ...) \
518- do { \
519- YT__current_testrecord->total_exp_count++; \
520- YT__add_callrecord (&YT__globalExceptationListHead, __LINE__, __FILE__, \
521- YT__COUNT_ARGS (__VA_ARGS__) / YT__ARG_FIELDS_COUNT, #f, \
522- ##__VA_ARGS__); \
523- } while (0)
498+ #define YT_MUST_CALL_ANY_ORDER (f , ...) \
499+ do { \
500+ YT__current_testrecord->total_exp_count++; \
501+ YT__add_callrecord (&YT__globalExceptationListHead, __LINE__, __FILE__, \
502+ YT__COUNT_ARGS (__VA_ARGS__) / YT__ARG_FIELDS_COUNT, #f, \
503+ ##__VA_ARGS__); \
504+ } while (0)
524505
525- #define YT_MUST_CALL_ANY_ORDER_ATLEAST_TIMES (n , f , ...) \
526- for (int i = n; i; i--) { \
527- YT_MUST_CALL_ANY_ORDER (f, ##__VA_ARGS__); \
528- }
506+ #define YT_MUST_CALL_ANY_ORDER_ATLEAST_TIMES (n , f , ...) \
507+ for (int i = n; i; i--) { \
508+ YT_MUST_CALL_ANY_ORDER (f, ##__VA_ARGS__); \
509+ }
529510
530- #define YT__MAX_CALLSTRING_SIZE 250
531- #define YT__MAX_SOURCE_FILE_NAME_LEN 250
532- #define YT__ARG_OPTIONAL_CHAR '!'
533- #define YT__ARG_SEPARATOR_CHAR ','
511+ #define YT__MAX_CALLSTRING_SIZE 250
512+ #define YT__MAX_SOURCE_FILE_NAME_LEN 250
513+ #define YT__ARG_OPTIONAL_CHAR '!'
514+ #define YT__ARG_SEPARATOR_CHAR ','
534515
535516typedef enum YT__CallRecordTypes {
536517 YT__CALLRECORD_TYPE_ORDERED_EXPECTATION ,
@@ -551,13 +532,13 @@ static bool YT__match_call_strings (const char* exp, const char* actual);
551532static void YT__string_append (char * str , size_t size , const char * const fmt , ...);
552533static void YT__call_record_free (YT__CallRecord * node );
553534static void YT__free_call_list (ACL_ListNode * head );
554- #ifdef YUKTI_TEST_DEBUG
535+ #ifdef YUKTI_TEST_DEBUG
555536static void YT__create_call_string (ACL_ListNode * head , char * buffer , size_t buffer_size , int n ,
556537 const char * const fn , va_list l );
557- #else
538+ #else
558539static void YT__create_call_string (char * buffer , size_t buffer_size , int n , const char * const fn ,
559540 va_list l );
560- #endif /* YUKTI_TEST_DEBUG */
541+ #endif /* YUKTI_TEST_DEBUG */
561542
562543static void YT__print_unmet_expectations ();
563544static void YT__validate_expectations ();
@@ -641,13 +622,13 @@ static void YT__call_record_free (YT__CallRecord* node)
641622 free (node );
642623}
643624
644- #ifdef YUKTI_TEST_DEBUG
625+ #ifdef YUKTI_TEST_DEBUG
645626void YT__create_call_string (ACL_ListNode * head , char * buffer , size_t buffer_size , int n ,
646627 const char * const fn , va_list l )
647- #else
628+ #else
648629void YT__create_call_string (char * buffer , size_t buffer_size , int n , const char * const fn ,
649630 va_list l )
650- #endif /* YUKTI_TEST_DEBUG */
631+ #endif /* YUKTI_TEST_DEBUG */
651632{
652633 // Expectation: Input pointers are not NULL and Buffer size > 0. They are not user facing!
653634 assert (buffer != NULL && fn != NULL && buffer_size > 0 );
@@ -659,10 +640,10 @@ void YT__create_call_string (char* buffer, size_t buffer_size, int n, const char
659640 char separator = (i == 0 ) ? ' ' : YT__ARG_SEPARATOR_CHAR ;
660641
661642 if (item .isOpt ) {
662- #ifdef YUKTI_TEST_DEBUG
643+ #ifdef YUKTI_TEST_DEBUG
663644 // Expectation: Actual call list must not have optional arguments
664645 assert (head != & YT__actualCallListHead );
665- #endif /* YUKTI_TEST_DEBUG */
646+ #endif /* YUKTI_TEST_DEBUG */
666647 YT__string_append (buffer , buffer_size , "%c%c" , separator , YT__ARG_OPTIONAL_CHAR );
667648 } else {
668649 YT__string_append (buffer , buffer_size , "%c%d" , separator , item .val );
@@ -705,11 +686,11 @@ void YT__add_callrecord (ACL_ListNode* head, int sourceLineNumber, const char* c
705686
706687 va_list l ;
707688 va_start (l , fn );
708- #ifdef YUKTI_TEST_DEBUG
689+ #ifdef YUKTI_TEST_DEBUG
709690 YT__create_call_string (head , newrec -> callString , sizeof (newrec -> callString ), n , fn , l );
710- #else
691+ #else
711692 YT__create_call_string (newrec -> callString , sizeof (newrec -> callString ), n , fn , l );
712- #endif /* YUKTI_TEST_DEBUG */
693+ #endif /* YUKTI_TEST_DEBUG */
713694 va_end (l );
714695}
715696
@@ -754,7 +735,7 @@ void YT__print_unmet_expectations (ACL_ListNode* neverCallExpectationFailedListH
754735 }
755736 }
756737
757- #ifdef YUKTI_TEST_DEBUG
738+ #ifdef YUKTI_TEST_DEBUG
758739 printf ("\n Actual order of functions calls was the following:\n" );
759740 acl_list_for_each (& YT__actualCallListHead , node )
760741 {
@@ -765,7 +746,7 @@ void YT__print_unmet_expectations (ACL_ListNode* neverCallExpectationFailedListH
765746
766747 printf (" * %s\n" , item -> callString );
767748 }
768- #endif /* YUKTI_TEST_DEBUG */
749+ #endif /* YUKTI_TEST_DEBUG */
769750}
770751
771752void YT__validate_expectations ()
@@ -851,8 +832,7 @@ static void YT__ec_init()
851832 acl_list_init (& YT__orderedExceptationListHead );
852833 acl_list_init (& YT__actualCallListHead );
853834}
854- #endif /* YUKTI_TEST_NO_MUST_CALL */
855- #endif /* YUKTI_TEST_IMPLEMENTATION */
835+ #endif /* YUKTI_TEST_IMPLEMENTATION */
856836
857837/*
858838 * ========================================================================================
0 commit comments