add c-api test
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
44
test/test_ipc_python_c.c
Normal file
44
test/test_ipc_python_c.c
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <stdio.h>
|
||||
#include <windows.h> // 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;
|
||||
}
|
||||
Reference in New Issue
Block a user