diff options
Diffstat (limited to 'src/fluent-bit/tests/include')
-rw-r--r-- | src/fluent-bit/tests/include/aws_client_mock.c | 256 | ||||
-rw-r--r-- | src/fluent-bit/tests/include/aws_client_mock.h | 223 | ||||
-rw-r--r-- | src/fluent-bit/tests/include/aws_client_mock_client_resp.def | 34 | ||||
-rw-r--r-- | src/fluent-bit/tests/include/flb_tests_initialize_tls.h | 44 |
4 files changed, 557 insertions, 0 deletions
diff --git a/src/fluent-bit/tests/include/aws_client_mock.c b/src/fluent-bit/tests/include/aws_client_mock.c new file mode 100644 index 000000000..84ee6a1eb --- /dev/null +++ b/src/fluent-bit/tests/include/aws_client_mock.c @@ -0,0 +1,256 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +#include "aws_client_mock.h" + +#include <fluent-bit/flb_aws_util.h> +#include <fluent-bit/flb_http_client.h> + +/* Vtable mocked methods */ +static struct flb_http_client *flb_aws_client_mock_vtable_request( + struct flb_aws_client *aws_client, int method, const char *uri, const char *body, + size_t body_len, struct flb_aws_header *dynamic_headers, size_t dynamic_headers_len); + +/* Protected structs */ + +/* flb_aws_client_mock pointer returned by mock_generator */ +static struct flb_aws_client_mock *flb_aws_client_mock_instance = NULL; + +/* Generator that returns clients with the test vtable */ +static struct flb_aws_client_generator mock_generator = { + .create = flb_aws_client_create_mock, +}; + +/* Test/mock flb_aws_client vtable */ +static struct flb_aws_client_vtable mock_client_vtable = { + .request = flb_aws_client_mock_vtable_request, +}; + +/* + * Configure generator + * Note: Automatically creates mock and wires to generator + * Destroys any existing mock in generator + */ +void flb_aws_client_mock_configure_generator( + struct flb_aws_client_mock_request_chain *request_chain) +{ + flb_aws_client_mock_destroy_generator(); + flb_aws_client_mock_instance = flb_aws_client_mock_create(request_chain); +} + +/* + * Clean up generator's memory + * Cleanup should be called on exiting generator + */ +void flb_aws_client_mock_destroy_generator() +{ + if (flb_aws_client_mock_instance != NULL) { + flb_aws_client_mock_destroy(flb_aws_client_mock_instance); + } +} + +/* Create Mock of flb_aws_client */ +struct flb_aws_client_mock *flb_aws_client_mock_create( + struct flb_aws_client_mock_request_chain *request_chain) +{ + struct flb_aws_client_mock *mock = flb_calloc(1, sizeof(struct flb_aws_client_mock)); + + /* Create a surrogate aws_client and copy to mock client */ + struct flb_aws_client *surrogate_aws_client = flb_aws_client_generator()->create(); + mock->super = *surrogate_aws_client; + mock->surrogate = surrogate_aws_client; + memset(mock->surrogate, 0, sizeof(struct flb_aws_client)); + + /* Switch vtable to mock vtable */ + mock->super.client_vtable = &mock_client_vtable; + mock->request_chain = request_chain; + mock->next_request_index = 0; + return mock; +} + +/* Destroy flb_aws_client_mock */ +void flb_aws_client_mock_destroy(struct flb_aws_client_mock *mock) +{ + /* Remove from generator registry if stored */ + if (flb_aws_client_mock_instance == mock) { + flb_aws_client_mock_instance = NULL; + } + + /* Resurrect surrogate, and destroy flb_aws_client */ + *mock->surrogate = mock->super; + flb_aws_client_destroy(mock->surrogate); + + /* Destroy mock flb_aws_client */ + flb_free(mock); +} + +/* Return a Mocked flb_aws_client, ready for injection */ +struct flb_aws_client *flb_aws_client_mock_context(struct flb_aws_client_mock *mock) +{ + return (struct flb_aws_client *)mock; +} + +/* Get the number of unused requests */ +int flb_aws_client_mock_count_unused_requests(struct flb_aws_client_mock *mock) +{ + return mock->request_chain->length - mock->next_request_index; +} + +/* Set flb_aws_client_mock_instance used in mock generator */ +void flb_aws_client_mock_set_generator_instance(struct flb_aws_client_mock *mock) +{ + flb_aws_client_mock_instance = mock; +} + +/* Set flb_aws_client_mock_instance used in mock generator */ +struct flb_aws_client_mock *flb_aws_client_mock_get_generator_instance( + struct flb_aws_client_mock *mock) +{ + return flb_aws_client_mock_instance = mock; +} + +/* Get generator used in mock */ +struct flb_aws_client_generator *flb_aws_client_get_mock_generator() +{ + return &mock_generator; +} + +/* Get the number of unused requests */ +int flb_aws_client_mock_generator_count_unused_requests() +{ + TEST_ASSERT(flb_aws_client_mock_instance != 0); + return flb_aws_client_mock_count_unused_requests(flb_aws_client_mock_instance); +} + +/* Return the mock instance */ +struct flb_aws_client *flb_aws_client_create_mock() +{ + TEST_CHECK(flb_aws_client_mock_instance != NULL); + TEST_MSG( + "[aws_mock_client] Must initialize flb_aws_client_mock_instance before calling " + "flb_aws_client_create_mock()"); + TEST_MSG( + "[aws_mock_client] This ouccurs when the generator is called, before tests are " + "initialized."); + + return flb_aws_client_mock_context(flb_aws_client_mock_instance); +} + +/* Mock request used by flb_aws_client mock */ +static struct flb_http_client *flb_aws_client_mock_vtable_request( + struct flb_aws_client *aws_client, int method, const char *uri, const char *body, + size_t body_len, struct flb_aws_header *dynamic_headers, size_t dynamic_headers_len) +{ + int h; + int i; + int ret; + + /* Get access to mock */ + struct flb_aws_client_mock *mock = (struct flb_aws_client_mock *)aws_client; + + /* Check that a response is left in the chain */ + ret = TEST_CHECK(mock->next_request_index < mock->request_chain->length); + if (!ret) { + TEST_MSG( + "[flb_aws_client_mock] %d mock responses provided. Attempting to call %d " + "times. Aborting.", + (int)mock->request_chain->length, (int)mock->next_request_index + 1); + return NULL; + } + struct flb_aws_client_mock_response *response = + &(mock->request_chain->responses[mock->next_request_index]); + struct flb_http_client *c = NULL; + + /* create an http client so that we can set the response */ + c = flb_calloc(1, sizeof(struct flb_http_client)); + if (!c) { + flb_errno(); + return NULL; + } + mk_list_init(&c->headers); + + /* Response configuration */ + for (i = 0; i < response->length; ++i) { + struct flb_aws_client_mock_response_config *response_config = + &(response->config_parameters[i]); + void *val1 = response_config->config_value; + void *val2 = response_config->config_value_2; + + /* Expectations */ + if (response_config->config_parameter == FLB_AWS_CLIENT_MOCK_EXPECT_HEADER) { + int header_found = FLB_FALSE; + /* Search for header in request */ + for (h = 0; h < dynamic_headers_len; ++h) { + ret = strncmp(dynamic_headers[h].key, (char *)val1, + dynamic_headers[h].key_len); + if (ret == 0) { + /* Check header value */ + ret = strncmp(dynamic_headers[h].val, (char *)val2, + dynamic_headers[h].val_len + 1); + TEST_CHECK(ret == 0); + TEST_MSG("[aws_mock_client] Expected Header: (%s: %s)", (char *)val1, + (char *)val2); + TEST_MSG("[aws_mock_client] Received Header: (%s: %s)", (char *)val1, + dynamic_headers[h].val); + + header_found = FLB_TRUE; + } + } + TEST_CHECK(header_found); + TEST_MSG("[aws_mock_client] Expected Header: (%s: %s)", (char *)val1, + (char *)val2); + TEST_MSG("[aws_mock_client] Header not received"); + } + else if (response_config->config_parameter == FLB_AWS_CLIENT_MOCK_EXPECT_METHOD) { + char *flb_http_methods[] = { + "FLB_HTTP_GET", "FLB_HTTP_POST", "FLB_HTTP_PUT", + "FLB_HTTP_HEAD", "FLB_HTTP_CONNECT", "FLB_HTTP_PATCH", + }; + + /* + * Check method is what is expected + * Typecast config value from void * -> int + */ + TEST_CHECK(method == (int)(uintptr_t)val1); + TEST_MSG("[aws_mock_client] Expected HTTP Method: %s", + flb_http_methods[(int)(uintptr_t)val1]); + TEST_MSG("[aws_mock_client] Received HTTP Method: %s", + flb_http_methods[method]); + } + else if (response_config->config_parameter == + FLB_AWS_CLIENT_MOCK_EXPECT_HEADER_COUNT) { + TEST_CHECK(dynamic_headers_len == (int)(uintptr_t)val1); + TEST_MSG("[aws_mock_client] Expected %d Headers", (int)(uintptr_t)val1); + TEST_MSG("[aws_mock_client] Received %d Headers", + (int)(uintptr_t)dynamic_headers_len); + } + else if (response_config->config_parameter == FLB_AWS_CLIENT_MOCK_EXPECT_URI) { + ret = strncmp(uri, (char *)val1, strlen((char *)val1) + 1); + TEST_CHECK(ret == 0); + TEST_MSG("[aws_mock_client] Expected URI: %s", (char *)val1); + TEST_MSG("[aws_mock_client] Received URI: %s", uri); + } + + /* Replace response client */ + else if (response_config->config_parameter == + FLB_AWS_CLIENT_MOCK_CONFIG_REPLACE) { + flb_http_client_destroy(c); + c = (struct flb_http_client *)val1; + } + + /* + * Response setters + * Set client fields using XMacro definitions + */ +#define EXPAND_CLIENT_RESPONSE_PARAMETER(lower, UPPER, type) \ + else if (response_config->config_parameter == FLB_AWS_CLIENT_MOCK_SET_##UPPER) \ + { \ + c->resp.lower = CONVERT_##type((char *)val1); \ + } +#include "aws_client_mock_client_resp.def" +#undef EXPAND_CLIENT_RESPONSE_PARAMETER + } + + /* Increment request */ + ++mock->next_request_index; + + return c; +}; diff --git a/src/fluent-bit/tests/include/aws_client_mock.h b/src/fluent-bit/tests/include/aws_client_mock.h new file mode 100644 index 000000000..7cdfc8106 --- /dev/null +++ b/src/fluent-bit/tests/include/aws_client_mock.h @@ -0,0 +1,223 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* + * AWS Client Mock + * + * Note: AWS Client Mock is not intended to be used with asynchronously + * running tests. A mock instance is stored and retrieved by + * the mock generator + */ + +/* + * FLB_AWS_CLIENT_MOCK() definition + * The following macro FLB_AWS_CLIENT_MOCK() translates a request definition + * into a c compound literal, which constructs a mock request chain + * at the block scope. + + * The following translation might ouccur: + + FLB_AWS_CLIENT_MOCK( + response( + expect("token", "aws_token") + expect("time", "123456") + set(STATUS, 200), + ), + response( + set(STATUS, 200), + ) + ) + + * ^^^^^^^^^^^^^^^^^^^^^^^^^ + * *~~~> Translates to ~~~>* + * *vvvvvvvvvvvvvvvvvvvvvvv* + + &(struct flb_aws_client_mock_request_chain){ + 2, + ((struct flb_aws_client_mock_response[]) { // Mock request chain + { + 3, + (struct flb_aws_client_mock_response_config[]){ + ((struct flb_aws_client_mock_response_config) { // Response + configuration FLB_AWS_CLIENT_MOCK_EXPECT_HEADER, (void *) "token", (void *) "aws_token" + }), + ((struct flb_aws_client_mock_response_config) + { FLB_AWS_CLIENT_MOCK_EXPECT_HEADER, + (void *) "time", + (void *) "123456" + } + ) + ((struct flb_aws_client_mock_response_config) { // Response + configuration FLB_AWS_CLIENT_MOCK_SET_STATUS, (void *) 200, (void *) 0 + }), + } + }, + { + 1, + &(struct flb_aws_client_mock_response_config) { + FLB_AWS_CLIENT_MOCK_SET_STATUS, + (void *) 200, + (void *) 0 + } + } + }) + } +*/ + +#ifndef AWS_CLIENT_MOCK_H +#define AWS_CLIENT_MOCK_H + +/* Variadic Argument Counter, Counts up to 64 variadic args */ +#define FLB_AWS_CLIENT_MOCK_COUNT64(...) \ + _FLB_AWS_CLIENT_MOCK_COUNT64(dummy, ##__VA_ARGS__, 63, 62, 61, 60, 59, 58, 57, 56, \ + 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, \ + 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, \ + 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, \ + 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) +#define _FLB_AWS_CLIENT_MOCK_COUNT64( \ + x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, \ + x19, x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x30, x31, x32, x33, x34, x35, \ + x36, x37, x38, x39, x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x50, x51, x52, \ + x53, x54, x55, x56, x57, x58, x59, x60, x61, x62, x63, count, ...) \ + count + +#define FLB_AWS_CLIENT_MOCK_EVAL(...) __VA_ARGS__ +#define FLB_AWS_CLIENT_MOCK_EMPTY() +#define FLB_AWS_CLIENT_MOCK_DIFER(...) \ + FLB_AWS_CLIENT_MOCK_EVAL FLB_AWS_CLIENT_MOCK_EMPTY()(__VA_ARGS__) + +/* Make block-scope addressable compound-literal request chain */ +#define FLB_AWS_CLIENT_MOCK(...) \ + FLB_AWS_CLIENT_MOCK_EVAL(&(struct flb_aws_client_mock_request_chain){ \ + FLB_AWS_CLIENT_MOCK_COUNT64(__VA_ARGS__), \ + (struct flb_aws_client_mock_response[]){__VA_ARGS__}}) + +#define FLB_AWS_CLIENT_MOCK_RESPONSE(...) \ + { \ + FLB_AWS_CLIENT_MOCK_COUNT64(__VA_ARGS__), \ + (struct flb_aws_client_mock_response_config[]) \ + { \ + __VA_ARGS__ \ + } \ + } + +#define FLB_AWS_CLIENT_MOCK_VFUNC___(name, n) name##n +#define FLB_AWS_CLIENT_MOCK_VFUNC(name, n) FLB_AWS_CLIENT_MOCK_VFUNC___(name, n) + +#define FLB_AWS_CLIENT_MOCK_STAGE_CONFIG(mode, parameter, value, ...) \ + ((struct flb_aws_client_mock_response_config){ \ + FLB_AWS_CLIENT_MOCK_##mode##parameter, (void *)value, \ + FLB_AWS_CLIENT_MOCK_VFUNC( \ + FLB_AWS_CLIENT_MOCK_STAGE_CONFIG_OPTIONAL_VALUES_, \ + FLB_AWS_CLIENT_MOCK_COUNT64(__VA_ARGS__))(__VA_ARGS__)}) + +#define FLB_AWS_CLIENT_MOCK_STAGE_CONFIG_OPTIONAL_VALUES_1(value) (void *)value +#define FLB_AWS_CLIENT_MOCK_STAGE_CONFIG_OPTIONAL_VALUES_0() (void *)0 + +// DIFER() allows for correct arg count +#define response(...) FLB_AWS_CLIENT_MOCK_DIFER(FLB_AWS_CLIENT_MOCK_RESPONSE(__VA_ARGS__)) +#define expect(...) \ + FLB_AWS_CLIENT_MOCK_DIFER(FLB_AWS_CLIENT_MOCK_STAGE_CONFIG(EXPECT_, __VA_ARGS__)) +#define config(...) \ + FLB_AWS_CLIENT_MOCK_DIFER(FLB_AWS_CLIENT_MOCK_STAGE_CONFIG(CONFIG_, __VA_ARGS__)) +#define set(...) \ + FLB_AWS_CLIENT_MOCK_DIFER(FLB_AWS_CLIENT_MOCK_STAGE_CONFIG(SET_, __VA_ARGS__)) + +/* Includes */ +#include <fluent-bit/flb_aws_util.h> + +#include "../lib/acutest/acutest.h" + +/* Enum */ +enum flb_aws_client_mock_response_config_parameter { + FLB_AWS_CLIENT_MOCK_EXPECT_METHOD, // int: FLB_HTTP_<method> where method = { "GET", + // "POST", "PUT", "HEAD", "CONNECT", "PATCH" } + FLB_AWS_CLIENT_MOCK_EXPECT_HEADER, // (string, string): (header key, header value) + FLB_AWS_CLIENT_MOCK_EXPECT_HEADER_COUNT, // int: header count + FLB_AWS_CLIENT_MOCK_EXPECT_URI, // string: uri + FLB_AWS_CLIENT_MOCK_CONFIG_REPLACE, // flb_http_client ptr. Client can be null if + // needed +// Define all client fields using XMacro definitions +#define EXPAND_CLIENT_RESPONSE_PARAMETER(x, UPPER, y) FLB_AWS_CLIENT_MOCK_SET_##UPPER, +#include "aws_client_mock_client_resp.def" +#undef EXPAND_CLIENT_RESPONSE_PARAMETER +}; + +/* Structs */ +struct flb_aws_client_mock_response_config { + enum flb_aws_client_mock_response_config_parameter config_parameter; + void *config_value; // Most configuration must be passed in string format. + void *config_value_2; +}; + +struct flb_aws_client_mock_response { + size_t length; + struct flb_aws_client_mock_response_config *config_parameters; +}; + +struct flb_aws_client_mock_request_chain { + size_t length; + struct flb_aws_client_mock_response *responses; +}; + +struct flb_aws_client_mock { + /* This member must come first in the struct's memory layout + * so that this struct can mock flb_aws_client context */ + struct flb_aws_client super; + struct flb_aws_client *surrogate; + + /* Additional data members added to mock */ + struct flb_aws_client_mock_request_chain *request_chain; + size_t next_request_index; +}; + +/* Declarations */ + +/* + * Configure mock generator to be returned by flb_aws_client_get_mock_generator() + * Generator is injected into credential providers and returns a mocked + * flb_aws_client instance. + * + * Note: Automatically creates mock and wires to generator + * Destroys any existing mock in generator + */ +void flb_aws_client_mock_configure_generator( + struct flb_aws_client_mock_request_chain *request_chain); + +/* + * Clean up generator memory + * Note: Cleanup should be called at the end of each test + */ +void flb_aws_client_mock_destroy_generator(); + +/* Create Mock of flb_aws_client */ +struct flb_aws_client_mock *flb_aws_client_mock_create( + struct flb_aws_client_mock_request_chain *request_chain); + +/* + * Destroy flb_aws_client_mock + * Note: flb_aws_client_destroy must not be used prior to flb_aws_client_mock_destroy. + */ +void flb_aws_client_mock_destroy(struct flb_aws_client_mock *mock); + +/* Get the number of unused requests */ +int flb_aws_client_mock_count_unused_requests(struct flb_aws_client_mock *mock); + +/* Return a Mocked flb_aws_client, ready for injection */ +struct flb_aws_client *flb_aws_client_mock_context(struct flb_aws_client_mock *mock); + +/* Generator Methods */ +/* Get/set flb_aws_client_mock_instance used by mock generator */ +void flb_aws_client_mock_set_generator_instance(struct flb_aws_client_mock *mock); +struct flb_aws_client_mock *flb_aws_client_mock_get_generator_instance( + struct flb_aws_client_mock *mock); + +int flb_aws_client_mock_generator_count_unused_requests(); + +/* Substitute Methods */ +/* Get generator used in mock */ +struct flb_aws_client_generator *flb_aws_client_get_mock_generator(); + +/* Return the mock instance */ +struct flb_aws_client *flb_aws_client_create_mock(); + +#endif /* AWS_CLIENT_MOCK_H */ diff --git a/src/fluent-bit/tests/include/aws_client_mock_client_resp.def b/src/fluent-bit/tests/include/aws_client_mock_client_resp.def new file mode 100644 index 000000000..225cc2ea1 --- /dev/null +++ b/src/fluent-bit/tests/include/aws_client_mock_client_resp.def @@ -0,0 +1,34 @@ +/* XMacro Definition for Mock AWS Client http_client Response */ + +/* Converters: CONVERT_<C_INT> */ +#define EVAL1(...) __VA_ARGS__ +#define CONVERT_T_INT(str) (int) (uintptr_t) str +#define CONVERT_T_SIZE_T(str) (size_t) str +#define CONVERT_T_LONG(str) (long) str +#define CONVERT_T_CHAR_STAR(str) str + +EVAL1(EXPAND_CLIENT_RESPONSE_PARAMETER(status, STATUS, T_INT)) /* HTTP response status */ +EVAL1(EXPAND_CLIENT_RESPONSE_PARAMETER(content_length, CONTENT_LENGTH, T_INT)) /* Content length set by headers */ +EVAL1(EXPAND_CLIENT_RESPONSE_PARAMETER(chunked_encoding, CHUNKED_ENCODEING, T_INT)) /* Chunked transfer encoding ? */ +EVAL1(EXPAND_CLIENT_RESPONSE_PARAMETER(connection_close, CONNECTION_CLOSE, T_INT)) /* connection: close ? */ +EVAL1(EXPAND_CLIENT_RESPONSE_PARAMETER(chunked_cur_size, CHUNKED_CUR_SIZE, T_LONG)) +EVAL1(EXPAND_CLIENT_RESPONSE_PARAMETER(chunked_exp_size, CHUNKED_EXP_SIZE, T_LONG)) /* expected chunked size */ +EVAL1(EXPAND_CLIENT_RESPONSE_PARAMETER(chunk_processed_end, CHUNK_PROCESSED_END, T_CHAR_STAR)) /* Position to mark last chunk */ +EVAL1(EXPAND_CLIENT_RESPONSE_PARAMETER(headers_end, HEADERS_END, T_CHAR_STAR)) /* Headers end (\r\n\r\n) */ + +/* Payload: body response: reference to 'data' */ +EVAL1(EXPAND_CLIENT_RESPONSE_PARAMETER(payload, PAYLOAD, T_CHAR_STAR)) +EVAL1(EXPAND_CLIENT_RESPONSE_PARAMETER(payload_size, PAYLOAD_SIZE, T_SIZE_T)) + +/* Buffer to store server response */ +EVAL1(EXPAND_CLIENT_RESPONSE_PARAMETER(data, DATA, T_CHAR_STAR)) +EVAL1(EXPAND_CLIENT_RESPONSE_PARAMETER(data_len, DATA_LEN, T_SIZE_T)) +EVAL1(EXPAND_CLIENT_RESPONSE_PARAMETER(data_size, DATA_SIZE, T_SIZE_T)) +EVAL1(EXPAND_CLIENT_RESPONSE_PARAMETER(data_size_max, DATA_SIZE_MAX, T_SIZE_T)) + +#undef CONVERT_T_INT +#undef CONVERT_T_SIZE +#undef CONVERT_T_LONG +#undef CONVERT_T_CHAR_STAR + +#undef EVAL1 diff --git a/src/fluent-bit/tests/include/flb_tests_initialize_tls.h b/src/fluent-bit/tests/include/flb_tests_initialize_tls.h new file mode 100644 index 000000000..bfe16f229 --- /dev/null +++ b/src/fluent-bit/tests/include/flb_tests_initialize_tls.h @@ -0,0 +1,44 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* Fluent Bit + * ========== + * Copyright (C) 2019-2020 The Fluent Bit Authors + * Copyright (C) 2015-2018 Treasure Data Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FLB_TESTS_INITALIZE_TLS_H +#define FLB_TESTS_INITALIZE_TLS_H + +#include <fluent-bit/flb_config.h> +#include <fluent-bit/flb_mem.h> + +struct flb_config *test_env_config = NULL; + +static inline void flb_test_env_config_init(void) +{ + test_env_config = flb_config_init(); + + if (test_env_config == NULL) { + return; + } +} + +static inline void flb_test_env_config_destroy(void) { + if (test_env_config != NULL) { + flb_config_exit(test_env_config); + } +} + +#endif |