diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5b802cd..dc00a2f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,10 +14,18 @@ target_link_libraries(test_ipc_c_api fifo_ipc ) -add_executable(test_ipc_python - test_ipc_python.cpp +add_executable(test_ipc_python_cpp + test_ipc_python_cpp.cpp ) -target_link_libraries(test_ipc_python +target_link_libraries(test_ipc_python_cpp + fifo_ipc +) + +add_executable(test_ipc_python_c + test_ipc_python_c.c +) + +target_link_libraries(test_ipc_python_c fifo_ipc ) diff --git a/test/test_ipc_python_c.c b/test/test_ipc_python_c.c new file mode 100644 index 0000000..710fb9e --- /dev/null +++ b/test/test_ipc_python_c.c @@ -0,0 +1,44 @@ +#include +#include // FIXME on *nix + +#include "ipc/c_api.h" + +#define UNUSED(x) (void)x; + +int +main(int argc, char** argv) +{ + UNUSED(argc); + UNUSED(argv); + + const int verbose = 0; + ipc_init_default(); + + ipc_start_external_default("python test_server.py", 1); + + printf("[client] pre-start\n"); + void* ipc = ipc_create_default(0, verbose); + printf("[client] start\n"); + + double answer; + const char* hline = "\n------------------------\n"; + for (int i = 2; i <= 5; ++i) { + Sleep(500); // FIXME on *nix + puts(hline); + + { + ipc_write_int(ipc, &i, 1); + printf("[client] write int(%d)\n", i); + } + + { + ipc_read_double(ipc, &answer, 1); + printf("[client] read double(%.2e)\n", answer); + } + } + + puts(hline); + printf("[client] finish the work\n\n"); + + return 0; +} diff --git a/test/test_ipc_python.cpp b/test/test_ipc_python_cpp.cpp similarity index 100% rename from test/test_ipc_python.cpp rename to test/test_ipc_python_cpp.cpp