add new RLC AM test for checking correct stopping

This commit is contained in:
Andre Puschmann 2018-07-30 14:56:22 +02:00
parent 3234add1f8
commit 1160dac54f
1 changed files with 83 additions and 0 deletions

View File

@ -27,11 +27,13 @@
#include <iostream>
#include "srslte/common/log_filter.h"
#include "srslte/common/logger_stdout.h"
#include "srslte/common/threads.h"
#include "srslte/upper/rlc_am.h"
#include "srslte/common/rlc_pcap.h"
#include <assert.h>
#define NBUFS 5
#define HAVE_PCAP 0
#define SDU_SIZE 500
using namespace srsue;
using namespace srslte;
@ -91,6 +93,48 @@ public:
rlc_pcap *pcap;
};
class ul_writer : public thread
{
public:
ul_writer(rlc_am* rlc_) : rlc(rlc_), running(false) {}
~ul_writer() { stop(); }
void stop()
{
running = false;
int cnt=0;
while(running && cnt<100) {
usleep(10000);
cnt++;
}
wait_thread_finish();
}
private:
void run_thread() {
int sn = 0;
running = true;
while(running) {
byte_buffer_t *pdu = byte_buffer_pool::get_instance()->allocate("rlc_tester::run_thread", true);
if (!pdu) {
printf("Error: Could not allocate PDU in rlc_tester::run_thread\n\n\n");
// backoff for a bit
usleep(1000);
continue;
}
for (uint32_t i = 0; i < SDU_SIZE; i++) {
pdu->msg[i] = sn;
}
sn++;
pdu->N_bytes = SDU_SIZE;
rlc->write_sdu(pdu);
}
running = false;
}
rlc_am* rlc;
bool running;
};
void basic_test()
{
srslte::log_filter log1("RLC_AM_1");
@ -1432,6 +1476,42 @@ void reset_test()
assert(0 == rlc1.get_buffer_state());
}
void stop_test()
{
srslte::log_filter log1("RLC_AM_1");
log1.set_level(srslte::LOG_LEVEL_DEBUG);
log1.set_hex_limit(-1);
rlc_am_tester tester;
mac_dummy_timers timers;
rlc_am rlc1;
log1.set_level(srslte::LOG_LEVEL_DEBUG);
rlc1.init(&log1, 1, &tester, &tester, &timers);
LIBLTE_RRC_RLC_CONFIG_STRUCT cnfg;
cnfg.rlc_mode = LIBLTE_RRC_RLC_MODE_AM;
cnfg.dl_am_rlc.t_reordering = LIBLTE_RRC_T_REORDERING_MS5;
cnfg.dl_am_rlc.t_status_prohibit = LIBLTE_RRC_T_STATUS_PROHIBIT_MS5;
cnfg.ul_am_rlc.max_retx_thresh = LIBLTE_RRC_MAX_RETX_THRESHOLD_T4;
cnfg.ul_am_rlc.poll_byte = LIBLTE_RRC_POLL_BYTE_KB25;
cnfg.ul_am_rlc.poll_pdu = LIBLTE_RRC_POLL_PDU_P4;
cnfg.ul_am_rlc.t_poll_retx = LIBLTE_RRC_T_POLL_RETRANSMIT_MS5;
rlc1.configure(&cnfg);
// start thread reading
ul_writer writer(&rlc1);
writer.start(-2);
// let writer thread block on tx_queue
usleep(1e6);
// stop RLC1
rlc1.stop();
}
int main(int argc, char **argv) {
basic_test();
byte_buffer_pool::get_instance()->cleanup();
@ -1471,4 +1551,7 @@ int main(int argc, char **argv) {
reset_test();
byte_buffer_pool::get_instance()->cleanup();
stop_test();
byte_buffer_pool::get_instance()->cleanup();
}