soft_uart: demonstrate a problem with inefficient polling

As outlined in the test case, we pull a total of 50 bits from the
transmitter in two rounds, pulling 25 bits at a time.  In the default
8-N-1 configuration, 50 bits should ideally comprise 5 characters.
However, as observed, only a total of 4 characters are retrieved
from the application, leaving the remaining 10 bits (5 + 5) unused.

Change-Id: Ic2539681a4adf6c1822e0bc256e4c829813d0e21
diff --git a/tests/soft_uart/soft_uart_test.c b/tests/soft_uart/soft_uart_test.c
index 0ea7fa8..7280bdc 100644
--- a/tests/soft_uart/soft_uart_test.c
+++ b/tests/soft_uart/soft_uart_test.c
@@ -604,6 +604,37 @@
 	osmo_soft_uart_free(suart);
 }
 
+static void test_tx_pull(void)
+{
+	struct osmo_soft_uart *suart;
+	ubit_t tx_buf[25 * 2];
+	int rc;
+
+	SUART_TEST_BEGIN;
+
+	g_tx_cb_cfg.data = (void *)"\x42\x42\x42\x42\x42";
+	g_tx_cb_cfg.data_len = 5;
+
+	suart = osmo_soft_uart_alloc(NULL, __func__, &suart_test_default_cfg);
+	OSMO_ASSERT(suart != NULL);
+
+	osmo_soft_uart_set_tx(suart, true);
+
+	printf("pulling 25 bits (first time) out of the transmitter\n");
+	rc = osmo_soft_uart_tx_ubits(suart, &tx_buf[0], sizeof(tx_buf) / 2);
+	OSMO_ASSERT(rc == 25);
+
+	printf("pulling 25 bits (second time) out of the transmitter\n");
+	rc = osmo_soft_uart_tx_ubits(suart, &tx_buf[25], sizeof(tx_buf) / 2);
+	OSMO_ASSERT(rc == 25);
+
+	/* FIXME: we pull total 25 + 25 == 50 bits out of the transmitter, which is enough
+	 * to fit 5 characters (assuming 8-N-1).  However, the current impelementation would
+	 * pull only 2 + 2 == characters total, wasting 5 + 5 == 10 bits for padding. */
+
+	osmo_soft_uart_free(suart);
+}
+
 int main(int argc, char **argv)
 {
 	test_rx();
@@ -616,6 +647,8 @@
 	test_tx_rx_pull_n(4);
 	test_tx_rx_pull_n(8);
 
+	test_tx_pull();
+
 	/* test flow control */
 	test_modem_status();
 	test_flow_control_dtr_dsr();