This is an automated email from the ASF dual-hosted git repository. cliffjansen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
The following commit(s) were added to refs/heads/master by this push: new 8c0e209 PROTON-1516: add tests for empty last frame in a streamed message 8c0e209 is described below commit 8c0e2099cc25c6fb9b53f25335898564a945f9f6 Author: Cliff Jansen <cliffjan...@apache.org> AuthorDate: Mon Dec 14 09:59:43 2020 -0800 PROTON-1516: add tests for empty last frame in a streamed message --- c/tests/connection_driver_test.cpp | 42 +++++++++++++++++++++++++++++++++++++ python/tests/proton_tests/engine.py | 30 ++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/c/tests/connection_driver_test.cpp b/c/tests/connection_driver_test.cpp index 8a86db5..ff04e81 100644 --- a/c/tests/connection_driver_test.cpp +++ b/c/tests/connection_driver_test.cpp @@ -575,3 +575,45 @@ TEST_CASE("driver_settle_incomplete_receiver") { cond_empty()); CHECK_THAT(*pn_connection_condition(d.server.connection), cond_empty()); } + +/* Empty last frame in streaming message. +*/ +TEST_CASE("driver_empty_last_frame") { + send_client_handler client; + delivery_handler server; + pn_test::driver_pair d(client, server); + + d.run(); + pn_link_t *rcv = server.link; + pn_link_t *snd = client.link; + char data[100] = {0}; /* Dummy data to send. */ + char rbuf[sizeof(data)] = {0}; /* Read buffer for incoming data. */ + pn_link_flow(rcv, 1); + pn_delivery_t *sd = pn_delivery(snd, pn_bytes("1")); /* Prepare to send */ + d.run(); + + /* Send/receive a frame */ + CHECK(sizeof(data) == pn_link_send(snd, data, sizeof(data))); + server.log_clear(); + d.run(); + CHECK_THAT(ETYPES(PN_DELIVERY), Equals(server.log_clear())); + CHECK(sizeof(data) == pn_link_recv(rcv, rbuf, sizeof(data))); + CHECK(pn_delivery_partial(pn_link_current(rcv))); + d.run(); + + /* Advance after all data transfered over wire. */ + CHECK(pn_link_advance(snd)); + server.log_clear(); + d.run(); + CHECK_THAT(ETYPES(PN_DELIVERY), Equals(server.log_clear())); + CHECK(PN_EOS == pn_link_recv(rcv, rbuf, sizeof(data))); + CHECK(!pn_delivery_partial(pn_link_current(rcv))); + + pn_delivery_settle(sd); + sd = NULL; + pn_delivery_settle(pn_link_current(rcv)); + d.run(); + CHECK_THAT(*pn_connection_remote_condition(d.client.connection), + cond_empty()); + CHECK_THAT(*pn_connection_condition(d.server.connection), cond_empty()); +} diff --git a/python/tests/proton_tests/engine.py b/python/tests/proton_tests/engine.py index 1b4c02b..70d10c8 100644 --- a/python/tests/proton_tests/engine.py +++ b/python/tests/proton_tests/engine.py @@ -935,6 +935,36 @@ class TransferTest(Test): self.pump() assert self.rcv.current.aborted + def test_multiframe_last_empty(self): + self.rcv.flow(1) + sd = self.snd.delivery("tag") + msg_p1 = b"this is a test" + n = self.snd.send(msg_p1) + assert n == len(msg_p1) + + self.pump() + + assert len(msg_p1) == self.rcv.current.pending + assert self.rcv.current.partial + msg_p2 = b"this is more." + n = self.snd.send(msg_p2) + assert n == len(msg_p2) + + self.pump() + + msg = msg_p1 + msg_p2 + assert len(msg) == self.rcv.current.pending + assert self.rcv.current.partial + # Advance. Should send empty xfer frame with more flag false. + assert self.snd.advance() + + self.pump() + + assert len(msg) == self.rcv.current.pending + assert not self.rcv.current.partial + binary = self.rcv.recv(self.rcv.current.pending) + assert binary == msg + def test_disposition(self): self.rcv.flow(1) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org