[MERGED] libosmo-netif[master]: osmux: Use osmo_gettimeofday for testing puroposes
Pau Espin Pedrol has submitted this change and it was merged. Change subject: osmux: Use osmo_gettimeofday for testing puroposes .. osmux: Use osmo_gettimeofday for testing puroposes This way we can use fake time and osmux_test take 700ms instead of >2sec to run. Change-Id: Ic39cab74400aca8262a00c0d06884230b1a15ca3 --- M src/osmux.c M tests/osmux/osmux_test.c 2 files changed, 26 insertions(+), 6 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/osmux.c b/src/osmux.c index 4d12427..d12a39a 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -777,7 +777,7 @@ #ifdef DEBUG_TIMING struct timeval now, diff; - gettimeofday(, NULL); + osmo_gettimeofday(, NULL); timersub(, >start, ); timersub(,>when, ); LOGP(DLMIB, LOGL_DEBUG, "we are lagging %lu.%.6lu in scheduled " @@ -806,7 +806,7 @@ h->timer.data = h; #ifdef DEBUG_TIMING - gettimeofday(>start, NULL); + osmo_gettimeofday(>start, NULL); h->when.tv_sec = when->tv_sec; h->when.tv_usec = when->tv_usec; #endif diff --git a/tests/osmux/osmux_test.c b/tests/osmux/osmux_test.c index 9941ce3..63f89f1 100644 --- a/tests/osmux/osmux_test.c +++ b/tests/osmux/osmux_test.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -54,6 +55,8 @@ 0xf2, 0x26, 0x33, 0x65, 0x54, }; +#define PKT_TIME_USEC 20*1000 + static int rtp_pkts; static int mark_pkts; #if OSMUX_TEST_USE_TIMING @@ -67,7 +70,7 @@ #if OSMUX_TEST_USE_TIMING struct timeval now, diff; - gettimeofday(, NULL); + osmo_gettimeofday(, NULL); timersub(, , ); last = now; @@ -159,10 +162,17 @@ osmux_xfrm_input_deliver(_input); } } +#if !OSMUX_TEST_USE_TIMING + osmo_gettimeofday_override_add(0, PKT_TIME_USEC); +#endif } - while (rtp_pkts) + while (rtp_pkts) { +#if !OSMUX_TEST_USE_TIMING + osmo_gettimeofday_override_add(1, 0); +#endif osmo_select_main(0); + } if (mark_pkts) { fprintf(stdout, "RTP M bit (marker) mismatch! %d\n", mark_pkts); @@ -204,7 +214,7 @@ if (i % 4 == 0) { #if OSMUX_TEST_USE_TIMING - gettimeofday(, NULL); + osmo_gettimeofday(, NULL); #endif /* After four RTP messages, squash them into the OSMUX @@ -217,8 +227,12 @@ * messages that are extracted from OSMUX has been * delivered. */ - for (j = 0; j < k-2; j++) + for (j = 0; j < k-2; j++) { osmo_select_main(0); +#if !OSMUX_TEST_USE_TIMING + osmo_gettimeofday_override_add(0, PKT_TIME_USEC); +#endif + } k = 0; } @@ -239,6 +253,12 @@ exit(EXIT_FAILURE); } +#if !OSMUX_TEST_USE_TIMING + /* This test uses fake time to speedup the run, unless we want to manually +* test time specific stuff */ + osmo_gettimeofday_override = true; +#endif + /* This test doesn't use it, but osmux requires it internally. */ osmo_init_logging(_test_log_info); log_set_log_level(osmo_stderr_target, LOGL_DEBUG); -- To view, visit https://gerrit.osmocom.org/2418 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic39cab74400aca8262a00c0d06884230b1a15ca3 Gerrit-PatchSet: 3 Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Owner: Pau Espin PedrolGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-Reviewer: Pau Espin Pedrol
libosmo-netif[master]: osmux: Use osmo_gettimeofday for testing puroposes
Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/2418 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic39cab74400aca8262a00c0d06884230b1a15ca3 Gerrit-PatchSet: 2 Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Owner: Pau Espin PedrolGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: No
[PATCH] libosmo-netif[master]: osmux: Use osmo_gettimeofday for testing puroposes
Hello Neels Hofmeyr, Harald Welte, Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/2418 to look at the new patch set (#2). osmux: Use osmo_gettimeofday for testing puroposes This way we can use fake time and osmux_test take 700ms instead of >2sec to run. Change-Id: Ic39cab74400aca8262a00c0d06884230b1a15ca3 --- M src/osmux.c M tests/osmux/osmux_test.c 2 files changed, 26 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/18/2418/2 diff --git a/src/osmux.c b/src/osmux.c index 4d12427..d12a39a 100644 --- a/src/osmux.c +++ b/src/osmux.c @@ -777,7 +777,7 @@ #ifdef DEBUG_TIMING struct timeval now, diff; - gettimeofday(, NULL); + osmo_gettimeofday(, NULL); timersub(, >start, ); timersub(,>when, ); LOGP(DLMIB, LOGL_DEBUG, "we are lagging %lu.%.6lu in scheduled " @@ -806,7 +806,7 @@ h->timer.data = h; #ifdef DEBUG_TIMING - gettimeofday(>start, NULL); + osmo_gettimeofday(>start, NULL); h->when.tv_sec = when->tv_sec; h->when.tv_usec = when->tv_usec; #endif diff --git a/tests/osmux/osmux_test.c b/tests/osmux/osmux_test.c index 9941ce3..63f89f1 100644 --- a/tests/osmux/osmux_test.c +++ b/tests/osmux/osmux_test.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -54,6 +55,8 @@ 0xf2, 0x26, 0x33, 0x65, 0x54, }; +#define PKT_TIME_USEC 20*1000 + static int rtp_pkts; static int mark_pkts; #if OSMUX_TEST_USE_TIMING @@ -67,7 +70,7 @@ #if OSMUX_TEST_USE_TIMING struct timeval now, diff; - gettimeofday(, NULL); + osmo_gettimeofday(, NULL); timersub(, , ); last = now; @@ -159,10 +162,17 @@ osmux_xfrm_input_deliver(_input); } } +#if !OSMUX_TEST_USE_TIMING + osmo_gettimeofday_override_add(0, PKT_TIME_USEC); +#endif } - while (rtp_pkts) + while (rtp_pkts) { +#if !OSMUX_TEST_USE_TIMING + osmo_gettimeofday_override_add(1, 0); +#endif osmo_select_main(0); + } if (mark_pkts) { fprintf(stdout, "RTP M bit (marker) mismatch! %d\n", mark_pkts); @@ -204,7 +214,7 @@ if (i % 4 == 0) { #if OSMUX_TEST_USE_TIMING - gettimeofday(, NULL); + osmo_gettimeofday(, NULL); #endif /* After four RTP messages, squash them into the OSMUX @@ -217,8 +227,12 @@ * messages that are extracted from OSMUX has been * delivered. */ - for (j = 0; j < k-2; j++) + for (j = 0; j < k-2; j++) { osmo_select_main(0); +#if !OSMUX_TEST_USE_TIMING + osmo_gettimeofday_override_add(0, PKT_TIME_USEC); +#endif + } k = 0; } @@ -239,6 +253,12 @@ exit(EXIT_FAILURE); } +#if !OSMUX_TEST_USE_TIMING + /* This test uses fake time to speedup the run, unless we want to manually +* test time specific stuff */ + osmo_gettimeofday_override = true; +#endif + /* This test doesn't use it, but osmux requires it internally. */ osmo_init_logging(_test_log_info); log_set_log_level(osmo_stderr_target, LOGL_DEBUG); -- To view, visit https://gerrit.osmocom.org/2418 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ic39cab74400aca8262a00c0d06884230b1a15ca3 Gerrit-PatchSet: 2 Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Owner: Pau Espin PedrolGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr
libosmo-netif[master]: osmux: Use osmo_gettimeofday for testing puroposes
Patch Set 1: Code-Review+1 (1 comment) https://gerrit.osmocom.org/#/c/2418/1/tests/osmux/osmux_test.c File tests/osmux/osmux_test.c: Line 233: osmo_gettimeofday_override_add(0,PKT_TIME_USEC); minor coding style: missing space -- To view, visit https://gerrit.osmocom.org/2418 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ic39cab74400aca8262a00c0d06884230b1a15ca3 Gerrit-PatchSet: 1 Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Owner: Pau Espin PedrolGerrit-Reviewer: Harald Welte Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr Gerrit-HasComments: Yes