Skip to content

Commit

Permalink
Update testing.h
Browse files Browse the repository at this point in the history
Add support to include CMocka headers, but not enable memory
checks.
  • Loading branch information
timrulebosch authored Oct 30, 2023
1 parent f2e969c commit 2006a5b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dse/testing.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#ifndef DSE_TESTING_H_
#define DSE_TESTING_H_

#ifdef UNIT_TESTING

#if defined(UNIT_TESTING) || defined(CMOCKA_TESTING)

#include <stdarg.h>
#include <stddef.h>
Expand All @@ -18,6 +18,8 @@
#include <cmocka.h>


#if defined(UNIT_TESTING) // Enables memory checks in CMocka includes.

/* Wrapping strdup() to get memory checking does not work with libyaml (and
* perhaps other libs too). Therefore, rather than wrapping we can use the
* preprocessor to swap strdup with this implementation in DSE code only.
Expand All @@ -32,7 +34,8 @@ static inline char *dse_strdup_swap(const char *s)
}
#define strdup dse_strdup_swap


#endif // UNIT_TESTING

#endif // UNIT_TESTING || CMOCKA_TESTING

#endif // DSE_TESTING_H_

0 comments on commit 2006a5b

Please sign in to comment.