Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/svs/index/flat/flat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "svs/core/logging.h"
#include "svs/lib/file.h"
#include "svs/lib/saveload/load.h"
#include "svs/lib/scopeguard.h"
#include "svs/orchestrators/exhaustive.h"

// tests
Expand All @@ -30,6 +31,9 @@
// spd log
#include "spdlog/sinks/callback_sink.h"

// stl
#include <algorithm>

CATCH_TEST_CASE("FlatIndex Logging Test", "[logging]") {
// Vector to store captured log messages
std::vector<std::string> captured_logs;
Expand All @@ -55,6 +59,13 @@ CATCH_TEST_CASE("FlatIndex Logging Test", "[logging]") {
global_callback_sink->set_level(spdlog::level::trace);
auto original_logger = svs::logging::get();
original_logger->sinks().push_back(global_callback_sink);
// The sink captures a local vector: remove it before the vector goes out of scope.
auto remove_sink = svs::lib::make_scope_guard([&]() noexcept {
auto& sinks = original_logger->sinks();
sinks.erase(
std::remove(sinks.begin(), sinks.end(), global_callback_sink), sinks.end()
);
});

std::vector<float> data{1.0f, 2.0f};
auto dataView = svs::data::SimpleDataView<float>(data.data(), 2, 1);
Expand Down
11 changes: 11 additions & 0 deletions tests/svs/index/inverted/clustering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
// header under test
#include "svs/index/inverted/clustering.h"

// svs
#include "svs/lib/scopeguard.h"

// tests
#include "tests/utils/test_dataset.h"
#include "tests/utils/utils.h"
Expand All @@ -25,6 +28,7 @@
#include "catch2/catch_test_macros.hpp"

// stl
#include <algorithm>
#include <unordered_map>

// logging
Expand Down Expand Up @@ -415,6 +419,13 @@ CATCH_TEST_CASE("Clustering with Logger", "[logging]") {
global_callback_sink->set_level(spdlog::level::trace);
auto original_logger = svs::logging::get();
original_logger->sinks().push_back(global_callback_sink);
// The sink captures a local vector: remove it before the vector goes out of scope.
auto remove_sink = svs::lib::make_scope_guard([&]() noexcept {
auto& sinks = original_logger->sinks();
sinks.erase(
std::remove(sinks.begin(), sinks.end(), global_callback_sink), sinks.end()
);
});

// Setup cluster
auto data = svs::data::SimpleData<float>::load(test_dataset::data_svs_file());
Expand Down
9 changes: 9 additions & 0 deletions tests/svs/index/inverted/memory_based.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
#include "catch2/catch_test_macros.hpp"
#include "spdlog/sinks/callback_sink.h"
#include "svs-benchmark/datasets.h"
#include "svs/lib/scopeguard.h"
#include "svs/lib/timing.h"
#include "svs/orchestrators/inverted.h"
#include "tests/utils/inverted_reference.h"
#include "tests/utils/test_dataset.h"
#include <algorithm>
#include <filesystem>
#include <sstream>

Expand Down Expand Up @@ -50,6 +52,13 @@ CATCH_TEST_CASE("InvertedIndex Logging Test", "[long][logging]") {
global_callback_sink->set_level(spdlog::level::trace);
auto original_logger = svs::logging::get();
original_logger->sinks().push_back(global_callback_sink);
// The sink captures a local vector: remove it before the vector goes out of scope.
auto remove_sink = svs::lib::make_scope_guard([&]() noexcept {
auto& sinks = original_logger->sinks();
sinks.erase(
std::remove(sinks.begin(), sinks.end(), global_callback_sink), sinks.end()
);
});

// Setup index
auto distance = svs::DistanceL2();
Expand Down
15 changes: 15 additions & 0 deletions tests/svs/index/vamana/dynamic_index_2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "svs/index/vamana/dynamic_index.h"
#include "svs/lib/float16.h"
#include "svs/lib/preprocessor.h"
#include "svs/lib/scopeguard.h"
#include "svs/lib/timing.h"

#include "svs/misc/dynamic_helper.h"
Expand Down Expand Up @@ -283,6 +284,13 @@ CATCH_TEST_CASE("Testing Graph Index", "[graph_index][dynamic_index]") {
global_callback_sink->set_level(spdlog::level::trace);
auto original_logger = svs::logging::get();
original_logger->sinks().push_back(global_callback_sink);
// The sink captures a local vector: remove it before the vector goes out of scope.
auto remove_sink = svs::lib::make_scope_guard([&]() noexcept {
auto& sinks = original_logger->sinks();
sinks.erase(
std::remove(sinks.begin(), sinks.end(), global_callback_sink), sinks.end()
);
});

// Load the base dataset and queries.
auto data = svs::data::SimpleData<Eltype, N>::load(test_dataset::data_svs_file());
Expand Down Expand Up @@ -495,6 +503,13 @@ CATCH_TEST_CASE("Dynamic MutableVamanaIndex Per-Index Logging Test", "[logging]"

auto original_logger = svs::logging::get();
original_logger->sinks().push_back(global_callback_sink);
// The sink captures a local vector: remove it before the vector goes out of scope.
auto remove_sink = svs::lib::make_scope_guard([&]() noexcept {
auto& sinks = original_logger->sinks();
sinks.erase(
std::remove(sinks.begin(), sinks.end(), global_callback_sink), sinks.end()
);
});

// Setup index
auto data = svs::data::SimpleData<Eltype, N>::load(test_dataset::data_svs_file());
Expand Down
9 changes: 9 additions & 0 deletions tests/svs/index/vamana/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "svs/extensions/vamana/scalar.h"
#include "svs/index/vamana/build_params.h"
#include "svs/lib/preprocessor.h"
#include "svs/lib/scopeguard.h"
#include "svs/orchestrators/vamana.h"
#include "svs/quantization/scalar/scalar.h"

Expand All @@ -41,6 +42,7 @@
// svsbenchmark
#include "svs-benchmark/benchmark.h"
// stl
#include <algorithm>
#include <sstream>
#include <string_view>

Expand Down Expand Up @@ -159,6 +161,13 @@ CATCH_TEST_CASE("Static VamanaIndex Per-Index Logging", "[logging]") {

auto original_logger = svs::logging::get();
original_logger->sinks().push_back(global_callback_sink);
// The sink captures a local vector: remove it before the vector goes out of scope.
auto remove_sink = svs::lib::make_scope_guard([&]() noexcept {
auto& sinks = original_logger->sinks();
sinks.erase(
std::remove(sinks.begin(), sinks.end(), global_callback_sink), sinks.end()
);
});

// Create some minimal data
auto data = svs::data::SimpleData<Eltype, N>::load(test_dataset::data_svs_file());
Expand Down
Loading