daniel has submitted this change. ( 
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
M tests/osmo_io/osmo_io_test.ok
2 files changed, 27 insertions(+), 14 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  fixeria: Looks good to me, but someone else must approve
  daniel: Looks good to me, approved




diff --git a/tests/osmo_io/osmo_io_test.c b/tests/osmo_io/osmo_io_test.c
index 3683ee3..a42e6d0 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,16 +72,10 @@
        .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;
        struct osmo_io_fd *iofd1, *iofd2;
-       struct msgb *msg;
-       uint8_t *buf;

        TEST_START();

@@ -80,13 +87,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);
diff --git a/tests/osmo_io/osmo_io_test.ok b/tests/osmo_io/osmo_io_test.ok
index 43e5464..82a6f38 100644
--- a/tests/osmo_io/osmo_io_test.ok
+++ b/tests/osmo_io/osmo_io_test.ok
@@ -1,6 +1,10 @@
 Running test_connected
-ep1: write() returned rc=16
+ep1: write() returned rc=0
 ep2: write() returned rc=0
+ep1: write() returned rc=16
+ep2: write() returned rc=16
+ep1: read() msg with len=16
+01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10
 ep2: read() msg with len=16
 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10
 Running test_unconnected

--
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: 4
Gerrit-Owner: daniel <dwillm...@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillm...@sysmocom.de>
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: pespin <pes...@sysmocom.de>
Gerrit-MessageType: merged

Reply via email to