mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
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.
This commit is contained in:
parent
a15baf7976
commit
33e92afd91
1 changed files with 19 additions and 1 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue