From 3d72321754765eea7d99ce4d718ad5456b7fe363 Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Tue, 26 Aug 2025 10:54:57 -0400 Subject: [PATCH 1/2] tests/runtime: only call flb_stop for in_netif tests that start correctly. Signed-off-by: Phillip Whelan --- tests/runtime/in_netif.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/runtime/in_netif.c b/tests/runtime/in_netif.c index ff66d9e13ef..8d37fd7117d 100644 --- a/tests/runtime/in_netif.c +++ b/tests/runtime/in_netif.c @@ -69,12 +69,14 @@ static struct test_ctx *test_ctx_create(struct flb_lib_out_cb *data) return ctx; } -static void test_ctx_destroy(struct test_ctx *ctx) +static void test_ctx_destroy(struct test_ctx *ctx, int ret) { TEST_CHECK(ctx != NULL); sleep(1); - flb_stop(ctx->flb); + if (ret == 0) { + flb_stop(ctx->flb); + } flb_destroy(ctx->flb); flb_free(ctx); } @@ -226,7 +228,7 @@ static void flb_test_normal() TEST_MSG("expect: >=1 got: %d", got); } - test_ctx_destroy(ctx); + test_ctx_destroy(ctx, ret); } static void flb_test_no_interface() @@ -251,7 +253,7 @@ static void flb_test_no_interface() ret = flb_start(ctx->flb); TEST_CHECK(ret != 0); - test_ctx_destroy(ctx); + test_ctx_destroy(ctx, ret); } static void flb_test_invalid_interface() @@ -285,7 +287,7 @@ static void flb_test_invalid_interface() ret = flb_start(ctx->flb); TEST_CHECK(ret != 0); - test_ctx_destroy(ctx); + test_ctx_destroy(ctx, ret); } static void flb_test_verbose() @@ -338,7 +340,7 @@ static void flb_test_verbose() TEST_MSG("expect: >10 got: %d", got); } - test_ctx_destroy(ctx); + test_ctx_destroy(ctx, ret); } TEST_LIST = { From 855f617b99d848d962d83ac4db76136f02c5286e Mon Sep 17 00:00:00 2001 From: Phillip Whelan Date: Tue, 26 Aug 2025 10:55:21 -0400 Subject: [PATCH 2/2] tests/runtime: only call flb_stop for in_podman_metrics tests that start correctly. Signed-off-by: Phillip Whelan --- tests/runtime/in_podman_metrics.c | 54 ++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/tests/runtime/in_podman_metrics.c b/tests/runtime/in_podman_metrics.c index 929fb2e2dac..eb06c5d22fb 100644 --- a/tests/runtime/in_podman_metrics.c +++ b/tests/runtime/in_podman_metrics.c @@ -83,12 +83,15 @@ void do_create(flb_ctx_t *ctx, char *system, ...) NULL) == 0); } -void do_destroy(flb_ctx_t *ctx) { - flb_stop(ctx); +void do_destroy(flb_ctx_t *ctx, int ret) { + if (ret == 0) { + flb_stop(ctx); + } flb_destroy(ctx); } void flb_test_ipm_regular() { + int ret; flb_ctx_t *ctx = flb_create(); do_create(ctx, "podman_metrics", @@ -97,14 +100,16 @@ void flb_test_ipm_regular() { "path.sysfs", DPATH_PODMAN_REGULAR, "path.procfs", DPATH_PODMAN_REGULAR, NULL); - TEST_CHECK(flb_start(ctx) == 0); + ret = flb_start(ctx); + TEST_CHECK(ret == 0); sleep(1); TEST_CHECK(check_metric(ctx, "usage_bytes") == 0); TEST_CHECK(check_metric(ctx, "receive_bytes_total") == 0); - do_destroy(ctx); + do_destroy(ctx, ret); } void flb_test_ipm_reversed() { + int ret; flb_ctx_t *ctx = flb_create(); do_create(ctx, "podman_metrics", @@ -113,14 +118,16 @@ void flb_test_ipm_reversed() { "path.sysfs", DPATH_PODMAN_REVERSED, "path.procfs", DPATH_PODMAN_REVERSED, NULL); - TEST_CHECK(flb_start(ctx) == 0); + ret = flb_start(ctx); + TEST_CHECK(ret == 0); sleep(1); TEST_CHECK(check_metric(ctx, "usage_bytes") == 0); TEST_CHECK(check_metric(ctx, "receive_bytes_total") == 0); - do_destroy(ctx); + do_destroy(ctx, ret); } void flb_test_ipm_garbage_config() { + int ret; flb_ctx_t *ctx = flb_create(); do_create(ctx, "podman_metrics", @@ -129,11 +136,13 @@ void flb_test_ipm_garbage_config() { "path.sysfs", DPATH_PODMAN_GARBAGE_CONFIG, "path.procfs", DPATH_PODMAN_GARBAGE_CONFIG, NULL); - TEST_CHECK(flb_start(ctx) != 0); - do_destroy(ctx); + ret = flb_start(ctx); + TEST_CHECK(ret != 0); + do_destroy(ctx, ret); } void flb_test_ipm_no_config() { + int ret; flb_ctx_t *ctx = flb_create(); do_create(ctx, "podman_metrics", @@ -142,11 +151,13 @@ void flb_test_ipm_no_config() { "path.sysfs", DPATH_PODMAN_NO_CONFIG, "path.procfs", DPATH_PODMAN_NO_CONFIG, NULL); - TEST_CHECK(flb_start(ctx) != 0); - do_destroy(ctx); + ret = flb_start(ctx); + TEST_CHECK(ret != 0); + do_destroy(ctx, ret); } void flb_test_ipm_no_sysfs() { + int ret; flb_ctx_t *ctx = flb_create(); do_create(ctx, "podman_metrics", @@ -155,14 +166,16 @@ void flb_test_ipm_no_sysfs() { "path.sysfs", DPATH_PODMAN_NO_SYSFS, "path.procfs", DPATH_PODMAN_NO_SYSFS, NULL); - TEST_CHECK(flb_start(ctx) == 0); + ret = flb_start(ctx); + TEST_CHECK(ret == 0); sleep(1); TEST_CHECK(check_metric(ctx, "usage_bytes") != 0); TEST_CHECK(check_metric(ctx, "receive_bytes_total") != 0); - do_destroy(ctx); + do_destroy(ctx, ret); } void flb_test_ipm_no_proc() { + int ret; flb_ctx_t *ctx = flb_create(); do_create(ctx, "podman_metrics", @@ -171,14 +184,16 @@ void flb_test_ipm_no_proc() { "path.sysfs", DPATH_PODMAN_NO_PROC, "path.procfs", DPATH_PODMAN_NO_PROC, NULL); - TEST_CHECK(flb_start(ctx) == 0); + ret = flb_start(ctx); + TEST_CHECK(ret == 0); sleep(1); TEST_CHECK(check_metric(ctx, "usage_bytes") == 0); TEST_CHECK(check_metric(ctx, "receive_bytes_total") != 0); - do_destroy(ctx); + do_destroy(ctx, ret); } void flb_test_ipm_garbage() { + int ret; flb_ctx_t *ctx = flb_create(); do_create(ctx, "podman_metrics", @@ -187,14 +202,16 @@ void flb_test_ipm_garbage() { "path.sysfs", DPATH_PODMAN_GARBAGE, "path.procfs", DPATH_PODMAN_GARBAGE, NULL); - TEST_CHECK(flb_start(ctx) == 0); + ret = flb_start(ctx); + TEST_CHECK(ret == 0); sleep(1); TEST_CHECK(check_metric(ctx, "usage_bytes") != 0); TEST_CHECK(check_metric(ctx, "receive_bytes_total") != 0); - do_destroy(ctx); + do_destroy(ctx, ret); } void flb_test_ipm_cgroupv2() { + int ret; flb_ctx_t *ctx = flb_create(); do_create(ctx, "podman_metrics", @@ -203,11 +220,12 @@ void flb_test_ipm_cgroupv2() { "path.sysfs", DPATH_PODMAN_CGROUP_V2, "path.procfs", DPATH_PODMAN_CGROUP_V2, NULL); - TEST_CHECK(flb_start(ctx) == 0); + ret = flb_start(ctx); + TEST_CHECK(ret == 0); sleep(1); TEST_CHECK(check_metric(ctx, "usage_bytes") == 0); TEST_CHECK(check_metric(ctx, "receive_bytes_total") == 0); - do_destroy(ctx); + do_destroy(ctx, ret); } TEST_LIST = {