#if defined(WPA_TRACE_BFD) && defined(CONFIG_TESTING_OPTIONS)
-#define TEST_FAIL() testing_test_fail(false)
-int testing_test_fail(bool is_alloc);
+#define TEST_FAIL() testing_test_fail(NULL, false)
+#define TEST_FAIL_TAG(tag) testing_test_fail(tag, false)
+int testing_test_fail(const char *tag, bool is_alloc);
int testing_set_fail_pattern(bool is_alloc, char *patterns);
int testing_get_fail_pattern(bool is_alloc, char *buf, size_t buflen);
#else
#define TEST_FAIL() 0
+#define TEST_FAIL_TAG(tag) 0
static inline int testing_set_fail_pattern(bool is_alloc, char *patterns)
{
return -1;
char pattern[256];
} wpa_trace_test_fail[5][2];
-int testing_test_fail(bool is_alloc)
+int testing_test_fail(const char *tag, bool is_alloc)
{
const char *ignore_list[] = {
- __func__, "os_malloc", "os_zalloc", "os_calloc", "os_realloc",
+ "os_malloc", "os_zalloc", "os_calloc", "os_realloc",
"os_realloc_array", "os_strdup", "os_memdup"
};
const char *func[WPA_TRACE_LEN];
res = wpa_trace_calling_func(func, WPA_TRACE_LEN);
i = 0;
- /* Skip this function as well as allocation helpers */
- for (j = 0; j < ARRAY_SIZE(ignore_list) && i < res; j++) {
- if (os_strcmp(func[i], ignore_list[j]) == 0)
+ if (is_alloc) {
+ /* Skip our own stack frame */
+ i++;
+
+ /* Skip allocation helpers */
+ for (j = 0; j < ARRAY_SIZE(ignore_list) && i < res; j++) {
+ if (os_strcmp(func[i], ignore_list[j]) == 0)
+ i++;
+ }
+ } else {
+ /* Not allocation, we might have a tag, if so, replace our
+ * own stack frame with the tag, otherwise skip it.
+ */
+ if (tag)
+ func[0] = tag;
+ else
i++;
}
{
struct os_alloc_trace *a;
- if (testing_test_fail(true))
+ if (testing_test_fail(NULL, true))
return NULL;
a = malloc(sizeof(*a) + size);