forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmacros.c
More file actions
73 lines (64 loc) · 1.56 KB
/
macros.c
File metadata and controls
73 lines (64 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2018 Intel Corporation. All rights reserved.
//
// Author: Michal Jerzy Wierzbicki <michalx.wierzbicki@linux.intel.com>
#include <rtos/alloc.h>
#include <stdio.h>
#include <stdarg.h>
#include <setjmp.h>
#include <stdint.h>
#include <cmocka.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#else
#include <stdlib.h>
#endif
#include <sof/trace/preproc.h>
#include <rtos/sof.h>
#include <sof/trace/trace.h>
#include <user/trace.h>
#define CAPTURE(aggr, ...)\
META_RECURSE(META_MAP(1, META_QUOTE, aggr, __VA_ARGS__))
static void test_debugability_macros_declare_log_entry(void **state)
{
const char *macro_result = CAPTURE(_DECLARE_LOG_ENTRY(
LOG_LEVEL_CRITICAL,
"Message",
0,
1
));
const char *should_be_eq =
"__attribute__((section(\".static_log.\""
" \"LOG_LEVEL_CRITICAL\"))) "
"static const struct "
"{ "
"uint32_t level; "
"uint32_t component_class; "
"uint32_t params_num; "
"uint32_t line_idx; "
"uint32_t file_name_len; "
"uint32_t text_len; "
"const char file_name[sizeof(\"" RELATIVE_FILE "\")]; "
"const char text[sizeof(\"Message\")]; "
"} log_entry = { "
"1"
"0"
"1"
"36"
"sizeof(\"" RELATIVE_FILE "\")"
"sizeof(\"Message\")"
"\"" RELATIVE_FILE "\""
"\"Message\" "
"}";
(void)state;
assert_string_equal(macro_result, should_be_eq);
}
int main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test(test_debugability_macros_declare_log_entry),
};
cmocka_set_message_output(CM_OUTPUT_TAP);
return cmocka_run_group_tests(tests, NULL, NULL);
}