Skip to content

Commit c30ab13

Browse files
added the test infra using gtest, and some tests (#49)
* added the test infra using gtest, and some tests * change the tests * get integration passed
1 parent 3333a4a commit c30ab13

18 files changed

Lines changed: 2980 additions & 42 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ build/
99
build-debug/
1010
build-release/
1111
vcpkg_installed/
12+
# Generated header
13+
include/livekit/build.h
1214
received_green.avif
1315
docs/*.bak
1416
docs/html/

CMakeLists.txt

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ set(LIVEKIT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
1111
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
1212

1313
option(LIVEKIT_BUILD_EXAMPLES "Build LiveKit examples" OFF)
14+
option(LIVEKIT_BUILD_TESTS "Build LiveKit tests" OFF)
1415

1516
# vcpkg is only used on Windows; Linux/macOS use system package managers
1617
if(WIN32)
@@ -131,8 +132,8 @@ add_custom_command(
131132

132133
target_sources(livekit_proto PRIVATE ${PROTO_SRCS} ${PROTO_HDRS})
133134

134-
set(GENERATED_INCLUDE_DIR "${LIVEKIT_BINARY_DIR}/generated")
135-
file(MAKE_DIRECTORY "${GENERATED_INCLUDE_DIR}")
135+
# Generate build.h directly into include/livekit/ for simpler include paths
136+
set(GENERATED_BUILD_H "${LIVEKIT_ROOT_DIR}/include/livekit/build.h")
136137

137138
set(GIT_COMMIT "unknown")
138139
find_package(Git QUIET)
@@ -151,7 +152,7 @@ set(GENERATED_COMMENT "This file was auto-generated by CMake on ${BUILD_DATE}. D
151152

152153
configure_file(
153154
"${LIVEKIT_ROOT_DIR}/build.h.in"
154-
"${GENERATED_INCLUDE_DIR}/build.h"
155+
"${GENERATED_BUILD_H}"
155156
@ONLY
156157
)
157158

@@ -321,7 +322,6 @@ target_include_directories(livekit
321322
${LIVEKIT_ROOT_DIR}/src
322323
${RUST_ROOT}/livekit-ffi/include
323324
${PROTO_BINARY_DIR}
324-
${GENERATED_INCLUDE_DIR}
325325
)
326326

327327
target_link_libraries(livekit
@@ -335,15 +335,12 @@ message(STATUS "Protobuf: version=${Protobuf_VERSION}; protoc=${Protobuf_PROTOC_
335335
add_dependencies(livekit build_rust_ffi)
336336

337337
if(LIVEKIT_IS_TOPLEVEL)
338-
# Copy public headers to build/include
338+
# Copy public headers to build/include (build.h is already in include/livekit/)
339339
add_custom_command(
340340
TARGET livekit POST_BUILD
341341
COMMAND ${CMAKE_COMMAND} -E copy_directory
342342
${LIVEKIT_ROOT_DIR}/include
343343
${CMAKE_BINARY_DIR}/include
344-
COMMAND ${CMAKE_COMMAND} -E copy
345-
${GENERATED_INCLUDE_DIR}/build.h
346-
${CMAKE_BINARY_DIR}/include/livekit/build.h
347344
COMMENT "Copying public headers to build/include"
348345
)
349346

@@ -591,17 +588,12 @@ if(APPLE)
591588
endif()
592589

593590

594-
# Install public headers
591+
# Install public headers (includes generated build.h which is now in include/livekit/)
595592
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/"
596593
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
597594
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
598595
)
599596

600-
# Install generated build.h if it is part of the public headers
601-
install(FILES "${GENERATED_INCLUDE_DIR}/build.h"
602-
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/livekit"
603-
)
604-
605597
# ---- Create Config + Version + Targets for find_package(LiveKit CONFIG) ----
606598

607599
# cmake/LiveKitConfig.cmake.in must exist in your repo
@@ -642,6 +634,10 @@ if(LIVEKIT_BUILD_EXAMPLES)
642634
add_subdirectory(examples)
643635
endif()
644636

637+
if(LIVEKIT_BUILD_TESTS)
638+
add_subdirectory(src/tests)
639+
endif()
640+
645641
add_custom_target(clean_generated
646642
COMMAND ${CMAKE_COMMAND} -E rm -rf "${PROTO_BINARY_DIR}"
647643
COMMENT "Clean generated protobuf files"

CMakePresets.json

Lines changed: 172 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@
6666
"inherits": "windows-base",
6767
"binaryDir": "${sourceDir}/build-release",
6868
"cacheVariables": {
69-
"CMAKE_BUILD_TYPE": "Release"
69+
"CMAKE_BUILD_TYPE": "Release",
70+
"LIVEKIT_BUILD_EXAMPLES": "OFF",
71+
"LIVEKIT_BUILD_TESTS": "OFF"
7072
}
7173
},
7274
{
@@ -76,7 +78,9 @@
7678
"inherits": "windows-base",
7779
"binaryDir": "${sourceDir}/build-debug",
7880
"cacheVariables": {
79-
"CMAKE_BUILD_TYPE": "Debug"
81+
"CMAKE_BUILD_TYPE": "Debug",
82+
"LIVEKIT_BUILD_EXAMPLES": "OFF",
83+
"LIVEKIT_BUILD_TESTS": "OFF"
8084
}
8185
},
8286
{
@@ -88,6 +92,7 @@
8892
"cacheVariables": {
8993
"CMAKE_BUILD_TYPE": "Release",
9094
"LIVEKIT_BUILD_EXAMPLES": "ON",
95+
"LIVEKIT_BUILD_TESTS": "OFF",
9196
"VCPKG_MANIFEST_FEATURES": "examples"
9297
}
9398
},
@@ -100,6 +105,7 @@
100105
"cacheVariables": {
101106
"CMAKE_BUILD_TYPE": "Debug",
102107
"LIVEKIT_BUILD_EXAMPLES": "ON",
108+
"LIVEKIT_BUILD_TESTS": "OFF",
103109
"VCPKG_MANIFEST_FEATURES": "examples"
104110
}
105111
},
@@ -110,7 +116,9 @@
110116
"inherits": "linux-base",
111117
"binaryDir": "${sourceDir}/build-release",
112118
"cacheVariables": {
113-
"CMAKE_BUILD_TYPE": "Release"
119+
"CMAKE_BUILD_TYPE": "Release",
120+
"LIVEKIT_BUILD_EXAMPLES": "OFF",
121+
"LIVEKIT_BUILD_TESTS": "OFF"
114122
}
115123
},
116124
{
@@ -120,7 +128,9 @@
120128
"inherits": "linux-base",
121129
"binaryDir": "${sourceDir}/build-debug",
122130
"cacheVariables": {
123-
"CMAKE_BUILD_TYPE": "Debug"
131+
"CMAKE_BUILD_TYPE": "Debug",
132+
"LIVEKIT_BUILD_EXAMPLES": "OFF",
133+
"LIVEKIT_BUILD_TESTS": "OFF"
124134
}
125135
},
126136
{
@@ -131,7 +141,8 @@
131141
"binaryDir": "${sourceDir}/build-release",
132142
"cacheVariables": {
133143
"CMAKE_BUILD_TYPE": "Release",
134-
"LIVEKIT_BUILD_EXAMPLES": "ON"
144+
"LIVEKIT_BUILD_EXAMPLES": "ON",
145+
"LIVEKIT_BUILD_TESTS": "OFF"
135146
}
136147
},
137148
{
@@ -142,7 +153,8 @@
142153
"binaryDir": "${sourceDir}/build-debug",
143154
"cacheVariables": {
144155
"CMAKE_BUILD_TYPE": "Debug",
145-
"LIVEKIT_BUILD_EXAMPLES": "ON"
156+
"LIVEKIT_BUILD_EXAMPLES": "ON",
157+
"LIVEKIT_BUILD_TESTS": "OFF"
146158
}
147159
},
148160
{
@@ -152,7 +164,9 @@
152164
"inherits": "macos-base",
153165
"binaryDir": "${sourceDir}/build-release",
154166
"cacheVariables": {
155-
"CMAKE_BUILD_TYPE": "Release"
167+
"CMAKE_BUILD_TYPE": "Release",
168+
"LIVEKIT_BUILD_EXAMPLES": "OFF",
169+
"LIVEKIT_BUILD_TESTS": "OFF"
156170
}
157171
},
158172
{
@@ -162,7 +176,9 @@
162176
"inherits": "macos-base",
163177
"binaryDir": "${sourceDir}/build-debug",
164178
"cacheVariables": {
165-
"CMAKE_BUILD_TYPE": "Debug"
179+
"CMAKE_BUILD_TYPE": "Debug",
180+
"LIVEKIT_BUILD_EXAMPLES": "OFF",
181+
"LIVEKIT_BUILD_TESTS": "OFF"
166182
}
167183
},
168184
{
@@ -173,7 +189,8 @@
173189
"binaryDir": "${sourceDir}/build-release",
174190
"cacheVariables": {
175191
"CMAKE_BUILD_TYPE": "Release",
176-
"LIVEKIT_BUILD_EXAMPLES": "ON"
192+
"LIVEKIT_BUILD_EXAMPLES": "ON",
193+
"LIVEKIT_BUILD_TESTS": "OFF"
177194
}
178195
},
179196
{
@@ -184,7 +201,80 @@
184201
"binaryDir": "${sourceDir}/build-debug",
185202
"cacheVariables": {
186203
"CMAKE_BUILD_TYPE": "Debug",
187-
"LIVEKIT_BUILD_EXAMPLES": "ON"
204+
"LIVEKIT_BUILD_EXAMPLES": "ON",
205+
"LIVEKIT_BUILD_TESTS": "OFF"
206+
}
207+
},
208+
{
209+
"name": "windows-release-tests",
210+
"displayName": "Windows x64 Release with Tests",
211+
"description": "Build for Windows x64 Release with test suite",
212+
"inherits": "windows-base",
213+
"binaryDir": "${sourceDir}/build-release",
214+
"cacheVariables": {
215+
"CMAKE_BUILD_TYPE": "Release",
216+
"LIVEKIT_BUILD_EXAMPLES": "OFF",
217+
"LIVEKIT_BUILD_TESTS": "ON"
218+
}
219+
},
220+
{
221+
"name": "windows-debug-tests",
222+
"displayName": "Windows x64 Debug with Tests",
223+
"description": "Build for Windows x64 Debug with test suite",
224+
"inherits": "windows-base",
225+
"binaryDir": "${sourceDir}/build-debug",
226+
"cacheVariables": {
227+
"CMAKE_BUILD_TYPE": "Debug",
228+
"LIVEKIT_BUILD_EXAMPLES": "OFF",
229+
"LIVEKIT_BUILD_TESTS": "ON"
230+
}
231+
},
232+
{
233+
"name": "linux-release-tests",
234+
"displayName": "Linux Release with Tests",
235+
"description": "Build for Linux Release with test suite",
236+
"inherits": "linux-base",
237+
"binaryDir": "${sourceDir}/build-release",
238+
"cacheVariables": {
239+
"CMAKE_BUILD_TYPE": "Release",
240+
"LIVEKIT_BUILD_EXAMPLES": "OFF",
241+
"LIVEKIT_BUILD_TESTS": "ON"
242+
}
243+
},
244+
{
245+
"name": "linux-debug-tests",
246+
"displayName": "Linux Debug with Tests",
247+
"description": "Build for Linux Debug with test suite",
248+
"inherits": "linux-base",
249+
"binaryDir": "${sourceDir}/build-debug",
250+
"cacheVariables": {
251+
"CMAKE_BUILD_TYPE": "Debug",
252+
"LIVEKIT_BUILD_EXAMPLES": "OFF",
253+
"LIVEKIT_BUILD_TESTS": "ON"
254+
}
255+
},
256+
{
257+
"name": "macos-release-tests",
258+
"displayName": "macOS Release with Tests",
259+
"description": "Build for macOS Release with test suite",
260+
"inherits": "macos-base",
261+
"binaryDir": "${sourceDir}/build-release",
262+
"cacheVariables": {
263+
"CMAKE_BUILD_TYPE": "Release",
264+
"LIVEKIT_BUILD_EXAMPLES": "OFF",
265+
"LIVEKIT_BUILD_TESTS": "ON"
266+
}
267+
},
268+
{
269+
"name": "macos-debug-tests",
270+
"displayName": "macOS Debug with Tests",
271+
"description": "Build for macOS Debug with test suite",
272+
"inherits": "macos-base",
273+
"binaryDir": "${sourceDir}/build-debug",
274+
"cacheVariables": {
275+
"CMAKE_BUILD_TYPE": "Debug",
276+
"LIVEKIT_BUILD_EXAMPLES": "OFF",
277+
"LIVEKIT_BUILD_TESTS": "ON"
188278
}
189279
}
190280
],
@@ -240,6 +330,78 @@
240330
{
241331
"name": "macos-debug-examples",
242332
"configurePreset": "macos-debug-examples"
333+
},
334+
{
335+
"name": "windows-release-tests",
336+
"configurePreset": "windows-release-tests",
337+
"configuration": "Release"
338+
},
339+
{
340+
"name": "windows-debug-tests",
341+
"configurePreset": "windows-debug-tests",
342+
"configuration": "Debug"
343+
},
344+
{
345+
"name": "linux-release-tests",
346+
"configurePreset": "linux-release-tests"
347+
},
348+
{
349+
"name": "linux-debug-tests",
350+
"configurePreset": "linux-debug-tests"
351+
},
352+
{
353+
"name": "macos-release-tests",
354+
"configurePreset": "macos-release-tests"
355+
},
356+
{
357+
"name": "macos-debug-tests",
358+
"configurePreset": "macos-debug-tests"
359+
}
360+
],
361+
"testPresets": [
362+
{
363+
"name": "windows-release-tests",
364+
"configurePreset": "windows-release-tests",
365+
"configuration": "Release",
366+
"output": {
367+
"outputOnFailure": true
368+
}
369+
},
370+
{
371+
"name": "windows-debug-tests",
372+
"configurePreset": "windows-debug-tests",
373+
"configuration": "Debug",
374+
"output": {
375+
"outputOnFailure": true
376+
}
377+
},
378+
{
379+
"name": "linux-release-tests",
380+
"configurePreset": "linux-release-tests",
381+
"output": {
382+
"outputOnFailure": true
383+
}
384+
},
385+
{
386+
"name": "linux-debug-tests",
387+
"configurePreset": "linux-debug-tests",
388+
"output": {
389+
"outputOnFailure": true
390+
}
391+
},
392+
{
393+
"name": "macos-release-tests",
394+
"configurePreset": "macos-release-tests",
395+
"output": {
396+
"outputOnFailure": true
397+
}
398+
},
399+
{
400+
"name": "macos-debug-tests",
401+
"configurePreset": "macos-debug-tests",
402+
"output": {
403+
"outputOnFailure": true
404+
}
243405
}
244406
]
245407
}

0 commit comments

Comments
 (0)