diff --git a/userspace/libsinsp/test/CMakeLists.txt b/userspace/libsinsp/test/CMakeLists.txt index 53fef27594..09d4531c5c 100644 --- a/userspace/libsinsp/test/CMakeLists.txt +++ b/userspace/libsinsp/test/CMakeLists.txt @@ -120,6 +120,7 @@ set(LIBSINSP_UNIT_TESTS_SOURCES thread_table.ut.cpp public_sinsp_API/event_related.cpp public_sinsp_API/sinsp_logger.cpp + cri_settings.ut.cpp "${TEST_PLUGINS}" "${SINSP_PARSERS_SUITE}" "${SINSP_CLASSES_SUITE}" diff --git a/userspace/libsinsp/test/cri_settings.ut.cpp b/userspace/libsinsp/test/cri_settings.ut.cpp new file mode 100644 index 0000000000..a7893ed050 --- /dev/null +++ b/userspace/libsinsp/test/cri_settings.ut.cpp @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: Apache-2.0 +/* +Copyright (C) 2024 The Falco Authors. + +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 +#include +#include +#include "./sinsp_with_test_input.h" + + +TEST_F(sinsp_with_test_input, default_cri_socket_paths) +{ + libsinsp::cri::settings* cri_settings = libsinsp::cri::settings::instance(); + + if (!cri_settings->get_cri_unix_socket_paths().empty()) + { + cri_settings->clear_cri_unix_socket_paths(); + } + + add_default_init_thread(); + open_inspector(); + + auto socket_paths = cri_settings->get_cri_unix_socket_paths(); + + ASSERT_EQ(socket_paths.size(), 3); + ASSERT_TRUE("/run/containerd/containerd.sock"==socket_paths[0]); + ASSERT_TRUE("/run/crio/crio.sock"==socket_paths[1]); + ASSERT_TRUE("/run/k3s/containerd/containerd.sock"==socket_paths[2]); +}