summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Hervey <edward@centricular.com>2018-10-27 15:48:13 +0200
committerEdward Hervey <bilboed@bilboed.com>2018-10-27 15:48:13 +0200
commit33e92afd91274e8b63aceccded344a266d401248 (patch)
tree33f29ea7439a8b9c3448437d20fb215681430f7b
parenta15baf797603c6c65e442f488f20993d800bbbc1 (diff)
downloadgst-plugins-base-33e92afd91274e8b63aceccded344a266d401248.tar.gz
gst-plugins-base-33e92afd91274e8b63aceccded344a266d401248.tar.xz
tests: Solidify tcp connection check
The previous failure was a timeout which was due to the sending pipeline pushing test buffer *before* the remote client was accepted. We would therefore never get the buffer on the other side. While the client socket would indeed appear as "connected", this doesn't mean that the remote server side did "accept" it (which is where we then add it to the list of remote parties to which data will be sent). The problem isn't with the element implementation, but to the nature of TCP 3-way handshake. In order to make the test reliable, wait for the sink to have accepted the remote client (by checking the number of handles) before sending out test buffers.
-rw-r--r--tests/check/pipelines/tcp.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/check/pipelines/tcp.c b/tests/check/pipelines/tcp.c
index 8701484d5..1226a5fb1 100644
--- a/tests/check/pipelines/tcp.c
+++ b/tests/check/pipelines/tcp.c
@@ -205,10 +205,28 @@ GST_END_TEST;
GST_START_TEST (test_that_tcpserversink_and_tcpclientsrc_are_symmetrical)
{
SymmetryTest st = { 0 };
+ GstElement *serversink = gst_check_setup_element ("tcpserversink");
+ guint timeout = 100;
- symmetry_test_setup (&st, gst_check_setup_element ("tcpserversink"),
+ symmetry_test_setup (&st, serversink,
gst_check_setup_element ("tcpclientsrc"));
+ /* Wait for the client to *actually* be connected before doing the
+ * test. The socket connection from the client might very well
+ * succeed, but that doesn't mean the server has accepted it yet. If
+ * we don't wait for the server to have accepted the connection, we
+ * would end up dropping the buffer (because no one is "connected")
+ * and the receiving side would wait forever. */
+ while (timeout) {
+ guint handles;
+ g_object_get (serversink, "num-handles", &handles, NULL);
+ if (handles > 0)
+ break;
+ /* Wait for 10ms to see if client connected */
+ g_usleep (G_USEC_PER_SEC / 100);
+ timeout--;
+ }
+
symmetry_test_assert_passthrough (&st,
gst_buffer_new_wrapped (g_strdup ("hello"), 5));
symmetry_test_teardown (&st);