Roger Meier | c101092 | 2010-11-26 10:17:48 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 20 | #include <netdb.h> |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 21 | #include <signal.h> |
Jens Geyer | 1c19027 | 2015-07-28 23:15:18 +0200 | [diff] [blame] | 22 | #include <sys/wait.h> |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 23 | |
Roger Meier | e3da768 | 2013-01-11 11:41:53 +0100 | [diff] [blame] | 24 | #include <thrift/c_glib/transport/thrift_transport.h> |
| 25 | #include <thrift/c_glib/transport/thrift_socket.h> |
| 26 | #include <thrift/c_glib/transport/thrift_server_transport.h> |
| 27 | #include <thrift/c_glib/transport/thrift_server_socket.h> |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 28 | |
| 29 | #define TEST_DATA { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' } |
| 30 | |
Roger Meier | e3da768 | 2013-01-11 11:41:53 +0100 | [diff] [blame] | 31 | #include "../src/thrift/c_glib/transport/thrift_buffered_transport.c" |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 32 | |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 33 | static void thrift_server (const int port); |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 34 | static void thrift_socket_server_open (const int port, int times); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 35 | |
| 36 | /* test object creation and destruction */ |
| 37 | static void |
| 38 | test_create_and_destroy(void) |
| 39 | { |
| 40 | ThriftTransport *transport = NULL; |
| 41 | guint r_buf_size = 0; |
| 42 | guint w_buf_size = 0; |
| 43 | |
| 44 | GObject *object = NULL; |
| 45 | object = g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT, NULL); |
James E. King, III | 43f4bf2 | 2017-10-28 12:54:02 -0400 | [diff] [blame] | 46 | g_assert (object != NULL); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 47 | g_object_get (G_OBJECT (object), "transport", &transport, |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 48 | "r_buf_size", &r_buf_size, |
| 49 | "w_buf_size", &w_buf_size, NULL); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 50 | g_object_unref (object); |
| 51 | } |
| 52 | |
| 53 | static void |
| 54 | test_open_and_close(void) |
| 55 | { |
| 56 | ThriftSocket *tsocket = NULL; |
| 57 | ThriftTransport *transport = NULL; |
| 58 | GError *err = NULL; |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 59 | pid_t pid; |
| 60 | int port = 51199; |
| 61 | int status; |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 62 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 63 | pid = fork (); |
| 64 | g_assert ( pid >= 0 ); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 65 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 66 | if ( pid == 0 ) |
| 67 | { |
| 68 | /* child listens */ |
| 69 | thrift_socket_server_open (port,1); |
| 70 | exit (0); |
| 71 | } else { |
| 72 | /* parent connects, wait a bit for the socket to be created */ |
| 73 | sleep (1); |
| 74 | /* create a ThriftSocket */ |
| 75 | tsocket = g_object_new (THRIFT_TYPE_SOCKET, "hostname", "localhost", |
| 76 | "port", port, NULL); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 77 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 78 | /* create a BufferedTransport wrapper of the Socket */ |
| 79 | transport = g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT, |
| 80 | "transport", THRIFT_TRANSPORT (tsocket), NULL); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 81 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 82 | /* this shouldn't work */ |
| 83 | g_assert (thrift_buffered_transport_open (transport, NULL) == TRUE); |
| 84 | g_assert (thrift_buffered_transport_is_open (transport) == TRUE); |
| 85 | g_assert (thrift_buffered_transport_close (transport, NULL) == TRUE); |
| 86 | g_object_unref (transport); |
| 87 | g_object_unref (tsocket); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 88 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 89 | /* try and underlying socket failure */ |
| 90 | tsocket = g_object_new (THRIFT_TYPE_SOCKET, "hostname", "localhost.broken", |
| 91 | NULL); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 92 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 93 | /* create a BufferedTransport wrapper of the Socket */ |
| 94 | transport = g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT, |
| 95 | "transport", THRIFT_TRANSPORT (tsocket), NULL); |
| 96 | |
| 97 | g_assert (thrift_buffered_transport_open (transport, &err) == FALSE); |
| 98 | g_object_unref (transport); |
| 99 | g_object_unref (tsocket); |
| 100 | g_error_free (err); |
| 101 | err = NULL; |
| 102 | g_assert ( wait (&status) == pid ); |
| 103 | g_assert ( status == 0 ); |
| 104 | } |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | static void |
| 108 | test_read_and_write(void) |
| 109 | { |
| 110 | int status; |
| 111 | pid_t pid; |
| 112 | ThriftSocket *tsocket = NULL; |
| 113 | ThriftTransport *transport = NULL; |
| 114 | int port = 51199; |
| 115 | guchar buf[10] = TEST_DATA; /* a buffer */ |
| 116 | |
| 117 | pid = fork (); |
James E. King, III | 43f4bf2 | 2017-10-28 12:54:02 -0400 | [diff] [blame] | 118 | g_assert ( pid >= 0 ); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 119 | |
| 120 | if ( pid == 0 ) |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 121 | { |
| 122 | /* child listens */ |
| 123 | thrift_server (port); |
| 124 | exit (0); |
| 125 | } else { |
| 126 | /* parent connects, wait a bit for the socket to be created */ |
| 127 | sleep (1); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 128 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 129 | tsocket = g_object_new (THRIFT_TYPE_SOCKET, "hostname", "localhost", |
| 130 | "port", port, NULL); |
| 131 | transport = g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT, |
| 132 | "transport", THRIFT_TRANSPORT (tsocket), |
| 133 | "w_buf_size", 4, NULL); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 134 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 135 | g_assert (thrift_buffered_transport_open (transport, NULL) == TRUE); |
| 136 | g_assert (thrift_buffered_transport_is_open (transport)); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 137 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 138 | /* write 10 bytes */ |
| 139 | thrift_buffered_transport_write (transport, buf, 10, NULL); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 140 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 141 | /* write 1 byte at a time */ |
| 142 | thrift_buffered_transport_write (transport, buf, 1, NULL); |
| 143 | thrift_buffered_transport_write (transport, buf, 1, NULL); |
| 144 | thrift_buffered_transport_write (transport, buf, 1, NULL); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 145 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 146 | /* overflow the buffer */ |
| 147 | thrift_buffered_transport_write (transport, buf, 2, NULL); |
| 148 | thrift_buffered_transport_write (transport, buf, 1, NULL); |
| 149 | thrift_buffered_transport_flush (transport, NULL); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 150 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 151 | /* write 1 byte and flush */ |
| 152 | thrift_buffered_transport_write (transport, buf, 1, NULL); |
| 153 | thrift_buffered_transport_flush (transport, NULL); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 154 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 155 | /* write and overflow buffer with 2 system calls */ |
| 156 | thrift_buffered_transport_write (transport, buf, 1, NULL); |
| 157 | thrift_buffered_transport_write (transport, buf, 3, NULL); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 158 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 159 | /* write 10 bytes */ |
| 160 | thrift_buffered_transport_write (transport, buf, 10, NULL); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 161 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 162 | thrift_buffered_transport_write_end (transport, NULL); |
| 163 | thrift_buffered_transport_flush (transport, NULL); |
| 164 | thrift_buffered_transport_close (transport, NULL); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 165 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 166 | g_object_unref (transport); |
| 167 | g_object_unref (tsocket); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 168 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 169 | g_assert ( wait (&status) == pid ); |
| 170 | g_assert ( status == 0 ); |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | |
| 175 | static void |
| 176 | thrift_socket_server_open (const int port, int times) |
| 177 | { |
| 178 | int bytes = 0; |
| 179 | ThriftServerTransport *transport = NULL; |
| 180 | ThriftTransport *client = NULL; |
| 181 | guchar buf[10]; /* a buffer */ |
| 182 | guchar match[10] = TEST_DATA; |
| 183 | int i; |
| 184 | ThriftServerSocket *tsocket = g_object_new (THRIFT_TYPE_SERVER_SOCKET, |
| 185 | "port", port, NULL); |
| 186 | |
| 187 | transport = THRIFT_SERVER_TRANSPORT (tsocket); |
| 188 | thrift_server_transport_listen (transport, NULL); |
| 189 | for(i=0;i<times;i++){ |
| 190 | client = thrift_server_transport_accept (transport, NULL); |
| 191 | g_assert (client != NULL); |
| 192 | thrift_socket_close (client, NULL); |
| 193 | g_object_unref (client); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 194 | } |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 195 | g_object_unref (tsocket); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | static void |
| 199 | thrift_server (const int port) |
| 200 | { |
| 201 | int bytes = 0; |
| 202 | ThriftServerTransport *transport = NULL; |
| 203 | ThriftTransport *client = NULL; |
| 204 | guchar buf[10]; /* a buffer */ |
| 205 | guchar match[10] = TEST_DATA; |
| 206 | |
| 207 | ThriftServerSocket *tsocket = g_object_new (THRIFT_TYPE_SERVER_SOCKET, |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 208 | "port", port, NULL); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 209 | |
| 210 | transport = THRIFT_SERVER_TRANSPORT (tsocket); |
| 211 | thrift_server_transport_listen (transport, NULL); |
| 212 | |
| 213 | /* wrap the client in a BufferedTransport */ |
| 214 | client = g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT, "transport", |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 215 | thrift_server_transport_accept (transport, NULL), |
| 216 | "r_buf_size", 5, NULL); |
James E. King, III | 43f4bf2 | 2017-10-28 12:54:02 -0400 | [diff] [blame] | 217 | g_assert (client != NULL); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 218 | |
| 219 | /* read 10 bytes */ |
| 220 | bytes = thrift_buffered_transport_read (client, buf, 10, NULL); |
James E. King, III | 43f4bf2 | 2017-10-28 12:54:02 -0400 | [diff] [blame] | 221 | g_assert (bytes == 10); /* make sure we've read 10 bytes */ |
| 222 | g_assert ( memcmp (buf, match, 10) == 0 ); /* make sure what we got matches */ |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 223 | |
| 224 | /* read 1 byte */ |
| 225 | bytes = thrift_buffered_transport_read (client, buf, 1, NULL); |
| 226 | |
| 227 | bytes = thrift_buffered_transport_read (client, buf, 6, NULL); |
| 228 | bytes = thrift_buffered_transport_read (client, buf, 2, NULL); |
| 229 | bytes = thrift_buffered_transport_read (client, buf, 1, NULL); |
| 230 | |
| 231 | thrift_buffered_transport_read_end (client, NULL); |
| 232 | thrift_buffered_transport_close (client, NULL); |
| 233 | g_object_unref (client); |
| 234 | g_object_unref (tsocket); |
| 235 | } |
| 236 | |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 237 | static void |
| 238 | test_write_fail(void) |
| 239 | { |
| 240 | int status; |
| 241 | pid_t pid; |
| 242 | ThriftSocket *tsocket = NULL; |
| 243 | ThriftTransport *transport = NULL; |
| 244 | int port = 51198; |
| 245 | guchar buf[10] = TEST_DATA; /* a buffer */ |
| 246 | |
| 247 | /* SIGPIPE when send to disconnected socket */ |
| 248 | signal(SIGPIPE, SIG_IGN); |
| 249 | |
| 250 | pid = fork (); |
James E. King, III | 43f4bf2 | 2017-10-28 12:54:02 -0400 | [diff] [blame] | 251 | g_assert ( pid >= 0 ); |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 252 | |
| 253 | if ( pid == 0 ) |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 254 | { |
| 255 | /* child listens */ |
| 256 | ThriftServerTransport *transport = NULL; |
| 257 | ThriftTransport *client = NULL; |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 258 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 259 | ThriftServerSocket *tsocket = g_object_new (THRIFT_TYPE_SERVER_SOCKET, |
| 260 | "port", port, NULL); |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 261 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 262 | transport = THRIFT_SERVER_TRANSPORT (tsocket); |
| 263 | thrift_server_transport_listen (transport, NULL); |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 264 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 265 | /* wrap the client in a BufferedTransport */ |
| 266 | client = g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT, "transport", |
| 267 | thrift_server_transport_accept (transport, NULL), |
| 268 | "r_buf_size", 5, NULL); |
| 269 | g_assert (client != NULL); |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 270 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 271 | /* just close socket */ |
| 272 | thrift_buffered_transport_close (client, NULL); |
| 273 | g_object_unref (client); |
| 274 | g_object_unref (tsocket); |
| 275 | exit (0); |
| 276 | } else { |
| 277 | /* parent connects, wait a bit for the socket to be created */ |
| 278 | sleep (1); |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 279 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 280 | tsocket = g_object_new (THRIFT_TYPE_SOCKET, "hostname", "localhost", |
| 281 | "port", port, NULL); |
| 282 | transport = g_object_new (THRIFT_TYPE_BUFFERED_TRANSPORT, |
| 283 | "transport", THRIFT_TRANSPORT (tsocket), |
| 284 | "w_buf_size", 4, NULL); |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 285 | |
| 286 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 287 | g_assert (thrift_buffered_transport_open (transport, NULL) == TRUE); |
| 288 | g_assert (thrift_buffered_transport_is_open (transport)); |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 289 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 290 | /* recognize disconnection */ |
| 291 | sleep(1); |
| 292 | g_assert (thrift_buffered_transport_write (transport, buf, 10, NULL) == TRUE); |
| 293 | g_assert (thrift_buffered_transport_write (transport, buf, 10, NULL) == FALSE); |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 294 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 295 | /* write and overflow buffer */ |
| 296 | g_assert (thrift_buffered_transport_write (transport, buf, 10, NULL) == FALSE); |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 297 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 298 | /* write 1 and flush */ |
| 299 | g_assert (thrift_buffered_transport_write (transport, buf, 1, NULL) == TRUE); |
| 300 | g_assert (thrift_buffered_transport_flush (transport, NULL) == FALSE); |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 301 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 302 | thrift_buffered_transport_close (transport, NULL); |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 303 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 304 | g_object_unref (transport); |
| 305 | g_object_unref (tsocket); |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 306 | |
Gonzalo Aguilar Delgado | 87ad2bc | 2017-09-15 12:26:02 +0200 | [diff] [blame] | 307 | g_assert ( wait (&status) == pid ); |
| 308 | g_assert ( status == 0 ); |
| 309 | } |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 310 | } |
| 311 | |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 312 | int |
Roger Meier | c101092 | 2010-11-26 10:17:48 +0000 | [diff] [blame] | 313 | main(int argc, char *argv[]) |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 314 | { |
Jens Geyer | 1c19027 | 2015-07-28 23:15:18 +0200 | [diff] [blame] | 315 | #if (!GLIB_CHECK_VERSION (2, 36, 0)) |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 316 | g_type_init(); |
Jens Geyer | 1c19027 | 2015-07-28 23:15:18 +0200 | [diff] [blame] | 317 | #endif |
| 318 | |
Roger Meier | c101092 | 2010-11-26 10:17:48 +0000 | [diff] [blame] | 319 | g_test_init (&argc, &argv, NULL); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 320 | |
Roger Meier | c101092 | 2010-11-26 10:17:48 +0000 | [diff] [blame] | 321 | g_test_add_func ("/testbufferedtransport/CreateAndDestroy", test_create_and_destroy); |
| 322 | g_test_add_func ("/testbufferedtransport/OpenAndClose", test_open_and_close); |
| 323 | g_test_add_func ("/testbufferedtransport/ReadAndWrite", test_read_and_write); |
Roger Meier | 5c80b56 | 2014-05-04 22:19:46 +0200 | [diff] [blame] | 324 | g_test_add_func ("/testbufferedtransport/WriteFail", test_write_fail); |
Roger Meier | c101092 | 2010-11-26 10:17:48 +0000 | [diff] [blame] | 325 | |
| 326 | return g_test_run (); |
Roger Meier | 213a664 | 2010-10-27 12:30:11 +0000 | [diff] [blame] | 327 | } |
| 328 | |