From dbbb5124074efe7565ad2f3ad36c8e3afc16a671 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 28 Jan 2015 22:44:16 +0100 Subject: [PATCH] add tcp test case --- cmake/test/CMakeLists.txt | 1 + test/test-tcp.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 test/test-tcp.c diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index 54a920f..7dfba08 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -64,6 +64,7 @@ add_helper_executable(test-spawn ${test-spawn_SOURCES} ${DBUS_INTERNAL_LIBRARIES add_helper_executable(test-exit ${test-exit_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) add_helper_executable(test-segfault ${test-segfault_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) add_helper_executable(test-sleep-forever ${test-sleep-forever_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) +add_test_executable(test-tcp ${CMAKE_SOURCE_DIR}/../test/test-tcp.c ${DBUS_INTERNAL_LIBRARIES}) if(DBUS_WITH_GLIB) message(STATUS "with glib test apps") diff --git a/test/test-tcp.c b/test/test-tcp.c new file mode 100644 index 0000000..cf396b7 --- /dev/null +++ b/test/test-tcp.c @@ -0,0 +1,25 @@ +#include "config.h" + +#include "dbus/dbus-server.h" + +/* This is a process that just exits with a failure code */ +int +main (int argc, char **argv) +{ + DBusServer *server; + DBusError error; + int i; + + for (i = 0; i < 1000; i++) + { + dbus_error_init (&error); + server = _dbus_server_new_for_tcp_socket ("localhost", "localhost", "0", "ipv4", &error, FALSE); + if (server == 0) + printf("%d: %s %s\n",i, error.name, error.message); + else + printf("%d: %s \n",i, dbus_server_get_address(server)); + + } + //dbus_server_disconnect(server); + //dbus_server_unref(server); +} -- 1.8.4.5