daniel has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/33496 )


Change subject: osmo_io: Make the test more deterministic between backends
......................................................................

osmo_io: Make the test more deterministic between backends

Change-Id: Ibdd26a4aeadfbd6c5039c8a31cc120d3c98be727
---
M tests/osmo_io/osmo_io_test.c
1 file changed, 22 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/96/33496/1

diff --git a/tests/osmo_io/osmo_io_test.c b/tests/osmo_io/osmo_io_test.c
index 3683ee3..74fe64d 100644
--- a/tests/osmo_io/osmo_io_test.c
+++ b/tests/osmo_io/osmo_io_test.c
@@ -38,6 +38,11 @@

 #define TEST_START() printf("Running %s\n", __func__)

+static uint8_t TESTDATA[] = {
+       1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
+};
+
+
 static void *ctx = NULL;

 static void read_cb(struct osmo_io_fd *iofd, int rc, struct msgb *msg)
@@ -51,7 +56,15 @@

 static void write_cb(struct osmo_io_fd *iofd, int rc, struct msgb *msg)
 {
+       uint8_t *buf;
        printf("%s: write() returned rc=%d\n", osmo_iofd_get_name(iofd), rc);
+       if (rc == 0) {
+               msg = msgb_alloc(1024, "Test data");
+               buf = msgb_put(msg, sizeof(TESTDATA));
+               memcpy(buf, TESTDATA, sizeof(TESTDATA));
+
+               osmo_iofd_write_msgb(iofd, msg);
+       }
 }

 struct osmo_io_ops ioops_conn_read_write = {
@@ -59,10 +72,6 @@
        .write_cb = write_cb,
 };

-uint8_t TESTDATA[] = {
-       1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16
-};
-
 static void test_connected(void)
 {
        int fds[2] = {0, 0}, rc;
@@ -80,13 +89,6 @@
        iofd2 = osmo_iofd_setup(ctx, fds[1], "ep2", OSMO_IO_FD_MODE_READ_WRITE, 
&ioops_conn_read_write, NULL);
        osmo_iofd_register(iofd2, fds[1]);

-       msg = msgb_alloc(1024, "Test data");
-       buf = msgb_put(msg, sizeof(TESTDATA));
-       memcpy(buf, TESTDATA, sizeof(TESTDATA));
-
-       osmo_iofd_write_msgb(iofd1, msg);
-
-
        /* Allow enough cycles to handle the messages */
        for (int i = 0; i < 128; i++)
                osmo_select_main(1);

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33496
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ibdd26a4aeadfbd6c5039c8a31cc120d3c98be727
Gerrit-Change-Number: 33496
Gerrit-PatchSet: 1
Gerrit-Owner: daniel <dwillm...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to