Files
obs-streamer-tools-plugin/core/tests/test_livekit_smoke.cpp
T
shadowdaoandClaude Sonnet 5 e595173049 Link the pinned LiveKit C++ SDK into the core library
Adds cmake/LiveKitSDK.cmake, adapted from
livekit-examples/cpp-example-collection's helper of the same name, with the
VERSION="latest" GitHub-API resolution path removed: this project pins an
exact client-sdk-cpp release (1.10.1, the newest tag as of today), and the
pin should not be silently bypassable. The module also now exports the
runtime shared libraries so packaging can stage liblivekit/liblivekit_ffi
next to the plugin module later.

core/ links LiveKit::livekit PUBLIC. A new smoke test proves the SDK is not
just linked but loadable and callable: livekit::initialize()/shutdown()
round-trip in-process, a second initialize() reports "already initialized",
the log level round-trips, and the SDK's generated LIVEKIT_BUILD_VERSION is
asserted equal to the version CMake pinned (so a stale extracted SDK
directory fails loudly rather than being silently reused).

Also adds core/tests/test_util.h, a dependency-free assertion harness that
keeps running after a failure and prints a pass/fail count, so CI output says
how much actually ran instead of dying on the first bare assert().

cmake_minimum_required goes 3.16 -> 3.19 (file(ARCHIVE_EXTRACT)).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RL8abRmgFXkVASHkkqiJbE
2026-09-06 21:22:14 -07:00

65 lines
2.4 KiB
C++

/*
streamer-tools OBS Camera Plugin - LiveKit SDK link smoke test
Copyright (C) 2026 CyberCoveLLC <jknapp85@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <https://www.gnu.org/licenses/>
*/
// Proves the pinned client-sdk-cpp release is genuinely linked and callable:
// the SDK's own global init/shutdown runs in-process without crashing, and
// the header-reported build version matches the version CMake pinned.
//
// This does NOT touch the network -- livekit::initialize() only sets up
// global SDK state and log routing.
#include <cstdio>
#include <cstring>
#include <livekit/build.h>
#include <livekit/livekit.h>
#include <livekit/logging.h>
#include "test_util.h"
int main()
{
// The pin CMake resolved is passed in as a define; the SDK's own
// generated build.h reports what was actually unpacked. A mismatch means
// a stale extracted SDK directory is being reused.
ST_ASSERT_EQ(std::string(LIVEKIT_BUILD_VERSION), std::string(STPLUGIN_EXPECTED_LIVEKIT_VERSION));
// initialize() returns true when this call performed the init, false if
// the SDK was already initialized. Either way it must not crash, and a
// second call must report "already initialized".
bool first = livekit::initialize(livekit::LogLevel::Error);
ST_ASSERT(first);
bool second = livekit::initialize(livekit::LogLevel::Error);
ST_ASSERT(!second);
// Log level round-trips through the SDK's global state.
livekit::setLogLevel(livekit::LogLevel::Warn);
ST_ASSERT(livekit::getLogLevel() == livekit::LogLevel::Warn);
livekit::shutdown();
// The SDK documents that initialize() may be called again after
// shutdown(); exercise that so a half-torn-down global state would show
// up here rather than in OBS.
ST_ASSERT(livekit::initialize(livekit::LogLevel::Error));
livekit::shutdown();
return st_test_report("livekit_smoke");
}