Skip to content
Open
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
6 changes: 6 additions & 0 deletions bindings/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,9 @@ install(FILES
DESTINATION "${SVS_RUNTIME_CONFIG_INSTALL_DIR}"
)

# Tests
if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()

50 changes: 50 additions & 0 deletions bindings/cpp/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2025 Intel Corporation
#
# 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(FetchContent)

set(CATCH_CONFIG_CONSOLE_WIDTH "100" CACHE STRING "" FORCE)
set(CATCH_BUILD_TESTING OFF CACHE BOOL "" FORCE)
set(CATCH_CONFIG_ENABLE_BENCHMARKING OFF CACHE BOOL "" FORCE)
set(CATCH_CONFIG_PREFIX_ALL ON CACHE BOOL "" FORCE)

FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0
)
FetchContent_MakeAvailable(Catch2)

# Runtime tests
add_executable(svs_runtime_tests
test_version_namespace.cpp
)

target_include_directories(svs_runtime_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../include
)

target_link_libraries(svs_runtime_tests PRIVATE
svs_runtime
Catch2::Catch2WithMain
)

target_compile_definitions(svs_runtime_tests PRIVATE
FAISS_SVS_RUNTIME_VERSION=v0
)

# Register with CTest
include(CTest)
include(Catch)
catch_discover_tests(svs_runtime_tests)
55 changes: 55 additions & 0 deletions bindings/cpp/tests/test_version_namespace.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2025 Intel Corporation
*
* 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 "catch2/catch_test_macros.hpp"
#include <svs/runtime/version.h>

// Validate macro is defined (like FAISS does)
#ifndef FAISS_SVS_RUNTIME_VERSION
#error "FAISS_SVS_RUNTIME_VERSION is not defined"
#endif

// Create namespace alias (FAISS integration pattern)
SVS_RUNTIME_CREATE_API_ALIAS(svs_runtime, FAISS_SVS_RUNTIME_VERSION);

CATCH_TEST_CASE("Version Namespace Compatibility", "[runtime][version]") {
CATCH_SECTION("Namespace alias resolves to v0") {
// Both access methods should give same values
CATCH_REQUIRE(
svs_runtime::VersionInfo::major == svs::runtime::v0::VersionInfo::major
);
CATCH_REQUIRE(
svs_runtime::VersionInfo::minor == svs::runtime::v0::VersionInfo::minor
);
CATCH_REQUIRE(
svs_runtime::VersionInfo::patch == svs::runtime::v0::VersionInfo::patch
);
}

CATCH_SECTION("Version compatibility check") {
// Should be compatible with v0
CATCH_REQUIRE(svs_runtime::VersionInfo::is_compatible_with_major(0));

// Should not be compatible with v1
CATCH_REQUIRE_FALSE(svs_runtime::VersionInfo::is_compatible_with_major(1));
}

CATCH_SECTION("Version string") {
// Verify version string is accessible
CATCH_REQUIRE(svs_runtime::VersionInfo::get_version() != nullptr);
CATCH_REQUIRE(svs_runtime::VersionInfo::get_api_namespace() != nullptr);
}
}
10 changes: 9 additions & 1 deletion docker/x86_64/build-cpp-runtime-bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,16 @@ mkdir -p /workspace/bindings/cpp/build_cpp_bindings /workspace/install_cpp_bindi

# Build and install runtime bindings library
cd /workspace/bindings/cpp/build_cpp_bindings
CC=gcc CXX=g++ cmake .. -DCMAKE_INSTALL_PREFIX=/workspace/install_cpp_bindings -DCMAKE_INSTALL_LIBDIR=lib
CC=gcc CXX=g++ cmake .. \
-DCMAKE_INSTALL_PREFIX=/workspace/install_cpp_bindings \
-DCMAKE_INSTALL_LIBDIR=lib \
-DBUILD_TESTING=ON
cmake --build . -j

# Run binding tests
echo "Running SVS Runtime Binding Tests..."
CTEST_OUTPUT_ON_FAILURE=1 ctest

cmake --install .

# Create tarball with symlink for compatibility
Expand Down
Loading