summaryrefslogtreecommitdiffstats
path: root/fluent-bit/lib/chunkio/tests/context.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-24 09:54:23 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-24 09:54:44 +0000
commit836b47cb7e99a977c5a23b059ca1d0b5065d310e (patch)
tree1604da8f482d02effa033c94a84be42bc0c848c3 /fluent-bit/lib/chunkio/tests/context.c
parentReleasing debian version 1.44.3-2. (diff)
downloadnetdata-836b47cb7e99a977c5a23b059ca1d0b5065d310e.tar.xz
netdata-836b47cb7e99a977c5a23b059ca1d0b5065d310e.zip
Merging upstream version 1.46.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'fluent-bit/lib/chunkio/tests/context.c')
-rw-r--r--fluent-bit/lib/chunkio/tests/context.c182
1 files changed, 0 insertions, 182 deletions
diff --git a/fluent-bit/lib/chunkio/tests/context.c b/fluent-bit/lib/chunkio/tests/context.c
deleted file mode 100644
index 7b7d9ea48..000000000
--- a/fluent-bit/lib/chunkio/tests/context.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/* Chunk I/O
- * =========
- * Copyright 2018 Eduardo Silva <eduardo@monkey.io>
- *
- * 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.
- */
-
-#include <chunkio/chunkio.h>
-#include <chunkio/cio_log.h>
-
-#include "cio_tests_internal.h"
-
-int log_check;
-
-/* Logging callback, once called it just turn on the log_check flag */
-static int log_cb(struct cio_ctx *ctx, int level, const char *file, int line,
- char *str)
-{
- (void) ctx;
- (void) file;
- (void) line;
- (void) str;
-
- log_check = 1;
- return 0;
-}
-
-/* Basic tests on context creation */
-static void test_context()
-{
- int flags;
- struct cio_ctx *ctx;
- struct cio_options cio_opts;
-
- flags = CIO_CHECKSUM;
-
- cio_options_init(&cio_opts);
- cio_opts.flags = flags;
-
- /* Invalid path */
- cio_opts.root_path = "";
- cio_opts.log_level = CIO_LOG_INFO;
-
- ctx = cio_create(&cio_opts);
- TEST_CHECK(ctx == NULL);
-
- /* Invalid debug level -1 */
- cio_opts.root_path = "/tmp/";
- cio_opts.log_level = -1;
-
- ctx = cio_create(&cio_opts);
- TEST_CHECK(ctx == NULL);
-
- /* Invalid debug level 6 */
- cio_opts.log_level = 6;
-
- ctx = cio_create(&cio_opts);
- TEST_CHECK(ctx == NULL);
-
- /* Valid context without callback */
- log_check = 0;
- cio_opts.log_level = CIO_LOG_INFO;
-
- ctx = cio_create(&cio_opts);
- TEST_CHECK(ctx != NULL);
- cio_log_info(ctx, "test");
- TEST_CHECK(log_check == 0);
- cio_destroy(ctx);
-
- /* Valid with context callback */
- log_check = 0;
- cio_opts.log_cb = log_cb;
-
- ctx = cio_create(&cio_opts);
- TEST_CHECK(ctx != NULL);
- cio_log_info(ctx, "test");
- TEST_CHECK(log_check == 1);
- cio_destroy(ctx);
-}
-
-static void test_log_level()
-{
- struct cio_ctx *ctx;
- struct cio_options cio_opts;
-
- cio_options_init(&cio_opts);
-
- /* Logging with unset callback at creation, but set later */
- log_check = 0;
- cio_opts.root_path = "/tmp/";
- cio_opts.log_level = CIO_LOG_INFO;
-
- ctx = cio_create(&cio_opts);
- TEST_CHECK(ctx != NULL);
- cio_log_info(ctx, "test");
- TEST_CHECK(log_check == 0);
-
- /* Loggin callback enable */
- cio_set_log_callback(ctx, log_cb);
- cio_log_info(ctx, "test");
- TEST_CHECK(log_check == 1);
-
- /* Test: CIO_ERROR */
- cio_set_log_level(ctx, CIO_LOG_ERROR);
- log_check = 0;
- cio_log_warn(ctx, "test");
- TEST_CHECK(log_check == 0);
- cio_log_error(ctx, "test");
- TEST_CHECK(log_check == 1);
-
- /* Test: CIO_WARN */
- cio_set_log_level(ctx, CIO_LOG_WARN);
- log_check = 0;
- cio_log_info(ctx, "test");
- TEST_CHECK(log_check == 0);
- cio_log_warn(ctx, "test");
- TEST_CHECK(log_check == 1);
-
- /* Test: CIO_INFO */
- cio_set_log_level(ctx, CIO_LOG_INFO);
- log_check = 0;
- cio_log_debug(ctx, "test");
- TEST_CHECK(log_check == 0);
- cio_log_info(ctx, "test");
- TEST_CHECK(log_check == 1);
-
- /* Test: CIO_DEBUG */
- cio_set_log_level(ctx, CIO_LOG_DEBUG);
- log_check = 0;
- cio_log_trace(ctx, "test");
- TEST_CHECK(log_check == 0);
- cio_log_debug(ctx, "test");
- TEST_CHECK(log_check == 1);
-
- /* Test: CIO_TRACE */
- cio_set_log_level(ctx, CIO_LOG_TRACE);
- log_check = 0;
- cio_log_trace(ctx, "test");
- TEST_CHECK(log_check == 1);
-
- /* destroy context */
- cio_destroy(ctx);
-}
-
-static void test_open_flags()
-{
- struct cio_ctx *ctx;
- struct cio_options cio_opts;
-
- cio_options_init(&cio_opts);
- TEST_CHECK(cio_opts.flags & CIO_OPEN_RW);
-
- /* reset flags */
- cio_opts.flags = 0;
-
- /* check that after context creation a default has been set */
- ctx = cio_create(&cio_opts);
- TEST_CHECK(ctx != NULL);
- TEST_CHECK(cio_opts.flags & CIO_OPEN_RW);
-
- /* destroy context */
- cio_destroy(ctx);
-}
-
-TEST_LIST = {
- {"context", test_context},
- {"log_level", test_log_level},
- {"open_flags", test_open_flags},
- { 0 }
-};