summaryrefslogtreecommitdiffstats
path: root/fluent-bit/tests/internal/CMakeLists.txt
blob: 5288004dbabc9d47988aa9905adfb8dc81d5a147 (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
find_package(Threads REQUIRED)

include_directories(cutest/)

set(UNIT_TESTS_FILES
  pack.c
  pipe.c
  sds.c
  sds_list.c
  hmac.c
  crypto.c
  hash.c
  slist.c
  router.c
  network.c
  unit_sizes.c
  hashtable.c
  http_client.c
  utils.c
  gzip.c
  random.c
  config_map.c
  mp.c
  input_chunk.c
  flb_time.c
  file.c
  csv.c
  multiline.c
  typecast.c
  base64.c
  bucket_queue.c
  flb_event_loop.c
  ring_buffer.c
  regex.c
  parser_json.c
  parser_ltsv.c
  parser_regex.c
  parser_logfmt.c
  env.c
  log.c
  log_event_decoder.c
  processor.c
  uri.c
  )

# Config format
set(UNIT_TESTS_FILES
    ${UNIT_TESTS_FILES}
    config_format.c
    config_format_fluentbit.c
)

if(FLB_HAVE_LIBYAML)
  set(UNIT_TESTS_FILES
      ${UNIT_TESTS_FILES}
      config_format_yaml.c
      )
endif()

if (NOT WIN32)
  set(UNIT_TESTS_FILES
    ${UNIT_TESTS_FILES}
    gelf.c
    fstore.c
    reload.c
    )
endif()

if(FLB_PARSER)
  set(UNIT_TESTS_FILES
    ${UNIT_TESTS_FILES}
    parser.c
    )
endif()

if(FLB_STREAM_PROCESSOR)
  set(UNIT_TESTS_FILES
    ${UNIT_TESTS_FILES}
    stream_processor.c
    )
endif()

if(FLB_RECORD_ACCESSOR)
  set(UNIT_TESTS_FILES
    ${UNIT_TESTS_FILES}
    record_accessor.c
    )
endif()

if(FLB_METRICS)
  set(UNIT_TESTS_FILES
    ${UNIT_TESTS_FILES}
    metrics.c
    )
endif()

if(FLB_SIGNV4)
  set(UNIT_TESTS_FILES
    ${UNIT_TESTS_FILES}
    signv4.c
    )
endif()

if(FLB_AVRO_ENCODER)
  set(UNIT_TESTS_FILES
    ${UNIT_TESTS_FILES}
    avro.c
    )
endif()

if(FLB_AWS)
  set(UNIT_TESTS_FILES
    ${UNIT_TESTS_FILES}
    aws_util.c
    aws_compress.c
    aws_credentials.c
    aws_credentials_ec2.c
    aws_credentials_sts.c
    aws_credentials_http.c
    aws_credentials_profile.c
    )
  if(FLB_HAVE_AWS_CREDENTIAL_PROCESS)
    set(UNIT_TESTS_FILES
      ${UNIT_TESTS_FILES}
      aws_credentials_process.c
      )
  endif()
endif()

if(FLB_AWS_ERROR_REPORTER)
  set(UNIT_TESTS_FILES
    ${UNIT_TESTS_FILES}
    error_reporter.c
    )
endif()

if(FLB_LUAJIT)
  set(UNIT_TESTS_FILES
    ${UNIT_TESTS_FILES}
    lua.c
    )
endif()

set(UNIT_TESTS_DATA
  data/tls/certificate.pem
  data/tls/private_key.pem
  data/pack/json_single_map_001.json
  data/pack/json_single_map_002.json
  data/parser/json.conf
  data/parser/regex.conf
  data/input_chunk/log/a_thousand_plus_one_bytes.log
  data/input_chunk/log/test_buffer_valid.log
  )

set(FLB_TESTS_DATA_PATH ${CMAKE_CURRENT_SOURCE_DIR}/)
configure_file(
  "${CMAKE_CURRENT_SOURCE_DIR}/flb_tests_internal.h.in"
  "${CMAKE_CURRENT_SOURCE_DIR}/flb_tests_internal.h"
  )

# Move data files to the path the test binaries can find them
macro(FLB_TEST_COPY_DATA path)
  configure_file(${path} ${CMAKE_CURRENT_BINARY_DIR}/${path} COPYONLY)
endmacro()

foreach(test_data ${UNIT_TESTS_DATA})
  FLB_TEST_COPY_DATA(${test_data})
endforeach()

# Prepare list of unit tests function
function(prepare_unit_tests TEST_PREFIX SOURCEFILES)
  foreach(source_file ${SOURCEFILES})
    get_filename_component(source_file_we ${source_file} NAME_WE)
    set(source_file_we ${TEST_PREFIX}${source_file_we})
    if(FLB_WITHOUT_${source_file_we})
      message("Skipping test ${source_file_we}")
    else()
      add_executable(
        ${source_file_we}
        ${source_file}
        )
      add_sanitizers(${source_file_we})

      if(FLB_JEMALLOC)
        target_link_libraries(${source_file_we} libjemalloc ${CMAKE_THREAD_LIBS_INIT})
      else()
        target_link_libraries(${source_file_we} ${CMAKE_THREAD_LIBS_INIT})
      endif()

      if(FLB_AWS)
        target_link_libraries(${source_file_we} flb-aws)
      endif()

      if(FLB_STREAM_PROCESSOR)
        target_link_libraries(${source_file_we} flb-sp)
      endif()

      target_link_libraries(${source_file_we} fluent-bit-static cfl-static)

      if(FLB_AVRO_ENCODER)
        target_link_libraries(${source_file_we} avro-static jansson)
      endif()

      add_test(NAME ${source_file_we}
              COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${source_file_we}
              WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY}/build)
      set_tests_properties(${source_file_we} PROPERTIES LABELS "internal")
    endif()
  endforeach()
endfunction(prepare_unit_tests)

prepare_unit_tests(flb-it- "${UNIT_TESTS_FILES}")

if(FLB_TESTS_INTERNAL_FUZZ)
  add_subdirectory(fuzzers)
endif()