2013-05-23 17:58:28 +00:00
|
|
|
/*
|
|
|
|
* (C) 2013 by Pablo Neira Ayuso <pablo@gnumonks.org>
|
|
|
|
* (C) 2013 by On Waves ehf <http://www.on-waves.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
2016-07-07 12:13:16 +00:00
|
|
|
#define OSMUX_TEST_USE_TIMING 0
|
|
|
|
|
2013-05-23 17:58:28 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <arpa/inet.h>
|
2016-07-07 12:13:16 +00:00
|
|
|
#if OSMUX_TEST_USE_TIMING
|
2013-05-23 17:58:28 +00:00
|
|
|
#include <sys/time.h>
|
2016-07-07 12:13:16 +00:00
|
|
|
#endif
|
2013-05-23 17:58:28 +00:00
|
|
|
|
|
|
|
#include <osmocom/core/select.h>
|
|
|
|
#include <osmocom/core/application.h>
|
|
|
|
#include <osmocom/core/logging.h>
|
|
|
|
#include <osmocom/core/msgb.h>
|
|
|
|
#include <osmocom/core/linuxlist.h>
|
2017-04-26 14:00:03 +00:00
|
|
|
#include <osmocom/core/timer.h>
|
2013-05-23 17:58:28 +00:00
|
|
|
#include <osmocom/netif/osmux.h>
|
|
|
|
#include <osmocom/netif/rtp.h>
|
|
|
|
|
|
|
|
#define DOSMUX_TEST 0
|
|
|
|
|
|
|
|
struct log_info_cat osmux_test_cat[] = {
|
|
|
|
[DOSMUX_TEST] = {
|
|
|
|
.name = "DOSMUX_TEST",
|
|
|
|
.description = "osmux test",
|
|
|
|
.color = "\033[1;35m",
|
|
|
|
.enabled = 1, .loglevel = LOGL_DEBUG,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct log_info osmux_test_log_info = {
|
|
|
|
.filter_fn = NULL,
|
|
|
|
.cat = osmux_test_cat,
|
|
|
|
.num_cat = ARRAY_SIZE(osmux_test_cat),
|
|
|
|
};
|
|
|
|
|
|
|
|
/* RTP packet with AMR payload */
|
|
|
|
static uint8_t rtp_pkt[] = {
|
|
|
|
0x80, 0x62, 0x3f, 0xcc, 0x00, 0x01, 0xa7, 0x6f, /* RTP */
|
|
|
|
0x07, 0x09, 0x00, 0x62, 0x20, 0x14, 0xff, 0xd4, /* AMR */
|
|
|
|
0xf9, 0xff, 0xfb, 0xe7, 0xeb, 0xf9, 0x9f, 0xf8,
|
|
|
|
0xf2, 0x26, 0x33, 0x65, 0x54,
|
|
|
|
};
|
|
|
|
|
2017-04-26 14:00:03 +00:00
|
|
|
#define PKT_TIME_USEC 20*1000
|
|
|
|
|
2013-05-23 17:58:28 +00:00
|
|
|
static int rtp_pkts;
|
2017-04-25 15:20:38 +00:00
|
|
|
static int mark_pkts;
|
2016-07-07 12:13:16 +00:00
|
|
|
#if OSMUX_TEST_USE_TIMING
|
2013-05-23 17:58:28 +00:00
|
|
|
static struct timeval last;
|
2016-07-07 12:13:16 +00:00
|
|
|
#endif
|
2013-05-23 17:58:28 +00:00
|
|
|
|
2019-10-04 09:53:08 +00:00
|
|
|
#define clock_debug(fmt, args...) \
|
|
|
|
do { \
|
|
|
|
struct timespec ts; \
|
|
|
|
struct timeval tv; \
|
|
|
|
osmo_clock_gettime(CLOCK_MONOTONIC, &ts); \
|
|
|
|
osmo_gettimeofday(&tv, NULL); \
|
2019-10-04 10:22:54 +00:00
|
|
|
fprintf(stderr, "sys={%lu.%06lu}, mono={%lu.%06lu}: " fmt, \
|
2019-10-04 09:53:08 +00:00
|
|
|
tv.tv_sec, tv.tv_usec, ts.tv_sec, ts.tv_nsec/1000, ##args); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
static void clock_override_enable(bool enable)
|
|
|
|
{
|
|
|
|
osmo_gettimeofday_override = enable;
|
|
|
|
osmo_clock_override_enable(CLOCK_MONOTONIC, enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void clock_override_add_debug(long sec, long usec, bool dbg)
|
|
|
|
{
|
|
|
|
osmo_gettimeofday_override_add(sec, usec);
|
|
|
|
osmo_clock_override_add(CLOCK_MONOTONIC, sec, usec*1000);
|
|
|
|
if (dbg)
|
|
|
|
clock_debug("clock_override_add\n");
|
|
|
|
}
|
2019-10-04 10:22:54 +00:00
|
|
|
#define clock_override_add(sec, usec) clock_override_add_debug(sec, usec, true)
|
2019-10-04 09:53:08 +00:00
|
|
|
|
2013-05-23 17:58:28 +00:00
|
|
|
static void tx_cb(struct msgb *msg, void *data)
|
|
|
|
{
|
2017-04-25 15:20:38 +00:00
|
|
|
struct rtp_hdr *rtph = (struct rtp_hdr *)msg->data;
|
osmux: fix buffer management mess in snprintf() calls
SNPRINTF_BUFFER_SIZE() looks too complex, previous version maintains two
different variables to account for the remaining space in the buffer,
one of them is always decremented based on what snprintf() returns,
which may result in underflow. These variables are swapped - not used
consistently - all over this code.
Replace this macro by a simplified version, with one single parameter to
account for remaining space. This macro also deals with two corner
cases:
1) snprintf() fails, actually never happens in practise, but
documentation indicates it may return -1, so let's catch this case
from here to stick to specs.
2) There is not enough space in the buffer, in that case, keep
increasing offset, so we know how much would have been printed, just
like snprintf() does.
Thanks to Pau Espin for reporting, and Holger for clues on this.
I have run osmux_test and, at quick glance, it looks good.
Change-Id: I5b5d6ec57a02f57c23b1ae86dbd894bad28ea797
2017-09-04 18:35:36 +00:00
|
|
|
char buf[4096];
|
2016-07-07 12:13:16 +00:00
|
|
|
#if OSMUX_TEST_USE_TIMING
|
2013-05-23 17:58:28 +00:00
|
|
|
struct timeval now, diff;
|
|
|
|
|
2017-04-26 14:00:03 +00:00
|
|
|
osmo_gettimeofday(&now, NULL);
|
2013-05-23 17:58:28 +00:00
|
|
|
timersub(&now, &last, &diff);
|
|
|
|
last = now;
|
|
|
|
|
2013-05-27 09:12:52 +00:00
|
|
|
if (diff.tv_usec > 2*17000) {
|
2019-10-04 10:22:54 +00:00
|
|
|
clock_debug("delivery of reconstructed RTP lagged"
|
2016-02-29 14:49:10 +00:00
|
|
|
" (diff.tv_usec=%u > 2*17000)\n",
|
|
|
|
(unsigned int)diff.tv_usec);
|
2013-05-23 17:58:28 +00:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2016-07-07 12:13:16 +00:00
|
|
|
#endif
|
2013-05-23 17:58:28 +00:00
|
|
|
|
|
|
|
osmo_rtp_snprintf(buf, sizeof(buf), msg);
|
2019-10-04 10:22:54 +00:00
|
|
|
clock_debug("extracted packet: %s\n", buf);
|
2013-05-23 17:58:28 +00:00
|
|
|
|
|
|
|
if (memcmp(msg->data + sizeof(struct rtp_hdr),
|
|
|
|
rtp_pkt + sizeof(struct rtp_hdr),
|
|
|
|
sizeof(rtp_pkt) - sizeof(struct rtp_hdr)) != 0) {
|
2019-10-04 10:22:54 +00:00
|
|
|
clock_debug("payload mismatch!\n");
|
2013-05-23 17:58:28 +00:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2017-04-25 15:20:38 +00:00
|
|
|
if (rtph->marker)
|
|
|
|
mark_pkts--;
|
2013-05-23 17:58:28 +00:00
|
|
|
rtp_pkts--;
|
2015-07-21 08:46:41 +00:00
|
|
|
msgb_free(msg);
|
2013-05-23 17:58:28 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 15:28:36 +00:00
|
|
|
static struct osmux_out_handle *h_output;
|
2013-05-23 17:58:28 +00:00
|
|
|
|
|
|
|
static void osmux_deliver(struct msgb *batch_msg, void *data)
|
|
|
|
{
|
|
|
|
struct osmux_hdr *osmuxh;
|
osmux: fix buffer management mess in snprintf() calls
SNPRINTF_BUFFER_SIZE() looks too complex, previous version maintains two
different variables to account for the remaining space in the buffer,
one of them is always decremented based on what snprintf() returns,
which may result in underflow. These variables are swapped - not used
consistently - all over this code.
Replace this macro by a simplified version, with one single parameter to
account for remaining space. This macro also deals with two corner
cases:
1) snprintf() fails, actually never happens in practise, but
documentation indicates it may return -1, so let's catch this case
from here to stick to specs.
2) There is not enough space in the buffer, in that case, keep
increasing offset, so we know how much would have been printed, just
like snprintf() does.
Thanks to Pau Espin for reporting, and Holger for clues on this.
I have run osmux_test and, at quick glance, it looks good.
Change-Id: I5b5d6ec57a02f57c23b1ae86dbd894bad28ea797
2017-09-04 18:35:36 +00:00
|
|
|
char buf[2048];
|
2013-05-23 17:58:28 +00:00
|
|
|
|
|
|
|
osmux_snprintf(buf, sizeof(buf), batch_msg);
|
2019-10-04 10:22:54 +00:00
|
|
|
clock_debug("OSMUX message (len=%d): %s\n", batch_msg->len, buf);
|
2013-05-23 17:58:28 +00:00
|
|
|
|
|
|
|
/* For each OSMUX message, extract the RTP messages and put them
|
|
|
|
* in a list. Then, reconstruct transmission timing.
|
|
|
|
*/
|
2018-04-19 10:29:45 +00:00
|
|
|
while((osmuxh = osmux_xfrm_output_pull(batch_msg)) != NULL)
|
2022-08-31 15:28:36 +00:00
|
|
|
osmux_xfrm_output_sched(h_output, osmuxh);
|
2015-07-21 08:46:41 +00:00
|
|
|
msgb_free(batch_msg);
|
2013-05-23 17:58:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct osmux_in_handle h_input = {
|
|
|
|
.osmux_seq = 0, /* sequence number to start OSmux message from */
|
|
|
|
.batch_factor = 4, /* batch up to 4 RTP messages */
|
|
|
|
.deliver = osmux_deliver,
|
|
|
|
};
|
|
|
|
|
2013-05-24 09:22:41 +00:00
|
|
|
static void sigalarm_handler(int foo)
|
|
|
|
{
|
2019-10-04 10:22:54 +00:00
|
|
|
clock_debug("FAIL: test did not run successfully\n");
|
2013-05-24 09:22:41 +00:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2017-04-25 15:20:38 +00:00
|
|
|
static void osmux_test_marker(int ccid) {
|
|
|
|
struct msgb *msg;
|
|
|
|
struct rtp_hdr *rtph = (struct rtp_hdr *)rtp_pkt;
|
|
|
|
struct rtp_hdr *cpy_rtph;
|
|
|
|
uint16_t seq;
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = 0; i < 64; i++) {
|
|
|
|
|
|
|
|
seq = ntohs(rtph->sequence);
|
|
|
|
seq++;
|
|
|
|
rtph->sequence = htons(seq);
|
|
|
|
|
|
|
|
for (j=0; j<4; j++) {
|
|
|
|
msg = msgb_alloc(1500, "test");
|
|
|
|
if (!msg)
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
|
|
|
memcpy(msg->data, rtp_pkt, sizeof(rtp_pkt));
|
|
|
|
cpy_rtph = (struct rtp_hdr *) msgb_put(msg, sizeof(rtp_pkt));
|
|
|
|
|
2018-04-18 17:10:20 +00:00
|
|
|
/* first condition guarantees that 1st packet per stream contains M bit set. */
|
|
|
|
if (i == 0 || (i+j) % 7 == 0) {
|
2017-04-25 15:20:38 +00:00
|
|
|
cpy_rtph->marker = 1;
|
|
|
|
mark_pkts++;
|
|
|
|
}
|
|
|
|
|
|
|
|
rtp_pkts++;
|
|
|
|
while (osmux_xfrm_input(&h_input, msg, j + ccid) > 0) {
|
|
|
|
osmux_xfrm_input_deliver(&h_input);
|
|
|
|
}
|
|
|
|
}
|
2017-04-26 14:00:03 +00:00
|
|
|
#if !OSMUX_TEST_USE_TIMING
|
2019-10-04 09:53:08 +00:00
|
|
|
clock_override_add(0, PKT_TIME_USEC);
|
2017-04-26 14:00:03 +00:00
|
|
|
#endif
|
2017-04-25 15:20:38 +00:00
|
|
|
}
|
|
|
|
|
2017-04-26 14:00:03 +00:00
|
|
|
while (rtp_pkts) {
|
|
|
|
#if !OSMUX_TEST_USE_TIMING
|
2019-10-04 09:53:08 +00:00
|
|
|
clock_override_add(1, 0);
|
2017-04-26 14:00:03 +00:00
|
|
|
#endif
|
2017-04-25 15:20:38 +00:00
|
|
|
osmo_select_main(0);
|
2017-04-26 14:00:03 +00:00
|
|
|
}
|
2017-04-25 15:20:38 +00:00
|
|
|
|
|
|
|
if (mark_pkts) {
|
2019-10-04 10:22:54 +00:00
|
|
|
clock_debug("osmux_test_marker: RTP M bit (marker) mismatch! %d\n", mark_pkts);
|
2017-04-25 15:20:38 +00:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-21 08:17:42 +00:00
|
|
|
static void osmux_test_loop(int ccid)
|
2013-05-23 17:58:28 +00:00
|
|
|
{
|
osmux: fix buffer management mess in snprintf() calls
SNPRINTF_BUFFER_SIZE() looks too complex, previous version maintains two
different variables to account for the remaining space in the buffer,
one of them is always decremented based on what snprintf() returns,
which may result in underflow. These variables are swapped - not used
consistently - all over this code.
Replace this macro by a simplified version, with one single parameter to
account for remaining space. This macro also deals with two corner
cases:
1) snprintf() fails, actually never happens in practise, but
documentation indicates it may return -1, so let's catch this case
from here to stick to specs.
2) There is not enough space in the buffer, in that case, keep
increasing offset, so we know how much would have been printed, just
like snprintf() does.
Thanks to Pau Espin for reporting, and Holger for clues on this.
I have run osmux_test and, at quick glance, it looks good.
Change-Id: I5b5d6ec57a02f57c23b1ae86dbd894bad28ea797
2017-09-04 18:35:36 +00:00
|
|
|
struct rtp_hdr *rtph = (struct rtp_hdr *)rtp_pkt;
|
2018-04-18 17:10:20 +00:00
|
|
|
struct rtp_hdr *cpy_rtph;
|
2013-05-23 17:58:28 +00:00
|
|
|
struct msgb *msg;
|
osmux: fix buffer management mess in snprintf() calls
SNPRINTF_BUFFER_SIZE() looks too complex, previous version maintains two
different variables to account for the remaining space in the buffer,
one of them is always decremented based on what snprintf() returns,
which may result in underflow. These variables are swapped - not used
consistently - all over this code.
Replace this macro by a simplified version, with one single parameter to
account for remaining space. This macro also deals with two corner
cases:
1) snprintf() fails, actually never happens in practise, but
documentation indicates it may return -1, so let's catch this case
from here to stick to specs.
2) There is not enough space in the buffer, in that case, keep
increasing offset, so we know how much would have been printed, just
like snprintf() does.
Thanks to Pau Espin for reporting, and Holger for clues on this.
I have run osmux_test and, at quick glance, it looks good.
Change-Id: I5b5d6ec57a02f57c23b1ae86dbd894bad28ea797
2017-09-04 18:35:36 +00:00
|
|
|
int i, j, k = 0;
|
2013-05-23 17:58:28 +00:00
|
|
|
char buf[1024];
|
|
|
|
uint16_t seq;
|
|
|
|
|
2015-07-21 09:11:26 +00:00
|
|
|
for (i = 1; i < 65; i++) {
|
2013-05-23 17:58:28 +00:00
|
|
|
msg = msgb_alloc(1500, "test");
|
|
|
|
if (!msg)
|
2015-07-21 08:17:42 +00:00
|
|
|
exit(EXIT_FAILURE);
|
2013-05-23 17:58:28 +00:00
|
|
|
|
|
|
|
memcpy(msg->data, rtp_pkt, sizeof(rtp_pkt));
|
2018-04-18 17:10:20 +00:00
|
|
|
cpy_rtph = (struct rtp_hdr *) msgb_put(msg, sizeof(rtp_pkt));
|
2013-05-23 17:58:28 +00:00
|
|
|
|
|
|
|
seq = ntohs(rtph->sequence);
|
|
|
|
seq++;
|
|
|
|
rtph->sequence = htons(seq);
|
2018-04-18 17:10:20 +00:00
|
|
|
if (i < 3) {
|
|
|
|
/* Mark 1 rtp packet of each stream */
|
|
|
|
cpy_rtph->marker = 1;
|
|
|
|
mark_pkts++;
|
|
|
|
}
|
2013-05-23 17:58:28 +00:00
|
|
|
|
|
|
|
osmo_rtp_snprintf(buf, sizeof(buf), msg);
|
2019-10-04 10:22:54 +00:00
|
|
|
clock_debug("adding to ccid=%u %s\n", (i % 2) + ccid, buf);
|
2013-05-23 17:58:28 +00:00
|
|
|
rtp_pkts++;
|
|
|
|
|
2013-05-24 11:12:14 +00:00
|
|
|
k++;
|
2013-12-16 09:41:15 +00:00
|
|
|
/* Fan out RTP packets between two circuit IDs to test
|
2013-12-16 10:59:01 +00:00
|
|
|
* multi-batch support. Mind that this approach implicitly add
|
|
|
|
* gaps between two messages to test the osmux replaying
|
|
|
|
* feature.
|
2013-12-16 09:41:15 +00:00
|
|
|
*/
|
2015-07-21 08:17:42 +00:00
|
|
|
osmux_xfrm_input(&h_input, msg, (i % 2) + ccid);
|
2013-05-24 11:12:14 +00:00
|
|
|
|
2013-05-23 17:58:28 +00:00
|
|
|
if (i % 4 == 0) {
|
2016-07-07 12:13:16 +00:00
|
|
|
#if OSMUX_TEST_USE_TIMING
|
2017-04-26 14:00:03 +00:00
|
|
|
osmo_gettimeofday(&last, NULL);
|
2016-07-07 12:13:16 +00:00
|
|
|
#endif
|
2013-05-23 17:58:28 +00:00
|
|
|
|
|
|
|
/* After four RTP messages, squash them into the OSMUX
|
|
|
|
* batch and call the routine to deliver it.
|
|
|
|
*/
|
|
|
|
osmux_xfrm_input_deliver(&h_input);
|
|
|
|
|
2013-12-16 09:41:15 +00:00
|
|
|
/* The first two RTP message (one per circuit ID batch)
|
|
|
|
* are delivered immediately, wait until the three RTP
|
|
|
|
* messages that are extracted from OSMUX has been
|
|
|
|
* delivered.
|
2013-05-23 17:58:28 +00:00
|
|
|
*/
|
2017-04-26 14:00:03 +00:00
|
|
|
for (j = 0; j < k-2; j++) {
|
2013-05-23 17:58:28 +00:00
|
|
|
osmo_select_main(0);
|
2017-04-26 14:00:03 +00:00
|
|
|
#if !OSMUX_TEST_USE_TIMING
|
2019-10-04 09:53:08 +00:00
|
|
|
clock_override_add(0, PKT_TIME_USEC);
|
2017-04-26 14:00:03 +00:00
|
|
|
#endif
|
|
|
|
}
|
2013-05-24 11:12:14 +00:00
|
|
|
|
|
|
|
k = 0;
|
2013-05-23 17:58:28 +00:00
|
|
|
}
|
|
|
|
}
|
2017-04-25 15:20:38 +00:00
|
|
|
|
|
|
|
if (mark_pkts) {
|
2019-10-04 10:22:54 +00:00
|
|
|
clock_debug("osmux_test_loop: RTP M bit (marker) mismatch! %d\n", mark_pkts);
|
2017-04-25 15:20:38 +00:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2015-07-21 08:17:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (signal(SIGALRM, sigalarm_handler) == SIG_ERR) {
|
|
|
|
perror("signal");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
2017-04-26 14:00:03 +00:00
|
|
|
#if !OSMUX_TEST_USE_TIMING
|
|
|
|
/* This test uses fake time to speedup the run, unless we want to manually
|
|
|
|
* test time specific stuff */
|
2019-10-04 09:53:08 +00:00
|
|
|
clock_override_enable(true);
|
2017-04-26 14:00:03 +00:00
|
|
|
#endif
|
|
|
|
|
2015-07-21 08:17:42 +00:00
|
|
|
/* This test doesn't use it, but osmux requires it internally. */
|
2018-04-17 09:41:13 +00:00
|
|
|
void *tall_ctx = talloc_named_const(NULL, 1, "Root context");
|
|
|
|
msgb_talloc_ctx_init(tall_ctx, 0);
|
|
|
|
osmo_init_logging2(tall_ctx, &osmux_test_log_info);
|
2015-07-21 08:17:42 +00:00
|
|
|
log_set_log_level(osmo_stderr_target, LOGL_DEBUG);
|
2019-10-04 10:22:54 +00:00
|
|
|
log_set_print_filename2(osmo_stderr_target, LOG_FILENAME_NONE);
|
|
|
|
log_set_print_category(osmo_stderr_target, 1);
|
|
|
|
log_set_print_category_hex(osmo_stderr_target, 0);
|
2019-11-20 04:03:37 +00:00
|
|
|
log_set_use_color(osmo_stderr_target, 0);
|
2015-07-21 08:17:42 +00:00
|
|
|
|
2022-08-31 15:28:36 +00:00
|
|
|
h_output = osmux_xfrm_output_alloc(NULL);
|
|
|
|
osmux_xfrm_output_set_rtp_ssrc(h_output, 0x7000000);
|
|
|
|
osmux_xfrm_output_set_rtp_pl_type(h_output, 98);
|
|
|
|
osmux_xfrm_output_set_tx_cb(h_output, tx_cb, NULL);
|
2019-10-16 09:42:56 +00:00
|
|
|
/* These fields are set using random() */
|
2022-08-31 15:28:36 +00:00
|
|
|
h_output->rtp_seq = 9158;
|
|
|
|
h_output->rtp_timestamp = 1681692777;
|
2015-07-21 08:17:42 +00:00
|
|
|
|
|
|
|
/* If the test takes longer than 10 seconds, abort it */
|
|
|
|
alarm(10);
|
|
|
|
|
2017-04-25 15:20:38 +00:00
|
|
|
#if !OSMUX_TEST_USE_TIMING
|
|
|
|
/* Check if marker bit features work correctly */
|
|
|
|
osmux_xfrm_input_init(&h_input);
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
osmux_xfrm_input_open_circuit(&h_input, i, 0);
|
|
|
|
osmux_test_marker(0);
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
osmux_xfrm_input_close_circuit(&h_input, i);
|
|
|
|
osmux_xfrm_input_fini(&h_input);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
osmux_xfrm_input_init(&h_input);
|
|
|
|
|
2015-07-21 08:17:42 +00:00
|
|
|
for (i = 0; i < 2; i++)
|
|
|
|
osmux_xfrm_input_open_circuit(&h_input, i, 0);
|
|
|
|
|
|
|
|
/* Add two circuits with dummy padding */
|
|
|
|
osmux_xfrm_input_open_circuit(&h_input, 2, 1);
|
|
|
|
osmux_xfrm_input_open_circuit(&h_input, 3, 1);
|
|
|
|
|
2015-07-21 08:31:44 +00:00
|
|
|
/* Wait 10 times to make sure dummy padding timer works fine */
|
|
|
|
for (i = 0; i < 10; i++)
|
|
|
|
osmo_select_main(0);
|
|
|
|
|
2015-07-21 08:17:42 +00:00
|
|
|
/* Start pushing voice data to circuits 0 and 1 */
|
|
|
|
osmux_test_loop(0);
|
2015-07-21 08:20:54 +00:00
|
|
|
/* ... now start pushing voice data to circuits 2 and 3. This circuits
|
|
|
|
* comes with dummy padding enabled.
|
|
|
|
*/
|
|
|
|
osmux_test_loop(2);
|
2015-07-20 19:01:58 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
osmux_xfrm_input_close_circuit(&h_input, i);
|
|
|
|
|
2015-07-21 08:37:29 +00:00
|
|
|
/* Reopen with two circuits and retest */
|
|
|
|
osmux_xfrm_input_open_circuit(&h_input, 0, 0);
|
|
|
|
osmux_xfrm_input_open_circuit(&h_input, 1, 1);
|
|
|
|
osmux_test_loop(0);
|
|
|
|
osmux_xfrm_input_close_circuit(&h_input, 0);
|
|
|
|
osmux_xfrm_input_close_circuit(&h_input, 1);
|
|
|
|
|
2015-07-20 19:01:58 +00:00
|
|
|
osmux_xfrm_input_fini(&h_input);
|
|
|
|
|
2019-10-04 10:22:54 +00:00
|
|
|
clock_debug("OK: Test passed\n");
|
2013-05-23 17:58:28 +00:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|