-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
921 lines (774 loc) · 35.9 KB
/
CMakeLists.txt
File metadata and controls
921 lines (774 loc) · 35.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
cmake_minimum_required(VERSION 3.20)
project(plugin_ipc LANGUAGES C)
# Default to RelWithDebInfo for single-config generators
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel)
endif()
include(CTest)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
find_package(Threads REQUIRED)
# Coverage build option: adds -fprofile-arcs -ftest-coverage to all C targets
option(NETIPC_COVERAGE "Enable code coverage instrumentation (gcov)" OFF)
if(NETIPC_COVERAGE)
add_compile_options(-fprofile-arcs -ftest-coverage -O0 -g)
add_link_options(-fprofile-arcs -ftest-coverage)
endif()
# Detect Windows runtime (native or MSYS/Cygwin)
set(NETIPC_WINDOWS_RUNTIME OFF)
if(WIN32 OR CYGWIN OR CMAKE_SYSTEM_NAME STREQUAL "MSYS")
set(NETIPC_WINDOWS_RUNTIME ON)
endif()
# --- C library: protocol (Codec + L1 wire envelope) ----------------------
add_library(netipc_protocol STATIC
src/libnetdata/netipc/src/protocol/netipc_protocol.c
)
target_include_directories(netipc_protocol PUBLIC
src/libnetdata/netipc/include
)
# --- C library: L1 POSIX UDS transport ------------------------------------
if(NOT NETIPC_WINDOWS_RUNTIME)
add_library(netipc_uds STATIC
src/libnetdata/netipc/src/transport/posix/netipc_uds.c
)
target_include_directories(netipc_uds PUBLIC
src/libnetdata/netipc/include
)
target_link_libraries(netipc_uds PUBLIC netipc_protocol)
# --- C library: L1 POSIX SHM transport (Linux only) ----------------------
if(NOT APPLE)
add_library(netipc_shm STATIC
src/libnetdata/netipc/src/transport/posix/netipc_shm.c
)
target_include_directories(netipc_shm PUBLIC
src/libnetdata/netipc/include
)
target_link_libraries(netipc_shm PUBLIC netipc_protocol)
# --- C library: L2 service orchestration (Linux only, needs SHM+UDS) ----
add_library(netipc_service STATIC
src/libnetdata/netipc/src/service/netipc_service.c
)
target_include_directories(netipc_service PUBLIC
src/libnetdata/netipc/include
)
target_link_libraries(netipc_service PUBLIC
netipc_protocol netipc_uds netipc_shm Threads::Threads
)
endif()
endif()
# --- C library: L1 Windows Named Pipe transport ----------------------------
if(NETIPC_WINDOWS_RUNTIME)
add_library(netipc_named_pipe STATIC
src/libnetdata/netipc/src/transport/windows/netipc_named_pipe.c
)
target_include_directories(netipc_named_pipe PUBLIC
src/libnetdata/netipc/include
)
target_link_libraries(netipc_named_pipe PUBLIC netipc_protocol)
# --- C library: L1 Windows SHM transport --------------------------------
add_library(netipc_win_shm STATIC
src/libnetdata/netipc/src/transport/windows/netipc_win_shm.c
)
target_include_directories(netipc_win_shm PUBLIC
src/libnetdata/netipc/include
)
target_link_libraries(netipc_win_shm PUBLIC netipc_protocol netipc_named_pipe)
# --- C library: L2/L3 Windows service orchestration ----------------------
add_library(netipc_service_win STATIC
src/libnetdata/netipc/src/service/netipc_service_win.c
)
target_include_directories(netipc_service_win PUBLIC
src/libnetdata/netipc/include
)
target_link_libraries(netipc_service_win PUBLIC
netipc_protocol netipc_named_pipe netipc_win_shm
)
endif()
# --- Rust crate -----------------------------------------------------------
find_program(CARGO_EXECUTABLE cargo)
if(CARGO_EXECUTABLE)
set(NETIPC_RUST_CRATE_DIR "${CMAKE_SOURCE_DIR}/src/crates/netipc")
add_custom_target(netipc_rust ALL
COMMAND ${CARGO_EXECUTABLE} build
WORKING_DIRECTORY "${NETIPC_RUST_CRATE_DIR}"
COMMENT "Building Rust netipc crate"
)
endif()
# --- Go package -----------------------------------------------------------
find_program(GO_EXECUTABLE go)
if(GO_EXECUTABLE)
set(NETIPC_GO_PKG_DIR "${CMAKE_SOURCE_DIR}/src/go")
set(NETIPC_GO_FIXTURE_DIR "${CMAKE_SOURCE_DIR}/tests/fixtures/go")
add_custom_target(netipc_go_test
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} test ./pkg/netipc/protocol/
WORKING_DIRECTORY "${NETIPC_GO_PKG_DIR}"
COMMENT "Running Go netipc protocol tests"
)
add_custom_target(interop_codec_go ALL
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} build -o "${CMAKE_BINARY_DIR}/bin/interop_codec_go" ./cmd/interop_codec
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/fixtures/go"
COMMENT "Building Go interop codec binary"
)
endif()
# --- Tests ----------------------------------------------------------------
enable_testing()
add_executable(test_protocol tests/test_protocol.c)
target_link_libraries(test_protocol PRIVATE netipc_protocol)
add_test(NAME test_protocol COMMAND test_protocol)
add_executable(interop_codec_c tests/fixtures/c/interop_codec.c)
target_link_libraries(interop_codec_c PRIVATE netipc_protocol)
if(CARGO_EXECUTABLE)
add_test(NAME test_protocol_rust
COMMAND ${CARGO_EXECUTABLE} test
WORKING_DIRECTORY "${NETIPC_RUST_CRATE_DIR}"
)
endif()
if(GO_EXECUTABLE)
add_test(NAME test_protocol_go
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} test ./pkg/netipc/protocol/
WORKING_DIRECTORY "${NETIPC_GO_PKG_DIR}"
)
endif()
if(CARGO_EXECUTABLE AND GO_EXECUTABLE)
add_test(NAME interop_codec
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/interop_codec.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
elseif(CARGO_EXECUTABLE)
add_test(NAME interop_codec
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/interop_codec.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
endif()
# --- Fuzz harness (standalone mode for CI) --------------------------------
add_executable(fuzz_protocol tests/fuzz_protocol.c)
target_compile_definitions(fuzz_protocol PRIVATE FUZZ_STANDALONE)
target_link_libraries(fuzz_protocol PRIVATE netipc_protocol)
# CTest fuzz targets: short 30-second runs with random input via /dev/urandom.
# Each test generates random data and feeds it to the standalone harness.
add_test(NAME fuzz_protocol_30s
COMMAND bash -c "head -c 65536 /dev/urandom | $<TARGET_FILE:fuzz_protocol>"
)
set_tests_properties(fuzz_protocol_30s PROPERTIES TIMEOUT 60)
if(GO_EXECUTABLE)
# Go fuzz targets: 30-second runs each.
foreach(FUZZ_TARGET
FuzzDecodeHeader
FuzzDecodeChunkHeader
FuzzDecodeHello
FuzzDecodeHelloAck
FuzzDecodeCgroupsRequest
FuzzDecodeCgroupsResponse
FuzzBatchDirDecode
FuzzBatchItemGet
)
add_test(NAME go_${FUZZ_TARGET}
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} test -fuzz=^${FUZZ_TARGET}$ -fuzztime=30s
./pkg/netipc/protocol/
WORKING_DIRECTORY "${NETIPC_GO_PKG_DIR}"
)
set_tests_properties(go_${FUZZ_TARGET} PROPERTIES
TIMEOUT 120
RESOURCE_LOCK go_fuzz_tests
)
endforeach()
endif()
# --- L1 UDS transport tests -----------------------------------------------
if(NOT NETIPC_WINDOWS_RUNTIME)
add_executable(test_uds tests/fixtures/c/test_uds.c)
target_link_libraries(test_uds PRIVATE netipc_uds netipc_protocol Threads::Threads)
add_test(NAME test_uds COMMAND test_uds)
set_tests_properties(test_uds PROPERTIES TIMEOUT 30)
# C interop binary for cross-language UDS tests
add_executable(interop_uds_c tests/fixtures/c/interop_uds.c)
target_link_libraries(interop_uds_c PRIVATE netipc_uds netipc_protocol)
endif()
# --- L1 SHM transport tests (Linux only) -----------------------------------
if(NOT NETIPC_WINDOWS_RUNTIME AND NOT APPLE)
add_executable(test_shm tests/fixtures/c/test_shm.c)
target_link_libraries(test_shm PRIVATE netipc_shm netipc_uds netipc_protocol Threads::Threads)
add_test(NAME test_shm COMMAND test_shm)
set_tests_properties(test_shm PROPERTIES TIMEOUT 30)
# C SHM interop binary
add_executable(interop_shm_c tests/fixtures/c/interop_shm.c)
target_link_libraries(interop_shm_c PRIVATE netipc_shm netipc_protocol)
endif()
# --- L2 service orchestration tests (Linux only) ---------------------------
if(NOT NETIPC_WINDOWS_RUNTIME AND NOT APPLE)
add_executable(test_service tests/fixtures/c/test_service.c)
target_link_libraries(test_service PRIVATE
netipc_service netipc_shm netipc_uds netipc_protocol Threads::Threads
)
target_compile_definitions(test_service PRIVATE NIPC_INTERNAL_TESTING=1)
add_test(NAME test_service COMMAND test_service)
set_tests_properties(test_service PROPERTIES TIMEOUT 60)
# Multi-client multi-worker server tests
add_executable(test_multi_server tests/fixtures/c/test_multi_server.c)
target_link_libraries(test_multi_server PRIVATE
netipc_service netipc_shm netipc_uds netipc_protocol Threads::Threads
)
target_compile_definitions(test_multi_server PRIVATE NIPC_INTERNAL_TESTING=1)
add_test(NAME test_multi_server COMMAND test_multi_server)
set_tests_properties(test_multi_server PROPERTIES TIMEOUT 120)
# C L2 interop binary
add_executable(interop_service_c tests/fixtures/c/interop_service.c)
target_link_libraries(interop_service_c PRIVATE
netipc_service netipc_shm netipc_uds netipc_protocol Threads::Threads
)
target_compile_definitions(interop_service_c PRIVATE NIPC_INTERNAL_TESTING=1)
# Stress tests (Phase H4: large-scale and stress testing)
add_executable(test_stress tests/fixtures/c/test_stress.c)
target_link_libraries(test_stress PRIVATE
netipc_service netipc_shm netipc_uds netipc_protocol Threads::Threads
)
target_compile_definitions(test_stress PRIVATE NIPC_INTERNAL_TESTING=1)
add_test(NAME test_stress COMMAND test_stress)
set_tests_properties(test_stress PROPERTIES TIMEOUT 180)
# Ping-pong tests: INCREMENT + STRING_REVERSE L2 typed calls
add_executable(test_ping_pong tests/fixtures/c/test_ping_pong.c)
target_link_libraries(test_ping_pong PRIVATE
netipc_service netipc_shm netipc_uds netipc_protocol Threads::Threads
)
target_compile_definitions(test_ping_pong PRIVATE NIPC_INTERNAL_TESTING=1)
add_test(NAME test_ping_pong COMMAND test_ping_pong)
set_tests_properties(test_ping_pong PROPERTIES TIMEOUT 30)
# Chaos tests (Phase H9: transport-level and SHM chaos testing)
add_executable(test_chaos tests/fixtures/c/test_chaos.c)
target_link_libraries(test_chaos PRIVATE
netipc_service netipc_shm netipc_uds netipc_protocol Threads::Threads
)
target_compile_definitions(test_chaos PRIVATE NIPC_INTERNAL_TESTING=1)
add_test(NAME test_chaos COMMAND test_chaos)
set_tests_properties(test_chaos PROPERTIES TIMEOUT 120)
# Hardening tests (Phase 3: security-critical edge cases)
add_executable(test_hardening tests/fixtures/c/test_hardening.c)
target_link_libraries(test_hardening PRIVATE
netipc_service netipc_shm netipc_uds netipc_protocol Threads::Threads
)
target_compile_definitions(test_hardening PRIVATE NIPC_INTERNAL_TESTING=1)
add_test(NAME test_hardening COMMAND test_hardening)
set_tests_properties(test_hardening PROPERTIES TIMEOUT 120)
endif()
# --- Rust UDS transport tests ---------------------------------------------
if(CARGO_EXECUTABLE)
add_test(NAME test_uds_rust
COMMAND ${CARGO_EXECUTABLE} test transport -- --test-threads=1
WORKING_DIRECTORY "${NETIPC_RUST_CRATE_DIR}"
)
set_tests_properties(test_uds_rust PROPERTIES TIMEOUT 30)
# Build the Rust interop binary
add_custom_target(interop_uds_rs ALL
COMMAND ${CARGO_EXECUTABLE} build --bin interop_uds
WORKING_DIRECTORY "${NETIPC_RUST_CRATE_DIR}"
COMMENT "Building Rust UDS interop binary"
)
# Rust SHM transport tests (Linux only)
if(NOT NETIPC_WINDOWS_RUNTIME AND NOT APPLE)
add_test(NAME test_shm_rust
COMMAND ${CARGO_EXECUTABLE} test shm -- --test-threads=1
WORKING_DIRECTORY "${NETIPC_RUST_CRATE_DIR}"
)
set_tests_properties(test_shm_rust PROPERTIES TIMEOUT 30)
# Build the Rust SHM interop binary
add_custom_target(interop_shm_rs ALL
COMMAND ${CARGO_EXECUTABLE} build --bin interop_shm
WORKING_DIRECTORY "${NETIPC_RUST_CRATE_DIR}"
COMMENT "Building Rust SHM interop binary"
)
# Rust L2 service tests
add_test(NAME test_service_rust
COMMAND ${CARGO_EXECUTABLE} test service -- --test-threads=1
WORKING_DIRECTORY "${NETIPC_RUST_CRATE_DIR}"
)
set_tests_properties(test_service_rust PROPERTIES TIMEOUT 120)
# Build the Rust L2 interop binary
add_custom_target(interop_service_rs ALL
COMMAND ${CARGO_EXECUTABLE} build --bin interop_service
WORKING_DIRECTORY "${NETIPC_RUST_CRATE_DIR}"
COMMENT "Building Rust L2 service interop binary"
)
endif()
endif()
# --- Go UDS transport tests ------------------------------------------------
if(GO_EXECUTABLE AND NOT NETIPC_WINDOWS_RUNTIME)
add_test(NAME test_uds_go
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} test -count=1 -timeout=60s ./pkg/netipc/transport/posix/
WORKING_DIRECTORY "${NETIPC_GO_PKG_DIR}"
)
set_tests_properties(test_uds_go PROPERTIES
TIMEOUT 60
RESOURCE_LOCK go_posix_transport_tests
)
# Build Go UDS interop binary
add_custom_target(interop_uds_go ALL
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} build -o "${CMAKE_BINARY_DIR}/bin/interop_uds_go" ./cmd/interop_uds
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/fixtures/go"
COMMENT "Building Go UDS interop binary"
)
# Go SHM transport tests (Linux only)
if(NOT APPLE)
add_test(NAME test_shm_go
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} test -count=1 -timeout=60s
-run TestShm ./pkg/netipc/transport/posix/
WORKING_DIRECTORY "${NETIPC_GO_PKG_DIR}"
)
set_tests_properties(test_shm_go PROPERTIES
TIMEOUT 60
RESOURCE_LOCK go_posix_transport_tests
)
# Build Go SHM interop binary
add_custom_target(interop_shm_go ALL
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} build -o "${CMAKE_BINARY_DIR}/bin/interop_shm_go" ./cmd/interop_shm
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/fixtures/go"
COMMENT "Building Go SHM interop binary"
)
endif()
# Go L2 service tests
add_test(NAME test_service_go
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} test -count=1 -timeout=120s
./pkg/netipc/service/cgroups/
WORKING_DIRECTORY "${NETIPC_GO_PKG_DIR}"
)
set_tests_properties(test_service_go PROPERTIES TIMEOUT 180)
# Build Go L2 interop binary
add_custom_target(interop_service_go ALL
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} build -o "${CMAKE_BINARY_DIR}/bin/interop_service_go" ./cmd/interop_service
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/fixtures/go"
COMMENT "Building Go L2 service interop binary"
)
endif()
# --- Cross-language UDS interop tests -------------------------------------
if(NOT NETIPC_WINDOWS_RUNTIME AND CARGO_EXECUTABLE)
set(INTEROP_UDS_RS "${NETIPC_RUST_CRATE_DIR}/target/debug/interop_uds")
set(INTEROP_UDS_GO "${CMAKE_BINARY_DIR}/bin/interop_uds_go")
add_test(NAME test_uds_interop
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/test_uds_interop.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
set_tests_properties(test_uds_interop PROPERTIES
TIMEOUT 60
ENVIRONMENT "INTEROP_UDS_C=$<TARGET_FILE:interop_uds_c>;INTEROP_UDS_RS=${INTEROP_UDS_RS};INTEROP_UDS_GO=${INTEROP_UDS_GO}"
)
endif()
# --- Cross-language SHM interop tests (Linux only) -------------------------
if(NOT NETIPC_WINDOWS_RUNTIME AND NOT APPLE AND CARGO_EXECUTABLE)
set(INTEROP_SHM_RS "${NETIPC_RUST_CRATE_DIR}/target/debug/interop_shm")
set(INTEROP_SHM_GO "${CMAKE_BINARY_DIR}/bin/interop_shm_go")
add_test(NAME test_shm_interop
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/test_shm_interop.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
set_tests_properties(test_shm_interop PROPERTIES
TIMEOUT 60
ENVIRONMENT "INTEROP_SHM_C=$<TARGET_FILE:interop_shm_c>;INTEROP_SHM_RS=${INTEROP_SHM_RS};INTEROP_SHM_GO=${INTEROP_SHM_GO}"
)
endif()
# --- Cross-language L2 service interop tests (Linux only) ------------------
if(NOT NETIPC_WINDOWS_RUNTIME AND NOT APPLE AND CARGO_EXECUTABLE)
set(INTEROP_SVC_RS "${NETIPC_RUST_CRATE_DIR}/target/debug/interop_service")
set(INTEROP_SVC_GO "${CMAKE_BINARY_DIR}/bin/interop_service_go")
add_test(NAME test_service_interop
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/test_service_interop.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
set_tests_properties(test_service_interop PROPERTIES
TIMEOUT 120
ENVIRONMENT "INTEROP_SVC_C=$<TARGET_FILE:interop_service_c>;INTEROP_SVC_RS=${INTEROP_SVC_RS};INTEROP_SVC_GO=${INTEROP_SVC_GO}"
)
endif()
# --- L3 cache tests (Linux only) -------------------------------------------
if(NOT NETIPC_WINDOWS_RUNTIME AND NOT APPLE)
add_executable(test_cache tests/fixtures/c/test_cache.c)
target_link_libraries(test_cache PRIVATE
netipc_service netipc_shm netipc_uds netipc_protocol Threads::Threads
)
target_compile_definitions(test_cache PRIVATE NIPC_INTERNAL_TESTING=1)
add_test(NAME test_cache COMMAND test_cache)
set_tests_properties(test_cache PROPERTIES TIMEOUT 120)
# C L3 interop binary
add_executable(interop_cache_c tests/fixtures/c/interop_cache.c)
target_link_libraries(interop_cache_c PRIVATE
netipc_service netipc_shm netipc_uds netipc_protocol Threads::Threads
)
target_compile_definitions(interop_cache_c PRIVATE NIPC_INTERNAL_TESTING=1)
endif()
# --- Rust L3 cache tests ---------------------------------------------------
if(CARGO_EXECUTABLE AND NOT NETIPC_WINDOWS_RUNTIME AND NOT APPLE)
# Build the Rust L3 interop binary
add_custom_target(interop_cache_rs ALL
COMMAND ${CARGO_EXECUTABLE} build --bin interop_cache
WORKING_DIRECTORY "${NETIPC_RUST_CRATE_DIR}"
COMMENT "Building Rust L3 cache interop binary"
)
endif()
# --- Go L3 cache tests -----------------------------------------------------
if(GO_EXECUTABLE AND NOT NETIPC_WINDOWS_RUNTIME)
# Go L3 cache tests (in same package as L2)
add_test(NAME test_cache_go
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} test -count=1 -timeout=120s
-run TestCache ./pkg/netipc/service/cgroups/
WORKING_DIRECTORY "${NETIPC_GO_PKG_DIR}"
)
set_tests_properties(test_cache_go PROPERTIES TIMEOUT 180)
# Build Go L3 interop binary
add_custom_target(interop_cache_go ALL
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} build -o "${CMAKE_BINARY_DIR}/bin/interop_cache_go" ./cmd/interop_cache
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/fixtures/go"
COMMENT "Building Go L3 cache interop binary"
)
endif()
# --- Go stress tests (Phase H4) ---------------------------------------------
if(GO_EXECUTABLE AND NOT NETIPC_WINDOWS_RUNTIME)
add_test(NAME test_stress_go
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} test -count=1 -timeout=180s
-run TestStress ./pkg/netipc/service/cgroups/
WORKING_DIRECTORY "${NETIPC_GO_PKG_DIR}"
)
set_tests_properties(test_stress_go PROPERTIES TIMEOUT 240)
endif()
# --- Rust stress tests (Phase H4) -------------------------------------------
if(CARGO_EXECUTABLE AND NOT NETIPC_WINDOWS_RUNTIME AND NOT APPLE)
add_test(NAME test_stress_rust
COMMAND ${CARGO_EXECUTABLE} test test_stress -- --test-threads=1
WORKING_DIRECTORY "${NETIPC_RUST_CRATE_DIR}"
)
set_tests_properties(test_stress_rust PROPERTIES TIMEOUT 240)
endif()
# --- Cross-language L2 service SHM interop tests (Linux only) ---------------
if(NOT NETIPC_WINDOWS_RUNTIME AND NOT APPLE AND CARGO_EXECUTABLE)
add_test(NAME test_service_shm_interop
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/test_service_shm_interop.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
set_tests_properties(test_service_shm_interop PROPERTIES
TIMEOUT 120
ENVIRONMENT "INTEROP_SVC_C=$<TARGET_FILE:interop_service_c>;INTEROP_SVC_RS=${INTEROP_SVC_RS};INTEROP_SVC_GO=${INTEROP_SVC_GO}"
)
endif()
# --- Cross-language L3 cache interop tests (Linux only) ---------------------
if(NOT NETIPC_WINDOWS_RUNTIME AND NOT APPLE AND CARGO_EXECUTABLE)
set(INTEROP_CACHE_RS "${NETIPC_RUST_CRATE_DIR}/target/debug/interop_cache")
set(INTEROP_CACHE_GO "${CMAKE_BINARY_DIR}/bin/interop_cache_go")
add_test(NAME test_cache_interop
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/test_cache_interop.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
set_tests_properties(test_cache_interop PROPERTIES
TIMEOUT 120
ENVIRONMENT "INTEROP_CACHE_C=$<TARGET_FILE:interop_cache_c>;INTEROP_CACHE_RS=${INTEROP_CACHE_RS};INTEROP_CACHE_GO=${INTEROP_CACHE_GO}"
)
# SHM variant
add_test(NAME test_cache_shm_interop
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/test_cache_shm_interop.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
set_tests_properties(test_cache_shm_interop PROPERTIES
TIMEOUT 120
ENVIRONMENT "INTEROP_CACHE_C=$<TARGET_FILE:interop_cache_c>;INTEROP_CACHE_RS=${INTEROP_CACHE_RS};INTEROP_CACHE_GO=${INTEROP_CACHE_GO}"
)
endif()
# --- L1 Windows Named Pipe transport tests ---------------------------------
if(NETIPC_WINDOWS_RUNTIME)
add_executable(test_named_pipe tests/fixtures/c/test_named_pipe.c)
target_link_libraries(test_named_pipe PRIVATE netipc_named_pipe netipc_protocol)
add_test(NAME test_named_pipe COMMAND test_named_pipe)
set_tests_properties(test_named_pipe PROPERTIES TIMEOUT 30)
# C Named Pipe interop binary
add_executable(interop_named_pipe_c tests/fixtures/c/interop_named_pipe.c)
target_link_libraries(interop_named_pipe_c PRIVATE netipc_named_pipe netipc_protocol)
endif()
# --- Rust Named Pipe transport (Windows) -----------------------------------
if(CARGO_EXECUTABLE AND NETIPC_WINDOWS_RUNTIME)
add_custom_target(interop_named_pipe_rs ALL
COMMAND ${CARGO_EXECUTABLE} build --bin interop_named_pipe
WORKING_DIRECTORY "${NETIPC_RUST_CRATE_DIR}"
COMMENT "Building Rust Named Pipe interop binary"
)
endif()
# --- Go Named Pipe transport (Windows) ------------------------------------
if(GO_EXECUTABLE AND NETIPC_WINDOWS_RUNTIME)
add_test(NAME test_named_pipe_go
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} test -count=1 -timeout=60s
./pkg/netipc/transport/windows/
WORKING_DIRECTORY "${NETIPC_GO_PKG_DIR}"
)
set_tests_properties(test_named_pipe_go PROPERTIES TIMEOUT 60)
# Build Go Named Pipe interop binary
add_custom_target(interop_named_pipe_go ALL
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} build -o "${CMAKE_BINARY_DIR}/bin/interop_named_pipe_go.exe"
./cmd/interop_named_pipe
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/fixtures/go"
COMMENT "Building Go Named Pipe interop binary"
)
endif()
# --- Cross-language Named Pipe interop tests (Windows) ---------------------
if(NETIPC_WINDOWS_RUNTIME AND CARGO_EXECUTABLE)
set(INTEROP_NP_RS "${NETIPC_RUST_CRATE_DIR}/target/debug/interop_named_pipe.exe")
set(INTEROP_NP_GO "${CMAKE_BINARY_DIR}/bin/interop_named_pipe_go.exe")
add_test(NAME test_named_pipe_interop
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/test_named_pipe_interop.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
set_tests_properties(test_named_pipe_interop PROPERTIES
TIMEOUT 60
ENVIRONMENT "INTEROP_NP_C=$<TARGET_FILE:interop_named_pipe_c>;INTEROP_NP_RS=${INTEROP_NP_RS};INTEROP_NP_GO=${INTEROP_NP_GO}"
)
endif()
# --- L1 Windows SHM transport tests ----------------------------------------
if(NETIPC_WINDOWS_RUNTIME)
add_executable(test_win_shm tests/fixtures/c/test_win_shm.c)
target_link_libraries(test_win_shm PRIVATE netipc_win_shm netipc_named_pipe netipc_protocol)
add_test(NAME test_win_shm COMMAND test_win_shm)
set_tests_properties(test_win_shm PROPERTIES TIMEOUT 30)
add_executable(test_win_service tests/fixtures/c/test_win_service.c)
target_link_libraries(test_win_service PRIVATE
netipc_service_win netipc_win_shm netipc_named_pipe netipc_protocol
)
add_test(NAME test_win_service COMMAND test_win_service)
set_tests_properties(test_win_service PROPERTIES
TIMEOUT 120
RUN_SERIAL TRUE
)
add_executable(test_win_service_extra tests/fixtures/c/test_win_service_extra.c)
target_link_libraries(test_win_service_extra PRIVATE
netipc_service_win netipc_win_shm netipc_named_pipe netipc_protocol
)
add_test(NAME test_win_service_extra COMMAND test_win_service_extra)
set_tests_properties(test_win_service_extra PROPERTIES
TIMEOUT 120
RUN_SERIAL TRUE
)
add_executable(test_win_stress tests/fixtures/c/test_win_stress.c)
target_link_libraries(test_win_stress PRIVATE
netipc_service_win netipc_win_shm netipc_named_pipe netipc_protocol
)
add_test(NAME test_win_stress COMMAND test_win_stress)
set_tests_properties(test_win_stress PROPERTIES TIMEOUT 120)
# C Windows SHM interop binary
add_executable(interop_win_shm_c tests/fixtures/c/interop_win_shm.c)
target_link_libraries(interop_win_shm_c PRIVATE netipc_win_shm netipc_named_pipe netipc_protocol)
endif()
# --- Rust Windows SHM transport (Windows) -----------------------------------
if(CARGO_EXECUTABLE AND NETIPC_WINDOWS_RUNTIME)
add_custom_target(interop_win_shm_rs ALL
COMMAND ${CARGO_EXECUTABLE} build --bin interop_win_shm
WORKING_DIRECTORY "${NETIPC_RUST_CRATE_DIR}"
COMMENT "Building Rust Windows SHM interop binary"
)
endif()
# --- Go Windows SHM transport (Windows) ------------------------------------
if(GO_EXECUTABLE AND NETIPC_WINDOWS_RUNTIME)
# Build Go Windows SHM interop binary
add_custom_target(interop_win_shm_go ALL
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} build -o "${CMAKE_BINARY_DIR}/bin/interop_win_shm_go.exe"
./cmd/interop_win_shm
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/fixtures/go"
COMMENT "Building Go Windows SHM interop binary"
)
endif()
# --- Cross-language Windows SHM interop tests (Windows) ---------------------
if(NETIPC_WINDOWS_RUNTIME AND CARGO_EXECUTABLE)
set(INTEROP_WIN_SHM_RS "${NETIPC_RUST_CRATE_DIR}/target/debug/interop_win_shm.exe")
set(INTEROP_WIN_SHM_GO "${CMAKE_BINARY_DIR}/bin/interop_win_shm_go.exe")
add_test(NAME test_win_shm_interop
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/test_win_shm_interop.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
set_tests_properties(test_win_shm_interop PROPERTIES
TIMEOUT 60
ENVIRONMENT "INTEROP_WIN_SHM_C=$<TARGET_FILE:interop_win_shm_c>;INTEROP_WIN_SHM_RS=${INTEROP_WIN_SHM_RS};INTEROP_WIN_SHM_GO=${INTEROP_WIN_SHM_GO}"
)
endif()
# --- Windows L2 service interop binaries -----------------------------------
if(NETIPC_WINDOWS_RUNTIME)
# C Windows L2 interop binary
add_executable(interop_service_win_c tests/fixtures/c/interop_service_win.c)
target_link_libraries(interop_service_win_c PRIVATE
netipc_service_win netipc_win_shm netipc_named_pipe netipc_protocol
)
target_compile_definitions(interop_service_win_c PRIVATE NIPC_INTERNAL_TESTING=1)
# C Windows L3 cache interop binary
add_executable(interop_cache_win_c tests/fixtures/c/interop_cache_win.c)
target_link_libraries(interop_cache_win_c PRIVATE
netipc_service_win netipc_win_shm netipc_named_pipe netipc_protocol
)
target_compile_definitions(interop_cache_win_c PRIVATE NIPC_INTERNAL_TESTING=1)
endif()
# --- Rust Windows L2/L3 interop binaries ------------------------------------
if(CARGO_EXECUTABLE AND NETIPC_WINDOWS_RUNTIME)
add_custom_target(interop_service_win_rs ALL
COMMAND ${CARGO_EXECUTABLE} build --bin interop_service_win
WORKING_DIRECTORY "${NETIPC_RUST_CRATE_DIR}"
COMMENT "Building Rust Windows L2 service interop binary"
)
add_custom_target(interop_cache_win_rs ALL
COMMAND ${CARGO_EXECUTABLE} build --bin interop_cache_win
WORKING_DIRECTORY "${NETIPC_RUST_CRATE_DIR}"
COMMENT "Building Rust Windows L3 cache interop binary"
)
endif()
# --- Go Windows L2/L3 interop binaries -------------------------------------
if(GO_EXECUTABLE AND NETIPC_WINDOWS_RUNTIME)
add_custom_target(interop_service_win_go ALL
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} build -o "${CMAKE_BINARY_DIR}/bin/interop_service_win_go.exe"
./cmd/interop_service_win
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/fixtures/go"
COMMENT "Building Go Windows L2 service interop binary"
)
add_custom_target(interop_cache_win_go ALL
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} build -o "${CMAKE_BINARY_DIR}/bin/interop_cache_win_go.exe"
./cmd/interop_cache_win
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/fixtures/go"
COMMENT "Building Go Windows L3 cache interop binary"
)
endif()
# --- Cross-language Windows L2 service interop tests ------------------------
if(NETIPC_WINDOWS_RUNTIME AND CARGO_EXECUTABLE)
set(INTEROP_SVC_WIN_RS "${NETIPC_RUST_CRATE_DIR}/target/debug/interop_service_win.exe")
set(INTEROP_SVC_WIN_GO "${CMAKE_BINARY_DIR}/bin/interop_service_win_go.exe")
add_test(NAME test_service_win_interop
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/test_service_win_interop.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
set_tests_properties(test_service_win_interop PROPERTIES
TIMEOUT 120
RESOURCE_LOCK win_service_interop_tests
ENVIRONMENT "INTEROP_SVC_C=$<TARGET_FILE:interop_service_win_c>;INTEROP_SVC_RS=${INTEROP_SVC_WIN_RS};INTEROP_SVC_GO=${INTEROP_SVC_WIN_GO}"
)
# SHM variant
add_test(NAME test_service_win_shm_interop
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/test_service_win_shm_interop.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
set_tests_properties(test_service_win_shm_interop PROPERTIES
TIMEOUT 120
RESOURCE_LOCK win_service_interop_tests
ENVIRONMENT "INTEROP_SVC_C=$<TARGET_FILE:interop_service_win_c>;INTEROP_SVC_RS=${INTEROP_SVC_WIN_RS};INTEROP_SVC_GO=${INTEROP_SVC_WIN_GO}"
)
endif()
# --- Cross-language Windows L3 cache interop tests --------------------------
if(NETIPC_WINDOWS_RUNTIME AND CARGO_EXECUTABLE)
set(INTEROP_CACHE_WIN_RS "${NETIPC_RUST_CRATE_DIR}/target/debug/interop_cache_win.exe")
set(INTEROP_CACHE_WIN_GO "${CMAKE_BINARY_DIR}/bin/interop_cache_win_go.exe")
add_test(NAME test_cache_win_interop
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/test_cache_win_interop.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
set_tests_properties(test_cache_win_interop PROPERTIES
TIMEOUT 120
RESOURCE_LOCK win_cache_interop_tests
ENVIRONMENT "INTEROP_CACHE_C=$<TARGET_FILE:interop_cache_win_c>;INTEROP_CACHE_RS=${INTEROP_CACHE_WIN_RS};INTEROP_CACHE_GO=${INTEROP_CACHE_WIN_GO}"
)
# SHM variant
add_test(NAME test_cache_win_shm_interop
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/test_cache_win_shm_interop.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
set_tests_properties(test_cache_win_shm_interop PROPERTIES
TIMEOUT 120
RESOURCE_LOCK win_cache_interop_tests
ENVIRONMENT "INTEROP_CACHE_C=$<TARGET_FILE:interop_cache_win_c>;INTEROP_CACHE_RS=${INTEROP_CACHE_WIN_RS};INTEROP_CACHE_GO=${INTEROP_CACHE_WIN_GO}"
)
endif()
# --- Benchmarks (Phase 13) ------------------------------------------------
if(NOT NETIPC_WINDOWS_RUNTIME AND NOT APPLE)
# C benchmark binary
add_executable(bench_posix_c bench/drivers/c/bench_posix.c)
target_link_libraries(bench_posix_c PRIVATE
netipc_service netipc_shm netipc_uds netipc_protocol Threads::Threads m
)
target_compile_definitions(bench_posix_c PRIVATE NIPC_INTERNAL_TESTING=1)
target_compile_options(bench_posix_c PRIVATE -O2)
endif()
# Rust benchmark binary (release build for accurate performance)
if(CARGO_EXECUTABLE AND NOT NETIPC_WINDOWS_RUNTIME AND NOT APPLE)
add_custom_target(bench_posix_rs
COMMAND ${CARGO_EXECUTABLE} build --release --bin bench_posix
WORKING_DIRECTORY "${NETIPC_RUST_CRATE_DIR}"
COMMENT "Building Rust benchmark binary (release)"
)
endif()
# Go benchmark binary
if(GO_EXECUTABLE AND NOT NETIPC_WINDOWS_RUNTIME)
add_custom_target(bench_posix_go ALL
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} build -o "${CMAKE_BINARY_DIR}/bin/bench_posix_go" .
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bench/drivers/go"
COMMENT "Building Go benchmark binary"
)
endif()
# Benchmark runner (not CTest — too slow for CI)
if(NOT NETIPC_WINDOWS_RUNTIME AND NOT APPLE)
add_custom_target(run-posix-bench
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/run-posix-bench.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
COMMENT "Running full POSIX benchmark suite"
DEPENDS bench_posix_c
)
add_custom_target(generate-benchmarks-posix
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/generate-benchmarks-posix.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
COMMENT "Generating benchmarks-posix.md from CSV data"
)
endif()
# --- Windows Benchmarks ---------------------------------------------------
if(NETIPC_WINDOWS_RUNTIME)
# C Windows benchmark binary
add_executable(bench_windows_c bench/drivers/c/bench_windows.c)
target_link_libraries(bench_windows_c PRIVATE
netipc_service_win netipc_named_pipe netipc_win_shm netipc_protocol
)
target_compile_definitions(bench_windows_c PRIVATE NIPC_INTERNAL_TESTING=1)
target_compile_options(bench_windows_c PRIVATE -O2)
# Rust Windows benchmark binary (release build for accurate performance)
if(CARGO_EXECUTABLE)
add_custom_target(bench_windows_rs
COMMAND ${CARGO_EXECUTABLE} build --release --bin bench_windows
WORKING_DIRECTORY "${NETIPC_RUST_CRATE_DIR}"
COMMENT "Building Rust Windows benchmark binary (release)"
)
endif()
# Go Windows benchmark binary
if(GO_EXECUTABLE)
add_custom_target(bench_windows_go ALL
COMMAND ${CMAKE_COMMAND} -E env CGO_ENABLED=0
${GO_EXECUTABLE} build -o "${CMAKE_BINARY_DIR}/bin/bench_windows_go.exe" .
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bench/drivers/go"
COMMENT "Building Go Windows benchmark binary"
)
endif()
add_custom_target(run-windows-bench
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/run-windows-bench.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
COMMENT "Running full Windows benchmark suite"
DEPENDS bench_windows_c
)
add_custom_target(generate-benchmarks-windows
COMMAND bash "${CMAKE_SOURCE_DIR}/tests/generate-benchmarks-windows.sh"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
COMMENT "Generating benchmarks-windows.md from CSV data"
)
endif()