summaryrefslogtreecommitdiff
path: root/test/c_glib
diff options
context:
space:
mode:
authorKevin Wojniak <kainjow@users.noreply.github.com>2019-07-01 17:11:56 -0700
committerJames E. King III <jking@apache.org>2019-07-01 20:11:56 -0400
commit6c847d2d028c155534aee006a77a5dca783233c4 (patch)
tree9424c354f3adb676876430e52b25d600f435efb3 /test/c_glib
parent35cda2fa85ae9c94fc1296e2abcaa2ef733b7352 (diff)
downloadthrift-6c847d2d028c155534aee006a77a5dca783233c4.tar.gz
THRIFT-4878 - [c_glib] add unix domain socket support to ThriftSocket (#1807)
Diffstat (limited to 'test/c_glib')
-rw-r--r--test/c_glib/src/test_client.c43
-rw-r--r--test/c_glib/src/test_server.c33
2 files changed, 57 insertions, 19 deletions
diff --git a/test/c_glib/src/test_client.c b/test/c_glib/src/test_client.c
index ef24ab76c..7126a86d8 100644
--- a/test/c_glib/src/test_client.c
+++ b/test/c_glib/src/test_client.c
@@ -113,6 +113,7 @@ main (int argc, char **argv)
{
static gchar * host = NULL;
static gint port = 9090;
+ static gchar * path = NULL;
static gboolean ssl = FALSE;
static gchar * transport_option = NULL;
static gchar * protocol_option = NULL;
@@ -124,6 +125,8 @@ main (int argc, char **argv)
"Host to connect (=localhost)", NULL },
{ "port", 'p', 0, G_OPTION_ARG_INT, &port,
"Port number to connect (=9090)", NULL },
+ { "domain-socket", 0, 0, G_OPTION_ARG_STRING, &path,
+ "Unix socket domain path to connect", NULL },
{ "ssl", 's', 0, G_OPTION_ARG_NONE, &ssl,
"Enable SSL", NULL },
{ "transport", 't', 0, G_OPTION_ARG_STRING, &transport_option,
@@ -227,12 +230,20 @@ main (int argc, char **argv)
if (!options_valid)
return 254;
- printf ("Connecting (%s/%s) to: %s/%s:%d\n",
- transport_name,
- protocol_name,
- socket_name,
- host,
- port);
+ if (path) {
+ printf ("Connecting (%s/%s) to: %s/%s\n",
+ transport_name,
+ protocol_name,
+ socket_name,
+ path);
+ } else {
+ printf ("Connecting (%s/%s) to: %s/%s:%d\n",
+ transport_name,
+ protocol_name,
+ socket_name,
+ host,
+ port);
+ }
/* Install our SIGPIPE handler, which outputs an error message to
standard error before exiting so testers can know what
@@ -247,10 +258,16 @@ main (int argc, char **argv)
}
/* Establish all our connection objects */
- socket = g_object_new (socket_type,
- "hostname", host,
- "port", port,
- NULL);
+ if (path) {
+ socket = g_object_new (socket_type,
+ "path", path,
+ NULL);
+ } else {
+ socket = g_object_new (socket_type,
+ "hostname", host,
+ "port", port,
+ NULL);
+ }
if (ssl && !thrift_ssl_load_cert_from_file(THRIFT_SSL_SOCKET(socket), "../keys/CA.pem")) {
fprintf(stderr, "Unable to load validation certificate ../keys/CA.pem - did you run in the test/c_glib directory?\n");
@@ -336,7 +353,11 @@ main (int argc, char **argv)
gboolean first;
gint32 i, j;
- printf ("Test #%d, connect %s:%d\n", test_num + 1, host, port);
+ if (path) {
+ printf ("Test #%d, connect %s\n", test_num + 1, path);
+ } else {
+ printf ("Test #%d, connect %s:%d\n", test_num + 1, host, port);
+ }
gettimeofday (&time_start, NULL);
/* These test routines have been ported from the C++ test
diff --git a/test/c_glib/src/test_server.c b/test/c_glib/src/test_server.c
index 2d716ec2e..0819b8ca5 100644
--- a/test/c_glib/src/test_server.c
+++ b/test/c_glib/src/test_server.c
@@ -69,6 +69,7 @@ int
main (int argc, char **argv)
{
static gint port = 9090;
+ static gchar *path_option = NULL;
static gchar *server_type_option = NULL;
static gchar *transport_option = NULL;
static gchar *protocol_option = NULL;
@@ -79,6 +80,8 @@ main (int argc, char **argv)
GOptionEntry option_entries[] = {
{ "port", 0, 0, G_OPTION_ARG_INT, &port,
"Port number to connect (=9090)", NULL },
+ { "domain-socket", 0, 0, G_OPTION_ARG_STRING, &path_option,
+ "Unix socket domain path to connect", NULL },
{ "server-type", 0, 0, G_OPTION_ARG_STRING, &server_type_option,
"Type of server: simple (=simple)", NULL },
{ "transport", 0, 0, G_OPTION_ARG_STRING, &transport_option,
@@ -218,9 +221,15 @@ main (int argc, char **argv)
"handler", handler,
NULL);
}
- server_transport = g_object_new (THRIFT_TYPE_SERVER_SOCKET,
- "port", port,
- NULL);
+ if (path_option) {
+ server_transport = g_object_new (THRIFT_TYPE_SERVER_SOCKET,
+ "path", path_option,
+ NULL);
+ } else {
+ server_transport = g_object_new (THRIFT_TYPE_SERVER_SOCKET,
+ "port", port,
+ NULL);
+ }
transport_factory = g_object_new (transport_factory_type,
NULL);
@@ -250,11 +259,19 @@ main (int argc, char **argv)
sigint_action.sa_flags = SA_RESETHAND;
sigaction (SIGINT, &sigint_action, NULL);
- printf ("Starting \"%s\" server (%s/%s) listen on: %d\n",
- server_name,
- transport_name,
- protocol_name,
- port);
+ if (path_option) {
+ printf ("Starting \"%s\" server (%s/%s) listen on: %s\n",
+ server_name,
+ transport_name,
+ protocol_name,
+ path_option);
+ } else {
+ printf ("Starting \"%s\" server (%s/%s) listen on: %d\n",
+ server_name,
+ transport_name,
+ protocol_name,
+ port);
+ }
fflush (stdout);
/* Serve clients until SIGINT is received (Ctrl-C is pressed) */